From: moodler Date: Fri, 22 Sep 2006 05:17:57 +0000 (+0000) Subject: Removing some notices X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9d829c681d279d6d8727b565e650bf20eff884d3;p=moodle.git Removing some notices --- diff --git a/lib/accesslib.php b/lib/accesslib.php index 11a0425e74..317b95ae62 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1353,32 +1353,32 @@ function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $time /// Do some data validation if (empty($roleid)) { - notify('Role ID not provided'); + debugging('Role ID not provided'); return false; } if (empty($userid) && empty($groupid)) { - notify('Either userid or groupid must be provided'); + debugging('Either userid or groupid must be provided'); return false; } if ($userid && !record_exists('user', 'id', $userid)) { - notify('User does not exist!'); + debugging('User does not exist!'); return false; } if ($groupid && !record_exists('groups', 'id', $groupid)) { - notify('Group does not exist!'); + debugging('Group does not exist!'); return false; } if (!$context = get_context_instance_by_id($contextid)) { - notify('A valid context must be provided'); + debugging('A valid context must be provided'); return false; } if (($timestart and $timeend) and ($timestart > $timeend)) { - notify('The end time can not be earlier than the start time'); + debugging('The end time can not be earlier than the start time'); return false; } @@ -2545,15 +2545,18 @@ function get_users_by_capability($context, $capability, $fields='', $sort='', } /// Sorting out roles with this capability set - $possibleroles = get_roles_with_capability($capability, CAP_ALLOW, $context); - $validroleids = array(); - foreach ($possibleroles as $prole) { - $caps = role_context_capabilities($prole->id, $context, $capability); // resolved list - if ($caps[$capability] > 0) { // resolved capability > 0 - $validroleids[] = $prole->id; + if ($possibleroles = get_roles_with_capability($capability, CAP_ALLOW, $context)) { + $validroleids = array(); + foreach ($possibleroles as $prole) { + $caps = role_context_capabilities($prole->id, $context, $capability); // resolved list + if ($caps[$capability] > 0) { // resolved capability > 0 + $validroleids[] = $prole->id; + } } + $roleids = '('.implode(',', $validroleids).')'; + } else { + return false; // No need to continue, since no roles have this capability set } - $roleids = '('.implode(',', $validroleids).')'; /// Construct the main SQL $select = " SELECT $fields";