MDL-14679 towards course conversion
This commit is contained in:
+3
-3
@@ -37,7 +37,7 @@
|
||||
print_error("unknowcategory");
|
||||
}
|
||||
|
||||
if (!$category = get_record("course_categories", "id", $id)) {
|
||||
if (!$category = $DB->get_record("course_categories", array("id"=>$id))) {
|
||||
print_error("unknowcategory");
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@
|
||||
$movecourse = $DB->get_record('course', array('id'=>$moveup));
|
||||
$swapcourse = $DB->get_record('course', array('category'=>$category->id, 'sortorder'=>($movecourse->sortorder-1)));
|
||||
} else {
|
||||
$movecourse = get_record('course', array('id'=>$movedown));
|
||||
$swapcourse = get_record('course', array('category'=>$category->id, 'sortorder'=>($movecourse->sortorder+1)));
|
||||
$movecourse = $DB->get_record('course', array('id'=>$movedown));
|
||||
$swapcourse = $DB->get_record('course', array('category'=>$category->id, 'sortorder'=>($movecourse->sortorder+1)));
|
||||
}
|
||||
|
||||
if ($swapcourse and $movecourse) { // Renumber everything for robustness
|
||||
|
||||
+15
-15
@@ -32,7 +32,7 @@ if ($categoryadd) { // Show Add category form: if $id is given, it is used as th
|
||||
} elseif (!is_null($id) && !$categoryadd) { // Show Edit category form: $id is given as the identifier of the category being edited
|
||||
$strtitle = get_string("editcategorysettings");
|
||||
$context = get_context_instance(CONTEXT_COURSECAT, $id);
|
||||
if (!$category = get_record("course_categories", "id", $id)) {
|
||||
if (!$category = $DB->get_record("course_categories", array("id"=>$id))) {
|
||||
print_error("unknowcategory");
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
|
||||
if ($resort and confirm_sesskey()) {
|
||||
if ($courses = get_courses($id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) {
|
||||
// move it off the range
|
||||
$count = get_record_sql('SELECT MAX(sortorder) AS max, 1
|
||||
$count = $DB->get_record_sql('SELECT MAX(sortorder) AS max, 1
|
||||
FROM ' . $CFG->prefix . 'course WHERE category=' . $category->id);
|
||||
$count = $count->max + 100;
|
||||
begin_sql();
|
||||
@@ -209,7 +209,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
|
||||
require_capability('moodle/category:update', $context);
|
||||
require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto));
|
||||
|
||||
if (!$destcategory = get_record("course_categories", "id", $data->moveto)) {
|
||||
if (!$destcategory = $DB->get_record("course_categories", array("id"=>$data->moveto))) {
|
||||
pritn_error("unknowcategory");
|
||||
}
|
||||
// TODO function to move the category
|
||||
@@ -219,10 +219,10 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
|
||||
if ((!empty($hide) or !empty($show)) and confirm_sesskey()) {
|
||||
require_capability('moodle/category:visibility', $context);
|
||||
if (!empty($hide)) {
|
||||
$category = get_record("course_categories", "id", $hide);
|
||||
$category = $DB->get_record("course_categories", array("id"=>$hide));
|
||||
$visible = 0;
|
||||
} else {
|
||||
$category = get_record("course_categories", "id", $show);
|
||||
$category = $DB->get_record("course_categories", array("id"=>$show));
|
||||
$visible = 1;
|
||||
}
|
||||
if ($category) {
|
||||
@@ -242,19 +242,19 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
|
||||
// TODO something like fix_course_sortorder() ?
|
||||
|
||||
// we are going to need to know the range
|
||||
$max = get_record_sql('SELECT MAX(sortorder) AS max, 1 FROM ' . $CFG->prefix . 'course_categories WHERE id=' . $category->id);
|
||||
$max = $DB->get_record_sql('SELECT MAX(sortorder) AS max, 1 FROM ' . $CFG->prefix . 'course_categories WHERE id=' . $category->id);
|
||||
$max = $max->max + 100;
|
||||
|
||||
if (!empty($moveup)) {
|
||||
$movecategory = get_record('course_categories', 'id', $moveup);
|
||||
$swapcategory = get_record('course_categories',
|
||||
'category', $category->id,
|
||||
'sortorder', $movecategory->sortorder - 1);
|
||||
$movecategory = $DB->get_record('course_categories', array('id'=>$moveup));
|
||||
$swapcategory = $DB->get_record('course_categories',
|
||||
array('category'=>$category->id,
|
||||
'sortorder'=>$movecategory->sortorder - 1));
|
||||
} else {
|
||||
$movecategory = get_record('course_categories', 'id', $movedown);
|
||||
$swapcategory = get_record('course_categories',
|
||||
'category', $category->id,
|
||||
'sortorder', $movecategory->sortorder + 1);
|
||||
$movecategory = $DB->get_record('course_categories', array('id'=>$movedown));
|
||||
$swapcategory = $DB->get_record('course_categories',
|
||||
array('category'=> $category->id,
|
||||
'sortorder'=>$movecategory->sortorder + 1));
|
||||
}
|
||||
|
||||
if ($swapcourse and $movecourse) { // Renumber everything for robustness
|
||||
@@ -273,7 +273,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) {
|
||||
} // End of editing stuff
|
||||
|
||||
// Print out all the sub-categories
|
||||
if ($subcategories = get_records("course_categories", "parent", $category->id, "sortorder ASC")) {
|
||||
if ($subcategories = $DB->get_records("course_categories", array("parent"=>$category->id), "sortorder ASC")) {
|
||||
$firstentry = true;
|
||||
foreach ($subcategories as $subcategory) {
|
||||
if ($subcategory->visible or has_capability('moodle/course:create', $context)) {
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@
|
||||
print_error("invalidshortname");
|
||||
}
|
||||
} else {
|
||||
if (!$course = get_record("course", array("id"=>$id))) {
|
||||
if (!$course = $DB->get_record("course", array("id"=>$id))) {
|
||||
print_error("invalidcourseid");
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@
|
||||
if ($managerroles = get_config('', 'coursemanager')) {
|
||||
$coursemanagerroles = split(',', $managerroles);
|
||||
foreach ($coursemanagerroles as $roleid) {
|
||||
$role = get_record('role','id',$roleid);
|
||||
$role = $DB->get_record('role', array('id'=>$roleid));
|
||||
$canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
|
||||
$roleid = (int) $roleid;
|
||||
if ($users = get_role_users($roleid, $context, true, '', 'u.lastname ASC', $canseehidden)) {
|
||||
|
||||
+4
-4
@@ -414,7 +414,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
|
||||
if (isset($ldcache[$log->module][$log->action])) {
|
||||
$ld = $ldcache[$log->module][$log->action];
|
||||
} else {
|
||||
$ld = get_record('log_display', 'module', $log->module, 'action', $log->action);
|
||||
$ld = $DB->get_record('log_display', array('module'=>$log->module, 'action'=>$log->action));
|
||||
$ldcache[$log->module][$log->action] = $ld;
|
||||
}
|
||||
if (0 && $ld && !empty($log->info)) {
|
||||
@@ -511,7 +511,7 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
|
||||
if (isset($ldcache[$log->module][$log->action])) {
|
||||
$ld = $ldcache[$log->module][$log->action];
|
||||
} else {
|
||||
$ld = get_record('log_display', 'module', $log->module, 'action', $log->action);
|
||||
$ld = $DB->get_record('log_display', array('module'=>$log->module, 'action'=>$log->action));
|
||||
$ldcache[$log->module][$log->action] = $ld;
|
||||
}
|
||||
if ($ld && !empty($log->info)) {
|
||||
@@ -781,10 +781,10 @@ function print_log_graph($course, $userid=0, $type="course.png", $date=0) {
|
||||
|
||||
|
||||
function print_overview($courses) {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
$htmlarray = array();
|
||||
if ($modules = get_records('modules')) {
|
||||
if ($modules = $DB->get_records('modules')) {
|
||||
foreach ($modules as $mod) {
|
||||
if (file_exists(dirname(dirname(__FILE__)).'/mod/'.$mod->name.'/lib.php')) {
|
||||
include_once(dirname(dirname(__FILE__)).'/mod/'.$mod->name.'/lib.php');
|
||||
|
||||
+13
-13
@@ -15,7 +15,7 @@
|
||||
$rejectnotice = optional_param('rejectnotice', '', PARAM_CLEANHTML);
|
||||
|
||||
if (!empty($approve) and confirm_sesskey()) {
|
||||
if ($course = get_record("course_request","id",$approve)) {
|
||||
if ($course = $DB->get_record("course_request", array("id"=>$approve))) {
|
||||
foreach (array_keys((array)$course) as $key) {
|
||||
$course->$key = addslashes($course->$key);
|
||||
}
|
||||
@@ -23,13 +23,13 @@
|
||||
// place at beginning of category
|
||||
fix_course_sortorder();
|
||||
|
||||
if (empty($CFG->defaultrequestcategory) or !record_exists('course_categories', 'id', $CFG->defaultrequestcategory)) {
|
||||
if (empty($CFG->defaultrequestcategory) or !$DB->record_exists('course_categories', array('id'=>$CFG->defaultrequestcategory))) {
|
||||
// default to first top level directory, hacky but means things don't break
|
||||
$CFG->defaultrequestcategory = get_field('course_categories', 'id', 'parent', '0');
|
||||
$CFG->defaultrequestcategory = $DB->get_field('course_categories', 'id', array('parent'=>'0'));
|
||||
}
|
||||
|
||||
$course->category = $CFG->defaultrequestcategory;
|
||||
$course->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category=$course->category");
|
||||
$course->sortorder = $DB->get_field_sql("SELECT min(sortorder)-1 FROM {course} WHERE category=?", array($course->category));
|
||||
if (empty($course->sortorder)) {
|
||||
$course->sortorder = 1000;
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor != 'none' && !empty($CFG->restrictbydefault)) {
|
||||
$course->restrictmodules = 1;
|
||||
}
|
||||
if ($courseid = insert_record("course",$course)) {
|
||||
if ($courseid = $DB->insert_record("course",$course)) {
|
||||
$page = page_create_object(PAGE_COURSE_VIEW, $courseid);
|
||||
blocks_repopulate_page($page); // Return value not checked because you can always edit later
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
@@ -55,11 +55,11 @@
|
||||
$allowedmods = explode(',',$CFG->defaultallowedmodules);
|
||||
update_restricted_mods($course,$allowedmods);
|
||||
}
|
||||
delete_records('course_request','id',$approve);
|
||||
$DB->delete_records('course_request', array('id'=>$approve));
|
||||
$success = 1;
|
||||
}
|
||||
if (!empty($success)) {
|
||||
$user = get_record('user','id',$teacherid);
|
||||
$user = $DB->get_record('user', array('id'=>$teacherid));
|
||||
$a->name = $course->fullname;
|
||||
$a->url = $CFG->wwwroot.'/course/view.php?id='.$courseid;
|
||||
$a->teacher = $course->teacher;
|
||||
@@ -80,7 +80,7 @@
|
||||
print_header($strtitle,$strheading,build_navigation(array(array('name'=>$strheading,'link'=>'','type'=>'misc'))));
|
||||
|
||||
if (!empty($reject) and confirm_sesskey()) {
|
||||
if ($reject = get_record("course_request","id",$reject)) {
|
||||
if ($reject = $DB->get_record("course_request", array("id"=>$reject))) {
|
||||
if (empty($rejectnotice)) {
|
||||
// display a form for writing a reason
|
||||
print_simple_box_start('center');
|
||||
@@ -89,13 +89,13 @@
|
||||
print_simple_box_end();
|
||||
}
|
||||
else {
|
||||
$user = get_record("user","id",$reject->requester);
|
||||
$user = $DB->get_record("user", array("id"=>$reject->requester));
|
||||
email_to_user($user,$USER,get_string('courserejectsubject'),get_string('courserejectemail','moodle',$rejectnotice));
|
||||
delete_records("course_request","id",$reject->id);
|
||||
$DB->delete_records("course_request", array("id"=>$reject->id));
|
||||
notice(get_string('courserejected'),'pending.php');
|
||||
}
|
||||
}
|
||||
} else if ($pending = get_records("course_request")) {
|
||||
} else if ($pending = $DB->get_records("course_request")) {
|
||||
// loop through
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 3;
|
||||
@@ -104,9 +104,9 @@
|
||||
get_string('requestreason'),'');
|
||||
$strrequireskey = get_string('requireskey');
|
||||
foreach ($pending as $course) {
|
||||
$requester = get_record('user','id',$course->requester);
|
||||
$requester = $DB->get_record('user', array('id'=>$course->requester));
|
||||
// check here for shortname collisions and warn about them.
|
||||
if ($match = get_record("course","shortname",$course->shortname)) {
|
||||
if ($match = $DB->get_record("course", array("shortname"=>$course->shortname))) {
|
||||
$course->shortname .= ' [*]';
|
||||
$collision = 1;
|
||||
}
|
||||
|
||||
+7
-7
@@ -8,7 +8,7 @@
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
|
||||
if (!$course = get_record('course', 'id', $id) ) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error("That's an invalid course id");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
$dateinfo = get_string('alldays');
|
||||
|
||||
if (!empty($param->user)) {
|
||||
if (!$u = get_record('user', 'id', $param->user) ) {
|
||||
if (!$u = $DB->get_record('user', array('id'=>$param->user))) {
|
||||
print_error("That's an invalid user!");
|
||||
}
|
||||
$userinfo = fullname($u);
|
||||
@@ -70,11 +70,11 @@
|
||||
$hiddenfilter = "AND cs.visible = 1";
|
||||
}
|
||||
$sections = array();
|
||||
if ($ss = get_records_sql("SELECT cs.id, cs.section, cs.sequence, cs.summary, cs.visible
|
||||
FROM {$CFG->prefix}course_sections cs
|
||||
WHERE cs.course = $course->id AND cs.section <= $course->numsections
|
||||
$hiddenfilter
|
||||
ORDER BY section")) {
|
||||
if ($ss = $DB->get_records_sql("SELECT cs.id, cs.section, cs.sequence, cs.summary, cs.visible
|
||||
FROM {course_sections} cs
|
||||
WHERE cs.course = ? AND cs.section <= ?
|
||||
$hiddenfilter
|
||||
ORDER BY section", array($course->id, $course->numsections))) {
|
||||
foreach ($ss as $section) {
|
||||
$sections[$section->section] = $section;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class course_reset_form extends moodleform {
|
||||
function definition (){
|
||||
global $CFG, $COURSE;
|
||||
global $CFG, $COURSE, $DB;
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
@@ -49,7 +49,7 @@ class course_reset_form extends moodleform {
|
||||
}
|
||||
|
||||
$unsupported_mods = array();
|
||||
if ($allmods = get_records('modules') ) {
|
||||
if ($allmods = $DB->get_records('modules') ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
if (!count_records($modname, 'course', $COURSE->id)) {
|
||||
@@ -91,7 +91,7 @@ class course_reset_form extends moodleform {
|
||||
}
|
||||
|
||||
function load_defaults() {
|
||||
global $CFG, $COURSE;
|
||||
global $CFG, $COURSE, $DB;
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
@@ -103,7 +103,7 @@ class course_reset_form extends moodleform {
|
||||
$defaults['reset_roles'] = array($CFG->defaultcourseroleid);
|
||||
}
|
||||
|
||||
if ($allmods = get_records('modules') ) {
|
||||
if ($allmods = $DB->get_records('modules') ) {
|
||||
foreach ($allmods as $mod) {
|
||||
$modname = $mod->name;
|
||||
$modfile = $CFG->dirroot."/mod/$modname/lib.php";
|
||||
|
||||
+8
-8
@@ -23,7 +23,7 @@ $visible = optional_param('visible', 0, PARAM_INT);
|
||||
|
||||
|
||||
// Authorise the user and verify some incoming data
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
error_log('AJAX commands.php: Course does not exist');
|
||||
die;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ switch($_SERVER['REQUEST_METHOD']) {
|
||||
|
||||
case 'section':
|
||||
|
||||
if (!record_exists('course_sections','course',$course->id,'section',$id)) {
|
||||
if (!$DB->record_exists('course_sections', array('course'=>$course->id, 'section'=>$id))) {
|
||||
error_log('AJAX commands.php: Bad Section ID '.$id);
|
||||
die;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ switch($_SERVER['REQUEST_METHOD']) {
|
||||
break;
|
||||
|
||||
case 'resource':
|
||||
if (!$mod = get_record('course_modules', 'id', $id, 'course', $course->id)) {
|
||||
if (!$mod = $DB->get_record('course_modules', array('id'=>$id, 'course'=>$course->id))) {
|
||||
error_log('AJAX commands.php: Bad course module ID '.$id);
|
||||
die;
|
||||
}
|
||||
@@ -113,13 +113,13 @@ switch($_SERVER['REQUEST_METHOD']) {
|
||||
break;
|
||||
|
||||
case 'move':
|
||||
if (!$section = get_record('course_sections','course',$course->id,'section',$sectionid)) {
|
||||
if (!$section = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>$sectionid))) {
|
||||
error_log('AJAX commands.php: Bad section ID '.$sectionid);
|
||||
die;
|
||||
}
|
||||
|
||||
if ($beforeid > 0){
|
||||
$beforemod = get_record('course_modules', 'id', $beforeid);
|
||||
$beforemod = $DB->get_record('course_modules', array('id'=>$beforeid));
|
||||
} else {
|
||||
$beforemod = NULL;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ switch($_SERVER['REQUEST_METHOD']) {
|
||||
$newcourse = new object;
|
||||
$newcourse->id = $course->id;
|
||||
$newcourse->marker = $value;
|
||||
if (!update_record('course',$newcourse)) {
|
||||
if (!$DB->update_record('course', $newcourse)) {
|
||||
error_log('AJAX commands.php: Failed to update course marker for course '.$newcourse->id);
|
||||
die;
|
||||
}
|
||||
@@ -157,11 +157,11 @@ switch($_SERVER['REQUEST_METHOD']) {
|
||||
break;
|
||||
|
||||
case 'resource':
|
||||
if (!$cm = get_record('course_modules', 'id', $id, 'course', $course->id)) {
|
||||
if (!$cm = $DB->get_record('course_modules', array('id'=>$id, 'course'=>$course->id))) {
|
||||
error_log('AJAX rest.php: Bad course module ID '.$id);
|
||||
die;
|
||||
}
|
||||
if (!$mod = get_record('modules', 'id', $cm->module)) {
|
||||
if (!$mod = $DB->get_record('modules', array('id'=>$cm->module))) {
|
||||
error_log('AJAX rest.php: Bad module ID '.$cm->module);
|
||||
die;
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@
|
||||
|
||||
print_header($strscales);
|
||||
|
||||
if ($scales = get_records("scale", "courseid", "$course->id", "name ASC")) {
|
||||
if ($scales = $DB->get_records("scale", array("courseid"=>$course->id), "name ASC")) {
|
||||
print_heading($strcustomscales);
|
||||
|
||||
if (has_capability('moodle/course:managescales', $context)) {
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($scales = get_records("scale", "courseid", "0", "name ASC")) {
|
||||
if ($scales = $DB->get_records("scale", array("courseid"=>0), "name ASC")) {
|
||||
print_heading($strstandardscales);
|
||||
foreach ($scales as $scale) {
|
||||
$scalemenu = make_menu_from_list($scale->scale);
|
||||
|
||||
+14
-14
@@ -53,14 +53,14 @@
|
||||
|
||||
if ($hide or $show and confirm_sesskey()) {
|
||||
if ($hide) {
|
||||
$course = get_record("course", "id", $hide);
|
||||
$course = $DB->get_record("course", array("id"=>$hide));
|
||||
$visible = 0;
|
||||
} else {
|
||||
$course = get_record("course", "id", $show);
|
||||
$course = $DB->get_record("course", array("id"=>$show));
|
||||
$visible = 1;
|
||||
}
|
||||
if ($course) {
|
||||
if (! set_field("course", "visible", $visible, "id", $course->id)) {
|
||||
if (! $DB->set_field("course", "visible", $visible, array("id"=>$course->id))) {
|
||||
notify("Could not update that course!");
|
||||
}
|
||||
}
|
||||
@@ -107,9 +107,9 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
|
||||
if (!empty($moveto) and $data = data_submitted(false) and confirm_sesskey()) { // Some courses are being moved
|
||||
|
||||
if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
|
||||
if (! $destcategory = $DB->get_record("course_categories", array("id"=>$data->moveto))) {
|
||||
print_error('cannotfindcategory', '', '', $data->moveto);
|
||||
}
|
||||
|
||||
@@ -125,8 +125,8 @@
|
||||
// get list of courses containing blocks if required
|
||||
if (!empty($blocklist) and confirm_sesskey()) {
|
||||
$blockid = $blocklist;
|
||||
if (!$blocks = get_records('block_instance', 'blockid', $blockid)) {
|
||||
print_error( 'blockcannotread', '', '', $blockid);
|
||||
if (!$blocks = $DB->get_records('block_instance', array('blockid'=>$blockid))) {
|
||||
print_error('blockcannotread', '', '', $blockid);
|
||||
}
|
||||
|
||||
// run through blocks and get (unique) courses
|
||||
@@ -138,7 +138,7 @@
|
||||
if ($courseid==0 || $block->pagetype != 'course-view') {
|
||||
continue;
|
||||
}
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('invalidcourseid', '', '', $courseid);
|
||||
}
|
||||
$courses[$courseid] = $course;
|
||||
@@ -148,7 +148,7 @@
|
||||
// get list of courses containing modules if required
|
||||
elseif (!empty($modulelist) and confirm_sesskey()) {
|
||||
$modulename = $modulelist;
|
||||
if (!$modules = get_records($modulename)) {
|
||||
if (!$modules = $DB->get_records($modulename)) {
|
||||
print_error('invalidmodulename', '', '', $modulename);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
if ($courseid==0) {
|
||||
continue;
|
||||
}
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('invalidcourseid', '', '', $courseid);
|
||||
}
|
||||
$courses[$courseid] = $course;
|
||||
@@ -180,7 +180,7 @@
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $strcourses, 'link' => 'index.php', 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strsearch, 'link' => 'search.php', 'type' => 'misc');
|
||||
$navlinks[] = array('name' => "'".s($search, true)."'", 'link' => null, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => "'".s($search)."'", 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$site->fullname : $strsearchresults", $site->fullname, $navigation, "", "", "", $searchform);
|
||||
@@ -191,7 +191,7 @@
|
||||
|
||||
print_heading("$strsearchresults: $totalcount");
|
||||
|
||||
$encodedsearch = urlencode(stripslashes($search));
|
||||
$encodedsearch = urlencode($search);
|
||||
print_paging_bar($totalcount, $page, $perpage, "search.php?search=$encodedsearch&perpage=$perpage&",'page',($perpage == 99999));
|
||||
|
||||
if ($perpage != 99999 && $totalcount > $perpage) {
|
||||
@@ -215,7 +215,7 @@
|
||||
|
||||
echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
|
||||
echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search, true)."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"page\" value=\"$page\" />\n";
|
||||
echo "<input type=\"hidden\" name=\"perpage\" value=\"$perpage\" /></div>\n";
|
||||
echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"4\" class=\"generalbox boxaligncenter\">\n<tr>\n";
|
||||
@@ -329,7 +329,7 @@
|
||||
|
||||
} else {
|
||||
if (!empty($search)) {
|
||||
print_heading(get_string("nocoursesfound", "", s($search, true)));
|
||||
print_heading(get_string("nocoursesfound", "", s($search)));
|
||||
}
|
||||
else {
|
||||
print_heading( $strnovalidcourses );
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@
|
||||
print_header("$course->shortname: $strunenrol", $course->fullname, $navigation);
|
||||
|
||||
if ($userid) {
|
||||
if (!$user = get_record('user', 'id', $userid)) {
|
||||
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
|
||||
print_error('nousers');
|
||||
}
|
||||
$strunenrolsure = get_string('unenrolsure', '', fullname($user, true));
|
||||
|
||||
+10
-11
@@ -17,7 +17,7 @@
|
||||
print_error('invalidcourseid', 'error');
|
||||
}
|
||||
|
||||
if (! $user = get_record("user", "id", $user)) {
|
||||
if (! $user = $DB->get_record("user", array("id"=>$user))) {
|
||||
print_error('invaliduserid', 'error');
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
require_once $CFG->dirroot.'/grade/lib.php';
|
||||
require_once $CFG->dirroot.'/grade/report/'.$CFG->grade_profilereport.'/lib.php';
|
||||
|
||||
$course = get_record('course', 'id', required_param('id', PARAM_INT));
|
||||
$course = $DB->get_record('course', array('id'=>required_param('id', PARAM_INT)));
|
||||
$functionname = 'grade_report_'.$CFG->grade_profilereport.'_profilereport';
|
||||
if (function_exists($functionname)) {
|
||||
$functionname($course, $user);
|
||||
@@ -112,9 +112,9 @@
|
||||
notify ($statsstatus);
|
||||
}
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_daily ORDER BY timeend');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_weekly ORDER BY timeend');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_monthly ORDER BY timeend');
|
||||
$earliestday = $DB->get_field_sql('SELECT timeend FROM {stats_user_daily} ORDER BY timeend');
|
||||
$earliestweek = $DB_>get_field_sql('SELECT timeend FROM {stats_user_weekly} ORDER BY timeend');
|
||||
$earliestmonth = $DB->get_field_sql('SELECT timeend FROM {stats_user_monthly} ORDER BY timeend');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
@@ -134,16 +134,15 @@
|
||||
$time = array_pop(array_keys($timeoptions));
|
||||
|
||||
$param = stats_get_parameters($time,STATS_REPORT_USER_VIEW,$course->id,STATS_MODE_DETAILED);
|
||||
$params = $param->params;
|
||||
|
||||
$param->table = 'user_'.$param->table;
|
||||
|
||||
$sql = 'SELECT timeend,'.$param->fields.' FROM '.$CFG->prefix.'stats_'.$param->table.' WHERE '
|
||||
$sql = 'SELECT timeend,'.$param->fields.' FROM {stats_'.$param->table.'} WHERE '
|
||||
.(($course->id == SITEID) ? '' : ' courseid = '.$course->id.' AND ')
|
||||
.' userid = '.$user->id
|
||||
.' AND timeend >= '.$param->timeafter
|
||||
.$param->extras
|
||||
.' userid = '.$user->id.' AND timeend >= '.$param->timeafter .$param->extras
|
||||
.' ORDER BY timeend DESC';
|
||||
$stats = get_records_sql($sql);
|
||||
$stats = $DB->get_records_sql($sql, $params); //TODO: improve these params!!
|
||||
|
||||
if (empty($stats)) {
|
||||
print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
|
||||
@@ -220,7 +219,7 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
$instance = get_record("$mod->modname", "id", "$mod->instance");
|
||||
$instance = $DB->get_record("$mod->modname", array("id"=>$mod->instance));
|
||||
$libfile = "$CFG->dirroot/mod/$mod->modname/lib.php";
|
||||
|
||||
if (file_exists($libfile)) {
|
||||
|
||||
+5
-5
@@ -26,15 +26,15 @@
|
||||
}
|
||||
|
||||
if (!empty($name)) {
|
||||
if (! ($course = get_record('course', 'shortname', $name)) ) {
|
||||
if (! ($course = $DB->get_record('course', array('shortname'=>$name)))) {
|
||||
print_error('invalidcoursenameshort', 'error');
|
||||
}
|
||||
} else if (!empty($idnumber)) {
|
||||
if (! ($course = get_record('course', 'idnumber', $idnumber)) ) {
|
||||
if (! ($course = $DB->get_record('course', array('idnumber'=>$idnumber)))) {
|
||||
print_error('invalidcourseid', 'error');
|
||||
}
|
||||
} else {
|
||||
if (! ($course = get_record('course', 'id', $id)) ) {
|
||||
if (! ($course = $DB->get_record('course', array('id'=>$id)))) {
|
||||
print_error('invalidcourseid', 'error');
|
||||
}
|
||||
}
|
||||
@@ -211,11 +211,11 @@
|
||||
|
||||
if (! $sections = get_all_sections($course->id)) { // No sections found
|
||||
// Double-check to be extra sure
|
||||
if (! $section = get_record('course_sections', 'course', $course->id, 'section', 0)) {
|
||||
if (! $section = $DB->get_record('course_sections', array('course'=>$course->id, 'section'=>0))) {
|
||||
$section->course = $course->id; // Create a default section.
|
||||
$section->section = 0;
|
||||
$section->visible = 1;
|
||||
$section->id = insert_record('course_sections', $section);
|
||||
$section->id = $DB->insert_record('course_sections', $section);
|
||||
}
|
||||
if (! $sections = get_all_sections($course->id) ) { // Try again
|
||||
print_error('cannotcreateorfindstructs', 'error');
|
||||
|
||||
Reference in New Issue
Block a user