get_parms( "sbas_id" , "period" , 'status0' , 'coll0' , 'status1' , 'coll1' ); $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; if ($dom->loadXML($oldxml)) { $xmlchanged = false; // foreach($parm2 as $pname=>$pvalue) foreach (array( "str:sbas_id", "str:period", 'str:status0', 'str:coll0', 'str:status1', 'str:coll1', ) as $pname) { $ptype = substr($pname, 0, 3); $pname = substr($pname, 4); $pvalue = $parm2[$pname]; if ($ns = $dom->getElementsByTagName($pname)->item(0)) { // le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu) while (($n = $ns->firstChild)) $ns->removeChild($n); } else { // le champ n'existait pas dans le xml, on le cree $dom->documentElement->appendChild($dom->createTextNode("\t")); $ns = $dom->documentElement->appendChild($dom->createElement($pname)); $dom->documentElement->appendChild($dom->createTextNode("\n")); } // on fixe sa valeur switch ($ptype) { case "str": $ns->appendChild($dom->createTextNode($pvalue)); break; case "boo": $ns->appendChild($dom->createTextNode($pvalue ? '1' : '0')); break; } $xmlchanged = true; } } return($dom->saveXML()); } public function xml2graphic($xml, $form) { if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here... // ... but we could check for safe values if ((int) ($sxml->period) < 10) $sxml->period = 10; elseif ((int) ($sxml->period) > 1440) // 1 jour $sxml->period = 1440; if ((string) ($sxml->delay) == '') $sxml->delay = 0; ?> get_session(); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); ob_start(); ?>
 :   

 : 

Collection :   ====>  
Status :

cmd
status_origine = (string) $sx_task_settings->status0; $this->status_destination = (string) $sx_task_settings->status1; $this->coll_origine = (int) $sx_task_settings->coll0; $this->coll_destination = (int) $sx_task_settings->coll1; parent::load_settings($sx_task_settings); $this->mono_sbas_id = (int) $sx_task_settings->sbas_id; // in minutes $this->period = (int) $sx_task_settings->period * 60; if ($this->period <= 0 || $this->period >= 24 * 60) $this->period = 60; return $this; } protected function retrieve_sbas_content(databox $databox) { $connbas = $databox->get_connection(); $status_origine = explode('_', $this->status_origine); if (count($status_origine) !== 2) throw new Exception('Error in settings for status origine'); $status_destination = explode('_', $this->status_destination); if (count($status_destination) !== 2) throw new Exception('Error in settings for status destination'); $collection_origine = collection::get_from_base_id($this->coll_origine); $collection_destination = collection::get_from_base_id($this->coll_destination); unset($collection_destination); unset($collection_origine); $status_orgine_number = (int) $status_origine[0]; $status_orgine_state = (int) $status_origine[1]; $status_destination_number = (int) $status_destination[0]; $status_destination_state = (int) $status_destination[1]; $u = 'coll_id = :coll_dest'; if ($status_destination_state === 0) $u .= ', status = status &~(1 << ' . $status_destination_number . ')'; else $u .= ', status = status |(1 << ' . $status_destination_number . ')'; $sql = 'UPDATE record SET ' . $u . ' WHERE coll_id = :coll_id AND (status >> ' . $status_orgine_number . ') & 1 = ' . $status_orgine_state; $params = array( ':coll_id' => $this->coll_origine, ':coll_dest' => $this->coll_destination ); $stmt = $connbas->prepare($sql); $stmt->execute($params); $this->log(sprintf(("SQL=%s - %s changes"), str_replace(array("\r\n", "\n", "\r"), " ", $sql), $stmt->rowCount())); $stmt->closeCursor(); return array(); } protected function process_one_content(databox $databox, Array $row) { return $this; } protected function flush_records_sbas() { return $this; } protected function post_process_one_content(databox $databox, Array $row) { return $this; } public function facility() { $request = http_request::getInstance(); $appbox = appbox::get_instance(\bootstrap::getCore()); $session = $appbox->get_session(); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $parm = $request->get_parms("bid"); phrasea::headers(200, true, 'text/xml', 'UTF-8', false); $ret = new DOMDocument("1.0", "UTF-8"); $ret->standalone = true; $ret->preserveWhiteSpace = false; $element = $ret->createElement('result'); $root = $ret->appendChild($element); $root->appendChild($ret->createCDATASection(var_export($parm, true))); $dfields = $root->appendChild($ret->createElement("date_fields")); $statbits = $root->appendChild($ret->createElement("status_bits")); $coll = $root->appendChild($ret->createElement("collections")); $sbas_id = (int) $parm['bid']; try { $databox = databox::get_instance($sbas_id); foreach ($databox->get_meta_structure() as $meta) { if ($meta->get_type() !== 'date') continue; $dfields->appendChild($ret->createElement("field")) ->appendChild($ret->createTextNode($meta->get_name())); } $status = $databox->get_statusbits(); foreach ($status as $n => $s) { $node = $statbits->appendChild($ret->createElement("bit")); $node->setAttribute('n', $n); $node->setAttribute('value', '0'); $node->setAttribute('label', $s['labeloff']); $node->appendChild($ret->createTextNode($s['labeloff'])); $node = $statbits->appendChild($ret->createElement("bit")); $node->setAttribute('n', $n); $node->setAttribute('value', '1'); $node->setAttribute('label', $s['labelon']); $node->appendChild($ret->createTextNode($s['labelon'])); } $base_ids = $user->ACL()->get_granted_base(array(), array($sbas_id)); foreach ($base_ids as $base_id => $collection) { $node = $coll->appendChild($ret->createElement("collection")); $node->setAttribute('id', $collection->get_coll_id()); $node->appendChild($ret->createTextNode($collection->get_name())); } } catch (Exception $e) { } return $ret->saveXML(); } }