// Only courseadmin or group members allowed } else { exit; } } elseif ($is_allowed_to_edit || is_my_shared_folder(api_get_user_id(), $_POST['curdirpath'], api_get_session_id())) { } else { // No course admin and no group member... exit; } if (!empty($_FILES)) { $file = $_FILES['file']; $result = DocumentManager::upload_document($_FILES, $_POST['curdirpath'], $file['name'], null, 0, 'overwrite', false, false); $json = array(); $json['name'] = Display::url(api_htmlentities($file['name']), api_htmlentities($result['url']), array('target' => '_blank')); $json['type'] = api_htmlentities($file['type']); $json['size'] = Text::format_file_size($file['size']); if (!empty($result) && is_array($result)) { $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded')); } else { $json['result'] = Display::return_icon('exclamation.png', get_lang('Error')); } echo json_encode($json); } break; case 'document_preview': $course_info = api_get_course_info_by_id($_REQUEST['course_id']); if (!empty($course_info) && is_array($course_info)) { echo DocumentManager::get_document_preview($course_info, false, '_blank', $_REQUEST['session_id']); } break; }
$column_show[] = 0; // Here we change the way how the colums are going to be sort // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" $column_order[3] = 8; $column_order[5] = 7; // The content of the sortable table = the received files foreach ($dropbox_person->sentWork as $dropbox_file) { $dropbox_file_data = array(); if ($view_dropbox_category_sent == $dropbox_file->category) { $dropbox_file_data[] = $dropbox_file->id; $link_open = '<a href="dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '">'; $dropbox_file_data[] = $link_open . build_document_icon_tag('file', $dropbox_file->title) . '</a>'; $dropbox_file_data[] = '<a href="dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '&action=download">' . Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_SMALL) . '</a>' . $link_open . $dropbox_file->title . '</a><br />' . $dropbox_file->description; $file_size = $dropbox_file->filesize; $dropbox_file_data[] = Text::format_file_size($file_size); $receivers_celldata = null; foreach ($dropbox_file->recipients as $recipient) { $receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']) . ', ' . $receivers_celldata; } $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. $dropbox_file_data[] = $receivers_celldata; $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); $dropbox_file_data[] = date_to_str_ago($last_upload_date) . '<br /><span class="dropbox_date">' . api_format_date($last_upload_date) . '</span>'; //$dropbox_file_data[] = $dropbox_file->author; $receivers_celldata = ''; $action_icons = check_number_feedback($dropbox_file->id, $number_feedback) . ' ' . get_lang('Feedback') . ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=viewfeedback&id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('discuss.png', get_lang('Comment'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=movesent&move_id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('move.png', get_lang('Move'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=deletesentfile&id=' . $dropbox_file->id . '&' . $sort_params . '" onclick="javascript: return confirmation(\'' . $dropbox_file->title . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
function manage_form($default, $select_from_user_list = null, $sent_to = null) { $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null; $param_f = isset($_GET['f']) ? Security::remove_XSS($_GET['f']) : ''; $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data')); if (empty($group_id)) { if (isset($select_from_user_list)) { $form->add_textfield('id_text_name', get_lang('SendMessageTo'), true, array('class' => 'span4', 'id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off')); $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" > </div>'); $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list')); } else { if (!empty($sent_to)) { $form->addElement('html', $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select', 'users', get_lang('SendMessageTo'), array(), array('id' => 'users')); } else { $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user')); } } } else { $usergroup = new UserGroup(); $group_info = $usergroup->get($group_id); $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name'])); $form->addElement('hidden', 'group_id', $group_id); $form->addElement('hidden', 'parent_id', $message_id); } $form->add_textfield('title', get_lang('Subject'), true, array('class' => 'span4')); $form->add_html_editor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '95%', 'Height' => '250')); if (isset($_GET['re_id'])) { $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title']; $form->addElement('hidden', 're_id', intval($_GET['re_id'])); $form->addElement('hidden', 'save_form', 'save_form'); //adding reply mail $user_reply_info = UserManager::get_user_info_by_id($message_reply_info['user_sender_id']); $default['content'] = '<br />' . sprintf(get_lang('XWroteY'), api_get_person_name($user_reply_info['firstname'], $user_reply_info['lastname']), Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('advanced_settings', get_lang('FilesAttachment') . '<span id="filepaths"> <div id="filepath_1"> <input type="file" name="attach_1"/><br /> ' . get_lang('Description') . ' <input type="text" name="legend[]" /><br /><br /> </div> </span>'); $form->addElement('advanced_settings', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); } $form->addElement('style_submit_button', 'compose', api_xml_http_response_encode(get_lang('SendMessage')), 'class="save"'); $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); if (!empty($group_id) && !empty($message_id)) { $message_info = MessageManager::get_message_by_id($message_id); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title']; } $form->setDefaults($default); $html = ''; if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $user_list = $default['users']; $file_comments = $_POST['legend']; $title = $default['title']; $content = $default['content']; $group_id = isset($default['group_id']) ? $default['group_id'] : null; $parent_id = $default['parent_id']; if (is_array($user_list) && count($user_list) > 0) { //all is well, send the message foreach ($user_list as $user) { $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id, null, null, api_get_user_id()); if ($res) { if (is_string($res)) { $html .= Display::return_message($res, 'error'); } else { $user_info = api_get_user_info($user); $html .= Display::return_message(get_lang('MessageSentTo') . " <b>" . $user_info['complete_name'] . "</b>", 'confirmation', false); } } } } else { Display::display_error_message('ErrorSendingMessage'); } } Security::clear_token(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $html .= $form->return_form(); } return $html; }
$quota_bytes += $document_data['size']; } } if ($quota_bytes != 0) { $quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100; } $session[] = array(addslashes(get_lang('Teacher') . ': ' . $user_name) . ' (' . Text::format_file_size($quota_bytes) . ')', $quota_percentage); //if a sesson is active if ($session_id != 0) { if (!empty($course_list)) { $total_courses_quota = 0; $total_quota_bytes = 0; foreach ($course_list as $course_data) { $total_quota_bytes += DocumentManager::get_course_quota($course_data['id']); } if ($quota_bytes != 0) { $quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100; } } $session[] = array(addslashes(get_lang('Teacherinsession') . ': ' . $user_name), $quota_percentage); } } $quota_percentage = round(($total_quota_bytes - $used_quota_bytes) / $total_quota_bytes, 2) * 100; $session[] = array(addslashes(get_lang('ShowCourseQuotaUse')) . ' (' . Text::format_file_size($total_quota_bytes - $used_quota_bytes) . ') ', $quota_percentage); $quota_data = json_encode($session); $htmlHeadXtra[] = "\n<script>\n\$(document).ready(function(){\n var data = " . $quota_data . ";\n var plot1 = jQuery.jqplot ('chart1', [data], {\n seriesDefaults: {\n // Make this a pie chart\n renderer: jQuery.jqplot.PieRenderer,\n rendererOptions: {\n // Put data labels on the pie slices.\n // By default, labels show the percentage of the slice.\n showDataLabels: true\n }\n },\n legend: { show:true, location: 'e' }\n }\n );\n});\n</script>"; $app['title'] = $tool_name; $tpl = $app['template']; $content = Display::page_subheader(get_lang('ShowCourseQuotaUse')) . '<div id="chart1"></div>'; $tpl->assign('content', $content); $tpl->display_one_col_template();
$param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id']) ? '&items_' . intval($_GET['topic_id']) . '_page_nr=' . (!empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1) : ''; if (isset($_GET['topic_id'])) { $param_item_page .= '&topic_id=' . intval($_GET['topic_id']); } $page_topic = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1; $anchor_topic = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']) : null; $url = api_get_path(WEB_PUBLIC_PATH) . 'main/social/group_topics.php?id=' . $group_id . '&anchor_topic=' . $anchor_topic . '&topics_page_nr=' . $page_topic . $param_item_page; $form = new FormValidator('form', 'post', $url, null, array('enctype' => 'multipart/form-data')); $form->addElement('hidden', 'action', $allowed_action); $form->addElement('hidden', 'group_id', $group_id); $form->addElement('hidden', 'parent_id', $message_id); $form->addElement('hidden', 'message_id', $message_id); $form->addElement('hidden', 'token', $tok); if (api_get_setting('allow_message_tool') == 'true') { // Normal message $user_info = api_get_user_info($userfriend_id); $height = 180; if ($allowed_action == 'add_message_group') { $form->addElement('text', 'title', get_lang('Title')); $height = 140; } $form->addElement('html_editor', 'content'); $form->addElement('label', null, get_lang('AttachmentFiles')); $form->addElement('label', null, '<div id="link-more-attach"> <a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a>'); $form->addElement('html', '<span id="filepaths"></span>'); $form->addElement('file', 'attach_1', sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize')))); $form->addElement('html', '</div>'); $form->addElement('button', 'submit', get_lang('SendMessage')); $form->display(); }
$user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']); $user_link = '<div class="document_owner">' . get_lang('Owner') . ': ' . display_user_link_document($document_data['insert_user_id'], $user_name) . '</div>'; } } // Icons (clickable) $row[] = create_document_link($document_data, true, $count, $is_visible); $path_info = pathinfo($document_data['path']); if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) { $count++; } // Validacion when belongs to a session $session_img = api_get_session_image($document_data['session_id'], $_user['status']); // Document title with link $row[] = create_document_link($document_data, false, null, $is_visible) . $session_img . '<br />' . $invisibility_span_open . '<i>' . nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)) . '</i>' . $invisibility_span_close . $user_link; // Comments => display comment under the document name $display_size = Text::format_file_size($size); $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close; // Last edit date $last_edit_date = $document_data['lastedit_date']; $last_edit_date = api_get_local_time($last_edit_date, null, date_default_timezone_get()); //$display_date = date_to_str_ago($last_edit_date).'<br /><span class="dropbox_date">'.api_format_date($last_edit_date).'</span>'; $display_date = date_to_str_ago($last_edit_date); $row[] = $invisibility_span_open . $display_date . $invisibility_span_close; // Admins get an edit column if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) { $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false; // If readonly, check if it the owner of the file or if the user is an admin if ($document_data['insert_user_id'] == api_get_user_id() || api_is_platform_admin()) { $edit_icons = build_edit_icons($document_data, $key, $is_template, 0, $is_visible); } else { $edit_icons = build_edit_icons($document_data, $key, $is_template, $document_data['readonly'], $is_visible);
// Link to create a folder /* if (!isset($_GET['createdir']) && !is_my_shared_folder($_user['user_id'], $path, api_get_session_id()) && !$is_certificate_mode) { echo '<a href="'.api_get_self().'?path='.$path.'&createdir=1">'.Display::return_icon('new_folder.png', get_lang('CreateDir'),'',ICON_SIZE_MEDIUM).'</a>'; }*/ echo '</div>'; // Form to select directory $folders = DocumentManager::get_all_document_folders($_course, $to_group_id, $is_allowed_to_edit); if (!$is_certificate_mode) { echo build_directory_selector($folders, $document_id, isset($group_properties['directory']) ? $group_properties['directory'] : array()); } $action = api_get_self() . '?' . api_get_cidreq() . '&id=' . $document_id; $form = new FormValidator('upload', 'POST', $action . '#tabs-2', '', 'enctype="multipart/form-data"'); $form->addElement('hidden', 'id', $document_id); $form->addElement('hidden', 'curdirpath', $path); $course_quota = Text::format_file_size(DocumentManager::get_course_quota() - DocumentManager::documents_total_space()); $label = get_lang('MaxFileSize') . ': ' . ini_get('upload_max_filesize') . '<br/>' . get_lang('DocumentQuota') . ': ' . $course_quota; $form->addElement('file', 'file', array(get_lang('File'), $label), 'style="width: 250px" id="user_upload"'); $form->addElement('text', 'title', get_lang('Title'), array('size' => '20', 'style' => 'width:300px', 'id' => 'title_file')); $form->addElement('textarea', 'comment', get_lang('Comment'), 'wrap="virtual" style="width:300px;"'); // Advanced parameters $form->addElement('label', null, Display::url(get_lang('AdvancedParameters'), '#', array('id' => 'upload_settings', 'class' => 'advanced_options'))); $form->addElement('html', '<div id="upload_settings_options" style="display:none">'); // Check box options $form->addElement('checkbox', 'unzip', get_lang('Options'), get_lang('Uncompress'), 'onclick="javascript: check_unzip();" value="1"'); if (api_get_setting('search_enabled') == 'true') { //TODO: include language file $supported_formats = get_lang('SupportedFormatsForIndex') . ': HTML, PDF, TXT, PDF, Postscript, MS Word, RTF, MS Power Point'; $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument') . '<div style="font-size: 80%" >' . $supported_formats . '</div>'); $form->addElement('html', '<br /><div class="sub-form">'); $form->addElement('html', '<div class="label">' . get_lang('SearchFeatureDocumentLanguage') . '</div>');
/** * This function checks if the upload succeeded * * @param array $uploaded_file ($_FILES) * @param bool $show_output * * @return true if upload succeeded */ static function process_uploaded_file($uploaded_file, $show_output = true) { // Checking the error code sent with the file upload. switch ($uploaded_file['error']) { case 1: // The uploaded file exceeds the upload_max_filesize directive in php.ini. if ($show_output) { Display::display_error_message(get_lang('UplExceedMaxServerUpload') . ini_get('upload_max_filesize')); } return false; case 2: // The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor). $max_file_size = intval($_POST['MAX_FILE_SIZE']); if ($show_output) { Display::display_error_message(get_lang('UplExceedMaxPostSize') . Text::format_file_size($max_file_size)); } return false; case 3: // The uploaded file was only partially uploaded. if ($show_output) { Display::display_error_message(get_lang('UplPartialUpload') . ' ' . get_lang('PleaseTryAgain')); } return false; case 4: // No file was uploaded. if ($show_output) { Display::display_error_message(get_lang('UplNoFileUploaded') . ' ' . get_lang('UplSelectFileFirst')); } return false; } if (!file_exists($uploaded_file['tmp_name'])) { // No file was uploaded. if ($show_output) { Display::display_error_message(get_lang('UplUploadFailed')); } return false; } if (file_exists($uploaded_file['tmp_name'])) { $filesize = filesize($uploaded_file['tmp_name']); if (empty($filesize)) { // No file was uploaded. if ($show_output) { Display::display_error_message(get_lang('UplUploadFailedSizeIsZero')); } return false; } } $course_id = api_get_course_id(); //Checking course quota if we are in a course if (!empty($course_id)) { $max_filled_space = DocumentManager::get_course_quota(); // Check if there is enough space to save the file if (!DocumentManager::enough_space($uploaded_file['size'], $max_filled_space)) { if ($show_output) { Display::display_error_message(get_lang('UplNotEnoughSpace')); } return false; } } // case 0: default: We assume there is no error, the file uploaded with success. return true; }
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); $form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types); if (api_get_setting('pdf_export_watermark_by_course') == 'true') { $url = PDF::get_watermark($course_code); $form->add_textfield('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60')); $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark')); if ($url != false) { $delete_url = '<a href="?delete_watermark">' . Display::return_icon('delete.png', get_lang('DelImage')) . '</a>'; $form->addElement('html', '<div class="row"><div class="formw"><a href="' . $url . '">' . $url . ' ' . $delete_url . '</a></div></div>'); } $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types); } $group = array(); $group[] = $form->createElement('select_theme', 'course_theme', null, array('class' => ' ', 'id' => 'course_theme_id')); $form->addGroup($group, '', array(get_lang("Stylesheets")), ''); $form->addElement('label', get_lang('DocumentQuota'), Text::format_file_size(DocumentManager::get_course_quota())); $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"'); $form->addElement('html', '</div></div>'); // COURSE ACCESS $form->addElement('html', '<div> <h3>' . Display::return_icon('course.png', Security::remove_XSS(get_lang('CourseAccess')), '', ICON_SIZE_SMALL) . ' ' . Security::remove_XSS(get_lang('CourseAccess')) . '</h3><div>'); $group = array(); $group[] = $form->createElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD); $group[] = $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM); $group[] = $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED); $group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED); // The "hidden" visibility is only available to portal admins if (api_is_platform_admin()) { $group[] = $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN); } $form->addGroup($group, '', array(get_lang("CourseAccess"), get_lang("CourseAccessConfigTip")), ''); $url = api_get_path(WEB_CODE_PATH) . "auth/inscription.php?c={$course_code}&e=1";
/** * Get array of links (download) for message attachment files * @param int message id * @param string type message list (inbox/outbox) * @return array */ public static function get_links_message_attachment_files($message_id, $type = '') { $tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); $message_id = intval($message_id); // get file attachments by message id $links_attach_file = array(); if (!empty($message_id)) { $sql = "SELECT * FROM {$tbl_message_attach} WHERE message_id = '{$message_id}'"; $rs_file = Database::query($sql); if (Database::num_rows($rs_file) > 0) { $attach_icon = Display::return_icon('attachment.gif', ''); $archiveURL = api_get_path(WEB_CODE_PATH) . 'messages/download.php?type=' . $type . '&file='; while ($row_file = Database::fetch_array($rs_file)) { $archiveFile = $row_file['path']; $filename = $row_file['filename']; $filesize = Text::format_file_size($row_file['size']); $filecomment = $row_file['comment']; $links_attach_file[] = $attach_icon . ' <a href="' . $archiveURL . $archiveFile . '">' . $filename . '</a> (' . $filesize . ')' . (!empty($filecomment) ? ' - <i>' . $filecomment . '</i>' : ''); } } } return $links_attach_file; }