本文整理汇总了PHP中UserGroup::get_users_by_usergroup方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::get_users_by_usergroup方法的具体用法?PHP UserGroup::get_users_by_usergroup怎么用?PHP UserGroup::get_users_by_usergroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGroup
的用法示例。
在下文中一共展示了UserGroup::get_users_by_usergroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_class_groups
/**
* Create a group for every class subscribed to the current course
* @param int $category_id The category in which the groups should be created
* @return array
*/
public static function create_class_groups($category_id)
{
$options['where'] = array(" usergroup.course_id = ? " => api_get_real_course_id());
$obj = new UserGroup();
$classes = $obj->get_usergroup_in_course($options);
$group_ids = array();
foreach ($classes as $class) {
$users_ids = $obj->get_users_by_usergroup($class['id']);
$group_id = self::create_group($class['name'], $category_id, 0, count($users_ids));
self::subscribe_users($users_ids, $group_id);
$group_ids[] = $group_id;
}
return $group_ids;
}
示例2: array
$filters = array(array('type' => 'text', 'name' => 'username', 'label' => get_lang('Username')), array('type' => 'text', 'name' => 'firstname', 'label' => get_lang('FirstName')), array('type' => 'text', 'name' => 'lastname', 'label' => get_lang('LastName')), array('type' => 'text', 'name' => 'official_code', 'label' => get_lang('OfficialCode')), array('type' => 'text', 'name' => 'email', 'label' => get_lang('Email')));
$searchForm = new FormValidator('search', 'get', api_get_self() . '?id=' . $id);
$searchForm->addHeader(get_lang('AdvancedSearch'));
$renderer =& $searchForm->defaultRenderer();
$searchForm->addElement('hidden', 'id', $id);
foreach ($filters as $param) {
$searchForm->addElement($param['type'], $param['name'], $param['label']);
}
$searchForm->addButtonSearch();
$filterData = array();
if ($searchForm->validate()) {
$filterData = $searchForm->getSubmitValues();
}
$data = $usergroup->get($id);
$list_in = $usergroup->getUsersByUsergroupAndRelation($id, $relation);
$list_all = $usergroup->get_users_by_usergroup();
$order = array('lastname');
if (api_is_western_name_order()) {
$order = array('firstname');
}
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$order = array('official_code', 'lastname');
}
$conditions = array();
if (!empty($first_letter_user)) {
$conditions['lastname'] = $first_letter_user;
}
if (!empty($filters) && !empty($filterData)) {
foreach ($filters as $filter) {
if (isset($filter['name']) && isset($filterData[$filter['name']])) {
示例3: array
$result = Database::select('*', "{$obj->table} ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
$new_result = array();
foreach ($result as $item) {
$new_result[] = $item;
}
$result = $new_result;
break;
case 'get_usergroups':
$columns = array('name', 'users', 'courses', 'sessions', 'group_type', 'actions');
$result = Database::select('*', $obj->table, array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}"));
$new_result = array();
if (!empty($result)) {
foreach ($result as $group) {
$group['sessions'] = count($obj->get_sessions_by_usergroup($group['id']));
$group['courses'] = count($obj->get_courses_by_usergroup($group['id']));
$group['users'] = count($obj->get_users_by_usergroup($group['id']));
switch ($group['group_type']) {
case '0':
$group['group_type'] = Display::label(get_lang('Class'), 'info');
break;
case '1':
$group['group_type'] = Display::label(get_lang('Social'), 'success');
break;
}
$new_result[] = $group;
}
$result = $new_result;
}
$columns = array('name', 'users', 'courses', 'sessions', 'group_type');
if (!in_array($sidx, $columns)) {
$sidx = 'name';
示例4: array
$create_subgroups_form->display();
}
}
/*
* Show form to generate groups from classes subscribed to the course
*/
$options['where'] = array(" usergroup.course_id = ? " => api_get_real_course_id());
$obj = new UserGroup();
$classes = $obj->get_usergroup_in_course($options);
if (count($classes) > 0) {
echo '<b>' . get_lang('GroupsFromClasses') . '</b>';
echo '<blockquote>';
echo '<p>' . get_lang('GroupsFromClassesInfo') . '</p>';
echo '<ul>';
foreach ($classes as $index => $class) {
$number_of_users = count($obj->get_users_by_usergroup($class['id']));
echo '<li>';
echo $class['name'];
echo ' (' . $number_of_users . ' ' . get_lang('Users') . ')';
echo '</li>';
}
echo '</ul>';
$create_class_groups_form = new FormValidator('create_class_groups_form');
$create_class_groups_form->addElement('hidden', 'action');
if (api_get_setting('allow_group_categories') == 'true') {
$group_categories = GroupManager::get_categories();
$cat_options = array();
foreach ($group_categories as $index => $category) {
// Don't allow new groups in the virtual course category!
if ($category['id'] != GroupManager::VIRTUAL_COURSE_CATEGORY) {
$cat_options[$category['id']] = $category['title'];
示例5: array
}
}
if ($use_extra_fields) {
$final_result = array();
if (count($extra_field_result) > 1) {
for ($i = 0; $i < count($extra_field_result) - 1; $i++) {
if (is_array($extra_field_result[$i + 1])) {
$final_result = array_intersect($extra_field_result[$i], $extra_field_result[$i + 1]);
}
}
} else {
$final_result = $extra_field_result[0];
}
}
$data = $usergroup->get($id);
$list_in = $usergroup->get_users_by_usergroup($id);
$list_all = $usergroup->get_users_by_usergroup();
$order = array('lastname');
if (api_is_western_name_order()) {
$order = array('firstname');
}
$elements_not_in = $elements_in = array();
$complete_user_list = UserManager::get_user_list(array(), $order);
if (!empty($complete_user_list)) {
foreach ($complete_user_list as $item) {
if ($use_extra_fields) {
if (!in_array($item['user_id'], $final_result)) {
continue;
}
}
if ($item['status'] == 6) {
示例6: indexAction
//.........这里部分代码省略.........
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
$result = Database::select('p.id,p.name, p.description, c.name as career, p.status', "{$obj->table} p LEFT JOIN " . Database::get_main_table(TABLE_CAREER) . " c ON c.id = p.career_id ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
$new_result = array();
foreach ($result as $item) {
if (!$item['status']) {
$item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>';
}
$new_result[] = $item;
}
$result = $new_result;
break;
case 'get_grade_models':
$columns = array('name', 'description', 'actions');
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
$result = Database::select('*', "{$obj->table} ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
$new_result = array();
foreach ($result as $item) {
$new_result[] = $item;
}
$result = $new_result;
break;
case 'get_usergroups':
$columns = array('name', 'users', 'courses', 'sessions', 'group_type', 'actions');
$result = Database::select('*', $obj->table, array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}"));
$new_result = array();
if (!empty($result)) {
foreach ($result as $group) {
$group['sessions'] = count($obj->get_sessions_by_usergroup($group['id']));
$group['courses'] = count($obj->get_courses_by_usergroup($group['id']));
$group['users'] = count($obj->get_users_by_usergroup($group['id']));
switch ($group['group_type']) {
case '0':
$group['group_type'] = Display::label(get_lang('Class'), 'info');
break;
case '1':
$group['group_type'] = Display::label(get_lang('Social'), 'success');
break;
}
$new_result[] = $group;
}
$result = $new_result;
}
$columns = array('name', 'users', 'courses', 'sessions', 'group_type');
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
//Multidimensional sort
ArrayClass::msort($result, $sidx);
break;
case 'get_extra_fields':
$obj = new \ExtraField($type);
$columns = array('field_display_text', 'field_variable', 'field_type', 'field_changeable', 'field_visible', 'field_filter', 'field_order');
$result = \Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
$new_result = array();
if (!empty($result)) {
foreach ($result as $item) {
$item['field_type'] = $obj->get_field_type_by_id($item['field_type']);
$item['field_changeable'] = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
$item['field_visible'] = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
$item['field_filter'] = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
$new_result[] = $item;
}