• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_profile_roles函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_profile_roles函数的典型用法代码示例。如果您正苦于以下问题:PHP get_profile_roles函数的具体用法?PHP get_profile_roles怎么用?PHP get_profile_roles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: definition

 protected function definition()
 {
     global $CFG, $DB;
     $collection = $this->_customdata['collection'];
     $context = $this->_customdata['context'];
     $mform = $this->_form;
     // Text search box.
     $mform->addElement('text', 'search', get_string('search'));
     $mform->setType('search', PARAM_TEXT);
     $options = array(\mod_mediagallery\base::TYPE_ALL => get_string('typeall', 'mediagallery'), \mod_mediagallery\base::TYPE_IMAGE => get_string('typeimage', 'mediagallery'), \mod_mediagallery\base::TYPE_VIDEO => get_string('typevideo', 'mediagallery'), \mod_mediagallery\base::TYPE_AUDIO => get_string('typeaudio', 'mediagallery'));
     $mform->addElement('select', 'type', get_string('mediatype', 'mediagallery'), $options);
     // Role select dropdown includes all roles, but using course-specific
     // names if applied. The reason for not restricting to roles that can
     // be assigned at course level is that upper-level roles display in the
     // enrolments table so it makes sense to let users filter by them.
     $rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true);
     if (!empty($CFG->showenrolledusersrolesonly)) {
         $rolenames = role_fix_names(get_roles_used_in_context($context));
     }
     $mform->addElement('select', 'role', get_string('role'), array(0 => get_string('all')) + $rolenames);
     // Filter by group.
     $allgroups = groups_get_all_groups($collection->course);
     $groupsmenu[0] = get_string('allparticipants');
     foreach ($allgroups as $gid => $unused) {
         $groupsmenu[$gid] = $allgroups[$gid]->name;
     }
     if (count($groupsmenu) > 1) {
         $mform->addElement('select', 'group', get_string('group'), $groupsmenu);
     }
     // Submit button does not use add_action_buttons because that adds
     // another fieldset which causes the CSS style to break in an unfixable
     // way due to fieldset quirks.
     $group = array();
     $group[] = $mform->createElement('submit', 'submitbutton', get_string('filter'));
     $group[] = $mform->createElement('submit', 'resetbutton', get_string('reset'));
     $group[] = $mform->createElement('submit', 'exportbutton', get_string('exportascsv', 'mediagallery'));
     $mform->addGroup($group, 'buttons', '', ' ', false);
     $mform->addElement('hidden', 'id', $context->instanceid);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'action', 'search');
     $mform->setType('action', PARAM_ALPHA);
 }
开发者ID:eSrem,项目名称:moodle-mod_mediagallery,代码行数:42,代码来源:search.php


示例2: unset

