本文整理汇总了PHP中get_suspended_userids函数的典型用法代码示例。如果您正苦于以下问题:PHP get_suspended_userids函数的具体用法?PHP get_suspended_userids怎么用?PHP get_suspended_userids使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_suspended_userids函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialise the iterator
*
* @return boolean success
*/
public function init()
{
global $CFG, $DB;
$this->close();
export_verify_grades($this->course->id);
$course_item = grade_item::fetch_course_item($this->course->id);
if ($course_item->needsupdate) {
// Can not calculate all final grades - sorry.
return false;
}
$coursecontext = context_course::instance($this->course->id);
list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');
list($gradebookroles_sql, $params) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
list($enrolledsql, $enrolledparams) = get_enrolled_sql($coursecontext, '', 0, $this->onlyactive);
$params = array_merge($params, $enrolledparams, $relatedctxparams);
if ($this->groupid) {
$groupsql = "INNER JOIN {groups_members} gm ON gm.userid = u.id";
$groupwheresql = "AND gm.groupid = :groupid";
// $params contents: gradebookroles
$params['groupid'] = $this->groupid;
} else {
$groupsql = "";
$groupwheresql = "";
}
if (empty($this->sortfield1)) {
// We must do some sorting even if not specified.
$ofields = ", u.id AS usrt";
$order = "usrt ASC";
} else {
$ofields = ", u.{$this->sortfield1} AS usrt1";
$order = "usrt1 {$this->sortorder1}";
if (!empty($this->sortfield2)) {
$ofields .= ", u.{$this->sortfield2} AS usrt2";
$order .= ", usrt2 {$this->sortorder2}";
}
if ($this->sortfield1 != 'id' and $this->sortfield2 != 'id') {
// User order MUST be the same in both queries,
// must include the only unique user->id if not already present.
$ofields .= ", u.id AS usrt";
$order .= ", usrt ASC";
}
}
$userfields = 'u.*';
$customfieldssql = '';
if ($this->allowusercustomfields && !empty($CFG->grade_export_customprofilefields)) {
$customfieldscount = 0;
$customfieldsarray = grade_helper::get_user_profile_fields($this->course->id, $this->allowusercustomfields);
foreach ($customfieldsarray as $field) {
if (!empty($field->customid)) {
$customfieldssql .= "\n LEFT JOIN (SELECT * FROM {user_info_data}\n WHERE fieldid = :cf{$customfieldscount}) cf{$customfieldscount}\n ON u.id = cf{$customfieldscount}.userid";
$userfields .= ", cf{$customfieldscount}.data AS customfield_{$field->shortname}";
$params['cf' . $customfieldscount] = $field->customid;
$customfieldscount++;
}
}
}
$users_sql = "SELECT {$userfields} {$ofields}\n FROM {user} u\n JOIN ({$enrolledsql}) je ON je.id = u.id\n {$groupsql} {$customfieldssql}\n JOIN (\n SELECT DISTINCT ra.userid\n FROM {role_assignments} ra\n WHERE ra.roleid {$gradebookroles_sql}\n AND ra.contextid {$relatedctxsql}\n ) rainner ON rainner.userid = u.id\n WHERE u.deleted = 0\n {$groupwheresql}\n ORDER BY {$order}";
$this->users_rs = $DB->get_recordset_sql($users_sql, $params);
if (!$this->onlyactive) {
$context = context_course::instance($this->course->id);
$this->suspendedusers = get_suspended_userids($context);
} else {
$this->suspendedusers = array();
}
if (!empty($this->grade_items)) {
$itemids = array_keys($this->grade_items);
list($itemidsql, $grades_params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED, 'items');
$params = array_merge($params, $grades_params);
$grades_sql = "SELECT g.* {$ofields}\n FROM {grade_grades} g\n JOIN {user} u ON g.userid = u.id\n JOIN ({$enrolledsql}) je ON je.id = u.id\n {$groupsql}\n JOIN (\n SELECT DISTINCT ra.userid\n FROM {role_assignments} ra\n WHERE ra.roleid {$gradebookroles_sql}\n AND ra.contextid {$relatedctxsql}\n ) rainner ON rainner.userid = u.id\n WHERE u.deleted = 0\n AND g.itemid {$itemidsql}\n {$groupwheresql}\n ORDER BY {$order}, g.itemid ASC";
$this->grades_rs = $DB->get_recordset_sql($grades_sql, $params);
} else {
$this->grades_rs = false;
}
return true;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:80,代码来源:lib.php
示例2: is_active_user
/**
* Return true is user is active user in course else false
*
* @param int $userid
* @return bool true is user is active in course.
*/
public function is_active_user($userid)
{
return !in_array($userid, get_suspended_userids($this->context, true));
}
开发者ID:mercysmart,项目名称:naikelas,代码行数:10,代码来源:locallib.php
示例3: is_active_user
/**
* Return true is user is active user in course else false
*
* @param int $userid
* @return bool true is user is active in course.
*/
public function is_active_user($userid)
{
if (is_null($this->susers) && !is_null($this->context)) {
$this->susers = get_suspended_userids($this->context);
}
return !in_array($userid, $this->susers);
}
开发者ID:covex-nn,项目名称:moodle,代码行数:13,代码来源:locallib.php
示例4: moodle_url
if ($mode === ROSTER_MODE_PRINT) {
$PAGE->set_pagelayout('print');
} else {
$PAGE->set_pagelayout('report');
}
$returnurl = new moodle_url('/course/view.php', array('id' => $id));
// Check permissions.
$coursecontext = context_course::instance($course->id);
require_capability('report/roster:view', $coursecontext);
// Get all the users.
$userlist = get_enrolled_users($coursecontext, '', $group, user_picture::fields('u', null, 0, 0, true));
// Get suspended users.
$suspended = get_suspended_userids($coursecontext);
$data = array();
foreach ($userlist as $user) {
if (!in_array($user->id, $suspended)) {
$item = $OUTPUT->user_picture($user, array('size' => 100, 'courseid' => $course->id));
$item .= html_writer::tag('span', fullname($user));
$data[] = $item;
}
}
// Finish setting up page.
$PAGE->set_title($course->shortname .': '. get_string('roster' , 'report_roster'));
$PAGE->set_heading($course->fullname);
$PAGE->requires->yui_module('moodle-report_roster-roster', 'M.report_roster.init');
$PAGE->requires->strings_for_js(array(
开发者ID:educacionbe,项目名称:campus,代码行数:31,代码来源:index.php
示例5: test_get_enrolled_sql_course
/**
* @dataProvider get_enrolled_sql_provider
*/
public function test_get_enrolled_sql_course($users, $counts)
{
global $DB;
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$context = context_course::instance($course->id);
$student = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
$createdusers = array();
foreach ($users as &$userdata) {
$user = $this->getDataGenerator()->create_user();
$userdata['id'] = $user->id;
$timestart = 0;
$timeend = 0;
$status = null;
if (isset($userdata['timestart'])) {
$timestart = time() + $userdata['timestart'];
}
if (isset($userdata['timeend'])) {
$timeend = time() + $userdata['timeend'];
}
if (isset($userdata['status'])) {
$status = $userdata['status'];
}
// Enrol the user in the course.
$this->getDataGenerator()->enrol_user($user->id, $course->id, $student->id, 'manual', $timestart, $timeend, $status);
}
// After all users have been enroled, check expectations.
$enrolled = get_enrolled_users($context, '', 0, 'u.id', null, 0, 0, false);
$active = get_enrolled_users($context, '', 0, 'u.id', null, 0, 0, true);
$suspended = get_suspended_userids($context);
foreach ($users as $userdata) {
if (isset($userdata['enrolled']) && $userdata['enrolled']) {
$this->assertTrue(isset($enrolled[$userdata['id']]));
} else {
$this->assertFalse(isset($enrolled[$userdata['id']]));
}
if (isset($userdata['active']) && $userdata['active']) {
$this->assertTrue(isset($active[$userdata['id']]));
} else {
$this->assertFalse(isset($active[$userdata['id']]));
}
if (isset($userdata['suspended']) && $userdata['suspended']) {
$this->assertTrue(isset($suspended[$userdata['id']]));
} else {
$this->assertFalse(isset($suspended[$userdata['id']]));
}
}
$this->assertCount($counts['enrolled'], $enrolled);
$this->assertCount($counts['active'], $active);
$this->assertCount($counts['suspended'], $suspended);
}
开发者ID:evltuma,项目名称:moodle,代码行数:54,代码来源:accesslib_test.php
示例6: get_roster
function get_roster($onlyrole = null)
{
//edited below, replaced old method
$coursecontext = context_course::instance($this->courseid);
$allroles = get_roles_used_in_context($coursecontext);
arsort($allroles);
if (!$this->visible) {
foreach ($allroles as $key => $role) {
if ($role->shortname != 'editingteacher') {
unset($allroles[$key]);
}
}
}
$roles = array_keys($allroles);
// can't used canned function as its likely to return a student role
// when the user has both a student and a teacher role
// so this bit will allow the lower roleid (higher value role) to overwrite the lower one
foreach ($roles as $role) {
$temp = get_role_users($role, $coursecontext, false, '', null, false);
if ($temp !== false && sizeof($temp) !== 0) {
if (isset($course->users)) {
$course->users = array_merge($course->users, $temp);
} else {
$course = new stdclass();
$course->users = $temp;
}
}
}
$members = array();
$suspended = get_suspended_userids($coursecontext);
foreach ($course->users as $cuser) {
if (array_key_exists($cuser->id, $suspended)) {
unset($course->users[$cuser->id]);
} else {
if ($onlyrole === null || $onlyrole == $allroles[$cuser->roleid]->shortname) {
$members[strtolower($cuser->email)] = $allroles[$cuser->roleid]->shortname;
}
}
}
return $members;
}
开发者ID:rlorenzo,项目名称:moodle-repository_morsle,代码行数:41,代码来源:lib.php
示例7: print_error
print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($course->id);
require_capability('gradereport/outcomes:view', $context);
// First make sure we have proper final grades.
grade_regrade_final_grades($courseid);
// Grab all outcomes used in course.
$report_info = array();
$outcomes = grade_outcome::fetch_all_available($courseid);
// Will exclude grades of suspended users if required.
$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
$showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
$showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
if ($showonlyactiveenrol) {
$suspendedusers = get_suspended_userids($context);
}
// Get grade_items that use each outcome.
foreach ($outcomes as $outcomeid => $outcome) {
$report_info[$outcomeid]['items'] = $DB->get_records_select('grade_items', "outcomeid = ? AND courseid = ?", array($outcomeid, $courseid));
$report_info[$outcomeid]['outcome'] = $outcome;
// Get average grades for each item.
if (is_array($report_info[$outcomeid]['items'])) {
foreach ($report_info[$outcomeid]['items'] as $itemid => $item) {
$params = array();
$hidesuspendedsql = '';
if ($showonlyactiveenrol && !empty($suspendedusers)) {
list($notinusers, $params) = $DB->get_in_or_equal($suspendedusers, SQL_PARAMS_QM, null, false);
$hidesuspendedsql = ' AND userid ' . $notinusers;
}
$params = array_merge(array($itemid), $params);
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:index.php
示例8: get_roster
function get_roster($onlyrole = null)
{
//edited below, replaced old method
$coursecontext = context_course::instance($this->courseid);
$allroles = get_roles_used_in_context($coursecontext);
arsort($allroles);
if (!$this->visible) {
foreach ($allroles as $key => $role) {
if ($role->shortname != 'editingteacher') {
unset($allroles[$key]);
}
}
}
$roles = array_keys($allroles);
// can't used canned function as its likely to return a student role
// when the user has both a student and a teacher role
// so this bit will allow the lower roleid (higher value role) to overwrite the lower one
foreach ($roles as $role) {
$temp = get_role_users($role, $coursecontext, false, '', null, false);
if ($temp !== false && sizeof($temp) !== 0) {
if (isset($course->users)) {
$course->users = array_merge($course->users, $temp);
} else {
$course = new stdclass();
$course->users = $temp;
}
}
}
$members = array();
$suspended = get_suspended_userids($coursecontext);
foreach ($course->users as $cuser) {
if (array_key_exists($cuser->id, $suspended)) {
/* Explanation of changes made: */
//edited use of unset below: previous implementation wasn't working
//because $cuser->id was a number larger than the size of
//$course->users.
//$course->users is an array of stdClass objects, which have their own IDs,
//but those IDs could not be directly accessed in $course->users without callling on the $cuser object.
//So the compiler was seeing $cuser->id as an index into the array $course->users
//$cuser->id is normally too large to be used to index into $course->users
//unset was not working because the index $cuser->id was out of range (larger than the size of $course->users)
//
///*unset($course->users[$cuser->id]);*/
//solution has been reimplemented below, and it should now work (hopefully)
$deleteUser = array_search($cuser, $course->users);
unset($course->users[$deleteUser]);
} else {
if ($onlyrole === null || $onlyrole == $allroles[$cuser->roleid]->shortname) {
$members[strtolower($cuser->email)] = $allroles[$cuser->roleid]->shortname;
}
}
}
return $members;
}
开发者ID:bobpuffer,项目名称:moodle-repository_morsle,代码行数:54,代码来源:lib.php
注:本文中的get_suspended_userids函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论