当前位置: 首页>>代码示例>>PHP>>正文


PHP course_enrolment_manager::get_assignable_roles方法代码示例

本文整理汇总了PHP中course_enrolment_manager::get_assignable_roles方法的典型用法代码示例。如果您正苦于以下问题:PHP course_enrolment_manager::get_assignable_roles方法的具体用法?PHP course_enrolment_manager::get_assignable_roles怎么用?PHP course_enrolment_manager::get_assignable_roles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在course_enrolment_manager的用法示例。


在下文中一共展示了course_enrolment_manager::get_assignable_roles方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: list

     list($instance, $plugin) = $manager->get_user_enrolment_components($ue);
     if (!$instance || !$plugin || !enrol_is_enabled($instance->enrol) || !$plugin->allow_unenrol_user($instance, $ue) || !has_capability("enrol/{$instance->enrol}:unenrol", $manager->get_context()) || !$manager->unenrol_user($ue)) {
         throw new enrol_ajax_exception('unenrolnotpermitted');
     }
     break;
 case 'unassign':
     $role = required_param('role', PARAM_INT);
     $user = required_param('user', PARAM_INT);
     if (!has_capability('moodle/role:assign', $manager->get_context()) || !$manager->unassign_role_from_user($user, $role)) {
         throw new enrol_ajax_exception('unassignnotpermitted');
     }
     break;
 case 'assign':
     $user = $DB->get_record('user', array('id' => required_param('user', PARAM_INT)), '*', MUST_EXIST);
     $roleid = required_param('roleid', PARAM_INT);
     if (!array_key_exists($roleid, $manager->get_assignable_roles())) {
         throw new enrol_ajax_exception('invalidrole');
     }
     if (!has_capability('moodle/role:assign', $manager->get_context()) || !$manager->assign_role_to_user($roleid, $user->id)) {
         throw new enrol_ajax_exception('assignnotpermitted');
     }
     $outcome->response->roleid = $roleid;
     break;
 case 'getassignable':
     $otheruserroles = optional_param('otherusers', false, PARAM_BOOL);
     $outcome->response = $manager->get_assignable_roles_for_json($otheruserroles);
     break;
 case 'searchotherusers':
     $search = optional_param('search', '', PARAM_RAW);
     $page = optional_param('page', 0, PARAM_INT);
     $outcome->response = $manager->search_other_users($search, $searchanywhere, $page);
开发者ID:dg711,项目名称:moodle,代码行数:31,代码来源:ajax.php

