Actualización

This commit is contained in:
Xes
2025-04-10 12:49:05 +02:00
parent 4aff98e77b
commit 1cdd00920f
9151 changed files with 1800913 additions and 0 deletions

BIN
main/document/Wami.swf Normal file

Binary file not shown.

190
main/document/add_link.php Normal file
View File

@@ -0,0 +1,190 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script allows to add cloud file links to the document structure.
*
* @package chamilo.document
*/
require_once __DIR__.'/../inc/global.inc.php';
$fileLinkEnabled = api_get_configuration_value('enable_add_file_link');
if (!$fileLinkEnabled) {
api_not_allowed(true);
}
api_protect_course_script();
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
api_not_allowed(true);
}
$documentId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$dir = '/';
$document_data = DocumentManager::get_document_data_by_id($documentId, api_get_course_id(), true);
if (empty($document_data)) {
$document_id = $parent_id = 0;
$path = '/';
} else {
if ($document_data['filetype'] == 'folder') {
$document_id = $document_data['id'];
$path = $document_data['path'].'/';
$parent_id = DocumentManager::get_document_id(api_get_course_info(), dirname($path));
}
$dir = dirname($document_data['path']);
}
$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
if ($is_certificate_mode) {
api_not_allowed(true);
}
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$groupIid = 0;
if (api_get_group_id()) {
// If the group id is set, check if the user has the right to be here
// Get group info
$group_properties = GroupManager::get_group_properties(api_get_group_id());
if ($is_allowed_to_edit || GroupManager::is_user_in_group(api_get_user_id(), $group_properties)) {
// Only courseadmin or group members allowed
$groupIid = $group_properties['iid'];
$interbreadcrumb[] = [
'url' => '../group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace'),
];
} else {
api_not_allowed(true);
}
} elseif ($is_allowed_to_edit || DocumentManager::is_my_shared_folder(api_get_user_id(), $path, api_get_session_id())) {
// Admin for "regular" upload, no group documents. And check if is my shared folder
} else { // No course admin and no group member...
api_not_allowed(true);
}
// Group docs can only be uploaded in the group directory
if ($groupIid != 0 && $path == '/') {
$path = $group_properties['directory']."/";
}
// Breadcrumbs
$interbreadcrumb[] = [
'url' => './document.php?id='.$document_id.'&'.api_get_cidreq(),
'name' => get_lang('Documents'),
];
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
// Hack in order to not add the document to the breadcrumb in case it is a link
if ($document_data && $document_data['filetype'] != 'link') {
$interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
}
} else {
foreach ($document_data['parents'] as $document_sub_data) {
// Hack in order to not add the document to the breadcrumb in case it is a link
if ($document_data['filetype'] != 'link') {
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'],
'name' => $document_sub_data['title'],
];
}
}
}
$this_section = SECTION_COURSES;
$nameTools = get_lang('LinkAdd');
$action = api_get_self().'?'.api_get_cidreq().'&id='.$document_id;
// URLs in whitelist
$urlWL = DocumentManager::getFileHostingWhiteList();
sort($urlWL);
$urlWLRegEx = '/(\/\/|\.)('.implode('|', $urlWL).')/i'; //Matches any of the whitelisted urls preceded by // or .
$urlWLText = "\n\t* ".implode("\n\t* ", $urlWL);
$urlWLHTML = "<ul><li>".implode("</li><li>", $urlWL)."</li></ul>";
$form = new FormValidator('upload', 'POST', $action, '', ['enctype' => 'multipart/form-data']);
$form->addHidden('linkid', $document_id);
$form->addHidden('curdirpath', $path);
$form->addElement('text', 'name', get_lang('LinkName'), ['id' => 'name_link']);
$form->addElement('text', 'url', get_lang('Url'), ['id' => 'url_link']);
$form->addElement(
'static',
'info',
'',
'<span class="text-primary" data-toggle="tooltip" title="'.$urlWLHTML.'">'.get_lang(
'ValidDomainList'
).' <span class="glyphicon glyphicon-question-sign"></span></span>'
);
$form->addButtonSend(get_lang('AddCloudLink'), 'submitDocument');
$form->addRule('name', get_lang('PleaseEnterCloudLinkName'), 'required', null, 'client');
$form->addRule('name', get_lang('PleaseEnterCloudLinkName'), 'required', null, 'server');
$form->addRule('url', get_lang('PleaseEnterURL'), 'required', null, 'client');
$form->addRule('url', get_lang('PleaseEnterURL'), 'required', null, 'server');
// Well formed url pattern (must have the protocol)
$urlRegEx = DocumentManager::getWellFormedUrlRegex();
$form->addRule('url', get_lang('NotValidURL'), 'regex', $urlRegEx, 'client');
$form->addRule('url', get_lang('NotValidURL'), 'regex', $urlRegEx, 'server');
$form->addRule('url', get_lang('NotValidDomain').$urlWLText, 'regex', $urlWLRegEx, 'client');
$form->addRule('url', get_lang('NotValidDomain').$urlWLHTML, 'regex', $urlWLRegEx, 'server');
if ($form->validate()) {
if (isset($_REQUEST['linkid'])) {
$doc_id = DocumentManager::addCloudLink($courseInfo, $path, $_REQUEST['url'], $_REQUEST['name']);
if ($doc_id) {
Display::addFlash(Display::return_message(get_lang('CloudLinkAdded'), 'success', false));
} else {
if (DocumentManager::cloudLinkExists($courseInfo, $path, $_REQUEST['url'])) {
Display::addFlash(Display::return_message(get_lang('UrlAlreadyExists'), 'warning', false));
} else {
Display::addFlash(Display::return_message(get_lang('ErrorAddCloudLink'), 'warning', false));
}
}
header('Location: document.php?'.api_get_cidreq().'&id='.$documentId);
exit;
}
}
// Display the header
Display::display_header($nameTools, 'Doc');
// Actions
echo '<div class="actions">';
// Link back to the documents overview
echo '<a href="document.php?id='.$document_id.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).
'</a>';
echo '</div>';
// Form to select directory
$folders = DocumentManager::get_all_document_folders(
$_course,
$groupIid,
$is_allowed_to_edit
);
echo DocumentManager::build_directory_selector(
$folders,
$document_id,
isset($group_properties['directory']) ? $group_properties['directory'] : []
);
// Add tooltip and correctly parse its inner HTML
echo '<script>
$(function() {
$("[data-toggle=\'tooltip\']").tooltip({
content:
function() {
return $(this).attr("title");
}
});
});
</script>';
echo $form->returnForm();
Display::display_footer();

View File

@@ -0,0 +1,354 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows creating audio files from a text.
*
* @package chamilo.document
*
* @author Juan Carlos Raña Trabado
*
* @since 8/January/2011
* TODO:clean all file
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$nameTools = get_lang('CreateAudio');
api_protect_course_script();
api_block_anonymous_users();
$groupRights = Session::read('group_member_with_upload_rights');
$groupId = api_get_group_id();
if (api_get_setting('enabled_text2audio') === 'false') {
api_not_allowed(true);
}
$requestId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
$document_data = DocumentManager::get_document_data_by_id(
$requestId,
api_get_course_id()
);
if (empty($document_data)) {
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties(
$groupId
);
$document_id = DocumentManager::get_document_id(
api_get_course_info(),
$group_properties['directory']
);
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
api_get_course_id()
);
}
}
$document_id = $document_data['id'];
$dir = $document_data['path'];
//jquery textareaCounter
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/textareacounter/jquery.textareaCounter.plugin.js" type="text/javascript"></script>';
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
// Please, do not modify this dirname formatting
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
//groups //TODO: clean
if (!empty($groupId)) {
$interbreadcrumb[] = [
"url" => "../group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace'),
];
$group = GroupManager::get_group_properties($groupId);
$path = explode('/', $dir);
if ('/'.$path[1] != $group['directory']) {
api_not_allowed(true);
}
}
$interbreadcrumb[] = [
"url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
"name" => get_lang('Documents'),
];
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
}
if (!($is_allowed_to_edit || $groupRights ||
DocumentManager::is_my_shared_folder(
api_get_user_id(),
Security::remove_XSS($dir),
api_get_session_id()
))
) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
if (isset($group)) {
$display_dir = explode('/', $dir);
unset($display_dir[0]);
unset($display_dir[1]);
$display_dir = implode('/', $display_dir);
}
// Copied from document.php
$dir_array = explode('/', $dir);
$array_len = count($dir_array);
$dir_acum = '';
for ($i = 0; $i < $array_len; $i++) {
$url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
//Max char 80
$url_to_who = cut($dir_array[$i], 80);
$interbreadcrumb[] = ['url' => $url_dir, 'name' => $url_to_who];
$dir_acum .= $dir_array[$i].'/';
}
$service = isset($_GET['service']) ? $_GET['service'] : 'google';
if (isset($_POST['text2voice_mode']) && $_POST['text2voice_mode'] == 'google') {
downloadAudioGoogle($filepath, $dir);
}
Display::display_header($nameTools, 'Doc');
echo '<div class="actions">';
echo '<a href="document.php?id='.$document_id.'">';
echo Display::return_icon(
'back.png',
get_lang('BackTo').' '.get_lang('DocumentsOverview'),
'',
ICON_SIZE_MEDIUM
);
echo '</a>';
echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&service=google">'.
Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
?>
<!-- javascript and styles for textareaCounter-->
<script>
var info;
$(function() {
var options = {
'maxCharacterSize': 100,
'originalStyle': 'originalTextareaInfo',
'warningStyle': 'warningTextareaInfo',
'warningNumber': 20,
'displayFormat': '#input/#max'
};
$('#textarea_google').textareaCount(options, function (data) {
$('#textareaCallBack').html(data);
});
});
</script>
<style>
.overview {
background: #FFEC9D;
padding: 10px;
width: 90%;
border: 1px solid #CCCCCC;
}
.originalTextareaInfo {
font-size: 12px;
color: #000000;
text-align: right;
}
.warningTextareaInfo {
color: #FF0000;
font-weight: bold;
text-align: right;
}
#showData {
height: 70px;
width: 200px;
border: 1px solid #CCCCCC;
padding: 10px;
margin: 10px;
}
</style>
<div id="textareaCallBack"></div>
<?php
$tbl_admin_languages = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$sql_select = "SELECT * FROM $tbl_admin_languages";
$result_select = Database::query($sql_select);
$options = $options_pedia = [];
$selected_language = null;
while ($row = Database::fetch_array($result_select)) {
$options[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
if (in_array($row['isocode'], ['de', 'en', 'es', 'fr'])) {
$options_pedia[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
}
}
if ($service == 'google') {
$selected_language = api_get_language_isocode(); //lang default is the course language
$form = new FormValidator('form1', 'post', api_get_self().'?'.api_get_cidreq(), '', ['id' => 'form1']);
$form->addHeader(get_lang('HelpText2Audio'));
$form->addElement('hidden', 'text2voice_mode', 'google');
$form->addElement('hidden', 'id', $document_id);
$form->addElement('text', 'title', get_lang('Title'));
$form->addElement('select', 'lang', get_lang('Language'), $options);
$form->addElement('textarea', 'text', get_lang('InsertText2Audio'), ['id' => 'textarea_google']);
$form->addButtonSave(get_lang('SaveMP3'));
$defaults = [];
$defaults['lang'] = $selected_language;
$form->setDefaults($defaults);
$form->display();
}
Display::display_footer();
/**
* This function save a post into a file mp3 from google services.
*
* @param $filepath
* @param $dir
*
* @author Juan Carlos Raña Trabado <herodoto@telefonica.net>
*
* @version january 2011, chamilo 1.8.8
*/
function downloadAudioGoogle($filepath, $dir)
{
$location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&service=google';
//security
if (!isset($_POST['lang']) && !isset($_POST['text']) &&
!isset($_POST['title']) && !isset($filepath) && !isset($dir)
) {
echo '<script>window.location.href="'.$location.'"</script>';
return;
}
$_course = api_get_course_info();
$_user = api_get_user_info();
$clean_title = trim($_POST['title']);
$clean_text = trim($_POST['text']);
if (empty($clean_title) || empty($clean_text)) {
echo '<script>window.location.href="'.$location.'"</script>';
return;
}
$clean_title = Security::remove_XSS($clean_title);
$clean_title = Database::escape_string($clean_title);
$clean_title = str_replace(' ', '_', $clean_title); //compound file names
$clean_text = Security::remove_XSS($clean_text);
$clean_lang = Security::remove_XSS($_POST['lang']);
$extension = 'mp3';
$audio_filename = $clean_title.'.'.$extension;
$audio_title = str_replace('_', ' ', $clean_title);
//prevent duplicates
if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
$i = 1;
while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
$i++;
}
$audio_filename = $clean_title.'_'.$i.'.'.$extension;
$audio_title = $clean_title.'_'.$i.'.'.$extension;
$audio_title = str_replace('_', ' ', $audio_title);
}
$documentPath = $filepath.'/'.$audio_filename;
$clean_text = api_replace_dangerous_char($clean_text);
// adding the file
// add new file to disk
$proxySettings = api_get_configuration_value('proxy_settings');
$key = api_get_configuration_value('translate_app_google_key');
$url = "https://www.googleapis.com/language/translate/v2?key=$key&".$clean_lang."&target=$clean_lang&q=".urlencode($clean_text)."";
if (empty($proxySettings)) {
$content = @file_get_contents($url);
} else {
if (!empty($proxySettings['stream_context_create'])) {
$context = stream_context_create($proxySettings['stream_context_create']);
} else {
$context = stream_context_create();
}
$content = file_get_contents($url, false, $context);
}
if (empty($content)) {
Display::addFlash(Display::return_message(get_lang('GoogleTranslateApiReturnedEmptyAnswer'), 'error'));
return;
}
file_put_contents(
$documentPath,
$content
);
// add document to database
$current_session_id = api_get_session_id();
$groupId = api_get_group_id();
$groupInfo = GroupManager::get_group_properties($groupId);
$relativeUrlPath = $dir;
$doc_id = add_document(
$_course,
$relativeUrlPath.$audio_filename,
'file',
filesize($documentPath),
$audio_title
);
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'DocumentAdded',
$_user['user_id'],
$groupInfo,
null,
null,
null,
$current_session_id
);
echo Display::return_message(get_lang('DocumentCreated'), 'confirm');
echo '<script>window.location.href="'.$location.'"</script>';
}

View File

