function getDirectiveFromXML($dom, $directive_id, $ruleid = 0, $rulename = "") { $_POST['ind'] = 0; $tab_rules = array(); $order = findorder($dom, $directive_id); if ($directive_id) { $doc = $dom->get_elements_by_tagname('directive'); $dir = $doc[$order]; if ($dir) { $directive = new Directive($dir->get_attribute('id'), $dir->get_attribute('name'), $dir->get_attribute('priority'), &$tab_rules, $dir); } else { $directive = new Directive($ruleid, $rulename, 2, &$tab_rules, $dir); } } $_POST['dir_id'] = $directive->id; init_directive($dir, &$tab_rules, 1, 0); $nb_child = 0; /* count the number of child of each rule */ for ($i = 1; $i <= count($tab_rules); $i++) { list($id_dir, $id_rule, $id_father) = explode("-", $tab_rules[$i]->id); if ($id_father == 0) { $nb_child++; } } $directive->nb_child = $nb_child; for ($i = 1; $i <= count($tab_rules); $i++) { list($id_dir, $id_rule, $id_father) = explode("-", $tab_rules[$i]->id); $nb_child = 0; for ($j = 1; $j <= count($tab_rules); $j++) { list($id_dir2, $id_rule2, $id_father2) = explode("-", $tab_rules[$j]->id); if ($id_rule == $id_father2) { $nb_child++; } } $tab_rules[$i]->nb_child = $nb_child; } return $directive; }
datestamp = NOW() WHERE id = ?d AND course_id = ?d" , $_POST['term'], $_POST['definition'], $url, purify($_POST['notes']), $category_id, $id, $course_id); $log_action = LOG_MODIFY; $success_message = $langGlossaryUpdated; } else { $q = Database::get()->query("INSERT INTO glossary SET term = ?s, definition = ?s, url = ?s, notes = ?s, category_id = ?d, datestamp = NOW(), course_id = ?d, `order` = ?d" , $_POST['term'], $_POST['definition'], $url, purify($_POST['notes']), $category_id, $course_id, findorder($course_id)); $log_action = LOG_INSERT; $success_message = $langGlossaryAdded; } $id = $q->lastInsertID; Log::record($course_id, MODULE_ID_GLOSSARY, $log_action, array('id' => $id, 'term' => $_POST['term'], 'definition' => $_POST['definition'], 'url' => $url, 'notes' => purify($_POST['notes']))); if ($q and $q->affectedRows) { invalidate_glossary_cache(); Session::Messages($success_message, 'alert-success'); } redirect_to_home_page("modules/glossary/index.php?course=$course_code");
invalidate_glossary_cache(); $tool_content .= "<div class='alert alert-success'>{$langQuotaSuccess}</div>"; } if (isset($_POST['submit'])) { if (!isset($_POST['category_id']) || $_POST['category_id'] == 0) { $category_id = NULL; } else { $category_id = intval($_POST['category_id']); } if (isset($_POST['id'])) { $id = intval($_POST['id']); $q = Database::get()->query("UPDATE glossary\n SET term = ?s,\n definition = ?s,\n url = ?s,\n notes = ?s,\n category_id = ?d ,\n datestamp = NOW()\n WHERE id = ?d AND course_id = ?d", $_POST['term'], $_POST['definition'], $url, purify($_POST['notes']), $category_id, $id, $course_id); $log_action = LOG_MODIFY; $success_message = $langGlossaryUpdated; } else { $q = Database::get()->query("INSERT INTO glossary\n SET term = ?s,\n definition = ?s,\n url = ?s,\n notes = ?s,\n category_id = ?d,\n datestamp = NOW(),\n course_id = ?d,\n `order` = ?d", $_POST['term'], $_POST['definition'], $url, purify($_POST['notes']), $category_id, $course_id, findorder($course_id)); $log_action = LOG_INSERT; $success_message = $langGlossaryAdded; } $id = $q->lastInsertID; Log::record($course_id, MODULE_ID_GLOSSARY, $log_action, array('id' => $id, 'term' => $_POST['term'], 'definition' => $_POST['definition'], 'url' => $url, 'notes' => purify($_POST['notes']))); if ($q and $q->affectedRows) { invalidate_glossary_cache(); $tool_content .= "<div class='alert alert-success'>{$success_message}</div><br />"; } } if (isset($_GET['delete'])) { $id = $_GET['delete']; $term = Database::get()->querySingle("SELECT term FROM glossary WHERE ID = ?d", $id)->term; $q = Database::get()->query("DELETE FROM glossary WHERE id = ?d AND course_id = ?d", $id, $course_id); invalidate_glossary_cache();