$form->addElement('text', 'title', get_lang('Title'), array('id' => 'document_title')); } // Show read-only box only in groups if (!empty($groupId)) { $group[] = $form->createElement('checkbox', 'readonly', '', get_lang('ReadOnly')); } $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('title', get_lang('FileExists'), 'callback', 'document_exists'); $current_session_id = api_get_session_id(); $form->add_html_editor('content', '', false, false, $html_editor_config); // Comment-field $folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit); // If we are not in the certificates creation, display a folder chooser for the // new document created if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'], $dir, $current_session_id)) { $folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit); $parent_select = $form->addElement('select', 'curdirpath', array(null, get_lang('DestinationDirectory'))); // Following two conditions copied from document.inc.php::build_directory_selector() $folder_titles = array(); if (is_array($folders)) { $escaped_folders = array(); foreach ($folders as $key => &$val) { //Hide some folders if ($val == '/HotPotatoes_files' || $val == '/certificates' || basename($val) == 'css') { continue; } //Admin setting for Hide/Show the folders of all users if (api_get_setting('show_users_folders') == 'false' && (strstr($val, '/shared_folder') || strstr($val, 'shared_folder_session_'))) { continue; } //Admin setting for Hide/Show Default folders to all users
DocumentManager::attach_gradebook_certificate($course_id, $document_id); Display::display_normal_message(get_lang('IsDefaultCertificate')); } } /* GET ALL DOCUMENT DATA FOR CURDIRPATH */ if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, true); } else { $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath, $to_group_id, null, $is_allowed_to_edit || $group_member_with_upload_rights, false); } if (api_get_group_id() != 0) { if (api_is_allowed_to_edit() || GroupManager::is_subscribed(api_get_user_id(), api_get_group_id()) || GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())) { $folders = DocumentManager::get_all_document_folders($_course, api_get_group_id(), $is_allowed_to_edit || $group_member_with_upload_rights); } } else { $folders = DocumentManager::get_all_document_folders($_course, api_get_group_id(), $is_allowed_to_edit || $group_member_with_upload_rights); } //$folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit || $group_member_with_upload_rights); if ($folders === false) { $folders = array(); } echo '<div class="actions">'; /* GO TO PARENT DIRECTORY */ if ($curdirpath != '/' && $curdirpath != $group_properties['directory'] && !$is_certificate_mode) { echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&id=' . $parent_id . '">'; echo Display::display_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM); echo '</a>'; } if ($is_certificate_mode && $curdirpath != '/certificates') { ?> <a href="<?php
Display::addFlash($message); } } /* GET ALL DOCUMENT DATA FOR CURDIRPATH */ if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { $documentAndFolders = DocumentManager::get_all_document_data($courseInfo, $curdirpath, $groupId, null, $is_allowed_to_edit || $group_member_with_upload_rights, true); } else { $documentAndFolders = DocumentManager::get_all_document_data($courseInfo, $curdirpath, $groupId, null, $is_allowed_to_edit || $group_member_with_upload_rights, false); } if ($groupId != 0) { $userAccess = GroupManager::user_has_access(api_get_user_id(), $groupId, GroupManager::GROUP_TOOL_DOCUMENTS); if ($userAccess) { $folders = DocumentManager::get_all_document_folders($courseInfo, $groupId, $is_allowed_to_edit || $group_member_with_upload_rights); } } else { $folders = DocumentManager::get_all_document_folders($courseInfo, $groupId, $is_allowed_to_edit || $group_member_with_upload_rights); } if (!isset($folders) || $folders === false) { $folders = array(); } $btngroup = array('class' => 'btn btn-default'); /* GO TO PARENT DIRECTORY */ $actionsLeft = ''; if ($curdirpath != '/' && $curdirpath != $group_properties['directory'] && !$is_certificate_mode) { $actionsLeft = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&id=' . $parent_id . '">'; $actionsLeft .= Display::return_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM); $actionsLeft .= '</a>'; } if ($is_certificate_mode && $curdirpath != '/certificates') { $actionsLeft .= Display::url(Display::return_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM), api_get_self() . '?' . api_get_cidreq() . '&curdirpath=' . $curdirpath); }
/** * Creates a list with all the documents in it * @param bool $showInvisibleFiles * @return string */ public function get_documents($showInvisibleFiles = false) { $course_info = api_get_course_info(); $sessionId = api_get_session_id(); $documentTree = DocumentManager::get_document_preview($course_info, $this->lp_id, null, $sessionId, true, null, null, $showInvisibleFiles, true); $headers = array(get_lang('Files'), get_lang('NewDocument'), get_lang('Upload')); $form = new FormValidator('form_upload', 'POST', api_get_self() . '?' . $_SERVER['QUERY_STRING'], '', array('enctype' => "multipart/form-data")); $folders = DocumentManager::get_all_document_folders(api_get_course_info(), 0, true); DocumentManager::build_directory_selector($folders, '', array(), true, $form, 'directory_parent_id'); $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'); $form->setDefaults(['if_exists' => 'rename']); // Check box options $form->addElement('checkbox', 'unzip', get_lang('Options'), get_lang('Uncompress')); $url = api_get_path(WEB_AJAX_PATH) . 'document.ajax.php?' . api_get_cidreq() . '&a=upload_file&curdirpath='; $form->addMultipleUpload($url); $new = $this->display_document_form('add', 0); $tabs = Display::tabs($headers, array($documentTree, $new, $form->returnForm()), 'subtab'); return $tabs; }