// Not needed anymore.
unset($contextid);
unset($courseid);
require_login($course);
$systemcontext = context_system::instance();
$isfrontpage = $course->id == SITEID;
$frontpagectx = context_course::instance(SITEID);
if ($isfrontpage) {
    $PAGE->set_pagelayout('admin');
    require_capability('moodle/site:viewparticipants', $systemcontext);
} else {
    $PAGE->set_pagelayout('incourse');
    require_capability('moodle/course:viewparticipants', $context);
}
$rolenamesurl = new moodle_url("{$CFG->wwwroot}/user/index.php?contextid={$context->id}&sifirst=&silast=");
$rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true);
if ($isfrontpage) {
    $rolenames[0] = get_string('allsiteusers', 'role');
} else {
    $rolenames[0] = get_string('allparticipants');
}
// Make sure other roles may not be selected by any means.
if (empty($rolenames[$roleid])) {
    print_error('noparticipants');
}
// No roles to display yet?
// frontpage course is an exception, on the front page course we should display all users.
if (empty($rolenames) && !$isfrontpage) {
    if (has_capability('moodle/role:assign', $context)) {
        redirect($CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php?contextid=' . $context->id);
    } else {
开发者ID:educakanchay,项目名称:campus,代码行数:31,代码来源:index.php


示例3: get_context_instance

    $isfrontpage = ($course->id == SITEID);

    $frontpagectx = get_context_instance(CONTEXT_COURSE, SITEID);

    if ($isfrontpage) {
        $PAGE->set_pagelayout('admin');
        require_capability('moodle/site:viewparticipants', $systemcontext);
    } else {
        $PAGE->set_pagelayout('incourse');
        require_capability('moodle/course:viewparticipants', $context);
    }

    $rolenamesurl = new moodle_url("$CFG->wwwroot/user/index.php?contextid=$context->id&sifirst=&silast=");

    $allroles = get_all_roles();
    $roles = get_profile_roles($context);
    $allrolenames = array();
    if ($isfrontpage) {
        $rolenames = array(0=>get_string('allsiteusers', 'role'));
    } else {
        $rolenames = array(0=>get_string('allparticipants'));
    }

    foreach ($allroles as $role) {
        $allrolenames[$role->id] = strip_tags(role_get_name($role, $context));   // Used in menus etc later on
        if (isset($roles[$role->id])) {
            $rolenames[$role->id] = $allrolenames[$role->id];
        }
    }

    // make sure other roles may not be selected by any means
开发者ID:rolandovanegas,项目名称:moodle,代码行数:31,代码来源:index.php


示例4: groups_get_possible_roles

/**
 * Obtains a list of the possible roles that group members might come from,
 * on a course. Generally this includes only profile roles.
 *
 * @param context $context Context of course
 * @return Array of role ID integers, or false if error/none.
 */
function groups_get_possible_roles($context)
{
    $roles = get_profile_roles($context);
    return array_keys($roles);
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:12,代码来源:lib.php


示例5: get_groups_roles

 /**
  * Return the current user roles and groups in the current course
  * @return array Array in the first element the groups in the second the user roles
  */
 public function get_groups_roles()
 {
     global $USER;
     $groups = array();
     $roles = array();
     if (!has_capability('moodle/course:viewparticipants', $this->context)) {
         return array($groups, $roles);
     }
     if ($groupmode = $this->course->groupmode) {
         $aag = has_capability('moodle/site:accessallgroups', $this->context);
         if ($groupmode == VISIBLEGROUPS or $aag) {
             $allowedgroups = groups_get_all_groups($this->course->id, 0, $this->course->defaultgroupingid);
         } else {
             $allowedgroups = groups_get_all_groups($this->course->id, $USER->id, $this->course->defaultgroupingid);
         }
         $activegroup = groups_get_course_group($this->course, true, $allowedgroups);
         $groupsmenu = array();
         if (!$allowedgroups or $groupmode == VISIBLEGROUPS or $aag) {
             $groupsmenu[0] = get_string('allparticipants');
         }
         if ($allowedgroups) {
             foreach ($allowedgroups as $group) {
                 $groupsmenu[$group->id] = format_string($group->name);
             }
         }
         $groups = $groupsmenu;
     }
     $allroles = get_all_roles();
     $roles = get_profile_roles($this->context);
     $allrolenames = array();
     $rolenames = array(0 => get_string('allparticipants'));
     foreach ($allroles as $role) {
         $allrolenames[$role->id] = strip_tags(role_get_name($role, $this->context));
         if (isset($roles[$role->id])) {
             $rolenames[$role->id] = $allrolenames[$role->id];
         }
     }
     $roles = $rolenames;
     return array($groups, $roles);
 }
开发者ID:borrown,项目名称:moodle-block_jmail,代码行数:44,代码来源:block_jmail_mailbox.class.php


示例6: view_creation

 /**
  * Outputs the content of the creation tab and manages actions taken in this tab
  */
 public function view_creation()
 {
     global $SESSION, $OUTPUT, $PAGE, $DB;
     $id = $this->cm->id;
     $context = context_course::instance($this->course->id);
     // Get applicable roles!
     $rolenames = array();
     if ($roles = get_profile_roles($context)) {
         foreach ($roles as $role) {
             $rolenames[$role->id] = strip_tags(role_get_name($role, $context));
         }
     }
     // Check if everything has been confirmed, so we can finally start working!
     if (optional_param('confirm', 0, PARAM_BOOL)) {
         if (isset($SESSION->grouptool->view_administration->createGroups)) {
             require_capability('mod/grouptool:create_groups', $this->context);
             // Create groups!
             $data = $SESSION->grouptool->view_administration;
             switch ($data->mode) {
                 case GROUPTOOL_GROUPS_AMOUNT:
                     // Allocate members from the selected role to groups!
                     switch ($data->allocateby) {
                         case 'no':
                         case 'random':
                         case 'lastname':
                             $orderby = 'lastname, firstname';
                             break;
                         case 'firstname':
                             $orderby = 'firstname, lastname';
                             break;
                         case 'idnumber':
                             $orderby = 'idnumber';
                             break;
                         default:
                             print_error('unknoworder');
                     }
                     $users = groups_get_potential_members($this->course->id, $data->roleid, $data->cohortid, $orderby);
                     $usercnt = count($users);
                     $numgrps = $data->amount;
                     $userpergrp = floor($usercnt / $numgrps);
                     list($error, $preview) = $this->create_groups($data, $users, $userpergrp, $numgrps);
                     break;
                 case GROUPTOOL_MEMBERS_AMOUNT:
                     // Allocate members from the selected role to groups!
                     switch ($data->allocateby) {
                         case 'no':
                         case 'random':
                         case 'lastname':
                             $orderby = 'lastname, firstname';
                             break;
                         case 'firstname':
                             $orderby = 'firstname, lastname';
                             break;
                         case 'idnumber':
                             $orderby = 'idnumber';
                             break;
                         default:
                             print_error('unknoworder');
                     }
                     $users = groups_get_potential_members($this->course->id, $data->roleid, $data->cohortid, $orderby);
                     $usercnt = count($users);
                     $numgrps = ceil($usercnt / $data->amount);
                     $userpergrp = $data->amount;
                     if (!empty($data->nosmallgroups) and $usercnt % $data->amount != 0) {
                         /*
                          *  If there would be one group with a small number of member
                          *  reduce the number of groups
                          */
                         $missing = $userpergrp * $numgrps - $usercnt;
                         if ($missing > $userpergrp * (1 - GROUPTOOL_AUTOGROUP_MIN_RATIO)) {
                             // Spread the users from the last small group!
                             $numgrps--;
                             $userpergrp = floor($usercnt / $numgrps);
                         }
                     }
                     list($error, $preview) = $this->create_groups($data, $users, $userpergrp, $numgrps);
                     break;
                 case GROUPTOOL_1_PERSON_GROUPS:
                     $users = groups_get_potential_members($this->course->id, $data->roleid, $data->cohortid);
                     if (!isset($data->groupingname)) {
                         $data->groupingname = null;
                     }
                     list($error, $prev) = $this->create_one_person_groups($users, $data->namingscheme, $data->grouping, $data->groupingname);
                     $preview = $prev;
                     break;
                 case GROUPTOOL_FROMTO_GROUPS:
                     if (!isset($data->groupingname)) {
                         $data->groupingname = null;
                     }
                     list($error, $preview) = $this->create_fromto_groups($data);
                     break;
             }
             $class = $error ? 'notifyproblem' : 'notifysuccess';
             $preview = $OUTPUT->notification($preview, $class);
             echo $OUTPUT->box(html_writer::tag('div', $preview, array('class' => 'centered')), 'generalbox');
         }
         unset($SESSION->grouptool->view_administration);
//.........这里部分代码省略.........
开发者ID:rimacher,项目名称:moodle-mod_grouptool,代码行数:101,代码来源:locallib.php


示例7: get_roles_for_users

 /**
  * Get the role names of all roles the users shown have.
  *
  * @param array $userids
  * @access public
  * @return array
  */
 public function get_roles_for_users($userids)
 {
     global $DB;
     if (empty($userids)) {
         return array();
     }
     $roles = array();
     $context = $this->params['context'];
     list($insql, $params) = $DB->get_in_or_equal($userids);
     $rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true);
     $sql = "SELECT ra.id, ra.userid, ra.roleid\n                FROM {role_assignments} ra\n                WHERE ra.userid {$insql} AND ra.contextid = ?";
     $params[] = $context->get_course_context()->id;
     $rolers = $DB->get_recordset_sql($sql, $params);
     foreach ($rolers as $record) {
         if (isset($rolenames[$record->roleid])) {
             $roles[$record->userid][$record->roleid] = $rolenames[$record->roleid];
         }
     }
     return $roles;
 }
开发者ID:eSrem,项目名称:moodle-mod_mediagallery,代码行数:27,代码来源:search.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_project_access函数代码示例发布时间:2022-05-15
下一篇:
PHP get_profile_photo_by_id函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap