From c16e25ca1dc7f4e79678be7f4aba94670cdf06d2 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 9 Sep 2004 08:35:22 +0000 Subject: [PATCH] Simply reformated before solving some bugs to have ideas clearer. --- mod/glossary/editcategories.php | 246 ++++++++++++++++---------------- 1 file changed, 123 insertions(+), 123 deletions(-) diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index 95476f48bc1..e7118a2704f 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -33,146 +33,144 @@ } if ($hook) { - if ($category = get_record("glossary_categories","id",$hook)) { - //Check it belongs to the same glossary - if ($category->glossaryid != $glossary->id) { - error("Glossary is incorrect"); - } - } else { - error("Category is incorrect"); - } + if ($category = get_record("glossary_categories","id",$hook)) { + //Check it belongs to the same glossary + if ($category->glossaryid != $glossary->id) { + error("Glossary is incorrect"); + } + } else { + error("Category is incorrect"); + } } require_login($course->id); - if ( !isteacher($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", $cm->id); + } $strglossaries = get_string("modulenameplural", "glossary"); $strglossary = get_string("modulename", "glossary"); print_header_simple(strip_tags("$glossary->name"), "", - "id>$strglossaries -> id&tab=GLOSSARY_CATEGORY_VIEW>$glossary->name -> " . get_string("categories","glossary"), - "", "", true, update_module_button($cm->id, $course->id, $strglossary), - navmenu($course, $cm)); + "id>$strglossaries -> id&tab=GLOSSARY_CATEGORY_VIEW>$glossary->name -> " . get_string("categories","glossary"), + "", "", true, update_module_button($cm->id, $course->id, $strglossary), + navmenu($course, $cm)); - if ( $hook ) { + if ( $hook ) { - if ( $action == "edit" ) { - if ( $confirm ) { - $action = ""; - $cat->id = $hook; - $cat->name = $name; - $cat->usedynalink = $usedynalink; + if ( $action == "edit" ) { + if ( $confirm ) { + $action = ""; + $cat->id = $hook; + $cat->name = $name; + $cat->usedynalink = $usedynalink; - if ( !update_record("glossary_categories", $cat) ) { - error("Weird error. The category was not updated."); - redirect("editcategories.php?id=$cm->id"); - } else { - add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id); - } - } else { - echo "

" . get_string("edit"). " " . get_string("category","glossary") . ""; - - $name = $category->name; - $usedynalink = $category->usedynalink; - require "editcategories.html"; - print_footer(); - die; - } - } elseif ( $action == "delete" ) { - if ( $confirm ) { - - delete_records("glossary_entries_categories","categoryid", $hook); - delete_records("glossary_categories","id", $hook); - - 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", $hook,$cm->id); - + if ( !update_record("glossary_categories", $cat) ) { + error("Weird error. The category was not updated."); redirect("editcategories.php?id=$cm->id"); - } else { - echo "

" . get_string("delete"). " " . get_string("category","glossary") . ""; + } else { + add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id); + } + } else { + echo "

" . get_string("edit"). " " . 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"); + $name = $category->name; + $usedynalink = $category->usedynalink; + require "editcategories.html"; + print_footer(); + die; + } + + } elseif ( $action == "delete" ) { + if ( $confirm ) { + delete_records("glossary_entries_categories","categoryid", $hook); + delete_records("glossary_categories","id", $hook); + + 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", $hook,$cm->id); - ?> -
+ redirect("editcategories.php?id=$cm->id"); + } else { + echo "

" . get_string("delete"). " " . get_string("category","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),"glossaryid",$glossary->id); - 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_simple_box_start("center","40%", "#FFBBBB"); + echo "
$category->name
"; - print_footer($course); + $num_entries = count_records("glossary_entries_categories","categoryid",$category->id); + if ( $num_entries ) { + print_string("deletingnoneemptycategory","glossary"); + } + echo "

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

- redirect("editcategories.php?id=$cm->id&action=add&&name=$name"); + + + + + +
+ "> + + - } else { - $action = ""; - $cat->name = $name; - $cat->usedynalink = $usedynalink; - $cat->glossaryid = $glossary->id; + $id); + print_single_button("editcategories.php", $options, get_string("no") ); + echo "
"; + echo "
"; + print_simple_box_end(); + } + } - if ( ! $cat->id = insert_record("glossary_categories", $cat) ) { - error("Weird error. The category was not inserted."); + } elseif ( $action == "add" ) { + if ( $confirm ) { + $dupcategory = get_record("glossary_categories","lcase(name)",strtolower($name),"glossaryid",$glossary->id); + 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 = ""; + $cat->name = $name; + $cat->usedynalink = $usedynalink; + $cat->glossaryid = $glossary->id; + + if ( ! $cat->id = insert_record("glossary_categories", $cat) ) { + 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->id,$cm->id); - } - } - } else { - echo "

" . get_string("add"). " " . get_string("category","glossary") . ""; - $name=""; - require "editcategories.html"; - } - } + redirect("editcategories.php?id=$cm->id"); + } else { + add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat->id,$cm->id); + } + } + } else { + echo "

" . get_string("add"). " " . get_string("category","glossary") . ""; + $name=""; + require "editcategories.html"; + } + } - if ( $action ) { - print_footer(); - die; - } + if ( $action ) { + print_footer(); + die; + } ?> @@ -190,13 +188,15 @@ -id,"name ASC"); - if ( $categories ) { - foreach ($categories as $category) { - $num_entries = count_records("glossary_entries_categories","categoryid",$category->id); - ?> +id,"name ASC"); + + if ( $categories ) { + foreach ($categories as $category) { + $num_entries = count_records("glossary_entries_categories","categoryid",$category->id); +?> +