id_tache = $id_tache;
}
//formulaire spécifique au type de tâche
function show_form ($param='') {
global $msg;
global $base_path, $type_task_id, $planificateur_id;
global $subaction;
if ($subaction == 'change') {
global $source_entrepot, $connecteurId;
} else {
if (is_array($param)) {
foreach ($param as $aparam=>$aparamv) {
if (is_array($aparamv)) {
foreach ($aparamv as $sparam=>$sparamv) {
global $$sparam;
$$sparam = $sparamv;
}
} else {
global $$aparam;
$$aparam = $aparamv;
}
}
}
}
$f_select .= "
";
$f_select .= "";
$f_select .= "";
//liste des entrepots synchronisable
$form_task .= "
".
$f_select
."
";
$form_task .= "
";
if ($source_entrepot) {
if ($connecteurId) {
require_once($base_path."/admin/connecteurs/in/".$contrs->catalog[$connecteurId]["PATH"]."/".$contrs->catalog[$connecteurId]["NAME"].".class.php");
eval("\$conn=new ".$contrs->catalog[$connecteurId]["NAME"]."(\"".$base_path."/admin/connecteurs/in/".$contrs->catalog[$connecteurId]["PATH"]."\");");
//Si on doit afficher un formulaire de synchronisation
$syncr_form = $conn->form_pour_maj_entrepot($source_entrepot,"planificateur_form");
if ($syncr_form) {
$form_task .= $syncr_form;
}
}
}
$form_task .= "
".$msg['40']." ".$msg['39']."
";
return $form_task;
}
function task_execution() {
global $base_path, $dbh, $msg, $PMBusername;
if (SESSrights & ADMINISTRATION_AUTH) {
if (file_exists($base_path."/admin/connecteurs/in/catalog_subst.xml"))
$catalog=$base_path."/admin/connecteurs/in/catalog_subst.xml";
else
$catalog=$base_path."/admin/connecteurs/in/catalog.xml";
$xml=file_get_contents($catalog);
$param=_parser_text_no_function_($xml,"CATALOG");
$tparameters = $this->unserialize_task_params();
if (isset($tparameters)) {
if (is_array($tparameters)) {
foreach ($tparameters as $aparameters=>$aparametersv) {
if (is_array($aparametersv)) {
foreach ($aparametersv as $sparameters=>$sparametersv) {
global $$sparameters;
$$sparameters = $sparametersv;
}
} else {
global $$aparameters;
$$aparameters = $aparametersv;
}
}
}
}
$this->id_source = $source_entrepot;
if ($this->id_source) {
$rqt = "select id_connector, name from connectors_sources where source_id=".$this->id_source;
$res = mysql_query($rqt);
$path = mysql_result($res,0,"id_connector");
$name = mysql_result($res,0,"name");
for ($i=0; $iid_connector = $item["ID"];
$result = array();
$this->report[] = "
".$this->msg["report_sync"]." : ".$name."
";
if (method_exists($this->proxy, "pmbesSync_doSync")) {
$result[] = $this->proxy->pmbesSync_doSync($this->id_connector, $this->id_source, $auto_import, $this->id_tache, array(&$this, "listen_commande"), array(&$this, "traite_commande"));
if ($result) {
foreach ($result as $lignes) {
foreach ($lignes as $ligne) {
if ($ligne != '') {
$htmlOutput = "
";
}
}
function traite_commande($cmd,$message) {
global $msg;
switch ($cmd) {
case RESUME:
$this->send_command(RUNNING);
break;
case SUSPEND:
$this->suspend_sync();
break;
case STOP:
$this->report[] = "
".$this->msg["planificateur_stop_sync"]."
";
$this->finalize($this->id_tache);
die();
break;
case ABORT:
$requete="delete from source_sync where source_id=".$this->id_source;
mysql_query($requete);
$this->report[] = "
".$this->msg["planificateur_abort_sync"]."
";
$this->finalize($this->id_tache);
die();
break;
case FAIL :
$requete="delete from source_sync where source_id=".$this->id_source;
mysql_query($requete);
$this->report[] = "
".$msg["planificateur_timeout_overtake"]."
";
$this->finalize($this->id_tache);
die();
break;
}
}
function make_serialized_task_params() {
global $base_path, $source_entrepot, $connecteurId;
global $auto_import;
$t = parent::make_serialized_task_params();
if ($source_entrepot) {
$t["source_entrepot"]=$source_entrepot;
$t["connecteurId"]=$connecteurId;
if ($connecteurId) {
$contrs=new connecteurs();
require_once($base_path."/admin/connecteurs/in/".$contrs->catalog[$connecteurId]["PATH"]."/".$contrs->catalog[$connecteurId]["NAME"].".class.php");
eval("\$conn=new ".$contrs->catalog[$connecteurId]["NAME"]."(\"".$base_path."/admin/connecteurs/in/".$contrs->catalog[$connecteurId]["PATH"]."\");");
//Propre au connecteur
$t["envt"]=$conn->get_maj_environnement($source_entrepot);
}
}
if($auto_import){
$t['auto_import'] = ($auto_import ? true : false);
}
return serialize($t);
}
function unserialize_task_params() {
$params = $this->get_task_params();
return $params;
}
function suspend_sync() {
while ($this->statut == SUSPENDED) {
sleep(20);
$this->statut = $this->listen_commande(array(&$this,"traite_commande"));
}
}
function flush_sync() {
// if ($id) {
// $contrs=new connecteurs();
// require_once($base_path."/admin/connecteurs/in/".$contrs->catalog[$id]["PATH"]."/".$contrs->catalog[$id]["NAME"].".class.php");
// eval("\$conn=new ".$contrs->catalog[$id]["NAME"]."(\"".$base_path."/admin/connecteurs/in/".$contrs->catalog[$id]["PATH"]."\");");
// if (($source_id)&&($conn)) {
// $conn->del_notices($source_id);
// }
// $sql = "UPDATE connectors_sources SET last_sync_date = '0000-00-00 00:00:00' WHERE source_id = $source_id ";
// mysql_query($sql);
// }
}
}