Skip to content

Commit

Permalink
MDL-44287 glossary: do not output before redirecting
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Feb 28, 2014
1 parent 6f9354b commit 7d96cf2
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions mod/glossary/editcategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,14 @@
$strglossaries = get_string("modulenameplural", "glossary");
$strglossary = get_string("modulename", "glossary");

$PAGE->navbar->add($strglossaries, new moodle_url('/mod/glossary/index.php', array('id'=>$course->id)));
$PAGE->navbar->add(get_string("categories","glossary"));
$PAGE->navbar->add(get_string("categories","glossary"),
new moodle_url('/mod/glossary/editcategories.php', array('id' => $cm->id,'mode' => 'cat')));
if (!empty($action)) {
$navaction = get_string($action). " " . core_text::strtolower(get_string("category","glossary"));
$PAGE->navbar->add($navaction);
}
$PAGE->set_title($glossary->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($glossary->name), 2);

// Prepare format_string/text options
$fmtoptions = array(
Expand Down Expand Up @@ -107,6 +105,8 @@
add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id);

} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($glossary->name), 2);
echo $OUTPUT->heading(format_string(get_string("edit"). " " . get_string("category","glossary")), 3);

$name = $category->name;
Expand All @@ -121,14 +121,12 @@
$DB->delete_records("glossary_entries_categories", array("categoryid"=>$hook));
$DB->delete_records("glossary_categories", array("id"=>$hook));

echo $OUTPUT->box_start('generalbox boxaligncenter errorboxcontent boxwidthnarrow');
echo "<div>" . get_string("categorydeleted","glossary") ."</div>";
echo $OUTPUT->box_end();

add_to_log($course->id, "glossary", "delete category", "editcategories.php?id=$cm->id", $hook,$cm->id);

redirect("editcategories.php?id=$cm->id");
redirect("editcategories.php?id=$cm->id", get_string("categorydeleted", "glossary"), 2);
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($glossary->name), 2);
echo $OUTPUT->heading(format_string(get_string("delete"). " " . get_string("category","glossary")), 3);

echo $OUTPUT->box_start('generalbox boxaligncenter errorboxcontent boxwidthnarrow');
Expand Down Expand Up @@ -173,13 +171,7 @@
if ( $confirm ) {
$dupcategory = $DB->get_records_sql("SELECT * FROM {glossary_categories} WHERE ".$DB->sql_like('name','?', false)." AND glossaryid=?", array($name, $glossary->id));
if ( $dupcategory ) {
echo "<h3 class=\"main\">" . get_string("add"). " " . get_string("category","glossary"). "</h3>";

echo $OUTPUT->box_start('generalbox boxaligncenter errorboxcontent boxwidthnarrow');
echo "<div>" . get_string("duplicatecategory","glossary") ."</div>";
echo $OUTPUT->box_end();

redirect("editcategories.php?id=$cm->id&amp;action=add&amp;name=$name");
redirect("editcategories.php?id=$cm->id&amp;action=add&amp;name=$name", get_string("duplicatecategory", "glossary"), 2);

} else {
$action = "";
Expand All @@ -192,6 +184,8 @@
add_to_log($course->id, "glossary", "add category", "editcategories.php?id=$cm->id", $cat->id,$cm->id);
}
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($glossary->name), 2);
echo "<h3 class=\"main\">" . get_string("add"). " " . get_string("category","glossary"). "</h3>";
$name="";
require "editcategories.html";
Expand All @@ -203,6 +197,9 @@
die;
}

echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($glossary->name), 2);

?>

<form method="post" action="editcategories.php">
Expand Down

0 comments on commit 7d96cf2

Please sign in to comment.