Merge pull request #1986 from AngelFQC/B12783

Add document_pdf_orientation and use_alternative_document_pdf_footer confi settings - refs BT#12783
pull/2487/head
Angel Fernando Quiroz Campos 8 years ago committed by GitHub
commit 1be168788b
  1. 495
      main/document/document.php
  2. 10
      main/inc/lib/document.lib.php
  3. 4
      main/install/configuration.dist.php
  4. 9
      main/template/default/export/alt_pdf_footer.tpl

@ -9,19 +9,19 @@ use ChamiloSession as Session;
* This script allows the user to manage files and directories on a remote http
* server.
* The user can : - navigate through files and directories.
* - upload a file
* - delete, copy a file or a directory
* - edit properties & content (name, comments, html content)
* - upload a file
* - delete, copy a file or a directory
* - edit properties & content (name, comments, html content)
* The script is organised in four sections.
*
* 1) Execute the command called by the user
* Note: somme commands of this section are organised in two steps.
* The script always begins with the second step,
* so it allows to return more easily to the first step.
* Note: somme commands of this section are organised in two steps.
* The script always begins with the second step,
* so it allows to return more easily to the first step.
*
* Note (March 2004) some editing functions (renaming, commenting)
* are moved to a separate page, edit_document.php. This is also
* where xml and other stuff should be added.
* Note (March 2004) some editing functions (renaming, commenting)
* are moved to a separate page, edit_document.php. This is also
* where xml and other stuff should be added.
* 2) Define the directory to display
* 3) Read files and directories from the directory defined in part 2
* 4) Display all of that on an HTML page
@ -67,9 +67,9 @@ if (!$allowUseTool) {
DocumentManager::removeGeneratedAudioTempFile();
if (
isset($_SESSION['temp_realpath_image']) &&
!empty($_SESSION['temp_realpath_image']) &&
file_exists($_SESSION['temp_realpath_image'])
isset($_SESSION['temp_realpath_image'])
&& !empty($_SESSION['temp_realpath_image'])
&& file_exists($_SESSION['temp_realpath_image'])
) {
unlink($_SESSION['temp_realpath_image']);
}
@ -109,15 +109,15 @@ $capturePluginInstalled = in_array('jcapture', $pluginList);
if ($capturePluginInstalled) {
$jcapturePath = api_get_path(WEB_PLUGIN_PATH).'jcapture/plugin_applet.php';
$htmlHeadXtra[] = '<script>
$(function() {
function insertAtCarret() {
}
$("#jcapture").click(function(){
$("#appletplace").load("'.$jcapturePath.'");
$htmlHeadXtra[]
= '<script>
$(function() {
$("#jcapture").click(function(){
$("#appletplace").load("'.$jcapturePath.'");
});
});
});
</script>';
</script>
';
}
if (empty($courseInfo)) {
@ -196,9 +196,10 @@ if (!empty($groupId)) {
);
// Allowed to upload?
if ($isAllowedToEdit ||
GroupManager::is_subscribed($userId, $group_properties) ||
GroupManager::is_tutor_of_group($userId, $group_properties, $courseId)
if (
$isAllowedToEdit
|| GroupManager::is_subscribed($userId, $group_properties)
|| GroupManager::is_tutor_of_group($userId, $group_properties, $courseId)
) {
// Only course admin or group members can upload
$group_member_with_upload_rights = true;
@ -222,10 +223,11 @@ $curdirpath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpat
switch ($action) {
case 'delete_item':
if ($isAllowedToEdit ||
$group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId)
if (
$isAllowedToEdit
|| $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId)
) {
if (isset($_GET['deleteid'])) {
if (!$isAllowedToEdit) {
@ -241,14 +243,7 @@ switch ($action) {
}
}
if (DocumentManager::check_readonly(
$courseInfo,
api_get_user_id(),
'',
$_GET['deleteid'],
true
)
) {
if (DocumentManager::check_readonly($courseInfo, api_get_user_id(), '', $_GET['deleteid'], true)) {
api_not_allowed();
}
}
@ -318,8 +313,10 @@ switch ($action) {
// Launch event
Event::event_download($document_data['url']);
// Check visibility of document and paths
if (!($isAllowedToEdit || $group_member_with_upload_rights)
&& !DocumentManager::is_visible_by_id($document_id, $courseInfo, $sessionId, api_get_user_id())) {
if (
!($isAllowedToEdit || $group_member_with_upload_rights)
&& !DocumentManager::is_visible_by_id($document_id, $courseInfo, $sessionId, api_get_user_id())
) {
api_not_allowed(true);
}
$full_file_name = $base_work_dir.$document_data['path'];
@ -358,9 +355,11 @@ switch ($action) {
//filter when I am into shared folder, I can download only my shared folder
if (DocumentManager::is_any_user_shared_folder($document_data['path'], $sessionId)) {
if (DocumentManager::is_my_shared_folder(api_get_user_id(), $document_data['path'], $sessionId)
if (
DocumentManager::is_my_shared_folder(api_get_user_id(), $document_data['path'], $sessionId)
|| $isAllowedToEdit
|| api_is_platform_admin()) {
|| api_is_platform_admin()
) {
require 'downloadfolder.inc.php';
}
} else {
@ -372,26 +371,34 @@ switch ($action) {
}
break;
case 'export_to_pdf':
if (api_get_setting('students_export2pdf') == 'true' || $isAllowedToEdit || api_is_platform_admin()) {
$orientation = 'landscape';
if (
api_get_setting('students_export2pdf') == 'true'
|| $isAllowedToEdit
|| api_is_platform_admin()
) {
$documentOrientation = api_get_configuration_value('document_pdf_orientation');
$orientation = in_array($documentOrientation, ['landscape', 'portrait'])
? $documentOrientation
: 'landscape';
$showHeaderAndFooter = true;
if ($is_certificate_mode) {
$orientation = api_get_configuration_value('certificate_pdf_orientation');
$certificateOrientation = api_get_configuration_value('certificate_pdf_orientation');
$orientation = in_array($certificateOrientation, ['landscape', 'portrait'])
? $certificateOrientation
: 'landscape';
$showHeaderAndFooter = !api_get_configuration_value('hide_header_footer_in_certificate');
}
DocumentManager::export_to_pdf(
$document_id,
$course_code,
$orientation,
$showHeaderAndFooter
);
DocumentManager::export_to_pdf($document_id, $course_code, $orientation, $showHeaderAndFooter);
}
break;
case 'copytomyfiles':
// Copy a file to general my files user's
if (api_get_setting('allow_my_files') == 'true' &&
api_get_setting('users_copy_files') == 'true'
if (
api_get_setting('allow_my_files') == 'true'
&& api_get_setting('users_copy_files') == 'true'
&& api_get_user_id() != 0
&& !api_is_anonymous()
) {
@ -433,7 +440,8 @@ switch ($action) {
}
$file_link = Display::url(
get_lang('SeeFile'),
api_get_path(WEB_CODE_PATH).'social/myfiles.php?'.api_get_cidreq_params($cidReq, $id_session, $gidReq).
api_get_path(WEB_CODE_PATH).'social/myfiles.php?'
.api_get_cidreq_params($cidReq, $id_session, $gidReq).
'&parent_id='.$parent_id
);
@ -443,16 +451,18 @@ switch ($action) {
if (file_exists($copyfile)) {
$message = get_lang('CopyAlreadyDone').'</p><p>';
$message .= '<a class = "btn btn-default" '.
'href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$parent_id.'">'.
get_lang("No").
'</a>'.
'&nbsp;&nbsp;|&nbsp;&nbsp;'.
'<a class = "btn btn-default" href="'.api_get_self().'?'.
api_get_cidreq().'&amp;action=copytomyfiles&amp;id='.$document_info['id'].
'&amp;copy=yes">'.
get_lang('Yes').
'</a></p>';
$message .= '<a class = "btn btn-default" '
.'href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='
.$parent_id.'">'
.get_lang("No")
.'</a>'
.'&nbsp;&nbsp;|&nbsp;&nbsp;'
.'<a class = "btn btn-default" href="'.api_get_self().'?'
.api_get_cidreq().'&amp;action=copytomyfiles&amp;id='
.$document_info['id']
.'&amp;copy=yes">'
.get_lang('Yes')
.'</a></p>';
if (!isset($_GET['copy'])) {
Display::addFlash(Display::return_message($message, 'warning', false));
}
@ -480,10 +490,12 @@ switch ($action) {
break;
case 'convertToPdf':
// PDF format as target by default
$formatTarget = $_REQUEST['formatTarget'] ?
strtolower(Security::remove_XSS($_REQUEST['formatTarget'])) : 'pdf';
$formatType = $_REQUEST['formatType'] ?
strtolower(Security::remove_XSS($_REQUEST['formatType'])) : 'text';
$formatTarget = $_REQUEST['formatTarget']
? strtolower(Security::remove_XSS($_REQUEST['formatTarget']))
: 'pdf';
$formatType = $_REQUEST['formatType']
? strtolower(Security::remove_XSS($_REQUEST['formatType']))
: 'text';
// Get the document data from the ID
$document_info = DocumentManager::get_document_data_by_id(
$document_id,
@ -491,8 +503,7 @@ switch ($action) {
true,
$session_id
);
$file = $sys_course_path.$courseInfo['directory'].
'/document'.$document_info['path'];
$file = $sys_course_path.$courseInfo['directory'].'/document'.$document_info['path'];
$fileInfo = pathinfo($file);
if ($fileInfo['extension'] == $formatTarget) {
Display::addFlash(Display::return_message(
@ -503,18 +514,13 @@ switch ($action) {
!(
in_array(
$fileInfo['extension'],
DocumentManager::getJodconverterExtensionList(
'from',
$formatType
)
DocumentManager::getJodconverterExtensionList('from', $formatType)
)
) || !(
)
|| !(
in_array(
$formatTarget,
DocumentManager::getJodconverterExtensionList(
'to',
$formatType
)
DocumentManager::getJodconverterExtensionList('to', $formatType)
)
)
) {
@ -523,9 +529,9 @@ switch ($action) {
'warning'
));
} else {
$convertedFile = $fileInfo['dirname'].DIRECTORY_SEPARATOR.
$fileInfo['filename'].'_from_'.$fileInfo['extension'].
'.'.$formatTarget;
$convertedFile = $fileInfo['dirname'].DIRECTORY_SEPARATOR
.$fileInfo['filename'].'_from_'.$fileInfo['extension']
.'.'.$formatTarget;
$convertedTitle = $document_info['title'];
$obj = new OpenofficePresentation(true);
if (file_exists($convertedFile)) {
@ -550,8 +556,10 @@ switch ($action) {
$gidReq = Security::remove_XSS($_GET['gidReq']);
$file_link = Display::url(
get_lang('SeeFile'),
api_get_path(WEB_CODE_PATH).
'document/showinframes.php?'.api_get_cidreq_params($cidReq, $id_session, $gidReq).'&id='.current($result)
api_get_path(WEB_CODE_PATH)
.'document/showinframes.php?'
.api_get_cidreq_params($cidReq, $id_session, $gidReq)
.'&id='.current($result)
);
Display::addFlash(Display::return_message(
get_lang('CopyMade').' '.$file_link,
@ -677,10 +685,10 @@ if (!$parent_id) {
$current_folder_id = $document_id;
// Show preview
if (isset($_GET['curdirpath']) &&
$_GET['curdirpath'] == '/certificates' &&
isset($_GET['set_preview']) &&
$_GET['set_preview'] == strval(intval($_GET['set_preview']))
if (
isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates'
&& isset($_GET['set_preview'])
&& $_GET['set_preview'] == strval(intval($_GET['set_preview']))
) {
if (isset($_GET['set_preview'])) {
// Generate document HTML
@ -772,12 +780,12 @@ function convertModal (id, format) {
$("." + format + "FormatType").show();
$("#convertSelect").change(function() {
var formatTarget = $(this).val();
window.location.href = "'.
api_get_self().'?'.api_get_cidreq().
'&curdirpath='.$curdirpath.
'&action=convertToPdf&formatTarget='.
'" + formatTarget + "&id=" + id + "&'.
api_get_cidreq().'&formatType=" + format;
window.location.href = "'
.api_get_self().'?'.api_get_cidreq()
.'&curdirpath='.$curdirpath
.'&action=convertToPdf&formatTarget='
.'" + formatTarget + "&id=" + id + "&'
.api_get_cidreq().'&formatType=" + format;
});
$("#convertModal").on("hidden", function(){
$("." + format + "FormatType").hide();
@ -796,7 +804,10 @@ if ($groupId != 0 && $curdirpath == '/') {
//if (!$isAllowedToEdit || api_is_coach()) { before
if (!$isAllowedToEdit && api_is_coach()) {
if ($curdirpath != '/' && !(DocumentManager::is_visible($curdirpath, $courseInfo, $sessionId, 'folder'))) {
if (
$curdirpath != '/'
&& !(DocumentManager::is_visible($curdirpath, $courseInfo, $sessionId, 'folder'))
) {
api_not_allowed(true);
}
}
@ -887,12 +898,21 @@ $_SESSION['image_files_only'] = '';
$image_files_only = '';
if ($is_certificate_mode) {
$interbreadcrumb[] = array('url' => '../gradebook/index.php', 'name' => get_lang('Gradebook'));
$interbreadcrumb[] = array(
'url' => '../gradebook/index.php',
'name' => get_lang('Gradebook')
);
} else {
if ((isset($_GET['id']) && $_GET['id'] != 0) || isset($_GET['curdirpath']) || isset($_GET['createdir'])) {
$interbreadcrumb[] = array('url' => 'document.php', 'name' => get_lang('Documents'));
$interbreadcrumb[] = array(
'url' => 'document.php',
'name' => get_lang('Documents')
);
} else {
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Documents'));
$interbreadcrumb[] = array(
'url' => '#',
'name' => get_lang('Documents')
);
}
}
@ -904,7 +924,10 @@ if (empty($document_data['parents'])) {
'name' => $document_data['title'],
);
} else {
$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
$interbreadcrumb[] = array(
'url' => '#',
'name' => $document_data['title']
);
}
} else {
$counter = 0;
@ -933,8 +956,10 @@ if (isset($_GET['createdir'])) {
$js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/';
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/chamilo/jplayer.blue.monday.css" type="text/css">';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>';
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.$js_path
.'jquery-jplayer/skin/chamilo/jplayer.blue.monday.css" type="text/css">';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.$js_path
.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>';
$mediaplayer_path = api_get_path(WEB_LIBRARY_PATH).'mediaplayer/player.swf';
$documentAndFolders = DocumentManager::get_all_document_data(
@ -983,7 +1008,8 @@ if (!empty($documentAndFolders)) {
$extension = 'oga';
}
$params = array('url' => $document_data['direct_url'],
$params = array(
'url' => $document_data['direct_url'],
'extension' => $extension,
'count' => $count
);
@ -994,12 +1020,14 @@ if (!empty($documentAndFolders)) {
}
}
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
//Experimental changes to preview mp3, ogg files
'.$jquery.'
});
</script>';
$htmlHeadXtra[] = '
<script>
$(document).ready( function() {
//Experimental changes to preview mp3, ogg files'
.$jquery.'
});
</script>
';
// Lib for event log, stats & tracking & record of the access
Event::event_access_tool(TOOL_DOCUMENT);
@ -1013,10 +1041,10 @@ $moveForm = '';
/* MOVE FILE OR DIRECTORY */
//Only teacher and all users into their group and each user into his/her shared folder
if ($isAllowedToEdit ||
$group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId)
if (
$isAllowedToEdit || $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId)
) {
if (isset($_GET['move']) && $_GET['move'] != '') {
$my_get_move = intval($_REQUEST['move']);
@ -1051,8 +1079,9 @@ if ($isAllowedToEdit ||
);
// filter if is my shared folder. TODO: move this code to build_move_to_selector function
if (DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) &&
!$isAllowedToEdit
if (
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
&& !$isAllowedToEdit
) {
//only main user shared folder
$main_user_shared_folder_main = '/shared_folder/sf_user_'.api_get_user_id();
@ -1060,7 +1089,10 @@ if ($isAllowedToEdit ||
$user_shared_folders = array();
foreach ($folders as $fold) {
if ($main_user_shared_folder_main == $fold || preg_match($main_user_shared_folder_sub, $fold)) {
if (
$main_user_shared_folder_main == $fold
|| preg_match($main_user_shared_folder_sub, $fold)
) {
$user_shared_folders[] = $fold;
}
}
@ -1176,9 +1208,9 @@ if ($isAllowedToEdit ||
/* DELETE FILE OR DIRECTORY */
//Only teacher and all users into their group
if ($isAllowedToEdit ||
$group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
if (
$isAllowedToEdit || $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) {
if (isset($_POST['action']) && isset($_POST['ids'])) {
$files = $_POST['ids'];
@ -1214,7 +1246,10 @@ if ($isAllowedToEdit ||
null,
$sessionId
)) {
$messages .= Display::return_message(get_lang('VisibilityChanged').': '.$data['title'], 'confirmation');
$messages .= Display::return_message(
get_lang('VisibilityChanged').': '.$data['title'],
'confirmation'
);
} else {
$messages .= Display::return_message(get_lang('ViModProb'), 'error');
}
@ -1233,7 +1268,10 @@ if ($isAllowedToEdit ||
null,
$sessionId
)) {
$messages .= Display::return_message(get_lang('VisibilityChanged').': '.$data['title'], 'confirmation');
$messages .= Display::return_message(
get_lang('VisibilityChanged').': '.$data['title'],
'confirmation'
);
} else {
$messages .= Display::return_message(get_lang('ViModProb'), 'error');
}
@ -1246,13 +1284,14 @@ if ($isAllowedToEdit ||
foreach ($files as $id) {
if (!$isAllowedToEdit) {
if (DocumentManager::check_readonly(
$courseInfo,
api_get_user_id(),
null,
$id,
false,
$sessionId
)) {
$courseInfo,
api_get_user_id(),
null,
$id,
false,
$sessionId
)
) {
$messages .= Display::return_message(
get_lang('CantDeleteReadonlyFiles'),
'error'
@ -1293,9 +1332,9 @@ $dirForm = '';
/* CREATE DIRECTORY */
//Only teacher and all users into their group and any user into his/her shared folder
if ($isAllowedToEdit ||
$group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
if (
$isAllowedToEdit || $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) {
// Create directory with $_POST data
if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
@ -1369,8 +1408,9 @@ if ($isAllowedToEdit ||
/* VISIBILITY COMMANDS */
if ($isAllowedToEdit) {
if ((isset($_GET['set_invisible']) && !empty($_GET['set_invisible'])) ||
(isset($_GET['set_visible']) && !empty($_GET['set_visible']))
if (
(isset($_GET['set_invisible']) && !empty($_GET['set_invisible']))
|| (isset($_GET['set_visible']) && !empty($_GET['set_visible']))
) {
// Make visible or invisible?
if (isset($_GET['set_visible'])) {
@ -1423,35 +1463,38 @@ $templateForm = '';
/* TEMPLATE ACTION */
//Only teacher and all users into their group
if ($isAllowedToEdit ||
$group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
if (
$isAllowedToEdit || $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) {
if (isset($_GET['add_as_template']) && !isset($_POST['create_template'])) {
$document_id_for_template = intval($_GET['add_as_template']);
// Create the form that asks for the directory name
$templateForm .= '
<form name="set_document_as_new_template" class="form-horizontal" enctype="multipart/form-data" action="' . api_get_self().'?add_as_template='.$document_id_for_template.'" method="post">
<form name="set_document_as_new_template" class="form-horizontal" enctype="multipart/form-data"
action="'.api_get_self().'?add_as_template='.$document_id_for_template.'" method="post">
<fieldset>
<legend>' . get_lang('AddAsTemplate').'</legend>
<legend>'.get_lang('AddAsTemplate').'</legend>
<div class="form-group">
<label for="template_title" class="col-sm-2 control-label">' . get_lang('TemplateName').'</label>
<label for="template_title" class="col-sm-2 control-label">'.get_lang('TemplateName').'</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="template_title" name="template_title">
</div>
</div>
<div class="form-group">
<label for="template_image" class="col-sm-2 control-label">' . get_lang('TemplateImage').'</label>
<label for="template_image" class="col-sm-2 control-label">'.get_lang('TemplateImage').'</label>
<div class="col-sm-10">
<input type="file" name="template_image" id="template_image">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" name="create_template" class="btn btn-primary">' . get_lang('CreateTemplate').'</button>
<button type="submit" name="create_template" class="btn btn-primary">'
.get_lang('CreateTemplate').'
</button>
</div>
</div>
<input type="hidden" name="curdirpath" value="' . $curdirpath.'" />
<input type="hidden" name="curdirpath" value="'.$curdirpath.'" />
</fieldset>
</form>
<hr>
@ -1475,10 +1518,11 @@ if ($isAllowedToEdit ||
if ($upload_ok) {
// Try to add an extension to the file if it hasn't one
$new_file_name = $courseInfo['code'].'-'.add_ext_on_mime(
stripslashes($_FILES['template_image']['name']),
$_FILES['template_image']['type']
);
$new_file_name = $courseInfo['code'].'-'
.add_ext_on_mime(
stripslashes($_FILES['template_image']['name']),
$_FILES['template_image']['type']
);
// Upload dir
$upload_dir = api_get_path(SYS_COURSE_PATH).$courseInfo['directory'].'/upload/template_thumbnails/';
@ -1526,10 +1570,10 @@ if ($isAllowedToEdit ||
// END ACTION MENU
// Attach certificate in the gradebook
if (isset($_GET['curdirpath']) &&
$_GET['curdirpath'] == '/certificates' &&
isset($_GET['set_certificate']) &&
$_GET['set_certificate'] == strval(intval($_GET['set_certificate']))
if (
isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates'
&& isset($_GET['set_certificate'])
&& $_GET['set_certificate'] == strval(intval($_GET['set_certificate']))
) {
if (isset($_GET['cidReq'])) {
$course_id = Security::remove_XSS($_GET['cidReq']); // course id
@ -1596,7 +1640,10 @@ $btngroup = array('class' => 'btn btn-default');
/* GO TO PARENT DIRECTORY */
$actionsLeft = '';
if ($curdirpath != '/' && $curdirpath != $group_properties['directory'] && !$is_certificate_mode) {
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>';
@ -1611,17 +1658,19 @@ if ($is_certificate_mode && $curdirpath != '/certificates') {
$column_show = array();
if ($isAllowedToEdit ||
$group_member_with_upload_rights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
if (
$isAllowedToEdit || $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) {
// TODO:check enable more options for shared folders
/* CREATE NEW DOCUMENT OR NEW DIRECTORY / GO TO UPLOAD / DOWNLOAD ZIPPED FOLDER */
// Create new document
if (!$is_certificate_mode) {
$actionsLeft .= Display::url(
Display::return_icon('new_document.png', get_lang('CreateDoc'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/create_document.php?'.api_get_cidreq().'&id='.$document_id
Display::return_icon('new_document.png', get_lang('CreateDoc'), '',
ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/create_document.php?'
.api_get_cidreq().'&id='.$document_id
);
// Create new draw
@ -1632,22 +1681,29 @@ if ($isAllowedToEdit ||
api_get_path(WEB_CODE_PATH).'document/create_draw.php?'.api_get_cidreq().'&id='.$document_id
);
} else {
$actionsLeft .= Display::return_icon('new_draw_na.png', get_lang('BrowserDontSupportsSVG'), '', ICON_SIZE_MEDIUM);
$actionsLeft .= Display::return_icon(
'new_draw_na.png',
get_lang('BrowserDontSupportsSVG'),
'',
ICON_SIZE_MEDIUM
);
}
}
// Create new paint
if (api_get_setting('enabled_support_pixlr') == 'true') {
$actionsLeft .= Display::url(
Display::return_icon('new_paint.png', get_lang('PhotoRetouching'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/create_paint.php?'.api_get_cidreq().'&id='.$document_id
Display::return_icon('new_paint.png',
get_lang('PhotoRetouching'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/create_paint.php?'
.api_get_cidreq().'&id='.$document_id
);
}
// Record an image clip from my webcam
if (api_get_setting('enable_webcam_clip') == 'true') {
$actionsLeft .= Display::url(
Display::return_icon('webcam.png', get_lang('WebCamClip'), '', ICON_SIZE_MEDIUM),
Display::return_icon('webcam.png', get_lang('WebCamClip'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/webcam_clip.php?'.api_get_cidreq().'&id='.$document_id
);
}
@ -1672,15 +1728,22 @@ if ($isAllowedToEdit ||
// Create new certificate
if ($is_certificate_mode) {
$actionsLeft .= Display::url(
Display::return_icon('new_certificate.png', get_lang('CreateCertificate'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/create_document.php?'.api_get_cidreq().'&id='.$document_id.'&certificate=true&selectcat='.$selectcat
Display::return_icon('new_certificate.png',
get_lang('CreateCertificate'),
'',
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH).'document/create_document.php?'
.api_get_cidreq().'&id='.$document_id.'&certificate=true&selectcat='
.$selectcat
);
}
// File upload link
if ($is_certificate_mode) {
$actionsLeft .= Display::url(
Display::return_icon('upload_certificate.png', get_lang('UploadCertificate'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/upload.php?'.api_get_cidreq().'&id='.$current_folder_id.'&certificate=true'
api_get_path(WEB_CODE_PATH).'document/upload.php?'.api_get_cidreq()
.'&id='.$current_folder_id.'&certificate=true'
);
} else {
$actionsLeft .= Display::url(
@ -1753,7 +1816,6 @@ $userIsSubscribed = CourseManager::is_user_subscribed_in_course(
$courseInfo['code']
);
$getSizeURL = api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=get_dir_size&'.api_get_cidreq();
if (isset($documentAndFolders) && is_array($documentAndFolders)) {
@ -1809,8 +1871,9 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
false,
false
);
$user_link = '<div class="document_owner">'.
get_lang('Owner').': '.UserManager::getUserProfileLink($userInfo).'</div>';
$user_link = '<div class="document_owner">'
.get_lang('Owner').': '.UserManager::getUserProfileLink($userInfo)
.'</div>';
}
}
@ -1827,8 +1890,9 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$path_info = pathinfo($document_data['path']);
if (isset($path_info['extension']) &&
in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))
if (
isset($path_info['extension'])
&& in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))
) {
$count++;
}
@ -1847,13 +1911,14 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
);
// Document title with link
$row[] = $link.$session_img.'<br />'.$invisibility_span_open.
'<i>'.nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)).'</i>'.
$invisibility_span_close.
$user_link;
$row[] = $link.$session_img.'<br />'.$invisibility_span_open.'<i>'
.nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset))
.'</i>'.$invisibility_span_close.$user_link;
if ($document_data['filetype'] == 'folder') {
$displaySize = '<span id="document_size_'.$document_data['id'].'" data-path= "'.$document_data['path'].'" class="document_size"></span>';
$displaySize = '<span id="document_size_'.$document_data['id']
.'" data-path= "'.$document_data['path']
.'" class="document_size"></span>';
} else {
$displaySize = format_file_size($document_data['size']);
}
@ -1871,10 +1936,11 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$row[] = $invisibility_span_open.$display_date.$invisibility_span_close;
// Admins get an edit column
if ($isAllowedToEdit ||
$groupMemberWithEditRights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) ||
$document_data['insert_user_id'] == api_get_user_id()
if (
$isAllowedToEdit
|| $groupMemberWithEditRights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
|| $document_data['insert_user_id'] == api_get_user_id()
) {
$is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
@ -1910,9 +1976,10 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
$countedPaths[$document_data['path']] = true;
}
if ((isset($_GET['keyword']) &&
DocumentManager::search_keyword($document_name, $_GET['keyword'])) ||
!isset($_GET['keyword']) || empty($_GET['keyword'])
if (
(isset($_GET['keyword']) && DocumentManager::search_keyword($document_name, $_GET['keyword']))
|| !isset($_GET['keyword'])
|| empty($_GET['keyword'])
) {
$sortable_data[] = $row;
}
@ -1926,13 +1993,15 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
if (!is_null($documentAndFolders)) {
// Show download zipped folder icon
if (!$is_certificate_mode && $total_size != 0
&& (api_get_setting('students_download_folders') == 'true'
|| $isAllowedToEdit
|| api_is_platform_admin()
&& (
api_get_setting('students_download_folders') == 'true'
|| $isAllowedToEdit
|| api_is_platform_admin()
)
) {
//for student does not show icon into other shared folder, and does not show into main path (root)
if (DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
if (
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
&& $curdirpath != '/'
|| $isAllowedToEdit
|| api_is_platform_admin()
@ -1944,7 +2013,8 @@ if (!is_null($documentAndFolders)) {
'',
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&action=downloadfolder&id='.$document_id
api_get_path(WEB_CODE_PATH).'document/document.php?'
.api_get_cidreq().'&action=downloadfolder&id='.$document_id
);
}
}
@ -1977,9 +2047,7 @@ if (!$is_certificate_mode && !isset($_GET['move'])) {
);
}
if (($isAllowedToEdit || $group_member_with_upload_rights) &&
count($documentAndFolders) > 1
) {
if (($isAllowedToEdit || $group_member_with_upload_rights) && count($documentAndFolders) > 1) {
$column_show[] = 1;
}
@ -1988,7 +2056,8 @@ $column_show[] = 1;
$column_show[] = 1;
$column_show[] = 1;
if ($isAllowedToEdit
if (
$isAllowedToEdit
|| $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) {
@ -2039,7 +2108,10 @@ $table->set_additional_parameters($query_vars);
$column = 0;
if (($isAllowedToEdit || $group_member_with_upload_rights) && count($documentAndFolders) > 1) {
if (
($isAllowedToEdit || $group_member_with_upload_rights)
&& count($documentAndFolders) > 1
) {
$table->set_header($column++, '', false, array('style' => 'width:12px;'));
}
$table->set_header($column++, get_lang('Type'), true, array('style' => 'width:30px;'));
@ -2047,9 +2119,11 @@ $table->set_header($column++, get_lang('Name'));
$table->set_header($column++, get_lang('Size'), true, array('style' => 'width:50px;'));
$table->set_header($column++, get_lang('Date'), true, array('style' => 'width:150px;'));
// Admins get an edit column
if ($isAllowedToEdit
if (
$isAllowedToEdit
|| $group_member_with_upload_rights
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) {
|| DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)
) {
$table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions'));
}
@ -2127,40 +2201,41 @@ echo '
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="text-align: center;">
<button type="button" class="close" data-dismiss="modal" aria-label="' . get_lang('Close').'">
<button type="button" class="close" data-dismiss="modal" aria-label="'.get_lang('Close').'">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">' . get_lang('Convert').'</h4>
<h4 class="modal-title">'.get_lang('Convert').'</h4>
</div>
<div class="modal-body">
<form action="#" class="form-horizontal">
<div class="form-group">
<label class="col-sm-4 control-label" for="convertSelect">' . get_lang('ConvertFormats').'</label>
<div class="col-sm-8">
<select id="convertSelect">
<option value="">' . get_lang('Select').'</option>
<option value="pdf">
<form action="#" class="form-horizontal">
<div class="form-group">
<label class="col-sm-4 control-label" for="convertSelect">'.get_lang('ConvertFormats').'</label>
<div class="col-sm-8">
<select id="convertSelect">
<option value="">'.get_lang('Select').'</option>
<option value="pdf">
PDF - Portable Document File
</option>
<option value="odt" style="display:none;" class="textFormatType">
</option>
<option value="odt" style="display:none;" class="textFormatType">
ODT - Open Document Text
</option>
<option value="odp" style="display:none;" class="presentationFormatType">
</option>
<option value="odp" style="display:none;" class="presentationFormatType">
ODP - Open Document Portable
</option>
<option value="ods" style="display:none;" class="spreadsheetFormatType">
</option>
<option value="ods" style="display:none;" class="spreadsheetFormatType">
ODS - Open Document Spreadsheet
</option>
</select>
</div>
</div>
</form>
</option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">' . get_lang('Close').'</button>
<button type="button" class="btn btn-default" data-dismiss="modal">'.get_lang('Close').'</button>
</div>
</div>
</div>';
</div>
';
// Footer
Display::display_footer();

@ -2870,6 +2870,16 @@ class DocumentManager
$pdfOrientation = 'P';
}
$pdf = new PDF($pageFormat, $pdfOrientation);
if (api_get_configuration_value('use_alternative_document_pdf_footer')) {
$view = new Template('', false, false, false, true, false, false);
$template = $view->get_template('export/alt_pdf_footer.tpl');
$pdf->set_custom_footer([
'html' => $view->fetch($template)
]);
}
$pdf->html_to_pdf(
$file_path,
$document_data['title'],

@ -379,3 +379,7 @@ $_configuration['agenda_legend'] = [
//$_configuration['allow_edit_tool_visibility_in_session'] = false;
// Enable the support to ODF files
//$_configuration['enabled_support_odf'] = true;
// Pdf orientation when exporting documents
// $_configuration['document_pdf_orientation'] = 'landscape'; // It can be 'portrait' or 'landscape'
// Use alternative footer when exporting document to PDF
//$_configuration['use_alternative_document_pdf_footer'] = false;

@ -0,0 +1,9 @@
<table border="0" class="full-width border-top page-footer">
<tr>
<td class="text-center">
<strong>{{ _s.institution }}</strong>
<br>
<strong>{PAGENO} / {nb}</strong>
</td>
</tr>
</table>
Loading…
Cancel
Save