$parent_cat = $DB->get_record('course_categories', array('id' => $newcategory->parent));
move_category($newcategory, $parent_cat);
}
- if (!$DB->update_record('course_categories', $newcategory)) {
- print_error( "cannotupdatecategory", '', '', $newcategory->name);
- }
+ $DB->update_record('course_categories', $newcategory);
fix_course_sortorder();
} else {
if ($cattomove->parent != $moveto) {
$newparent = $DB->get_record('course_categories', array('id'=>$moveto));
require_capability('moodle/category:manage', get_category_or_system_context($moveto));
- if (!move_category($cattomove, $newparent)) {
- print_error('cannotupdatecategory', '', '', format_string($cattomove->name));
- }
+ move_category($cattomove, $newparent);
}
}
}
}
require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent));
if ($tempcat) {
- if (!$DB->set_field('course_categories', 'visible', $visible, array('id'=>$tempcat->id))) {
- print_error('cannotupdatecategory', '', '', format_string($tempcat->name));
- }
- if (!$DB->set_field('course', 'visible', $visible, array('category' => $tempcat->id))) {
- print_error('cannotshowhidecoursesincategory', '', '', format_string($tempcat->name));
- }
+ $DB->set_field('course_categories', 'visible', $visible, array('id'=>$tempcat->id));
+ $DB->set_field('course', 'visible', $visible, array('category' => $tempcat->id));
}
}
if ($children = $DB->get_records('course_categories', array('parent'=>$category->id), 'sortorder ASC')) {
foreach ($children as $childcat) {
- if (!move_category($childcat, $newparentcat)) {
- notify("Error moving category $childcat->name");
- return false;
- }
+ move_category($childcat, $newparentcat);
}
}
* Efficiently moves a category - NOTE that this can have
* a huge impact access-control-wise...
*/
-function move_category ($category, $newparentcat) {
+function move_category($category, $newparentcat) {
global $CFG, $DB;
$context = get_context_instance(CONTEXT_COURSECAT, $category->id);
if (empty($newparentcat->id)) {
- if (!$DB->set_field('course_categories', 'parent', 0, array('id'=>$category->id))) {
- return false;
- }
+ $DB->set_field('course_categories', 'parent', 0, array('id'=>$category->id));
$newparent = get_context_instance(CONTEXT_SYSTEM);
} else {
- if (!$DB->set_field('course_categories', 'parent', $newparentcat->id, array('id'=>$category->id))) {
- return false;
- }
+ $DB->set_field('course_categories', 'parent', $newparentcat->id, array('id'=>$category->id));
$newparent = get_context_instance(CONTEXT_COURSECAT, $newparentcat->id);
}
// and fix the sortorders
fix_course_sortorder();
-
- return true;
}
/**
$cm->indent = 0;
}
- if (!$DB->set_field('course_modules', 'indent', $cm->indent, array('id'=>$cm->id))) {
- print_error('cannotupdatelevel');
- }
+ $DB->set_field('course_modules', 'indent', $cm->indent, array('id'=>$cm->id));
rebuild_course_cache($cm->course);
condition_info::update_cm_from_form($cm,$fromform,true);
}
- if (!$DB->update_record('course_modules', $cm)) {
- print_error('cannotupdatecoursemodule');
- }
+ $DB->update_record('course_modules', $cm);
if (!$updateinstancefunction($fromform, $mform)) {
print_error('cannotupdatemod', '', 'view.php?id=$course->id', $fromform->modulename);
$string['cannotsetupcapformod'] = 'Could not set up the capabilities for $a';
$string['cannotshowhidecoursesincategory'] = 'Cannot show/hide the courses in category $a.';
$string['cannotunzipfile'] = 'Cannot unzip file';
-$string['cannotupgradeblock'] = 'Upgrade of blocks system failed! (Could not update version in config table.)';
-$string['cannotupgradecaps'] = 'Had difficulties upgrading the core capabilities for the Roles system';
-$string['cannotupdatecategory'] = 'Could not update the category ($a)';
-$string['cannotupdatecoursemodule'] = 'Could not update the course module';
-$string['cannotupdatecomment'] = 'Could not update this comment';
$string['cannotupdatecm'] = 'Could not update the course module with the correct section';
-$string['cannotupdatefield'] = 'Error updating field';
-$string['cannotupdatelevel'] = 'Could not update the indent level on that course module';
$string['cannotupdategroup'] = 'Error updating group';
$string['cannotupdaterate'] = 'Could not update an old rating ($a->id = $a->rating)';
$string['cannotupdaterecord'] = 'Could not update record ID $a';
$updatedcomment->format = $data->format;
$updatedcomment->timemodified = time();
- if (!$DB->update_record('glossary_comments', $updatedcomment)) {
- print_error('cannotupdatecomment');
- } else {
- add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&eid=$entry->id", "$updatedcomment->id",$cm->id);
- }
+ $DB->update_record('glossary_comments', $updatedcomment);
+ add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&eid=$entry->id", "$updatedcomment->id",$cm->id);
+
redirect("comments.php?id=$cm->id&eid=$entry->id");
} else {
$cat->name = $name;
$cat->usedynalink = $usedynalink;
- if ( !$DB->update_record("glossary_categories", $cat) ) {
- 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);
- }
+ $DB->update_record("glossary_categories", $cat);
+ add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id);
+
} else {
echo "<p style=\"text-align:center\">" . get_string("edit"). " " . get_string("category","glossary") . "<span style=\"font-size:1.5em\">";
print_error('cannotaddcoursemoduletosection');
}
- if (! $DB->set_field('course_modules', 'section', $sectionid, array("id"=>$hotpot->coursemodule))) {
- print_error('cannotupdatecoursemodule');
- }
+ $DB->set_field('course_modules', 'section', $sectionid, array("id"=>$hotpot->coursemodule));
add_to_log($hotpot->course, "course", "add mod",
"../mod/$hotpot->modulename/view.php?id=$hotpot->coursemodule",
if (empty($data->id)) {
unset($data->id);
- if (!$data->id = $DB->insert_record('user_info_field', $data)) {
- print_error('cannotcreatefield');
- }
+ $data->id = $DB->insert_record('user_info_field', $data);
} else {
- if (!$DB->update_record('user_info_field', $data)) {
- print_error('cannotupdatefield');
- }
+ $DB->update_record('user_info_field', $data);
}
}
if (empty($data->id)) {
unset($data->id);
$data->sortorder = $DB->count_records('user_info_category') + 1;
- if (!$DB->insert_record('user_info_category', $data, false)) {
- print_error('cannotinsertcategory');
- }
+ $DB->insert_record('user_info_category', $data, false);
} else {
- if (!$DB->update_record('user_info_category', $data)) {
- print_error('cannotupdatecategory');
- }
+ $DB->update_record('user_info_category', $data);
}
profile_reorder_categories();
redirect($redirect);