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


PHP get_user_roles函数代码示例

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


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

示例1: navbar

 public function navbar()
 {
     global $CFG;
     $items = $this->page->navbar->get_items();
     /* Added for subadmin */
     $context = get_context_instance(CONTEXT_SYSTEM);
     $roles = get_user_roles($context, $USER->id, false);
     $role = key($roles);
     $rolename = $roles[$role]->shortname;
     $htmlblocks = array();
     // Iterate the navarray and display each node
     $itemcount = count($items);
     $separator = get_separator();
     for ($i = 0; $i < $itemcount; $i++) {
         $item = $items[$i];
         $item->hideicon = true;
         if ($i === 0) {
             if ($rolename == 'subadmin') {
                 $item->action = new moodle_url($CFG->wwwroot . '/my/');
             }
             $content = html_writer::tag('li', $this->render($item));
         } else {
             $content = html_writer::tag('li', $separator . $this->render($item));
         }
         $htmlblocks[] = $content;
     }
     //accessibility: heading for navbar list  (MDL-20446)
     $navbarcontent = html_writer::tag('span', get_string('pagepath'), array('class' => 'accesshide'));
     $navbarcontent .= html_writer::tag('ul', join('', $htmlblocks), array('role' => 'navigation'));
     // XHTML
     return $navbarcontent;
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:32,代码来源:renderers.php

示例2: get_rol

/**
 * Obtiene el rol del usuario logeado.
 * @return string Rol {'Alumno', 'Profesor', 'Decano', 'Rector'}
 */
function get_rol()
{
    global $USER, $DB, $SESSION;
    if (isset($SESSION->rol)) {
        return $SESSION->rol;
        exit;
    }
    $context = context_system::instance();
    $rolesportada = get_user_roles($context, false);
    foreach ($rolesportada as $rol) {
        if ($rol->name == 'Rector') {
            $SESSION->rol = 'Rector';
            return 'Rector';
        }
    }
    $facultades = $DB->get_records_sql("SELECT DISTINCT {course}.category\n\t\t\t\t\t\t\t\t\t\tFROM {course} INNER JOIN {context} ON ({course}.category = {context}.instanceid)\n\t\t\t\t\t\t\t\t\t\tINNER JOIN {role_assignments} ON ({context}.id = {role_assignments}.contextid)\n\t\t\t\t\t\t\t\t\t\tINNER JOIN {role} ON ({role_assignments}.roleid = {role}.id)\n\t\t\t\t\t\t\t\t\t\tWHERE {role}.name = 'Decano' AND {role_assignments}.userid = " . $USER->id);
    if (!empty($facultades)) {
        $SESSION->rol = 'Decano';
        $SESSION->facultades = array_keys($facultades);
        return 'Decano';
    }
    $profesores = $DB->get_records_sql("SELECT DISTINCT id_profesor FROM {local_toolbox_score}");
    if (array_key_exists($USER->id, $profesores)) {
        $SESSION->rol = 'Profesor';
        return 'Profesor';
    }
    $SESSION->rol = 'Alumno';
    return 'Alumno';
}
开发者ID:edmiranda,项目名称:toolbox,代码行数:33,代码来源:lib.php

示例3: definition

 function definition()
 {
     global $CFG, $DB;
     $mform = $this->_form;
     $user = $this->_customdata['user'];
     $course = $this->_customdata['course'];
     $context = context_course::instance($course->id);
     $assignable = $this->_customdata['assignable'];
     $assignable = array_reverse($assignable, true);
     // students first
     $ras = get_user_roles($context, $user->id, true);
     foreach ($ras as $ra) {
         unset($assignable[$ra->roleid]);
     }
     $mform->addElement('header', 'general', fullname($user));
     $mform->addElement('select', 'roleid', get_string('addrole', 'role'), $assignable);
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'user');
     $mform->setType('user', PARAM_INT);
     $mform->addElement('hidden', 'action');
     $mform->setType('action', PARAM_ALPHANUMEXT);
     $mform->addElement('hidden', 'ifilter');
     $mform->setType('ifilter', PARAM_ALPHA);
     $mform->addElement('hidden', 'page');
     $mform->setType('page', PARAM_INT);
     $mform->addElement('hidden', 'perpage');
     $mform->setType('perpage', PARAM_INT);
     $mform->addElement('hidden', 'sort');
     $mform->setType('sort', PARAM_ALPHA);
     $mform->addElement('hidden', 'dir');
     $mform->setType('dir', PARAM_ALPHA);
     $this->add_action_buttons();
     $this->set_data(array('action' => 'assign', 'user' => $user->id));
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:35,代码来源:users_forms.php

示例4: logged_in

function logged_in()
{
    global $DB, $ip, $username, $teamid, $teamdata, $userdata;
    if (!empty($username) && !empty($userdata) && !empty($teamdata)) {
        return TRUE;
    }
    // Retrieve userdata for given AUTH_METHOD, assume not logged in
    // when userdata is empty:
    switch (AUTH_METHOD) {
        case 'FIXED':
            $username = FIXED_USER;
            $userdata = $DB->q('MAYBETUPLE SELECT * FROM user
		                    WHERE username = %s AND enabled = 1', $username);
            break;
        case 'EXTERNAL':
            if (empty($_SERVER['REMOTE_USER'])) {
                $username = $userdata = null;
            } else {
                $username = $_SERVER['REMOTE_USER'];
                $userdata = $DB->q('MAYBETUPLE SELECT * FROM user
			                    WHERE username = %s AND enabled = 1', $username);
            }
            break;
        case 'IPADDRESS':
            $userdata = $DB->q('MAYBETUPLE SELECT * FROM user
		                    WHERE ip_address = %s AND enabled = 1', $ip);
            break;
        case 'PHP_SESSIONS':
        case 'LDAP':
            if (session_id() == "") {
                session_start();
            }
            if (isset($_SESSION['username'])) {
                $userdata = $DB->q('MAYBETUPLE SELECT * FROM user
			                    WHERE username = %s AND enabled = 1', $_SESSION['username']);
            }
            break;
        default:
            error("Unknown authentication method '" . AUTH_METHOD . "' requested.");
    }
    if (!empty($userdata)) {
        $username = $userdata['username'];
        $teamdata = $DB->q('MAYBETUPLE SELECT * FROM team
		                    WHERE teamid = %i AND enabled = 1', $userdata['teamid']);
        // Pull the list of roles that a user has
        $userdata['roles'] = get_user_roles($userdata['userid']);
    }
    if (!empty($teamdata)) {
        $teamid = $teamdata['teamid'];
        // Is this the first visit? Record that in the team table.
        if (empty($teamdata['teampage_first_visited'])) {
            $hostname = gethostbyaddr($ip);
            $DB->q('UPDATE team SET teampage_first_visited = %s, hostname = %s
			        WHERE teamid = %i', now(), $hostname, $teamid);
        }
    }
    return $username !== NULL;
}
开发者ID:22a,项目名称:Cleaner-Ducss-Judge,代码行数:58,代码来源:auth.php

示例5: execute

 function execute($userid, $context, $data) {
     //global $DB, $CFG, $COURSE;
     //$context = ($this->report->courseid == SITEID) ? context_system::instance() : context_course::instance($this->report->courseid);
     //$context = context_course::instance($COURSE->id);
     $roles = get_user_roles($context, $userid);
     if (!empty($roles)) {
         foreach ($roles as $rol) {
             if ($rol->roleid == $data->roleid)
                 return true;
         }
     }
     return false;
 }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:13,代码来源:plugin.class.php

示例6: is_admin

 function is_admin($id = 0)
 {
     $user = new Focalworks\Users\User();
     $current_user = Auth::user();
     if ($id > 0) {
         $current_user = $user::find($id);
     }
     $user_roles = get_user_roles($current_user->id);
     if (in_array(1, $user_roles)) {
         return true;
         //if admin logged in
     }
     return false;
 }
开发者ID:gitllermopalafox,项目名称:user,代码行数:14,代码来源:helpers.php

示例7: execute

 function execute($userid, $context, $data)
 {
     global $CFG;
     $context = $this->report->courseid == SITEID ? get_context_instance(CONTEXT_SYSTEM) : get_context_instance(CONTEXT_COURSE, $this->report->courseid);
     $roles = get_user_roles($context, $userid);
     if (!empty($roles)) {
         foreach ($roles as $rol) {
             if ($rol->roleid == $data->roleid) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:14,代码来源:plugin.class.php

示例8: init

 public function init()
 {
     parent::init();
     $this->addElement('text', 'username', array('label' => __('Username'), 'description' => __('Username must be 30 characters or fewer. Whitespace is not allowed.'), 'required' => true, 'size' => '30', 'validators' => array(array('validator' => 'NotEmpty', 'breakChainOnFailure' => true, 'options' => array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => __('Username is required.')))), array('validator' => 'Regex', 'breakChainOnFailure' => true, 'options' => array('pattern' => '#^[a-zA-Z0-9.*@+!\\-_%\\#\\^&$]*$#u', 'messages' => array(Zend_Validate_Regex::NOT_MATCH => __('Whitespace is not allowed. Only these special characters may be used: %s', ' + ! @ # $ % ^ & * . - _')))), array('validator' => 'StringLength', 'breakChainOnFailure' => true, 'options' => array('min' => User::USERNAME_MIN_LENGTH, 'max' => User::USERNAME_MAX_LENGTH, 'messages' => array(Zend_Validate_StringLength::TOO_SHORT => __('Username must be at least %min% characters long.'), Zend_Validate_StringLength::TOO_LONG => __('Username must be at most %max% characters long.')))), array('validator' => 'Db_NoRecordExists', 'options' => array('table' => $this->_user->getTable()->getTableName(), 'field' => 'username', 'exclude' => array('field' => 'id', 'value' => (int) $this->_user->id), 'adapter' => $this->_user->getDb()->getAdapter(), 'messages' => array('recordFound' => __('This username is already in use.')))))));
     $this->addElement('text', 'name', array('label' => __('Display Name'), 'description' => __('Name as it should be displayed on the site'), 'size' => '30', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'breakChainOnFailure' => true, 'options' => array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => __('Real Name is required.')))))));
     $invalidEmailMessage = __('This email address is invalid.');
     $this->addElement('text', 'email', array('label' => __('Email'), 'size' => '30', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'breakChainOnFailure' => true, 'options' => array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => __('Email is required.')))), array('validator' => 'EmailAddress', 'options' => array('messages' => array(Zend_Validate_EmailAddress::INVALID => $invalidEmailMessage, Zend_Validate_EmailAddress::INVALID_FORMAT => $invalidEmailMessage, Zend_Validate_EmailAddress::INVALID_HOSTNAME => $invalidEmailMessage))), array('validator' => 'Db_NoRecordExists', 'options' => array('table' => $this->_user->getTable()->getTableName(), 'field' => 'email', 'exclude' => array('field' => 'id', 'value' => (int) $this->_user->id), 'adapter' => $this->_user->getDb()->getAdapter(), 'messages' => array('recordFound' => __('This email address is already in use.')))))));
     if ($this->_hasRoleElement) {
         $this->addElement('select', 'role', array('label' => __('Role'), 'description' => __("Roles describe the permissions a user has. See <a href='http://omeka.org/codex/User_Roles' target='_blank'>documentation</a> for details."), 'multiOptions' => get_user_roles(), 'required' => true));
     }
     if ($this->_hasActiveElement) {
         $description = __('Inactive users cannot log in to the site.');
         if ($this->_user->active == 0 && $this->_usersActivations) {
             $description .= '<br>' . __('Activation has been pending since %s.', format_date($this->_usersActivations->added));
         }
         $this->addElement('checkbox', 'active', array('label' => __('Active?'), 'description' => $description));
     }
     $this->addElement('hash', 'user_csrf', array('timeout' => 3600));
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:19,代码来源:User.php

示例9: customlabel_filter_role_disabled

/**
* filters types against roles of the current user. Checks in global configuration keys
* for custom label.
* @uses $CFG.
* @uses $USER;
*
*/
function customlabel_filter_role_disabled(&$classes, $context)
{
    global $CFG, $USER;
    $roleids = array();
    $roles = get_user_roles($context, $USER->id, true);
    foreach ($roles as $role) {
        $roleids[] = $role->roleid;
    }
    for ($i = 0; $i < count($classes); $i++) {
        $typename = $classes[$i]->id;
        $globparm = "customlabel_{$typename}_hiddenfor";
        $disabledrolelist = explode(",", @$CFG->{$globparm});
        $diff = array_diff($roleids, $disabledrolelist);
        // if all roles held by user here are in disabled list, put it out.
        if (empty($diff)) {
            unset($classes[$i]);
        }
    }
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:26,代码来源:locallib.php

示例10: init

 public function init()
 {
     parent::init();
     $this->addElement('text', 'username', array('label' => __('Username'), 'placeholder' => "Nom d'utilisateur", 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'options' => array('messages' => array('isEmpty' => __('Nom d\'utilisateur obligatoire.')))))));
     $this->addElement('hidden', 'name', array('label' => __('Display Name'), 'value' => 'aucun', 'placeholder' => "Nom et prénom", 'size' => '30', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'breakChainOnFailure' => true, 'options' => array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => __('Nom et prénom obligatoires.')))))));
     $invalidEmailMessage = __('Adresse e-mail invalide.');
     $this->addElement('text', 'email', array('label' => __('Email'), 'placeholder' => "Adresse e-mail", 'size' => '30', 'required' => true, 'validators' => array(array('validator' => 'NotEmpty', 'breakChainOnFailure' => true, 'options' => array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => __('Adresse  e-mail obligatoire.')))), array('validator' => 'EmailAddress', 'options' => array('messages' => array(Zend_Validate_EmailAddress::INVALID => $invalidEmailMessage, Zend_Validate_EmailAddress::INVALID_FORMAT => $invalidEmailMessage, Zend_Validate_EmailAddress::INVALID_HOSTNAME => $invalidEmailMessage))), array('validator' => 'Db_NoRecordExists', 'options' => array('table' => $this->_user->getTable()->getTableName(), 'field' => 'email', 'exclude' => array('field' => 'id', 'value' => (int) $this->_user->id), 'adapter' => $this->_user->getDb()->getAdapter(), 'messages' => array('recordFound' => __('Cette adresse e-mail est déjà utilisée.')))))));
     if ($this->_hasRoleElement) {
         $this->addElement('select', 'role', array('label' => __('Role'), 'description' => __("Les roles décrivent les permissions des utilisateurs. Voir <a href='http://omeka.org/codex/User_Roles' target='_blank'>documentation</a> pour plus d'infos."), 'multiOptions' => get_user_roles(), 'required' => true));
     }
     if ($this->_hasActiveElement) {
         $description = __('Inactive users cannot log in to the site.');
         if ($this->_user->active == 0 && $this->_usersActivations) {
             $description .= '<br>' . __('Activation en attente depuis %s.', format_date($this->_usersActivations->added));
         }
         $this->addElement('checkbox', 'active', array('label' => __('Active?'), 'description' => $description));
     }
     $this->addElement('hash', 'user_csrf', array('timeout' => 3600));
 }