示例2: stdClass

}
require_login($course);
require_capability('moodle/course:enrolreview', $context);
require_sesskey();
echo $OUTPUT->header();
// Send headers.
$manager = new course_enrolment_manager($PAGE, $course);
$outcome = new stdClass();
$outcome->success = true;
$outcome->response = new stdClass();
$outcome->error = '';
$searchanywhere = get_user_preferences('userselector_searchanywhere', false);
switch ($action) {
    case 'getassignable':
        $otheruserroles = optional_param('otherusers', false, PARAM_BOOL);
        $outcome->response = array_reverse($manager->get_assignable_roles($otheruserroles), true);
        break;
    case 'searchusers':
        $enrolid = required_param('enrolid', PARAM_INT);
        $search = optional_param('search', '', PARAM_RAW);
        $page = optional_param('page', 0, PARAM_INT);
        $outcome->response = $manager->get_potential_users($enrolid, $search, $searchanywhere, $page);
        $extrafields = get_extra_user_fields($context);
        foreach ($outcome->response['users'] as &$user) {
            $user->picture = $OUTPUT->user_picture($user);
            $user->fullname = fullname($user);
            $fieldvalues = array();
            foreach ($extrafields as $field) {
                $fieldvalues[] = s($user->{$field});
                unset($user->{$field});
            }
开发者ID:vinoth4891,项目名称:clinique,代码行数:31,代码来源:ajax.php

示例3: list

     list($instance, $plugin) = $manager->get_user_enrolment_components($ue);
     if (!$instance || !$plugin || !$plugin->allow_unenrol($instance) || !has_capability("enrol/{$instance->enrol}:unenrol", $manager->get_context()) || !$manager->unenrol_user($ue)) {
         throw new enrol_ajax_exception('unenrolnotpermitted');
     }
     break;
 case 'unassign':
     $role = required_param('role', PARAM_INT);
     $user = required_param('user', PARAM_INT);
     if (!has_capability('moodle/role:assign', $manager->get_context()) || !$manager->unassign_role_from_user($user, $role)) {
         throw new enrol_ajax_exception('unassignnotpermitted');
     }
     break;
 case 'assign':
     $user = $DB->get_record('user', array('id' => required_param('user', PARAM_INT)), '*', MUST_EXIST);
     $roleid = required_param('roleid', PARAM_INT);
     if (!array_key_exists($roleid, $manager->get_assignable_roles())) {
         throw new enrol_ajax_exception('invalidrole');
     }
     if (!has_capability('moodle/role:assign', $manager->get_context()) || !$manager->assign_role_to_user($roleid, $user->id)) {
         throw new enrol_ajax_exception('assignnotpermitted');
     }
     $outcome->response->roleid = $roleid;
     break;
 case 'getassignable':
     $otheruserroles = optional_param('otherusers', false, PARAM_BOOL);
     $outcome->response = array_reverse($manager->get_assignable_roles($otheruserroles), true);
     break;
 case 'searchotherusers':
     $search = optional_param('search', '', PARAM_RAW);
     $page = optional_param('page', 0, PARAM_INT);
     $outcome->response = $manager->search_other_users($search, false, $page);
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:ajax.php

示例4: array

         }
         $actiontaken = true;
     }
     break;
     /**
      * Assigns a new role to a user enrolled within this course.
      * A user must be enrolled in the course in order for this script to action
      */
 /**
  * Assigns a new role to a user enrolled within this course.
  * A user must be enrolled in the course in order for this script to action
  */
 case 'assign':
     $user = $DB->get_record('user', array('id' => required_param('user', PARAM_INT)), '*', MUST_EXIST);
     if (is_enrolled($context, $user) && has_capability('moodle/role:assign', $manager->get_context())) {
         $mform = new enrol_users_assign_form(NULL, array('user' => $user, 'course' => $course, 'assignable' => $manager->get_assignable_roles()));
         $mform->set_data($PAGE->url->params());
         $data = $mform->get_data();
         if ($mform->is_cancelled() || $data && array_key_exists($data->roleid, $manager->get_assignable_roles()) && $manager->assign_role_to_user($data->roleid, $user->id)) {
             redirect($PAGE->url);
         } else {
             $pagetitle = get_string('assignroles', 'role');
         }
         $actiontaken = true;
     }
     break;
     /**
      * Removes the user from the given group
      */
 /**
  * Removes the user from the given group
开发者ID:Keneth1212,项目名称:moodle,代码行数:31,代码来源:users.php

示例5: array

$PAGE->set_url('/enrol/otherusers.php', $manager->get_url_params() + $table->get_url_params());
$userdetails = array('picture' => false, 'firstname' => get_string('firstname'), 'lastname' => get_string('lastname'));
$extrafields = get_extra_user_fields($context);
foreach ($extrafields as $field) {
    $userdetails[$field] = get_user_field_name($field);
}
$fields = array('userdetails' => $userdetails, 'lastseen' => get_string('lastaccess'), 'role' => get_string('roles', 'role'));
// Remove hidden fields if the user has no access
if (!has_capability('moodle/course:viewhiddenuserfields', $context)) {
    $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
    if (isset($hiddenfields['lastaccess'])) {
        unset($fields['lastseen']);
    }
}
$table->set_fields($fields, $OUTPUT);
//$users = $manager->get_other_users($table->sort, $table->sortdirection, $table->page, $table->perpage);
$renderer = $PAGE->get_renderer('core_enrol');
$canassign = has_capability('moodle/role:assign', $manager->get_context());
$users = $manager->get_other_users_for_display($renderer, $PAGE->url, $table->sort, $table->sortdirection, $table->page, $table->perpage);
$assignableroles = $manager->get_assignable_roles(true);
foreach ($users as $userid => &$user) {
    $user['picture'] = $OUTPUT->render($user['picture']);
    $user['role'] = $renderer->user_roles_and_actions($userid, $user['roles'], $assignableroles, $canassign, $PAGE->url);
}
$table->set_total_users($manager->get_total_other_users());
$table->set_users($users);
$PAGE->set_title($course->fullname . ': ' . get_string('totalotherusers', 'enrol', $manager->get_total_other_users()));
$PAGE->set_heading($PAGE->title);
echo $OUTPUT->header();
echo $renderer->render($table);
echo $OUTPUT->footer();
开发者ID:nmicha,项目名称:moodle,代码行数:31,代码来源:otherusers.php


注:本文中的course_enrolment_manager::get_assignable_roles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。