@@ -0,0 +1,682 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows creating new html documents with an online WYSIWYG html editor.
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
api_protect_course_group(GroupManager::GROUP_TOOL_DOCUMENTS);
$this_section = SECTION_COURSES;
$groupRights = Session::read('group_member_with_upload_rights');
$htmlHeadXtra[] = '
<script>
$(function() {
$(".scrollbar-light").scrollbar();
expandColumnToogle("#hide_bar_template", {
selector: "#template_col",
width: 3
}, {
selector: "#doc_form",
width: 9
});
CKEDITOR.on("instanceReady", function (e) {
showTemplates();
e.editor.on("beforeCommandExec", function (event) {
if (event.data.name == "save") {
$("#create_document").append("<input type=hidden name=button_ck value=1 />");
}
});
});
});
$(document).on("change", ".selectpicker", function () {
var dirValue = $(this).val();
$.ajax({
contentType: "application/x-www-form-urlencoded",
data: "dirValue="+dirValue,
url: "'.api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_destination",
type: "POST",
success: function(response) {
$("[name=\'dirValue\']").val(response)
}
});
});
function setFocus() {
$("#document_title").focus();
}
$(window).on("load", function () {
setFocus();
});
</script>';
//I'm in the certification module?
$is_certificate_mode = false;
if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] === 'true') {
$is_certificate_mode = true;
}
$nameTools = get_lang('CreateDocument');
if ($is_certificate_mode) {
$nameTools = get_lang('CreateCertificate');
}
/* Constants and variables */
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
$course_id = api_get_course_int_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$userId = api_get_user_id();
$_course = api_get_course_info();
$groupId = api_get_group_id();
$document_data = [];
if (isset($_REQUEST['id'])) {
$document_data = DocumentManager::get_document_data_by_id(
$_REQUEST['id'],
$courseCode,
true,
0
);
}
if (!empty($sessionId) && empty($document_data)) {
$document_data = DocumentManager::get_document_data_by_id(
$_REQUEST['id'],
$courseCode,
true,
$sessionId
);
}
$groupIid = 0;
$group_properties = [];
if (!empty($groupId)) {
$group_properties = GroupManager::get_group_properties($groupId);
$groupIid = $group_properties['iid'];
}
if (empty($document_data)) {
$dir = '/';
$folder_id = 0;
if (api_is_in_group()) {
$document_id = DocumentManager::get_document_id($_course, $group_properties['directory']);
$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
$dir = $document_data['path'];
$folder_id = $document_data['id'];
}
} else {
$folder_id = $document_data['id'];
$dir = $document_data['path'];
}
// Please, do not modify this dirname formatting
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
if ($is_certificate_mode) {
$document_id = DocumentManager::get_document_id(
api_get_course_info(),
'/certificates'
);
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
api_get_course_id(),
true
);
$folder_id = $document_data['id'];
$dir = '/certificates/';
}
$doc_tree = explode('/', $dir);
$count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are 2 "/"
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties(api_get_group_id());
// Level correction for group documents.
if (!empty($group_properties['directory'])) {
$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
}
}
$relative_url = '';
for ($i = 0; $i < ($count_dir); $i++) {
$relative_url .= '../';
}
if ($relative_url == '') {
$relative_url = '/';
}
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$editorConfig = [
'ToolbarSet' => $is_allowed_to_edit ? 'Documents' : 'DocumentsStudent',
'Width' => '100%',
'Height' => '400',
'cols-size' => [2, 10, 0],
'FullPage' => true,
'InDocument' => true,
'CreateDocumentDir' => $relative_url,
'CreateDocumentWebDir' => (empty($group_properties['directory']))
? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
: api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir,
];
if ($is_certificate_mode) {
$editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
$editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
$editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
}
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
if (!$is_certificate_mode) {
if (api_is_in_group()) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace').' '.$group_properties['name'],
];
$path = explode('/', $dir);
if (strcasecmp('/'.$path[1], $group_properties['directory']) !== 0) {
api_not_allowed(true);
}
}
$interbreadcrumb[] = [
"url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
"name" => get_lang('Documents'),
];
} else {
$interbreadcrumb[] = [
'url' => Category::getUrl(),
'name' => get_lang('Gradebook'),
];
}
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
}
if (!($is_allowed_to_edit ||
$groupRights ||
DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id()))
) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
if (isset($group_properties)) {
$display_dir = explode('/', $dir);
unset($display_dir[0]);
unset($display_dir[1]);
$display_dir = implode('/', $display_dir);
}
$select_cat = isset($_REQUEST['selectcat']) ? (int) $_REQUEST['selectcat'] : null;
$curDirPath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
// Create a new form
$form = new FormValidator(
'create_document',
'post',
api_get_self().'?'.api_get_cidreq().'&dir='.Security::remove_XSS(urlencode($dir)).'&selectcat='.$select_cat,
null
);
// form title
$form->addElement('header', $nameTools);
if ($is_certificate_mode) {
//added condition for certicate in gradebook
$form->addElement(
'hidden',
'certificate',
'true',
['id' => 'certificate']
);
if (isset($_GET['selectcat'])) {
$form->addElement('hidden', 'selectcat', $select_cat);
}
}
// Hidden element with current directory
$form->addElement('hidden', 'id');
$defaults = [];
$defaults['id'] = $folder_id;
// Filename
$form->addElement('hidden', 'title_edited', 'false', 'id="title_edited"');
/**
* Check if a document width the chosen filename already exists.
*/
function document_exists($filename)
{
global $dir;
$cleanName = api_replace_dangerous_char($filename);
// No "dangerous" files
$cleanName = disable_dangerous_file($cleanName);
return !DocumentManager::documentExists(
$dir.$cleanName.'.html',
api_get_course_info(),
api_get_session_id(),
api_get_group_id()
);
}
// Add group to the form
if ($is_certificate_mode) {
$form->addText(
'title',
get_lang('CertificateName'),
true,
['cols-size' => [2, 10, 0], 'autofocus']
);
} else {
$form->addText(
'title',
get_lang('Title'),
true,
['cols-size' => [2, 10, 0], 'autofocus']
);
}
// 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->addHtmlEditor(
'content',
get_lang('Content'),
true,
true,
$editorConfig
);
// Comment-field
$folders = DocumentManager::get_all_document_folders(
$_course,
$groupIid,
$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 &&
!DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id)
) {
$folders = DocumentManager::get_all_document_folders(
$_course,
$groupIid,
$is_allowed_to_edit
);
$parent_select = $form->addSelect(
'curdirpath',
get_lang('DestinationDirectory'),
null,
['cols-size' => [2, 10, 0]]
);
$folder_titles = [];
if (is_array($folders)) {
$escaped_folders = [];
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
if (api_get_setting('show_default_folders') == 'false' && ($val == '/images' || $val == '/flash' || $val == '/audio' || $val == '/video' || strstr($val, '/images/gallery') || $val == '/video/flv')) {
continue;
}
// Admin setting for Hide/Show chat history folder
if (api_get_setting('show_chat_folder') == 'false' && $val == '/chat_files') {
continue;
}
$escaped_folders[$key] = Database::escape_string($val);
}
$folder_sql = implode("','", $escaped_folders);
$sql = "SELECT * FROM $doc_table
WHERE
c_id = $course_id AND
filetype = 'folder' AND
path IN ('".$folder_sql."')";
$res = Database::query($sql);
$folder_titles = [];
while ($obj = Database::fetch_object($res)) {
$folder_titles[$obj->path] = Security::remove_XSS($obj->title);
}
}
if (empty($group_dir)) {
$parent_select->addOption(get_lang('HomeDirectory'), '/');
if (is_array($folders)) {
foreach ($folders as &$folder) {
//Hide some folders
if ($folder == '/HotPotatoes_files' || $folder == '/certificates' || basename($folder) == 'css') {
continue;
}
//Admin setting for Hide/Show the folders of all users
if (api_get_setting('show_users_folders') == 'false' &&
(strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_'))
) {
continue;
}
//Admin setting for Hide/Show Default folders to all users
if (api_get_setting('show_default_folders') == 'false' &&
(
$folder == '/images' ||
$folder == '/flash' ||
$folder == '/audio' ||
$folder == '/video' ||
strstr($folder, '/images/gallery') ||
$folder == '/video/flv'
)
) {
continue;
}
//Admin setting for Hide/Show chat history folder
if (api_get_setting('show_chat_folder') == 'false' &&
$folder == '/chat_files'
) {
continue;
}
$selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
$path_parts = explode('/', $folder);
$folder_titles[$folder] = cut($folder_titles[$folder], 80);
$space_counter = count($path_parts) - 2;
if ($space_counter > 0) {
$label = str_repeat('&nbsp;&nbsp;&nbsp;', $space_counter).' &mdash; '.$folder_titles[$folder];
} else {
$label = ' &mdash; '.$folder_titles[$folder];
}
$parent_select->addOption($label, $folder);
if ($selected != '') {
$parent_select->setSelected($folder);
}
}
}
} else {
if (is_array($folders) && !empty($folders)) {
foreach ($folders as &$folder) {
$selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : '';
$label = $folder_titles[$folder];
if ($folder == $group_dir) {
$label = '/ ('.get_lang('HomeDirectory').')';
} else {
$path_parts = explode('/', str_replace($group_dir, '', $folder));
$label = cut($label, 80);
$label = str_repeat('&nbsp;&nbsp;&nbsp;', count($path_parts) - 2).' &mdash; '.$label;
}
$parent_select->addOption($label, $folder);
if ($selected != '') {
$parent_select->setSelected($folder);
}
}
}
}
}
$form->addHidden('dirValue', '');
if ($is_certificate_mode) {
$form->addButtonCreate(get_lang('CreateCertificate'));
} else {
$form->addButtonCreate(get_lang('CreateDoc'));
}
$form->setDefaults($defaults);
// If form validates -> save the new document
if ($form->validate()) {
$values = $form->exportValues();
$readonly = isset($values['readonly']) ? 1 : 0;
$values['title'] = trim($values['title']);
if (!empty($values['dirValue'])) {
$dir = $values['dirValue'];
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
$filepath = $filepath.$dir;
// Setting the filename
$filename = $values['title'];
$filename = addslashes(trim($filename));
$filename = Security::remove_XSS($filename);
$filename = api_replace_dangerous_char($filename);
$filename = disable_dangerous_file($filename);
$filename .= DocumentManager::getDocumentSuffix(
$_course,
api_get_session_id(),
api_get_group_id()
);
// Setting the title
$title = $values['title'];
$extension = 'html';
$content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY);
// Don't create file with the same name.
if (file_exists($filepath.$filename.'.'.$extension)) {
Display::addFlash(Display::return_message(get_lang('FileExists').' '.$title, 'error', false));
Display::display_header($nameTools, 'Doc');
Display::display_footer();
exit;
}
if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) {
$content = str_replace(
api_get_path(WEB_COURSE_PATH),
api_get_configuration_value('url_append').api_get_path(REL_COURSE_PATH),
$content
);
fputs($fp, $content);
fclose($fp);
chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files());
$file_size = filesize($filepath.$filename.'.'.$extension);
$save_file_path = $dir.$filename.'.'.$extension;
$document_id = add_document(
$_course,
$save_file_path,
'file',
$file_size,
$title,
null,
$readonly
);
if ($document_id) {
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$document_id,
'DocumentAdded',
$userId,
$group_properties,
null,
null,
null,
$current_session_id
);
// Update parent folders
item_property_update_on_folder($_course, $dir, $userId);
$new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';
$new_title = isset($_POST['title']) ? trim($_POST['title']) : '';
$new_title = htmlspecialchars($new_title);
if ($new_comment || $new_title) {
$ct = '';
$params = [];
if ($new_comment) {
$params['comment'] = $new_comment;
}
if ($new_title) {
$params['title'] = $new_title;
}
if (!empty($params)) {
Database::update(
$doc_table,
$params,
['c_id = ? AND id = ?' => [$course_id, $document_id]]
);
}
}
$dir = substr($dir, 0, -1);
$selectcat = '';
if (isset($_REQUEST['selectcat'])) {
$selectcat = "&selectcat=".intval($_REQUEST['selectcat']);
}
$certificate_condition = '';
if ($is_certificate_mode) {
$df = DocumentManager::get_default_certificate_id($_course['code']);
if (!isset($df)) {
DocumentManager::attach_gradebook_certificate($_course['code'], $document_id);
}
$certificate_condition = '&certificate=true&curdirpath=/certificates';
}
Display::addFlash(Display::return_message(get_lang('ItemAdded')));
$url = 'document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition;
$redirectToEditPage = isset($_POST['button_ck']) && 1 === (int) $_POST['button_ck'];
if ($redirectToEditPage) {
$url = 'edit_document.php?'.api_get_cidreq().'&id='.$document_id.$selectcat.$certificate_condition;
}
header('Location: '.$url);
exit();
} else {
Display::addFlash(Display::return_message(get_lang('Impossible'), 'error'));
Display::display_header($nameTools, 'Doc');
Display::display_footer();
}
} else {
Display::addFlash(Display::return_message(get_lang('Impossible'), 'error'));
Display::display_header($nameTools, 'Doc');
Display::display_footer();
}
} else {
// Copied from document.php
$dir_array = explode('/', $dir);
$array_len = count($dir_array);
// Breadcrumb for the current directory root path
if (!empty($document_data)) {
if (empty($document_data['parents'])) {
$interbreadcrumb[] = [
'url' => '#',
'name' => $document_data['title'],
];
} else {
foreach ($document_data['parents'] as $document_sub_data) {
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'],
'name' => $document_sub_data['title'],
];
}
}
}
Display::display_header($nameTools, "Doc");
// link back to the documents overview
if ($is_certificate_mode) {
$actionsLeft = '<a href="document.php?'.api_get_cidreq().'&certificate=true&id='.$folder_id.'&selectcat='.$select_cat.'">'.
Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.
Display::return_icon('expand.png', get_lang('Back'), ['id' => 'expand'], ICON_SIZE_MEDIUM).
Display::return_icon('contract.png', get_lang('Back'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
} else {
$actionsLeft = '<a href="document.php?'.api_get_cidreq().'&curdirpath='.Security::remove_XSS($dir).'">'.
Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.
Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).
Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
}
echo $toolbar = Display::toolbarAction('actions-documents', [$actionsLeft]);
if ($is_certificate_mode) {
$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
api_get_user_id(),
api_get_course_id(),
api_get_session_id()
);
$str_info = '';
foreach ($all_information_by_create_certificate[0] as $info_value) {
$str_info .= $info_value.'<br/>';
}
$create_certificate = get_lang('CreateCertificateWithTags');
echo Display::return_message($create_certificate.': <br /><br/>'.$str_info, 'normal', false);
}
// HTML-editor
echo '<div class="page-create">
<div class="row" style="overflow:hidden">
<div id="template_col" class="col-md-3">
<div class="panel panel-default">
<div class="panel-body">
<div id="frmModel" class="items-templates scrollbar-light"></div>
</div>
</div>
</div>
<div id="doc_form" class="col-md-9">
'.$form->returnForm().'
</div>
</div></div>';
Display::display_footer();
}

View File

@@ -0,0 +1,172 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows creating new svg and png documents with an online editor.
*
* @author Juan Carlos Raña Trabado
*
* @since 25/september/2010
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$groupRights = Session::read('group_member_with_upload_rights');
$nameTools = get_lang('Draw');
api_protect_course_script();
api_block_anonymous_users();
api_protect_course_group(GroupManager::GROUP_TOOL_DOCUMENTS);
$document_data = DocumentManager::get_document_data_by_id(
$_GET['id'],
api_get_course_id(),
true
);
if (empty($document_data)) {
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties(
api_get_group_id()
);
$document_id = DocumentManager::get_document_id(
api_get_course_info(),
$group_properties['directory']
);
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
api_get_course_id()
);
}
}
$document_id = $document_data['id'];
$dir = $document_data['path'];
// path for svg-edit save
Session::write('draw_dir', Security::remove_XSS($dir));
if ($dir == '/') {
Session::write('draw_dir', '');
}
$dir = isset($dir) ? Security::remove_XSS($dir) : (isset($_POST['dir']) ? Security::remove_XSS($_POST['dir']) : '/');
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
// Please, do not modify this dirname formatting
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
$groupId = api_get_group_id();
if (!empty($groupId)) {
$interbreadcrumb[] = [
"url" => "../group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace'),
];
$group = GroupManager::get_group_properties($groupId);
$path = explode('/', $dir);
if ('/'.$path[1] != $group['directory']) {
api_not_allowed(true);
}
}
$interbreadcrumb[] = [
"url" => "./document.php?".api_get_cidreq(),
"name" => get_lang('Documents'),
];
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
}
if (!($is_allowed_to_edit || $groupRights ||
DocumentManager::is_my_shared_folder(
api_get_user_id(),
Security::remove_XSS($dir),
api_get_session_id()
))
) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
if (isset($group)) {
$display_dir = explode('/', $dir);
unset($display_dir[0]);
unset($display_dir[1]);
$display_dir = implode('/', $display_dir);
}
// Interbreadcrumb for the current directory root path
// Copied from document.php
$dir_array = explode('/', $dir);
$array_len = count($dir_array);
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
} else {
foreach ($document_data['parents'] as $document_sub_data) {
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'],
'name' => $document_sub_data['title'],
];
}
}
Display::display_header($nameTools, 'Doc');
echo '<div class="actions">';
echo '<a href="document.php?id='.$document_id.'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
if (api_browser_support('svg')) {
// Automatic loading the course language
$translationList = ['' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'];
$langsvgedit = api_get_language_isocode();
$langsvgedit = isset($translationList[$langsvgedit]) ? $translationList[$langsvgedit] : $langsvgedit;
$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?'.api_get_cidreq().'&lang='.$langsvgedit; ?>
<script>
document.write('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
function resizeIframe() {
var height = window.innerHeight -50;
// max lower size
if (height<550) {
height=550;
}
document.getElementById('frame').style.height = height +"px";
}
document.getElementById('frame').onload = resizeIframe;
window.onresize = resizeIframe;
</script>
<?php
echo '<noscript>';
echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="'.$svg_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
echo '</noscript>';
} else {
echo Display::return_message(get_lang('BrowserDontSupportsSVG'), 'error');
}
Display::display_footer();

View File

@@ -0,0 +1,190 @@
<?php
/* For licensing terms, see /license.txt */
exit;
use ChamiloSession as Session;
/**
* This file allows creating audio files from a text.
*
* @package chamilo.document
*
* @author Juan Carlos Raña Trabado
*
* @since 30/January/2011
*
* @todo clean all file
*/
require_once __DIR__.'/../inc/global.inc.php';
if (api_get_setting('enabled_support_paint') === 'false') {
api_not_allowed(true);
}
$this_section = SECTION_COURSES;
$nameTools = get_lang('PhotoRetouching');
$groupRights = Session::read('group_member_with_upload_rights');
api_protect_course_script();
api_block_anonymous_users();
$_course = api_get_course_info();
$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
if (empty($document_data)) {
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties(api_get_group_id());
$document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
}
}
$document_id = $document_data['id'];
$dir = $document_data['path'];
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
// path for pixlr save
$paintDir = Security::remove_XSS($dir);
if (empty($paintDir)) {
$paintDir = '/';
}
Session::write('paint_dir', $paintDir);
Session::write('paint_file', get_lang('NewImage'));
// Please, do not modify this dirname formatting
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
$groupId = api_get_group_id();
if (!empty($groupId)) {
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace'),
];
$group = GroupManager::get_group_properties($groupId);
$path = explode('/', $dir);
if ('/'.$path[1] != $group['directory']) {
api_not_allowed(true);
}
}
$interbreadcrumb[] = [
"url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
"name" => get_lang('Documents'),
];
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
}
if (!($is_allowed_to_edit || $groupRights ||
DocumentManager::is_my_shared_folder($_user['user_id'], Security::remove_XSS($dir), api_get_session_id()))
) {
api_not_allowed(true);
}
/* Header */
Event::event_access_tool(TOOL_DOCUMENT);
$display_dir = $dir;
if (isset($group)) {
$display_dir = explode('/', $dir);
unset($display_dir[0]);
unset($display_dir[1]);
$display_dir = implode('/', $display_dir);
}
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
} else {
foreach ($document_data['parents'] as $document_sub_data) {
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'],
'name' => $document_sub_data['title'],
];
}
}
Display::display_header($nameTools, 'Doc');
echo '<div class="actions">';
echo '<a href="document.php?id='.$document_id.'">'.
Display::return_icon(
'back.png',
get_lang('BackTo').' '.get_lang('DocumentsOverview'),
'',
ICON_SIZE_MEDIUM
).
'</a>';
echo '</div>';
// pixlr
// max size 1 Mb ??
$title = urlencode(utf8_encode(get_lang('NewImage'))); //TODO:check
$image = Display::returnIconPath('canvas1024x768.png');
$exit_path = api_get_path(WEB_CODE_PATH).'document/exit_pixlr.php';
Session::write('exit_pixlr', $document_data['path']);
$target_path = api_get_path(WEB_CODE_PATH).'document/save_pixlr.php';
$target = $target_path;
$locktarget = 'true';
$locktitle = 'false';
$referrer = 'Chamilo';
if ($_SERVER['HTTP_HOST'] == "localhost") {
$path_and_file = api_get_path(SYS_PATH).'/crossdomain.xml';
if (!file_exists($path_and_file)) {
$crossdomain = '<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="cdn.pixlr.com" />
<site-control permitted-cross-domain-policies="master-only"/>
<allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/>
</cross-domain-policy>'; //more open domain="*"
@file_put_contents($path_and_file, $crossdomain);
}
$credentials = 'true';
} else {
$credentials = 'false';
}
$pixlr_url = '//pixlr.com/editor/?title='.$title.'&image='.$image.'&referrer='.$referrer.'&target='.$target.'&exit='.$exit_path.'&locktarget='.$locktarget.'&locktitle='.$locktitle.'&credentials='.$credentials;
?>
<script>
document.write('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $pixlr_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe></div>');
function resizeIframe() {
var height = window.innerHeight;
//max lower size
if (height<600) {
height=600;
}
document.getElementById('frame').style.height = height +"px";
};
document.getElementById('frame').onload = resizeIframe;
window.onresize = resizeIframe;
</script>
<?php
echo '<noscript>';
echo '<iframe style="height: 600px; width: 100%;" scrolling="no" frameborder="0" src="'.$pixlr_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
echo '</noscript>';
Display::display_footer();

