Skip to content

Commit

Permalink
MDL-27148 use new get_in_or_equal() param prefix instead of start
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Apr 14, 2011
1 parent c49bec3 commit cf717dc
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 94 deletions.
4 changes: 2 additions & 2 deletions admin/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ public function generate_modules($courses) {
.$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));
Expand Down
2 changes: 1 addition & 1 deletion admin/roles/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ public function find_users($search) {
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;

Expand Down
4 changes: 2 additions & 2 deletions auth/db/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function sync_users($do_updates=false) {

// 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
Expand Down Expand Up @@ -290,7 +290,7 @@ function sync_users($do_updates=false) {
// 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
Expand Down
2 changes: 1 addition & 1 deletion course/report/participation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions enrol/category/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ public function role_unassigned($ra) {
$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) {
$coursecontext = get_context_instance(CONTEXT_COURSE, $instance->courseid);
$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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion enrol/ldap/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public function sync_enrolments() {
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);
Expand Down
4 changes: 2 additions & 2 deletions enrol/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function get_total_users() {
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
Expand Down Expand Up @@ -222,7 +222,7 @@ public function get_other_users($sort, $direction='ASC', $page=0, $perpage=25) {
}
$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
Expand Down
8 changes: 4 additions & 4 deletions enrol/meta/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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";
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion grade/import/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions grade/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function init() {
$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);
Expand Down Expand Up @@ -144,7 +144,7 @@ public function init() {

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

Expand Down Expand Up @@ -2245,7 +2245,7 @@ public static function get_info_manage_settings($courseid) {
*/
public static function get_plugins_reports($courseid) {
global $SITE;

if (self::$gradereports !== null) {
return self::$gradereports;
}
Expand Down
2 changes: 1 addition & 1 deletion grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public function load_users() {
$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;
}
Expand Down
18 changes: 9 additions & 9 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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";
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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";
}
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,13 @@ public function load_blocks($includeinvisible = null) {
$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');

Expand Down
4 changes: 2 additions & 2 deletions lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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";
}
Expand Down
Loading

0 comments on commit cf717dc

Please sign in to comment.