Merge branch 'BT8314' of https://github.com/danbarretodev/chamilo-lms into danbarretodev-BT8314

1.9.x
Yannick Warnier 12 years ago
commit ee60e4df65
  1. 136
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php
  2. 4
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_delete_file.php
  3. 5
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_copy.php
  4. 4
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_cut.php
  5. 2
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_paste.php
  6. 6
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php
  7. 3
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php
  8. 2
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_name.php
  9. 2
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php
  10. 13
      main/inc/lib/main_api.lib.php

@ -28,80 +28,78 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_NEWFOLDER) {
$error = ERR_FOLDER_NAME_EMPTY;
} elseif (!preg_match("/^[a-zA-Z0-9_\- ]+$/", $_POST['new_folder'])) {
$error = ERR_FOLDER_FORMAT;
} elseif (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) {
$error = ERR_FOLDER_PATH_NOT_ALLOWED;
} elseif (file_exists(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'])) {
$error = ERR_FOLDER_EXISTS;
} else {
if (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) {
$error = ERR_FOLDER_PATH_NOT_ALLOWED;
} elseif (file_exists(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'])) {
$error = ERR_FOLDER_EXISTS;
} else {
include_once CLASS_FILE;
$file = new file();
if ($file->mkdir(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'], 0775)) {
include_once CLASS_MANAGER;
$manager = new manager(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder'], false);
$pathInfo = $manager->getFolderInfo(addTrailingSlash($_POST['currentFolderPath']).$_POST['new_folder']);
//bridge to Chamilo
if (!empty($_course['path'])) {
//only inside courses
$mainPath = '../../../../../../../courses/'.$_course['path'].'/document/'; //get Chamilo
$fullPath = $_POST['currentFolderPath'].$_POST['new_folder']; //get Ajaxfilemanager
$chamiloPath = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1);
$_POST['new_folder'] = str_replace(
'_',
' ',
$_POST['new_folder']
); //Restore for interaction with Chamilo. Because fix long names. See: ajaxfilemanager/inc/class.manager.php
$chamiloFile = $_POST['new_folder']; //get Ajaxfilemanager
include_once CLASS_FILE;
$file = new file();
if ($file->mkdir(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], 0775)) {
event_system(LOG_MY_FOLDER_CREATE, LOG_MY_FOLDER_PATH, $_POST['currentFolderPath'] . $_POST['new_folder']);
include_once CLASS_MANAGER;
$manager = new manager(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], false);
$pathInfo = $manager->getFolderInfo(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder']);
//bridge to Chamilo
if (!empty($_course['path'])) {
//only inside courses
$mainPath = '../../../../../../../courses/'.$_course['path'].'/document/'; //get Chamilo
$fullPath = $_POST['currentFolderPath'].$_POST['new_folder']; //get Ajaxfilemanager
$chamiloPath = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1);
$_POST['new_folder'] = str_replace(
'_',
' ',
$_POST['new_folder']
); //Restore for interaction with Chamilo. Because fix long names. See: ajaxfilemanager/inc/class.manager.php
$chamiloFile = $_POST['new_folder']; //get Ajaxfilemanager
$doc_id = add_document($_course, $chamiloPath, 'folder', 0, $chamiloFile); //get Chamilo
$current_session_id = api_get_session_id(); //get Chamilo
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'FolderCreated',
api_get_user_id(),
$to_group_id,
null,
null,
null,
$current_session_id
); //get Chamilo
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'invisible',
api_get_user_id(),
$to_group_id,
null,
null,
null,
$current_session_id
); //get Chamilo
}
// end bridge to Chamilo
$doc_id = add_document($_course, $chamiloPath, 'folder', 0, $chamiloFile); //get Chamilo
$current_session_id = api_get_session_id(); //get Chamilo
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'FolderCreated',
api_get_user_id(),
$to_group_id,
null,
null,
null,
$current_session_id
); //get Chamilo
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'invisible',
api_get_user_id(),
$to_group_id,
null,
null,
null,
$current_session_id
); //get Chamilo
}
// end bridge to Chamilo
foreach ($pathInfo as $k => $v) {
switch ($k) {
case "ctime";
case "mtime":
case "atime":
$v = date(DATE_TIME_FORMAT, $v);
break;
case 'name':
$info .= sprintf(", %s:'%s'", 'short_name', shortenFileName($v));
break;
case 'cssClass':
$v = 'folderEmpty';
break;
}
$info .= sprintf(", %s:'%s'", $k, $v);
foreach ($pathInfo as $k => $v) {
switch ($k) {
case "ctime";
case "mtime":
case "atime":
$v = date(DATE_TIME_FORMAT, $v);
break;
case 'name':
$info .= sprintf(", %s:'%s'", 'short_name', shortenFileName($v));
break;
case 'cssClass':
$v = 'folderEmpty';
break;
}
} else {
$error = ERR_FOLDER_CREATION_FAILED;
$info .= sprintf(", %s:'%s'", $k, $v);
}
} else {
$error = ERR_FOLDER_CREATION_FAILED;
}
}
echo "error:'".$error."'";

@ -63,6 +63,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) {
'document_path',
addTrailingSlash(backslashToSlash($_GET['delete']))
);
event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $_GET['delete']);
}
//////end bridge to Chamilo
$file->delete(addTrailingSlash(backslashToSlash($_GET['delete'])));
@ -101,6 +102,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) {
} else {
$file->delete($_GET['delete']); //deleted by ajaxfilemanager
event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', $_GET['delete']);
event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $_GET['delete']);
}
//////end bridge to Chamilo
}
@ -158,6 +160,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) {
'document_path',
addTrailingSlash(backslashToSlash($doc))
);
event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $doc);
}
//////end bridge to Chamilo
} elseif (is_file($doc)
@ -196,6 +199,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) {
} else {
$file->delete($doc); //deleted by ajaxfilemanager
event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', $doc);
event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $doc);
}
//////end bridge to Chamilo
}

