function do_directive($directive, &$tab_rules, $dom) { $direct = $directive->directive; for ($ind = 1; $ind <= count($tab_rules); $ind++) { $rule = $tab_rules[$ind]; list($id_dir, $id_rule, $id_father) = explode("-", $rule->id); if ($id_father == 0) { $node = $tab_rules[$id_rule]->getXMLNode($dom); $node = $direct->append_child($node); $tab_rules[$id_rule]->rule = $node; if ($tab_rules[$id_rule]->nb_child > 0) { do_rules($id_rule, &$tab_rules, $dom); } } } }
function do_rules($id_rule, &$tab_rules, $dom) { $father = $tab_rules[$id_rule]->rule; $rules = $father->child_nodes(); foreach ($rules as $rule) { if ($rule->type == XML_ELEMENT_NODE && $rule->tagname() == 'rules') { for ($i = 1; $i <= count($tab_rules); $i++) { $lign = $tab_rules[$i]; list($id_dir, $id_rule2, $id_father) = explode("-", $lign->id); if ($id_father == $id_rule) { $node = $tab_rules[$id_rule2]->getXMLNode($dom); $node = $rule->append_child($node); $tab_rules[$id_rule2]->rule = $node; if ($tab_rules[$id_rule2]->nb_child > 0) { do_rules($id_rule2, &$tab_rules, $dom); } } } } } }
$_SESSION['directive'] = serialize($new_directive); $directives->append_child($node); $dom->dump_file($XML_FILE); $new_rule_id = $new_id . "-1-0"; echo "<html><body onload=\"window.open('../index.php?directive=" . $new_directive->id . "&level=1&action=add_rule&id=" . $new_rule_id . "&nlevel=1','main')\"></body></html>"; } else { $tab_rules = $directive->rules; for ($ind = 1; $ind <= count($tab_rules); $ind++) { $rule = $tab_rules[$ind]; list($id_dir, $id_rule, $id_father) = explode("-", $rule->id); if ($id_father == 0) { $new_node = $tab_rules[$id_rule]->getXMLNode($dom); $new_node = $node->append_child($new_node); $tab_rules[$id_rule]->rule = $new_node; if ($tab_rules[$id_rule]->nb_child > 0) { do_rules($id_rule, &$tab_rules, $dom); } } } $new_directive->directive = $node; $_SESSION['directive'] = serialize($new_directive); $OLD_XML_FILE = get_directive_file($directive->id); if ($OLD_XML_FILE == $XML_FILE) { $dom2 = $dom; } else { $dom2 = open_file($OLD_XML_FILE); } $tab_directive = $dom2->get_elements_by_tagname('directive'); foreach ($tab_directive as $direct) { if ($direct->get_attribute('id') == $directive->id) { $old_node = $direct;