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

PHP get_user_roles函数代码示例

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

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



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


示例16: __

                <span class="quick-filter-heading"><?php 
echo __("Quick Filter");
?>
</span>
            </li>
            <li>
                <a href="<?php 
echo url('guest-user/user/browse');
?>
"><?php 
echo __("View All");
?>
</a>
            </li>
            <?php 
foreach (get_user_roles() as $value => $name) {
    ?>
            <li>
                <a href="<?php 
    echo url('guest-user/user/browse', array('role' => $value));
    ?>
"><?php 
    echo __("%s", $name);
    ?>
</a>
            </li>
            <?php 
}
?>
            <li>
                <a href="<?php 
开发者ID:KelvinSmithLibrary,项目名称:playhouse,代码行数:31,代码来源:browse.php


示例17: organizer_send_message

function organizer_send_message($sender, $receiver, $slot, $type, $digest = null, $customdata = array())
{
    global $DB;
    if ($type == 'register_reminder:student') {
        $organizer = $slot;
    } else {
        $organizer = $DB->get_record('organizer', array('id' => $slot->organizerid));
    }
    $sender = is_int($sender) ? $DB->get_record('user', array('id' => $sender)) : $sender;
    $receiver = is_int($receiver) ? $DB->get_record('user', array('id' => $receiver)) : $receiver;
    $module = $DB->get_record('modules', array('name' => 'organizer'));
    $cm = $DB->get_record('course_modules', array('module' => $module->id, 'instance' => $organizer->id));
    $course = $DB->get_record('course', array('id' => $cm->course));
    $context = context_course::instance($cm->course);
    $roles = get_user_roles($context, $receiver->id);
    $now = time();
    if (!$cm->visible || $cm->availablefrom && $cm->availablefrom > $now || $cm->availableuntil && $cm->availableuntil < $now || count($roles) == 0) {
        return false;
    }
    $namesplit = explode(':', $type);
    $strings = new stdClass();
    $strings->sendername = fullname($sender);
    $strings->receivername = fullname($receiver);
    if ($type != 'register_reminder:student') {
        $strings->date = userdate($slot->starttime, get_string('datetemplate', 'organizer'));
        $strings->time = userdate($slot->starttime, get_string('timetemplate', 'organizer'));
        $strings->location = $slot->location;
    }
    $strings->organizername = $organizer->name;
    $strings->coursefullname = $course->fullname;
    $strings->courseshortname = $course->shortname;
    $strings->courseid = $course->idnumber == "" ? "" : $course->idnumber . ' ';
    if ($namesplit[0] == "edit_notify") {
        $strings->slot_teacher = $slot->teachervisible == 1 ? fullname($DB->get_record('user', array('id' => $slot->teacherid))) : get_string('teacherinvisible', 'organizer');
        $strings->slot_location = organizer_location_link($slot);
        $strings->slot_maxparticipants = $slot->maxparticipants;
        $strings->slot_comments = $slot->comments;
    }
    $courseurl = new moodle_url('/mod/organizer/view.php', array('id' => $cm->id));
    $strings->courselink = html_writer::link($courseurl, $course->fullname);
    if ($organizer->isgrouporganizer) {
        if (strpos($type, 'register_notify') !== false || strpos($type, 'group_registration_notify') !== false) {
            $group = groups_get_user_groups($organizer->course, $sender->id);
            $group = reset($group);
            $group = reset($group);
            $group = groups_get_group($group);
        } else {
            $group = groups_get_user_groups($organizer->course, $receiver->id);
            $group = reset($group);
            $group = reset($group);
            $group = groups_get_group($group);
        }
        $strings->groupname = $group->name;
        $type .= ":group";
    }
    if ($namesplit[0] == "eval_notify_newappointment") {
        $namesplit[0] = "eval_notify";
    }
    $message = new stdClass();
    $message->modulename = 'organizer';
    $message->component = 'mod_organizer';
    $message->name = "{$namesplit['0']}:{$namesplit['1']}";
    $message->notification = 1;
    $message->fullmessageformat = FORMAT_PLAIN;
    $message->userfrom = $sender;
    $message->userto = $receiver;
    if (isset($digest)) {
        $strings->digest = $digest;
        $type .= ":digest";
    }
    $message->subject = get_string("{$type}:subject", 'organizer', $strings);
    $message->message = get_string("{$type}:fullmessage", 'organizer', $strings);
    $message->fullmessage = get_string("{$type}:fullmessage", 'organizer', $strings);
    $message->fullmessagehtml = organizer_make_html(get_string("{$type}:fullmessage", 'organizer', $strings), $organizer, $cm, $course);
    if (isset($customdata['custommessage'])) {
        $message->fullmessage = str_replace('{$a->custommessage}', $customdata['custommessage'], $message->fullmessage);
        $message->fullmessagehtml = str_replace('{$a->custommessage}', $customdata['custommessage'], $message->fullmessagehtml);
    }
    $message->smallmessage = get_string("{$type}:smallmessage", 'organizer', $strings);
    if (ORGANIZER_ENABLE_MESSAGING) {
        return message_send($message);
    } else {
        return false;
    }
}
开发者ID:miotto,项目名称:moodle-mod_organizer,代码行数:85,代码来源:messaging.php