开发者ID:kyfr59,项目名称:cg35,代码行数:19,代码来源:User.php

示例11: verifyEvent

 /**
  * Observe the events, and dispatch them if necessary.
  *
  * @param \core\event\base $event The event.
  * @return void
  */
 protected static function verifyEvent(\core\event\base $event)
 {
     if (is_siteadmin()) {
         return;
     }
     // So executa as acoes de bloqueio caso seja aluno
     $context = context_course::instance($event->courseid);
     $userRoles = get_user_roles($context, $event->userid);
     $isStudent = false;
     if (!empty($userRoles)) {
         foreach ($userRoles as $r => $role) {
             if ($role->roleid == 5) {
                 $isStudent = true;
                 break;
             }
         }
     }
     if ($isStudent) {
         $manager = local_wsmiidle_manager::get($event->courseid);
         $manager->capture_event($event);
     }
 }
开发者ID:uemanet,项目名称:moodle-local_wsmiidle,代码行数:28,代码来源:helper.php

示例12: user_can_assign

/**
 * Checks if a user can assign users to a particular role in this context
 *
 * @param context $context
 * @param int $targetroleid - the id of the role you want to assign users to
 * @return boolean
 */
function user_can_assign(context $context, $targetroleid)
{
    global $DB;
    // first check if user has override capability
    // if not return false;
    if (!has_capability('moodle/role:assign', $context)) {
        return false;
    }
    // pull out all active roles of this user from this context(or above)
    if ($userroles = get_user_roles($context)) {
        foreach ($userroles as $userrole) {
            // if any in the role_allow_override table, then it's ok
            if ($DB->get_record('role_allow_assign', array('roleid' => $userrole->roleid, 'allowassign' => $targetroleid))) {
                return true;
            }
        }
    }
    return false;
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:26,代码来源:accesslib.php

示例13: import_file


//.........这里部分代码省略.........
             continue;
         }
         // Parse the line, from which we may get one or two
         // matches since the group name is an optional item
         // on a line by line basis
         if (!preg_match($regex_pattern, $line, $matches)) {
             $result .= sprintf(get_string('ERR_PATTERN_MATCH', self::PLUGIN_NAME), $line_num, $line);
             continue;
         }
         $ident_value = $matches[1];
         $group_name = isset($matches[2]) ? $matches[2] : '';
         // User must already exist, we import enrollments
         // into courses, not users into the system. Exclude
         // records marked as deleted. Because idnumber is
         // not enforced unique, possible multiple records
         // returned when using that identifying field, so
         // use ->get_records method to make that detection
         // and inform user
         $user_rec_array = $DB->get_records('user', array($ident_field => addslashes($ident_value), 'deleted' => 0));
         // Should have one and only one record, otherwise
         // report it and move on to the next
         $user_rec_count = count($user_rec_array);
         if ($user_rec_count == 0) {
             // No record found
             $result .= sprintf(get_string('ERR_USERID_INVALID', self::PLUGIN_NAME), $line_num, $ident_value);
             continue;
         } elseif ($user_rec_count > 1) {
             // Too many records
             $result .= sprintf(get_string('ERR_USER_MULTIPLE_RECS', self::PLUGIN_NAME), $line_num, $ident_value);
             continue;
         }
         $user_rec = array_shift($user_rec_array);
         // Fetch all the role assignments this user might have for this course's context
         $roles = get_user_roles($course_context, $user_rec->id, false);
         // If a user has a role in this course, then we leave it alone and move on
         // to the group assignment if there is one. If they have no role, then we
         // should go ahead and add one, as long as it is not a metacourse.
         if (!$roles && $role_id > 0) {
             if ($metacourse) {
                 $result .= sprintf(get_string('ERR_ENROLL_META', self::PLUGIN_NAME), $line_num, $ident_value);
             } else {
                 try {
                     $manual_enrol_plugin->enrol_user($enrol_instance, $user_rec->id, $role_id);
                 } catch (Exception $exc) {
                     $result .= sprintf(get_string('ERR_ENROLL_FAILED', self::PLUGIN_NAME), $line_num, $ident_value);
                     $result .= $exc->getMessage();
                     continue;
                 }
             }
         }
         // If no group assignments, or group is from file, but no
         // group found, next line
         if (!$group_assign || $group_id == 0 && empty($group_name)) {
             continue;
         }
         // If no group pre-selected, see if group from import already
         // created for that course
         $assign_group_id = 0;
         $assign_group_name = '';
         if ($selected_group != null) {
             $assign_group_id = $selected_group->id;
             $assign_group_name = $selected_group->name;
         } else {
             foreach ($existing_groups as $existing_group) {
                 if ($existing_group->name != $group_name) {
                     continue;
开发者ID:aj-michael,项目名称:moodle-local_userenrols,代码行数:67,代码来源:lib.php

示例14: dialogue_get_available_teachers

/**
 * Return a list of teachers that the current user is able to open a dialogue with
 * 
 * Called by dialogue_get_available_users(). The list is used to populate a drop-down
 * list in the UI. The returned array of usernames is filtered to hide teacher names
 * if those teachers have a hidden role assignment, unless the list is being returned
 * for a teacher in which case those hidden teachers are listed
 * @param   object  $dialogue
 * @param   object  $context    for a user in this activity
 * @param   int     $editconversationid
 * @return  array   usernames and ids
 */
function dialogue_get_available_teachers($dialogue, $context, $editconversationid = 0)
{
    global $USER, $CFG;
    $canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
    if (!($course = get_record('course', 'id', $dialogue->course))) {
        error('Course is misconfigured');
    }
    if (!($cm = get_coursemodule_from_instance('dialogue', $dialogue->id, $course->id))) {
        error('Course Module ID was incorrect');
    }
    // get the list of teachers (actually, those who have dialogue:manage capability)
    $hiddenTeachers = array();
    if ($users = get_users_by_capability($context, 'mod/dialogue:manage', '', null, null, null, null, null, null, true, null)) {
        foreach ($users as $user) {
            $userRoles = get_user_roles($context, $user->id, true);
            foreach ($userRoles as $role) {
                if ($role->hidden == 1) {
                    $hiddenTeachers[$user->id] = 1;
                    break;
                }
            }
        }
        $canSeeHidden = false;
        if (has_capability('moodle/role:viewhiddenassigns', $context)) {
            $canSeeHidden = true;
        }
        $groupid = get_current_group($course->id);
        foreach ($users as $otheruser) {
            // ...exclude self and ...
            if ($USER->id != $otheruser->id) {
                // ...if groupmode is SEPARATEGROUPS then exclude teachers not in student's group
                if ($groupid and groupmode($course, $cm) == SEPARATEGROUPS) {
                    if (!ismember($groupid, $otheruser->id)) {
                        continue;
                    }
                }
                if (!$canSeeHidden && array_key_exists($otheruser->id, $hiddenTeachers) && $hiddenTeachers[$otheruser->id] == 1) {
                    continue;
                }
                // ...any already in open conversations unless multiple conversations allowed
                if ($dialogue->multipleconversations or count_records_select('dialogue_conversations', "dialogueid = {$dialogue->id} AND id != {$editconversationid} AND ((userid = {$USER->id} AND \n                        recipientid = {$otheruser->id}) OR (userid = {$otheruser->id} AND \n                        recipientid = {$USER->id})) AND closed = 0") == 0) {
                    $names[$otheruser->id] = fullname($otheruser);
                }
            }
        }
    }
    if (isset($names)) {
        natcasesort($names);
        return $names;
    }
    return;
}
开发者ID:netspotau,项目名称:moodle-mod_dialogue,代码行数:64,代码来源:locallib.php

示例15: print_header_simple

    // Bye!
}
/// Check if the course is a meta course  (bug 5734)
if ($course->metacourse) {
    print_header_simple();
    notice(get_string('coursenotaccessible'), "{$CFG->wwwroot}/index.php");
}
/// Users can't enroll to site course
if ($course->id == SITEID) {
    print_header_simple();
    notice(get_string('enrollfirst'), "{$CFG->wwwroot}/index.php");
}
/// Double check just in case they are enrolled to start in the future
if ($course->enrolperiod) {
    // Only active if the course has an enrolment period in effect
    if ($roles = get_user_roles($context, $USER->id)) {
        foreach ($roles as $role) {
            if ($role->timestart and $role->timestart >= time()) {
                $message = get_string('enrolmentnotyet', '', userdate($student->timestart));
                print_header();
                notice($message, "{$CFG->wwwroot}/index.php");
            }
        }
    }
}
/// Check if the course is enrollable
if (!method_exists($enrol, 'print_entry')) {
    print_header_simple();
    notice(get_string('enrolmentnointernal'), "{$CFG->wwwroot}/index.php");
}
if (!$course->enrollable || $course->enrollable == 2 && $course->enrolstartdate > 0 && $course->enrolstartdate > time() || $course->enrollable == 2 && $course->enrolenddate > 0 && $course->enrolenddate <= time()) {
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:enrol.php


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