Example #1
0
require_login($course);
$canview = has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $context);
if (!$canview) {
    print_error('nopermissions', 'error', '', get_string('checkpermissions', 'role'));
}
/// These are needed early because of tabs.php
$assignableroles = get_assignable_roles($context, ROLENAME_BOTH);
$overridableroles = get_overridable_roles($context, ROLENAME_BOTH);
/// Get the user_selector we will need.
/// Teachers within a course just get to see the same list of people they can
/// assign roles to. Admins (people with moodle/role:manage) can run this report for any user.
$options = array('context' => $context, 'roleid' => 0);
if ($context->contextlevel > CONTEXT_COURSE && !is_inside_frontpage($context) && !has_capability('moodle/role:manage', $context)) {
    $userselector = new potential_assignees_below_course('reportuser', $options);
} else {
    $userselector = new potential_assignees_course_and_above('reportuser', $options);
}
$userselector->set_multiselect(false);
$userselector->set_rows(10);
/// Work out an appropriate page title.
$title = get_string('checkpermissionsin', 'role', $contextname);
$straction = get_string('checkpermissions', 'role');
// Used by tabs.php
/// Print the header and tabs
if ($context->contextlevel == CONTEXT_USER) {
    $user = get_record('user', 'id', $userid);
    $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
    /// course header
    $navlinks = array();
    if ($courseid != SITEID) {
        if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $courseid))) {
Example #2
0
if ($course->enrollable == 2) {
    if ($course->enrolstartdate > 0) {
        $basemenu[4] = get_string('courseenrolstart') . ' (' . userdate($course->enrolstartdate, $timeformat) . ')';
    }
    if ($course->enrolenddate > 0) {
        $basemenu[5] = get_string('courseenrolend') . ' (' . userdate($course->enrolenddate, $timeformat) . ')';
    }
}
/// Process any incoming role assignments before printing the header.
if ($roleid) {
    /// Create the user selector objects.
    $options = array('context' => $context, 'roleid' => $roleid);
    if ($context->contextlevel > CONTEXT_COURSE && !is_inside_frontpage($context)) {
        $potentialuserselector = new potential_assignees_below_course('addselect', $options);
    } else {
        $potentialuserselector = new potential_assignees_course_and_above('addselect', $options);
    }
    if ($context->contextlevel == CONTEXT_SYSTEM && is_admin_role($roleid)) {
        $currentuserselector = new existing_role_holders_site_admin('removeselect', $options);
    } else {
        $currentuserselector = new existing_role_holders('removeselect', $options);
    }
    /// Process incoming role assignments
    $errors = array();
    if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
        $userstoassign = $potentialuserselector->get_selected_users();
        if (!empty($userstoassign)) {
            foreach ($userstoassign as $adduser) {
                $allow = true;
                if ($inmeta) {
                    if (has_capability('moodle/course:managemetacourse', $context, $adduser->id)) {