course)) { error("Course is misconfigured"); } if (! $glossary = get_record("glossary", "id", $cm->instance)) { error("Course module is incorrect"); } require_login($course->id); if ( !isteacher($course->id) ) { error("You must be a teacher to use this page."); } // add_to_log($course->id, "glossary", "edit categories", "view.php?id=$cm->id", "$glossary->id"); if ($course->category) { $navigation = "id\">$course->shortname ->"; } $strglossaries = get_string("modulenameplural", "glossary"); $strglossary = get_string("modulename", "glossary"); print_header("$course->shortname: $glossary->name", "$course->fullname", "$navigation id>$strglossaries -> $glossary->name", "", "", true, update_module_button($cm->id, $course->id, $strglossary), navmenu($course, $cm)); if ( $cat ) { $category = get_record("glossary_categories","id",$cat); if ( $action == "edit" ) { if ( $confirm ) { $action = ""; $CategoryObject->id = $cat; $CategoryObject->name = $name; if ( !update_record("glossary_categories", $CategoryObject) ) { error("Weird error. The category was not updated."); redirect("editcategories.php?id=$cm->id"); } } else { echo "

" . get_string("edit"). " " . get_string("category","glossary") . ""; $name = $category->name; require "editcategories.html"; print_footer(); die; } } elseif ( $action == "delete" ) { if ( $confirm ) { delete_records("glossary_entries_categories","categoryid", $cat); delete_records("glossary_categories","id", $cat); print_simple_box_start("center","40%", "#FFBBBB"); echo "

" . get_string("categorydeleted","glossary") ."
"; echo ""; print_simple_box_end(); print_footer($course); add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $cat); redirect("editcategories.php?id=$cm->id"); } else { echo "

" . get_string("delete"). " " . get_string("category","glossary") . ""; print_simple_box_start("center","40%", "#FFBBBB"); echo "

$category->name
"; $num_entries = count_records("glossary_entries_categories","categoryid",$category->id); if ( $num_entries ) { print_string("deletingnoneemptycategory","glossary"); } echo "

"; print_string("areyousuredelete","glossary"); ?>

"> $id); print_single_button("editcategories.php", $options, get_string("no") ); echo "
"; echo "
"; print_simple_box_end(); } } } elseif ( $action == "add" ) { if ( $confirm ) { $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name)); if ( $dupcategory ) { echo "

" . get_string("add"). " " . get_string("category","glossary") . ""; print_simple_box_start("center","40%", "#FFBBBB"); echo "

" . get_string("duplicatedcategory","glossary") ."
"; echo ""; print_simple_box_end(); print_footer($course); redirect("editcategories.php?id=$cm->id&action=add&&name=$name"); } else { $action = ""; $CategoryObject->name = $name; $CategoryObject->glossaryid = $glossary->id; if ( ! $CategoryObject->id = insert_record("glossary_categories", $CategoryObject) ) { error("Weird error. The category was not inserted."); redirect("editcategories.php?id=$cm->id"); } else { add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat); } } } else { echo "

" . get_string("add"). " " . get_string("category","glossary") . ""; $name=""; require "editcategories.html"; } } if ( $action ) { print_footer(); die; } ?>

action="editcategories.php">
id,"name ASC"); if ( $categories ) { foreach ($categories as $category) { $num_entries = count_records("glossary_entries_categories","categoryid",$category->id); ?>
$category->name ($num_entries " . get_string("entries","glossary") . ")"; ?> id&action=delete&cat=$category->id\">\"" "; echo "id&action=edit&cat=$category->id\">\"""; ?>
id; $options['action'] = "add"; echo ""; echo ""; ?>
"; echo print_single_button("editcategories.php", $options, get_string("add") . " " . get_string("category","glossary"), "get"); echo ""; unset($options['action']); $options['currentview'] = "categories"; echo print_single_button("view.php", $options, get_string("back","glossary") ); echo "