本文整理汇总了PHP中GroupManager::get_group_list方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupManager::get_group_list方法的具体用法?PHP GroupManager::get_group_list怎么用?PHP GroupManager::get_group_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupManager
的用法示例。
在下文中一共展示了GroupManager::get_group_list方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_lang
$form->addElement('radio', 'export_format', null, get_lang('ExportAsCSV'), 'csv', array('id' => 'export_format_csv_label'));
$form->addElement('radio', 'export_format', null, get_lang('ExportAsXLS'), 'xls', array('id' => 'export_format_xls_label'));
$form->addElement('checkbox', 'load_extra_data', null, get_lang('LoadExtraData'), '0', array('id' => 'export_format_xls_label'));
$form->addElement('checkbox', 'include_all_users', null, get_lang('IncludeAllUsers'), '0');
$form->addElement('checkbox', 'only_best_attempts', null, get_lang('OnlyBestAttempts'), '0');
$form->setDefaults(array('export_format' => 'csv'));
$extra .= $form->return_form();
$extra .= '</div>';
if ($is_allowedToEdit) {
echo $extra;
}
echo $actions;
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_results&exerciseId=' . $exercise_id . '&filter_by_user=' . $filter_user . '&' . api_get_cidreq();
$action_links = '';
//Generating group list
$group_list = GroupManager::get_group_list();
$group_parameters = array('group_all:' . get_lang('All'), 'group_none:' . get_lang('None'));
foreach ($group_list as $group) {
$group_parameters[] = $group['id'] . ':' . $group['name'];
}
if (!empty($group_parameters)) {
$group_parameters = implode(';', $group_parameters);
}
$officialCodeInList = api_get_setting('exercise.show_official_code_exercise_result_list');
if ($is_allowedToEdit || $is_tutor) {
// The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), get_lang('Group'), get_lang('Duration') . ' (' . get_lang('MinMinute') . ')', get_lang('StartDate'), get_lang('EndDate'), get_lang('Score'), get_lang('IP'), get_lang('Status'), get_lang('ToolLearnpath'), get_lang('Actions'));
if ($officialCodeInList === 'true') {
$columns = array_merge(array(get_lang('OfficialCode')), $columns);
}
//Column config
示例2: get_forum_categories
*/
// Step 1: We store all the forum categories in an array $forum_categories.
$forumCategories = get_forum_categories();
// Step 2: We find all the forums (only the visible ones if it is a student).
// display group forum in general forum tool depending to configuration option
$setting = api_get_setting('display_groups_forum_in_general_tool');
$forum_list = get_forums('', '', $setting == 'true');
$user_id = api_get_user_id();
/* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
// The groups of the user.
$groups_of_user = array();
$groups_of_user = GroupManager::get_group_ids($_course['real_id'], $user_id);
// All groups in the course (and sorting them as the
// id of the group = the key of the array).
if (!api_is_anonymous()) {
$all_groups = GroupManager::get_group_list();
if (is_array($all_groups)) {
foreach ($all_groups as $group) {
$all_groups[$group['id']] = $group;
}
}
}
/* CLEAN GROUP ID FOR AJAXFILEMANAGER */
if (isset($_SESSION['_gid'])) {
unset($_SESSION['_gid']);
}
/* ACTION LINKS */
echo '<div class="actions">';
//if is called from learning path
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) {
echo "<a href=\"../newscorm/lp_controller.php?" . api_get_cidreq() . "&gradebook=&action=add_item&type=step&lp_id={$lp_id}#resource_tab-5\">" . Display::return_icon('back.png', get_lang("BackTo") . ' ' . get_lang("LearningPaths"), '', ICON_SIZE_MEDIUM) . "</a>";
示例3: getOverview
/**
* @param int $courseId
* @param string $keyword
* @return string
*/
public static function getOverview($courseId, $keyword = null)
{
$content = null;
$categories = GroupManager::get_categories();
if (!empty($categories)) {
foreach ($categories as $category) {
if (api_get_setting('allow_group_categories') == 'true') {
$content .= '<h2>' . $category['title'] . '</h2>';
}
if (!empty($keyword)) {
$groups = GroupManager::getGroupListFilterByName($keyword, $category['id'], $courseId);
} else {
$groups = GroupManager::get_group_list($category['id']);
}
$content .= '<ul>';
if (!empty($groups)) {
foreach ($groups as $group) {
$content .= '<li>';
$content .= Display::tag('h3', Security::remove_XSS($group['name']));
$users = GroupManager::getTutors($group['id']);
if (!empty($users)) {
$content .= '<ul>';
$content .= "<li>" . Display::tag('h4', get_lang('Tutors')) . "</li><ul>";
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
$content .= '<li title="' . $user_info['username'] . '">' . $user_info['complete_name_with_username'] . '</li>';
}
$content .= '</ul>';
$content .= '</ul>';
}
$users = GroupManager::getStudents($group['id']);
if (!empty($users)) {
$content .= '<ul>';
$content .= "<li>" . Display::tag('h4', get_lang('Students')) . "</li><ul>";
foreach ($users as $user) {
$user_info = api_get_user_info($user['user_id']);
$content .= '<li title="' . $user_info['username'] . '">' . $user_info['complete_name_with_username'] . '</li>';
}
$content .= '</ul>';
$content .= '</ul>';
}
$content .= '</li>';
}
}
$content .= '</ul>';
}
}
return $content;
}
示例4: getCourseEvents
/**
* @param int $start
* @param int $end
* @param array $courseInfo
* @param int $groupId
* @param int $session_id
* @param int $user_id
* @param string $color
*
* @return array
*/
public function getCourseEvents($start, $end, $courseInfo, $groupId = 0, $session_id = 0, $user_id = 0, $color = '')
{
$start = isset($start) && !empty($start) ? api_get_utc_datetime(intval($start)) : null;
$end = isset($end) && !empty($end) ? api_get_utc_datetime(intval($end)) : null;
if (empty($courseInfo)) {
return array();
}
$course_id = $courseInfo['real_id'];
if (empty($course_id)) {
return array();
}
$session_id = intval($session_id);
$user_id = intval($user_id);
$groupList = GroupManager::get_group_list(null, $courseInfo['code']);
$group_name_list = array();
if (!empty($groupList)) {
foreach ($groupList as $group) {
$group_name_list[$group['id']] = $group['name'];
}
}
$group_memberships = [];
if (!empty($groupId)) {
if (!api_is_allowed_to_edit()) {
$user_id = api_get_user_id();
$group_memberships = GroupManager::get_group_ids($course_id, $user_id);
} else {
$group_memberships = GroupManager::get_group_ids($course_id, $user_id);
}
} else {
// if no group was defined but I am a student reviewing his agenda,
// group events should show, so we should fetch those groups to which
// I belong
if (!api_is_allowed_to_edit()) {
$user_id = api_get_user_id();
$group_memberships = GroupManager::get_group_ids($course_id, $user_id);
} else {
// If no group was defined and I am a teacher/admin reviewing
// someone else's agenda, we should fetch this person's groups
$group_memberships = GroupManager::get_group_ids($course_id, $user_id);
}
}
$tlb_course_agenda = Database::get_course_table(TABLE_AGENDA);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
if (!empty($groupId)) {
$group_memberships = array($groupId);
}
if (is_array($group_memberships) && count($group_memberships) > 0) {
if (api_is_allowed_to_edit()) {
if (!empty($groupId)) {
$where_condition = "( ip.to_group_id IN (" . implode(", ", $group_memberships) . ") ) ";
} else {
if (!empty($user_id)) {
$where_condition = "( ip.to_user_id = {$user_id} OR ip.to_user_id IS NULL OR (ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ")) ) ";
} else {
$where_condition = "( ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) ";
}
}
} else {
$where_condition = "( ip.to_user_id = {$user_id} OR ip.to_user_id IS NULL OR (ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ")) ) ";
}
$sessionCondition = '';
if (empty($session_id)) {
$sessionCondition = "\n (\n agenda.session_id = 0 AND\n ip.session_id IS NULL\n ) ";
} else {
$sessionCondition = "\n (\n agenda.session_id = {$session_id} AND\n ip.session_id = {$session_id}\n ) ";
}
$sql = "SELECT DISTINCT\n agenda.*,\n ip.visibility,\n ip.to_group_id,\n ip.insert_user_id,\n ip.ref,\n to_user_id\n FROM {$tlb_course_agenda} agenda\n INNER JOIN {$tbl_property} ip\n ON (agenda.id = ip.ref AND agenda.c_id = ip.c_id)\n WHERE\n ip.tool = '" . TOOL_CALENDAR_EVENT . "' AND\n {$where_condition} AND\n ip.visibility = '1' AND\n agenda.c_id = {$course_id} AND\n ip.c_id = agenda.c_id AND\n {$sessionCondition}\n ";
} else {
$visibilityCondition = " ip.visibility='1' AND ";
$sessionCondition = '';
if (api_is_allowed_to_edit()) {
if ($user_id == 0) {
$where_condition = "";
} else {
$where_condition = " (ip.to_user_id = " . $user_id . " OR ip.to_user_id IS NULL) AND ip.to_group_id IS NULL AND ";
}
$visibilityCondition = " (ip.visibility IN ('1', '0')) AND ";
} else {
$where_condition = " ( (ip.to_user_id = " . api_get_user_id() . " OR ip.to_user_id IS NULL) AND ip.to_group_id IS NULL) AND ";
}
if (empty($session_id)) {
$sessionCondition = "\n (\n agenda.session_id = 0 AND\n ip.session_id IS NULL\n ) ";
} else {
$sessionCondition = "\n (\n agenda.session_id = {$session_id} AND\n ip.session_id = {$session_id}\n ) ";
}
$sql = "SELECT DISTINCT\n agenda.*,\n ip.visibility,\n ip.to_group_id,\n ip.insert_user_id,\n ip.ref,\n to_user_id\n FROM {$tlb_course_agenda} agenda\n INNER JOIN {$tbl_property} ip\n ON (agenda.id = ip.ref AND agenda.c_id = ip.c_id)\n WHERE\n ip.tool='" . TOOL_CALENDAR_EVENT . "' AND\n {$where_condition}\n {$visibilityCondition}\n agenda.c_id = {$course_id} AND\n {$sessionCondition}\n ";
}
$dateCondition = null;
if (!empty($start) && !empty($end)) {
//.........这里部分代码省略.........
示例5: get_lang
}
}
if ($today == $attendance_date['date']) {
$exists_attendance_today = true;
}
if ($includeCalendar) {
$values[$attendance_date['id']] = $attendance_date['date_time'];
}
}
}
if (!$exists_attendance_today) {
Display::display_warning_message(get_lang('ThereIsNoClassScheduledTodayTryPickingAnotherDay'));
}
$form->addSelect('filter', get_lang('Filter'), $values, ['id' => 'filter_id', 'onchange' => 'submit();']);
//$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
$groupList = GroupManager::get_group_list(null, null, 1);
$groupIdList = array('--');
foreach ($groupList as $group) {
$groupIdList[$group['id']] = $group['name'];
}
if (!empty($groupList)) {
$form->addSelect('group_id', get_lang('Group'), $groupIdList);
}
if (isset($_REQUEST['filter'])) {
if (in_array($_REQUEST['filter'], array_keys($values))) {
$default_filter = $_REQUEST['filter'];
}
} else {
$default_filter = 'today';
}
$renderer = $form->defaultRenderer();
示例6: displayGroupMenu
/**
* @param string $in_name is the name and the id of the <select>
* @param string $in_default default value for option
* @param string $in_onchange
* @return string the html code of the <select>
*/
public static function displayGroupMenu($in_name, $in_default, $in_onchange = "")
{
// check the default value of option
$tabSelected = array($in_default => " selected='selected' ");
$res = "";
$res .= "<select name='{$in_name}' id='{$in_name}' onchange='" . $in_onchange . "' >";
$res .= "<option value='-1'" . $tabSelected["-1"] . ">-- " . get_lang('AllGroups') . " --</option>";
$res .= "<option value='0'" . $tabSelected["0"] . ">- " . get_lang('NotInAGroup') . " -</option>";
$tabGroups = GroupManager::get_group_list();
$currentCatId = 0;
for ($i = 0; $i < count($tabGroups); $i++) {
$tabCategory = GroupManager::get_category_from_group($tabGroups[$i]["id"]);
if ($tabCategory["id"] != $currentCatId) {
$res .= "<option value='-1' disabled='disabled'>" . $tabCategory["title"] . "</option>";
$currentCatId = $tabCategory["id"];
}
$res .= "<option " . $tabSelected[$tabGroups[$i]["id"]] . "style='margin-left:40px' value='" . $tabGroups[$i]["id"] . "'>" . $tabGroups[$i]["name"] . "</option>";
}
$res .= "</select>";
return $res;
}
示例7: get_course_events
/**
* @param int $start
* @param int $end
* @param array $course_info
* @param int $group_id
* @param int $session_id
* @param int $user_id
* @return array
*/
public function get_course_events($start, $end, $course_info, $group_id = 0, $session_id = 0, $user_id = 0)
{
$course_id = $course_info['real_id'];
$user_id = intval($user_id);
$group_list = GroupManager::get_group_list(null, $course_info['code']);
$group_name_list = array();
if (!empty($group_list)) {
foreach ($group_list as $group) {
$group_name_list[$group['id']] = $group['name'];
}
}
if (!api_is_allowed_to_edit()) {
$group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
$user_id = api_get_user_id();
} else {
$group_memberships = array_keys($group_name_list);
}
$tlb_course_agenda = Database::get_course_table(TABLE_AGENDA);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
if (!empty($group_id)) {
$group_memberships = array($group_id);
}
$session_id = intval($session_id);
if (is_array($group_memberships) && count($group_memberships) > 0) {
if (api_is_allowed_to_edit()) {
if (!empty($user_id)) {
$where_condition = "( ip.to_user_id = {$user_id} AND ip.to_group_id is null OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) ";
} else {
$where_condition = "( ip.to_group_id is null OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) ";
}
} else {
$where_condition = "( ip.to_user_id = {$user_id} OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) ";
}
$sql = "SELECT DISTINCT\n agenda.*,\n ip.visibility,\n ip.to_group_id,\n ip.insert_user_id,\n ip.ref,\n to_user_id\n FROM " . $tlb_course_agenda . " agenda, " . $tbl_property . " ip\n WHERE agenda.id = ip.ref AND\n ip.tool ='" . TOOL_CALENDAR_EVENT . "' AND\n {$where_condition} AND\n ip.visibility = '1' AND\n agenda.c_id = {$course_id} AND\n ip.c_id = {$course_id}\n GROUP BY id";
} else {
if (api_is_allowed_to_edit()) {
$where_condition = "";
} else {
$where_condition = "( ip.to_user_id={$user_id} OR ip.to_group_id='0') AND ";
}
$sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref, to_user_id\n FROM " . $tlb_course_agenda . " agenda, " . $tbl_property . " ip\n WHERE agenda.id = ip.ref AND\n ip.tool='" . TOOL_CALENDAR_EVENT . "' AND\n {$where_condition}\n ip.visibility='1' AND\n agenda.c_id = {$course_id} AND\n ip.c_id = {$course_id} AND\n agenda.session_id = {$session_id} AND\n ip.id_session = {$session_id}\n ";
}
$result = Database::query($sql);
$events = array();
if (Database::num_rows($result)) {
$events_added = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
//to gather sent_tos
$sql = "SELECT to_user_id, to_group_id\n FROM " . $tbl_property . " ip\n WHERE ip.tool = '" . TOOL_CALENDAR_EVENT . "' AND\n ref = {$row['ref']} AND\n ip.visibility = '1' AND\n ip.c_id = {$course_id}";
$sent_to_result = Database::query($sql);
$user_to_array = array();
$group_to_array = array();
while ($row_send_to = Database::fetch_array($sent_to_result, 'ASSOC')) {
if (!empty($row_send_to['to_group_id'])) {
$group_to_array[] = $row_send_to['to_group_id'];
}
if (!empty($row_send_to['to_user_id'])) {
$user_to_array[] = $row_send_to['to_user_id'];
}
}
//Only show events from the session
/*if (api_get_course_int_id()) {
if ($row['session_id'] != api_get_session_id()) {
continue;
}
}*/
$event = array();
$event['id'] = 'course_' . $row['id'];
//To avoid doubles
if (in_array($row['id'], $events_added)) {
continue;
}
$events_added[] = $row['id'];
$attachment = get_attachment($row['id'], $course_id);
$has_attachment = '';
if (!empty($attachment)) {
$has_attachment = Display::return_icon('attachment.gif', get_lang('Attachment'));
$user_filename = $attachment['filename'];
$full_file_name = 'download.php?file=' . $attachment['path'] . '&course_id=' . $course_id;
$event['attachment'] = $has_attachment . Display::url($user_filename, $full_file_name);
} else {
$event['attachment'] = '';
}
$event['title'] = $row['title'];
$event['className'] = 'course';
$event['allDay'] = 'false';
$event['course_id'] = $course_id;
$event['borderColor'] = $event['backgroundColor'] = $this->event_course_color;
if (isset($row['session_id']) && !empty($row['session_id'])) {
$event['borderColor'] = $event['backgroundColor'] = $this->event_session_color;
}
//.........这里部分代码省略.........
示例8: show_add_forum_form
/**
* This function displays the form that is used to add a forum category.
*
* @param array $inputvalues
* @param int $lp_id
* @return void HTML
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Juan Carlos Raña Trabado (return to lp_id)
*
* @version may 2011, Chamilo 1.8.8
*/
function show_add_forum_form($inputvalues = array(), $lp_id)
{
$_course = api_get_course_info();
// Initialize the object.
$form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq());
// The header for the form
if (!empty($inputvalues)) {
$form_title = get_lang('EditForum');
} else {
$form_title = get_lang('AddForum');
}
$session_header = Session::read('session_name');
$form->addElement('header', $form_title . $session_header);
// We have a hidden field if we are editing.
if (!empty($inputvalues) && is_array($inputvalues)) {
$my_forum_id = isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null;
$form->addElement('hidden', 'forum_id', $my_forum_id);
}
$lp_id = intval($lp_id);
// hidden field if from learning path
$form->addElement('hidden', 'lp_id', $lp_id);
// The title of the forum
$form->addElement('text', 'forum_title', get_lang('Title'), array('autofocus'));
// The comment of the forum.
$form->addHtmlEditor('forum_comment', get_lang('Description'), null, null, array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200'));
// Dropdown list: Forum categories
$forum_categories = get_forum_categories();
foreach ($forum_categories as $key => $value) {
$forum_categories_titles[$value['cat_id']] = $value['cat_title'];
}
$form->addElement('select', 'forum_category', get_lang('InForumCategory'), $forum_categories_titles);
$form->applyFilter('forum_category', 'html_filter');
if ($_course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) {
// This is for horizontal
$group = array();
$group[] = $form->createElement('radio', 'allow_anonymous', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'allow_anonymous', null, get_lang('No'), 0);
$form->addGroup($group, 'allow_anonymous_group', get_lang('AllowAnonymousPosts'), ' ');
}
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
$group = array();
$group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('No'), 0);
$form->addGroup($group, 'students_can_edit_group', get_lang('StudentsCanEdit'), ' ');
$group = array();
$group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Approval'), 1);
$group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Direct'), 0);
$group = array();
$group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('No'), 0);
$group = array();
$group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('No'), 0);
$form->addGroup($group, 'allow_new_threads_group', get_lang('AllowNewThreads'), ' ');
$group = array();
$group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Flat'), 'flat');
$group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Threaded'), 'threaded');
$group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Nested'), 'nested');
$form->addGroup($group, 'default_view_type_group', get_lang('DefaultViewType'), ' ');
// Drop down list: Groups
$groups = GroupManager::get_group_list();
$groups_titles[0] = get_lang('NotAGroupForum');
foreach ($groups as $key => $value) {
$groups_titles[$value['id']] = $value['name'];
}
$form->addElement('select', 'group_forum', get_lang('ForGroup'), $groups_titles);
// Public or private group forum
$group = array();
$group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Public'), 'public');
$group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Private'), 'private');
$form->addGroup($group, 'public_private_group_forum_group', get_lang('PublicPrivateGroupForum'), '');
// Forum image
$form->add_progress_bar();
if (isset($inputvalues['forum_image']) && strlen($inputvalues['forum_image']) > 0) {
$image_path = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/upload/forum/images/' . $inputvalues['forum_image'];
$image_size = api_getimagesize($image_path);
$img_attributes = '';
if (!empty($image_size)) {
if ($image_size['width'] > 100 || $image_size['height'] > 100) {
//limit display width and height to 100px
$img_attributes = 'width="100" height="100"';
}
$show_preview_image = '<img src="' . $image_path . '" ' . $img_attributes . '>';
$form->addElement('label', get_lang('PreviewImage'), $show_preview_image);
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
}
}
//.........这里部分代码省略.........
示例9: display_add_form
/**
* this function displays the form to upload a new item to the dropbox.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
{
$course_info = api_get_course_info();
$_user = api_get_user_info();
$is_courseAdmin = api_is_course_admin();
$is_courseTutor = api_is_course_tutor();
$origin = isset($_GET['origin']) ? $_GET['origin'] : null;
$token = Security::get_token();
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
$form = new FormValidator('sent_form', 'post', api_get_self() . '?view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&' . api_get_cidreq(), null, array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);'));
$form->addElement('header', get_lang('UploadNewFile'));
$form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
$form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'origin', $origin);
$form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
if (dropbox_cnf('allowOverwrite')) {
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
}
// List of all users in this course and all virtual courses combined with it
if (api_get_session_id()) {
$complete_user_list_for_dropbox = array();
if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
}
$complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id());
$complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $complete_user_list2);
} else {
if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
} else {
$complete_user_list_for_dropbox = CourseManager::get_teacher_list_from_course_code($course_info['code'], false);
}
}
if (!empty($complete_user_list_for_dropbox)) {
foreach ($complete_user_list_for_dropbox as $k => $e) {
$complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
}
$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
}
/*
Create the options inside the select box:
List all selected users their user id as value and a name string as display
*/
$current_user_id = '';
$options = array();
foreach ($complete_user_list_for_dropbox as $current_user) {
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['tutor_id'] == 1) && $current_user['user_id'] != $_user['user_id']) {
// Don't include yourself.
if ($current_user['user_id'] == $current_user_id) {
continue;
}
$full_name = $current_user['lastcommafirst'];
$current_user_id = $current_user['user_id'];
$options['user_' . $current_user_id] = $full_name;
//echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
}
}
/*
* Show groups
*/
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) {
$complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId'));
if (count($complete_group_list_for_dropbox) > 0) {
foreach ($complete_group_list_for_dropbox as $current_group) {
if ($current_group['number_of_members'] > 0) {
//echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
$options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users');
}
}
}
}
if (dropbox_cnf('allowJustUpload')) {
//echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>';
//echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
$options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect');
}
$form->addElement('select', 'recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'class' => 'span4'));
$form->addElement('button', 'submitWork', get_lang('Upload'));
$form->display();
}
示例10: display_add_form
/**
* this function displays the form to upload a new item to the dropbox.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
{
$course_info = api_get_course_info();
$_user = api_get_user_info();
$is_courseAdmin = api_is_course_admin();
$is_courseTutor = api_is_course_tutor();
$origin = isset($_GET['origin']) ? $_GET['origin'] : null;
$token = Security::get_token();
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
$form = new FormValidator('sent_form', 'post', api_get_self() . '?view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&' . api_get_cidreq(), null, array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);'));
$form->addElement('header', get_lang('UploadNewFile'));
$form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
$form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
$form->addElement('hidden', 'sec_token', $token);
$form->addElement('hidden', 'origin', $origin);
$form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
if (dropbox_cnf('allowOverwrite')) {
$form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
}
// List of all users in this course and all virtual courses combined with it
if (api_get_session_id()) {
$complete_user_list_for_dropbox = array();
if (api_get_setting('dropbox.dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id(), null, null, 0);
}
$complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id());
$generalCoachList = array();
$courseCoachList = array();
foreach ($complete_user_list2 as $coach) {
if ($coach['type'] == 'general_coach') {
$generalCoachList[] = $coach;
} else {
$courseCoachList[] = $coach;
}
}
$hideCourseCoach = api_get_setting('dropbox_hide_course_coach');
if ($hideCourseCoach == 'false') {
$complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $courseCoachList);
}
$hideGeneralCoach = api_get_setting('dropbox_hide_general_coach');
if ($hideGeneralCoach == 'false') {
$complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $generalCoachList);
}
} else {
if (api_get_setting('dropbox.dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
$complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
} else {
$complete_user_list_for_dropbox = CourseManager::getTeacherListFromCourse($course_info['real_id'], false);
}
}
if (!empty($complete_user_list_for_dropbox)) {
foreach ($complete_user_list_for_dropbox as $k => $e) {
$complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
}
$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
}
/*
Create the options inside the select box:
List all selected users their user id as value and a name string as display
*/
$current_user_id = '';
$options = array();
$userGroup = new UserGroup();
foreach ($complete_user_list_for_dropbox as $current_user) {
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['is_tutor'] == 1) && $current_user['user_id'] != $_user['user_id']) {
// Don't include yourself.
if ($current_user['user_id'] == $current_user_id) {
continue;
}
$userId = $current_user['user_id'];
$userInfo = api_get_user_info($userId);
if ($userInfo['status'] != INVITEE) {
$groupNameListToString = '';
if (!empty($groups)) {
$groupNameList = array_column($groups, 'name');
$groupNameListToString = ' - [' . implode(', ', $groupNameList) . ']';
}
$groups = $userGroup->getUserGroupListByUser($userId);
$full_name = $userInfo['complete_name'] . $groupNameListToString;
$current_user_id = $current_user['user_id'];
$options['user_' . $current_user_id] = $full_name;
}
}
}
/*
* Show groups
*/
if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) {
$complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId'));
if (count($complete_group_list_for_dropbox) > 0) {
foreach ($complete_group_list_for_dropbox as $current_group) {
if ($current_group['number_of_members'] > 0) {
$options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users');
}
//.........这里部分代码省略.........