id_tache = $id_tache;
}
//formulaire spécifique au type de tâche
function show_form ($param='') {
//paramètres pré-enregistré
$tab_maintenance = array();
if ($param['mySQL']) {
foreach ($param['mySQL'] as $elem) {
$tab_maintenance[$elem] = $elem;
}
}
$form_task .= "
";
return $form_task;
}
function task_execution() {
global $dbh, $charset, $msg, $PMBusername;
if (SESSrights & ADMINISTRATION_AUTH) {
$parameters = $this->unserialize_task_params();
$this->report[] = "".$this->msg["mysql_operation"]." |
";
if (method_exists($this->proxy, "pmbesMySQL_mysqlTable")) {
if ($parameters["mySQL"]) {
$percent = 0;
$p_value = (int) 100/count($parameters["mySQL"]);
foreach($parameters["mySQL"] as $action) {
$this->listen_commande(array(&$this, 'traite_commande')); //fonction a rappeller (traite commande)
if($this->statut == WAITING) {
$this->send_command(RUNNING);
}
if($this->statut == RUNNING) {
$this->report[] = "".$action." |
";
$result = $this->proxy->pmbesMySQL_mysqlTable($action);
$maintenance_mysql = array();
foreach ($result as $i=>$table) {
switch ($table[2]) { //Msg_Type : status error info warning
case "status" :
$maintenance_mysql["status"][$table[3]][] = $table[0];
break;
case "error" :
$maintenance_mysql["error"][$table[3]][] = $table[0];
break;
case "info" :
$maintenance_mysql["info"][$table[3]][] = $table[0];
break;
case "warning" :
$maintenance_mysql["warning"][$table[3]][] = $table[0];
break;
}
}
$txt_msg_type = "";
$txt_msg_text = "";
$htmlOutput = "";
foreach ($maintenance_mysql as $msg_type=>$values) {
if ($msg_type != $txt_msg_type) {
$txt_msg_type = $msg_type;
$htmlOutput .= "Op : ".$msg_type." |
";
}
foreach ($values as $msg_text=>$tables) {
if ($msg_text != $txt_msg_text) {
$txt_msg_text = $msg_text;
$htmlOutput .= "Msg_text : ".$msg_text." |
";
$htmlOutput .= "Tables : ".implode(" - ", $tables)." |
";
}
}
}
$this->report[] = htmlentities($htmlOutput, ENT_QUOTES, $charset);
$percent += $p_value;
$this->update_progression($percent);
}
}
} else {
$this->report[] = "".$this->msg["mysql_action_unknown"]." |
";
}
} else {
$this->report[] = "".sprintf($msg["planificateur_function_rights"],"mysqlTable","pmbesMySQL",$PMBusername)." |
";
}
} else {
$this->report[] = "".sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername)." |
";
}
}
function traite_commande($cmd,$message) {
switch ($cmd) {
case RESUME:
$this->send_command(WAITING);
break;
case SUSPEND:
$this->suspend_mysql();
break;
case STOP:
$this->finalize();
die();
break;
case FAIL:
$this->finalize();
die();
break;
}
}
function make_serialized_task_params() {
global $mySQL;
$t = parent::make_serialized_task_params();
if ($mySQL) {
foreach ($mySQL as $elem) {
$t["mySQL"][$elem]=stripslashes($elem);
}
}
return serialize($t);
}
function unserialize_task_params() {
$params = $this->get_task_params();
return $params;
}
function suspend_mysql() {
while ($this->statut == SUSPENDED) {
sleep(20);
$this->listen_commande(array(&$this,"traite_commande"));
}
}
}