mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-27148 use new get_in_or_equal() param prefix instead of start
This commit is contained in:
parent
c49bec382c
commit
cf717dc26b
@ -387,10 +387,10 @@ class generator {
|
||||
.$this->get('number_of_modules')." modules in each section, for each course...");
|
||||
|
||||
list($modules_list_sql, $modules_params) =
|
||||
$DB->get_in_or_equal($this->get('modules_list'), SQL_PARAMS_NAMED, 'param0000', true);
|
||||
$DB->get_in_or_equal($this->get('modules_list'), SQL_PARAMS_NAMED, 'mod', true);
|
||||
|
||||
list($modules_ignored_sql, $ignore_params) =
|
||||
$DB->get_in_or_equal($this->modules_to_ignore, SQL_PARAMS_NAMED, 'param2000', false);
|
||||
$DB->get_in_or_equal($this->modules_to_ignore, SQL_PARAMS_NAMED, 'ignore', false);
|
||||
|
||||
$wheresql = "name $modules_list_sql AND name $modules_ignored_sql";
|
||||
$modules = $DB->get_records_select('modules', $wheresql, array_merge($modules_params, $ignore_params));
|
||||
|
@ -1142,7 +1142,7 @@ class existing_role_holders extends role_assign_user_selector_base {
|
||||
global $DB;
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params = array_merge($params, $ctxparams);
|
||||
$params['roleid'] = $this->roleid;
|
||||
|
||||
|
@ -228,7 +228,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
|
||||
// find obsolete users
|
||||
if (count($userlist)) {
|
||||
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u0000', false);
|
||||
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', false);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.id, u.username, u.email, u.auth
|
||||
FROM {user} u
|
||||
@ -290,7 +290,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
// only go ahead if we actually
|
||||
// have fields to update locally
|
||||
if (!empty($updatekeys)) {
|
||||
list($in_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u0000', true);
|
||||
list($in_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', true);
|
||||
$params['authtype'] = $this->authtype;
|
||||
$sql = "SELECT u.id, u.username
|
||||
FROM {user} u
|
||||
|
@ -196,7 +196,7 @@
|
||||
$actions = array_merge($viewnames, $postnames);
|
||||
}
|
||||
|
||||
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action0');
|
||||
list($actionsql, $params) = $DB->get_in_or_equal($actions, SQL_PARAMS_NAMED, 'action');
|
||||
$actionsql = "action $actionsql";
|
||||
|
||||
$relatedcontexts = get_related_contexts_string($context);
|
||||
|
@ -111,7 +111,7 @@ class enrol_category_handler {
|
||||
$params = array('courselevel'=>CONTEXT_COURSE, 'match'=>$parentcontext->path.'/%', 'userid'=>$ra->userid);
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
$params['userid'] = $ra->userid;
|
||||
|
||||
foreach ($rs as $instance) {
|
||||
@ -119,7 +119,7 @@ class enrol_category_handler {
|
||||
$contextids = get_parent_contexts($coursecontext);
|
||||
array_pop($contextids); // remove system context, we are interested in categories only
|
||||
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c000');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c');
|
||||
$params = array_merge($params, $contextparams);
|
||||
|
||||
$sql = "SELECT ra.id
|
||||
@ -168,8 +168,8 @@ function enrol_category_sync_course($course) {
|
||||
$contextids = get_parent_contexts($coursecontext);
|
||||
array_pop($contextids); // remove system context, we are interested in categories only
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
list($contextids, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'c');
|
||||
$params = array_merge($params, $contextparams);
|
||||
$params['courseid'] = $course->id;
|
||||
|
||||
@ -257,7 +257,7 @@ function enrol_category_sync_full() {
|
||||
return;
|
||||
}
|
||||
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r000');
|
||||
list($roleids, $params) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED, 'r');
|
||||
$params['courselevel'] = CONTEXT_COURSE;
|
||||
$params['catlevel'] = CONTEXT_COURSECAT;
|
||||
|
||||
|
@ -449,7 +449,7 @@ class enrol_ldap_plugin extends enrol_plugin {
|
||||
WHERE u.deleted = 0 AND e.courseid = :courseid ";
|
||||
$params = array('roleid'=>$role->id, 'courseid'=>$course_obj->id);
|
||||
if (!empty($ldapmembers)) {
|
||||
list($ldapml, $params2) = $DB->get_in_or_equal($ldapmembers, SQL_PARAMS_NAMED, 'm0', false);
|
||||
list($ldapml, $params2) = $DB->get_in_or_equal($ldapmembers, SQL_PARAMS_NAMED, 'm', false);
|
||||
$sql .= "AND u.idnumber $ldapml";
|
||||
$params = array_merge($params, $params2);
|
||||
unset($params2);
|
||||
|
@ -141,7 +141,7 @@ class course_enrolment_manager {
|
||||
public function get_total_other_users() {
|
||||
global $DB;
|
||||
if ($this->totalotherusers === null) {
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params['courseid'] = $this->course->id;
|
||||
$sql = "SELECT COUNT(DISTINCT u.id)
|
||||
FROM {role_assignments} ra
|
||||
@ -222,7 +222,7 @@ class course_enrolment_manager {
|
||||
}
|
||||
$key = md5("$sort-$direction-$page-$perpage");
|
||||
if (!array_key_exists($key, $this->otherusers)) {
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($ctxcondition, $params) = $DB->get_in_or_equal(get_parent_contexts($this->context, true), SQL_PARAMS_NAMED, 'ctx');
|
||||
$params['courseid'] = $this->course->id;
|
||||
$params['cid'] = $this->course->id;
|
||||
$sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, u.*, ue.lastseen
|
||||
|
@ -208,7 +208,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
|
||||
// iterate through all not enrolled yet users
|
||||
if (enrol_is_enabled('meta')) {
|
||||
list($enabled, $params) = $DB->get_in_or_equal(explode(',', $CFG->enrol_plugins_enabled), SQL_PARAMS_NAMED, 'e00');
|
||||
list($enabled, $params) = $DB->get_in_or_equal(explode(',', $CFG->enrol_plugins_enabled), SQL_PARAMS_NAMED, 'e');
|
||||
$onecourse = "";
|
||||
if ($courseid) {
|
||||
$params['courseid'] = $courseid;
|
||||
@ -267,7 +267,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
}
|
||||
$enabled[] = $DB->sql_empty(); // manual assignments are replicated too
|
||||
|
||||
list($enabled, $params) = $DB->get_in_or_equal($enabled, SQL_PARAMS_NAMED, 'e00');
|
||||
list($enabled, $params) = $DB->get_in_or_equal($enabled, SQL_PARAMS_NAMED, 'e');
|
||||
$sql = "SELECT DISTINCT pra.roleid, pra.userid, c.id AS contextid, e.id AS enrolid
|
||||
FROM {role_assignments} pra
|
||||
JOIN {user} u ON (u.id = pra.userid AND u.deleted = 0)
|
||||
@ -281,7 +281,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
$params['courseid'] = $courseid;
|
||||
|
||||
if ($ignored = $meta->get_config('nosyncroleids')) {
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'i00', false);
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'ig', false);
|
||||
$params = array_merge($params, $xparams);
|
||||
$sql = "$sql AND pra.roleid $notignored";
|
||||
}
|
||||
@ -296,7 +296,7 @@ function enrol_meta_sync($courseid = NULL) {
|
||||
// remove unwanted roles - include ignored roles and disabled plugins too
|
||||
$params = array('coursecontext' => CONTEXT_COURSE, 'courseid' => $courseid);
|
||||
if ($ignored = $meta->get_config('nosyncroleids')) {
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'i00', false);
|
||||
list($notignored, $xparams) = $DB->get_in_or_equal(explode(',', $ignored), SQL_PARAMS_NAMED, 'ig', false);
|
||||
$params = array_merge($params, $xparams);
|
||||
$notignored = "AND pra.roleid $notignored";
|
||||
} else {
|
||||
|
@ -164,7 +164,7 @@ function get_unenrolled_users_in_import($importcode, $courseid) {
|
||||
$relatedctxcondition = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
|
||||
//users with a gradeable role
|
||||
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
|
||||
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
|
||||
|
||||
//enrolled users
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
|
@ -89,7 +89,7 @@ class graded_users_iterator {
|
||||
$relatedcontexts = get_related_contexts_string($coursecontext);
|
||||
|
||||
list($gradebookroles_sql, $params) =
|
||||
$DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
|
||||
$DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
|
||||
|
||||
//limit to users with an active enrolment
|
||||
list($enrolledsql, $enrolledparams) = get_enrolled_sql($coursecontext);
|
||||
@ -144,7 +144,7 @@ class graded_users_iterator {
|
||||
|
||||
if (!empty($this->grade_items)) {
|
||||
$itemids = array_keys($this->grade_items);
|
||||
list($itemidsql, $grades_params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED, 'items0');
|
||||
list($itemidsql, $grades_params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED, 'items');
|
||||
$params = array_merge($params, $grades_params);
|
||||
// $params contents: gradebookroles, enrolledparams, groupid (for $groupwheresql) and itemids
|
||||
|
||||
@ -2245,7 +2245,7 @@ abstract class grade_helper {
|
||||
*/
|
||||
public static function get_plugins_reports($courseid) {
|
||||
global $SITE;
|
||||
|
||||
|
||||
if (self::$gradereports !== null) {
|
||||
return self::$gradereports;
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ class grade_report_grader extends grade_report {
|
||||
$this->users = array();
|
||||
$this->userselect_params = array();
|
||||
} else {
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid0');
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users), SQL_PARAMS_NAMED, 'usid');
|
||||
$this->userselect = "AND g.userid $usql";
|
||||
$this->userselect_params = $params;
|
||||
}
|
||||
|
@ -2540,7 +2540,7 @@ function get_roles_with_capability($capability, $permission = null, $context = n
|
||||
|
||||
if ($context) {
|
||||
$contexts = get_parent_contexts($context, true);
|
||||
list($insql, $params) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED, 'ctx000');
|
||||
list($insql, $params) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED, 'ctx');
|
||||
$contextsql = "AND rc.contextid $insql";
|
||||
} else {
|
||||
$params = array();
|
||||
@ -3097,7 +3097,7 @@ function get_enrolled_sql($context, $withcapability = '', $groupid = 0, $onlyact
|
||||
|
||||
// get all relevant capability info for all roles
|
||||
if ($withcapability) {
|
||||
list($incontexts, $cparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'ctx00');
|
||||
list($incontexts, $cparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'ctx');
|
||||
$cparams['cap'] = $withcapability;
|
||||
|
||||
$defs = array();
|
||||
@ -3741,7 +3741,7 @@ function fetch_context_capabilities($context) {
|
||||
|
||||
case CONTEXT_USER:
|
||||
$extracaps = array('moodle/grade:viewall');
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap');
|
||||
$SQL = "SELECT *
|
||||
FROM {capabilities}
|
||||
WHERE contextlevel = ".CONTEXT_USER."
|
||||
@ -3814,7 +3814,7 @@ function fetch_context_capabilities($context) {
|
||||
$extra = '';
|
||||
$extracaps = block_method_result($bi->blockname, 'get_extra_capabilities');
|
||||
if ($extracaps) {
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap0');
|
||||
list($extra, $params) = $DB->get_in_or_equal($extracaps, SQL_PARAMS_NAMED, 'cap');
|
||||
$extra = "OR name $extra";
|
||||
}
|
||||
|
||||
@ -4876,8 +4876,8 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
|
||||
|
||||
// we need to find out all roles that have these capabilities either in definition or in overrides
|
||||
$defs = array();
|
||||
list($incontexts, $params) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'con000');
|
||||
list($incaps, $params2) = $DB->get_in_or_equal($caps, SQL_PARAMS_NAMED, 'cap000');
|
||||
list($incontexts, $params) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED, 'con');
|
||||
list($incaps, $params2) = $DB->get_in_or_equal($caps, SQL_PARAMS_NAMED, 'cap');
|
||||
$params = array_merge($params, $params2);
|
||||
$sql = "SELECT rc.id, rc.roleid, rc.permission, rc.capability, ctx.path
|
||||
FROM {role_capabilities} rc
|
||||
@ -5001,7 +5001,7 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
|
||||
/// Groups
|
||||
if ($groups) {
|
||||
$groups = (array)$groups;
|
||||
list($grouptest, $grpparams) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED, 'grp000');
|
||||
list($grouptest, $grpparams) = $DB->get_in_or_equal($groups, SQL_PARAMS_NAMED, 'grp');
|
||||
$grouptest = "u.id IN (SELECT userid FROM {groups_members} gm WHERE gm.groupid $grouptest)";
|
||||
$params = array_merge($params, $grpparams);
|
||||
|
||||
@ -5016,7 +5016,7 @@ function get_users_by_capability($context, $capability, $fields = '', $sort = ''
|
||||
/// User exceptions
|
||||
if (!empty($exceptions)) {
|
||||
$exceptions = (array)$exceptions;
|
||||
list($exsql, $exparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'exc000', false);
|
||||
list($exsql, $exparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'exc', false);
|
||||
$params = array_merge($params, $exparams);
|
||||
$wherecond[] = "u.id $exsql";
|
||||
}
|
||||
@ -5538,7 +5538,7 @@ function user_has_role_assignment($userid, $roleid, $contextid = 0) {
|
||||
return false;
|
||||
}
|
||||
$parents = get_parent_contexts($context, true);
|
||||
list($contexts, $params) = $DB->get_in_or_equal($parents, SQL_PARAMS_NAMED, 'r0000');
|
||||
list($contexts, $params) = $DB->get_in_or_equal($parents, SQL_PARAMS_NAMED, 'r');
|
||||
$params['userid'] = $userid;
|
||||
$params['roleid'] = $roleid;
|
||||
|
||||
|
@ -533,13 +533,13 @@ class block_manager {
|
||||
$parentcontextids = get_parent_contexts($context);
|
||||
if ($parentcontextids) {
|
||||
list($parentcontexttest, $parentcontextparams) =
|
||||
$DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext0000');
|
||||
$DB->get_in_or_equal($parentcontextids, SQL_PARAMS_NAMED, 'parentcontext');
|
||||
$contexttest = "($contexttest OR (bi.showinsubcontexts = 1 AND bi.parentcontextid $parentcontexttest))";
|
||||
}
|
||||
|
||||
$pagetypepatterns = matching_page_type_patterns($this->page->pagetype);
|
||||
list($pagetypepatterntest, $pagetypepatternparams) =
|
||||
$DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest0000');
|
||||
$DB->get_in_or_equal($pagetypepatterns, SQL_PARAMS_NAMED, 'pagetypepatterntest');
|
||||
|
||||
list($ccselect, $ccjoin) = context_instance_preload_sql('b.id', CONTEXT_BLOCK, 'ctx');
|
||||
|
||||
|
@ -111,7 +111,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', array $excepti
|
||||
$fullname = $DB->sql_fullname('u.firstname', 'u.lastname');
|
||||
|
||||
if (!empty($exceptions)) {
|
||||
list($exceptions, $params) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex0000', false);
|
||||
list($exceptions, $params) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex', false);
|
||||
$except = "AND u.id $exceptions";
|
||||
} else {
|
||||
$except = "";
|
||||
@ -210,7 +210,7 @@ function get_users($get=true, $search='', $confirmed=false, array $exceptions=nu
|
||||
}
|
||||
|
||||
if ($exceptions) {
|
||||
list($exceptions, $eparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex0000', false);
|
||||
list($exceptions, $eparams) = $DB->get_in_or_equal($exceptions, SQL_PARAMS_NAMED, 'ex', false);
|
||||
$params = $params + $eparams;
|
||||
$except = " AND id $exceptions";
|
||||
}
|
||||
|
@ -3037,7 +3037,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
|
||||
// add roles without archetypes, it may contain weird things, but we can not fix them
|
||||
list($narsql, $params) = $DB->get_in_or_equal(array_keys($defaults), SQL_PARAMS_NAMED, 'ar000', false);
|
||||
list($narsql, $params) = $DB->get_in_or_equal(array_keys($defaults), SQL_PARAMS_NAMED, 'ar', false);
|
||||
$sql = "SELECT DISTINCT ra.roleid, con.contextlevel
|
||||
FROM {role_assignments} ra
|
||||
JOIN {context} con ON ra.contextid = con.id
|
||||
@ -4030,7 +4030,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
|
||||
// enabled
|
||||
$enabledplugins = explode(',', $CFG->enrol_plugins_enabled);
|
||||
list($sqlenabled, $params) = $DB->get_in_or_equal($enabledplugins, SQL_PARAMS_NAMED, 'ena00');
|
||||
list($sqlenabled, $params) = $DB->get_in_or_equal($enabledplugins, SQL_PARAMS_NAMED, 'ena');
|
||||
$params['siteid'] = SITEID;
|
||||
$sql = "INSERT INTO {enrol} (enrol, status, courseid, sortorder, enrolperiod, enrolstartdate, enrolenddate, expirynotify, expirythreshold,
|
||||
notifyall, password, cost, currency, roleid, timecreated, timemodified)
|
||||
@ -4042,7 +4042,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
WHERE c.id <> :siteid AND ra.enrol $sqlenabled";
|
||||
$processed = $DB->get_fieldset_sql("SELECT DISTINCT enrol FROM {enrol}");
|
||||
if ($processed) {
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np00', false);
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np', false);
|
||||
$params = array_merge($params, $params2);
|
||||
$sql = "$sql AND ra.enrol $sqlnotprocessed";
|
||||
}
|
||||
@ -4060,7 +4060,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
WHERE c.id <> :siteid";
|
||||
$processed = $DB->get_fieldset_sql("SELECT DISTINCT enrol FROM {enrol}");
|
||||
if ($processed) {
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np00', false);
|
||||
list($sqlnotprocessed, $params2) = $DB->get_in_or_equal($processed, SQL_PARAMS_NAMED, 'np', false);
|
||||
$params = array_merge($params, $params2);
|
||||
$sql = "$sql AND ra.enrol $sqlnotprocessed";
|
||||
}
|
||||
@ -4310,7 +4310,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
$params = array('syscontext'=>$syscontext->id, 'participate'=>'moodle/course:participate');
|
||||
$roles = $DB->get_fieldset_sql("SELECT DISTINCT roleid FROM {role_capabilities} WHERE contextid = :syscontext AND capability = :participate AND permission = 1", $params);
|
||||
if ($roles) {
|
||||
list($sqlroles, $params) = $DB->get_in_or_equal($roles, SQL_PARAMS_NAMED, 'r00');
|
||||
list($sqlroles, $params) = $DB->get_in_or_equal($roles, SQL_PARAMS_NAMED, 'r');
|
||||
|
||||
$sql = "INSERT INTO {user_enrolments} (status, enrolid, userid, timestart, timeend, modifierid, timecreated, timemodified)
|
||||
|
||||
|
@ -244,7 +244,7 @@ function enrol_sharing_course($user1, $user2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($plugins, $params) = $DB->get_in_or_equal($plugins, SQL_PARAMS_NAMED, 'ee00');
|
||||
list($plugins, $params) = $DB->get_in_or_equal($plugins, SQL_PARAMS_NAMED, 'ee');
|
||||
$params['enabled'] = ENROL_INSTANCE_ENABLED;
|
||||
$params['active1'] = ENROL_USER_ACTIVE;
|
||||
$params['active2'] = ENROL_USER_ACTIVE;
|
||||
|
@ -208,7 +208,7 @@ function grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance,
|
||||
|
||||
$count = count($grades);
|
||||
if ($count > 0 and $count < 200) {
|
||||
list($uids, $params) = $DB->get_in_or_equal(array_keys($grades), SQL_PARAMS_NAMED, $start='uid0');
|
||||
list($uids, $params) = $DB->get_in_or_equal(array_keys($grades), SQL_PARAMS_NAMED, $start='uid');
|
||||
$params['gid'] = $grade_item->id;
|
||||
$sql = "SELECT * FROM {grade_grades} WHERE itemid = :gid AND userid $uids";
|
||||
|
||||
|
@ -378,8 +378,8 @@ function stats_cron_daily($maxdays=1) {
|
||||
|
||||
|
||||
/// individual user stats (including not-logged-in) in each course, this is slow - reuse this data if possible
|
||||
list($viewactionssql, $params1) = $DB->get_in_or_equal($viewactions, SQL_PARAMS_NAMED, 'view000');
|
||||
list($postactionssql, $params2) = $DB->get_in_or_equal($postactions, SQL_PARAMS_NAMED, 'post000');
|
||||
list($viewactionssql, $params1) = $DB->get_in_or_equal($viewactions, SQL_PARAMS_NAMED, 'view');
|
||||
list($postactionssql, $params2) = $DB->get_in_or_equal($postactions, SQL_PARAMS_NAMED, 'post');
|
||||
$sql = "INSERT INTO {stats_user_daily} (stattype, timeend, courseid, userid, statsreads, statswrites)
|
||||
|
||||
SELECT 'activity' AS stattype, $nextmidnight AS timeend, d.courseid, d.userid,
|
||||
|
@ -336,7 +336,7 @@ class mnetservice_enrol {
|
||||
if (empty($list)) {
|
||||
$DB->delete_records('mnetservice_enrol_enrolments', array('hostid'=>$mnethostid, 'remotecourseid'=>$remotecourseid));
|
||||
} else {
|
||||
list($isql, $params) = $DB->get_in_or_equal(array_keys($list), SQL_PARAMS_NAMED, 'param0000', false);
|
||||
list($isql, $params) = $DB->get_in_or_equal(array_keys($list), SQL_PARAMS_NAMED, 'param', false);
|
||||
$params['hostid'] = $mnethostid;
|
||||
$params['remotecourseid'] = $remotecourseid;
|
||||
$select = "hostid = :hostid AND remotecourseid = :remotecourseid AND id $isql";
|
||||
@ -556,7 +556,7 @@ class mnetservice_enrol_potential_users_selector extends user_selector_base {
|
||||
return array();
|
||||
}
|
||||
|
||||
list($usql, $uparams) = $DB->get_in_or_equal(array_keys($userids), SQL_PARAMS_NAMED, 'uid0000');
|
||||
list($usql, $uparams) = $DB->get_in_or_equal(array_keys($userids), SQL_PARAMS_NAMED, 'uid');
|
||||
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
|
||||
|
@ -1939,7 +1939,7 @@ function forum_search_posts($searchterms, $courseid=0, $limitfrom=0, $limitnum=5
|
||||
if ($forum->type == 'qanda'
|
||||
&& !has_capability('mod/forum:viewqandawithoutposting', $context)) {
|
||||
if (!empty($forum->onlydiscussions)) {
|
||||
list($discussionid_sql, $discussionid_params) = $DB->get_in_or_equal($forum->onlydiscussions, SQL_PARAMS_NAMED, 'qanda'.$forumid.'_0000');
|
||||
list($discussionid_sql, $discussionid_params) = $DB->get_in_or_equal($forum->onlydiscussions, SQL_PARAMS_NAMED, 'qanda'.$forumid.'_');
|
||||
$params = array_merge($params, $discussionid_params);
|
||||
$select[] = "(d.id $discussionid_sql OR p.parent = 0)";
|
||||
} else {
|
||||
@ -1948,7 +1948,7 @@ function forum_search_posts($searchterms, $courseid=0, $limitfrom=0, $limitnum=5
|
||||
}
|
||||
|
||||
if (!empty($forum->onlygroups)) {
|
||||
list($groupid_sql, $groupid_params) = $DB->get_in_or_equal($forum->onlygroups, SQL_PARAMS_NAMED, 'grps'.$forumid.'_0000');
|
||||
list($groupid_sql, $groupid_params) = $DB->get_in_or_equal($forum->onlygroups, SQL_PARAMS_NAMED, 'grps'.$forumid.'_');
|
||||
$params = array_merge($params, $groupid_params);
|
||||
$select[] = "d.groupid $groupid_sql";
|
||||
}
|
||||
@ -1963,7 +1963,7 @@ function forum_search_posts($searchterms, $courseid=0, $limitfrom=0, $limitnum=5
|
||||
}
|
||||
|
||||
if ($fullaccess) {
|
||||
list($fullid_sql, $fullid_params) = $DB->get_in_or_equal($fullaccess, SQL_PARAMS_NAMED, 'fula0');
|
||||
list($fullid_sql, $fullid_params) = $DB->get_in_or_equal($fullaccess, SQL_PARAMS_NAMED, 'fula');
|
||||
$params = array_merge($params, $fullid_params);
|
||||
$where[] = "(d.forum $fullid_sql)";
|
||||
}
|
||||
|
@ -241,7 +241,7 @@
|
||||
if ($hook == 'SPECIAL') {
|
||||
//Create appropiate IN contents
|
||||
$alphabet = explode(",", get_string('alphabet', 'langconfig'));
|
||||
list($nia, $aparams) = $DB->get_in_or_equal($alphabet, SQL_PARAMS_NAMED, $start='a0', false);
|
||||
list($nia, $aparams) = $DB->get_in_or_equal($alphabet, SQL_PARAMS_NAMED, $start='a', false);
|
||||
$params = array_merge($params, $aparams);
|
||||
$where = "AND " . $DB->sql_substr("upper(concept)", 1, 1) . " $nia";
|
||||
}
|
||||
|
@ -245,19 +245,19 @@ class quiz_overview_report extends quiz_default_report {
|
||||
break;
|
||||
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH:
|
||||
// Show only students with attempts
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000');
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $allowed_params;
|
||||
$where = "u.id $allowed_usql AND qa.preview = 0 AND qa.id IS NOT NULL";
|
||||
break;
|
||||
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
|
||||
// Show only students without attempts
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000');
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $allowed_params;
|
||||
$where = "u.id $allowed_usql AND qa.id IS NULL";
|
||||
break;
|
||||
case QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS:
|
||||
// Show all students with or without attempts
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000');
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $allowed_params;
|
||||
$where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)";
|
||||
break;
|
||||
|
@ -234,19 +234,19 @@ class quiz_responses_report extends quiz_default_report {
|
||||
break;
|
||||
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH:
|
||||
// Show only students with attempts
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000');
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $allowed_params;
|
||||
$where = "u.id $allowed_usql AND qa.preview = 0 AND qa.id IS NOT NULL";
|
||||
break;
|
||||
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
|
||||
// Show only students without attempts
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000');
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $allowed_params;
|
||||
$where = "u.id $allowed_usql AND qa.id IS NULL";
|
||||
break;
|
||||
case QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS:
|
||||
// Show all students with or without attempts
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u0000');
|
||||
list($allowed_usql, $allowed_params) = $DB->get_in_or_equal($allowed, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $allowed_params;
|
||||
$where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)";
|
||||
break;
|
||||
|
@ -38,7 +38,7 @@ class qstats{
|
||||
}
|
||||
function get_records($quizid, $currentgroup, $groupstudents, $allattempts){
|
||||
global $DB;
|
||||
list($qsql, $qparams) = $DB->get_in_or_equal(array_keys($this->questions), SQL_PARAMS_NAMED, 'q0000');
|
||||
list($qsql, $qparams) = $DB->get_in_or_equal(array_keys($this->questions), SQL_PARAMS_NAMED, 'q');
|
||||
list($fromqa, $whereqa, $qaparams) = quiz_report_attempts_sql($quizid, $currentgroup, $groupstudents, $allattempts);
|
||||
$sql = 'SELECT qs.id, ' .
|
||||
'qs.question, ' .
|
||||
|
@ -659,7 +659,7 @@ function quiz_report_attempts_sql($quizid, $currentgroup, $groupstudents, $allat
|
||||
$whereqa = 'qa.quiz = :quizid AND qa.preview=0 AND qa.timefinish !=0 ';
|
||||
$qaparams = array('quizid'=>$quizid);
|
||||
if (!empty($currentgroup) && $groupstudents) {
|
||||
list($grpsql, $grpparams) = $DB->get_in_or_equal(array_keys($groupstudents), SQL_PARAMS_NAMED, 'u0000');
|
||||
list($grpsql, $grpparams) = $DB->get_in_or_equal(array_keys($groupstudents), SQL_PARAMS_NAMED, 'u');
|
||||
$whereqa .= 'AND qa.userid '.$grpsql.' ';
|
||||
$qaparams += $grpparams;
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ class question_bank_view {
|
||||
} else {
|
||||
$categoryids = array($category->id);
|
||||
}
|
||||
list($catidtest, $params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'cat0000');
|
||||
list($catidtest, $params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'cat');
|
||||
$tests[] = 'q.category ' . $catidtest;
|
||||
$this->sqlparams = $params;
|
||||
|
||||
|
@ -653,7 +653,7 @@ abstract class repository {
|
||||
WHERE i.typeid = r.id ";
|
||||
|
||||
if (!empty($args['disable_types']) && is_array($args['disable_types'])) {
|
||||
list($types, $p) = $DB->get_in_or_equal($args['disable_types'], SQL_PARAMS_QM, 'param0000', false);
|
||||
list($types, $p) = $DB->get_in_or_equal($args['disable_types'], SQL_PARAMS_QM, 'param', false);
|
||||
$sql .= " AND r.type $types";
|
||||
$params = array_merge($params, $p);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
* Major chages in this review is passing the xxxx_db_names return to
|
||||
* multiple arity to handle multiple document types modules
|
||||
*
|
||||
*
|
||||
* changes are in implementing new $DB access
|
||||
*/
|
||||
|
||||
@ -114,7 +114,7 @@
|
||||
$docIds = $DB->get_records_sql_menu($query, array($mod->name));
|
||||
|
||||
if (!empty($docIds)){
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($docIds), SQL_PARAMS_QM, 'param0000', false); // negative IN
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($docIds), SQL_PARAMS_QM, 'param', false); // negative IN
|
||||
$query = "
|
||||
SELECT id,
|
||||
$values[0] as docid
|
||||
|
@ -15,7 +15,7 @@
|
||||
* Major chages in this review is passing the xxxx_db_names return to
|
||||
* multiple arity to handle multiple document types modules
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* includes and requires
|
||||
*/
|
||||
@ -24,15 +24,15 @@
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from the cron script
|
||||
}
|
||||
|
||||
|
||||
global $DB;
|
||||
|
||||
/// makes inclusions of the Zend Engine more reliable
|
||||
/// makes inclusions of the Zend Engine more reliable
|
||||
ini_set('include_path', $CFG->dirroot.DIRECTORY_SEPARATOR.'search'.PATH_SEPARATOR.ini_get('include_path'));
|
||||
|
||||
require_once($CFG->dirroot.'/search/lib.php');
|
||||
require_once($CFG->dirroot.'/search/indexlib.php');
|
||||
|
||||
require_once($CFG->dirroot.'/search/indexlib.php');
|
||||
|
||||
/// checks global search activation
|
||||
|
||||
// require_login();
|
||||
@ -57,23 +57,23 @@
|
||||
$dbcontrol = new IndexDBControl();
|
||||
$deletion_count = 0;
|
||||
$startcleantime = time();
|
||||
|
||||
|
||||
mtrace('Starting clean-up of removed records...');
|
||||
mtrace('Index size before: '.$CFG->search_index_size."\n");
|
||||
|
||||
|
||||
/// check all modules
|
||||
if ($mods = search_collect_searchables(false, true)){
|
||||
|
||||
|
||||
foreach ($mods as $mod) {
|
||||
//build function names
|
||||
$class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
|
||||
$delete_function = $mod->name.'_delete';
|
||||
$db_names_function = $mod->name.'_db_names';
|
||||
$deletions = array();
|
||||
|
||||
|
||||
if (file_exists($class_file)) {
|
||||
require_once($class_file);
|
||||
|
||||
|
||||
//if both required functions exist
|
||||
if (function_exists($delete_function) and function_exists($db_names_function)) {
|
||||
mtrace("Checking $mod->name module for deletions.");
|
||||
@ -83,26 +83,26 @@
|
||||
$where = (!empty($values[5])) ? 'WHERE '.$values[5] : '';
|
||||
$itemtypes = ($values[4] != '*' && $values[4] != 'any') ? " itemtype = '{$values[4]}' AND " : '' ;
|
||||
$query = "
|
||||
SELECT
|
||||
SELECT
|
||||
id,
|
||||
{$values[0]}
|
||||
FROM
|
||||
FROM
|
||||
{{$values[1]}}
|
||||
$where
|
||||
";
|
||||
$docIds = $DB->get_records_sql($query, array());
|
||||
|
||||
|
||||
if (!empty($docIds)){
|
||||
$table = SEARCH_DATABASE_TABLE;
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($docIds), SQL_PARAMS_QM, 'param0000', false); // negative IN
|
||||
list($usql, $params) = $DB->get_in_or_equal(array_keys($docIds), SQL_PARAMS_QM, 'param', false); // negative IN
|
||||
$query = "
|
||||
SELECT
|
||||
id,
|
||||
docid
|
||||
FROM
|
||||
SELECT
|
||||
id,
|
||||
docid
|
||||
FROM
|
||||
{{$table}}
|
||||
WHERE
|
||||
doctype = '{$mod->name}' AND
|
||||
WHERE
|
||||
doctype = '{$mod->name}' AND
|
||||
$itemtypes
|
||||
docid $usql
|
||||
";
|
||||
@ -110,24 +110,24 @@
|
||||
} else {
|
||||
$records = array();
|
||||
}
|
||||
|
||||
|
||||
// build an array of all the deleted records
|
||||
foreach($records as $record) {
|
||||
$deletions[] = $delete_function($record->docid, $values[4]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($deletions as $delete) {
|
||||
// find the specific document in the index, using it's docid and doctype as keys
|
||||
// change from default text only search to include numerals for this search.
|
||||
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
|
||||
$doc = $index->find("+docid:{$delete->id} +doctype:$mod->name +itemtype:{$delete->itemtype}");
|
||||
|
||||
|
||||
// get the record, should only be one
|
||||
foreach ($doc as $thisdoc) {
|
||||
++$deletion_count;
|
||||
mtrace(" Delete: $thisdoc->title (database id = $thisdoc->dbid, index id = $thisdoc->id, moodle instance id = $thisdoc->docid)");
|
||||
|
||||
|
||||
//remove it from index and database table
|
||||
$dbcontrol->delDocument($thisdoc);
|
||||
$index->delete($thisdoc->id);
|
||||
@ -142,16 +142,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// commit changes
|
||||
|
||||
$index->commit();
|
||||
|
||||
|
||||
/// update index date and index size
|
||||
|
||||
set_config('search_indexer_cleanup_date', $startcleantime);
|
||||
set_config('search_index_size', (int)$CFG->search_index_size - (int)$deletion_count);
|
||||
|
||||
|
||||
mtrace("Finished $deletion_count removals.");
|
||||
mtrace('Index size after: '.$index->count());
|
||||
|
||||
|
@ -451,14 +451,14 @@ abstract class user_selector_base {
|
||||
|
||||
// If we are being asked to exclude any users, do that.
|
||||
if (!empty($this->exclude)) {
|
||||
list($usertest, $userparams) = $DB->get_in_or_equal($this->exclude, SQL_PARAMS_NAMED, 'ex000', false);
|
||||
list($usertest, $userparams) = $DB->get_in_or_equal($this->exclude, SQL_PARAMS_NAMED, 'ex', false);
|
||||
$tests[] = $u . 'id ' . $usertest;
|
||||
$params = array_merge($params, $userparams);
|
||||
}
|
||||
|
||||
// If we are validating a set list of userids, add an id IN (...) test.
|
||||
if (!empty($this->validatinguserids)) {
|
||||
list($usertest, $userparams) = $DB->get_in_or_equal($this->validatinguserids, SQL_PARAMS_NAMED, 'val000');
|
||||
list($usertest, $userparams) = $DB->get_in_or_equal($this->validatinguserids, SQL_PARAMS_NAMED, 'val');
|
||||
$tests[] = $u . 'id ' . $usertest;
|
||||
$params = array_merge($params, $userparams);
|
||||
}
|
||||
@ -756,7 +756,7 @@ class group_non_members_selector extends groups_user_selector_base {
|
||||
$usergroups = array();
|
||||
$potentialmembersids = $this->potentialmembersids;
|
||||
if( empty($potentialmembersids)==false ) {
|
||||
list($membersidsclause, $params) = $DB->get_in_or_equal($potentialmembersids, SQL_PARAMS_NAMED, 'pm0');
|
||||
list($membersidsclause, $params) = $DB->get_in_or_equal($potentialmembersids, SQL_PARAMS_NAMED, 'pm');
|
||||
$sql = "SELECT u.id AS userid, g.*
|
||||
FROM {user} u
|
||||
JOIN {groups_members} gm ON u.id = gm.userid
|
||||
@ -792,7 +792,7 @@ class group_non_members_selector extends groups_user_selector_base {
|
||||
// Get list of allowed roles.
|
||||
$context = get_context_instance(CONTEXT_COURSE, $this->courseid);
|
||||
if ($validroleids = groups_get_possible_roles($context)) {
|
||||
list($roleids, $roleparams) = $DB->get_in_or_equal($validroleids, SQL_PARAMS_NAMED, 'r00');
|
||||
list($roleids, $roleparams) = $DB->get_in_or_equal($validroleids, SQL_PARAMS_NAMED, 'r');
|
||||
} else {
|
||||
$roleids = " = -1";
|
||||
$roleparams = array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user