2342
main/document/document.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,150 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Document quota management script.
*
* @package chamilo.document
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
if (!api_is_allowed_to_edit(null, true)) {
api_not_allowed(true);
}
$current_course_tool = TOOL_DOCUMENT;
$this_section = SECTION_COURSES;
$tool_name = get_lang('DocumentQuota');
$interbreadcrumb[] = ['url' => 'document.php', 'name' => get_lang('Documents')];
$htmlHeadXtra[] = api_get_js('jqplot/jquery.jqplot.js');
$htmlHeadXtra[] = api_get_js('jqplot/plugins/jqplot.pieRenderer.js');
$htmlHeadXtra[] = api_get_js('jqplot/plugins/jqplot.donutRenderer.js');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/jqplot/jquery.jqplot.css');
$course_code = api_get_course_id();
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$user_id = api_get_user_id();
$user_info = api_get_user_info($user_id);
$session = [];
$user_name = $user_info['complete_name'];
$course_list = SessionManager::get_course_list_by_session_id($session_id);
$session_list = SessionManager::get_session_by_course($course_id);
$total_quota_bytes = DocumentManager::get_course_quota();
$quota_bytes = DocumentManager::documents_total_space($course_id, 0, 0);
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
$session[] = [get_lang('Course').' ('.format_file_size($quota_bytes).')', $quota_percentage];
$used_quota_bytes = $quota_bytes;
if (!empty($session_list)) {
foreach ($session_list as $session_data) {
$quota_percentage = 0;
$quota_bytes = DocumentManager::documents_total_space($course_id, null, $session_data['id']);
if (!empty($quota_bytes)) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
if ($session_id == $session_data['id']) {
$session_data['name'] = $session_data['name'].' * ';
}
$used_quota_bytes += $quota_bytes;
$session[] = [
addslashes(get_lang('Session').': '.$session_data['name']).' ('.format_file_size($quota_bytes).')',
$quota_percentage,
];
}
}
$group_list = GroupManager::get_groups();
if (!empty($group_list)) {
foreach ($group_list as $group_data) {
$quota_percentage = 0;
$my_group_id = $group_data['id'];
$quota_bytes = DocumentManager::documents_total_space($course_id, $my_group_id, 0);
if (!empty($quota_bytes)) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
if ($group_id == $my_group_id) {
$group_data['name'] = $group_data['name'].' * ';
}
$used_quota_bytes += $quota_bytes;
$session[] = [
addslashes(get_lang('Group').': '.$group_data['name']).' ('.format_file_size($quota_bytes).')',
$quota_percentage,
];
}
}
// Showing weight of documents uploaded by user
$document_list = DocumentManager::getAllDocumentData(api_get_course_info());
if (!empty($document_list)) {
foreach ($document_list as $document_data) {
if ($document_data['insert_user_id'] == api_get_user_id() && $document_data['filetype'] === 'file') {
$quota_bytes += $document_data['size'];
}
}
if ($quota_bytes != 0) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
$session[] = [
addslashes(get_lang('Teacher').': '.$user_name).' ('.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;
if (is_array($course_list) && !empty($course_list)) {
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[] = [addslashes(sprintf(get_lang('TeacherXInSession'), $user_name)), $quota_percentage];
}
}
$quota_percentage = round(($total_quota_bytes - $used_quota_bytes) / $total_quota_bytes, 2) * 100;
$session[] = [
addslashes(get_lang('ShowCourseQuotaUse')).' ('.format_file_size(
$total_quota_bytes - $used_quota_bytes
).') ',
$quota_percentage,
];
$quota_data = json_encode($session);
$htmlHeadXtra[] = "<script>
$(function() {
var data = ".$quota_data.";
var plot1 = jQuery.jqplot('chart1', [data], {
seriesDefaults: {
// Make this a pie chart
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
});
});
</script>";
$tpl = new Template($tool_name);
$content = Display::page_subheader(get_lang('ShowCourseQuotaUse')).'<div id="chart1"></div>';
$tpl->assign('content', $content);
$tpl->display_one_col_template();

View File

@@ -0,0 +1,107 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
* files (since these are the files that can be viewed in a browser) and creates
* a slideshow with it by allowing to go to the next/previous image.
* You can also have a quick overview (thumbnail view) of all the images in
* that particular folder.
*
* Each slideshow is folder based. Only
* the images of the chosen folder are shown.
*
* This file has two large sections.
* 1. code that belongs in document.php, but to avoid clutter I put the code here
* (not present) 2. the function resize_image that handles the image resizing
*
* @author Patrick Cool, responsible author
* @author Roan Embrechts, minor cleanup
*
* @package chamilo.document
*/
/**
* General code that belongs in document.php.
*
* This code should indeed go in documents.php but since document.php is already a really ugly file with
* too much things in one file , I decided to put the code for document.php here and to include this
* file into document.php
*/
// We check if there are images in this folder by searching the extensions for .jpg, .gif, .png
// grabbing the list of all the documents of this folder
$array_to_search = !empty($documentAndFolders) && is_array($documentAndFolders) ? $documentAndFolders : [];
if (count($array_to_search) > 0) {
foreach ($array_to_search as $file) {
$all_files[] = basename($file['path']);
}
}
// Always show gallery.
$image_present = 1;
/*
if (isset($all_files) && is_array($all_files) && count($all_files) > 0) {
foreach ($all_files as & $file) {
$slideshow_extension = strrchr($file, '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension, $accepted_extensions)) {
$image_present = 1;
break;
}
}
}*/
$tablename_column = isset($_GET['tablename_column']) ? Security::remove_XSS($_GET['tablename_column']) : 0;
if ($tablename_column == 0) {
$tablename_column = 1;
} else {
$tablename_column = intval($tablename_column) - 1;
}
$image_files_only = sort_files($array_to_search);
function sort_files($table)
{
$tablename_direction = isset($_GET['tablename_direction']) ? Security::remove_XSS($_GET['tablename_direction']) : 'ASC';
$accepted_extensions = ['.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg'];
$temp = [];
foreach ($table as &$file_array) {
if ($file_array['filetype'] == 'file') {
$slideshow_extension = strrchr($file_array['path'], '.');
$slideshow_extension = strtolower($slideshow_extension);
if (in_array($slideshow_extension, $accepted_extensions)) {
$start_date = isset($file_array['insert_date']) ? $file_array['insert_date'] : null;
$temp[] = ['file', basename($file_array['path']), $file_array['size'], $start_date];
}
}
}
if ($tablename_direction == 'DESC') {
usort($temp, 'rsort_table');
} else {
usort($temp, 'sort_table');
}
$final_array = [];
foreach ($temp as &$file_array) {
$final_array[] = $file_array[1];
}
return $final_array;
}
function sort_table($a, $b)
{
global $tablename_column;
return strnatcmp($a[$tablename_column], $b[$tablename_column]);
}
function rsort_table($a, $b)
{
global $tablename_column;
return strnatcmp($b[$tablename_column], $a[$tablename_column]);
}

129
main/document/download.php Normal file
View File

@@ -0,0 +1,129 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file is responsible for passing requested documents to the browser.
* Many functions updated and moved to lib/document.lib.php.
*/
session_cache_limiter('none');
require_once __DIR__.'/../inc/global-min.inc.php';
$this_section = SECTION_COURSES;
api_protect_course_script();
$_course = api_get_course_info();
if (!isset($_course)) {
api_not_allowed(true);
}
// Change the '&' that got rewritten to '///' by mod_rewrite back to '&'
$doc_url = str_replace('///', '&', $_GET['doc_url']);
// Still a space present? it must be a '+' (that got replaced by mod_rewrite)
$docUrlNoPlus = $doc_url;
$doc_url = str_replace(' ', '+', $doc_url);
$docUrlParts = preg_split('/\/|\\\/', $doc_url);
$doc_url = '';
foreach ($docUrlParts as $docUrlPart) {
if (empty($docUrlPart) || in_array($docUrlPart, ['.', '..', '0'])) {
continue;
}
$doc_url .= '/'.$docUrlPart;
}
if (empty($doc_url)) {
api_not_allowed(!empty($_GET['origin']) && $_GET['origin'] === 'learnpath');
}
// Dealing with image included into survey: when users receive a link towards a
// survey while not being authenticated on the platform.
// The administrator should probably be able to disable this code through admin
// interface.
$refer_script = isset($_SERVER['HTTP_REFERER']) ? strrchr($_SERVER['HTTP_REFERER'], '/') : null;
$sys_course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (substr($refer_script, 0, 15) === '/fillsurvey.php') {
$parts = parse_url($refer_script);
parse_str($parts['query'], $queryParts);
$course = isset($queryParts['course']) ? $queryParts['course'] : '';
$invitation = isset($queryParts['invitationcode']) ? $queryParts['invitationcode'] : '';
include '../survey/survey.download.inc.php';
if ('auto' === $invitation && $queryParts['scode']) {
$invitation = Session::read('auto_invitation_code_'.$queryParts['scode']);
}
$_course = check_download_survey($course, $invitation, $doc_url);
$_course['path'] = $_course['directory'];
} else {
// If the rewrite rule asks for a directory, we redirect to the document explorer
if (is_dir($sys_course_path.$doc_url)) {
// Remove last slash if present
// mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René)
while ($doc_url[$dul = strlen($doc_url) - 1] == '/') {
$doc_url = substr($doc_url, 0, $dul);
}
// Group folder?
$gid_req = ($_GET['gidReq']) ? '&gidReq='.intval($_GET['gidReq']) : '';
// Create the path
$document_explorer = api_get_path(WEB_CODE_PATH).'document/document.php?curdirpath='.urlencode($doc_url).'&'.api_get_cidreq_params(Security::remove_XSS($_GET['cidReq'], 0, $gid_req));
// Redirect
header('Location: '.$document_explorer);
exit;
}
}
//Fixes swf upload problem in chamilo 1.8.x. When uploading a file with
//the character "-" the filename was changed from "-" to "_" in the DB for no reason
$path_info = pathinfo($doc_url);
$fix_file_name = false;
if (isset($path_info['extension']) && $path_info['extension'] === 'swf') {
$fixed_url = str_replace('-', '_', $doc_url);
$doc_id = DocumentManager::get_document_id(api_get_course_info(), $doc_url);
if (!$doc_id) {
$doc_id = DocumentManager::get_document_id(api_get_course_info(), $doc_url, '0');
if (!$doc_id) {
$fix_file_name = true;
}
}
}
// When dealing with old systems or wierd migrations, it might so happen that
// the filename contains spaces, that were replaced above by '+' signs, but
// these '+' signs might not match the real filename. Give files with spaces
// another chance if the '+' version doesn't exist.
if (!is_file($sys_course_path.$doc_url) && is_file($sys_course_path.$docUrlNoPlus)) {
$doc_url = $docUrlNoPlus;
}
if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) {
$fullFileName = $sys_course_path.$doc_url;
if ($fix_file_name) {
$doc_url = $fixed_url;
}
// Check visibility of document and paths
$is_visible = DocumentManager::is_visible($doc_url, $_course, api_get_session_id());
//Document's slideshow thumbnails
//correct $is_visible used in below and ??. Now the students can view the thumbnails too
if (preg_match('/\.thumbs\/\./', $doc_url)) {
$doc_url_thumbs = str_replace('.thumbs/.', '', $doc_url);
$is_visible = DocumentManager::is_visible($doc_url_thumbs, $_course, api_get_session_id());
}
if (!api_is_allowed_to_edit() && !$is_visible) {
echo Display::return_message(get_lang('ProtectedDocument'), 'error'); //api_not_allowed backbutton won't work.
exit; // You shouldn't be here anyway.
}
// Launch event
Event::event_download($doc_url);
$download = !empty($_GET['dl']) ? true : false;
$result = DocumentManager::file_send_for_download($fullFileName, $download);
if ($result === false) {
api_not_allowed(true);
}
}
exit;

View File

@@ -0,0 +1,65 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file is responsible for passing requested documents to the browser.
*
* @package chamilo.document
*/
session_cache_limiter('none');
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
// Protection
api_protect_course_script();
$_course = api_get_course_info();
if (!isset($_course)) {
api_not_allowed(true);
}
/** @var learnpath $obj */
$obj = Session::read('oLP');
// If LP obj exists
if (empty($obj)) {
api_not_allowed();
}
// If is visible for the current user
if (!learnpath::is_lp_visible_for_student($obj->get_id(), api_get_user_id(), $_course)) {
api_not_allowed();
}
$doc_url = isset($_GET['doc_url']) ? $_GET['doc_url'] : null;
// Change the '&' that got rewritten to '///' by mod_rewrite back to '&'
$doc_url = str_replace('///', '&', $doc_url);
// Still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace(['../', '\\..', '\\0', '..\\'], ['', '', '', ''], $doc_url); //echo $doc_url;
if (strpos($doc_url, '../') || strpos($doc_url, '/..')) {
$doc_url = '';
}
$sys_course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/scorm';
if (is_dir($sys_course_path.$doc_url)) {
api_not_allowed();
}
if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) {
$full_file_name = $sys_course_path.$doc_url;
// Launch event
Event::event_download($doc_url);
$fixLinks = api_get_configuration_value('lp_replace_http_to_https');
$result = DocumentManager::file_send_for_download($full_file_name, false, '', $fixLinks);
if ($result === false) {
api_not_allowed(true, get_lang('FileNotFound'), 404);
}
} else {
api_not_allowed(true, get_lang('FileNotFound'), 404);
}

View File

@@ -0,0 +1,38 @@
<?php
/* For licensing terms, see /license.txt */
session_cache_limiter('none');
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
// Protection
api_protect_course_script();
$courseCode = isset($_GET['code']) ? $_GET['code'] : '';
$type = isset($_GET['type']) ? $_GET['type'] : '';
$file = isset($_GET['file']) ? $_GET['file'] : '';
$courseInfo = api_get_course_info($courseCode);
if (empty($courseInfo)) {
$courseInfo = api_get_course_info();
}
$type = preg_replace("/[^a-zA-Z_]+/", '', $type);
if (empty($courseInfo) || empty($type) || empty($file)) {
api_not_allowed(true);
}
$toolPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/upload/'.$type.'/';
if (!is_dir($toolPath)) {
api_not_allowed(true);
}
if (Security::check_abs_path($toolPath.$file, $toolPath.'/')) {
$fullFilePath = $toolPath.$file;
$result = DocumentManager::file_send_for_download($fullFilePath, false, '');
if ($result === false) {
api_not_allowed(true);
}
}
exit;

View File

@@ -0,0 +1,382 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Functions and main code for the download folder feature.
*
* @package chamilo.document
*/
set_time_limit(0);
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
$sysCoursePath = api_get_path(SYS_COURSE_PATH);
$courseInfo = api_get_course_info();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$courseCode = api_get_course_id();
// Check if folder exists in current course.
$documentInfo = DocumentManager::get_document_data_by_id(
$_GET['id'],
$courseCode,
false,
0
);
if (!empty($sessionId)) {
/* If no data found and session id exists
try to look the file inside the session */
if (empty($documentInfo)) {
$documentInfo = DocumentManager::get_document_data_by_id(
$_GET['id'],
$courseCode,
false,
$sessionId
);
}
}
$path = $documentInfo['path'];
if (empty($path)) {
$path = '/';
}
// A student should not be able to download a root shared directory
if (($path == '/shared_folder' ||
$path == '/shared_folder_session_'.api_get_session_id()) &&
(!api_is_allowed_to_edit() || !api_is_platform_admin())
) {
api_not_allowed(true);
exit;
}
// Creating a ZIP file.
$tempZipFile = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
$zip = new PclZip($tempZipFile);
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
$prop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
// We need this path to clean it out of the zip file
// I'm not using dir name as it gives too much problems (cfr.)
$remove_dir = ($path != '/') ? substr($path, 0, strlen($path) - strlen(basename($path))) : '/';
// Put the files in the zip
// 2 possibilities: Admins get all files and folders in the selected folder (except for the deleted ones)
// Normal users get only visible files that are in visible folders
function fixDocumentNameCallback($p_event, &$p_header)
{
global $remove_dir;
$files = Session::read('doc_files_to_download');
$storedFile = $remove_dir.$p_header['stored_filename'];
if (!isset($files[$storedFile])) {
return 0;
}
$documentData = $files[$storedFile];
$documentNameFixed = DocumentManager::undoFixDocumentName(
$documentData['path'],
$documentData['c_id'],
$documentData['session_id'],
$documentData['to_group_id']
);
// Changes file.phps to file.php
$basename = basename($documentNameFixed);
$basenamePHPFixed = str_replace('.phps', '.php', $basename);
$documentNameFixed = str_replace(
$basename,
$basenamePHPFixed,
$documentNameFixed
);
if ($remove_dir != '/') {
$documentNameFixed = str_replace($remove_dir, '/', $documentNameFixed);
if (substr($documentNameFixed, 0, 1) == '/') {
$documentNameFixed = substr($documentNameFixed, 1, api_strlen($documentNameFixed));
}
} else {
$documentNameFixed = ltrim($documentNameFixed, '/');
}
$p_header['stored_filename'] = $documentNameFixed;
return 1;
}
$groupJoin = '';
if (!empty($groupId)) {
$table = Database::get_course_table(TABLE_GROUP);
$groupJoin = " INNER JOIN $table g ON (g.iid = props.to_group_id AND g.c_id = docs.c_id)";
$groupCondition = " g.id = ".$groupId;
} else {
$groupCondition = " (props.to_group_id = 0 OR props.to_group_id IS NULL ) ";
}
$userIsSubscribed = CourseManager::is_user_subscribed_in_course(
api_get_user_id(),
$courseInfo['code']
);
$filesToZip = [];
// Admins are allowed to download invisible files
if (api_is_allowed_to_edit()) {
// Set the path that will be used in the query
if ($path == '/') {
$querypath = ''; // To prevent ...path LIKE '//%'... in query
} else {
$querypath = $path;
}
$querypath = Database::escape_string($querypath);
// Search for all files that are not deleted => visibility != 2
$sql = "SELECT
path,
docs.session_id,
docs.id,
props.to_group_id,
docs.c_id
FROM $doc_table AS docs
INNER JOIN $prop_table AS props
ON
docs.id = props.ref AND
docs.c_id = props.c_id
$groupJoin
WHERE
props.tool ='".TOOL_DOCUMENT."' AND
docs.path LIKE '".$querypath."/%' AND
docs.filetype = 'file' AND
props.visibility <> '2' AND
$groupCondition AND
(props.session_id IN ('0', '$sessionId') OR props.session_id IS NULL) AND
docs.c_id = ".$courseId." ";
$sql .= DocumentManager::getSessionFolderFilters($querypath, $sessionId);
$result = Database::query($sql);
$files = [];
while ($row = Database::fetch_array($result)) {
$files[$row['path']] = $row;
}
Session::write('doc_files_to_download', $files);
foreach ($files as $not_deleted_file) {
// Filtering folders and
if (strpos($not_deleted_file['path'], 'chat_files') > 0 ||
strpos($not_deleted_file['path'], 'shared_folder') > 0
) {
if (!empty($sessionId)) {
if ($not_deleted_file['session_id'] != $sessionId) {
continue;
}
}
}
$filesToZip[] = $sysCoursePath.$courseInfo['path'].'/document'.$not_deleted_file['path'];
}
$zip->add(
$filesToZip,
PCLZIP_OPT_REMOVE_PATH,
$sysCoursePath.$courseInfo['path'].'/document'.$remove_dir,
PCLZIP_CB_PRE_ADD,
'fixDocumentNameCallback'
);
Session::erase('doc_files_to_download');
} else {
// For other users, we need to create a zip file with only visible files and folders
if ($path == '/') {
$querypath = ''; // To prevent ...path LIKE '//%'... in query
} else {
$querypath = $path;
}
/* A big problem: Visible files that are in a hidden folder are
included when we do a query for visibility='v'
So... I do it in a couple of steps:
1st: Get all files that are visible in the given path
*/
$querypath = Database::escape_string($querypath);
$sql = "SELECT path, docs.session_id, docs.id, props.to_group_id, docs.c_id
FROM $doc_table AS docs
INNER JOIN $prop_table AS props
ON
docs.id = props.ref AND
docs.c_id = props.c_id
$groupJoin
WHERE
docs.c_id = $courseId AND
props.tool = '".TOOL_DOCUMENT."' AND
docs.path LIKE '".$querypath."/%' AND
docs.filetype = 'file' AND
(props.session_id IN ('0', '$sessionId') OR props.session_id IS NULL) AND
$groupCondition
";
$sql .= DocumentManager::getSessionFolderFilters($querypath, $sessionId);
$result = Database::query($sql);
$files = [];
$all_visible_files_path = [];
// Add them to an array
while ($all_visible_files = Database::fetch_assoc($result)) {
if (strpos($all_visible_files['path'], 'chat_files') > 0 ||
strpos($all_visible_files['path'], 'shared_folder') > 0
) {
if (!empty($sessionId)) {
if ($all_visible_files['session_id'] != $sessionId) {
continue;
}
}
}
$isVisible = DocumentManager::is_visible_by_id(
$all_visible_files['id'],
$courseInfo,
api_get_session_id(),
api_get_user_id(),
false,
$userIsSubscribed
);
if (!$isVisible) {
continue;
}
$all_visible_files_path[] = $all_visible_files['path'];
$files[$all_visible_files['path']] = $all_visible_files;
}
// 2nd: Get all folders that are invisible in the given path
$sql = "SELECT path, docs.session_id, docs.id, props.to_group_id, docs.c_id
FROM $doc_table AS docs
INNER JOIN $prop_table AS props
ON
docs.id = props.ref AND
docs.c_id = props.c_id
WHERE
docs.c_id = $courseId AND
props.tool = '".TOOL_DOCUMENT."' AND
docs.path LIKE '".$querypath."/%' AND
props.visibility <> '1' AND
(props.session_id IN ('0', '$sessionId') OR props.session_id IS NULL) AND
docs.filetype = 'folder'";
$query2 = Database::query($sql);
// If we get invisible folders, we have to filter out these results from all visible files we found
if (Database::num_rows($query2) > 0) {
//$files = [];
// Add item to an array
while ($invisible_folders = Database::fetch_assoc($query2)) {
//3rd: Get all files that are in the found invisible folder (these are "invisible" too)
$sql = "SELECT path, docs.id, props.to_group_id, docs.c_id
FROM $doc_table AS docs
INNER JOIN $prop_table AS props
ON
docs.id = props.ref AND
docs.c_id = props.c_id
WHERE
docs.c_id = $courseId AND
props.tool ='".TOOL_DOCUMENT."' AND
docs.path LIKE '".$invisible_folders['path']."/%' AND
docs.filetype = 'file' AND
(props.session_id IN ('0', '$sessionId') OR props.session_id IS NULL)
";
$query3 = Database::query($sql);
// Add tem to an array
while ($files_in_invisible_folder = Database::fetch_assoc($query3)) {
$isVisible = DocumentManager::is_visible_by_id(
$files_in_invisible_folder['id'],
$courseInfo,
api_get_session_id(),
api_get_user_id(),
false,
$userIsSubscribed
);
if (!$isVisible) {
continue;
}
$files_in_invisible_folder_path[] = $files_in_invisible_folder['path'];
$files[$files_in_invisible_folder['path']] = $files_in_invisible_folder;
}
}
// Compare the array with visible files and the array with files in invisible folders
// and keep the difference (= all visible files that are not in an invisible folder)
$files_for_zipfile = diff(
(array) $all_visible_files_path,
(array) $files_in_invisible_folder_path
);
} else {
// No invisible folders found, so all visible files can be added to the zipfile
$files_for_zipfile = $all_visible_files_path;
}
Session::write('doc_files_to_download', $files);
// Add all files in our final array to the zipfile
for ($i = 0; $i < count($files_for_zipfile); $i++) {
$filesToZip[] = $sysCoursePath.$courseInfo['path'].'/document'.$files_for_zipfile[$i];
}
$zip->add(
$filesToZip,
PCLZIP_OPT_REMOVE_PATH,
$sysCoursePath.$courseInfo['path'].'/document'.$remove_dir,
PCLZIP_CB_PRE_ADD,
'fixDocumentNameCallback'
);
Session::erase('doc_files_to_download');
}
// Launch event
Event::event_download(
($path == '/') ? 'documents.zip (folder)' : basename($path).'.zip (folder)'
);
// Start download of created file
$name = ($path == '/') ? 'documents.zip' : $documentInfo['title'].'.zip';
if (Security::check_abs_path($tempZipFile, api_get_path(SYS_ARCHIVE_PATH))) {
$result = DocumentManager::file_send_for_download($tempZipFile, true, $name);
if ($result === false) {
api_not_allowed(true);
}
@unlink($tempZipFile);
exit;
} else {
api_not_allowed(true);
}
/**
* Returns the difference between two arrays, as an array of those key/values
* Use this as array_diff doesn't give the.
*
* @param array $arr1 first array
* @param array $arr2 second array
*
* @return array difference between the two arrays
*/
function diff($arr1, $arr2)
{
$res = [];
$r = 0;
foreach ($arr1 as &$av) {
if (!in_array($av, $arr2)) {
$res[$r] = $av;
$r++;
}
}
return $res;
}

View File

@@ -0,0 +1,623 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows editing documents.
*
* Based on create_document, this file allows
* - edit name
* - edit comments
* - edit metadata (requires a document table entry)
* - edit html content (only for htm/html files)
*
* For all files
* - show editable name field
* - show editable comments field
* Additionally, for html and text files
* - show RTE
*
* Remember, all files and folders must always have an entry in the
* database, regardless of wether they are visible/invisible, have
* comments or not.
*
* @package chamilo.document
*
* @todo improve script structure (FormValidator is used to display form, but
* not for validation at the moment)
*/
require_once __DIR__.'/../inc/global.inc.php';
$groupRights = Session::read('group_member_with_upload_rights');
// Template's javascript
$htmlHeadXtra[] = '
<script>
$(function() {
$(".scrollbar-light").scrollbar();
expandColumnToogle("#hide_bar_template", {
selector: "#template_col",
width: 3
}, {
selector: "#doc_form",
width: 9
});
CKEDITOR.on("instanceReady", function (e) {
showTemplates();
e.editor.on("beforeCommandExec", function (event) {
if (event.data.name == "save") {
$("#formEdit").append("<input type=hidden name=button_ck value=1 />");
}
});
});
});
</script>';
$this_section = SECTION_COURSES;
$lib_path = api_get_path(LIBRARY_PATH);
$course_info = api_get_course_info();
$group_id = api_get_group_id();
$sessionId = api_get_session_id();
$dir = '/';
$currentDirPath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
$readonly = false;
if (isset($_GET['id'])) {
$document_data = DocumentManager::get_document_data_by_id(
$_GET['id'],
api_get_course_id(),
true,
0
);
if (!empty($sessionId) && empty($document_data)) {
$document_data = DocumentManager::get_document_data_by_id(
$_REQUEST['id'],
api_get_course_id(),
true,
$sessionId
);
}
$document_id = $document_data['id'];
$file = $document_data['path'];
$parent_id = DocumentManager::get_document_id($course_info, dirname($file));
$dir = dirname($document_data['path']);
$dir_original = $dir;
$doc = basename($file);
$readonly = $document_data['readonly'];
$file_type = $document_data['filetype'];
}
if (empty($document_data)) {
api_not_allowed(true);
}
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties($group_id);
}
$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
//Call from
$call_from_tool = api_get_origin();
$slide_id = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
$file_name = $doc;
$group_document = false;
$_course = api_get_course_info();
$sessionId = api_get_session_id();
$user_id = api_get_user_id();
$doc_tree = explode('/', $file);
$count_dir = count($doc_tree) - 2; // "2" because at the begin and end there are 2 "/"
// Level correction for group documents.
if (!empty($group_properties['directory'])) {
$count_dir = $count_dir > 0 ? $count_dir - 1 : 0;
}
$relative_url = '';
for ($i = 0; $i < ($count_dir); $i++) {
$relative_url .= '../';
}
$editorConfig = [
'ToolbarSet' => (api_is_allowed_to_edit(null, true) ? 'Documents' : 'DocumentsStudent'),
'Width' => '100%',
'Height' => '400',
'cols-size' => [2, 10, 0],
'FullPage' => true,
'InDocument' => true,
'CreateDocumentDir' => $relative_url,
'CreateDocumentWebDir' => (empty($group_properties['directory']))
? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'
: api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/',
'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir,
];
if ($is_certificate_mode) {
$editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
$editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/';
$editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
}
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $groupRights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId);
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
$course_id = api_get_course_int_id();
if (!empty($group_id)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace'),
];
$group_document = true;
}
if (!$is_certificate_mode) {
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."document/document.php?curdirpath=".urlencode($currentDirPath).'&'.api_get_cidreq(),
"name" => get_lang('Documents'),
];
} else {
$interbreadcrumb[] = [
'url' => Category::getUrl(),
'name' => get_lang('Gradebook'),
];
}
if (empty($document_data['parents'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
} else {
foreach ($document_data['parents'] as $document_sub_data) {
if ($document_data['title'] == $document_sub_data['title']) {
continue;
}
$interbreadcrumb[] = ['url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']];
}
}
if (!($is_allowed_to_edit ||
$groupRights ||
DocumentManager::is_my_shared_folder($user_id, $dir, api_get_session_id()))
) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
//TODO:check the below code and his funcionality
if (!api_is_allowed_to_edit()) {
if (DocumentManager::check_readonly($course_info, $user_id, $file)) {
api_not_allowed();
}
}
$document_info = api_get_item_property_info(
api_get_course_int_id(),
'document',
$document_id,
0
);
// Try to find this document in the session
if (!empty($sessionId)) {
$document_info = api_get_item_property_info(
api_get_course_int_id(),
'document',
$document_id,
$sessionId
);
}
if (api_is_in_group()) {
$group_properties = GroupManager::get_group_properties($group_id);
GroupManager::allowUploadEditDocument(
api_get_user_id(),
api_get_course_int_id(),
$group_properties,
$document_info,
true
);
}
/* MAIN TOOL CODE */
/* Code to change the comment */
if (isset($_POST['comment'])) {
// Fixing the path if it is wrong
$comment = trim($_POST['comment']);
$title = trim($_POST['title']);
// Just in case see BT#3525
if (empty($title)) {
$title = $document_data['title'];
}
if (empty($title)) {
$title = get_document_title($_POST['filename']);
}
if (!empty($document_id)) {
$linkExists = false;
if ($file_type == 'link') {
$linkExists = DocumentManager::cloudLinkExists($course_info, $file, $_POST['comment']);
}
if (!$linkExists || $linkExists == $document_id) {
$params = [
'comment' => $comment,
'title' => $title,
];
Database::update(
$dbTable,
$params,
['c_id = ? AND id = ?' => [$course_id, $document_id]]
);
if ($file_type != 'link') {
Display::addFlash(Display::return_message(get_lang('fileModified')));
} else {
Display::addFlash(Display::return_message(get_lang('CloudLinkModified')));
}
} else {
Display::addFlash(Display::return_message(get_lang('UrlAlreadyExists'), 'warning'));
}
}
}
/* WYSIWYG HTML EDITOR - Program Logic */
if ($is_allowed_to_edit) {
if (isset($_POST['formSent']) && $_POST['formSent'] == 1 && !empty($document_id)) {
//$content = isset($_POST['content']) ? trim(str_replace(["\r", "\n"], '', stripslashes($_POST['content']))) : null;
$content = isset($_POST['content']) ? trim(stripslashes($_POST['content'])) : null;
$content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
if ($dir == '/') {
$dir = '';
}
$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
$read_only_flag = empty($read_only_flag) ? 0 : 1;
if ($file_type != 'link') {
$file_size = filesize($document_data['absolute_path']);
}
if ($read_only_flag == 0) {
if (!empty($content)) {
if ($fp = @fopen($document_data['absolute_path'], 'w')) {
// For flv player, change absolute path temporarily to prevent
// from erasing it in the following lines
$content = str_replace(['flv=h', 'flv=/'], ['flv=h|', 'flv=/|'], $content);
fputs($fp, $content);
fclose($fp);
$filepath = $document_data['absolute_parent_path'];
update_existing_document(
$_course,
$document_id,
$file_size,
$read_only_flag
);
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$document_id,
'DocumentUpdated',
api_get_user_id(),
null,
null,
null,
null,
$sessionId
);
// Update parent folders
item_property_update_on_folder(
$_course,
$dir,
api_get_user_id()
);
} else {
Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning'));
}
} else {
if ($document_id) {
update_existing_document($_course, $document_id, $file_size, $read_only_flag);
}
}
} else {
if ($document_id) {
update_existing_document($_course, $document_id, $file_size, $read_only_flag);
}
}
// It saves extra fields values
$extraFieldValue = new ExtraFieldValue('document');
$values = $_REQUEST;
$values['item_id'] = $document_id;
$extraFieldValue->saveFieldValues($values);
$url = 'document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : '');
$redirectToEditPage = isset($_POST['button_ck']) && 1 === (int) $_POST['button_ck'];
if ($redirectToEditPage) {
$url = 'edit_document.php?'.api_get_cidreq().'&id='.$document_id.($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : '');
}
header('Location: '.$url);
exit;
}
}
// Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/')
$content = null;
$extension = null;
$filename = null;
if (file_exists($document_data['absolute_path'])) {
$path_info = pathinfo($document_data['absolute_path']);
$filename = $path_info['filename'];
if (is_file($document_data['absolute_path'])) {
$extension = $path_info['extension'];
if (in_array($extension, ['html', 'htm'])) {
$content = file($document_data['absolute_path']);
$content = implode('', $content);
}
}
}
// Display the header
$nameTools = get_lang('EditDocument').': '.Security::remove_XSS($document_data['title']);
Display::display_header($nameTools, 'Doc');
$owner_id = $document_info['insert_user_id'];
$last_edit_date = $document_info['lastedit_date'];
$createdDate = $document_info['insert_date'];
$groupInfo = GroupManager::get_group_properties(api_get_group_id());
if ($owner_id == api_get_user_id() ||
api_is_platform_admin() ||
$is_allowed_to_edit || GroupManager::is_user_in_group(
api_get_user_id(),
$groupInfo
)
) {
$action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq();
if ($is_certificate_mode) {
$action .= '&curdirpath=/certificates&selectcat=1';
}
$form = new FormValidator(
'formEdit',
'post',
$action,
null,
['class' => 'form-vertical']
);
// Form title
$form->addHeader($nameTools);
$key_label_title = $file_type != 'link' ? 'Title' : 'LinkName';
$form->addText(
'title',
get_lang($key_label_title),
true,
['cols-size' => [2, 10, 0], 'autofocus']
);
$defaults['title'] = $document_data['title'];
$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
// Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor.
// This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573
$defaults['content'] = str_replace('<!--[', '<!-- [', $content);
// HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved.
$showSystemFolders = api_get_course_setting('show_system_folders');
$condition = stripos($dir, '/HotPotatoes_files') === false;
if ($showSystemFolders == 1) {
$condition = true;
}
if (($extension == 'htm' || $extension == 'html') && $condition) {
if (empty($readonly) && $readonly == 0) {
$form->addHtmlEditor('content', get_lang('Content'), true, true, $editorConfig);
}
}
if (!empty($createdDate)) {
$form->addLabel(get_lang('CreatedOn'), Display::dateToStringAgoAndLongDate($createdDate));
}
if ($file_type != 'link') {
if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
$form->addLabel(get_lang('UpdatedOn'), Display::dateToStringAgoAndLongDate($last_edit_date));
}
if (!empty($document_info['insert_user_id'])) {
$insertByUserInfo = api_get_user_info($document_info['insert_user_id']);
if (!empty($insertByUserInfo)) {
$form->addLabel(get_lang('Author'), $insertByUserInfo['complete_name_with_message_link']);
}
}
}
if ($file_type == 'link') {
// URLs in whitelist
$urlWL = DocumentManager::getFileHostingWhiteList();
sort($urlWL);
//Matches any of the whitelisted urls preceded by // or .
$urlWLRegEx = '/(\/\/|\.)('.implode('|', $urlWL).')/i';
$urlWLText = "\n\t* ".implode("\n\t* ", $urlWL);
$urlWLHTML = "<ul><li>".implode("</li><li>", $urlWL)."</li></ul>";
$form->addText('comment', get_lang('Url'));
$form->addElement(
'static',
'info',
'',
'<span class="text-primary" data-toggle="tooltip" title="'.$urlWLHTML.'">'.get_lang(
'ValidDomainList'
).' <span class="glyphicon glyphicon-question-sign"></span></span>'
);
} else {
$form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]);
}
$itemId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$extraField = new ExtraField('document');
$extraField->addElements(
$form,
$itemId,
[], //exclude
false, // filter
false, // tag as select
[], //show only fields
[], // order fields
[] // extra data
);
if ($file_type != 'link') {
if ($owner_id == api_get_user_id() || api_is_platform_admin()) {
$checked = &$form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly'));
if ($readonly == 1) {
$checked->setChecked(true);
}
}
}
if ($file_type == 'link') {
$form->addRule('title', get_lang('PleaseEnterCloudLinkName'), 'required');
$form->addRule('comment', get_lang('PleaseEnterURL'), 'required');
// Well formed url pattern (must have the protocol)
$urlRegEx = DocumentManager::getWellFormedUrlRegex();
$form->addRule('comment', get_lang('NotValidURL'), 'regex', $urlRegEx, 'client');
$form->addRule('comment', get_lang('NotValidURL'), 'regex', $urlRegEx, 'server');
$form->addRule('comment', get_lang('NotValidDomain').$urlWLText, 'regex', $urlWLRegEx, 'client');
$form->addRule('comment', get_lang('NotValidDomain').$urlWLHTML, 'regex', $urlWLRegEx, 'server');
}
if ($is_certificate_mode) {
$form->addButtonUpdate(get_lang('SaveCertificate'));
} elseif ($file_type == 'link') {
$form->addButtonUpdate(get_lang('SaveLink'));
} else {
$form->addButtonUpdate(get_lang('SaveDocument'));
}
$form->addHidden('formSent', 1);
$form->addHidden('filename', $filename);
$defaults['extension'] = $extension;
$defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
$defaults['commentPath'] = $file;
$defaults['renameTo'] = $file_name;
$defaults['comment'] = $document_data['comment'];
$defaults['origin'] = api_get_origin();
$defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
$form->setDefaults($defaults);
show_return(
$parent_id,
$dir_original,
$call_from_tool,
$slide_id,
$is_certificate_mode
);
if ($is_certificate_mode) {
$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
api_get_user_id(),
api_get_course_id(),
api_get_session_id()
);
$str_info = '';
foreach ($all_information_by_create_certificate[0] as $info_value) {
$str_info .= $info_value.'<br/>';
}
$create_certificate = get_lang('CreateCertificateWithTags');
echo Display::return_message(
$create_certificate.': <br /><br />'.$str_info,
'normal',
false
);
}
if ($extension == 'svg' && !api_browser_support('svg') &&
api_get_setting('enabled_support_svg') == 'true'
) {
echo Display::return_message(get_lang('BrowserDontSupportsSVG'), 'warning');
}
if ($file_type != 'link') {
// HTML-editor
echo '<div class="page-create">
<div class="row" style="overflow:hidden">
<div id="template_col" class="col-md-3">
<div class="panel panel-default">
<div class="panel-body">
<div id="frmModel" class="items-templates scrollbar-light"></div>
</div>
</div>
</div>
<div id="doc_form" class="col-md-9">
'.$form->returnForm().'
</div>
</div></div>';
} else {
// Add tooltip and correctly parse its inner HTML
echo '<script>
$(function() {
$("[data-toggle=\'tooltip\']").tooltip(
{
content:
function() {
return $(this).attr("title");
}
}
);
});
</script>';
echo $form->returnForm();
}
}
Display::display_footer();
// return button back to
function show_return($document_id, $path, $call_from_tool = '', $slide_id = 0, $is_certificate_mode = false)
{
$actionsLeft = null;
global $parent_id;
$url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$parent_id;
if ($is_certificate_mode) {
$selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '');
$actionsLeft .= '<a href="document.php?curdirpath='.$selectedCategory.'&selectcat='.$selectedCategory.'">'.
Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
} elseif ($call_from_tool == 'slideshow') {
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'.
Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM).'</a>';
} elseif ($call_from_tool == 'editdraw') {
$actionsLeft .= '<a href="'.$url.'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), [], 32).'</a>';
} elseif ($call_from_tool == 'editodf') {
$actionsLeft .= '<a href="'.$url.'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Write'), [], 32).'</a>';
$actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
} elseif ($call_from_tool == 'editpaint' && api_get_setting('enabled_support_pixlr') === 'true') {
$actionsLeft .= '<a href="'.$url.'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), [], ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), [], 32).'</a>';
} else {
$actionsLeft .= '<a href="'.$url.'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).'</a>';
}
echo $toolbar = Display::toolbarAction('actions-documents', [$actionsLeft]);
}

172
main/document/edit_draw.php Normal file
View File

@@ -0,0 +1,172 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows creating new svg and png documents with an online editor.
*
* @package chamilo.document
*
* @author Juan Carlos Ra<52>a Trabado
*
* @since 25/september/2010
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$groupRights = Session::read('group_member_with_upload_rights');
api_protect_course_script(true);
api_block_anonymous_users();
$document_data = DocumentManager::get_document_data_by_id(
$_GET['id'],
api_get_course_id(),
true
);
$file_path = '';
if (empty($document_data)) {
api_not_allowed();
} else {
$document_id = $document_data['id'];
$file_path = $document_data['path'];
$dir = dirname($document_data['path']);
$parent_id = DocumentManager::get_document_id(api_get_course_info(), $dir);
$my_cur_dir_path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : '';
}
//and urlencode each url $curdirpath (hack clean $curdirpath under Windows - Bug #3261)
$dir = str_replace('\\', '/', $dir);
/* Constants & Variables */
$current_session_id = api_get_session_id();
$group_id = api_get_group_id();
//path for svg-edit save
Session::write('draw_dir', Security::remove_XSS($dir));
if ($dir == '/') {
Session::write('draw_dir', '');
}
Session::write('draw_file', basename(Security::remove_XSS($file_path)));
$get_file = Security::remove_XSS($file_path);
$file = basename($get_file);
$temp_file = explode(".", $file);
$filename = $temp_file[0];
$nameTools = get_lang('EditDocument').': '.$filename;
$courseDir = $_course['path'].'/document';
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
/* Other initialization code */
/* Please, do not modify this dirname formatting */
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
//groups //TODO:clean
if (!empty($group_id)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace'),
];
$group_document = true;
}
$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
if (!$is_certificate_mode) {
$interbreadcrumb[] = [
"url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(),
"name" => get_lang('Documents'),
];
} else {
$interbreadcrumb[] = [
'url' => Category::getUrl(),
'name' => get_lang('Gradebook'),
];
}
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
} else {
foreach ($document_data['parents'] as $document_sub_data) {
if ($document_data['title'] == $document_sub_data['title']) {
continue;
}
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'],
'name' => $document_sub_data['title'],
];
}
}
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights || DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
if (!$is_allowedToEdit) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
Display::display_header($nameTools, 'Doc');
echo '<div class="actions">';
echo '<a href="document.php?id='.$parent_id.'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.'&origin=editdraw">'.
Display::return_icon('edit.png', get_lang('Rename').'/'.get_lang('Comments'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
if (api_browser_support('svg')) {
//automatic loading the course language
$svgedit_code_translation_table = [
'' => 'en',
'pt' => 'pt-Pt',
'sr' => 'sr_latn',
];
$langsvgedit = api_get_language_isocode();
$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit; ?>
<script>
document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
function resizeIframe() {
var height = window.innerHeight -50;
//max lower size
if (height<550) {
height=550;
}
document.getElementById('frame').style.height = height +"px";
};
document.getElementById('frame').onload = resizeIframe;
window.onresize = resizeIframe;
</script>
<?php
echo '<noscript>';
echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
echo '</noscript>';
} else {
echo Display::return_message(get_lang('BrowserDontSupportsSVG'), 'error');
}
Display::display_footer();

144
main/document/edit_odf.php Normal file
View File

@@ -0,0 +1,144 @@
<?php
/* For licensing terms, see /license.txt */
/**
* ODF document editor script.
*
* @package chamilo.document
*/
require_once __DIR__.'/../inc/global.inc.php';
$documentId = isset($_GET['id']) ? intval($_GET['id']) : 0;
$courseCode = api_get_course_id();
if (!$documentId) {
api_not_allowed();
}
$documentInfo = DocumentManager::get_document_data_by_id(
$documentId,
$courseCode,
true
);
if (empty($documentInfo)) {
api_not_allowed();
}
//Check user visibility
$is_visible = DocumentManager::check_visibility_tree(
$documentId,
api_get_course_info(),
api_get_session_id(),
api_get_user_id(),
api_get_group_id()
);
if (!api_is_allowed_to_edit() && !$is_visible) {
api_not_allowed(true);
}
$headerFile = $documentInfo['path'];
$pathinfo = pathinfo($headerFile);
$showOdfEditor = false;
$webOdfSupportedFiles = DocumentManager::get_web_odf_extension_list();
if (in_array(strtolower($pathinfo['extension']), $webOdfSupportedFiles) &&
api_get_configuration_value('enabled_support_odf') === true
) {
$showOdfEditor = true;
}
$fileUrl = api_get_path(WEB_COURSE_PATH)
.$_course['path'].'/document'.$headerFile;
if (!$showOdfEditor) {
api_not_allowed(true);
}
$parentId = $documentInfo['parent_id'];
if (!$parentId) {
$testParentId = 0;
// Get parent id from current path
if (!empty($documentInfo['path'])) {
$testParentId = DocumentManager::get_document_id(
api_get_course_info(),
dirname($documentInfo['path']),
0
);
}
$parentId = !empty($testParentId) ? $testParentId : 0;
}
//$htmlHeadXtra[] = api_get_js('webodf/webodf.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/wodotexteditor.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/localfileeditor.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/FileSaver.js');
$htmlHeadXtra[] = '
<script>
$(function() {
createEditor(\''.$fileUrl.'\');
});
</script>
';
$htmlHeadXtra[] = '
<style>
#editorContainer {
width: 100%;
height: 600px;
margin: 0px;
padding: 0px;
}
</style>
';
// Interbreadcrumb for the current directory root path
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'document/document.php',
'name' => get_lang('Documents'),
];
if (!empty($documentInfo['parents'])) {
foreach ($documentInfo['parents'] as $documentParent) {
if ($documentInfo['title'] == $documentParent['title']) {
continue;
}
$interbreadcrumb[] = [
'url' => $documentParent['document_url'],
'name' => $documentParent['title'],
];
}
}
$actionBack = Display::url(
Display::return_icon(
'back.png',
get_lang('BackTo').' '.get_lang('DocumentsOverview'),
[],
ICON_SIZE_MEDIUM
),
'document.php?'.api_get_cidreq(true, true, 'editodf').'&id='.$parentId
);
$actionEdit = Display::url(
Display::return_icon(
'edit.png',
get_lang('Rename').'/'.get_lang('Comments'),
[],
ICON_SIZE_MEDIUM
),
'edit_document.php?'.api_get_cidreq(true, true, 'editodf')
.'&id='.$documentId
);
$content = '<div id="editorContainer"></div>';
$view = new Template($documentInfo['title']);
$view->assign(
'actions',
Display::toolbarAction('actions', [$actionBack.$actionEdit])
);
$view->assign('header', $documentInfo['title']);
$view->assign('content', $content);
$view->display_one_col_template();

View File

@@ -0,0 +1,234 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows creating new svg and png documents with an online editor.
*
* @package chamilo.document
*
* @todo used the document_id instead of the curdirpath
*
* @author Juan Carlos Raña Trabado
*
* @since 30/january/2011
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$groupRights = Session::read('group_member_with_upload_rights');
api_protect_course_script(true);
api_block_anonymous_users();
$_course = api_get_course_info();
$groupId = api_get_group_id();
$document_data = DocumentManager::get_document_data_by_id(
$_GET['id'],
api_get_course_id(),
true
);
if (empty($document_data)) {
api_not_allowed();
} else {
$document_id = $document_data['id'];
$file_path = $document_data['path'];
$dir = dirname($document_data['path']);
$parent_id = DocumentManager::get_document_id(api_get_course_info(), $dir);
$my_cur_dir_path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
}
//and urlencode each url $curdirpath (hack clean $curdirpath under Windows - Bug #3261)
$dir = str_replace('\\', '/', $dir);
if (empty($dir)) {
$dir = '/';
}
/* Constants & Variables */
$current_session_id = api_get_session_id();
//path for pixlr save
Session::write('paint_dir', Security::remove_XSS($dir));
Session::write('paint_file', basename(Security::remove_XSS($file_path)));
$get_file = Security::remove_XSS($file_path);
$file = basename($get_file);
$temp_file = explode(".", $file);
$filename = $temp_file[0];
$nameTools = get_lang('EditDocument').': '.$filename;
$courseDir = $_course['path'].'/document';
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
/* Other initialization code */
/* Please, do not modify this dirname formatting */
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
//groups //TODO:clean
if (!empty($groupId)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace'),
];
$group_document = true;
}
$is_certificate_mode = DocumentManager::is_certificate_mode($dir);
if (!$is_certificate_mode) {
$interbreadcrumb[] = [
"url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(),
"name" => get_lang('Documents'),
];
} else {
$interbreadcrumb[] = [
'url' => Category::getUrl(),
'name' => get_lang('Gradebook'),
];
}
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
} else {
foreach ($document_data['parents'] as $document_sub_data) {
if ($document_data['title'] == $document_sub_data['title']) {
continue;
}
$interbreadcrumb[] = ['url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']];
}
}
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
if (!$is_allowedToEdit) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
Display::display_header($nameTools, 'Doc');
echo '<div class="actions">';
echo '<a href="document.php?id='.$parent_id.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.'&'.api_get_cidreq().'&origin=editpaint">'.
Display::return_icon('edit.png', get_lang('Rename').'/'.get_lang('Comment'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
// pixlr
$title = $file; //disk name. No sql name because pixlr return this when save
$langpixlr = api_get_language_isocode();
$langpixlr = isset($pixlr_code_translation_table[$langpixlr]) ? $pixlredit_code_translation_table[$langpixlr] : $langpixlr;
$loc = $langpixlr; // deprecated ?? TODO:check pixlr read user browser
$exit_path = api_get_path(WEB_CODE_PATH).'document/exit_pixlr.php';
Session::write('exit_pixlr', Security::remove_XSS($parent_id));
$referrer = "Chamilo";
$target_path = api_get_path(WEB_CODE_PATH).'document/save_pixlr.php';
$target = $target_path;
$locktarget = "true";
$locktitle = "false";
if ($_SERVER['HTTP_HOST'] == "localhost") {
$path_and_file = api_get_path(SYS_PATH).'/crossdomain.xml';
if (!file_exists($path_and_file)) {
$crossdomain = '<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="cdn.pixlr.com" />
<site-control permitted-cross-domain-policies="master-only"/>
<allow-http-request-headers-from domain="cnd.pixlr.com" headers="*" secure="true"/>
</cross-domain-policy>'; //more open domain="*"
@file_put_contents($path_and_file, $crossdomain);
}
$credentials = "true";
} else {
$credentials = "false";
}
//make temp images
$temp_folder = api_get_path(SYS_ARCHIVE_PATH).'temp/images';
if (!file_exists($temp_folder)) {
@mkdir($temp_folder, api_get_permissions_for_new_directories(), true); //TODO:check $permissions value, now empty;
}
//make htaccess with allow from all, and file index.html into temp/images
$htaccess = api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess';
if (!file_exists($htaccess)) {
$htaccess_content = "order deny,allow\r\nallow from all\r\nOptions -Indexes";
$fp = @fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/.htaccess', 'w');
if ($fp) {
fwrite($fp, $htaccess_content);
fclose($fp);
}
}
$html_index = api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html';
if (!file_exists($html_index)) {
$html_index_content = "<html><head></head><body></body></html>";
$fp = @fopen(api_get_path(SYS_ARCHIVE_PATH).'temp/images/index.html', 'w');
if ($fp) {
fwrite($fp, $html_index_content);
fclose($fp);
}
}
//encript temp name file
$name_crip = sha1(uniqid()); //encript
$findext = explode(".", $file);
$extension = $findext[count($findext) - 1];
$file_crip = $name_crip.'.'.$extension;
//copy file to temp/images directory
$from = $filepath.$file;
$to = api_get_path(SYS_ARCHIVE_PATH).'temp/images/'.$file_crip;
copy($from, $to);
Session::write('temp_realpath_image', $to);
//load image to url
$to_url = api_get_path(WEB_ARCHIVE_PATH).'temp/images/'.$file_crip;
$image = urlencode($to_url);
$pixlr_url = '//pixlr.com/editor/?title='.$title.'&image='.$image.'&loc='.$loc.'&referrer='.$referrer.'&target='.$target.'&exit='.$exit_path.'&locktarget='.$locktarget.'&locktitle='.$locktitle.'&credentials='.$credentials;
//make frame an send image
?>
<script>
document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $pixlr_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
function resizeIframe() {
var height = window.innerHeight;
//max lower size
if (height<600) {
height=600;
}
document.getElementById('frame').style.height = height +"px";
};
document.getElementById('frame').onload = resizeIframe;
window.onresize = resizeIframe;
</script>
<?php
echo '<noscript>';
echo '<iframe style="height: 600px; width: 100%;" scrolling="no" frameborder="0" src="'.$pixlr_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
echo '</noscript>';
Display::display_footer();

Binary file not shown.

View File

@@ -0,0 +1,8 @@
%PDF-1.4
%<25><><EFBFBD><EFBFBD>
1 0 obj
<< /Length 2 0 R
/Filter /FlateDecode
>>
stream
x<EFBFBD><EFBFBD>UMo<EFBFBD>0 <0C><07>й@]~Ȗ'v,`?`[7 ͆<CD86>GI<47><49><EFBFBD>ٗ;D<>(<28>|<7C>"r<72><7F>WG<57><47>*vAl<41><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ow<4F><77>vCU<43><55><EFBFBD>Qk<><6B><EFBFBD><EFBFBD><1B>v<EFBFBD>]<5D><1B>$<24>Ŭ<EFBFBD>}<7D>5k<35>o7<6F>w<EFBFBD>

View File

@@ -0,0 +1,40 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows creating new svg and png documents with an online editor.
*
* @package chamilo.document
*
* @author Juan Carlos Ra<52>a Trabado
*
* @since 30/january/2011
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
api_block_anonymous_users();
//delete temporal file
$fileToDelete = Session::read('temp_realpath_image');
if (file_exists($fileToDelete)) {
unlink($fileToDelete);
}
//Clean sessions and return to Chamilo file list
Session::erase('paint_dir');
Session::erase('paint_file');
Session::erase('temp_realpath_image');
$exit = Session::read('exit_pixlr');
if (empty($exit)) {
$location = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq();
echo '<script>window.parent.location.href="'.$location.'"</script>';
api_not_allowed(true);
} else {
echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>';
$location = api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($exit).'&'.api_get_cidreq();
echo '<script>window.parent.location.href="'.$location.'"</script>';
Session::erase('exit_pixlr');
}

7
main/document/index.html Normal file
View File

@@ -0,0 +1,7 @@
<html>
<head>
<meta http-equiv="refresh" content="0; url=document.php">
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,148 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows record audio files.
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
$groupRights = Session::read('group_member_with_upload_rights');
$nameTools = get_lang('VoiceRecord');
api_protect_course_script();
api_block_anonymous_users();
api_protect_course_group(GroupManager::GROUP_TOOL_DOCUMENTS);
$groupId = api_get_group_id();
$_course = api_get_course_info();
$document_data = DocumentManager::get_document_data_by_id(
$_GET['id'],
api_get_course_id(),
true
);
$dir = '/';
$document_id = 0;
$group_properties = null;
if (!empty($groupId)) {
$group_properties = GroupManager::get_group_properties(api_get_group_id());
}
if (empty($document_data)) {
if (api_is_in_group()) {
$document_id = DocumentManager::get_document_id($_course, $group_properties['directory']);
$document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
$dir = $document_data['path'];
}
} else {
$document_id = $document_data['id'];
$dir = $document_data['path'];
}
//make some vars
$wamidir = $dir;
if ($wamidir === '/') {
$wamidir = '';
}
$wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir.'/';
$groupId = api_get_group_id();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
// Please, do not modify this dirname formatting.
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] === '.') {
$dir = substr($dir, 1);
}
if ($dir[0] !== '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] !== '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
$dir = '/';
}
if (!empty($groupId)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace').' '.$group_properties['name'],
];
}
$interbreadcrumb[] = ['url' => './document.php?id='.$document_id.'&'.api_get_cidreq(), 'name' => get_lang('Documents')];
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
}
if (!($is_allowed_to_edit || $groupRights ||
DocumentManager::is_my_shared_folder(
api_get_user_id(),
Security::remove_XSS($dir),
api_get_session_id()
))
) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
$counter = 0;
if (isset($document_data['parents'])) {
foreach ($document_data['parents'] as $document_sub_data) {
//fixing double group folder in breadcrumb
if (api_get_group_id()) {
if ($counter == 0) {
$counter++;
continue;
}
}
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'],
'name' => $document_sub_data['title'],
];
$counter++;
}
}
$wamiuserid = api_get_user_id();
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
$htmlHeadXtra[] = api_get_js('record_audio/record_audio.js');
$actions = Display::toolbarButton(
get_lang('BackTo').' '.get_lang('DocumentsOverview'),
'document.php?'.api_get_cidreq()."&id=$document_id",
'arrow-left',
'default',
[],
false
);
$template = new Template($nameTools);
$template->assign('directory', $wamidir);
$template->assign('user_id', api_get_user_id());
$template->assign('reload_page', 1);
$layout = $template->get_template('document/record_audio.tpl');
$content = $template->fetch($layout);
$template->assign(
'actions',
Display::toolbarAction('toolbar', [$actions])
);
$template->assign('content', $content);
$template->display_one_col_template();

67
main/document/recycle.php Normal file
View File

@@ -0,0 +1,67 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
if (!api_get_configuration_value('document_manage_deleted_files')) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$files = DocumentManager::getDeletedDocuments($courseInfo, $sessionId);
$actions = Display::url(
get_lang('DownloadAll'),
api_get_self().'?'.api_get_cidreq().'&action=download_all',
['class' => 'btn btn-default']
);
$actions .= Display::url(
get_lang('DeleteAll'),
api_get_self().'?'.api_get_cidreq().'&action=delete_all',
['class' => 'btn btn-danger']
);
$action = isset($_GET['action']) ? $_GET['action'] : '';
$id = isset($_GET['id']) ? (int) $_GET['id'] : '';
$currentUrl = api_get_self().'?'.api_get_cidreq();
switch ($action) {
case 'delete':
DocumentManager::purgeDocument($id, $courseInfo, $sessionId);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header('Location: '.$currentUrl);
exit;
break;
case 'delete_all':
DocumentManager::purgeDocuments($courseInfo, $sessionId);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header('Location: '.$currentUrl);
exit;
break;
case 'download':
DocumentManager::downloadDeletedDocument($id, $courseInfo, $sessionId);
break;
case 'download_all':
DocumentManager::downloadAllDeletedDocument($courseInfo, $sessionId);
break;
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(),
'name' => get_lang('Documents'),
];
$template = new Template(get_lang('DeletedDocuments'));
$template->assign('files', $files);
$template->assign(
'actions',
Display::toolbarAction('toolbar', [$actions])
);
$template->assign('web_cid_query', api_get_cidreq());
$templateName = $template->get_template('document/recycle.tpl');
$content = $template->fetch($templateName);
$template->assign('content', $content);
$template->display_one_col_template();

82
main/document/remote.php Normal file
View File

@@ -0,0 +1,82 @@
<?php
/* See license terms in /license.txt */
/**
* Script that allows download of a specific file from external applications.
*
* @author Arnaud Ligot <arnaud@cblue.be>, Based on work done for old videoconference application (I have about 30 minutes to write this peace of code so if somebody has more time, feel free to rewrite it...)
*
* @package chamilo.document
*/
/**
* Script that allows remote download of a file.
*
* @param string Action parameter (action=...)
* @param string Course code (cidReq=...)
* @param string Current working directory (cwd=...)
*
* @return string JSON output
*/
/* FIX for IE cache when using https */
session_cache_limiter('none');
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
api_block_anonymous_users();
/*==== Variables initialisation ====*/
$action = $_REQUEST['action']; //safe as only used in if()'s
$seek = ['/', '%2F', '..'];
$destroy = ['', '', ''];
$cidReq = str_replace($seek, $destroy, $_REQUEST["cidReq"]);
$cidReq = Security::remove_XSS($cidReq);
$user_id = api_get_user_id();
$coursePath = api_get_path(SYS_COURSE_PATH).$cidReq.'/document';
$_course = api_get_course_info($cidReq);
if (empty($_course)) {
exit("problem when fetching course information");
}
// stupid variable initialisation for old version of DocumentManager functions.
$_course['path'] = $_course['directory'];
$is_manager = (CourseManager::getUserInCourseStatus($user_id, $_course['real_id']) == COURSEMANAGER);
if ($debug > 0) {
error_log($coursePath, 0);
}
// FIXME: check security around $_REQUEST["cwd"]
$cwd = $_REQUEST['cwd'];
// treat /..
$nParent = 0; // the number of /.. into the url
while (substr($cwd, -3, 3) == '/..') {
// go to parent directory
$cwd = substr($cwd, 0, -3);
if (strlen($cwd) == 0) {
$cwd = '/';
}
$nParent++;
}
for (; $nParent > 0; $nParent--) {
$cwd = (strrpos($cwd, '/') > -1 ? substr($cwd, 0, strrpos($cwd, '/')) : $cwd);
}
if (strlen($cwd) == 0) {
$cwd = '/';
}
if (Security::check_abs_path($cwd, api_get_path(SYS_PATH))) {
exit();
}
if ($action == 'list') {
/*==== List files ====*/
if ($debug > 0) {
error_log("sending file list", 0);
}
// get files list
$files = DocumentManager::getAllDocumentData($_course, $cwd, 0, null, false);
// adding download link to files
foreach ($files as $k => $f) {
if ($f['filetype'] == 'file') {
$files[$k]['download'] = api_get_path(WEB_COURSE_PATH).$cidReq."/document".$f['path'];
}
echo json_encode($files);
exit;
}
}

View File

@@ -0,0 +1,234 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
exit;
/**
* This file allows creating new svg and png documents with an online editor.
*
* @package chamilo.document
*
* @author Juan Carlos Raña Trabado
*
* @since 30/january/2011
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
api_block_anonymous_users();
if (!isset($_GET['title']) || !isset($_GET['type']) || !isset($_GET['image'])) {
echo 'No title';
exit;
}
$paintDir = Session::read('paint_dir');
if (empty($paintDir)) {
echo 'No directory to save';
exit;
}
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
echo 'Course not set';
exit;
}
// pixlr return
//The user preferred file name of the image.
$filename = Security::remove_XSS($_GET['title']);
//The image type, "pdx", "jpg", "bmp" or "png".
$extension = Security::remove_XSS($_GET['type']);
//A URL to the image on Pixlr.com server or the raw file post of the saved image.
$urlcontents = Security::remove_XSS($_GET['image']);
// make variables
$title = Database::escape_string(str_replace('_', ' ', $filename));
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$groupInfo = GroupManager::get_group_properties($groupId);
$dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document';
$saveDir = $dirBaseDocuments.$paintDir;
$contents = file_get_contents($urlcontents);
//Security. Verify that the URL is pointing to a file @ pixlr.com domain or an ip @ pixlr.com.
// Comment because sometimes return a ip number
/*
if (strpos($urlcontents, "pixlr.com") === 0){
echo "Invalid referrer";
exit;
}
*/
//Security. Allway get from pixlr.com. Comment because for now this does not run
/*
$urlcontents1='http://pixlr.com/';
$urlcontents2 = strstr($urlcontents, '_temp');
$urlcontents_to_save=$urlcontents1.$urlcontents2;
$contents = file_get_contents($urlcontents_to_save);//replace line 45.
*/
//a bit title security
$filename = addslashes(trim($filename));
$filename = Security::remove_XSS($filename);
$filename = api_replace_dangerous_char($filename);
$filename = disable_dangerous_file($filename);
if (strlen(trim($filename)) == 0) {
echo "The title is empty"; //if title is empty, headers Content-Type = application/octet-stream,
// then not create a new title here please
exit;
}
//check file_get_contents
if ($contents === false) {
echo "I cannot read: ".$urlcontents;
exit;
}
// Extension security
if ($extension != 'jpg' && $extension != 'png' && $extension != 'pxd') {
exit();
}
if ($extension == 'pxd') {
echo "pxd file type does not supported";
// not secure because check security headers and finfo() return Content-Type = application/octet-stream
exit;
}
//Verify that the file is an image. Headers method
$headers = get_headers($urlcontents, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
echo "Invalid file type";
exit;
}
//Verify that the file is an image. Fileinfo method
$finfo = new finfo(FILEINFO_MIME);
$current_mime = $finfo->buffer($contents);
if (strpos($current_mime, 'image') === false) {
echo "Invalid mime type file";
exit;
}
//path, file and title
$paintFileName = $filename.'.'.$extension;
$title = $title.'.'.$extension;
$temp_file_2delete = Session::read('temp_realpath_image');
if (empty($temp_file_2delete)) {
// Create file
if (0 != $groupId) {
$group_properties = GroupManager::get_group_properties($groupId);
$groupPath = $group_properties['directory'];
} else {
$groupPath = '';
}
if (file_exists($saveDir.'/'.$filename.'.'.$extension)) {
$i = 1;
while (file_exists($saveDir.'/'.$filename.'_'.$i.'.'.$extension)) {
$i++;
}
$paintFileName = $filename.'_'.$i.'.'.$extension;
$title = $filename.'_'.$i.'.'.$extension;
}
$documentPath = $saveDir.'/'.$paintFileName;
// Add new document to disk
file_put_contents($documentPath, $contents);
// Add document to database
$documentId = add_document($courseInfo, $paintDir.$paintFileName, 'file', filesize($documentPath), $title);
if ($documentId) {
api_item_property_update(
$courseInfo,
TOOL_DOCUMENT,
$documentId,
'DocumentAdded',
api_get_user_id(),
$groupInfo,
null,
null,
null,
$sessionId
);
Display::addFlash(Display::return_message(get_lang('Saved')));
}
} else {
// Update
$documentPath = $saveDir.'/'.$paintFileName;
file_put_contents($documentPath, $contents);
$paintFile = Session::read('paint_file');
//check path
if (empty($paintFile)) {
echo 'No attribute paint_file';
exit;
}
if ($paintFile == $paintFileName) {
$documentId = DocumentManager::get_document_id($courseInfo, $paintDir.$paintFileName);
update_existing_document($courseInfo, $documentId, filesize($documentPath), null);
api_item_property_update(
$courseInfo,
TOOL_DOCUMENT,
$documentId,
'DocumentUpdated',
$_user['user_id'],
$groupInfo,
null,
null,
null,
$sessionId
);
} else {
//add a new document
$documentId = add_document(
$courseInfo,
$paintDir.$paintFileName,
'file',
filesize($documentPath),
$title
);
if ($documentId) {
api_item_property_update(
$courseInfo,
TOOL_DOCUMENT,
$documentId,
'DocumentAdded',
api_get_user_id(),
$groupInfo,
null,
null,
null,
$sessionId
);
Display::addFlash(Display::return_message(get_lang('Updated')));
}
}
}
if (!empty($temp_file_2delete)) {
// Delete temporal file
unlink($temp_file_2delete);
}
//Clean sessions and return to Chamilo file list
Session::erase('paint_dir');
Session::erase('paint_file');
Session::erase('temp_realpath_image');
$exit = Session::read('exit_pixlr');
if (empty($exit)) {
$location = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq();
echo '<script>window.parent.location.href="'.$location.'"</script>';
exit;
} else {
echo '<div align="center" style="padding-top:150; font-family:Arial, Helvetica, Sans-serif;font-size:25px;color:#aaa;font-weight:bold;">'.get_lang('PleaseStandBy').'</div>';
$location = api_get_path(WEB_CODE_PATH).'document/document.php?id='.Security::remove_XSS($exit).'&'.api_get_cidreq();
echo '<script>window.parent.location.href="'.$location.'"</script>';
Session::erase('exit_pixlr');
}

View File

@@ -0,0 +1,109 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author jmontoya
*
* @package chamilo.document
*/
require_once __DIR__.'/../inc/global.inc.php';
// Protection
api_protect_course_script(true);
$header_file = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
$document_id = intval($_GET['id']);
$courseId = api_get_course_int_id();
$course_info = api_get_course_info_by_id($courseId);
$course_code = $course_info['code'];
$session_id = api_get_session_id();
if (empty($course_info)) {
api_not_allowed(true);
}
// Generate path
if (!$document_id) {
$document_id = DocumentManager::get_document_id($course_info, $header_file);
}
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
$course_code,
true,
$session_id
);
if ($session_id != 0 && !$document_data) {
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
$course_code,
true,
0
);
}
if (empty($document_data)) {
api_not_allowed(true);
}
$header_file = $document_data['path'];
$name_to_show = cut($header_file, 80);
$path_array = explode('/', str_replace('\\', '/', $header_file));
$path_array = array_map('urldecode', $path_array);
$header_file = implode('/', $path_array);
$file = Security::remove_XSS(urldecode($document_data['path']));
$file_root = $course_info['path'].'/document'.str_replace('%2F', '/', $file);
$file_url_sys = api_get_path(SYS_COURSE_PATH).$file_root;
$file_url_web = api_get_path(WEB_COURSE_PATH).$file_root;
if (!file_exists($file_url_sys)) {
api_not_allowed(true);
}
if (is_dir($file_url_sys)) {
api_not_allowed(true);
}
//fix the screen when you try to access a protected course through the url
$is_allowed_in_course = api_is_allowed_in_course();
if ($is_allowed_in_course == false) {
api_not_allowed(true);
}
// Check user visibility
$is_visible = DocumentManager::check_visibility_tree(
$document_id,
api_get_course_info(),
api_get_session_id(),
api_get_user_id(),
api_get_group_id()
);
if (!api_is_allowed_to_edit() && !$is_visible) {
api_not_allowed(true);
}
//TODO:clean all code
/* Main section */
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
//header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
$browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' - '.$file;
$file_url_web = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$header_file.'?'.api_get_cidreq();
$pathinfo = pathinfo($header_file);
if ($pathinfo['extension'] == 'swf') {
$width = '83%';
$height = '83%';
} else {
$width = '100%';
$height = '100%';
}
echo '<iframe border="0" frameborder="0" scrolling="no" style="width:'.$width.'; height:'.$height.';background-color:#ffffff;" id="mainFrame" name="mainFrame" src="'.$file_url_web.'?'.api_get_cidreq().'&amp;rand='.mt_rand(1, 1000).'"></iframe>';

View File

@@ -0,0 +1,436 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file will show documents in a separate frame.
* We don't like frames, but it was the best of two bad things.
*
* display html files within Chamilo - html files have the Chamilo header.
*
* --- advantages ---
* users "feel" like they are in Chamilo,
* and they can use the navigation context provided by the header.
* --- design ---
* a file gets a parameter (an html file) and shows
* - chamilo header
* - html file from parameter
* - (removed) chamilo footer
*
* @version 0.6
*
* @author Roan Embrechts (roan.embrechts@vub.ac.be)
*
* @package chamilo.document
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
$header_file = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null;
$document_id = (int) $_GET['id'];
$originIsLearnpath = isset($_GET['origin']) && $_GET['origin'] === 'learnpathitem';
$courseInfo = api_get_course_info();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
if (empty($courseInfo)) {
api_not_allowed(true);
}
$show_web_odf = false;
// Generate path
if (!$document_id) {
$document_id = DocumentManager::get_document_id($courseInfo, $header_file);
}
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
$course_code,
true,
$session_id
);
if ($session_id != 0 && !$document_data) {
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
$course_code,
true,
0
);
}
if (empty($document_data)) {
api_not_allowed(true);
}
$header_file = $document_data['path'];
$name_to_show = $document_data['title'];
$path_array = explode('/', str_replace('\\', '/', $header_file));
$path_array = array_map('urldecode', $path_array);
$header_file = implode('/', $path_array);
$file = Security::remove_XSS(urldecode($document_data['path']));
$file_root = $courseInfo['path'].'/document'.str_replace('%2F', '/', $file);
$file_url_sys = api_get_path(SYS_COURSE_PATH).$file_root;
$file_url_web = api_get_path(WEB_COURSE_PATH).$file_root;
if (!file_exists($file_url_sys)) {
api_not_allowed(true);
}
if (is_dir($file_url_sys)) {
api_not_allowed(true);
}
$is_allowed_to_edit = api_is_allowed_to_edit();
//fix the screen when you try to access a protected course through the url
$is_allowed_in_course = api_is_allowed_in_course() || $is_allowed_to_edit;
if ($is_allowed_in_course == false) {
api_not_allowed(true);
}
// Check user visibility.
$is_visible = DocumentManager::check_visibility_tree(
$document_id,
api_get_course_info(),
api_get_session_id(),
api_get_user_id(),
api_get_group_id(),
false
);
$pathinfo = pathinfo($header_file);
$playerSupportedFiles = ['mp3', 'mp4', 'ogv', 'ogg', 'flv', 'm4v', 'webm', 'wav'];
$playerSupported = false;
if (in_array(strtolower($pathinfo['extension']), $playerSupportedFiles)) {
$playerSupported = true;
}
$group_id = api_get_group_id();
if (!empty($group_id)) {
$current_group = GroupManager::get_group_properties($group_id);
if ($current_group) {
$current_group_name = $current_group['name'];
}
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace').' '.$current_group_name,
];
$name_to_show = explode('/', $name_to_show);
unset($name_to_show[1]);
$name_to_show = implode('/', $name_to_show);
}
$interbreadcrumb[] = [
'url' => './document.php?curdirpath='.dirname($header_file).'&'.api_get_cidreq(),
'name' => get_lang('Documents'),
];
if (empty($document_data['parents'])) {
if (isset($_GET['createdir'])) {
$interbreadcrumb[] = [
'url' => $document_data['document_url'],
'name' => $document_data['title'],
];
} else {
$interbreadcrumb[] = [
'url' => '#',
'name' => $document_data['title'],
];
}
} else {
foreach ($document_data['parents'] as $document_sub_data) {
if (!isset($_GET['createdir']) && $document_sub_data['id'] == $document_data['id']) {
$document_sub_data['document_url'] = '#';
}
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'],
'name' => $document_sub_data['title'],
];
}
}
$this_section = SECTION_COURSES;
$nameTools = get_lang('Documents');
/**
* Main code section.
*/
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
$browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' - '.$file;
// Only admins get to see the "no frames" link in pageheader.php, so students get a header that's not so high
$frameheight = 135;
if (api_is_course_admin()) {
$frameheight = 165;
}
$execute_iframe = true;
$frameReady = Display::getFrameReadyBlock('#mainFrame');
$web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
// PDF should be displayed with viewerJS
$web_odf_supported_files[] = 'pdf';
if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) {
$show_web_odf = true;
$execute_iframe = false;
$htmlHeadXtra[] = '
<script>
resizeIframe = function() {
var bodyHeight = $("body").height();
var topbarHeight = $("#topbar").height();
$("#viewerJSContent").height((bodyHeight - topbarHeight));
}
$(function() {
$(window).resize(resizeIframe());
});
</script>';
}
// Activate code highlight.
$isChatFolder = false;
if (isset($document_data['parents']) && isset($document_data['parents'][0])) {
$chatFolder = $document_data['parents'][0];
if (isset($chatFolder['path']) && $chatFolder['path'] === '/chat_files') {
$isChatFolder = true;
}
}
if ($isChatFolder) {
$htmlHeadXtra[] = api_get_js('highlight/highlight.pack.js');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'chat.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/highlight/styles/github.css');
$htmlHeadXtra[] = '
<script>
hljs.initHighlightingOnLoad();
</script>';
}
if ($playerSupported) {
$extension = api_strtolower($pathinfo['extension']);
$execute_iframe = false;
}
$is_freemind_available = $pathinfo['extension'] === 'mm' && api_get_setting('enable_freemind') === 'true';
if ($is_freemind_available) {
$execute_iframe = false;
}
if (!$playerSupported && $execute_iframe) {
$htmlHeadXtra[] = '<script>
<!--
var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\';
-->
</script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
$htmlHeadXtra[] = '<script>
// Fixes the content height of the frame
$(function() {
$(\'#mainFrame\').on(\'load\', function () {
let currentHeight = this.style.height;
currentHeight = parseInt(currentHeight, 10);
let frameHeight = parseInt(this.contentWindow.document.body.scrollHeight) + 50;
if (frameHeight > currentHeight) {
this.style.height = frameHeight + \'px\';
}
});
'.$frameReady.'
});
</script>';
}
if ($originIsLearnpath) {
Display::display_reduced_header();
} else {
Display::display_header();
}
if (!$is_allowed_to_edit && !$is_visible) {
echo Display::return_message(get_lang('ProtectedDocument'), 'warning');
Display::display_footer();
exit;
}
$file_url = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document'.$header_file;
$file_url_web = $file_url.'?'.api_get_cidreq();
if ($playerSupported) {
echo DocumentManager::generateMediaPreview($file_url_web, $extension);
}
if ($is_freemind_available) {
?>
<script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_PATH); ?>swfobject/swfobject.js"></script>
<style type="text/css">
#flashcontent {
height: 500px;
padding-top:10px;
}
</style>
<div id="flashcontent" onmouseover="giveFocus();">
Flash plugin or Javascript are turned off.
Activate both and reload to view the mindmap
</div>
<script>
function giveFocus() {
document.visorFreeMind.focus();
}
document.onload=giveFocus;
// <![CDATA[
// for allowing using http://.....?mindmap.mm mode
function getMap(map){
var result=map;
var loc=document.location+'';
if(loc.indexOf(".mm")>0 && loc.indexOf("?")>0){
result=loc.substring(loc.indexOf("?")+1);
}
return result;
}
var fo = new FlashObject("<?php echo api_get_path(WEB_LIBRARY_PATH); ?>freeMindFlashBrowser/visorFreemind.swf", "visorFreeMind", "100%", "100%", 6, "#ffffff");
fo.addParam("quality", "high");
//fo.addParam("bgcolor", "#a0a0f0");
fo.addVariable("openUrl", "_blank");//Default value "_self"
fo.addVariable("startCollapsedToLevel","3");//Default value = "-1", meaning do nothing, the mindmap will open as it was saved. The root node, or central node, of your mindmap is level zero. You could force the browser to open (unfold) your mind map to an expanded level using this variable.
fo.addVariable("maxNodeWidth","200");
//
fo.addVariable("mainNodeShape","elipse");//"rectangle", "elipse", "none". None hide the main node. Default is "elipse"
fo.addVariable("justMap","false");
fo.addVariable("initLoadFile",getMap("<?php echo $file_url_web; ?>"));
fo.addVariable("defaultToolTipWordWrap",200);//max width for tooltips. Default "600" pixels
fo.addVariable("offsetX","left");//for the center of the mindmap. Admit also "left" and "right"
fo.addVariable("offsetY","top");//for the center of the mindmap. Admit also "top" and "bottom"
fo.addVariable("buttonsPos","top");//"top" or "bottom"
fo.addVariable("min_alpha_buttons",20);//for dynamic view of buttons
fo.addVariable("max_alpha_buttons",100);//for dynamic view of buttons
fo.addVariable("scaleTooltips","false");
//
//extra
//fo.addVariable("CSSFile","<?php // echo api_get_path(WEB_LIBRARY_PATH);?>freeMindFlashBrowser/flashfreemind.css");//
//fo.addVariable("baseImagePath","<?php // echo api_get_path(WEB_LIBRARY_PATH);?>freeMindFlashBrowser/");//
//fo.addVariable("justMap","false");//Hides all the upper control options. Default value "false"
//fo.addVariable("noElipseMode","anyvalue");//for changing to old elipseNode edges. Default = not set
//fo.addVariable("ShotsWidth","200");//The width of snapshots, in pixels.
//fo.addVariable("genAllShots","true");//Preview shots (like the samples on the Shots Width page) will be generated for all linked maps when your main map loads. If you have a lot of linked maps, this could take some time to complete
//fo.addVariable("unfoldAll","true"); //For each mindmap loaded start the display with all nodes unfolded. Another variable to be wary of!
//fo.addVariable("toolTipsBgColor","0xaaeeaa");: bgcolor for tooltips ej;"0xaaeeaa"
//fo.addVariable("defaultWordWrap","300"); //default 600
//
fo.write("flashcontent");
// ]]>
</script>
<?php
}
if (($execute_iframe || $show_web_odf) && !$isChatFolder) {
$parentId = $document_data['parent_id'];
$url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$parentId;
$actionsLeft = Display::url(
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM),
$url
);
$groupMemberWithEditRights = false;
$groupId = api_get_group_id();
if (!empty($groupId)) {
$groupInfo = GroupManager::get_group_properties($groupId);
if ($groupInfo) {
$groupMemberWithEditRights = GroupManager::allowUploadEditDocument(
api_get_user_id(),
api_get_course_int_id(),
$groupInfo,
$document_data
);
}
}
$allowToEdit = api_is_allowed_to_edit(null, true) || $groupMemberWithEditRights;
if ($allowToEdit) {
if (false === $show_web_odf) {
$actionsLeft .= Display::url(
Display::return_icon(
'edit.png',
get_lang('Modify'),
'',
ICON_SIZE_MEDIUM
),
api_get_path(WEB_CODE_PATH).'document/edit_document.php?'.api_get_cidreq().'&id='.$document_id
);
}
$titleToShow = addslashes(basename($document_data['title']));
$urlDeleteParams = http_build_query(
[
'action' => 'delete_item',
'id' => $parentId,
'deleteid' => $document_data['id'],
]
);
$actionsLeft .= Display::url(
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_MEDIUM),
'#',
[
'data-item-title' => $titleToShow,
'data-href' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&'.$urlDeleteParams,
'data-toggle' => 'modal',
'data-target' => '#confirm-delete',
]
);
if (false === $show_web_odf) {
$secToken = Security::get_token();
$actionsLeft .= Display::url(
Display::return_icon('pdf.png', get_lang('Export2PDF'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(
).'&action=export_to_pdf&id='.$document_id.'&sec_token='.$secToken
);
}
}
echo $toolbar = Display::toolbarAction('actions-documents', [$actionsLeft]);
}
if ($show_web_odf) {
$execute_iframe = false;
echo '<div class="text-center">';
$browser = api_get_navigator();
$pdfUrl = api_get_path(WEB_LIBRARY_PATH).'javascript/ViewerJS/index.html?zoom=page-width#'.$file_url;
if ($browser['name'] === 'Mozilla' && preg_match('|.*\.pdf|i', $header_file)) {
$pdfUrl = $file_url;
}
echo '<div id="viewerJS">';
echo '<iframe
id="viewerJSContent"
frameborder="0"
allowfullscreen="allowfullscreen"
webkitallowfullscreen
style="width:100%;height:600px;"
src="'.$pdfUrl.'">
</iframe>';
echo '</div>';
echo '</div>';
}
if ($execute_iframe) {
if ($isChatFolder) {
$content = Security::remove_XSS(file_get_contents($file_url_sys));
echo $content;
} else {
echo '<iframe
id="mainFrame"
name="mainFrame"
border="0"
frameborder="0"
marginheight="0"
marginwidth="0"
scrolling="no"
style="width:100%; height:600px"
src="'.$file_url_web.'&rand='.mt_rand(1, 10000).'"
allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>';
}
}
Display::display_footer();

