get_class_name($valeur[$i]);
require_once($base_path."/admin/connecteurs/in/$source/$source.class.php");
eval("\$src=new $source(\"".$base_path."/admin/connecteurs/in/".$source."\");");
$params=$src->get_source_params($valeur[$i]);
if ($params["REPOSITORY"]==2) {
$source_id=$valeur[$i];
$source_name_sql = "SELECT name FROM connectors_sources WHERE source_id = ".addslashes($source_id);
$source_name = mysql_result(mysql_query($source_name_sql), 0, 0);
$unimarc_query=$this->search->make_unimarc_query();
$search_id=md5(serialize($unimarc_query));
//Suppression des vieilles notices
//Vérification du ttl
$ttl=$params["TTL"];
$requete="delete from entrepot_source_$source_id where unix_timestamp(now())-unix_timestamp(date_import)>".$ttl.';';
mysql_query($requete);
$requete="select count(1) from entrepot_source_$source_id where search_id='".addslashes($search_id)."'";
$resultat=mysql_query($requete);
$search_exists=mysql_result($resultat,0,0);
$requete="select count(1) from entrepot_source_$source_id where search_id='".addslashes($search_id)."' and unix_timestamp(now())-unix_timestamp(date_import)>".$ttl;
$resultat=mysql_query($requete);
if ((mysql_result($resultat,0,0)) || ((!mysql_result($resultat,0,0))&&(!$search_exists))) {
//Recherche si on a le droit
$flag_search=true;
$requete="select (unix_timestamp(now())-unix_timestamp(date_sync)) as sec from source_sync where source_id=$source_id";
$res_sync=mysql_query($requete);
if (mysql_num_rows($res_sync)) {
$rsync=mysql_fetch_object($res_sync);
if ($rsync->sec>300) {
mysql_query("delete from source_sync where source_id=".$source_id);
} else $flag_search=false;
}
if ($flag_search) {
$flag_error=false;
for ($j=0; $j<$params["RETRY"]; $j++) {
$src->search($valeur[$i],$unimarc_query,$search_id);
if (!$src->error)
break;
else {
$flag_error=true;
$error_messages[$source_name][] = $src->error_message;
/*print $src->error_message."
"*/;
}
}
//Il y a eu trois essais infructueux, on d�sactive pendant 5 min !!
if ($flag_error) {
mysql_query("insert into source_sync (source_id,date_sync,cancel) values($source_id,now(),2)");
$error_messages[$source_name][] = sprintf($msg["externalsource_isblocked"], date("H:i", time() + 5*60));
}
}
}
}
}
if ($error_messages) {
echo ''.$msg["externalsource_error"].": ";
foreach ($error_messages as $aname => $aerror_messages) {
$aerror_messages = array_unique($aerror_messages);
print ''.$aname.'';
print " ";
}
echo '
';
}
//Sources
$tvaleur=array();
for ($i=0; $in_ligne;
//$requete="create temporary table ".$t_table." select distinct recid as notice_id from entrepots where source_id in (".implode(",",$valeur).")";
$requete="create temporary table ".$t_table." (notice_id integer unsigned not null)";
mysql_query($requete);
return $t_table;
}
//fonction de traduction litterale de la requete effectuee (renvoie un tableau des termes saisis)
function make_human_query() {
global $msg;
global $include_path;
$litteral=array();
//R�cup�ration de la valeur de saisie
$valeur_="field_".$this->n_ligne."_s_".$this->id;
global $$valeur_;
$valeur=$$valeur_;
$requete="select name from connectors_sources where source_id in (".implode(",",$valeur).")";
$resultat=mysql_query($requete);
while ($r=mysql_fetch_object($resultat)) {
$litteral[]=$r->name;
}
return $litteral;
}
function make_unimarc_query() {
return array();
}
//fonction de v�rification du champ saisi ou s�lectionn�
function is_empty($valeur) {
if (count($valeur)) return false; else return true;
}
}
?>