@ -24,5 +24,8 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_COPY) {
$sessionAction->setFolder($_POST['currentFolderPath']);
$sessionAction->set($_POST['selectedDoc']);
$info = ',num:'.sizeof($_POST['selectedDoc']);
foreach ($_POST['selectedDoc'] as $doc) {
event_system(LOG_MY_FOLDER_COPY, LOG_MY_FOLDER_PATH, $doc);
}
}
echo "{error:'".$error."'\n".$info."}";
echo "{error:'".$error."'\n".$info."}";

@ -26,5 +26,7 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_CUT) {
$sessionAction->setFolder($_POST['currentFolderPath']);
$sessionAction->set($_POST['selectedDoc']);
$info = ',num:'.sizeof($_POST['selectedDoc']);
foreach ($_POST['selectedDoc'] as $doc) {
event_system(LOG_MY_FOLDER_COPY, LOG_MY_FOLDER_PATH, $doc);
}
}
echo "{error:'".$error."'\n".$info."}";

@ -12,6 +12,7 @@ require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanage
$error = '';
$fileMoved = array();
$unmovedDocDueToSamePath = array();
$finalPath = '';
if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
$error = SYS_DISABLED;
} elseif (empty($_GET['current_folder_path'])) {
@ -61,6 +62,7 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
$obj = new manager($finalPath, false);
$fileType = $obj->getFileType($finalPath, (is_dir($finalPath) ? true : false));
event_system(LOG_MY_FOLDER_PASTE, LOG_MY_FOLDER_PATH, $finalPath);
foreach ($fileType as $k => $v) {
$tem[$k] = $v;

@ -14,7 +14,8 @@ require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanage
sleep(3);
echo "{";
$error = "";
$info = "";
$info = "";
$fullPath = '';
include_once CLASS_UPLOAD;
$upload = new Upload();
@ -115,12 +116,13 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD) {
}
$info .= sprintf(", url:'%s'", getFileUrl($path));
$info .= sprintf(", tipedit:'%s'", TIP_DOC_RENAME);
// Log to TRACK_E_DEFAULT
event_system(LOG_MY_FOLDER_UPLOAD, LOG_MY_FOLDER_PATH, $fullPath);
} else {
$error = ERR_FILE_NOT_AVAILABLE;
}
}
}
echo "error:'".$error."'";
echo $info;
echo "}";

@ -10,6 +10,7 @@
require_once '../../../../../../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
$path = isset($_REQUEST['path'])? Security::remove_XSS($_REQUEST['path']) : null ;
if (!isset($manager)) {
/**
* this is part of script for processing file paste
@ -41,7 +42,7 @@ if (!isset($manager)) {
$sessionAction = new SessionAction();
include_once(DIR_AJAX_INC."class.manager.php");
$manager = new manager();
$manager = new manager($path);
$manager->setSessionAction($sessionAction);
$fileList = $manager->getFileList();

@ -70,6 +70,8 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_RENAME) {
$fileInfo = $manager->getFolderInfo();
$fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']);
}
event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_PATH, $_POST['original_path']);
event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_NEW_PATH, $path);
}
echo "{";

@ -82,7 +82,7 @@ class manager
$this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
}
$this->currentFolderPath = (isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash((addTrailingSlash($this->getCurrentFolderPath()))) : CONFIG_SYS_DEFAULT_PATH);
$this->currentFolderPath = (isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash((addTrailingSlash($this->getCurrentFolderPath()))) : $this->currentFolderPath);
$this->currentFolderPath = base64_encode($this->currentFolderPath);
if ($this->calculateSubdir) {

@ -196,7 +196,15 @@ define('LOG_EXERCISE_RESULT_DELETE', 'exe_result_deleted');
define('LOG_LP_ATTEMPT_DELETE', 'lp_attempt_deleted');
define('LOG_QUESTION_RESULT_DELETE', 'qst_attempt_deleted');
// event logs data types (max 20 chars)
define('LOG_MY_FOLDER_CREATE', 'my_folder_created');
define('LOG_MY_FOLDER_CHANGE', 'my_folder_changed');
define('LOG_MY_FOLDER_DELETE', 'my_folder_deleted');
define('LOG_MY_FOLDER_COPY', 'my_folder_copied');
define('LOG_MY_FOLDER_CUT', 'my_folder_cut');
define('LOG_MY_FOLDER_PASTE', 'my_folder_pasted');
define('LOG_MY_FOLDER_UPLOAD', 'my_folder_uploaded');
// Event logs data types
define('LOG_COURSE_CODE', 'course_code');
define('LOG_COURSE_ID', 'course_id');
define('LOG_USER_ID', 'user_id');
@ -218,6 +226,9 @@ define('LOG_EXERCISE_AND_USER_ID', 'exercise_and_user_id');
define('LOG_LP_ID', 'lp_id');
define('LOG_EXERCISE_ATTEMPT_QUESTION_ID', 'exercise_a_q_id');
define('LOG_MY_FOLDER_PATH', 'path');
define('LOG_MY_FOLDER_NEW_PATH', 'new_path');
define('USERNAME_PURIFIER', '/[^0-9A-Za-z_\.]/');
//used when login_is_email setting is true

Loading…
Cancel
Save