541
main/document/slideshow.php Normal file
View File

@@ -0,0 +1,541 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @author Patrick Cool patrick.cool@UGent.be Ghent University Mai 2004
* @author Julio Montoya Lots of improvements, cleaning, adding security
* @author Juan Carlos Raña Trabado herodoto@telefonica.net January 2008
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
if (api_get_configuration_value('disable_slideshow_documents')) {
api_not_allowed(true);
}
$curdirpath = $path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
$courseInfo = api_get_course_info();
$pathurl = urlencode($path);
$slide_id = isset($_GET['slide_id']) ? Security::remove_XSS($_GET['slide_id']) : null;
$document_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
if (empty($slide_id)) {
$edit_slide_id = 1;
} else {
$edit_slide_id = $slide_id;
}
if ($path != '/') {
$folder = $path.'/';
} else {
$folder = '/';
}
$sys_course_path = api_get_path(SYS_COURSE_PATH);
// Breadcrumb navigation
$url = 'document.php?curdirpath='.$pathurl.'&'.api_get_cidreq();
$originaltoolname = get_lang('Documents');
$_course = api_get_course_info();
$interbreadcrumb[] = ['url' => Security::remove_XSS($url), 'name' => $originaltoolname];
$originaltoolname = get_lang('SlideShow');
$sessionId = api_get_session_id();
$groupIid = 0;
$groupMemberWithEditRights = false;
// Setting group variables.
if (!empty($groupId)) {
$group_properties = GroupManager::get_group_properties($groupId);
$groupIid = isset($group_properties['iid']) ? $group_properties['iid'] : 0;
}
Display::display_header($originaltoolname, 'Doc');
$slideshowKey = 'slideshow_'.api_get_course_id().api_get_session_id().$curdirpath;
$documentAndFolders = Session::read($slideshowKey);
if (empty($documentAndFolders)) {
$documentAndFolders = DocumentManager::getAllDocumentData(
$courseInfo,
$curdirpath,
$groupIid,
null,
$isAllowedToEdit,
false
);
Session::write($slideshowKey, $documentAndFolders);
}
require 'document_slideshow.inc.php';
// Calculating the current slide, next slide, previous slide and the number of slides
$slide = null;
if ($slide_id != 'all') {
$slide = $slide_id ? $slide_id : 0;
$previous_slide = $slide - 1;
$next_slide = $slide + 1;
}
$total_slides = count($image_files_only);
echo '<div class="actions">';
if ($slide_id != 'all') {
$image = null;
if (isset($image_files_only[$slide])) {
$image = $sys_course_path.$_course['path'].'/document'.$folder.$image_files_only[$slide];
}
if (file_exists($image)) {
echo '<div class="actions-pagination">';
// Back forward buttons
if ($slide == 0) {
$imgp = 'action_prev_na.png';
$first = Display::return_icon('action_first_na.png');
} else {
$imgp = 'action_prev.png';
$first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'&'.api_get_cidreq().'">
'.Display::return_icon('action_first.png', get_lang('FirstSlide')).'
</a>';
}
// First slide
echo $first;
// Previous slide
if ($slide > 0) {
echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'&'.api_get_cidreq().'">';
}
echo Display::return_icon($imgp, get_lang('Previous'));
if ($slide > 0) {
echo '</a>';
}
// Divider
echo ' [ '.$next_slide.'/'.$total_slides.' ] ';
// Next slide
if ($slide < $total_slides - 1) {
echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'&'.api_get_cidreq().'">';
}
if ($slide == $total_slides - 1) {
$imgn = 'action_next_na.png';
$last = Display::return_icon('action_last_na.png', get_lang('LastSlide'));
} else {
$imgn = 'action_next.png';
$last = '<a href="slideshow.php?slide_id='.($total_slides - 1).'&curdirpath='.$pathurl.'&'.api_get_cidreq().'">
'.Display::return_icon('action_last.png', get_lang('LastSlide')).'
</a>';
}
echo Display::return_icon($imgn, get_lang('Next'));
if ($slide > 0) {
echo '</a>';
}
// Last slide
echo $last;
echo '</div>';
}
}
echo Display::url(
Display::return_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$document_id
);
// Show thumbnails
if ($slide_id != 'all') {
echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
Display::return_icon('thumbnails.png', get_lang('ShowThumbnails'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
echo Display::return_icon('thumbnails_na.png', get_lang('ShowThumbnails'), '', ICON_SIZE_MEDIUM);
}
// Slideshow options
echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
Display::return_icon('settings.png', get_lang('SetSlideshowOptions'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
echo '<br />';
/* TREATING THE POST DATA FROM SLIDESHOW OPTIONS */
// If we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
if (isset($_POST['Submit'])) {
// We come from slideshowoptions.php
Session::write('image_resizing', Security::remove_XSS($_POST['radio_resizing']));
if ($_POST['radio_resizing'] == 'resizing' && $_POST['width'] != '' && $_POST['height'] != '') {
Session::write('image_resizing_width', Security::remove_XSS($_POST['width']));
Session::write('image_resizing_height', Security::remove_XSS($_POST['height']));
} else {
Session::write('image_resizing_width', null);
Session::write('image_resizing_height', null);
}
}
$target_width = $target_height = null;
$imageResize = Session::read('image_resizing');
// The target height and width depends if we choose resizing or no resizing
if ($imageResize == 'resizing') {
$target_width = Session::read('image_resizing_width');
$target_height = Session::read('image_resizing_height');
}
/* THUMBNAIL VIEW */
// This is for viewing all the images in the slideshow as thumbnails.
$image_tag = [];
$html = '';
if ($slide_id == 'all') {
// Config for make thumbnails
$allowed_thumbnail_types = ['jpg', 'jpeg', 'gif', 'png'];
$max_thumbnail_width = 250;
$max_thumbnail_height = 250;
$png_compression = 0; //0(none)-9
$jpg_quality = 75; //from 0 to 100 (default is 75). More quality less compression
$directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/';
//Other parameters only for show tumbnails
$row_items = 4; //only in slideshow.php
$number_image = 7; //num icons cols to show
$thumbnail_width_frame = $max_thumbnail_width; //optional $max_thumbnail_width+x
$thumbnail_height_frame = $max_thumbnail_height;
// Create the template_thumbnails folder (if no exist)
if (!file_exists($directory_thumbnails)) {
@mkdir($directory_thumbnails, api_get_permissions_for_new_directories());
}
// check files and thumbnails
if (is_array($image_files_only)) {
foreach ($image_files_only as $one_image_file) {
$image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file;
$image_thumbnail = $directory_thumbnails.'.'.$one_image_file;
if (file_exists($image)) {
//check thumbnail
$imagetype = explode(".", $image);
//or check $imagetype = image_type_to_extension(exif_imagetype($image), false);
$imagetype = strtolower($imagetype[count($imagetype) - 1]);
if (in_array($imagetype, $allowed_thumbnail_types)) {
if (!file_exists($image_thumbnail)) {
//run each once we view thumbnails is too heavy,
// then need move into !file_exists($image_thumbnail,
// and only run when haven't the thumbnail
$original_image_size = api_getimagesize($image);
switch ($imagetype) {
case 'gif':
$source_img = imagecreatefromgif($image);
break;
case 'jpg':
$source_img = imagecreatefromjpeg($image);
break;
case 'jpeg':
$source_img = imagecreatefromjpeg($image);
break;
case 'png':
$source_img = imagecreatefrompng($image);
break;
}
$new_thumbnail_size = api_calculate_image_size(
$original_image_size['width'],
$original_image_size['height'],
$max_thumbnail_width,
$max_thumbnail_height
);
if ($max_thumbnail_width > $original_image_size['width'] &&
$max_thumbnail_height > $original_image_size['height']
) {
$new_thumbnail_size['width'] = $original_image_size['width'];
$new_thumbnail_size['height'] = $original_image_size['height'];
}
$crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
// preserve transparency
if ($imagetype == 'png') {
imagesavealpha($crop, true);
$color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127);
imagefill($crop, 0, 0, $color);
}
if ($imagetype == 'gif') {
$transindex = imagecolortransparent($source_img);
$palletsize = imagecolorstotal($source_img);
//GIF89a for transparent and anim (first clip), either GIF87a
if ($transindex >= 0 && $transindex < $palletsize) {
$transcol = imagecolorsforindex($source_img, $transindex);
$transindex = imagecolorallocatealpha(
$crop,
$transcol['red'],
$transcol['green'],
$transcol['blue'],
127
);
imagefill($crop, 0, 0, $transindex);
imagecolortransparent($crop, $transindex);
}
}
// Resampled image
imagecopyresampled(
$crop,
$source_img,
0,
0,
0,
0,
$new_thumbnail_size['width'],
$new_thumbnail_size['height'],
$original_image_size['width'],
$original_image_size['height']
);
switch ($imagetype) {
case 'gif':
imagegif($crop, $image_thumbnail);
break;
case 'jpg':
imagejpeg($crop, $image_thumbnail, $jpg_quality);
break;
case 'jpeg':
imagejpeg($crop, $image_thumbnail, $jpg_quality);
break;
case 'png':
imagepng($crop, $image_thumbnail, $png_compression);
break;
}
//clean memory
imagedestroy($crop);
}//end !exist thumbnail
//show thumbnail and link
$one_image_thumbnail_file = '.thumbs/.'.$one_image_file; //get path thumbnail
$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
$image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
} else {
// If images aren't support by gd (not gif, jpg, jpeg, png)
if ($imagetype == 'bmp') {
// use getimagesize instead api_getimagesize($image);
// because api_getimagesize doesn't support bmp files.
// Put here for each show, only for a few bmp files isn't heavy
$original_image_size = getimagesize($image);
if ($max_thumbnail_width < $original_image_size[0] ||
$max_thumbnail_height < $original_image_size[1]
) {
//don't use resize_image because doesn't run with bmp files
$thumbnail_size = api_calculate_image_size(
$original_image_size[0],
$original_image_size[1],
$max_thumbnail_width,
$max_thumbnail_height
);
$image_height = $thumbnail_size['height'];
$image_width = $thumbnail_size['width'];
} else {
$image_height = $original_image_size[0];
$image_width = $original_image_size[1];
}
} else {
// Example for svg files,...
$image_width = $max_thumbnail_width;
$image_height = $max_thumbnail_height;
}
$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
$image_tag[] = '<img
src="download.php?doc_url='.$doc_url.'"
border="0"
width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">';
}
}
}
}
// Creating the table
$html_table = '';
$i = 0;
$count_image = count($image_tag);
$number_iteration = ceil($count_image / $number_image);
$p = 0;
$html = '';
$html .= '<div class="gallery">';
for ($k = 0; $k < $number_iteration; $k++) {
for ($i = 0; $i < $number_image; $i++) {
if (isset($image_tag[$p])) {
$html .= '<div class="col-xs-6 col-sm-3 col-md-2">';
$html .= '<div class="canvas-one">';
$html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">';
$html .= '<div class="frame">';
$html .= '<div class="photo">';
$html .= $image_tag[$p];
$html .= '</div>';
$html .= '</div>';
$html .= '</a>';
$html .= '</div>';
$html .= '</div>';
}
$p++;
}
}
$html .= '</div>';
}
echo $html;
/* ONE AT A TIME VIEW */
$course_id = api_get_course_int_id();
// This is for viewing all the images in the slideshow one at a time.
if ($slide_id != 'all' && !empty($image_files_only)) {
if (file_exists($image) && is_file($image)) {
$image_height_width = DocumentManager::resizeImageSlideShow($image, $target_width, $target_height);
$image_height = $image_height_width[0];
$image_width = $image_height_width[1];
$height_width_tags = null;
if ($imageResize == 'resizing') {
$height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
}
// This is done really quickly and should be cleaned up a little bit using the API functions
$tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
if ($path == '/') {
$pathpart = '/';
} else {
$pathpart = $path.'/';
}
$sql = "SELECT * FROM $tbl_documents
WHERE
c_id = $course_id AND
path = '".Database::escape_string($pathpart.$image_files_only[$slide])."'";
$result = Database::query($sql);
$row = Database::fetch_array($result);
echo '<div class="thumbnail">';
if ($slide < $total_slides - 1 && $slide_id != 'all') {
echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
} else {
echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>";
}
if ($path == '/') {
$path = '';
}
list($width, $height) = getimagesize($image);
// Auto resize
if ($imageResize == 'resizing') {
?>
<script>
var initial_width='<?php echo $width; ?>';
var initial_height='<?php echo $height; ?>';
var height = window.innerHeight -320;
var width = window.innerWidth -360;
if (initial_height>height || initial_width>width) {
start_width = width;
start_height= height;
} else {
start_width = initial_width;
start_height = initial_height;
}
document.write('<img id="image" src="<?php echo 'download.php?doc_url='.$path.'/'.$image_files_only[$slide]; ?>" width="'+start_width+'" height="'+start_height+'" border="0" alt="<?php echo $image_files_only[$slide]; ?>">');
function resizeImage() {
var resize_factor_width = width / initial_width;
var resize_factor_height = height / initial_height;
var delta_width = width - initial_width * resize_factor_height;
var delta_height = height - initial_height * resize_factor_width;
if (delta_width > delta_height) {
width = Math.ceil(initial_width * resize_factor_height);
height= Math.ceil(initial_height * resize_factor_height);
} else if(delta_width < delta_height) {
width = Math.ceil(initial_width * resize_factor_width);
height = Math.ceil(initial_height * resize_factor_width);
} else {
width = Math.ceil(width);
height = Math.ceil(height);
}
document.getElementById('image').style.height = height +"px";
document.getElementById('image').style.width = width +"px";
document.getElementById('td_image').style.background='none';
document.getElementById('image').style.visibility='visible';
}
if (initial_height > height || initial_width > width) {
document.getElementById('image').style.visibility='hidden';
document.getElementById('td_image').style.background='url(<?php echo Display::returnIconPath('loadingAnimation.gif'); ?>) center no-repeat';
document.getElementById('image').onload = resizeImage;
window.onresize = resizeImage;
}
</script>
<?php
} else {
echo "<img
class=\"img-responsive\"
src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."'
border='0'".$height_width_tags.'>';
}
echo '</a>';
echo '<div class="caption text-center">';
echo Display::tag('h3', $row['title']);
echo '<p>'.$row['comment'].'</p>';
echo '</div>';
echo '</div>';
if (api_is_allowed_to_edit(null, true)) {
echo '<ul class="list-unstyled">';
$aux = explode('.', htmlspecialchars($image_files_only[$slide]));
$ext = $aux[count($aux) - 1];
if ($imageResize == 'resizing') {
$resize_info = get_lang('Resizing').'<br />';
$resize_width = Session::read('image_resizing_width').' x ';
$resize_height = Session::read('image_resizing_height');
} elseif ($imageResize != 'noresizing') {
$resize_info = get_lang('Resizing').'<br />';
$resize_width = get_lang('Auto').' x ';
$resize_height = get_lang('Auto');
} else {
$resize_info = get_lang('NoResizing').'<br />';
$resize_width = '';
$resize_height = '';
}
echo '<li class="text-center">';
echo $image_files_only[$slide].' ';
echo Display::toolbarButton(
get_lang('Modify'),
'edit_document.php?'.api_get_cidreq().'&'.http_build_query([
'id' => $row['id'],
'origin' => 'slideshow',
'origin_opt' => $edit_slide_id,
'curdirpath' => $pathurl,
]),
'edit',
'link',
[],
false
);
echo '</li>';
echo '<li class="text-center">'.$width.' x '.$height.'</li>';
echo '<li class="text-center">'.round((filesize($image) / 1024), 2).' KB - '.$ext.'</li>';
echo '<li class="text-center">'.$resize_info.'</li>';
echo '<li class="text-center">'.$resize_width.'</li>';
echo '<li class="text-center">'.$resize_height.'</li>';
echo '</ul>';
}
} else {
echo Display::return_message(get_lang('FileNotFound'), 'warning');
}
} else {
if ($slide_id != 'all') {
echo Display::return_message(get_lang('NoDataAvailable'), 'warning');
}
}
Display::display_footer();

View File

@@ -0,0 +1,147 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @author Patrick Cool, patrick.cool@UGent.be, Ghent University, May 2004, http://icto.UGent.be
* Please bear in mind that this is only an beta release.
* I wrote this quite quick and didn't think too much about it in advance.
* It is not perfect at all but it is workable and usefull (I think)
* Do not consider this as a powerpoint replacement, although it has
* the same starting point.
* This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
* files (since these are the files that can be viewed in a browser) and creates
* a slideshow with it by allowing to go to the next/previous image.
* You can also have a quick overview (thumbnail view) of all the images in
* that particular folder.
* Maybe it is important to notice that each slideshow is folder based. Only
* the images of the chosen folder are shown.
* On this page the options of the slideshow can be set: maintain the original file
* or resize the file to a given width.
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
if (api_get_configuration_value('disable_slideshow_documents')) {
api_not_allowed(true);
}
$path = Security::remove_XSS($_GET['curdirpath']);
$pathurl = urlencode($path);
// Breadcrumb navigation
$url = 'document.php?curdirpath='.$pathurl;
$originaltoolname = get_lang('Documents');
$interbreadcrumb[] = ['url' => $url, 'name' => $originaltoolname];
$url = 'slideshow.php?curdirpath='.$pathurl;
$originaltoolname = get_lang('SlideShow');
$interbreadcrumb[] = ['url' => $url, 'name' => $originaltoolname];
// Because $nametools uses $_SERVER['PHP_SELF'] for the breadcrumbs instead of $_SERVER['REQUEST_URI'], I had to
// bypass the $nametools thing and use <b></b> tags in the $interbreadcrump array
$url = 'slideshowoptions.php?curdirpath='.$pathurl;
$originaltoolname = '<b>'.get_lang('SlideshowOptions').'</b>';
$interbreadcrumb[] = ['url' => $url, 'name' => $originaltoolname];
Display::display_header($originaltoolname, 'Doc');
$image_resizing = Session::read('image_resizing');
?>
<script>
function enableresizing() { //v2.0
document.options.width.disabled=false;
//document.options.width.className='enabled_input';
document.options.height.disabled=false;
//document.options.height.className='enabled_input';
}
function disableresizing() { //v2.0
document.options.width.disabled=true;
//document.options.width.className='disabled_input';
document.options.height.disabled=true;
//document.options.height.className='disabled_input';
}
window.onload = <?php echo $image_resizing == 'resizing' ? 'enableresizing' : 'disableresizing'; ?>;
</script>
<?php
$actions = '<a href="document.php?action=exit_slideshow&curdirpath='.$pathurl.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
$actions .= '<a href="slideshow.php?curdirpath='.$pathurl.'">'.Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('SlideShow'), '', ICON_SIZE_MEDIUM).'</a>';
echo Display::toolbarAction('toolbar-slideshow', [$actions]);
?>
<div class="panel panel-default">
<div class="panel-body">
<form action="slideshow.php?curdirpath=<?php echo $pathurl; ?>" method="post" name="options" id="options" class="form-horizontal">
<legend><?php echo get_lang('SlideshowOptions'); ?></legend>
<div class="radio">
<label>
<input name="radio_resizing" type="radio" onClick="disableresizing()" value="noresizing" <?php
if ($image_resizing == 'noresizing' || $image_resizing == '') {
echo ' checked';
}
?>>
</label>
<?php echo '<b>'.get_lang('NoResizing').'</b>, '.get_lang('NoResizingComment'); ?>
</div>
<div class="radio">
<label>
<input name="radio_resizing" type="radio" onClick="disableresizing()" value="autoresizing" <?php
if ($image_resizing == 'resizing_auto' || $image_resizing == '') {
echo ' checked';
}
?>>
</label>
<?php echo '<b>'.get_lang('ResizingAuto').'</b>, '.get_lang('ResizingAutoComment'); ?>
</div>
<div class="radio">
<label>
<input class="checkbox" name="radio_resizing" type="radio" onClick="javascript: enableresizing();" value="resizing" <?php
if ($image_resizing == 'resizing') {
echo ' checked';
$width = Session::read('image_resizing_width');
$height = Session::read('image_resizing_height');
}
?>>
</label>
<?php echo '<b>'.get_lang('Resizing').'</b>, '.get_lang('ResizingComment'); ?>
</div>
<div class="form-group">
<label class="col-sm-1 control-label"><?php echo get_lang('Width'); ?></label>
<div class="col-sm-3">
<input class="form-control" name="width" type="text" id="width" <?php
if ($image_resizing == 'resizing') {
echo ' value="'.$width.'"';
echo ' class="enabled_input"';
} else {
echo ' class="disabled_input"';
}
?> >
</div>
<div class="col-sm-8"></div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label"><?php echo get_lang('Height'); ?></label>
<div class="col-sm-3">
<input class="form-control" name="height" type="text" id="height" <?php
if ($image_resizing == 'resizing') {
echo ' value="'.$height.'"';
echo ' class="enabled_input"';
} else {
echo ' class="disabled_input"';
}
?> >
</div>
<div class="col-sm-8"></div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-default" name="Submit" value="Save" ><?php echo get_lang('Save'); ?></button>
</div>
</div>
</form>
</div>
</div>
<?php
Display::display_footer();

342
main/document/upload.php Normal file
View File

@@ -0,0 +1,342 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Main script for the documents tool.
*
* 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)
*
* 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 (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
*
* @todo eliminate code duplication between
* document/document.php, scormdocument.php
*
* @package chamilo.document
*/
require_once __DIR__.'/../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
api_protect_course_script(true);
// Adding extra javascript to the form
$htmlHeadXtra[] = api_get_jquery_libraries_js(['jquery-ui', 'jquery-upload']);
// Variables
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$_course = api_get_course_info();
$groupId = api_get_group_id();
$courseDir = $_course['path'].'/document';
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path.$courseDir;
$sessionId = api_get_session_id();
$selectcat = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : null;
$document_data = [];
if (isset($_REQUEST['id'])) {
$document_data = DocumentManager::get_document_data_by_id(
$_REQUEST['id'],
api_get_course_id(),
true,
$sessionId
);
if ($sessionId != 0 && !$document_data) {
$document_data = DocumentManager::get_document_data_by_id(
$_REQUEST['id'],
api_get_course_id(),
true,
0
);
}
}
if (empty($document_data)) {
$document_id = $parent_id = 0;
$path = '/';
} else {
$document_id = $document_data['id'];
$path = $document_data['path'];
$parent_id = DocumentManager::get_document_id(
api_get_course_info(),
dirname($path)
);
}
$group_properties = [];
$htmlHeadXtra[] = '<script>
function check_unzip() {
if (document.upload.unzip.checked) {
document.upload.if_exists[1].checked=true;
} else {
document.upload.if_exists[2].checked=true;
}
}
function setFocus() {
$("#title_file").focus();
}
</script>';
$groupIid = 0;
// This needs cleaning!
if (!empty($groupId)) {
// If the group id is set, check if the user has the right to be here
// Get group info
$group_properties = GroupManager::get_group_properties($groupId);
$groupIid = $group_properties['iid'];
// Only courseadmin or group members allowed
if ($is_allowed_to_edit || GroupManager::is_user_in_group(api_get_user_id(), $group_properties)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace'),
];
} else {
api_not_allowed(true);
}
GroupManager::allowUploadEditDocument(api_get_user_id(), api_get_course_int_id(), $group_properties, null, true);
} elseif ($is_allowed_to_edit ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $path, api_get_session_id())) {
} else {
// No course admin and no group member...
api_not_allowed(true);
}
// Group docs can only be uploaded in the group directory
if ($groupId != 0 && $path == '/') {
$path = $group_properties['directory'];
}
// I'm in the certification module?
$is_certificate_mode = false;
$is_certificate_array = explode('/', $path);
array_shift($is_certificate_array);
if ($is_certificate_array[0] == 'certificates') {
$is_certificate_mode = true;
}
// Title of the tool
$add_group_to_title = null;
if ($groupId != 0) {
// Add group name after for group documents
$add_group_to_title = ' ('.$group_properties['name'].')';
}
if (isset($_REQUEST['certificate'])) {
$nameTools = get_lang('UploadCertificate').$add_group_to_title;
$is_certificate_mode = true;
} else {
$nameTools = get_lang('UplUploadDocument').$add_group_to_title;
}
$certificateLink = '';
if ($is_certificate_mode) {
$certificateLink = '&certificate=true';
}
// Breadcrumbs
if ($is_certificate_mode) {
$interbreadcrumb[] = [
'url' => '../gradebook/index.php?'.api_get_cidreq().$certificateLink,
'name' => get_lang('Gradebook'),
];
} else {
$interbreadcrumb[] = [
'url' => './document.php?id='.$document_id.'&'.api_get_cidreq().$certificateLink,
'name' => get_lang('Documents'),
];
}
// Interbreadcrumb for the current directory root path
if ($document_data) {
if (empty($document_data['parents'])) {
$interbreadcrumb[] = ['url' => '#', 'name' => $document_data['title']];
} else {
foreach ($document_data['parents'] as $document_sub_data) {
$interbreadcrumb[] = [
'url' => $document_sub_data['document_url'].$certificateLink,
'name' => $document_sub_data['title'],
];
}
}
}
$this_section = SECTION_COURSES;
/* Here we do all the work */
$unzip = isset($_POST['unzip']) ? $_POST['unzip'] : null;
$index = isset($_POST['index_document']) ? $_POST['index_document'] : null;
// User has submitted a file
if (!empty($_FILES)) {
DocumentManager::upload_document(
$_FILES,
$_POST['curdirpath'],
$_POST['title'],
$_POST['comment'],
$unzip,
$_POST['if_exists'],
$index,
true
);
$redirectUrl = api_get_self().'?'.api_get_cidreq().$certificateLink;
if ($document_data) {
$redirectUrl .= '&'.http_build_query(
[
'id' => $document_data['iid'],
]
);
}
header("Location: $redirectUrl");
exit;
}
// Display the header
Display::display_header($nameTools, 'Doc');
// Actions
// Link back to the documents overview
if ($is_certificate_mode) {
$actions = '<a href="document.php?id='.$document_id.'&selectcat='.$selectcat.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('CertificateOverview'), '', ICON_SIZE_MEDIUM).
'</a>';
} else {
$actions = '<a href="document.php?id='.$document_id.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).
'</a>';
}
// Link to create a folder
echo $toolbar = Display::toolbarAction('toolbar-upload', [$actions]);
// Form to select directory
$folders = DocumentManager::get_all_document_folders(
$_course,
$groupIid,
$is_allowed_to_edit
);
if (!$is_certificate_mode) {
echo DocumentManager::build_directory_selector(
$folders,
$document_id,
(isset($group_properties['directory']) ? $group_properties['directory'] : [])
);
}
$action = api_get_self().'?'.api_get_cidreq().'&id='.$document_id.$certificateLink;
$form = new FormValidator(
'upload',
'POST',
$action.'#tabs-2',
'',
['enctype' => 'multipart/form-data']
);
$form->addElement('hidden', 'id', $document_id);
$form->addElement('hidden', 'curdirpath', $path);
$courseQuota = format_file_size(DocumentManager::get_course_quota() - DocumentManager::documents_total_space());
$label =
get_lang('MaxFileSize').': '.getIniMaxFileSizeInBytes(true).'<br/>'.
get_lang('DocumentQuota').': '.$courseQuota;
$form->addElement('BigUpload', 'file', [get_lang('File'), $label], ['id' => 'bigUploadFile', 'data-origin' => 'document']);
//$form->addElement('file', 'file', [get_lang('File'), $label], ['id' => 'user_upload']);
$form->addElement('text', 'title', get_lang('Title'), ['id' => 'title_file']);
$form->addElement('textarea', 'comment', get_lang('Comment'));
// Advanced parameters
$form->addButtonAdvancedSettings('advanced_params');
$form->addElement('html', '<div id="advanced_params_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
$supportedFormats = 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%" >'.$supportedFormats.'</div>'
);
$form->addElement('html', '<br /><div class="sub-form">');
$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->addProgress('DocumentUpload', 'file');
$fileExistsOption = api_get_setting('document_if_file_exists_option');
$defaultFileExistsOption = 'rename';
if (!empty($fileExistsOption)) {
$defaultFileExistsOption = $fileExistsOption;
}
$defaults = [
'index_document' => 'checked="checked"',
'if_exists' => $defaultFileExistsOption,
];
$form->setDefaults($defaults);
$url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?'.api_get_cidreq().'&a=upload_file&curdirpath='.$path;
$multipleForm = new FormValidator(
'drag_drop',
'post',
'#',
['enctype' => 'multipart/form-data']
);
$multipleForm->addMultipleUpload($url);
$headers = [
get_lang('Upload'),
get_lang('Upload').' ('.get_lang('Simple').')',
];
echo Display::tabs($headers, [$multipleForm->returnForm(), $form->returnForm()], 'tabs');
Display::display_footer();

