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

PHP get_role_users函数代码示例

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

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



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

示例1: init

 /**
  * Initialise this screen
  *
  * @param bool $selfitemisempty Has an item been selected (will be false)
  */
 public function init($selfitemisempty = false)
 {
     global $DB;
     $roleids = explode(',', get_config('moodle', 'gradebookroles'));
     $this->items = get_role_users($roleids, $this->context, false, '', 'u.id, u.lastname, u.firstname', null, $this->groupid, $this->perpage * $this->page, $this->perpage);
     $this->item = $DB->get_record('course', array('id' => $this->courseid));
 }
开发者ID:HuiChangZhai,项目名称:moodle,代码行数:12,代码来源:select.php


示例2: blended_get_users_by_type

/**
 * Find the list of users and get a list with the ids of students and a list of non-students
 * @param type $context_course
 * @return array(array($studentIds), array($non_studentIds), array($activeids), array($user_records))
 */
function blended_get_users_by_type($context_course)
{
    // Get users with gradable roles
    global $CFG;
    $gradable_roles = $CFG->gradebookroles;
    $roles = explode(',', $gradable_roles);
    $students = array();
    foreach ($roles as $roleid) {
        $users_in_role = get_role_users($roleid, $context_course);
        $ids = array_keys($users_in_role);
        $students = array_merge($students, $ids);
        $students = array_unique($students);
    }
    // get enrolled users
    $user_records = get_enrolled_users($context_course, '', 0, '*');
    $users = array_keys($user_records);
    $non_students = array_diff($users, $students);
    // select active userids
    $activeids = array();
    global $DB;
    list($select, $params) = $DB->get_in_or_equal($students);
    $select = "userid {$select}";
    $select .= " AND courseid = ?";
    $params[] = (int) $context_course->instanceid;
    $last_accesses = $DB->get_records_select('user_lastaccess', $select, $params);
    foreach ($last_accesses as $record) {
        $activeids[] = $record->userid;
    }
    return array($students, $non_students, $activeids, $user_records);
}
开发者ID:juacas,项目名称:moodle-mod_blended,代码行数:35,代码来源:blended_locallib.php


示例3: 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


