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


PHP role_get_name函数代码示例

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


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

示例1: course_info_box

 /**
  * Renders course info box.
  *
  * @param stdClass $course
  * @return string
  */
 public function course_info_box(stdClass $course)
 {
     global $CFG;
     $context = context_course::instance($course->id);
     $content = '';
     $content .= $this->output->box_start('generalbox info');
     $summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
     $content .= format_text($summary, $course->summaryformat, array('overflowdiv' => true), $course->id);
     if (!empty($CFG->coursecontact)) {
         $coursecontactroles = explode(',', $CFG->coursecontact);
         foreach ($coursecontactroles as $roleid) {
             if ($users = get_role_users($roleid, $context, true)) {
                 foreach ($users as $teacher) {
                     $role = new stdClass();
                     $role->id = $teacher->roleid;
                     $role->name = $teacher->rolename;
                     $role->shortname = $teacher->roleshortname;
                     $role->coursealias = $teacher->rolecoursealias;
                     $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
                     $namesarray[] = role_get_name($role, $context) . ': <a href="' . $CFG->wwwroot . '/user/view.php?id=' . $teacher->id . '&amp;course=' . SITEID . '">' . $fullname . '</a>';
                 }
             }
         }
         if (!empty($namesarray)) {
             $content .= "<ul class=\"teachers\">\n<li>";
             $content .= implode('</li><li>', $namesarray);
             $content .= "</li></ul>";
         }
     }
     $content .= $this->output->box_end();
     return $content;
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:38,代码来源:renderer.php

示例2: definition

 function definition()
 {
     global $CFG, $DB;
     $mform = $this->_form;
     list($instance, $plugin, $course) = $this->_customdata;
     $coursecontext = context_course::instance($course->id);
     $enrol = enrol_get_plugin('cohort');
     $groups = array(0 => get_string('none'));
     foreach (groups_get_all_groups($course->id) as $group) {
         $groups[$group->id] = format_string($group->name, true, array('context' => $coursecontext));
     }
     $mform->addElement('header', 'general', get_string('pluginname', 'enrol_cohort'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $mform->setType('name', PARAM_TEXT);
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_cohort'), $options);
     if ($instance->id) {
         if ($cohort = $DB->get_record('cohort', array('id' => $instance->customint1))) {
             $cohorts = array($instance->customint1 => format_string($cohort->name, true, array('context' => context::instance_by_id($cohort->contextid))));
         } else {
             $cohorts = array($instance->customint1 => get_string('error'));
         }
         $mform->addElement('select', 'customint1', get_string('cohort', 'cohort'), $cohorts);
         $mform->setConstant('customint1', $instance->customint1);
         $mform->hardFreeze('customint1', $instance->customint1);
     } else {
         $cohorts = array('' => get_string('choosedots'));
         $allcohorts = cohort_get_available_cohorts($coursecontext, 0, 0, 0);
         foreach ($allcohorts as $c) {
             $cohorts[$c->id] = format_string($c->name);
         }
         $mform->addElement('select', 'customint1', get_string('cohort', 'cohort'), $cohorts);
         $mform->addRule('customint1', get_string('required'), 'required', null, 'client');
     }
     $roles = get_assignable_roles($coursecontext);
     $roles[0] = get_string('none');
     $roles = array_reverse($roles, true);
     // Descending default sortorder.
     $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_cohort'), $roles);
     $mform->setDefault('roleid', $enrol->get_config('roleid'));
     if ($instance->id and !isset($roles[$instance->roleid])) {
         if ($role = $DB->get_record('role', array('id' => $instance->roleid))) {
             $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS, true);
             $roles[$instance->roleid] = role_get_name($role, $coursecontext);
         } else {
             $roles[$instance->roleid] = get_string('error');
         }
     }
     $mform->addElement('select', 'customint2', get_string('addgroup', 'enrol_cohort'), $groups);
     $mform->addElement('hidden', 'courseid', null);
     $mform->setType('courseid', PARAM_INT);
     $mform->addElement('hidden', 'id', null);
     $mform->setType('id', PARAM_INT);
     if ($instance->id) {
         $this->add_action_buttons(true);
     } else {
         $this->add_action_buttons(true, get_string('addinstance', 'enrol'));
     }
     $this->set_data($instance);
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:60,代码来源:edit_form.php

示例3: get_instance_name

 /**
  * Returns localised name of enrol instance
  *
  * @param object|null $instance enrol_mnet instance
  * @return string
  */
 public function get_instance_name($instance)
 {
     global $DB;
     if (empty($instance)) {
         $enrol = $this->get_name();
         return get_string('pluginname', 'enrol_' . $enrol);
     } else {
         if (empty($instance->name)) {
             $enrol = $this->get_name();
             if ($role = $DB->get_record('role', array('id' => $instance->roleid))) {
                 $role = role_get_name($role, get_context_instance(CONTEXT_COURSE, $instance->courseid));
             } else {
                 $role = get_string('error');
             }
             if (empty($instance->customint1)) {
                 $host = get_string('remotesubscribersall', 'enrol_mnet');
             } else {
                 $host = $DB->get_field('mnet_host', 'name', array('id' => $instance->customint1));
             }
             return get_string('pluginname', 'enrol_' . $enrol) . ' (' . format_string($host) . ' - ' . $role . ')';
         } else {
             return format_string($instance->name);
         }
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:lib.php

示例4: get_instance_name

 /**
  * Returns localised name of enrol instance.
  *
  * @param stdClass $instance (null is accepted too)
  * @return string
  */
 public function get_instance_name($instance)
 {
     global $DB;
     if (empty($instance)) {
         $enrol = $this->get_name();
         return get_string('pluginname', 'enrol_' . $enrol);
     } else {
         if (empty($instance->name)) {
             $enrol = $this->get_name();
             $cohort = $DB->get_record('cohort', array('id' => $instance->customint1));
             if (!$cohort) {
                 return get_string('pluginname', 'enrol_' . $enrol);
             }
             $cohortname = format_string($cohort->name, true, array('context' => context::instance_by_id($cohort->contextid)));
             if ($role = $DB->get_record('role', array('id' => $instance->roleid))) {
                 $role = role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING));
                 return get_string('pluginname', 'enrol_' . $enrol) . ' (' . $cohortname . ' - ' . $role . ')';
             } else {
                 return get_string('pluginname', 'enrol_' . $enrol) . ' (' . $cohortname . ')';
             }
         } else {
             return format_string($instance->name, true, array('context' => context_course::instance($instance->courseid)));
         }
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:31,代码来源:lib.php

示例5: get_label

 /**
  * Returns a human friendly description of the filter used as label.
  * @param array $data filter settings
  * @return string active filter label
  */
 function get_label($data)
 {
     global $DB;
     $role = $DB->get_record('role', array('id' => $data['value']));
     $a = new stdClass();
     $a->label = $this->_label;
     $a->value = '"' . role_get_name($role) . '"';
     return get_string('globalrolelabel', 'filters', $a);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:14,代码来源:globalrole.php

示例6: get_role_name

 /**
  * Gets role name.
  * If no such role exists this function returns null.
  *
  * @return string|null
  */
 private function get_role_name($rid)
 {
     global $DB, $PAGE;
     $rec = $DB->get_record('role', array('id' => $rid));
     if ($rec) {
         return role_get_name($rec, $PAGE->context, ROLENAME_ALIAS);
     } else {
         return null;
     }
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:16,代码来源:award_criteria_manual.php

示例7: extend_assignable_roles

 /**
  * Gets a list of roles that this user can assign for the course as the default for auto-enrolment.
  *
  * @param context $context the context.
  * @param integer $defaultrole the id of the role that is set as the default for auto-enrolment
  * @return array index is the role id, value is the role name
  */
 function extend_assignable_roles($context, $defaultrole)
 {
     global $DB;
     $roles = get_assignable_roles($context, ROLENAME_BOTH);
     if (!isset($roles[$defaultrole])) {
         if ($role = $DB->get_record('role', array('id' => $defaultrole))) {
             $roles[$defaultrole] = role_get_name($role, $context, ROLENAME_BOTH);
         }
     }
     return $roles;
 }
开发者ID:ninelanterns,项目名称:scaffold-enrol_auto,代码行数:18,代码来源:edit_form.php

示例8: get_course_roles

 protected function get_course_roles($context)
 {
     global $DB;
     $roleswithnames = array();
     $contextroleids = get_roles_for_contextlevels(CONTEXT_COURSE);
     $contextroles = $DB->get_records_list('role', 'id', $contextroleids);
     foreach ($contextroles as $id => $role) {
         $roleswithnames[$id] = role_get_name($role, $context);
     }
     return $roleswithnames;
 }
开发者ID:moodleuulm,项目名称:moodle-availability_role,代码行数:11,代码来源:frontend.php

示例9: get_instance_name

 /**
  * Creating an instance of the plugin
  */
 public function get_instance_name($instance)
 {
     if (empty($instance->name)) {
         if (!empty($instance->roleid)) {
             $role = ' (' . role_get_name($role, context_course::instance($instance->courseid)) . ')';
         } else {
             $role = '';
         }
         $enrol = $this->get_name();
         return get_string('pluginname', 'enrol_' . $enrol) . $role;
     } else {
         return format_string($instance->name);
     }
 }
开发者ID:vaughany,项目名称:moodle-enrol_forced,代码行数:17,代码来源:lib.php

示例10: get_instance_name

 /**
  * Returns localised name of enrol instance
  *
  * @param stdClass $instance (null is accepted too)
  * @return string
  */
 public function get_instance_name($instance)
 {
     global $DB;
     if (empty($instance->name)) {
         if (!empty($instance->roleid) and $role = $DB->get_record('role', array('id' => $instance->roleid))) {
             $role = ' (' . role_get_name($role, context_course::instance($instance->courseid, IGNORE_MISSING)) . ')';
         } else {
             $role = '';
         }
         $enrol = $this->get_name();
         return get_string('pluginname', 'enrol_' . $enrol) . $role;
     } else {
         return format_string($instance->name);
     }
 }
开发者ID:ruddj,项目名称:moodle,代码行数:21,代码来源:lib.php

示例11: get_instance_name

 /**
  * Returns localised name of enrol instance
  *
  * @param object $instance (null is accepted too)
  * @return string
  */
 public function get_instance_name($instance)
 {
     global $DB;
     if (empty($instance)) {
         $enrol = $this->get_name();
         return get_string('pluginname', 'enrol_' . $enrol);
     } else {
         if (empty($instance->name)) {
             $enrol = $this->get_name();
             if ($role = $DB->get_record('role', array('id' => $instance->roleid))) {
                 $role = role_get_name($role, get_context_instance(CONTEXT_COURSE, $instance->courseid));
                 return get_string('pluginname', 'enrol_' . $enrol) . ' (' . format_string($DB->get_field('cohort', 'name', array('id' => $instance->customint1))) . ' - ' . $role . ')';
             } else {
                 return get_string('pluginname', 'enrol_' . $enrol) . ' (' . format_string($DB->get_field('cohort', 'name', array('id' => $instance->customint1))) . ')';
             }
         } else {
             return format_string($instance->name);
         }
     }
 }
开发者ID:nmicha,项目名称:moodle,代码行数:26,代码来源:lib.php

示例12: tool_editrolesbycap_load_role_definitions

/**
 * @param stdClass $capability the information about a capability.
 * @return array role shortname => object with fields (role) shortname, (role) name,
 *      (role) description and permission (for this capability for that role).
 */
function tool_editrolesbycap_load_role_definitions($capability)
{
    global $DB;
    $data = $DB->get_records_sql('
                SELECT r.id AS roleid,
                       r.shortname,
                       r.name,
                       r.description,
                       r.archetype,
                       rc.permission
                  FROM {role} r
             LEFT JOIN {role_capabilities} rc ON rc.roleid = r.id
                                             AND rc.capability = :capability
                                             AND rc.contextid = :syscontextid
              ORDER BY r.sortorder, r.name', array('capability' => $capability->name, 'syscontextid' => context_system::instance()->id));
    foreach ($data as $role) {
        $role->name = role_get_name($role);
        $role->description = role_get_description($role);
        $role->defaultpermission = tool_editrolesbycap_get_default_permission($role, $capability);
    }
    return $data;
}
开发者ID:Keneth1212,项目名称:moodle,代码行数:27,代码来源:locallib.php

示例13: get_name_field

 protected function get_name_field($id)
 {
     return role_get_name($this->role);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:4,代码来源:view_role_definition_table.php

示例14: get_course_contacts

 /**
  * Returns list of course contacts (usually teachers) to display in course link
  *
  * Roles to display are set up in $CFG->coursecontact
  *
  * The result is the list of users where user id is the key and the value
  * is an array with elements:
  *  - 'user' - object containing basic user information
  *  - 'role' - object containing basic role information (id, name, shortname, coursealias)
  *  - 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS)
  *  - 'username' => fullname($user, $canviewfullnames)
  *
  * @return array
  */
 public function get_course_contacts()
 {
     global $CFG;
     if (empty($CFG->coursecontact)) {
         // No roles are configured to be displayed as course contacts.
         return array();
     }
     if ($this->coursecontacts === null) {
         $this->coursecontacts = array();
         $context = context_course::instance($this->id);
         if (!isset($this->record->managers)) {
             // Preload course contacts from DB.
             $courses = array($this->id => &$this->record);
             coursecat::preload_course_contacts($courses);
         }
         // Build return array with full roles names (for this course context) and users names.
         $canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
         foreach ($this->record->managers as $ruser) {
             if (isset($this->coursecontacts[$ruser->id])) {
                 // Only display a user once with the highest sortorder role.
                 continue;
             }
             $user = new stdClass();
             $user = username_load_fields_from_object($user, $ruser, null, array('id', 'username'));
             $role = new stdClass();
             $role->id = $ruser->roleid;
             $role->name = $ruser->rolename;
             $role->shortname = $ruser->roleshortname;
             $role->coursealias = $ruser->rolecoursealias;
             $this->coursecontacts[$user->id] = array('user' => $user, 'role' => $role, 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS), 'username' => fullname($user, $canviewfullnames));
         }
     }
     return $this->coursecontacts;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:48,代码来源:coursecatlib.php

示例15: login_info

    /**
     * Return the standard string that says whether you are logged in (and switched
     * roles/logged in as another user).
     * @param bool $withlinks if false, then don't include any links in the HTML produced.
     * If not set, the default is the nologinlinks option from the theme config.php file,
     * and if that is not set, then links are included.
     * @return string HTML fragment.
     */
    public function login_info($withlinks = null) {
        global $USER, $CFG, $DB, $SESSION;

        if (during_initial_install()) {
            return '';
        }

        if (is_null($withlinks)) {
            $withlinks = empty($this->page->layout_options['nologinlinks']);
        }

        $course = $this->page->course;
        if (\core\session\manager::is_loggedinas()) {
            $realuser = \core\session\manager::get_realuser();
            $fullname = fullname($realuser, true);
            if ($withlinks) {
                $loginastitle = get_string('loginas');
                $realuserinfo = " [<a href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&amp;sesskey=".sesskey()."\"";
                $realuserinfo .= "title =\"".$loginastitle."\">$fullname</a>] ";
            } else {
                $realuserinfo = " [$fullname] ";
            }
        } else {
            $realuserinfo = '';
        }

        $loginpage = $this->is_login_page();
        $loginurl = get_login_url();

        if (empty($course->id)) {
            // $course->id is not defined during installation
            return '';
        } else if (isloggedin()) {
            $context = context_course::instance($course->id);

            $fullname = fullname($USER, true);
            // Since Moodle 2.0 this link always goes to the public profile page (not the course profile page)
            if ($withlinks) {
                $linktitle = get_string('viewprofile');
                $username = "<a href=\"$CFG->wwwroot/user/profile.php?id=$USER->id\" title=\"$linktitle\">$fullname</a>";
            } else {
                $username = $fullname;
            }
            if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id'=>$USER->mnethostid))) {
                if ($withlinks) {
                    $username .= " from <a href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
                } else {
                    $username .= " from {$idprovider->name}";
                }
            }
            if (isguestuser()) {
                $loggedinas = $realuserinfo.get_string('loggedinasguest');
                if (!$loginpage && $withlinks) {
                    $loggedinas .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
                }
            } else if (is_role_switched($course->id)) { // Has switched roles
                $rolename = '';
                if ($role = $DB->get_record('role', array('id'=>$USER->access['rsw'][$context->path]))) {
                    $rolename = ': '.role_get_name($role, $context);
                }
                $loggedinas = get_string('loggedinas', 'moodle', $username).$rolename;
                if ($withlinks) {
                    $url = new moodle_url('/course/switchrole.php', array('id'=>$course->id,'sesskey'=>sesskey(), 'switchrole'=>0, 'returnurl'=>$this->page->url->out_as_local_url(false)));
                    $loggedinas .= ' ('.html_writer::tag('a', get_string('switchrolereturn'), array('href' => $url)).')';
                }
            } else {
                $loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username);
                if ($withlinks) {
                    $loggedinas .= " (<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
                }
            }
        } else {
            $loggedinas = get_string('loggedinnot', 'moodle');
            if (!$loginpage && $withlinks) {
                $loggedinas .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
            }
        }

        $loggedinas = '<div class="logininfo">'.$loggedinas.'</div>';

        if (isset($SESSION->justloggedin)) {
            unset($SESSION->justloggedin);
            if (!empty($CFG->displayloginfailures)) {
                if (!isguestuser()) {
                    // Include this file only when required.
                    require_once($CFG->dirroot . '/user/lib.php');
                    if ($count = user_count_login_failures($USER)) {
                        $loggedinas .= '<div class="loginfailures">';
                        $a = new stdClass();
                        $a->attempts = $count;
                        $loggedinas .= get_string('failedloginattempts', '', $a);
                        if (file_exists("$CFG->dirroot/report/log/index.php") and has_capability('report/log:view', context_system::instance())) {
//.........这里部分代码省略.........
开发者ID:afgal,项目名称:moodle-1,代码行数:101,代码来源:outputrenderers.php


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