BIN
main/document/webcam.swf Normal file

Binary file not shown.

View File

@@ -0,0 +1,154 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file allows record wav files.
*
* @author Juan Carlos Raña Trabado herodoto@telefonica.net
*
* @since 7/jun/2012
* @Updated 04/09/2015 Upgrade to WebCamJS
*/
require_once __DIR__.'/../inc/global.inc.php';
$_SESSION['whereami'] = 'document/webcamclip';
$this_section = SECTION_COURSES;
$nameTools = get_lang('WebCamClip');
$htmlHeadXtra[] = api_get_js_simple(api_get_path(WEB_PATH).'web/assets/webcamjs/webcam.js');
$htmlHeadXtra[] = api_get_js('webcam_recorder.js');
$groupRights = Session::read('group_member_with_upload_rights');
api_protect_course_script();
api_block_anonymous_users();
$courseInfo = api_get_course_info();
$userId = api_get_user_id();
$courseCode = api_get_course_id();
$groupId = api_get_group_id();
$sessionId = api_get_session_id();
$documentData = DocumentManager::get_document_data_by_id($_GET['id'], $courseCode, true);
$groupProperties = null;
if (!empty($groupId)) {
$groupProperties = GroupManager::get_group_properties($groupId);
}
$documentId = 0;
$dir = '/';
if (empty($documentData)) {
if (api_is_in_group()) {
$documentId = DocumentManager::get_document_id(
$courseInfo,
$groupProperties['directory']
);
$documentData = DocumentManager::get_document_data_by_id($documentId, $courseCode);
$dir = $documentData['path'];
}
} else {
$documentId = $documentData['id'];
$dir = $documentData['path'];
}
$webcamdir = $dir;
if ($webcamdir === '/') {
$webcamdir = '';
}
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
// Please, do not modify this dirname formatting.
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] === '.') {
$dir = substr($dir, 1);
}
if ($dir[0] !== '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] !== '/') {
$dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'.$dir;
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document/';
$dir = '/';
}
if (!empty($groupId)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'name' => get_lang('Groups'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
'name' => get_lang('GroupSpace').' '.$groupProperties['name'],
];
}
$interbreadcrumb[] = [
'url' => "./document.php?id=".$documentId."&".api_get_cidreq(),
'name' => get_lang('Documents'),
];
if (!api_is_allowed_in_course()) {
api_not_allowed(true);
}
$isMySharedFolder = DocumentManager::is_my_shared_folder($userId, Security::remove_XSS($dir), $sessionId);
if (!($isAllowedToEdit || $groupRights || $isMySharedFolder)) {
api_not_allowed(true);
}
Event::event_access_tool(TOOL_DOCUMENT);
$counter = 0;
if (isset($documentData['parents'])) {
foreach ($documentData['parents'] as $documentSubData) {
//fixing double group folder in breadcrumb
if ($groupId) {
if ($counter == 0) {
$counter++;
continue;
}
}
$interbreadcrumb[] = [
'url' => $documentSubData['document_url'],
'name' => $documentSubData['title'],
];
$counter++;
}
}
$actions = Display::toolbarAction(
'webcam_toolbar',
[
Display::url(
Display::return_icon(
'back.png',
get_lang('BackTo').' '.get_lang('DocumentsOverview'),
[],
ICON_SIZE_MEDIUM
),
'document.php?id='.$documentId.'&'.api_get_cidreq()
),
]
);
$template = new Template($nameTools);
$template->assign('webcam_dir', $webcamdir);
$template->assign('user_id', $userId);
$template->assign('filename', 'video_clip.jpg');
$content = $template->fetch($template->get_template('document/webcam.tpl'));
$template->assign('header', get_lang('TakeYourPhotos'));
$template->assign('actions', $actions);
$template->assign('content', $content);
$template->display_one_col_template();

View File

@@ -0,0 +1,99 @@
<?php
/* JPEGCam Script *****UPDATED to lib webcamJS 2015-09-04***** */
/* Receives JPEG webcam submission and saves to local file. */
/* Make sure your directory has permission to write files as your web server user! */
//Changes on directory because move the proper script to the new lib upgrade directory
require_once __DIR__.'/../inc/global.inc.php';
////Add security from Chamilo
api_protect_course_script();
api_block_anonymous_users();
///
// Save the audio to a URL-accessible directory for playback.
parse_str($_SERVER['QUERY_STRING'], $params);
if (isset($params['webcamname']) && isset($params['webcamdir']) && isset($params['webcamuserid'])) {
$webcamname = $params['webcamname'];
$webcamdir = $params['webcamdir'];
$webcamuserid = $params['webcamuserid'];
} else {
api_not_allowed();
exit();
}
if ($webcamuserid != api_get_user_id() || api_get_user_id() == 0 || $webcamuserid == 0) {
api_not_allowed();
exit();
}
//clean
$webcamname = Security::remove_XSS($webcamname);
$webcamname = Database::escape_string($webcamname);
$webcamname = addslashes(trim($webcamname));
$webcamname = api_replace_dangerous_char($webcamname);
$webcamname = disable_dangerous_file($webcamname);
$webcamdir = Security::remove_XSS($webcamdir);
$courseInfo = api_get_course_info();
//security extension
$ext = explode('.', $webcamname);
$ext = strtolower($ext[count($ext) - 1]);
if ($ext !== 'jpg') {
exit;
}
//Do not use here check Fileinfo method because return: text/plain //CHECK THIS BEFORE COMMIT
$dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document';
$saveDir = $dirBaseDocuments.$webcamdir;
$current_session_id = api_get_session_id();
$groupId = api_get_group_id();
$groupInfo = GroupManager::get_group_properties($groupId);
// Avoid duplicates.
$webcamname_to_save = $webcamname;
$title_to_save = str_replace('_', ' ', $webcamname);
$webcamname_noex = basename($webcamname, ".jpg");
if (file_exists($saveDir.'/'.$webcamname_noex.'.'.$ext)) {
$i = 1;
while (file_exists($saveDir.'/'.$webcamname_noex.'_'.$i.'.'.$ext)) {
$i++;
}
$webcamname_to_save = $webcamname_noex.'_'.$i.'.'.$ext;
$title_to_save = $webcamname_noex.'_'.$i.'.'.$ext;
$title_to_save = str_replace('_', ' ', $title_to_save);
}
$documentPath = $saveDir.'/'.$webcamname_to_save;
//read content
//Change to move_uploaded_file() function instead file_get_contents() to adapt the new lib
$content = move_uploaded_file($_FILES['webcam']['tmp_name'], $documentPath);
if (!$content) {
echo "PHP ERROR: Failed to read data\n";
exit();
}
//add document to database
$doc_id = add_document(
$courseInfo,
$webcamdir.'/'.$webcamname_to_save,
'file',
filesize($documentPath),
$title_to_save
);
api_item_property_update(
$courseInfo,
TOOL_DOCUMENT,
$doc_id,
'DocumentAdded',
api_get_user_id(),
$groupInfo,
null,
null,
null,
$current_session_id
);
$url = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI']).'/'.$documentPath;
echo get_lang('ClipSent');

BIN
main/document/welcome.odt Normal file

Binary file not shown.