示例4: execute

 function execute($data, $user, $courseid)
 {
     $context = get_context_instance(CONTEXT_COURSE, $courseid);
     if ($users = get_role_users($data->roles, $context, false, 'u.id')) {
         return array_keys($users);
     }
     return array();
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:8,代码来源:plugin.class.php


示例5: execute

 function execute($data, $user, $courseid)
 {
     global $DB;
     $context = cr_get_context(CONTEXT_COURSE, $courseid);
     if ($users = get_role_users($data->roles, $context, false, 'u.id', 'u.id')) {
         return array_keys($users);
     }
     return array();
 }
开发者ID:adonm,项目名称:learning,代码行数:9,代码来源:plugin.class.php


示例6: getStudentsByCourse

function getStudentsByCourse($courseId)
{

$courses = get_courses();
            $context = context_course::instance($courseId);//course id
   
            $students = get_role_users(5, $context); //student context
                  return   $students ;

}
开发者ID:kmahesh541,项目名称:mitclone,代码行数:10,代码来源:teacher_reports.php


示例7: _wwassignment_get_course_students

/**
* @desc Finds all of the users in the course
* @param $courseid   -- the course id
* @return record containing user information ( username, userid)
*/
function _wwassignment_get_course_students($courseid)
{
    debugLog("Begin get_course_students({$courseid} )");
    debugLog("courseID is " . print_r($courseid, true));
    $context = get_context_instance(CONTEXT_COURSE, $courseid);
    debugLog("context is " . print_r($context, true));
    $users = array();
    $roles_used_in_context = get_roles_used_in_context($context);
    //debugLog("roles used ". print_r($roles_used_in_context, true));
    foreach ($roles_used_in_context as $role) {
        $roleid = $role->id;
        debugLog("roleid should be 5 for a student {$roleid}");
        //debugLog(get_role_users($roleid, $context, true) );
        if ($new_users = get_role_users($roleid, $context, true)) {
            $users = array_merge($users, $new_users);
            //FIXME a user could be liseted twice
        }
        debugLog("display users " . print_r($users, true));
    }
    debugLog("display users in course--on");
    debugLog("users again" . print_r($users, true));
    debugLog("End get_course_students({$courseid} )");
    return $users;
}
开发者ID:bjornbe,项目名称:wwassignment,代码行数:29,代码来源:locallib.php


示例8: getKnownUsers

 /**
  * Retrieve all known users for the current Moodle user
  * @return array Array of objects featuring name and Moodle id
  */
 function getKnownUsers()
 {
     global $course;
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     $students = get_role_users(5, $context);
     $tmp = (array) null;
     foreach ($students as $student) {
         $knownUser = (object) null;
         $knownUser->id = $student->id;
         if ($student->maildisplay) {
             $knownUser->email = $student->email;
         }
         $fullname = $student->firstname . ' ' . $student->lastname;
         if (strlen(trim($fullname)) == 0) {
             $fullname = $student->username;
         }
         $knownUser->name = $fullname;
         if ($account_link = get_record("studynotes_account_links", "system", "moodle", "external_id", $student->id)) {
             $knownUser->mb_id = $account_link->internal_id;
         }
         $tmp[] = $knownUser;
     }
     return $tmp;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:28,代码来源:moodle_auth.php


示例9: get_course_absenties

			function get_course_absenties($cid){

				$context = context_course::instance($cid);
				$enrolledStudents = get_role_users(5 , $context);//getting all the students from a course level
				$loggedinusers=get_all_loggedin_users('All');


				$logstuarr=array();$cnt=0;
				foreach($loggedinusers as $logstudent){

					$logstuarr[$cnt++]=array('stid'=>$logstudent->userid);

				}
				$lgss=array_column($logstuarr, 'stid');
				//print_r($lgss);

				$absented_Students=array();$stcnt=0;
				foreach($enrolledStudents as $student){
					if(in_array($student->id, $lgss)){}
					else{
						$absented_Students[$stcnt++]=array('stid'=>$student->id);
					}
				}
				$absented_Students=array_column($absented_Students,'stid');
				return $absented_Students;

			}
开发者ID:kmahesh541,项目名称:mitclone,代码行数:27,代码来源:testcenterutil.php


示例10: email_welcome_message

 /**
  * Send welcome email to specified user.
  *
  * @param stdClass $instance
  * @param stdClass $user user record
  * @return void
  */
 protected function email_welcome_message($instance, $user)
 {
     global $CFG, $DB;
     $course = $DB->get_record('course', array('id' => $instance->courseid), '*', MUST_EXIST);
     $context = context_course::instance($course->id);
     $a = new stdClass();
     $a->coursename = format_string($course->fullname, true, array('context' => $context));
     $a->profileurl = "{$CFG->wwwroot}/user/view.php?id={$user->id}&course={$course->id}";
     if (trim($instance->customtext1) !== '') {
         $message = $instance->customtext1;
         $key = array('{$a->coursename}', '{$a->profileurl}', '{$a->fullname}', '{$a->email}');
         $value = array($a->coursename, $a->profileurl, fullname($user), $user->email);
         $message = str_replace($key, $value, $message);
         if (strpos($message, '<') === false) {
             // Plain text only.
             $messagetext = $message;
             $messagehtml = text_to_html($messagetext, null, false, true);
         } else {
             // This is most probably the tag/newline soup known as FORMAT_MOODLE.
             $messagehtml = format_text($message, FORMAT_MOODLE, array('context' => $context, 'para' => false, 'newlines' => true, 'filter' => true));
             $messagetext = html_to_text($messagehtml);
         }
     } else {
         $messagetext = get_string('welcometocoursetext', 'enrol_self', $a);
         $messagehtml = text_to_html($messagetext, null, false, true);
     }
     $subject = get_string('welcometocourse', 'enrol_self', format_string($course->fullname, true, array('context' => $context)));
     $rusers = array();
     if (!empty($CFG->coursecontact)) {
         $croles = explode(',', $CFG->coursecontact);
         list($sort, $sortparams) = users_order_by_sql('u');
         // We only use the first user.
         $i = 0;
         do {
             $rusers = get_role_users($croles[$i], $context, true, '', 'r.sortorder ASC, ' . $sort, null, '', '', '', '', $sortparams);
             $i++;
         } while (empty($rusers) && !empty($croles[$i]));
     }
     if ($rusers) {
         $contact = reset($rusers);
     } else {
         $contact = core_user::get_support_user();
     }
     // Directly emailing welcome message rather than using messaging.
     email_to_user($user, $contact, $subject, $messagetext, $messagehtml);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:53,代码来源:lib.php


示例11: definition

 function definition()
 {
     global $USER, $CFG, $DB;
     $courseconfig = get_config('moodlecourse');
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $category = $this->_customdata['category'];
     $systemcontext = get_context_instance(CONTEXT_SYSTEM);
     $categorycontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
     $disable_meta = false;
     // basic meta course state protection; server-side security checks not needed
     if (!empty($course)) {
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
         $context = $coursecontext;
         if (course_in_meta($course)) {
             $disable_meta = get_string('metaalreadyinmeta');
         } else {
             if ($course->metacourse) {
                 if ($DB->count_records('course_meta', array('parent_course' => $course->id)) > 0) {
                     $disable_meta = get_string('metaalreadyhascourses');
                 }
             } else {
                 // if users already enrolled directly into coures, do not allow switching to meta,
                 // users with metacourse manage permission are exception
                 // please note that we do not need exact results - anything unexpected here prevents metacourse
                 $managers = get_users_by_capability($coursecontext, 'moodle/course:managemetacourse', 'u.id');
                 $enrolroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $coursecontext);
                 if ($users = get_role_users(array_keys($enrolroles), $coursecontext, false, 'u.id', 'u.id ASC')) {
                     foreach ($users as $user) {
                         if (!isset($managers[$user->id])) {
                             $disable_meta = get_string('metaalreadyhasenrolments');
                             break;
                         }
                     }
                 }
                 unset($managers);
                 unset($users);
                 unset($enrolroles);
             }
         }
     } else {
         $coursecontext = null;
         $context = $categorycontext;
     }
     /// form definition with new course defaults
     //--------------------------------------------------------------------------------
     $mform->addElement('header', 'general', get_string('general', 'form'));
     // Must have create course capability in both categories in order to move course
     if (has_capability('moodle/course:create', $categorycontext)) {
         $displaylist = array();
         $parentlist = array();
         make_categories_list($displaylist, $parentlist, 'moodle/course:create');
         $mform->addElement('select', 'category', get_string('category'), $displaylist);
     } else {
         $mform->addElement('hidden', 'category', null);
     }
     $mform->setHelpButton('category', array('coursecategory', get_string('category')));
     $mform->setDefault('category', $category->id);
     $mform->setType('category', PARAM_INT);
     $fullname = get_string('defaultcoursefullname');
     $shortname = get_string('defaultcourseshortname');
     while ($DB->record_exists('course', array('fullname' => $fullname)) or $DB->record_exists('course', array('fullname' => $fullname))) {
         $fullname++;
         $shortname++;
     }
     $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"');
     $mform->setHelpButton('fullname', array('coursefullname', get_string('fullnamecourse')), true);
     $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client');
     $mform->setType('fullname', PARAM_MULTILANG);
     if ($course and !has_capability('moodle/course:changefullname', $coursecontext)) {
         $mform->hardFreeze('fullname');
         $mform->setConstant('fullname', $course->fullname);
     }
     $mform->setDefault('fullname', $fullname);
     $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"');
     $mform->setHelpButton('shortname', array('courseshortname', get_string('shortnamecourse')), true);
     $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
     $mform->setType('shortname', PARAM_MULTILANG);
     if ($course and !has_capability('moodle/course:changeshortname', $coursecontext)) {
         $mform->hardFreeze('shortname');
         $mform->setConstant('shortname', $course->shortname);
     }
     $mform->setDefault('shortname', $shortname);
     $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100"  size="10"');
     $mform->setHelpButton('idnumber', array('courseidnumber', get_string('idnumbercourse')), true);
     $mform->setType('idnumber', PARAM_RAW);
     if ($course and !has_capability('moodle/course:changeidnumber', $coursecontext)) {
         $mform->hardFreeze('idnumber');
         $mform->setConstants('idnumber', $course->idnumber);
     }
     $mform->addElement('htmleditor', 'summary', get_string('summary'), array('rows' => '10', 'cols' => '65'));
     $mform->setHelpButton('summary', array('text2', get_string('helptext')), true);
     $mform->setType('summary', PARAM_RAW);
     $courseformats = get_list_of_plugins('course/format');
     $formcourseformats = array();
     foreach ($courseformats as $courseformat) {
         $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}", "format_{$courseformat}");
         if ($formcourseformats["{$courseformat}"] == "[[format{$courseformat}]]") {
             $formcourseformats["{$courseformat}"] = get_string("format{$courseformat}");
         }
//.........这里部分代码省略.........
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:edit_form.php


示例12: bigbluebuttonbn_get_users

function bigbluebuttonbn_get_users($context)
{
    $roles = bigbluebuttonbn_get_db_moodle_roles();
    $users_array = array();
    foreach ($roles as $role) {
        $users = get_role_users($role->id, $context);
        foreach ($users as $user) {
            array_push($users_array, array("id" => $user->id, "name" => $user->firstname . ' ' . $user->lastname));
        }
    }
    return $users_array;
}
开发者ID:Brotality,项目名称:moodle-mod_streamline,代码行数:12,代码来源:BBBlocallib.php


示例13: foreach

}
foreach ($completion->get_criteria() as $criterion) {
    if (!in_array($criterion->criteriatype, array(COMPLETION_CRITERIA_TYPE_COURSE, COMPLETION_CRITERIA_TYPE_ACTIVITY))) {
        $criteria[] = $criterion;
    }
}
// Can logged in user mark users as complete?
// (if the logged in user has a role defined in the role criteria)
$allow_marking = false;
$allow_marking_criteria = null;
if (!$csv) {
    // Get role criteria
    $rcriteria = $completion->get_criteria(COMPLETION_CRITERIA_TYPE_ROLE);
    if (!empty($rcriteria)) {
        foreach ($rcriteria as $rcriterion) {
            $users = get_role_users($rcriterion->role, $context, true);
            // If logged in user has this role, allow marking complete
            if ($users && in_array($USER->id, array_keys($users))) {
                $allow_marking = true;
                $allow_marking_criteria = $rcriterion->id;
                break;
            }
        }
    }
}
/**
 * Setup page header
 */
if ($csv) {
    header('Content-Disposition: attachment; filename=progress.' . preg_replace('/[^a-z0-9-]/', '_', strtolower($course->shortname)) . '.csv');
    // Unicode byte-order mark for Excel
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:index.php


示例14: array

<?php

$role = $DB->get_record('role', array('shortname' => 'student'));
$table = 'jcode_files';
$context = context_course::instance($course->id);
$students = get_role_users($role->id, $context);
$save = optional_param('savequickgrades', '', PARAM_TEXT);
require_once $CFG->libdir . '/gradelib.php';
if (!empty($save)) {
    foreach ($_POST as $name => $value) {
        if (strstr($name, 'quickgrade_') && !strstr($name, 'comments_')) {
            $name = str_replace('quickgrade_', '', $name);
            $nota = new stdClass();
            $nota->grade = $value;
            $grading_info = grade_get_grades($course->id, 'mod', 'jcode', $jcode->id, 0);
            grade_update_outcomes('mod/jcode', $course->id, 'mod', 'jcode', $jcode->id, $name, array('0' => $value));
            if (is_numeric($nota->grade)) {
                $feedback = $_POST['quickgrade_comments_' . $name];
                $nota->feedback = $feedback;
                if ($n = $DB->get_record($table, array('jcode_id' => $jcode->id, 'user_id' => $name))) {
                    $nota->id = $n->id;
                    $DB->update_record($table, $nota);
                } else {
                    $DB->insert($table, $nota);
                }
            }
        }
    }
}
$t = new html_table();
jcode_add_table_row_cells($t, array('Aluno', 'Nota', 'Feedback', 'Data de Entrega', 'Arquivo', 'Resultado'));
开发者ID:jrlamb,项目名称:alexBado,代码行数:31,代码来源:lista.php


示例15: tao_message_get_recipients_by_target

function tao_message_get_recipients_by_target($target, $course, $user = null)
{
    $user = tao_user_parameter($user);
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    if (!empty($target->recipientrole) || !empty($target->recipientroles)) {
        if (!empty($target->recipientcontext)) {
            $context = get_context_instance_by_id($target->recipientcontext);
        }
        if (!empty($target->recipientrole)) {
            $roleid = get_field('role', 'id', 'shortname', $target->recipientrole);
        } else {
            $rolesql = " IN ( '" . implode("','", $target->recipientroles) . "' ) ";
            $roleid = array_keys(get_records_select('role', 'shortname ' . $rolesql, '', 'id, id'));
        }
        return get_role_users($roleid, $context);
    } else {
        if (is_array($target->recipientfunction)) {
            // recipientfunction
            $function = $target->recipientfunction['users'];
            $users = $function($user, $course);
            if (empty($target->recipienttransform)) {
                return $users;
            }
            switch ($target->recipienttransform) {
                case 'nested':
                    // these are the grandchild ones
                    $newu = array();
                    foreach ($users as $key => $children) {
                        $newu = array_merge($newu, $children);
                    }
                    return $newu;
            }
        }
    }
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:35,代码来源:messagelib.php


示例16: moodle_url

        } else {
            $pageurl = new moodle_url('/badges/award.php', array('id' => $badgeid));
            $issuerrole = new stdClass();
            $issuerrole->roleid = $role;
            $roleselect = get_string('selectaward', 'badges') . $OUTPUT->single_select(new moodle_url($pageurl), 'role', $select, $role, null);
        }
    } else {
        echo $OUTPUT->header();
        $return = html_writer::link(new moodle_url('recipients.php', array('id' => $badge->id)), $strrecipients);
        echo $OUTPUT->notification(get_string('notacceptedrole', 'badges', $return));
        echo $OUTPUT->footer();
        die;
    }
} else {
    // User has to be an admin or the one with the required role.
    $users = get_role_users($acceptedroles[0], $context, true, 'u.id', 'u.id ASC');
    $usersids = array_keys($users);
    if (!$isadmin && !in_array($USER->id, $usersids)) {
        echo $OUTPUT->header();
        $return = html_writer::link(new moodle_url('recipients.php', array('id' => $badge->id)), $strrecipients);
        echo $OUTPUT->notification(get_string('notacceptedrole', 'badges', $return));
        echo $OUTPUT->footer();
        die;
    } else {
        $issuerrole = new stdClass();
        $issuerrole->roleid = $acceptedroles[0];
    }
}
$options = array('badgeid' => $badge->id, 'context' => $context, 'issuerid' => $USER->id, 'issuerrole' => $issuerrole->roleid);
$existingselector = new badge_existing_users_selector('existingrecipients', $options);
$recipientselector = new badge_potential_users_selector('potentialrecipients', $options);
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:31,代码来源:award.php


示例17: init

 /**
  * Init this page
  *
  * @param bool $selfitemisempty True if we have not selected a user.
  */
 public function init($selfitemisempty = false)
 {
     $roleids = explode(',', get_config('moodle', 'gradebookroles'));
     $this->items = array();
     foreach ($roleids as $roleid) {
         // Keeping the first user appearance.
         $this->items = $this->items + get_role_users($roleid, $this->context, false, '', 'u.lastname, u.firstname', null, $this->groupid);
     }
     $this->totalitemcount = count_role_users($roleids, $this->context);
     if ($selfitemisempty) {
         return;
     }
     $params = array('id' => $this->itemid, 'courseid' => $this->courseid);
     $this->item = grade_item::fetch($params);
     if (!self::filter($this->item)) {
         $this->items = array();
         $this->set_init_error(get_string('gradeitemcannotbeoverridden', 'gradereport_singleview'));
     }
     $this->requiresextra = !$this->item->is_manual_item();
     $this->setup_structure();
     $this->set_definition($this->original_definition());
     $this->set_headers($this->original_headers());
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:28,代码来源:grade.php


示例18: internal_get_tracked_users

 /**
  * Gets list of users in a course whose progress is tracked for display on the
  * progress report.
  *
  * @global object
  * @global object
  * @uses CONTEXT_COURSE
  * @param bool $sortfirstname True to sort with firstname
  * @param int $groupid Optionally restrict to groupid
  * @return array Array of user objects containing id, firstname, lastname (empty if none)
  */
 function internal_get_tracked_users($sortfirstname, $groupid = 0)
 {
     global $CFG, $DB;
     if (!empty($CFG->progresstrackedroles)) {
         $roles = explode(', ', $CFG->progresstrackedroles);
     } else {
         // This causes it to default to everyone (if there is no student role)
         $roles = array();
     }
     $users = get_role_users($roles, get_context_instance(CONTEXT_COURSE, $this->course->id), true, 'u.id, u.firstname, u.lastname, u.idnumber', $sortfirstname ? 'u.firstname ASC' : 'u.lastname ASC', true, $groupid);
     $users = $users ? $users : array();
     // In case it returns false
     return $users;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:25,代码来源:completionlib.php


示例19: email_welcome_message

 /**
  * Send welcome email to specified user
  *
  * @param object $instance
  * @param object $user user record
  * @return void
  */
 protected function email_welcome_message($instance, $user)
 {
     global $CFG, $DB;
     $course = $DB->get_record('course', array('id' => $instance->courseid), '*', MUST_EXIST);
     $a = new stdClass();
     $a->coursename = format_string($course->fullname);
     $a->profileurl = "{$CFG->wwwroot}/user/view.php?id={$user->id}&course={$course->id}";
     if (trim($instance->customtext1) !== '') {
         $message = $instance->customtext1;
         $message = str_replace('{$a->coursename}', $a->coursename, $message);
         $message = str_replace('{$a->profileurl}', $a->profileurl, $message);
     } else {
         $message = get_string('welcometocoursetext', 'enrol_self', $a);
     }
     $subject = get_string('welcometocourse', 'enrol_self', format_string($course->fullname));
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     $rusers = array();
     if (!empty($CFG->coursecontact)) {
         $croles = explode(',', $CFG->coursecontact);
         $rusers = get_role_users($croles, $context, true, '', 'r.sortorder ASC, u.lastname ASC');
     }
     if ($rusers) {
         $contact = reset($rusers);
     } else {
         $contact = get_admin();
     }
     //directly emailing welcome message rather than using messaging
     email_to_user($user, $contact, $subject, $message);
 }
开发者ID:nfreear,项目名称:moodle,代码行数:36,代码来源:lib.php


示例20: test_get_role_users

 /**
  * Test getting of role users.
  * @return void
  */
 public function test_get_role_users()
 {
     global $DB;
     $this->resetAfterTest();
     $systemcontext = context_system::instance();
     $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher'), '*', MUST_EXIST);
     $course = $this->getDataGenerator()->create_course();
     $coursecontext = context_course::instance($course->id);
     $otherid = create_role('Other role', 'other', 'Some other role', '');
     $teacherrename = (object) array('roleid' => $teacherrole->id, 'name' => 'Učitel', 'contextid' => $coursecontext->id);
     $DB->insert_record('role_names', $teacherrename);
     $otherrename = (object) array('roleid' => $otherid, 'name' => 'Ostatní', 'contextid' => $coursecontext->id);
     $DB->insert_record('role_names', $otherrename);
     $user1 = $this->getDataGenerator()->create_user();
     role_assign($teacherrole->id, $user1->id, $coursecontext->id);
     $user2 = $this->getDataGenerator()->create_user();
     role_assign($teacherrole->id, $user2->id, $systemcontext->id);
     $users = get_role_users($teacherrole->id, $coursecontext);
     $this->assertCount(1, $users);
     $user = reset($users);
     $userid = key($users);
     $this->assertEquals($userid, $user->id);
     $this->assertEquals($teacherrole->id, $user->roleid);
     $this->assertEquals($teacherrole->name, $user->rolename);
     $this->assertEquals($teacherrole->shortname, $user->roleshortname);
     $this->assertEquals($teacherrename->name, $user->rolecoursealias);
     $users = get_role_users($teacherrole->id, $coursecontext, true);
     $this->assertCount(2, $users);
     $users = get_role_users($teacherrole->id, $coursecontext, false, 'u.id, u.email, u.idnumber', 'u.idnumber', null, 1, 0, 10, 'u.deleted = 0');
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:34,代码来源:accesslib_test.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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