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 = pmb_mysql_result(pmb_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.';';
pmb_mysql_query($requete);
$requete="select count(1) from entrepot_source_$source_id where search_id='".addslashes($search_id)."'";
$resultat=pmb_mysql_query($requete);
$search_exists=pmb_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=pmb_mysql_query($requete);
if ((pmb_mysql_result($resultat,0,0)) || ((!pmb_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=pmb_mysql_query($requete);
if (pmb_mysql_num_rows($res_sync)) {
$rsync=pmb_mysql_fetch_object($res_sync);
if ($rsync->sec>300) {
pmb_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) {
pmb_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)";
pmb_mysql_query($requete);
return $t_table;
}
//fonction de traduction littérale de la requête effectuée (renvoie un tableau des termes saisis)
public 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_};
if(isset($valeur) && is_array($valeur) && count($valeur)){
$requete="select name from connectors_sources where source_id in (".implode(",",$valeur).")";
$resultat=pmb_mysql_query($requete);
while ($r=pmb_mysql_fetch_object($resultat)) {
$litteral[]=$r->name;
}
}
return $litteral;
}
public function make_unimarc_query() {
return array();
}
//fonction de vérification du champ saisi ou sélectionné
public function is_empty($valeur) {
if (count($valeur)) return false; else return true;
}
}
?>