示例18: groups_get_user_groups

if (!has_capability('moodle/site:accessallgroups', $context)) {
    $mastercap = false;
    $mygroups = groups_get_user_groups($courseid);
    $gids = implode(',', array_values($mygroups['0']));
    $groups = empty($gids) ? array() : $DB->get_records_select('groups', 'id IN (' . $gids . ')');
}
$globalaccess = empty($allgroups);
// Fill the course users by.
$users = array();
$users_to_roles = array();
$users_to_groups = array();
$everyone = get_enrolled_users($context, '', 0, user_picture::fields('u', array('mailformat', 'maildisplay')), "", 0, 0, true);
foreach ($everyone as $userid => $user) {
    $usergroups = groups_get_user_groups($courseid, $userid);
    $gids = ($globalaccess or $mastercap) ? array_values($usergroups['0']) : array_intersect(array_values($mygroups['0']), array_values($usergroups['0']));
    $userroles = get_user_roles($context, $userid);
    $filterd = clampmail::filter_roles($userroles, $roles);
    // Available groups.
    if (!$globalaccess and !$mastercap and empty($gids) or empty($filterd) or $userid == $USER->id) {
        continue;
    }
    $groupmapper = function ($id) use($allgroups) {
        return $allgroups[$id];
    };
    $users_to_groups[$userid] = array_map($groupmapper, $gids);
    $users_to_roles[$userid] = $filterd;
    $users[$userid] = $user;
}
if (empty($users)) {
    print_error('no_users', 'block_clampmail');
}
开发者ID:sryder,项目名称:clampmail,代码行数:31,代码来源:email.php


示例19: get_user_roles

 /**
  * Gets the roles assigned to this user that are applicable for this course.
  *
  * @param int $userid
  * @return array
  */
 public function get_user_roles($userid)
 {
     $roles = array();
     $ras = get_user_roles($this->context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
     $plugins = $this->get_enrolment_plugins(false);
     foreach ($ras as $ra) {
         if ($ra->contextid != $this->context->id) {
             if (!array_key_exists($ra->roleid, $roles)) {
                 $roles[$ra->roleid] = null;
             }
             // higher ras, course always takes precedence
             continue;
         }
         if (array_key_exists($ra->roleid, $roles) && $roles[$ra->roleid] === false) {
             continue;
         }
         $changeable = true;
         if ($ra->component) {
             $changeable = false;
             if (strpos($ra->component, 'enrol_') === 0) {
                 $plugin = substr($ra->component, 6);
                 if (isset($plugins[$plugin])) {
                     $changeable = !$plugins[$plugin]->roles_protected();
                 }
             }
         }
         $roles[$ra->roleid] = $changeable;
     }
     return $roles;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:36,代码来源:locallib.php


示例20: get_content


//.........这里部分代码省略.........
             }
         }
     }
     /// Manage groups in this course
     if ($course->id !== SITEID && ($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context)) {
         $strgroups = get_string('groups');
         $this->content->items[] = '<a title="' . $strgroups . '" href="' . $CFG->wwwroot . '/group/index.php?id=' . $this->instance->pageid . '">' . $strgroups . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/group.gif" class="icon" alt="" />';
     }
     /// Backup this course
     if ($course->id !== SITEID and has_capability('moodle/site:backup', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/backup/backup.php?id=' . $this->instance->pageid . '">' . get_string('backup') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/backup.gif" class="icon" alt="" />';
     }
     /// Restore to this course
     if ($course->id !== SITEID and has_capability('moodle/site:restore', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/files/index.php?id=' . $this->instance->pageid . '&amp;wdir=/backupdata">' . get_string('restore') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/restore.gif" class="icon" alt="" />';
     }
     /// Import data from other courses
     if ($course->id !== SITEID and has_capability('moodle/site:import', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/import.php?id=' . $this->instance->pageid . '">' . get_string('import') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/restore.gif" class="icon" alt="" />';
     }
     /// update this course
     //TODO fix the capability used here!!!
     if ($course->id !== SITEID and has_capability('moodle/site:restore', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/backup/get_incremental.php?id=' . $COURSE->id . '">' . get_string('update') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/restore.gif" class="icon" alt="" />';
     }
     /// export this course to an offline user.
     //TODO fix the capability used here!!!
     if ($course->id !== SITEID and has_capability('moodle/site:restore', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/backup/export_incremental.php?id=' . $COURSE->id . '">' . get_string('export', 'local') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/resto 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_user_roles_in_course函数代码示例发布时间:2022-05-15
下一篇:
PHP get_user_rank_prices函数代码示例发布时间: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