global $USER, $CFG;
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
- print_error("Course Module ID was incorrect");
+ print_error('invalidcoursemodule');
}
if (! $course = get_record("course", "id", $cm->course)) {
- print_error("Course is misconfigured");
+ print_error('coursemisconf');
}
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
- print_error("Course module is incorrect");
+ print_error('invalidcousemodule');
}
if (! $entry = get_record("glossary_entries", "id", $eid)) {
- print_error("Entry is incorrect");
+ print_error('invalidentry');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
- print_error("Course Module ID was incorrect");
+ print_error("invalidcoursemodule");
}
if (! $course = get_record("course", "id", $cm->course)) {
- print_error("Course is misconfigured");
+ print_error('coursemisconf');
}
if (! $entry = get_record("glossary_entries","id", $entry)) {
- print_error("Entry ID was incorrect");
+ print_error('invalidentry');
}
require_login($course->id, false, $cm);
$manageentries = has_capability('mod/glossary:manageentries', $context);
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
- print_error("Glossary is incorrect");
+ print_error('invalidid', 'glossary');
}
navmenu($course, $cm));
if (($entry->userid != $USER->id) and !$manageentries) { // guest id is never matched, no need for special check here
- print_error("You can't delete other people's entries!");
+ print_error('nopermissiontodelentry');
}
$ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways);
if (!$ineditperiod and !$manageentries) {
- print_error("You can't delete this. Time expired!");
+ print_error('errdeltimeexpired', 'glossary');
}
/// If data submitted, then process and store.
$dbentry->glossaryid = $entry->sourceglossaryid;
$dbentry->sourceglossaryid = 0;
if (! update_record('glossary_entries', $dbentry)) {
- print_error("Could not update your glossary");
+ print_error('cantupdateglossary', 'glossary');
}
} else {
$hook = optional_param('hook', '', PARAM_ALPHANUM); // CategoryID
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
- print_error("Course Module ID was incorrect");
+ print_error('invalidcoursemodule');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (! $course = get_record("course", "id", $cm->course)) {
- print_error("Course is misconfigured");
+ print_error('coursemisconf');
}
require_login($course->id, false, $cm);
if ( isguest() ) {
- print_error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]);
+ print_error('guestnoedit', 'glossary', $_SERVER["HTTP_REFERER"]);
}
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
- print_error("Course module is incorrect");
+ print_error('invalidid', 'glossary');
}
if ($e) { // if entry is specified
if (!$entry = get_record("glossary_entries", "id", $e)) {
- print_error("Incorrect entry id");
+ print_error('invalidentry');
}
$ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways);
if (!has_capability('mod/glossary:manageentries', $context) and !($entry->userid == $USER->id and ($ineditperiod and has_capability('mod/glossary:write', $context)))) {
//expired edit time is the most probable cause here
- print_error('erredittimeexpired', 'glossary', "view.php?id=$cm->id&mode=entry&hook=$e");
+ print_error('erredittimeexpired', 'glossary', 'view.php?id=$cm->id&mode=entry&hook=$e');
}
} else { // new entry
require_capability('mod/glossary:write', $context);
"view.php?id=$cm->id&mode=entry&hook=$todb->id",
$todb->id, $cm->id);
} else {
- print_error("Could not update your glossary");
+ print_error('cantupdateglossary', 'glossary');
}
} else {
add_to_log($course->id, "glossary", "add entry",
"view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id,$cm->id);
} else {
- print_error("Could not insert this new entry");
+ print_error('cantinsertent', 'glossary');
}
}
$action = strtolower($action);
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
- print_error("Course Module ID was incorrect");
+ print_error('invalidcoursemodule');
}
if (! $course = get_record("course", "id", $cm->course)) {
- print_error("Course is misconfigured");
+ print_error('coursemisconf');
}
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
- print_error("Course module is incorrect");
+ print_error('invalidcoursemodule');
}
if ($hook > 0) {
if ($category = get_record("glossary_categories","id",$hook)) {
//Check it belongs to the same glossary
if ($category->glossaryid != $glossary->id) {
- print_error("Glossary is incorrect");
+ print_error('invalidid', 'glossary');
}
} else {
- print_error("Category is incorrect");
+ print_error('invalidcategoryid');
}
}
$cat->usedynalink = $usedynalink;
if ( !update_record("glossary_categories", $cat) ) {
- print_error("Weird error. The category was not updated.");
+ print_error('cannotupdatecategory');
redirect("editcategories.php?id=$cm->id");
} else {
add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id);
$cat->glossaryid = $glossary->id;
if ( ! $cat->id = insert_record("glossary_categories", $cat) ) {
- print_error("Weird error. The category was not inserted.");
+ print_error('cannotinsertcategory');
redirect("editcategories.php?id=$cm->id");
} else {
require_capability('mod/glossary:export', $context);
if (! $course = get_record('course', 'id', $cm->course)) {
- print_error('Course is misconfigured');
+ print_error('coursemisconf');
}
if (! $glossary = get_record('glossary', 'id', $cm->instance)) {
- print_error('Course module is incorrect');
+ print_error('invalidid', 'glossary');
}
$strglossaries = get_string('modulenameplural', 'glossary');
$dbentry->sourceglossaryid = $glossary->id;
if (! update_record('glossary_entries', $dbentry)) {
- print_error('Could not export the entry to the main glossary');
+ print_error('cantexportentry', 'glossary');
} else {
print_simple_box_start('center', '60%');
echo '<p align="center"><font size="3">'.$entryexported.'</font></p></font>';
$hook = optional_param('hook', 'ALL', PARAM_ALPHANUM);
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
- print_error("Course Module ID was incorrect");
+ print_error('invalidcoursemodule');
}
if (! $course = get_record("course", "id", $cm->course)) {
- print_error("Course is misconfigured");
+ print_error('coursemisconf');
}
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
- print_error("Course module is incorrect");
+ print_error('invalidid', 'glossary');
}
require_login($course->id, false, $cm);
// to each other, so we have to update one of them twice.
if (! $currmodule = get_record("modules", "name", 'glossary')) {
- print_error("Glossary module doesn't exist");
+ print_error('modulenotexist', 'debug', '', 'Glossary');
}
$mod->module = $currmodule->id;
$mod->course = $course->id;
$mod->section = 0;
if (! $mod->coursemodule = add_course_module($mod) ) {
- print_error("Could not add a new course module");
+ print_error('cannotaddcoursemodule');
}
if (! $sectionid = add_mod_to_section($mod) ) {
- print_error("Could not add the new course module to that section");
+ print_error('cannotaddcoursemoduletosection');
}
//We get the section's visible field status
$visible = get_field("course_sections","visible","id",$sectionid);
if (! set_field("course_modules", "visible", $visible, "id", $mod->coursemodule)) {
- print_error("Could not update the course module with the correct visibility");
+ print_error('cannotupdatemod', '', '', $mod->coursemodule);
}
if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
- print_error("Could not update the course module with the correct section");
+ print_error('cannotupdatemod', '', '', $mod->coursemodule);
}
add_to_log($course->id, "course", "add mod",
"../mod/$mod->modulename/view.php?id=$mod->coursemodule",
$id = required_param('id', PARAM_INT); // course
if (!$course = $DB->get_record('course', array('id'=>$id))) {
- print_error("Course ID is incorrect");
+ print_error('invalidcourseid');
}
require_course_login($course);
//Check displayformat is a valid one
$formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
if (!in_array($glossary->displayformat, $formats)) {
- print_error("This format doesn't exist!");
+ print_error('unknowformat', '', '', $glossary->displayformat);
}
if ($returnid = $DB->insert_record("glossary", $glossary)) {
//Check displayformat is a valid one
$formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
if (!in_array($glossary->displayformat, $formats)) {
- print_error("This format doesn't exist!");
+ print_error('unknowformat', '', '', $glossary->displayformat);
}
if ($return = $DB->update_record("glossary", $glossary)) {
if ( $entries ) {
foreach ( $entries as $entry ) {
if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
- print_error('Glossary ID was incorrect or no longer exists');
+ print_error('invalidid', 'glossary');
}
if (! $course = get_record('course', 'id', $glossary->course)) {
- print_error('Glossary is misconfigured - don\'t know what course it\'s from');
+ print_error('coursemisconf');
}
if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid, $glossary->course) ) {
- print_error('Glossary is misconfigured - don\'t know what course module it is');
+ print_error('invalidid', 'glossary');
}
//If displayformat is present, override glossary->displayformat
$sort = optional_param('sort', '', PARAM_ALPHA);
if (! $entry = get_record('glossary_entries', 'id', $id)) {
- print_error("Entry ID was incorrect");
+ print_error('invalidentry');
}
if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
- print_error("Glossary ID was incorrect");
+ print_error('invalidid', 'glossary');
}
if (! $course = get_record('course', 'id', $glossary->course)) {
- print_error("Course ID was incorrect");
+ print_error('invalidcourseid');
}
if (! $cm = get_coursemodule_from_instance('glossary', $glossary->id, $course->id)) {
- print_error("Course Module ID was incorrect");
+ print_error('invalidcoursemodule');
}
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!$glossary->assessed) {
- print_error("This activity does not use ratings");
+ print_error('nopermissiontorate');
}
if (!has_capability('mod/glossary:manageentries', $context) and $USER->id != $entry->userid) {
- print_error("You can only look at results for your own entries");
+ print_error('nopermissiontoviewresult', 'glossary');
}
switch ($sort) {