mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Just tidying a couple of functions
This commit is contained in:
parent
7f5bc80b78
commit
ff64aaeaec
1 changed files with 16 additions and 12 deletions
|
@ -2288,45 +2288,49 @@ function allow_override($sroleid, $troleid) {
|
||||||
* @return int - id or false
|
* @return int - id or false
|
||||||
*/
|
*/
|
||||||
function allow_assign($sroleid, $troleid) {
|
function allow_assign($sroleid, $troleid) {
|
||||||
|
$record = new object;
|
||||||
$record->roleid = $sroleid;
|
$record->roleid = $sroleid;
|
||||||
$record->allowassign = $troleid;
|
$record->allowassign = $troleid;
|
||||||
return insert_record('role_allow_assign', $record);
|
return insert_record('role_allow_assign', $record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a list of roles assignalbe in this context for this user
|
* Gets a list of roles that this user can assign in this context
|
||||||
* @param object $context
|
* @param object $context
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_assignable_roles ($context) {
|
function get_assignable_roles ($context) {
|
||||||
|
|
||||||
$role = get_records('role');
|
|
||||||
$options = array();
|
$options = array();
|
||||||
foreach ($role as $rolex) {
|
|
||||||
if (user_can_assign($context, $rolex->id)) {
|
if ($roles = get_records('role')) {
|
||||||
$options[$rolex->id] = $rolex->name;
|
foreach ($roles as $role) {
|
||||||
|
if (user_can_assign($context, $role->id)) {
|
||||||
|
$options[$role->id] = $role->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a list of roles that can be overriden in this context by this user
|
* Gets a list of roles that this user can override in this context
|
||||||
* @param object $context
|
* @param object $context
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_overridable_roles ($context) {
|
function get_overridable_roles ($context) {
|
||||||
|
|
||||||
$role = get_records('role');
|
|
||||||
$options = array();
|
$options = array();
|
||||||
foreach ($role as $rolex) {
|
|
||||||
if (user_can_override($context, $rolex->id)) {
|
if ($roles = get_records('role')) {
|
||||||
$options[$rolex->id] = $rolex->name;
|
foreach ($roles as $role) {
|
||||||
|
if (user_can_override($context, $role->id)) {
|
||||||
|
$options[$role->id] = $role->name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue