本文整理汇总了PHP中GroupManager::getAllGroupPerUserSubscription方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupManager::getAllGroupPerUserSubscription方法的具体用法?PHP GroupManager::getAllGroupPerUserSubscription怎么用?PHP GroupManager::getAllGroupPerUserSubscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupManager
的用法示例。
在下文中一共展示了GroupManager::getAllGroupPerUserSubscription方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_user_data
/**
* Get the users to display on the current page.
*/
function get_user_data($from, $number_of_items, $column, $direction)
{
global $origin;
global $course_info;
global $is_western_name_order;
global $session_id;
global $extraFields;
$a_users = array();
// limit
if (!isset($_GET['keyword']) || empty($_GET['keyword'])) {
$limit = 'LIMIT '.intval($from).','.intval($number_of_items);
}
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
switch ($column) {
case 2: //official code
$order_by = 'ORDER BY user.official_code '.$direction;
break;
case 3:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
} else {
$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
}
break;
case 4:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
} else {
$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
}
break;
case 5: //username
$order_by = 'ORDER BY user.username '.$direction;
break;
default:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname '.$direction.', user.firstname '.$direction;
} else {
$order_by = 'ORDER BY user.firstname '.$direction.', user.lastname '.$direction;
}
break;
}
$session_id = api_get_session_id();
$course_code = api_get_course_id();
$active = isset($_GET['active']) ? $_GET['active'] : null;
$a_course_users = CourseManager :: get_user_list_from_course_code(
$course_code,
$session_id,
$limit,
$order_by,
null,
null,
false,
false,
null,
array(),
array(),
$active
);
foreach ($a_course_users as $user_id => $o_course_user) {
if ((
isset($_GET['keyword']) &&
searchUserKeyword(
$o_course_user['firstname'],
$o_course_user['lastname'],
$o_course_user['username'],
$o_course_user['official_code'],
$_GET['keyword'])
) || !isset($_GET['keyword']) || empty($_GET['keyword'])
) {
$groupsNameList = GroupManager::getAllGroupPerUserSubscription($user_id);
$temp = array();
if (api_is_allowed_to_edit(null, true)) {
$temp[] = $user_id;
$image_path = UserManager::get_user_picture_path_by_id(
$user_id,
'web',
false,
true
);
$user_profile = UserManager::get_picture_user(
$user_id,
$image_path['file'],
22,
USER_IMAGE_SIZE_SMALL,
' width="22" height="22" '
);
if (!api_is_anonymous()) {
//.........这里部分代码省略.........
示例2: get_user_data
/**
* Get the users to display on the current page.
*/
function get_user_data($from, $number_of_items, $column, $direction)
{
global $is_western_name_order;
global $extraFields;
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$course_info = api_get_course_info();
$sessionId = api_get_session_id();
$course_code = $course_info['code'];
$a_users = array();
// limit
if (!isset($_GET['keyword']) || empty($_GET['keyword'])) {
$limit = 'LIMIT ' . intval($from) . ',' . intval($number_of_items);
}
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
switch ($column) {
case 2:
//official code
$order_by = 'ORDER BY user.official_code ' . $direction;
break;
case 3:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
} else {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
}
break;
case 4:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
case 5:
//username
$order_by = 'ORDER BY user.username ' . $direction;
break;
default:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
}
$active = isset($_GET['active']) ? $_GET['active'] : null;
if (empty($sessionId)) {
$status = $type;
} else {
if ($type == COURSEMANAGER) {
$status = 2;
} else {
$status = 0;
}
}
$a_course_users = CourseManager::get_user_list_from_course_code($course_code, $sessionId, $limit, $order_by, $status, null, false, false, null, array(), array(), $active);
foreach ($a_course_users as $user_id => $o_course_user) {
if (isset($_GET['keyword']) && searchUserKeyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword']) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
$groupsNameList = GroupManager::getAllGroupPerUserSubscription($user_id);
$groupsNameListParsed = [];
if (!empty($groupsNameList)) {
$groupsNameListParsed = array_column($groupsNameList, 'name');
}
$temp = array();
if (api_is_allowed_to_edit(null, true)) {
$userInfo = api_get_user_info($user_id);
$photo = '<img src="' . $userInfo['avatar_small'] . '" alt="' . $userInfo['complete_name'] . '" title="' . $userInfo['complete_name'] . '" />';
$temp[] = $user_id;
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
}
$temp[] = $o_course_user['username'];
// Groups.
$temp[] = implode(', ', $groupsNameListParsed);
// Status
$default_status = get_lang('Student');
if (isset($o_course_user['status_rel']) && $o_course_user['status_rel'] == 1 || isset($o_course_user['status_session']) && $o_course_user['status_session'] == 2) {
$default_status = get_lang('CourseManager');
} elseif (isset($o_course_user['is_tutor']) && $o_course_user['is_tutor'] == 1) {
$default_status = get_lang('Tutor');
}
$temp[] = $default_status;
// Active
$temp[] = $o_course_user['active'];
if (!empty($extraFields)) {
foreach ($extraFields as $extraField) {
$extraFieldValue = new ExtraFieldValue('user');
$data = $extraFieldValue->get_values_by_handler_and_field_id($user_id, $extraField['id']);
$temp[] = $data['value'];
//.........这里部分代码省略.........
示例3: is_lp_visible_for_student
/**
* Checks if the learning path is visible for student after the progress
* of its prerequisite is completed, considering the time availability and
* the LP visibility.
* @param int $lp_id
* @param int $student_id
* @param string Course code (optional)
* @param int $sessionId
* @return bool
*/
public static function is_lp_visible_for_student($lp_id, $student_id, $courseCode = null, $sessionId = null)
{
$lp_id = (int) $lp_id;
$courseInfo = api_get_course_info($courseCode);
$sessionId = intval($sessionId);
if (empty($sessionId)) {
$sessionId = api_get_session_id();
}
$tbl_learnpath = Database::get_course_table(TABLE_LP_MAIN);
// Get current prerequisite
$sql = "SELECT id, prerequisite, subscribe_users, publicated_on, expired_on\n FROM {$tbl_learnpath}\n WHERE c_id = " . $courseInfo['real_id'] . " AND id = {$lp_id}";
$itemInfo = api_get_item_property_info($courseInfo['real_id'], TOOL_LEARNPATH, $lp_id, $sessionId);
// If the item was deleted.
if (isset($itemInfo['visibility']) && $itemInfo['visibility'] == 2) {
return false;
}
$rs = Database::query($sql);
$now = time();
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs, 'ASSOC');
$prerequisite = $row['prerequisite'];
$is_visible = true;
if (!empty($prerequisite)) {
$progress = self::getProgress($prerequisite, $student_id, $courseInfo['real_id'], $sessionId);
$progress = intval($progress);
if ($progress < 100) {
$is_visible = false;
}
}
// Also check the time availability of the LP
if ($is_visible) {
// Adding visibility restrictions
if (!empty($row['publicated_on']) && $row['publicated_on'] != '0000-00-00 00:00:00') {
if ($now < api_strtotime($row['publicated_on'], 'UTC')) {
//api_not_allowed();
$is_visible = false;
}
}
// Blocking empty start times see BT#2800
global $_custom;
if (isset($_custom['lps_hidden_when_no_start_date']) && $_custom['lps_hidden_when_no_start_date']) {
if (empty($row['publicated_on']) || $row['publicated_on'] == '0000-00-00 00:00:00') {
//api_not_allowed();
$is_visible = false;
}
}
if (!empty($row['expired_on']) && $row['expired_on'] != '0000-00-00 00:00:00') {
if ($now > api_strtotime($row['expired_on'], 'UTC')) {
//api_not_allowed();
$is_visible = false;
}
}
}
// Check if the subscription users/group to a LP is ON
if (isset($row['subscribe_users']) && $row['subscribe_users'] == 1) {
// Try group
$is_visible = false;
// Checking only the user visibility
$userVisibility = api_get_item_visibility($courseInfo, 'learnpath', $row['id'], $sessionId, $student_id, 'LearnpathSubscription');
if ($userVisibility == 1) {
$is_visible = true;
} else {
$userGroups = GroupManager::getAllGroupPerUserSubscription($student_id);
if (!empty($userGroups)) {
foreach ($userGroups as $groupInfo) {
$groupId = $groupInfo['iid'];
$userVisibility = api_get_item_visibility($courseInfo, 'learnpath', $row['id'], $sessionId, null, 'LearnpathSubscription', $groupId);
if ($userVisibility == 1) {
$is_visible = true;
break;
}
}
}
}
}
return $is_visible;
}
return false;
}