/** * Return a form to upload asynchronously attachments to forum post. * @param int $forumId Forum ID from where the post are * @param int $threadId Thread ID where forum post are * @param int $postId Post ID to identify Post * @deprecated this function seems to never been used * @return string The Forum Attachment Ajax Form * */ function getAttachmentAjaxForm($forumId, $threadId, $postId) { $forumId = intval($forumId); $postId = intval($postId); $threadId = !empty($threadId) ? intval($threadId) : isset($_REQUEST['thread']) ? intval($_REQUEST['thread']) : ''; if ($forumId === 0) { // Forum Id must be defined return ''; } $url = api_get_path(WEB_AJAX_PATH) . 'forum.ajax.php?' . api_get_cidreq() . '&forum=' . $forumId . '&thread=' . $threadId . '&postId=' . $postId . '&a=upload_file'; $multipleForm = new FormValidator('post'); $multipleForm->addMultipleUpload($url); return $multipleForm->returnForm(); }
$form->addElement('html', '<div class="label">' . get_lang('SearchFeatureDocumentLanguage') . '</div>'); $form->addLabel(get_lang('Language'), api_get_languages_combo()); $form->addElement('html', '</div><div class="sub-form">'); $specific_fields = get_specific_field_list(); foreach ($specific_fields as $specific_field) { $form->addElement('text', $specific_field['code'], $specific_field['name']); } $form->addElement('html', '</div>'); } $form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'nothing'); $form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'overwrite'); $form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename'); // Close the java script and avoid the footer up $form->addElement('html', '</div>'); // Button upload document $form->addButtonSend(get_lang('SendDocument'), 'submitDocument'); $form->add_real_progress_bar('DocumentUpload', 'file'); $fileExistsOption = api_get_setting('document.if_file_exists_option'); $defaultFileExistsOption = 'rename'; if (!empty($fileExistsOption)) { $defaultFileExistsOption = $fileExistsOption; } $defaults = array('index_document' => 'checked="checked"', 'if_exists' => $defaultFileExistsOption); $form->setDefaults($defaults); $simple_form = $form->returnForm(); $url = api_get_path(WEB_AJAX_PATH) . 'document.ajax.php?' . api_get_cidreq() . '&a=upload_file&curdirpath=' . $path; $multipleForm = new FormValidator('drag_drop', 'post', '#', array('enctype' => 'multipart/form-data')); $multipleForm->addMultipleUpload($url); $headers = array(get_lang('Upload'), get_lang('Upload') . ' (' . get_lang('Simple') . ')'); echo Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs'); Display::display_footer();
/** * this function displays the form to upload a new item to the dropbox. * * @author Patrick Cool <*****@*****.**>, 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'); } } } } if (dropbox_cnf('allowJustUpload')) { $options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect'); } $form->addSelect('recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10')); $form->addButtonUpload(get_lang('Upload'), 'submitWork'); $headers = array(get_lang('Upload'), get_lang('Upload') . ' (' . get_lang('Simple') . ')'); $multipleForm = new FormValidator('sent_multiple', 'post', '#', null, array('enctype' => 'multipart/form-data', 'id' => 'fileupload')); $multipleForm->addSelect('recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'id' => 'recipient_form')); $url = api_get_path(WEB_AJAX_PATH) . 'dropbox.ajax.php?' . api_get_cidreq() . '&a=upload_file&id='; $multipleForm->addHtml('<div id="multiple_form" style="display:none">'); $multipleForm->addMultipleUpload($url); $multipleForm->addHtml('</div>'); echo Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs'); }