id_tache = $id_tache; } //formulaire spécifique au type de tâche function show_form ($param='') { global $subaction,$dbh,$aff_list, $msg; global $pmb_procedure_server_credentials, $pmb_procedure_server_address; if ($subaction == 'change') { global $type_proc, $form_procs, $form_procs_remote; } 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; } } } } $form_task .= ""; // Procédure interne ou Procédure distante ?? $form_task .= "
".$this->msg["planificateur_proc_internal"]." ".$this->msg["planificateur_proc_remote"]."
 
"; //procédure interne if ($type_proc == 'internal') { //Choix d'une procédure $form_task .= "
 
"; if ($form_procs) { $form_task .= "
"; $hp=new parameters($form_procs,"procs"); if (preg_match_all("|!!(.*)!!|U",$hp->proc->requete,$query_parameters)) $form_task .= $hp->gen_form_plann(); $form_task .= "
"; } } else if ($type_proc == 'remote') { $form_task .= "
"; // //Procédures Externes // $pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials); if ($pmb_procedure_server_address && (count($pmb_procedure_server_credentials_exploded) == 2)) { $aremote_procedure_client = new remote_procedure_client($pmb_procedure_server_address, trim($pmb_procedure_server_credentials_exploded[0]), trim($pmb_procedure_server_credentials_exploded[1])); $procedures = $aremote_procedure_client->get_procs("AP"); if ($procedures) { if ($procedures->error_information->error_code) { $form_task .=$msg['remote_procedures_error_server'].":
".$procedures->error_information->error_string.""; } else if (isset($procedures->elements)){ $form_task .= ""; } else { $form_task .="
".$msg["remote_procedures_no_procs"]."

"; } } $form_task .= "
 
"; if ($form_procs_remote) { $id = $form_procs_remote; $procedure = $aremote_procedure_client->get_proc($id,"AP"); $form_task .= "
"; if ($procedure["error_message"]) { $form_task .= htmlentities($msg["remote_procedures_error_server"], ENT_QUOTES, $charset).":
".$procedure["error_message"].""; } else { $the_procedure = $procedure["procedure"]; if ($the_procedure->params && ($the_procedure->params != "NULL")) { $sql = "CREATE TEMPORARY TABLE remote_proc LIKE procs"; mysql_query($sql, $dbh) or die(mysql_error()); $sql = "INSERT INTO remote_proc (idproc, name, requete, comment, autorisations, parameters, num_classement) VALUES (0, '".mysql_escape_string($the_procedure->name)."', '".mysql_escape_string($the_procedure->sql)."', '".mysql_escape_string($the_procedure->comment)."', '', '".mysql_escape_string($the_procedure->params)."', 0)"; mysql_query($sql, $dbh) or die(mysql_error()); $idproc = mysql_insert_id($dbh); $hp=new parameters($idproc,"remote_proc"); if (preg_match_all("|!!(.*)!!|U",$hp->proc->requete,$query_parameters)) $form_task .= $hp->gen_form_plann(); } } $form_task .= "
"; } } } return $form_task; } function task_execution() { global $dbh,$msg, $PMBusername; if (SESSrights & ADMINISTRATION_AUTH) { $parameters = $this->unserialize_task_params(); if ($parameters["type_proc"]) { if ($parameters["type_proc"] == 'internal') { //vérifie que la procédure existe toujours en base PMB $res = mysql_query("SELECT name FROM procs where idproc=".$parameters["form_procs"],$dbh); if (mysql_num_rows($res) == 1) { $id_proc = $parameters["form_procs"]; $row = mysql_fetch_object($res); if($this->statut == RUNNING) { $this->report[] = "".$this->msg["proc_execution"]." : ".$row->name.""; if (method_exists($this->proxy, "pmbesProcs_executeProc")) { $result_proc = $this->proxy->pmbesProcs_executeProc(INTERNAL,$id_proc,$parameters["envt"]); $this->report[] = "".$result_proc["report"].""; $this->update_progression(100); } else { $this->report[] = "".sprintf($msg["planificateur_function_rights"],"executeProc","pmbesProcs",$PMBusername).""; } } } else { $this->report[] = $this->msg["proc_unknown"]; } } else if ($parameters["type_proc"] == 'remote') { $id_proc = $parameters["form_procs_remote"]; if($this->statut == RUNNING) { if (method_exists($this->proxy, "pmbesProcs_executeProc")) { $result_proc = $this->proxy->pmbesProcs_executeProc(EXTERNAL,$id_proc,$parameters["envt"]); $this->report[] = "".$this->msg["proc_execution_remote"]." : ".$result_proc["name"].""; $this->report[] = "".$result_proc["report"].""; $this->update_progression(100); } else { $this->report[] = "".$this->msg["proc_execution_remote"].""; $this->report[] = "".sprintf($msg["planificateur_function_rights"],"executeProc","pmbesProcs",$PMBusername).""; } } } else { $this->report[] = "".$this->msg["proc_error"].""; } } else { $this->report[] = "".$this->msg["proc_error"].""; } } else { $this->report[] = "".sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername).""; } } function make_serialized_task_params() { global $dbh, $type_proc, $form_procs, $form_procs_remote; global $pmb_procedure_server_credentials, $pmb_procedure_server_address; $t = parent::make_serialized_task_params(); $t["type_proc"] = stripslashes($type_proc); $t["form_procs"] = stripslashes($form_procs); $t["form_procs_remote"] = stripslashes($form_procs_remote); if ($form_procs) { $hp=new parameters($form_procs,"procs"); $t["envt"]=$hp->make_serialized_parameters_params(); } else if ($form_procs_remote) { $id = $form_procs_remote; $pmb_procedure_server_credentials_exploded = explode("\n", $pmb_procedure_server_credentials); if ($pmb_procedure_server_address && (count($pmb_procedure_server_credentials_exploded) == 2)) { $aremote_procedure_client = new remote_procedure_client($pmb_procedure_server_address, trim($pmb_procedure_server_credentials_exploded[0]), trim($pmb_procedure_server_credentials_exploded[1])); $procedure = $aremote_procedure_client->get_proc($id,"AP"); if (!$procedure["error_message"]) { $the_procedure = $procedure["procedure"]; if ($the_procedure) { $sql = "CREATE TEMPORARY TABLE remote_proc LIKE procs"; mysql_query($sql, $dbh) or die(mysql_error()); $sql = "INSERT INTO remote_proc (idproc, name, requete, comment, autorisations, parameters, num_classement) VALUES (0, '".mysql_escape_string($the_procedure->name)."', '".mysql_escape_string($the_procedure->sql)."', '".mysql_escape_string($the_procedure->comment)."', '', '".mysql_escape_string($the_procedure->params)."', 0)"; mysql_query($sql, $dbh) or die(mysql_error()); $idproc = mysql_insert_id($dbh); $hp=new parameters($idproc,"remote_proc"); $t["envt"]=$hp->make_serialized_parameters_params(); } } } } return serialize($t); } function unserialize_task_params() { $params = $this->get_task_params(); return $params; } }