MDL-40337 fix some more deprecated calls in role code

This commit is contained in:
Petr Škoda 2013-06-27 09:34:46 +02:00
parent 5089cca0b4
commit 1415127ebc
9 changed files with 23 additions and 26 deletions

View File

@ -45,7 +45,7 @@ $controller = new $classformode[$mode]();
if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
$controller->process_submission();
mark_context_dirty($syscontext->path);
$syscontext->mark_dirty();
add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
redirect($baseurl);
}

View File

@ -55,7 +55,7 @@ require_capability('moodle/role:assign', $context);
$PAGE->set_url($url);
$PAGE->set_context($context);
$contextname = print_context_name($context);
$contextname = $context->get_context_name();
$courseid = $course->id;
// These are needed early because of tabs.php.
@ -163,7 +163,7 @@ switch ($context->contextlevel) {
}
break;
case CONTEXT_MODULE:
$PAGE->set_heading(print_context_name($context, false));
$PAGE->set_heading($context->get_context_name(false));
$PAGE->set_cacheable(false);
break;
case CONTEXT_BLOCK:

View File

@ -53,7 +53,7 @@ $PAGE->set_url($url);
$PAGE->set_context($context);
$courseid = $course->id;
$contextname = print_context_name($context);
$contextname = $context->get_context_name();
// Get the user_selector we will need.
// Teachers within a course just get to see the same list of enrolled users.
@ -90,7 +90,7 @@ switch ($context->contextlevel) {
}
break;
case CONTEXT_MODULE:
$PAGE->set_heading(print_context_name($context, false));
$PAGE->set_heading($context->get_context_name(false));
$PAGE->set_cacheable(false);
break;
case CONTEXT_BLOCK:
@ -164,7 +164,7 @@ echo $OUTPUT->heading('<label for="reportuser">' . $selectheading . '</label>',
$userselector->display();
// Submit button and the end of the form.
echo '<p id="chooseusersubmit"><input type="submit" value="' . get_string('showthisuserspermissions', 'corerole') . '" /></p>';
echo '<p id="chooseusersubmit"><input type="submit" value="' . get_string('showthisuserspermissions', 'core_role') . '" /></p>';
echo '</form>';
echo $OUTPUT->box_end();

View File

@ -36,7 +36,7 @@ abstract class core_role_capability_table_with_risks extends core_role_capabilit
protected $strperms; // Language string cache.
protected $risksurl; // URL in moodledocs about risks.
protected $riskicons = array(); // Cache to avoid regenerating the HTML for each risk icon.
/** The capabilities to highlight as default/inherited. */
/** @var array The capabilities to highlight as default/inherited. */
protected $parentpermissions;
protected $displaypermissions;
protected $permissions;

View File

@ -44,7 +44,6 @@ class core_role_check_capability_table extends core_role_capability_table_base {
* @param string $contextname print_context_name($context) - to save recomputing.
*/
public function __construct($context, $user, $contextname) {
global $CFG;
parent::__construct($context, 'explaincaps');
$this->user = $user;
$this->fullname = fullname($user);
@ -71,7 +70,6 @@ class core_role_check_capability_table extends core_role_capability_table_base {
}
protected function add_row_cells($capability) {
global $OUTPUT;
if ($this->hascap) {
$result = $this->stryes;
} else {

View File

@ -34,22 +34,21 @@ class core_role_existing_role_holders extends core_role_assign_user_selector_bas
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, 'ctx');
list($ctxcondition, $ctxparams) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
$params = array_merge($params, $ctxparams);
$params['roleid'] = $this->roleid;
list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
$params = array_merge($params, $sortparams);
$sql = "SELECT ra.id as raid," . $this->required_fields_sql('u') . ",ra.contextid,ra.component
FROM {role_assignments} ra
JOIN {user} u ON u.id = ra.userid
JOIN {context} ctx ON ra.contextid = ctx.id
WHERE
$wherecondition AND
ctx.id $ctxcondition AND
ra.roleid = :roleid
ORDER BY ctx.depth DESC, ra.component, $sort";
$sql = "SELECT ra.id AS raid," . $this->required_fields_sql('u') . ",ra.contextid,ra.component
FROM {role_assignments} ra
JOIN {user} u ON u.id = ra.userid
JOIN {context} ctx ON ra.contextid = ctx.id
WHERE $wherecondition
AND ctx.id $ctxcondition
AND ra.roleid = :roleid
ORDER BY ctx.depth DESC, ra.component, $sort";
$contextusers = $DB->get_records_sql($sql, $params);
// No users at all.
@ -111,7 +110,7 @@ class core_role_existing_role_holders extends core_role_assign_user_selector_bas
return get_string('extusers', 'core_role');
}
}
$contexttype = get_contextlevel_name($this->context->contextlevel);
$contexttype = context_helper::get_level_name($this->context->contextlevel);
if ($search) {
$a = new stdClass;
$a->search = $search;
@ -132,7 +131,7 @@ class core_role_existing_role_holders extends core_role_assign_user_selector_bas
protected function parent_con_group_name($search, $contextid) {
$context = context::instance_by_id($contextid);
$contextname = print_context_name($context, true, true);
$contextname = $context->get_context_name(true, true);
if ($search) {
$a = new stdClass;
$a->contextname = $contextname;

View File

@ -58,7 +58,7 @@ class core_role_override_permissions_table_advanced extends core_role_capability
protected function load_parent_permissions() {
// Get the capabilities from the parent context, so that can be shown in the interface.
$parentcontext = context::instance_by_id($this->context->get_parent_context());
$parentcontext = $this->context->get_parent_context();
$this->parentpermissions = role_context_capabilities($this->roleid, $parentcontext);
}

View File

@ -31,15 +31,15 @@ defined('MOODLE_INTERNAL') || die();
* some blocks) then return a core_role_potential_assignees_below_course object. Otherwise
* return a core_role_potential_assignees_course_and_above.
*
* @param stdClass $context a context.
* @param context $context a context.
* @param string $name passed to user selector constructor.
* @param array $options to user selector constructor.
* @return user_selector_base an appropriate user selector.
*/
function core_role_get_potential_user_selector($context, $name, $options) {
function core_role_get_potential_user_selector(context $context, $name, $options) {
$blockinsidecourse = false;
if ($context->contextlevel == CONTEXT_BLOCK) {
$parentcontext = context::instance_by_id(get_parent_contextid($context));
$parentcontext = $context->get_parent_context();
$blockinsidecourse = in_array($parentcontext->contextlevel, array(CONTEXT_MODULE, CONTEXT_COURSE));
}

View File

@ -74,7 +74,7 @@ list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_rol
// Work out an appropriate page title.
$contextname = $context->get_context_name();
$straction = get_string('overrideroles', 'core_role'); // Used by tabs.php.
$a = (object)array('context' => $contextname, 'core_role' => $overridableroles[$roleid]);
$a = (object)array('context' => $contextname, 'role' => $overridableroles[$roleid]);
$title = get_string('overridepermissionsforrole', 'core_role', $a);
$currenttab = 'permissions';