Browse Source

Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into 1.9.x

Yannick Warnier 11 years ago
parent
commit
0b40fb36ba
68 changed files with 4626 additions and 3907 deletions
  1. 53 47
      main/dropbox/dropbox_class.inc.php
  2. 14 15
      main/dropbox/dropbox_config.inc.php
  3. 85 98
      main/dropbox/dropbox_download.php
  4. 186 187
      main/dropbox/dropbox_functions.inc.php
  5. 137 49
      main/dropbox/dropbox_init.inc.php
  6. 49 96
      main/dropbox/dropbox_submit.php
  7. 64 141
      main/dropbox/index.php
  8. 133 2
      main/inc/ajax/model.ajax.php
  9. 6 2
      main/inc/lib/course.lib.php
  10. 47 40
      main/inc/lib/fckeditor/editor/filemanager/connectors/php/config.php
  11. 6 24
      main/inc/lib/fckeditor/editor/plugins/ImageManager/Classes/ImageManager.php
  12. 42 54
      main/inc/lib/fckeditor/editor/plugins/ImageManager/config.inc.php
  13. 0 2
      main/inc/lib/fckeditor/editor/plugins/ImageManager/editor.php
  14. 23 25
      main/inc/lib/fckeditor/editor/plugins/ImageManager/editorFrame.php
  15. 6 14
      main/inc/lib/fckeditor/editor/plugins/ImageManager/manager.php
  16. 151 126
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_details_listing.php
  17. 138 83
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php
  18. 12 11
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_load_folders.php
  19. 81 60
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php
  20. 15 13
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_delete_file.php
  21. 28 30
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_download.php
  22. 102 115
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_editor_reset.php
  23. 29 32
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_copy.php
  24. 29 32
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_cut.php
  25. 206 62
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_paste.php
  26. 104 80
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php
  27. 24 27
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php
  28. 14 12
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_folder_listing.php
  29. 244 205
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_editor.php
  30. 169 194
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_save.php
  31. 18 14
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_thumbnail.php
  32. 81 91
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_undo.php
  33. 40 44
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_login.php
  34. 40 40
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_preview.php
  35. 41 35
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_as_form.php
  36. 76 79
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_name.php
  37. 57 84
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_text.php
  38. 144 148
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_text_editor.php
  39. 677 676
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php
  40. 0 5
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php
  41. 3 4
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.php
  42. 0 131
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.tinymce.php
  43. 0 11
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php
  44. 14 11
      main/inc/lib/fckeditor/fckeditor.php
  45. 6 18
      main/inc/lib/fckeditor/fcktemplates.xml.php
  46. 1 19
      main/inc/lib/fckeditor/myconfig.php
  47. 72 69
      main/inc/lib/fckeditor/repository.php
  48. 9 33
      main/inc/lib/fileDisplay.lib.php
  49. 2 2
      main/inc/lib/groupmanager.lib.php
  50. 3 2
      main/inc/lib/main_api.lib.php
  51. 408 34
      main/inc/lib/sessionmanager.lib.php
  52. 50 32
      main/inc/lib/tracking.lib.php
  53. 23 7
      main/inc/local.inc.php
  54. 43 0
      main/lang/slovak/admin.inc.php
  55. 2 0
      main/lang/slovak/create_course.inc.php
  56. 16 16
      main/lang/slovak/exercice.inc.php
  57. 41 4
      main/lang/slovak/install.inc.php
  58. 23 0
      main/lang/slovak/tracking.inc.php
  59. 1 1
      main/lang/slovak/trad4all.inc.php
  60. 258 279
      main/mySpace/index.php
  61. 114 0
      main/mySpace/myspace.lib.php
  62. 18 60
      main/mySpace/student.php
  63. 2 6
      main/survey/survey.lib.php
  64. 133 71
      main/user/user.php
  65. 1 0
      main/work/add_user.php
  66. 1 1
      main/work/student_work.php
  67. 10 1
      main/work/work.lib.php
  68. 1 1
      tests/main/inc/lib/main_api.lib.test.php

+ 53 - 47
main/dropbox/dropbox_class.inc.php

@@ -68,11 +68,11 @@ class Dropbox_Work
      * @param unknown_type $arg6
      * @return Dropbox_Work
      */
-    function Dropbox_Work($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null)
+    public function Dropbox_Work($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null)
     {
         if (func_num_args() > 1) {
             $this->_createNewWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
-        }  else  {
+        } else {
             $this->_createExistingWork($arg1);
         }
     }
@@ -80,33 +80,35 @@ class Dropbox_Work
 	/**
 	 * private function creating a new work object
 	 *
-	 * @param unknown_type $uploader_id
-	 * @param unknown_type $title
-	 * @param unknown_type $description
-	 * @param unknown_type $author
-	 * @param unknown_type $filename
-	 * @param unknown_type $filesize
+	 * @param int $uploader_id
+	 * @param string $title
+	 * @param string $description
+	 * @param string $author
+	 * @param string $filename
+	 * @param int $filesize
 	 *
 	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
 	 * 			As a consequence this parameter can be removed
 	 */
-	function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
+	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
     {
-		global $_user, $dropbox_cnf;
-		// Fill in the properties
-		$this->uploader_id = intval($uploader_id);
-		$this->uploaderName = getUserNameFromId($this->uploader_id);
-		$this->filename = $filename;
-		$this->filesize = $filesize;
-		$this->title = $title;
-		$this->description = $description;
-		$this->author = api_get_person_name($_user['firstName'], $_user['lastName']);
-		$this->last_upload_date = api_get_utc_datetime();
-		$course_id = api_get_course_int_id();
+        $_user = api_get_user_info();
+        $dropbox_cnf = getDropboxConf();
+
+        // Fill in the properties
+        $this->uploader_id = intval($uploader_id);
+        $this->uploaderName = getUserNameFromId($this->uploader_id);
+        $this->filename = $filename;
+        $this->filesize = $filesize;
+        $this->title = $title;
+        $this->description = $description;
+        $this->author = api_get_person_name($_user['firstName'], $_user['lastName']);
+        $this->last_upload_date = api_get_utc_datetime();
+        $course_id = api_get_course_int_id();
 
-		// Check if object exists already. If it does, the old object is used
-		// with updated information (authors, description, upload_date)
-		$this->isOldWork = false;
+        // Check if object exists already. If it does, the old object is used
+        // with updated information (authors, description, upload_date)
+        $this->isOldWork = false;
 		$sql = "SELECT id, upload_date FROM ".$dropbox_cnf['tbl_file']."
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
         $result = Database::query($sql);
@@ -138,7 +140,7 @@ class Dropbox_Work
 						, '".Database::escape_string($this->author)."'
 						, '".Database::escape_string($this->upload_date)."'
 						, '".Database::escape_string($this->last_upload_date)."'
-						, ".intval($_SESSION['id_session'])."
+						, ".api_get_session_id()."
 						)";
 
         	Database::query($sql);
@@ -166,10 +168,12 @@ class Dropbox_Work
 	 *
 	 * @param int $id
 	 */
-	function _createExistingWork($id)
+	public function _createExistingWork($id)
     {
 	    $course_id = api_get_course_int_id();
-		global $_user, $dropbox_cnf;
+        $dropbox_cnf = getDropboxConf();
+
+        $action = isset($_GET['action']) ? $_GET['action'] : null;
 
 		// Do some sanity checks
 		$id	= intval($id);
@@ -205,7 +209,7 @@ class Dropbox_Work
 		$this->category = $res['cat_id'];
 
 		// Getting the feedback on the work.
-		if ($_GET['action'] == 'viewfeedback' AND $this->id == $_GET['id']) {
+		if ($action == 'viewfeedback' AND $this->id == $_GET['id']) {
 			$feedback2 = array();
 			$sql_feedback = "SELECT * FROM ".$dropbox_cnf['tbl_feedback']." WHERE c_id = $course_id AND file_id='".$id."' ORDER BY feedback_id ASC";
 			$result = Database::query($sql_feedback);
@@ -247,17 +251,19 @@ class Dropbox_SentWork extends Dropbox_Work
 	/**
 	 * private function creating a new SentWork object
 	 *
-	 * @param unknown_type $uploader_id
-	 * @param unknown_type $title
-	 * @param unknown_type $description
-	 * @param unknown_type $author
-	 * @param unknown_type $filename
-	 * @param unknown_type $filesize
-	 * @param unknown_type $recipient_ids
+	 * @param int $uploader_id
+	 * @param string $title
+	 * @param string $description
+	 * @param string $author
+	 * @param string $filename
+	 * @param int $filesize
+	 * @param array $recipient_ids
 	 */
-	function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
+	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
     {
-			global $dropbox_cnf;
+        $dropbox_cnf = getDropboxConf();
+        $_course = api_get_course_info();
+
 		// Call constructor of Dropbox_Work object
 		$this->Dropbox_Work($uploader_id, $title, $description, $author, $filename, $filesize);
 
@@ -275,9 +281,11 @@ class Dropbox_SentWork extends Dropbox_Work
 			$justSubmit = true;
 			$recipient_ids = array($uploader_id);
 		}
+
 		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
 			die(get_lang('GeneralError').' (code 209)');
 		}
+
 		foreach ($recipient_ids as $rec) {
 			if (empty($rec)) die(get_lang('GeneralError').' (code 210)');
 			//if (!isCourseMember($rec)) die(); //cannot sent document to someone outside of course
@@ -314,7 +322,6 @@ class Dropbox_SentWork extends Dropbox_Work
             }
 
 			// Update item_property table for each recipient
-			global $_course, $dropbox_cnf;
 			if (($ownerid = $this->uploader_id) > $dropbox_cnf['mailingIdBase']) {
 			    $ownerid = getUserOwningThisMailing($ownerid);
 			}
@@ -332,8 +339,7 @@ class Dropbox_SentWork extends Dropbox_Work
 	 */
 	function _createExistingSentWork ($id)
     {
-		global $dropbox_cnf;
-
+        $dropbox_cnf = getDropboxConf();
         $id = intval($id);
 
 		$course_id = api_get_course_int_id();
@@ -533,7 +539,7 @@ class Dropbox_Person
 	 */
 	function deleteAllReceivedWork () {
 	    $course_id = api_get_course_int_id();
-		global $dropbox_cnf;
+        $dropbox_cnf = getDropboxConf();
 		// Delete entries in person table concerning received works
 		foreach ($this->receivedWork as $w) {
 			Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'");
@@ -546,7 +552,7 @@ class Dropbox_Person
 	 */
 	function deleteReceivedWorkFolder($id)
     {
-		global $dropbox_cnf;
+        $dropbox_cnf = getDropboxConf();
         $course_id = api_get_course_int_id();
 
 		$id = intval($id);
@@ -567,7 +573,7 @@ class Dropbox_Person
 	function deleteReceivedWork($id)
     {
 	    $course_id = api_get_course_int_id();
-		global $dropbox_cnf;
+        $dropbox_cnf = getDropboxConf();
 		$id = intval($id);
 
 		// index check
@@ -596,7 +602,7 @@ class Dropbox_Person
 	function deleteAllSentWork()
     {
 	    $course_id = api_get_course_int_id();
-		global $dropbox_cnf;
+        $dropbox_cnf = getDropboxConf();
 		//delete entries in person table concerning sent works
 		foreach ($this->sentWork as $w) {
 			Database::query("DELETE FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'");
@@ -613,8 +619,8 @@ class Dropbox_Person
 	function deleteSentWork($id)
     {
 	    $course_id = api_get_course_int_id();
+        $dropbox_cnf = getDropboxConf();
 
-		global $dropbox_cnf;
 		$id = intval($id);
 
 		// index check
@@ -646,8 +652,9 @@ class Dropbox_Person
 	function updateFeedback($id, $text)
     {
 	    $course_id = api_get_course_int_id();
+        $_course = api_get_course_info();
+        $dropbox_cnf = getDropboxConf();
 
-		global $_course, $dropbox_cnf;
 		$id = intval($id);
 
 		// index check
@@ -688,8 +695,7 @@ class Dropbox_Person
 	 */
 	function filter_received_work($type, $value)
     {
-		global $dropbox_cnf;
-
+        $dropbox_cnf = getDropboxConf();
     	$new_received_work = array();
 		foreach ($this->receivedWork as $work) {
 			switch ($type) {

+ 14 - 15
main/dropbox/dropbox_config.inc.php

@@ -1,17 +1,11 @@
 <?php
 /* For licensing terms, see /license.txt */
 
-/**
- *  DEBUGGING VARS
- */
-$DEBUG = false; // TODO: Is this needed?
-
 /**
  *  DATABASE TABLE VARIABLES
  */
 $dropbox_cnf['tbl_user']        = Database::get_main_table(TABLE_MAIN_USER);
 $dropbox_cnf['tbl_course_user'] = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-
 $dropbox_cnf['tbl_post'] 		= Database::get_course_table(TABLE_DROPBOX_POST);
 $dropbox_cnf['tbl_file'] 		= Database::get_course_table(TABLE_DROPBOX_FILE);
 $dropbox_cnf['tbl_person'] 		= Database::get_course_table(TABLE_DROPBOX_PERSON);
@@ -23,19 +17,22 @@ $dropbox_cnf['tbl_feedback'] 	= Database::get_course_table(TABLE_DROPBOX_FEEDBAC
  *  INITIALISE OTHER VARIABLES & CONSTANTS
  */
 $dropbox_cnf['courseId'] 				= $_cid;
-$dropbox_cnf['sysPath'] 				= api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox'; //path to dropbox subdir in course containing the uploaded files
+//path to dropbox subdir in course containing the uploaded files
+$dropbox_cnf['sysPath'] 				= api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox';
 $dropbox_cnf['webPath'] 				= api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/dropbox';
-$dropbox_cnf['maxFilesize'] 			= api_get_setting('dropbox_max_filesize'); //file size limit as imposed by the platform admin (see Chamilo Config Settings on the platform administration section)
-//$dropbox_cnf['version'] 				= '1.4';
-$dropbox_cnf['allowOverwrite'] 			= string_2_boolean(api_get_setting('dropbox_allow_overwrite'));
-$dropbox_cnf['allowJustUpload'] 		= string_2_boolean(api_get_setting('dropbox_allow_just_upload'));
-$dropbox_cnf['allowStudentToStudent'] 	= string_2_boolean(api_get_setting('dropbox_allow_student_to_student'));
-$dropbox_cnf['allowGroup'] 				= string_2_boolean(api_get_setting('dropbox_allow_group'));
+
+//file size limit as imposed by the platform admin (see Chamilo Config Settings on the platform administration section)
+$dropbox_cnf['maxFilesize'] 			= api_get_setting('dropbox_max_filesize');
+$dropbox_cnf['allowOverwrite'] 			= api_string_2_boolean(api_get_setting('dropbox_allow_overwrite'));
+$dropbox_cnf['allowJustUpload'] 		= api_string_2_boolean(api_get_setting('dropbox_allow_just_upload'));
+$dropbox_cnf['allowStudentToStudent'] 	= api_string_2_boolean(api_get_setting('dropbox_allow_student_to_student'));
+$dropbox_cnf['allowGroup'] 				= api_string_2_boolean(api_get_setting('dropbox_allow_group'));
 
 /**
- * INITIALISE MAILING VARIABLES
+ * MAILING VARIABLES
  */
-$dropbox_cnf['allowMailing'] = string_2_boolean(api_get_setting('dropbox_allow_mailing'));  // false = no mailing functionality
+// false = no mailing functionality
+$dropbox_cnf['allowMailing'] = api_string_2_boolean(api_get_setting('dropbox_allow_mailing'));
 $dropbox_cnf['mailingIdBase'] = 10000000;  // bigger than any user_id,
 // allowing enough space for pseudo_ids as uploader_id, dest_user_id, user_id:
 // mailing pseudo_id = dropbox_cnf('mailingIdBase') + mailing id
@@ -45,3 +42,5 @@ $dropbox_cnf['mailingWhereUSERID'] = 'username';
 $dropbox_cnf['mailingWhereLOGINNAME'] = 'username';
 $dropbox_cnf['mailingFileRegexp'] = '/^(.+)\.\w{1,4}$/';
 $dropbox_cnf['sent_received_tabs'] = true;
+
+return $dropbox_cnf;

+ 85 - 98
main/dropbox/dropbox_download.php

@@ -6,10 +6,8 @@
 /**
  * Code
  */
-/*	INIT SECTION */
 
 // We cannot use dropbox_init.inc.php because this one already outputs data.
-
 $language_file = 'dropbox';
 
 // including the basic Chamilo initialisation file
@@ -32,137 +30,126 @@ $course_id = api_get_course_int_id();
 $user_id = api_get_user_id();
 
 if (isset($_GET['cat_id']) AND is_numeric($_GET['cat_id']) AND $_GET['action'] == 'downloadcategory' AND isset($_GET['sent_received'])) {
-	// step 1: constructingd' the sql statement. Due to the nature off the classes of the dropbox the categories for sent files are stored in the table
-	// dropbox_file while the categories for the received files are stored in dropbox_post. It would have been more elegant if these could be stored
-	// in dropbox_person (which stores the link file-person)
-	// Therefore we have to create to separate sql statements to find which files are in the categorie (depending if we zip-download a sent category or a
-	// received category)
-
-	if ($_GET['sent_received'] == 'sent') {
-		// here we also incorporate the person table to make sure that deleted sent documents are not included.
-		$sql = "SELECT DISTINCT file.id, file.filename, file.title
+    /** step 1: constructing the sql statement.
+    Due to the nature off the classes of the dropbox the categories for sent files are stored in the table
+    dropbox_file while the categories for the received files are stored in dropbox_post.
+    It would have been more elegant if these could be stored in dropbox_person (which stores the link file-person)
+    Therefore we have to create to separate sql statements to find which files are in the category
+    (depending if we zip-download a sent category or a received category)*/
+
+    if ($_GET['sent_received'] == 'sent') {
+        // here we also incorporate the person table to make sure that deleted sent documents are not included.
+        $sql = "SELECT DISTINCT file.id, file.filename, file.title
                 FROM ".$dropbox_cnf['tbl_file']." file INNER JOIN ".$dropbox_cnf['tbl_person']." person
                 ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
-				WHERE
+                WHERE
                     file.uploader_id = $user_id AND
                     file.cat_id='".intval($_GET['cat_id'])."'  AND
                     person.user_id = $user_id";
-	}
+    }
 
-	if ($_GET['sent_received'] == 'received') {
-		$sql = "SELECT DISTINCT file.id, file.filename, file.title
+    if ($_GET['sent_received'] == 'received') {
+        $sql = "SELECT DISTINCT file.id, file.filename, file.title
                 FROM ".$dropbox_cnf['tbl_file']." file INNER JOIN ".$dropbox_cnf['tbl_person']." person
                 ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
                 INNER JOIN ".$dropbox_cnf['tbl_post']." post
                 ON (post.file_id = file.id AND post.c_id = $course_id AND file.c_id = $course_id)
-				WHERE
+                WHERE
                     post.cat_id = ".intval($_GET['cat_id'])." AND
                     post.dest_user_id = $user_id" ;
-	}
-
-	$result = Database::query($sql);
-	while ($row = Database::fetch_array($result)) {
-		$files_to_download[] = $row['id'];
-	}
-	if (!is_array($files_to_download) OR empty($files_to_download)) {
-		header('location: index.php?view='.Security::remove_XSS($_GET['sent_received']).'&error=ErrorNoFilesInFolder');
-		exit;
-	}
-	zip_download($files_to_download);
-	exit;
-}
-
+    }
 
+    $result = Database::query($sql);
+    while ($row = Database::fetch_array($result)) {
+        $files_to_download[] = $row['id'];
+    }
+    if (!is_array($files_to_download) OR empty($files_to_download)) {
+        header('location: index.php?view='.Security::remove_XSS($_GET['sent_received']).'&error=ErrorNoFilesInFolder');
+        exit;
+    }
+    zip_download($files_to_download);
+    exit;
+}
 /*	DOWNLOAD A FILE */
-
-/*		AUTHORIZATION */
+/* AUTHORIZATION */
 
 // Check if the id makes sense
 if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
-	Display::display_header($nameTools, 'Dropbox');
-	Display :: display_error_message(get_lang('Error'));
-	Display::display_footer();
-	exit;
+    Display::display_header($nameTools, 'Dropbox');
+    Display :: display_error_message(get_lang('Error'));
+    Display::display_footer();
+    exit;
 }
 
 // Check if the user is allowed to download the file
 $allowed_to_download = false;
 if (user_can_download_file($_GET['id'], api_get_user_id())) {
-	$allowed_to_download = true;
+    $allowed_to_download = true;
 }
 
 /*		ERROR IF NOT ALLOWED TO DOWNLOAD */
 
-
 if (!$allowed_to_download) {
-	Display::display_header($nameTools, 'Dropbox');
-	Display::display_error_message(get_lang('YouAreNotAllowedToDownloadThisFile'));
-	Display::display_footer();
+    Display::display_header($nameTools, 'Dropbox');
+    Display::display_error_message(get_lang('YouAreNotAllowedToDownloadThisFile'));
+    Display::display_footer();
 	exit;
 } else {
     /*      DOWNLOAD THE FILE */
     // the user is allowed to download the file
-	$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX][] = intval($_GET['id']);
+    $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX][] = intval($_GET['id']);
 
-	$work = new Dropbox_work($_GET['id']);
-	$path = dropbox_cnf('sysPath') . '/' . $work -> filename; //path to file as stored on server
+    $work = new Dropbox_work($_GET['id']);
+    $path = dropbox_cnf('sysPath') . '/' . $work -> filename; //path to file as stored on server
 
     if (!Security::check_abs_path($path, dropbox_cnf('sysPath').'/')) {
-    	exit;
+        exit;
+    }
+    $file = $work->title;
+    $mimetype = DocumentManager::file_get_mime_type(true);
+    $fileinfo = pathinfo($file);
+    $extension = $fileinfo['extension'];
+
+    if (!empty($extension) && isset($mimetype[$extension]) && $_GET['action'] != 'download') {
+        // give hint to browser about filetype
+        header( 'Content-type: ' . $mimetype[$extension] . "\n");
+    } else {
+        //no information about filetype: force a download dialog window in browser
+        header( "Content-type: application/octet-stream\n");
     }
-	$file = $work->title;
-	$mimetype = DocumentManager::file_get_mime_type(true);
-	$fileinfo = pathinfo($file);
-	$extension = $fileinfo['extension'];
-
-	if (!empty($extension) && isset($mimetype[$extension]) && $_GET['action'] != 'download') {
-	    // give hint to browser about filetype
-    	header( 'Content-type: ' . $mimetype[$extension] . "\n");
-	} else {
-		//no information about filetype: force a download dialog window in browser
-		header( "Content-type: application/octet-stream\n");
-	}
-
-	/*if (!in_array(strtolower($extension), array('doc', 'xls', 'ppt', 'pps', 'sxw', 'sxc', 'sxi'))) {
-		header('Content-Disposition: inline; filename='.$file); // bugs with open office
-	} else {
-		header('Content-Disposition: attachment; filename='.$file);
-	}*/
-
-	header('Content-Disposition: attachment; filename='.$file);
-
-	/**
-	 * Note that if you use these two headers from a previous example:
-	 * header('Cache-Control: no-cache, must-revalidate');
-	 * header('Pragma: no-cache');
-	 * before sending a file to the browser, the "Open" option on Internet Explorer's file download dialog will not work properly. If the user clicks "Open" instead of "Save," the target application will open an empty file, because the downloaded file was not cached. The user will have to save the file to their hard drive in order to use it.
-	 * Make sure to leave these headers out if you'd like your visitors to be able to use IE's "Open" option.
-	 */
-	header("Pragma: \n");
-	header("Cache-Control: \n");
-	header("Cache-Control: public\n"); // IE cannot download from sessions without a cache
-
-	/*if (isset($_SERVER['HTTPS'])) {
-	    /**
-	     * We need to set the following headers to make downloads work using IE in HTTPS mode.
-	     *
-	    //header('Pragma: ');
-	    //header('Cache-Control: ');
-	    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n");
-	    header("Last-Modified: " . gmdate( "D, d M Y H:i:s") . " GMT\n");
-	    header("Cache-Control: no-store, no-cache, must-revalidate\n"); // HTTP/1.1
-	    header("Cache-Control: post-check=0, pre-check=0\n", false);
-	}*/
-
-	header('Content-Description: '.trim(htmlentities($file)));
-	header('Content-transfer-encoding: binary');
-
-	header("Content-Length: " . filesize($path)."\n" );
-
-	$fp = fopen( $path, 'rb');
-	fpassthru($fp);
-	exit();
+    header('Content-Disposition: attachment; filename='.$file);
+
+    /**
+     * Note that if you use these two headers from a previous example:
+     * header('Cache-Control: no-cache, must-revalidate');
+     * header('Pragma: no-cache');
+     * before sending a file to the browser, the "Open" option on Internet Explorer's file download dialog will not work properly. If the user clicks "Open" instead of "Save," the target application will open an empty file, because the downloaded file was not cached. The user will have to save the file to their hard drive in order to use it.
+     * Make sure to leave these headers out if you'd like your visitors to be able to use IE's "Open" option.
+     */
+    header("Pragma: \n");
+    header("Cache-Control: \n");
+    header("Cache-Control: public\n"); // IE cannot download from sessions without a cache
+
+    /*if (isset($_SERVER['HTTPS'])) {
+        /**
+         * We need to set the following headers to make downloads work using IE in HTTPS mode.
+         *
+        //header('Pragma: ');
+        //header('Cache-Control: ');
+        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT\n");
+        header("Last-Modified: " . gmdate( "D, d M Y H:i:s") . " GMT\n");
+        header("Cache-Control: no-store, no-cache, must-revalidate\n"); // HTTP/1.1
+        header("Cache-Control: post-check=0, pre-check=0\n", false);
+    }*/
+
+    header('Content-Description: '.trim(htmlentities($file)));
+    header('Content-transfer-encoding: binary');
+
+    header("Content-Length: " . filesize($path)."\n" );
+
+    $fp = fopen( $path, 'rb');
+    fpassthru($fp);
+    exit();
 }
-
 //@todo clean this file the code below is useless there are 2 exits in previous conditions ... maybe a bad copy/paste/merge?
 exit;

+ 186 - 187
main/dropbox/dropbox_functions.inc.php

@@ -7,6 +7,7 @@
 * to one file 		-- Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @author Julio Montoya adding c_id support
 */
+use \ChamiloSession as Session;
 
 $this_section = SECTION_COURSES;
 
@@ -25,22 +26,24 @@ $(document).ready(function () {
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function handle_multiple_actions() {
-	global $_user, $is_courseAdmin, $is_courseTutor;
-
-	// STEP 1: are we performing the actions on the received or on the sent files?
-	if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'download_received') {
-		$part = 'received';
-	} elseif ($_POST['action'] == 'delete_sent' || $_POST['action'] == 'download_sent') {
-		$part = 'sent';
-	}
+function handle_multiple_actions()
+{
+    $_user = api_get_user_info();
+    $is_courseAdmin = api_is_course_admin();
+    $is_courseTutor = api_is_course_tutor();
+
+    // STEP 1: are we performing the actions on the received or on the sent files?
+    if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'download_received') {
+        $part = 'received';
+    } elseif ($_POST['action'] == 'delete_sent' || $_POST['action'] == 'download_sent') {
+        $part = 'sent';
+    }
 
-	// STEP 2: at least one file has to be selected. If not we return an error message
-    $ids = Request::get('id', array());
-    if(count($ids)>0){
+    // STEP 2: at least one file has to be selected. If not we return an error message
+    $ids = issset($_GET['id']) ? $_GET['id'] : array();
+    if (count($ids)>0) {
         $checked_file_ids = $_POST['id'];
-    }
-    else{
+    } else {
         foreach ($_POST as $key => $value) {
             if (strstr($value, $part.'_') AND $key != 'view_received_category' AND $key != 'view_sent_category') {
                 $checked_files = true;
@@ -48,38 +51,38 @@ function handle_multiple_actions() {
             }
         }
     }
-	$checked_file_ids = $_POST['id'];
+    $checked_file_ids = $_POST['id'];
 
-	if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
-		return get_lang('CheckAtLeastOneFile');
-	}
+    if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
+        return get_lang('CheckAtLeastOneFile');
+    }
 
-	// STEP 3A: deleting
-	if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'delete_sent') {
-		$dropboxfile = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
-		foreach ($checked_file_ids as $key => $value) {
-			if ($_GET['view'] == 'received') {
-				$dropboxfile->deleteReceivedWork($value);
-				$message = get_lang('ReceivedFileDeleted');
-			}
-			if ($_GET['view'] == 'sent' OR empty($_GET['view'])) {
-				$dropboxfile->deleteSentWork($value);
-				$message = get_lang('SentFileDeleted');
-			}
-		}
-		return $message;
-	}
+    // STEP 3A: deleting
+    if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'delete_sent') {
+        $dropboxfile = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
+        foreach ($checked_file_ids as $key => $value) {
+            if ($_GET['view'] == 'received') {
+                $dropboxfile->deleteReceivedWork($value);
+                $message = get_lang('ReceivedFileDeleted');
+            }
+            if ($_GET['view'] == 'sent' OR empty($_GET['view'])) {
+                $dropboxfile->deleteSentWork($value);
+                $message = get_lang('SentFileDeleted');
+            }
+        }
+        return $message;
+    }
 
-	// STEP 3B: giving comment
-	if ($_POST['actions'] == 'comment') {
-		// This has not been implemented.
-		// The idea was that it would be possible to write the same feedback for the selected documents.
-	}
+    // STEP 3B: giving comment
+    if ($_POST['actions'] == 'comment') {
+        // This has not been implemented.
+        // The idea was that it would be possible to write the same feedback for the selected documents.
+    }
 
-	// STEP 3C: moving
-	if (strstr($_POST['action'], 'move_')) {
-        	// check move_received_n or move_sent_n command
-		if (strstr($_POST['action'], 'received')) {
+    // STEP 3C: moving
+    if (strstr($_POST['action'], 'move_')) {
+            // check move_received_n or move_sent_n command
+        if (strstr($_POST['action'], 'received')) {
               $part = 'received';
               $to_cat_id = str_replace('move_received_', '', $_POST['action']);
         } else {
@@ -87,16 +90,25 @@ function handle_multiple_actions() {
               $to_cat_id = str_replace('move_sent_', '', $_POST['action']);
         }
 
-		foreach ($checked_file_ids as $key => $value) {
-			store_move($value, $to_cat_id, $part);
-		}
-		return get_lang('FilesMoved');
+        foreach ($checked_file_ids as $key => $value) {
+            store_move($value, $to_cat_id, $part);
+        }
+        return get_lang('FilesMoved');
     }
 
-	// STEP 3D: downloading
-	if ($_POST['action'] == 'download_sent' || $_POST['action'] == 'download_received') {
-		zip_download($checked_file_ids);
-	}
+    // STEP 3D: downloading
+    if ($_POST['action'] == 'download_sent' || $_POST['action'] == 'download_received') {
+        zip_download($checked_file_ids);
+    }
+}
+
+/**
+ * Get conf settings
+ * @return array
+ */
+function getDropboxConf()
+{
+    return Session::read('dropbox_conf');
 }
 
 /**
@@ -107,18 +119,22 @@ function handle_multiple_actions() {
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function delete_category($action, $id, $user_id = null) {
+function delete_category($action, $id, $user_id = null)
+{
     $course_id = api_get_course_int_id();
-
-	global $dropbox_cnf;
-	global $is_courseAdmin, $is_courseTutor;
+    $is_courseAdmin = api_is_course_admin();
+    $is_courseTutor = api_is_course_tutor();
+    $dropbox_cnf = getDropboxConf();
 
     if (empty($user_id)) {
         $user_id = api_get_user_id();
     }
 
     $cat = get_dropbox_category($id);
-    if (count($cat)==0) { return false; }
+    if (count($cat)==0) {
+        return false;
+    }
+
     if ($cat['user_id'] != $user_id && !api_is_platform_admin($user_id)) {
         return false;
     }
@@ -160,15 +176,16 @@ function delete_category($action, $id, $user_id = null) {
 
 /**
 * Displays the form to move one individual file to a category
-*
-* @return html code of the form that appears in a message box.
-*
+*@ return html code of the form that appears in a message box.
 * @author Julio Montoya - function rewritten
-
 */
-function display_move_form($part, $id, $target = array(), $extra_params = array())
+function display_move_form($part, $id, $target = array(), $extra_params = array(), $viewReceivedCategory, $viewSentCategory, $view)
 {
-    $form = new FormValidator('form1', 'post', api_get_self().'?view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&view='.Security::remove_XSS($_GET['view']).'&'.$extra_params);
+    $form = new FormValidator(
+        'form1',
+        'post',
+        api_get_self().'?view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&'.$extra_params
+    );
 	$form->addElement('header', get_lang('MoveFileTo'));
     $form->addElement('hidden', 'id', intval($id));
     $form->addElement('hidden', 'part', Security::remove_XSS($part));
@@ -180,7 +197,6 @@ function display_move_form($part, $id, $target = array(), $extra_params = array(
     $form->addElement('select', 'move_target', get_lang('MoveFileTo'), $options);
     $form->addElement('button', 'do_move', get_lang('MoveFile'));
     $form->display();
-
 }
 
 /**
@@ -197,7 +213,8 @@ function display_move_form($part, $id, $target = array(), $extra_params = array(
 */
 function store_move($id, $target, $part)
 {
-	global $_user, $dropbox_cnf;
+    $_user = api_get_user_info();
+    $dropbox_cnf = getDropboxConf();
     $course_id = api_get_course_int_id();
 
 	if ((isset($id) AND $id != '') AND (isset($target) AND $target != '') AND (isset($part) AND $part != '')) {
@@ -241,7 +258,7 @@ function display_action_options($part, $categories, $current_category = 0)
 		if ($current_category != 0) {
 			echo '<option value="move_0">'.get_lang('Root').'</a>';
 		}
-		foreach ($categories as $key => $value) {
+		foreach ($categories as $value) {
 			if ($current_category != $value['cat_id']) {
 				echo '<option value="move_'.$value['cat_id'].'">'.$value['cat_name'].'</option>';
 			}
@@ -285,9 +302,8 @@ function display_file_checkbox($id, $part) {
 function get_dropbox_categories($filter = '')
 {
     $course_id = api_get_course_int_id();
-	global $_user;
-	global $dropbox_cnf;
-
+    $_user = api_get_user_info();
+    $dropbox_cnf = getDropboxConf();
 	$return_array = array();
 
 	$session_id = api_get_session_id();
@@ -310,8 +326,9 @@ function get_dropbox_categories($filter = '')
  * @param int The category ID
  * @return array The details of this category
  */
-function get_dropbox_category($id) {
-    global $dropbox_cnf;
+function get_dropbox_category($id)
+{
+    $dropbox_cnf = getDropboxConf();
     $course_id = api_get_course_int_id();
     if (empty($id) or $id != intval($id)) { return array(); }
     $sql = "SELECT * FROM ".$dropbox_cnf['tbl_category']." WHERE c_id = $course_id AND cat_id='".$id."'";
@@ -337,10 +354,11 @@ function get_dropbox_category($id) {
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function store_addcategory() {
+function store_addcategory()
+{
     $course_id = api_get_course_int_id();
-	global $_user;
-	global $dropbox_cnf;
+    $_user = api_get_user_info();
+    $dropbox_cnf = getDropboxConf();
 
 	// check if the target is valid
 	if ($_POST['target'] == 'sent') {
@@ -393,8 +411,9 @@ function store_addcategory() {
  *
 * @version march 2006
 */
-function display_addcategory_form($category_name = '', $id = '', $action) {
-	global $dropbox_cnf;
+function display_addcategory_form($category_name = '', $id = '', $action)
+{
+    $dropbox_cnf = getDropboxConf();
     $course_id = api_get_course_int_id();
 	$title = get_lang('AddNewCategory');
 
@@ -431,7 +450,7 @@ function display_addcategory_form($category_name = '', $id = '', $action) {
 		$class = 'add';
 	}
 
-    $form = new FormValidator('add_new_category', 'post', api_get_self().'?view="'.Security::remove_XSS($_GET['view']));
+    $form = new FormValidator('add_new_category', 'post', api_get_self().'?view='.Security::remove_XSS($_GET['view']));
     $form->addElement('header', $title);
 
 	if (isset($id) AND $id != '') {
@@ -456,55 +475,37 @@ function display_addcategory_form($category_name = '', $id = '', $action) {
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function display_add_form() {
-	global $_user, $is_courseAdmin, $is_courseTutor, $course_info, $origin, $dropbox_unid;
+function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
+{
+    $course_info = api_get_course_info();
+    $_user = api_get_user_info();
+    $is_courseAdmin = api_is_course_admin();
+    $is_courseTutor = api_is_course_tutor();
+    $origin = isset($_GET['origin']) ? $_GET['origin'] : null;
 
-	$token = Security::get_token();
+    $token = Security::get_token();
 	$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
-	?>
-	<form method="post" action="index.php?view_received_category=<?php echo Security::remove_XSS($_GET['view_received_category']); ?>&view_sent_category=<?php echo Security::remove_XSS($_GET['view_sent_category']); ?>&view=<?php echo Security::remove_XSS($_GET['view']); ?>&<?php echo "origin=$origin"."&".api_get_cidreq(); ?>" enctype="multipart/form-data" onsubmit="javascript: return checkForm(this);">
-	<legend><?php echo get_lang('UploadNewFile'); ?></legend>
-
-	<div class="control-group">
-		<label>
-			<span class="form_required">*</span><?php echo get_lang('UploadFile'); ?>:
-		</label>
-		<div class="controls">
-				<input type="hidden" name="MAX_FILE_SIZE" value='<?php echo dropbox_cnf('maxFilesize'); ?>' />
-				<input type="file" name="file" size="20" <?php if (dropbox_cnf('allowOverwrite')) echo 'onChange="javascript: checkfile(this.value);"'; ?> />
-				<input type="hidden" name="dropbox_unid" value="<?php echo $dropbox_unid; ?>" />
-				<input type="hidden" name="sec_token" value="<?php echo $token; ?>" />
-				<?php
-				if ($origin == 'learnpath') {
-					echo '<input type="hidden" name="origin" value="learnpath" />';
-				}
-				?>
-		</div>
-	</div>
 
-	<?php
+    $form = new FormValidator(
+        'sent_form',
+        'post',
+        api_get_self().'?view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&'.api_get_cidreq(),
+        null,
+        array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);')
+    );
+
+    $form->addElement('header', get_lang('UploadNewFile'));
+    $form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
+    $form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
+    $form->addElement('hidden', 'sec_token', $token);
+    $form->addElement('hidden', 'origin', $origin);
+    $form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
+
 	if (dropbox_cnf('allowOverwrite')) {
-		?>
-		<div class="control-group">
-			<div class="controls">
-				<label class="checkbox">
-                    <input type="checkbox" name="cb_overwrite" id="cb_overwrite" value="true" />
-				<?php echo get_lang('OverwriteFile'); ?>
-				</label>
-			</div>
-		</div>
-		<?php
+        $form->addElement('checkbox', 'cb_overwrite',  null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
 	}
-	?>
 
-	<div class="control-group">
-		<label class="control-label">
-			<?php echo get_lang('SendTo'); ?>
-		</label>
-		<div class="controls">
-	<?php
-
-	//list of all users in this course and all virtual courses combined with it
+	// List of all users in this course and all virtual courses combined with it
 	if (api_get_session_id()) {
 		$complete_user_list_for_dropbox = array();
 		if (api_get_setting('dropbox_allow_student_to_student')=='true' || $_user['status'] != STUDENT) {
@@ -527,13 +528,13 @@ function display_add_form() {
     	$complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
     }
 
-    echo '<select name="recipients[]" size="10" multiple class="span4">';
 	/*
 		Create the options inside the select box:
 		List all selected users their user id as value and a name string as display
 	*/
 
 	$current_user_id = '';
+    $options = array();
 	foreach ($complete_user_list_for_dropbox as $current_user) {
 		if (($dropbox_person -> isCourseTutor
 				|| $dropbox_person -> isCourseAdmin
@@ -546,10 +547,12 @@ function display_add_form() {
 			}
 			$full_name = $current_user['lastcommafirst'];
 			$current_user_id = $current_user['user_id'];
-			echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
+            $options['user_' . $current_user_id] = $full_name;
+			//echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
 		}
 	}
 
+
 	/*
 	* Show groups
 	*/
@@ -560,40 +563,31 @@ function display_add_form() {
 		if (count($complete_group_list_for_dropbox) > 0) {
 			foreach ($complete_group_list_for_dropbox as $current_group) {
 				if ($current_group['number_of_members'] > 0) {
-					echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
+					//echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
+                    $options['group_'.$current_group['id']] = 'G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users');
 				}
 			}
 		}
     }
 
-    if (($dropbox_person -> isCourseTutor || $dropbox_person -> isCourseAdmin) && dropbox_cnf('allowMailing')) {
-		// echo '<option value="mailing">'.get_lang('MailingInSelect').'</option>';
-	}
-
     if (dropbox_cnf('allowJustUpload')) {
     	//echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>';
-    	echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
+    	//echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
+        $options['user_'.$_user['user_id']] = get_lang('JustUploadInSelect');
     }
 
-	echo '</select>
-		</div>
-	</div>';
-	echo '
-		<div class="control-group">
-			<div class="controls">
-				<button type="Submit" class="upload" name="submitWork">'.get_lang('Upload', '').'</button>
-			</div>
-		</div>
-	';
-	echo '</form>';
+    $form->addElement('select', 'recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'class' => 'span4'));
+    $form->addElement('button', 'submitWork', get_lang('Upload'));
+    $form->display();
 }
 
 /**
 * returns username or false if user isn't registered anymore
 * @todo check if this function is still necessary. There might be a library function for this.
 */
-function getUserNameFromId($id) {
-	global $dropbox_cnf;
+function getUserNameFromId($id)
+{
+    $dropbox_cnf = getDropboxConf();
 
     $mailingId = $id - dropbox_cnf('mailingIdBase');
     if ($mailingId > 0) {
@@ -614,7 +608,8 @@ function getUserNameFromId($id) {
 * returns loginname or false if user isn't registered anymore
 * @todo check if this function is still necessary. There might be a library function for this.
 */
-function getLoginFromId($id) {
+function getLoginFromId($id)
+{
     $id = intval($id);
     $sql = "SELECT username
 			FROM " . dropbox_cnf('tbl_user') . "
@@ -627,12 +622,12 @@ function getLoginFromId($id) {
 
 /**
 * @return boolean indicating if user with user_id=$user_id is a course member
-* @todo eliminate global
 * @todo check if this function is still necessary. There might be a library function for this.
 */
-function isCourseMember($user_id) {
-    global $_course;
-	$course_code = $_course['sysCode'];
+function isCourseMember($user_id)
+{
+    $_course = api_get_course_info();
+	$course_code = $_course['code'];
 	$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, true);
 	return $is_course_member;
 }
@@ -641,7 +636,8 @@ function isCourseMember($user_id) {
 * Checks if there are files in the dropbox_file table that aren't used anymore in dropbox_person table.
 * If there are, all entries concerning the file are deleted from the db + the file is deleted from the server
 */
-function removeUnusedFiles() {
+function removeUnusedFiles()
+{
     $course_id = api_get_course_int_id();
 
     // select all files that aren't referenced anymore
@@ -679,8 +675,8 @@ function removeUnusedFiles() {
 function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '')
 {
     $course_id = api_get_course_int_id();
+    $dropbox_cnf = getDropboxConf();
 
-	global $dropbox_cnf;
     $mailingPseudoId = intval($mailingPseudoId);
     $sql = "SELECT f.uploader_id
 			FROM " . $dropbox_cnf['tbl_file'] . " f
@@ -705,7 +701,7 @@ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '')
 function removeMoreIfMailing($file_id)
 {
     $course_id = api_get_course_int_id();
-	global $dropbox_cnf;
+    $dropbox_cnf = getDropboxConf();
     // when deleting a mailing zip-file (posted to mailingPseudoId):
     // 1. the detail window is no longer reachable, so
     //    for all content files, delete mailingPseudoId from person-table
@@ -738,22 +734,26 @@ function removeMoreIfMailing($file_id)
 */
 function dropbox_cnf($variable)
 {
-    return $GLOBALS['dropbox_cnf'][$variable];
+    $dropbox_cnf = getDropboxConf();
+    return $dropbox_cnf[$variable];
 }
 
-function store_add_dropbox() {
-	global $dropbox_cnf;
-	global $_user;
-	global $_course;
+/**
+ * @return array|null|string
+ */
+function store_add_dropbox()
+{
+    $_course = api_get_course_info();
+    $_user = api_get_user_info();
+    $dropbox_cnf = getDropboxConf();
 
 	// Validating the form data
 
     // there are no recipients selected
 	if (!isset($_POST['recipients']) || count( $_POST['recipients']) <= 0) {
         return get_lang('YouMustSelectAtLeastOneDestinee');
-    }
-    // Check if all the recipients are valid
-    else {
+    } else {
+        // Check if all the recipients are valid
         $thisIsAMailing = false;
         $thisIsJustUpload = false;
 	    foreach ($_POST['recipients'] as $rec) {
@@ -785,7 +785,6 @@ function store_add_dropbox() {
 		return get_lang('NoFileSpecified');
 	}
 
-
 	// are we overwriting a previous file or sending a new one
 
 	$dropbox_overwrite = false;
@@ -831,7 +830,7 @@ function store_add_dropbox() {
 	// set title
 	$dropbox_title = $dropbox_filename;
 	// set author
-	if ($_POST['authors'] == '') {
+	if (!isset($_POST['authors'])) {
 		$_POST['authors'] = getUserNameFromId($_user['user_id']);
 	}
 
@@ -885,7 +884,7 @@ function store_add_dropbox() {
 		}
 	}
 
-	new Dropbox_SentWork( $_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $new_work_recipients);
+	new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $new_work_recipients);
 
 	Security::clear_token();
     return get_lang('FileUploadSucces');
@@ -930,7 +929,7 @@ function display_user_link_work($user_id, $name = '') {
 */
 function feedback($array) {
     $output = null;
-	foreach ($array as $key => $value) {
+	foreach ($array as $value) {
 		$output .= format_feedback($value);
 	}
 	$output .= feedback_form();
@@ -946,7 +945,8 @@ function feedback($array) {
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function format_feedback($feedback) {
+function format_feedback($feedback)
+{
 	$output = display_user_link_work($feedback['author_user_id']);
 	$output .= '&nbsp;&nbsp;'.api_convert_and_format_date($feedback['feedback_date'], DATE_TIME_FORMAT_LONG).'<br />';
 	$output .= '<div style="padding-top:6px">'.nl2br($feedback['feedback']).'</div><hr size="1" noshade/><br />';
@@ -960,7 +960,8 @@ function format_feedback($feedback) {
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function feedback_form() {
+function feedback_form()
+{
 	$return = get_lang('AddNewFeedback').'<br />';
 	$number_users_who_see_file = check_if_file_exist($_GET['id']);
 	if ($number_users_who_see_file) {
@@ -976,7 +977,7 @@ function feedback_form() {
 }
 
 function user_can_download_file($id, $user_id) {
-    global $dropbox_cnf;
+    $dropbox_cnf = getDropboxConf();
     $course_id = api_get_course_int_id();
     $id = intval($id);
     $user_id = intval($user_id);
@@ -994,7 +995,7 @@ function user_can_download_file($id, $user_id) {
 // we now check if the other users have not delete this document yet. If this is the case then it is useless to see the
 	// add feedback since the other users will never get to see the feedback.
 function check_if_file_exist($id) {
-    global $dropbox_cnf;
+    $dropbox_cnf = getDropboxConf();
     $id = intval($id);
     $course_id = api_get_course_int_id();
     $sql = "SELECT file_id FROM ".$dropbox_cnf['tbl_person']." WHERE c_id = $course_id AND file_id = ".$id;
@@ -1015,8 +1016,9 @@ function check_if_file_exist($id) {
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @version march 2006
 */
-function store_feedback() {
-	global $dropbox_cnf;
+function store_feedback()
+{
+    $dropbox_cnf = getDropboxConf();
 	if (!is_numeric($_GET['id'])) {
 		return get_lang('FeedbackError');
 	}
@@ -1043,16 +1045,10 @@ function store_feedback() {
 * @version march 2006
 */
 function zip_download($array) {
-	global $_course;
-	global $dropbox_cnf;
-	global $files;
+	$_course = api_get_course_info();
+    $dropbox_cnf = getDropboxConf();
 
     $course_id = api_get_course_int_id();
-	$sys_course_path = api_get_path(SYS_COURSE_PATH);
-
-	// place to temporarily stash the zipfiles
-	$temp_zip_dir = api_get_path(SYS_COURSE_PATH);
-
 	$array = array_map('intval', $array);
 
 	// note: we also have to add the check if the user has received or sent this file.
@@ -1103,7 +1099,8 @@ function my_pre_add_callback($p_event, &$p_header) {
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, March 2006
  * @author Ivan Tcholakov, 2010, code for html metadata has been added.
  */
-function generate_html_overview($files, $dont_show_columns = array(), $make_link = array()) {
+function generate_html_overview($files, $dont_show_columns = array(), $make_link = array())
+{
 	$return = '<!DOCTYPE html'."\n";
 	$return .= "\t".'PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'."\n";
 	$return .= "\t".'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
@@ -1116,7 +1113,7 @@ function generate_html_overview($files, $dont_show_columns = array(), $make_link
 	$return .= "<table border=\"1px\">\n";
 
 	$counter = 0;
-	foreach ($files as $key => $value) {
+	foreach ($files as $value) {
 
 		// Adding the header.
 		if ($counter == 0) {
@@ -1160,11 +1157,12 @@ function generate_html_overview($files, $dont_show_columns = array(), $make_link
 * @version march 2006
 */
 function get_total_number_feedback($file_id = '') {
-	global $dropbox_cnf;
+    $dropbox_cnf = getDropboxConf();
 	$course_id = api_get_course_int_id();
 	$sql = "SELECT COUNT(feedback_id) AS total, file_id FROM ".$dropbox_cnf['tbl_feedback']."
 			WHERE c_id = $course_id GROUP BY file_id";
 	$result = Database::query($sql);
+    $return = array();
 	while ($row=Database::fetch_array($result)) {
 		$return[$row['file_id']] = $row['total'];
 	}
@@ -1201,23 +1199,24 @@ function check_number_feedback($key, $array) {
  *
  * @todo consider moving this function to a more appropriate place.
  */
-function get_last_tool_access($tool, $course_code='', $user_id='') {
-	global $_course, $_user;
-
+function get_last_tool_access($tool, $course_code = '', $user_id='')
+{
 	// The default values of the parameters
-	if ($course_code == '') {
-		$course_code = $_course['id'];
+	if (empty($course_code)) {
+        $course_code = api_get_course_id();
 	}
-	if ($user_id == '') {
-		$user_id = $_user['user_id'];
+	if (empty($user_id)) {
+		$user_id = api_get_user_id();
 	}
 
 	// the table where the last tool access is stored (=track_e_lastaccess)
-	$table_last_access = Database::get_statistic_table('track_e_lastaccess');
+	$table_last_access = Database::get_main_table('track_e_lastaccess');
 
-	$sql = "SELECT access_date FROM $table_last_access WHERE access_user_id='".Database::escape_string($user_id)."'
-				AND access_cours_code='".Database::escape_string($course_code)."'
-				AND access_tool='".Database::escape_string($tool)."'
+	$sql = "SELECT access_date FROM $table_last_access
+	        WHERE
+	            access_user_id='".Database::escape_string($user_id)."' AND
+	            access_cours_code='".Database::escape_string($course_code)."' AND
+	            access_tool='".Database::escape_string($tool)."'
 				ORDER BY access_date DESC
 				LIMIT 1";
 	$result = Database::query($sql);

+ 137 - 49
main/dropbox/dropbox_init.inc.php

@@ -1,6 +1,96 @@
 <?php
 /* For licensing terms, see /license.txt */
 
+
+/**
+ * @desc The dropbox is a personal (peer to peer) file exchange module that allows
+ * you to send documents to a certain (group of) users.
+ *
+ * @version 1.3
+ *
+ * @author Jan Bols <jan@ivpv.UGent.be>, main programmer, initial version
+ * @author René Haentjens <rene.haentjens@UGent.be>, several contributions
+ * @author Roan Embrechts, virtual course support
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (see history version 1.3)
+ *
+ * @package chamilo.dropbox
+ *
+ * @todo complete refactoring. Currently there are about at least 3 sql queries needed for every individual dropbox document.
+ *			first we find all the documents that were sent (resp. received) by the user
+ *			then for every individual document the user(s)information who received (resp. sent) the document is searched
+ *			then for every individual document the feedback is retrieved
+ * @todo 	the implementation of the dropbox categories could (on the database level) have been done more elegantly by storing the category
+ *			in the dropbox_person table because this table stores the relationship between the files (sent OR received) and the users
+ */
+
+/**
+HISTORY
+Version 1.1
+------------
+- dropbox_init1.inc.php: changed include statements to require statements. This way if a file is not found, it stops the execution of a script instead of continuing with warnings.
+- dropbox_init1.inc.php: the include files "claro_init_global.inc.php" & "debug.lib.inc.php" are first checked for their existence before including them. If they don't exist, in the .../include dir, they get loaded from the .../inc dir. This change is necessary because the UCL changed the include dir to inc.
+- dropbox_init1.inc.php: the databasetable name in the variable $dropbox_cnf["introTbl"] is chnged from "introduction" to "tool_intro"
+- install.php: after submit, checks if the database uses accueil or tool_list as a tablename
+- index.php: removed the behaviour of only the teachers that are allowed to delete entries
+- index.php: added field "lastUploadDate" in table dropbox_file to store information about last update when resubmiting a file
+- dropbox.inc.php: added $lang["lastUpdated"]
+- index.php: entries in received list show when file was last updated if it is updated
+- index.php: entries in sent list show when file was last resent if it was resent
+- dropbox_submit.php: add a unique id to every uploaded file
+- index.php: add POST-variable to the upload form with overwrite data when user decides to overwrite the previous sent file with new file
+- dropbox_submit.php: add sanity checks on POST['overwrite'] data
+- index.php: remove title field in upload form
+- dropbox_submit.php: remove use of POST['title'] variable
+- dropbox_init1.inc.php: added $dropbox_cnf["version"] variable
+- dropbox_class.inc.php: add $this->lastUploadDate to Dropbox_work class
+- dropbox.inc.php: added $lang['emptyTable']
+- index.php: if the received or sent list is empty, a message is displayed
+- dropbox_download.php: the $file var is set equal to the title-field of the filetable. So not constructed anymore by substracting the username from the filename
+- index.php: add check to see if column lastUploadDate exists in filetable
+- index.php: moved javascripts from dropbox_init2.inc.php to index.php
+- index.php: when specifying an uploadfile in the form, a checkbox allowing the user to overwrite a previously sent file is shown when the specified file has the same name as a previously uploaded file of that user.
+- index.php: assign all the metadata (author, description, date, recipient, sender) of an entry in a list to the class="dropbox_detail" and add css to html-header
+- index.php: assign all dates of entries in list to the class="dropbox_date" and add CSS
+- index.php: assign all persons in entries of list to the class="dropbox_person" and add CSS
+- dropbox.inc.php: added $lang['dropbox_version'] to indicate the lates version. This must be equal to the $dropbox_cnf['version'] variable.
+- dropbox_init1.inc.php: if the newest lang file isn't loaded by claro_init_global.inc.php from the .../lang dir it will be loaded locally from the .../plugin/dropbox/ dir. This way an administrator must not install the dropbox.inc.php in the .../lang/english dir, but he can leave it in the local .../plugin/dropbox/ dir. However if you want to present multiple language translations of the file you must still put the file in the /lang/ dir, because there is no language management system inside the .../plugin/dropbox dir.
+- mime.inc.php: created this file. It contains an array $mimetype with all the mimetypes that are used by dropbox_download.php to give hinst to the browser during download about content
+- dropbox_download.php: remove https specific headers because they're not necessary
+- dropbox_download.php: use application/octet-stream as the default mime and inline as the default Content-Disposition
+- dropbox.inc.php: add lang vars for "order by" action
+- dropbox_class.inc.php: add methods orderSentWork, orderReceivedWork en _cmpWork and propery _orderBy to class Dropbox_person to take care of sorting
+- index.php: add selectionlist to headers of sent/received lists to select "order by" and add code to keep selected value in sessionvar.
+- index.php: moved part of a <a> hyperlink to previous line to remove the underlined space between symbol and title of a work entry in the sent/received list
+- index.php: add filesize info in sent/received lists
+- dropbox_submit.php: resubmit prevention only for GET action, because it gives some annoying behaviour in POST situation: white screen in IE6
+
+Version 1.2
+-----------
+- adapted entire dropbox tool so it can be used as a default tool in Dokeos 1.5
+- index.php: add event registration to log use of tool in stats tables
+- index.php: upload form checks for correct user selection and file specification before uploading the script
+- dropbox_init1.inc.php: added dropbox_cnf["allowOverwrite"] to allow or disallow overwriting of files
+- index.php: author name textbox is automatically filled in
+- mailing functionality (René Haentjens)
+- allowStudentToStudent and allowJustUpload options (id.)
+- help in separate window (id.)
+
+Version 1.3 (Patrick Cool)
+--------------------------
+- sortable table
+- categories
+- fixing a security hole
+- tabs (which can be disabled: see $dropbox_cnf['sent_received_tabs'])
+- same action on multiple documents ([zip]download, move, delete)
+- consistency with the docuements tool (open/download file, icons of documents, ...)
+- zip download of complete folder
+
+Version 1.4 (Yannick Warnier)
+-----------------------------
+- removed all self-built database tables names
+ */
+
+
 /**
  * First initialisation file with initialisation of variables and
  * without outputting anything to browser.
@@ -23,6 +113,7 @@
  				extended feedback
  * @package chamilo.dropbox
  */
+
 /**
  * Code
  */
@@ -32,18 +123,14 @@ use \ChamiloSession as Session;
 
 $language_file = array('dropbox', 'document');
 
-// This var disables the link in the breadcrumbs on top of the page
-//$noPHP_SELF = true;
-
 // including the basic Chamilo initialisation file
-require '../inc/global.inc.php';
+require_once '../inc/global.inc.php';
+$is_allowed_in_course = api_is_allowed_to_edit(false, true);
 $current_course_tool  = TOOL_DROPBOX;
 
 // the dropbox configuration parameters
-require_once 'dropbox_config.inc.php';
-
-// the dropbox sanity files (adds a new table and some new fields)
-//require_once 'dropbox_sanity.inc.php';
+$dropbox_cnf = require_once 'dropbox_config.inc.php';
+Session::write('dropbox_conf', $dropbox_cnf);
 
 // the dropbox file that contains additional functions
 require_once 'dropbox_functions.inc.php';
@@ -54,12 +141,8 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 // protecting the script
 api_protect_course_script();
 
-
 /*	Libraries */
 
-// including the library for the sortable table
-//require_once api_get_path(LIBRARY_PATH).'tablesort.lib.php';moved to autoload
-
 // including the library for the dropbox
 require_once 'dropbox_class.inc.php';
 
@@ -68,14 +151,17 @@ require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';  // we use
 require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php'; // the function choose_image is used
 require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 
-
 /*	Virtual course support */
 
 $user_id = api_get_user_id();
 $course_code = api_get_course_id();
-$course_info = Database::get_course_info($course_code);
-
+$course_info = api_get_course_info($course_code);
 $session_id = api_get_session_id();
+
+$action = isset($_GET['action']) ? $_GET['action'] : null;
+$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
+$postAction = isset($_POST['action']) ? $_POST['action'] : null;
+
 if (empty($session_id)) {
     $is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, false);
 } else {
@@ -88,7 +174,7 @@ if (empty($session_id)) {
 // off all the documents that have already been sent.
 // @todo consider moving the javascripts in a function that displays the javascripts
 // only when it is needed.
-if ($_GET['action'] == 'add') {
+if ($action == 'add') {
 	$dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
 }
 
@@ -130,17 +216,20 @@ $javascript = "<script type=\"text/javascript\">
 	";
 
 if (dropbox_cnf('allowOverwrite')) {
+    //sentArray keeps list of all files still available in the sent files list
+    //of the user.
+    //This is used to show or hide the overwrite file-radio button of the upload form
+
 	$javascript .= "
-		var sentArray = new Array(";	//sentArray keeps list of all files still available in the sent files list
-										//of the user.
-										//This is used to show or hide the overwrite file-radio button of the upload form
-	for ($i = 0; $i < count($dropbox_person->sentWork); $i++) {
-		if ($i > 0) {
-		    $javascript .= ", ";
-		}
-		$javascript .= "'".$dropbox_person->sentWork[$i]->title."'";
-		//echo '***'.$dropbox_person->sentWork[$i]->title;
-	}
+		var sentArray = new Array(";
+    if (isset($dropbox_person)) {
+        for ($i = 0; $i < count($dropbox_person->sentWork); $i++) {
+            if ($i > 0) {
+                $javascript .= ", ";
+            }
+            $javascript .= "'".$dropbox_person->sentWork[$i]->title."'";
+        }
+    }
 	$javascript .= ");
 
 		function checkfile(str)
@@ -188,9 +277,7 @@ if (dropbox_cnf('allowOverwrite')) {
 
 $javascript .= "
 	</script>";
-
 $htmlHeadXtra[] = $javascript;
-
 $htmlHeadXtra[] =
 "<script type=\"text/javascript\">
 function confirmation (name)
@@ -209,26 +296,26 @@ $htmlHeadXtra[] = '<meta http-equiv="cache-control" content="no-cache">
 	<meta http-equiv="expires" content="-1">';
 
 $checked_files = false;
-if (!$_GET['view'] OR $_GET['view'] == 'received') {
+if (!$view OR $view == 'received') {
 	$part = 'received';
-} elseif ($_GET['view'] = 'sent') {
+} elseif ($view = 'sent') {
 	$part = 'sent';
 } else {
-	header ('location: index.php?view='.$_GET['view'].'&error=Error');
+	header ('location: index.php?view='.$view.'&error=Error');
 }
 
-if (($_POST['action'] == 'download_received' || $_POST['action'] == 'download_sent') and !$_POST['store_feedback']) {
-	$checked_file_ids = $_POST['id'];
-	if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
-		header ('location: index.php?view='.$_GET['view'].'&error=CheckAtLeastOneFile');
-	} else {
-		handle_multiple_actions();
-	}
-	exit;
+if (($postAction == 'download_received' || $postAction == 'download_sent') and !$_POST['store_feedback']) {
+    $checked_file_ids = $_POST['id'];
+    if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) {
+        header ('location: index.php?view='.$view.'&error=CheckAtLeastOneFile');
+    } else {
+        handle_multiple_actions();
+    }
+    exit;
 }
 
 /*
- *         AUTHORISATION SECTION
+ * AUTHORISATION SECTION
  * Prevents access of all users that are not course members
  */
 
@@ -243,25 +330,25 @@ if ((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(nu
 
 /*	BREADCRUMBS */
 
-if ($_GET['view'] == 'received') {
+if ($view == 'received') {
 	$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
 	$nameTools = get_lang('ReceivedFiles');
 
-	if ($_GET['action'] == 'addreceivedcategory') {
+	if ($action == 'addreceivedcategory') {
 		$interbreadcrumb[] = array('url' => '../dropbox/index.php?view=received', 'name' => get_lang('ReceivedFiles'));
 		$nameTools = get_lang('AddNewCategory');
 	}
 }
 
-if ($_GET['view'] == 'sent' OR empty($_GET['view'])) {
+if ($view == 'sent' OR empty($view)) {
 	$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
 	$nameTools = get_lang('SentFiles');
 
-	if ($_GET['action'] == 'addsentcategory') {
+	if ($action == 'addsentcategory') {
 		$interbreadcrumb[] = array('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles'));
 		$nameTools = get_lang('AddNewCategory');
 	}
-	if ($_GET['action'] == 'add') {
+	if ($action == 'add') {
 		$interbreadcrumb[] = array ('url' => '../dropbox/index.php?view=sent', 'name' => get_lang('SentFiles'));
 		$nameTools = get_lang('UploadNewFile');
 	}
@@ -269,9 +356,10 @@ if ($_GET['view'] == 'sent' OR empty($_GET['view'])) {
 
 /*	HEADER & TITLE */
 
-if ($origin != 'learnpath') {
+if (isset($origin) && $origin == 'learnpath') {
+    // if we come from the learning path we have to include the stylesheet and the required javascripts manually.
+    echo '<link rel="stylesheet" type="text/css" href="', api_get_path(WEB_CODE_PATH), 'css/default.css">';
+    echo $javascript;
+} else {
     Display::display_header($nameTools, 'Dropbox');
-} else { // if we come from the learning path we have to include the stylesheet and the required javascripts manually.
-	echo '<link rel="stylesheet" type="text/css" href="', api_get_path(WEB_CODE_PATH), 'css/default.css">';
-	echo $javascript;
 }

+ 49 - 96
main/dropbox/dropbox_submit.php

@@ -95,55 +95,55 @@ if (isset($_POST['submitWork'])) {
             // Transform any .php file in .phps fo security
             $dropbox_filename = php2phps($dropbox_filename);
             if (!filter_extension($dropbox_filename)) {
-            	$error = true;
-            	$errormsg = get_lang('UplUnableToSaveFileFilteredExtension');
+                $error = true;
+                $errormsg = get_lang('UplUnableToSaveFileFilteredExtension');
             } else {
-	            // set title
-	            $dropbox_title = $dropbox_filename;
-
-	            // set author
-	            if ($_POST['authors'] == '') {
-	                $_POST['authors'] = getUserNameFromId($_user['user_id']);
-	            }
-
-				if ($dropbox_overwrite) {
-					$dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
-
-					foreach ($dropbox_person->sentWork as $w) {
-						if ($w->title == $dropbox_filename) {
-						    if (($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase')) xor $thisIsAMailing) {
-								$error = true;
-								$errormsg = get_lang('MailingNonMailingError');
-							}
-							if ( ($w->recipients[0]['id'] == $_user['user_id']) xor $thisIsJustUpload) {
-								$error = true;
-								$errormsg = get_lang('MailingJustUploadSelectNoOther');
-							}
-							$dropbox_filename = $w->filename;
-							$found = true;
-							break;
-						}
-					}
-				} else {
-					// rename file to login_filename_uniqueId format
-					$dropbox_filename = getLoginFromId( $_user['user_id']) . '_' . $dropbox_filename . '_'.uniqid('');
-				}
-
-				if (!is_dir(dropbox_cnf('sysPath'))) {
-					//The dropbox subdir doesn't exist yet so make it and create the .htaccess file
-	                mkdir(dropbox_cnf('sysPath'), api_get_permissions_for_new_directories()) or die(get_lang('ErrorCreatingDir').' (code 404)');
-					$fp = fopen(dropbox_cnf('sysPath').'/.htaccess', 'w') or die(get_lang('ErrorCreatingDir').' (code 405)');
-					fwrite($fp, "AuthName AllowLocalAccess
-	                             AuthType Basic
-
-	                             order deny,allow
-	                             deny from all
-
-	                             php_flag zlib.output_compression off") or die(get_lang('ErrorCreatingDir').' (code 406)');
-	            }
-
-				if ($error) {}
-				elseif ($thisIsAMailing) {
+                // set title
+                $dropbox_title = $dropbox_filename;
+
+                // set author
+                if ($_POST['authors'] == '') {
+                    $_POST['authors'] = getUserNameFromId($_user['user_id']);
+                }
+
+                if ($dropbox_overwrite) {
+                    $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor);
+
+                    foreach ($dropbox_person->sentWork as $w) {
+                        if ($w->title == $dropbox_filename) {
+                            if (($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase')) xor $thisIsAMailing) {
+                                $error = true;
+                                $errormsg = get_lang('MailingNonMailingError');
+                            }
+                            if (($w->recipients[0]['id'] == $_user['user_id']) xor $thisIsJustUpload) {
+                                $error = true;
+                                $errormsg = get_lang('MailingJustUploadSelectNoOther');
+                            }
+                            $dropbox_filename = $w->filename;
+                            $found = true;
+                            break;
+                        }
+                    }
+                } else {
+                    // rename file to login_filename_uniqueId format
+                    $dropbox_filename = getLoginFromId( $_user['user_id']) . '_' . $dropbox_filename . '_'.uniqid('');
+                }
+
+                if (!is_dir(dropbox_cnf('sysPath'))) {
+                    //The dropbox subdir doesn't exist yet so make it and create the .htaccess file
+                    mkdir(dropbox_cnf('sysPath'), api_get_permissions_for_new_directories()) or die(get_lang('ErrorCreatingDir').' (code 404)');
+                    $fp = fopen(dropbox_cnf('sysPath').'/.htaccess', 'w') or die(get_lang('ErrorCreatingDir').' (code 405)');
+                    fwrite($fp, "AuthName AllowLocalAccess
+                                 AuthType Basic
+
+                                 order deny,allow
+                                 deny from all
+
+                                 php_flag zlib.output_compression off") or die(get_lang('ErrorCreatingDir').' (code 406)');
+                }
+
+				if ($error) {
+                } elseif ($thisIsAMailing) {
 				    if (preg_match(dropbox_cnf('mailingZipRegexp'), $dropbox_title)) {
 			            $newWorkRecipients = dropbox_cnf('mailingIdBase');
 					} else {
@@ -172,7 +172,7 @@ if (isset($_POST['submitWork'])) {
 				// After uploading the file, create the db entries
 
 	        	if (!$error) {
-		            @move_uploaded_file( $dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename)
+		            @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename)
 		            	or die(get_lang('UploadError').' (code 407)');
 		            new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $newWorkRecipients);
 	        	}
@@ -180,11 +180,9 @@ if (isset($_POST['submitWork'])) {
         }
     } //end if(!$error)
 
-
     /**
      * SUBMIT FORM RESULTMESSAGE
      */
-
     if (!$error) {
 		$return_message = get_lang('FileUploadSucces');
     } else {
@@ -192,51 +190,6 @@ if (isset($_POST['submitWork'])) {
     }
 }
 
-function findRecipient($thisFile) {
-	// string result = error message, array result = [user_id, lastname, firstname, status]
-	global $nameParts, $preFix, $preLen, $postFix, $postLen;
-    if (preg_match(dropbox_cnf('mailingFileRegexp'), $thisFile, $matches)) {
-        $thisName = $matches[1];
-        if (api_substr($thisName, 0, $preLen) == $preFix) {
-            if ($postLen == 0 || api_substr($thisName, -$postLen) == $postFix) {
-	            $thisRecip = api_substr($thisName, $preLen, api_strlen($thisName) - $preLen - $postLen);
-	            if ($thisRecip) {
-	            	return getUser($thisRecip);
-	            }
-	            return ' <'.get_lang('MailingFileNoRecip', '').'>';
-            } else {
-	            return ' <'.get_lang('MailingFileNoPostfix', '').$postFix.'>';
-            }
-        } else {
-            return ' <'.get_lang('MailingFileNoPrefix', '').$preFix.'>';
-        }
-    } else {
-        return ' <'.get_lang('MailingFileFunny', '').'>';
-    }
-}
-
-function getUser($thisRecip) {
-	// string result = error message, array result = [user_id, lastname, firstname]
-
-	global $var, $sel;
-    if (isset($students)) {
-        unset($students);
-    }
-
-    $result = Database::query($sel . $thisRecip . "'");
-    while ( ($res = Database::fetch_array($result))) {$students[] = $res;}
-    Database::free_result($result);
-
-	if (count($students) == 1) {
-    	return($students[0]);
-	} elseif (count($students) > 1) {
-    	return ' <'.get_lang('MailingFileRecipDup', '').$var."= $thisRecip>";
-	} else {
-    	return ' <'.get_lang('MailingFileRecipNotFound', '').$var."= $thisRecip>";
-	}
-}
-
-
 /**
  * DELETE RECEIVED OR SENT FILES - EDIT FEEDBACK
  * - DELETE ALL RECEIVED FILES

+ 64 - 141
main/dropbox/index.php

@@ -1,109 +1,23 @@
 <?php
 /* For licensing terms, see /license.txt */
 
-/**
- * @desc The dropbox is a personal (peer to peer) file exchange module that allows
- * you to send documents to a certain (group of) users.
- *
- * @version 1.3
- *
- * @author Jan Bols <jan@ivpv.UGent.be>, main programmer, initial version
- * @author René Haentjens <rene.haentjens@UGent.be>, several contributions
- * @author Roan Embrechts, virtual course support
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University (see history version 1.3)
- *
- * @package chamilo.dropbox
- *
- * @todo complete refactoring. Currently there are about at least 3 sql queries needed for every individual dropbox document.
- *			first we find all the documents that were sent (resp. received) by the user
- *			then for every individual document the user(s)information who received (resp. sent) the document is searched
- *			then for every individual document the feedback is retrieved
- * @todo 	the implementation of the dropbox categories could (on the database level) have been done more elegantly by storing the category
- *			in the dropbox_person table because this table stores the relationship between the files (sent OR received) and the users
- */
-
-/**
-					HISTORY
-Version 1.1
-------------
-- dropbox_init1.inc.php: changed include statements to require statements. This way if a file is not found, it stops the execution of a script instead of continuing with warnings.
-- dropbox_init1.inc.php: the include files "claro_init_global.inc.php" & "debug.lib.inc.php" are first checked for their existence before including them. If they don't exist, in the .../include dir, they get loaded from the .../inc dir. This change is necessary because the UCL changed the include dir to inc.
-- dropbox_init1.inc.php: the databasetable name in the variable $dropbox_cnf["introTbl"] is chnged from "introduction" to "tool_intro"
-- install.php: after submit, checks if the database uses accueil or tool_list as a tablename
-- index.php: removed the behaviour of only the teachers that are allowed to delete entries
-- index.php: added field "lastUploadDate" in table dropbox_file to store information about last update when resubmiting a file
-- dropbox.inc.php: added $lang["lastUpdated"]
-- index.php: entries in received list show when file was last updated if it is updated
-- index.php: entries in sent list show when file was last resent if it was resent
-- dropbox_submit.php: add a unique id to every uploaded file
-- index.php: add POST-variable to the upload form with overwrite data when user decides to overwrite the previous sent file with new file
-- dropbox_submit.php: add sanity checks on POST['overwrite'] data
-- index.php: remove title field in upload form
-- dropbox_submit.php: remove use of POST['title'] variable
-- dropbox_init1.inc.php: added $dropbox_cnf["version"] variable
-- dropbox_class.inc.php: add $this->lastUploadDate to Dropbox_work class
-- dropbox.inc.php: added $lang['emptyTable']
-- index.php: if the received or sent list is empty, a message is displayed
-- dropbox_download.php: the $file var is set equal to the title-field of the filetable. So not constructed anymore by substracting the username from the filename
-- index.php: add check to see if column lastUploadDate exists in filetable
-- index.php: moved javascripts from dropbox_init2.inc.php to index.php
-- index.php: when specifying an uploadfile in the form, a checkbox allowing the user to overwrite a previously sent file is shown when the specified file has the same name as a previously uploaded file of that user.
-- index.php: assign all the metadata (author, description, date, recipient, sender) of an entry in a list to the class="dropbox_detail" and add css to html-header
-- index.php: assign all dates of entries in list to the class="dropbox_date" and add CSS
-- index.php: assign all persons in entries of list to the class="dropbox_person" and add CSS
-- dropbox.inc.php: added $lang['dropbox_version'] to indicate the lates version. This must be equal to the $dropbox_cnf['version'] variable.
-- dropbox_init1.inc.php: if the newest lang file isn't loaded by claro_init_global.inc.php from the .../lang dir it will be loaded locally from the .../plugin/dropbox/ dir. This way an administrator must not install the dropbox.inc.php in the .../lang/english dir, but he can leave it in the local .../plugin/dropbox/ dir. However if you want to present multiple language translations of the file you must still put the file in the /lang/ dir, because there is no language management system inside the .../plugin/dropbox dir.
-- mime.inc.php: created this file. It contains an array $mimetype with all the mimetypes that are used by dropbox_download.php to give hinst to the browser during download about content
-- dropbox_download.php: remove https specific headers because they're not necessary
-- dropbox_download.php: use application/octet-stream as the default mime and inline as the default Content-Disposition
-- dropbox.inc.php: add lang vars for "order by" action
-- dropbox_class.inc.php: add methods orderSentWork, orderReceivedWork en _cmpWork and propery _orderBy to class Dropbox_person to take care of sorting
-- index.php: add selectionlist to headers of sent/received lists to select "order by" and add code to keep selected value in sessionvar.
-- index.php: moved part of a <a> hyperlink to previous line to remove the underlined space between symbol and title of a work entry in the sent/received list
-- index.php: add filesize info in sent/received lists
-- dropbox_submit.php: resubmit prevention only for GET action, because it gives some annoying behaviour in POST situation: white screen in IE6
-
-Version 1.2
------------
-- adapted entire dropbox tool so it can be used as a default tool in Dokeos 1.5
-- index.php: add event registration to log use of tool in stats tables
-- index.php: upload form checks for correct user selection and file specification before uploading the script
-- dropbox_init1.inc.php: added dropbox_cnf["allowOverwrite"] to allow or disallow overwriting of files
-- index.php: author name textbox is automatically filled in
-- mailing functionality (René Haentjens)
-- allowStudentToStudent and allowJustUpload options (id.)
-- help in separate window (id.)
-
-Version 1.3 (Patrick Cool)
---------------------------
-- sortable table
-- categories
-- fixing a security hole
-- tabs (which can be disabled: see $dropbox_cnf['sent_received_tabs'])
-- same action on multiple documents ([zip]download, move, delete)
-- consistency with the docuements tool (open/download file, icons of documents, ...)
-- zip download of complete folder
-
-Version 1.4 (Yannick Warnier)
------------------------------
-- removed all self-built database tables names
-
-
- */
-
-/*	INIT SECTION */
-
 // The file that contains all the initialisation stuff (and includes all the configuration stuff)
 require_once 'dropbox_init.inc.php';
 
 // get the last time the user accessed the tool
 if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
-	$last_access = get_last_tool_access(TOOL_DROPBOX, $_course['code'], $_user['user_id']);
+	$last_access = get_last_tool_access(TOOL_DROPBOX);
 	$_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access;
 } else {
 	$last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX];
 }
 
+$postAction = isset($_POST['action']) ? $_POST['action'] : null;
+$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
+$viewReceivedCategory = isset($_GET['view_received_category']) ? Security::remove_XSS($_GET['view_received_category']) : null;
+$viewSentCategory = isset($_GET['view_sent_category']) ? Security::remove_XSS($_GET['view_sent_category']) : null;
+
+
 // Do the tracking
 event_access_tool(TOOL_DROPBOX);
 
@@ -138,7 +52,7 @@ if ($action == 'add') {
 	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
 		api_not_allowed();
 	}
-	display_add_form();
+	display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view);
 }
 
 if (isset($_POST['submitWork'])) {
@@ -183,7 +97,7 @@ if (isset($_POST['StoreCategory'])) {
 	}
 	if ($return_information['type'] == 'error') {
 		Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']);
-		display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $_POST['action']);
+		display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction);
 	}
 }
 
@@ -193,7 +107,15 @@ if (($action == 'movesent' OR $action == 'movereceived') AND isset($_GET['move_i
 	if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
 		api_not_allowed();
 	}
-	display_move_form(str_replace('move', '', $action), $_GET['move_id'], get_dropbox_categories(str_replace('move', '', $action)), $sort_params);
+	display_move_form(
+        str_replace('move', '', $action),
+        $_GET['move_id'],
+        get_dropbox_categories(str_replace('move', '', $action)),
+        $sort_params,
+        $viewReceivedCategory,
+        $viewSentCategory,
+        $view
+    );
 }
 if (isset($_POST['do_move'])) {
 	Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part']));
@@ -229,9 +151,9 @@ if (($action == 'deletereceivedcategory' OR $action == 'deletesentcategory') AND
 // only the download has is handled separately in dropbox_init_inc.php because this has to be done before the headers are sent
 // (which also happens in dropbox_init.inc.php
 
-if (!isset($_POST['feedback']) && (strstr($_POST['action'], 'move_received') OR
-    $_POST['action'] == 'delete_received' OR $_POST['action'] == 'download_received' OR
-    $_POST['action'] == 'delete_sent' OR $_POST['action'] == 'download_sent')) {
+if (!isset($_POST['feedback']) && (strstr($postAction, 'move_received') OR
+    $postAction == 'delete_received' OR $postAction == 'download_received' OR
+    $postAction == 'delete_sent' OR $postAction == 'download_sent')) {
 
 	$display_message = handle_multiple_actions();
 	Display :: display_normal_message($display_message);
@@ -272,12 +194,12 @@ if ($action != 'add') {
 	}
 
 	// ACTIONS
-	if ($_GET['view'] == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
+	if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
 		//echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
 
 		// This is for the categories
-		if (isset($_GET['view_received_category']) AND $_GET['view_received_category'] != '') {
-			$view_dropbox_category_received = Security::remove_XSS($_GET['view_received_category']);
+		if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
+			$view_dropbox_category_received = $viewReceivedCategory;
 		} else {
 			$view_dropbox_category_received = 0;
 		}
@@ -287,32 +209,32 @@ if ($action != 'add') {
 		if (api_get_session_id() == 0) {
 			echo '<div class="actions">';
 			if ($view_dropbox_category_received != 0  && api_is_allowed_to_session_edit(false, true)) {
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
+				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
 				echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
 				$movelist[0] = 'Root'; // move_received selectbox content
 			} else {
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
+				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
 			}
 			echo '</div>';
 		} else {
 			if (api_is_allowed_to_session_edit(false, true)) {
 				echo '<div class="actions">';
 				if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) {
-					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
+					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
 					echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> ';
 					$movelist[0] = 'Root'; // move_received selectbox content
 				} else {
-					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
+					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>';
 				}
 				echo '</div>';
 			}
 		}
 	}
 
-	if (!$_GET['view'] OR $_GET['view'] == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
+	if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
 		// This is for the categories
-		if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category'] != '') {
-			$view_dropbox_category_sent = $_GET['view_sent_category'];
+		if (isset($viewSentCategory) AND $viewSentCategory != '') {
+			$view_dropbox_category_sent = $viewSentCategory;
 		} else {
 			$view_dropbox_category_sent = 0;
 		}
@@ -322,13 +244,13 @@ if ($action != 'add') {
 		if (api_get_session_id() == 0) {
 			echo '<div class="actions">';
 			if ($view_dropbox_category_sent != 0) {
-				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category=0&amp;view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
+				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category=0&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
 				echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
 			} else {
-				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".Security::remove_XSS($_GET['view'])."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
+				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
 			}
-			if (empty($_GET['view_sent_category'])) {
-				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".Security::remove_XSS($_GET['view'])."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
+			if (empty($viewSentCategory)) {
+				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
 			}
 			echo '</div>';
 		} else {
@@ -336,12 +258,12 @@ if ($action != 'add') {
 				echo '<div class="actions">';
 				if ($view_dropbox_category_sent != 0) {
 					echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
-					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category=0&amp;view='.Security::remove_XSS($_GET['view']).'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
+					echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category=0&amp;view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>";
 				} else {
-					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".Security::remove_XSS($_GET['view'])."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
+					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n";
 				}
-				if (empty($_GET['view_sent_category'])) {
-					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".Security::remove_XSS($_GET['view'])."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
+				if (empty($viewSentCategory)) {
+					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&amp;action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>";
 				}
 				echo '</div>';
 			}
@@ -354,9 +276,9 @@ if ($action != 'add') {
 ?>
 
 <ul class="nav nav-tabs">
-    <li <?php if (!$_GET['view'] OR $_GET['view'] == 'sent') { echo 'class="active"'; } ?> >
+    <li <?php if (!$view OR $view == 'sent') { echo 'class="active"'; } ?> >
         <a href="index.php?<?php echo api_get_cidreq(); ?>&view=sent" ><?php echo get_lang('SentFiles'); ?></a></li>
-    <li <?php if ($_GET['view'] == 'received') { echo 'class="active"'; } ?> >
+    <li <?php if ($view == 'received') { echo 'class="active"'; } ?> >
         <a href="index.php?<?php echo api_get_cidreq(); ?>&view=received"  ><?php echo get_lang('ReceivedFiles'); ?></a></li>
 </ul>
 
@@ -365,10 +287,10 @@ if ($action != 'add') {
 
 	/*	RECEIVED FILES */
 
-	if ($_GET['view'] == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
+	if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
 		// This is for the categories
-		if (isset($_GET['view_received_category']) AND $_GET['view_received_category'] != '') {
-			$view_dropbox_category_received = $_GET['view_received_category'];
+		if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
+			$view_dropbox_category_received = $viewReceivedCategory;
 		} else {
 			$view_dropbox_category_received = 0;
 		}
@@ -453,16 +375,16 @@ if ($action != 'add') {
 				$dropbox_file_data[] = date_to_str_ago($last_upload_date).'<br /><span class="dropbox_date">'.api_format_date($last_upload_date).'</span>';
 
 				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=movereceived&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletereceivedfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.
                                     Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
 
 				// This is a hack to have an additional row in a sortable table
 
 				if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) {
 					$action_icons .= "</td></tr>"; // Ending the normal row of the sortable table
-					$action_icons .= '<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category'])."&amp;view_sent_category=".Security::remove_XSS($_GET['view_sent_category'])."&amp;view=".Security::remove_XSS($_GET['view']).'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
+					$action_icons .= '<tr><td colspan="2"><a href="index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&amp;view_sent_category=".$viewSentCategory."&amp;view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
 				}
 				if (api_get_session_id() == 0) {
 					$dropbox_file_data[] = $action_icons;
@@ -484,14 +406,14 @@ if ($action != 'add') {
 					$movelist[$category['cat_id']] = $category['cat_name'];
 					$dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear
 					// The icon of the category
-					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'">';
+					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'">';
 					$dropbox_category_data[] = $link_open.build_document_icon_tag('folder', $category['cat_name']).'</a>';
 					$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>';
 					$dropbox_category_data[] = '';
 					$dropbox_category_data[] = '';
 					$dropbox_category_data[] = '';
-					$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=editcategory&amp;id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
-										  <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletereceivedcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+					$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=editcategory&amp;id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
+										  <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletereceivedcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
 				}
 				if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
 					$dropbox_data_recieved[] = $dropbox_category_data;
@@ -499,7 +421,7 @@ if ($action != 'add') {
 			}
 		}
 		// Displaying the table
-		$additional_get_parameters = array('view' => $_GET['view'], 'view_received_category' => $_GET['view_received_category'], 'view_sent_category' => $_GET['view_sent_category']);
+		$additional_get_parameters = array('view' => $view, 'view_received_category' => $viewReceivedCategory, 'view_sent_category' => $viewSentCategory);
 		$selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download'));
 		if (is_array($movelist)) {
 			foreach ($movelist as $catid => $catname){
@@ -516,10 +438,10 @@ if ($action != 'add') {
 
 	/*	SENT FILES */
 
-	if (!$_GET['view'] OR $_GET['view'] == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
+	if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
 		// This is for the categories
-		if (isset($_GET['view_sent_category']) AND $_GET['view_sent_category'] != '') {
-			$view_dropbox_category_sent = $_GET['view_sent_category'];
+		if (isset($viewSentCategory) AND $viewSentCategory != '') {
+			$view_dropbox_category_sent = $viewSentCategory;
 		} else {
 			$view_dropbox_category_sent = 0;
 		}
@@ -588,6 +510,7 @@ if ($action != 'add') {
 				$dropbox_file_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&amp;action=download">'.Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description;
 				$file_size = $dropbox_file->filesize;
 				$dropbox_file_data[] = format_file_size($file_size);
+                $receivers_celldata = null;
 				foreach ($dropbox_file->recipients as $recipient) {
 					$receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']).', '.$receivers_celldata;
 				}
@@ -600,14 +523,14 @@ if ($action != 'add') {
 				$receivers_celldata = '';
 
 				$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=movesent&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletesentfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=viewfeedback&amp;id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a>
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=movesent&amp;move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a>
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletesentfile&amp;id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
 				// This is a hack to have an additional row in a sortable table
 				if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) {
 					$action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table
 					$action_icons .= "<tr><td colspan=\"2\">";
-					$action_icons .= "<a href=\"index.php?".api_get_cidreq()."&view_received_category=".Security::remove_XSS($_GET['view_received_category'])."&view_sent_category=".Security::remove_XSS($_GET['view_sent_category'])."&view=".Security::remove_XSS($_GET['view']).'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
+					$action_icons .= "<a href=\"index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>";
 					$action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>";
 				}
 				$dropbox_file_data[] = $action_icons;
@@ -624,7 +547,7 @@ if ($action != 'add') {
 				$dropbox_category_data = array();
 				if ($category['sent'] == '1') {
 					$dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear.
-					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.Security::remove_XSS($_GET['view']).'">';
+					$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$category['cat_id'].'&amp;view='.$view.'">';
 					$dropbox_category_data[] = $link_open.build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
 					$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&amp;action=downloadcategory&amp;sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';
 					//$dropbox_category_data[] = '';
@@ -632,9 +555,9 @@ if ($action != 'add') {
 					//$dropbox_category_data[] = '';
 					$dropbox_category_data[] = '';
 					$dropbox_category_data[] = '';
-					$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=editcategory&id='.$category['cat_id'].'">'.
+					$dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=editcategory&id='.$category['cat_id'].'">'.
                                     Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>
-									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.Security::remove_XSS($_GET['view_received_category']).'&amp;view_sent_category='.Security::remove_XSS($_GET['view_sent_category']).'&amp;view='.Security::remove_XSS($_GET['view']).'&amp;action=deletesentcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.
+									<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&amp;view_sent_category='.$viewSentCategory.'&amp;view='.$view.'&amp;action=deletesentcategory&amp;id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.
                                     Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
 				}
 				if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) {
@@ -643,7 +566,7 @@ if ($action != 'add') {
 			}
 		}
 		// Displaying the table
-		$additional_get_parameters = array('view' => Security::remove_XSS($_GET['view']), 'view_received_category' => Security::remove_XSS($_GET['view_received_category']), 'view_sent_category' => Security::remove_XSS($_GET['view_sent_category']));
+		$additional_get_parameters = array('view' => $view, 'view_received_category' => $viewReceivedCategory, 'view_sent_category' => $viewSentCategory);
 		$selectlist = array('delete_received' => get_lang('Delete'), 'download_received' => get_lang('Download'));
 		if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
 			$selectlist = array('download_received' => get_lang('Download'));

+ 133 - 2
main/inc/ajax/model.ajax.php

@@ -31,6 +31,7 @@ if (!in_array($sord, array('asc','desc'))) {
     $sord = 'desc';
 }
 
+// Actions allowed to other roles.
 if (!in_array(
     $action,
     array(
@@ -45,7 +46,8 @@ if (!in_array(
         'get_user_skill_ranking',
         'get_usergroups_teacher',
         'get_user_course_report_resumed',
-        'get_user_course_report'
+        'get_user_course_report',
+        'get_sessions_tracking'
     )
 )) {
     api_protect_admin_script(true);
@@ -220,6 +222,14 @@ switch ($action) {
         $hotpot_path = $_REQUEST['path'];
         $count = get_count_exam_hotpotatoes_results($hotpot_path);
         break;
+    case 'get_sessions_tracking':
+        if (api_is_drh()) {
+            $count = SessionManager::get_sessions_followed_by_drh(api_get_user_id(), null, null, true);
+        } else {
+            // Sessions for the coach
+            $count = Tracking::get_sessions_coached_by_user(api_get_user_id(), null, null, true);
+        }
+        break;
     case 'get_sessions':
         $courseId = isset($_GET['course_id']) && !empty($_GET['course_id']) ? intval($_GET['course_id']) : null;
         if (!empty($courseId)) {
@@ -228,7 +238,14 @@ switch ($action) {
         $count = SessionManager::get_count_admin($where_condition);
         break;
     case 'get_session_lp_progress':
-        $count = SessionManager::get_count_session_lp_progress($_GET['session_id']);
+        $count = SessionManager::get_count_session_lp_progress(intval($_GET['session_id']));
+        break;
+    case 'get_session_progress':
+        $courses = SessionManager::get_course_list_by_session_id(intval($_GET['session_id']));
+        //TODO let select course
+        $course = current($courses);
+        $users = CourseManager::get_student_list_from_course_code($course['code'], true, intval($_GET['session_id']));
+        $count = count($users);
         break;
     /*case 'get_extra_fields':
         $type = $_REQUEST['type'];
@@ -482,6 +499,57 @@ switch ($action) {
 		$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date',  'score', 'actions');
 		$result = get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $where_condition); //get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition);
 		break;
+    case 'get_sessions_tracking':
+        if (api_is_drh()) {
+            $sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id(), $start, $limit);
+        } else {
+            // Sessions for the coach
+            $sessions = Tracking::get_sessions_coached_by_user(api_get_user_id(), $start, $limit);
+        }
+
+        $columns =  array(
+            'name',
+            'date',
+            'course_per_session',
+            'student_per_session',
+            'details'
+        );
+
+        $result = array();
+        if (!empty($sessions)) {
+            foreach ($sessions as $session) {
+                if (api_drh_can_access_all_session_content()) {
+                    $count_courses_in_session = count(SessionManager::get_course_list_by_session_id($session['id']));
+                } else {
+                    $count_courses_in_session = count(Tracking::get_courses_followed_by_coach($user_id, $session['id']));
+                }
+
+                $count_users_in_session = count(SessionManager::get_users_by_session($session['id'], 0));
+                $session_date = array();
+                if (!empty($session['date_start']) && $session['date_start'] != '0000-00-00') {
+                    $session_date[] = get_lang('From').' '.api_format_date($session['date_start'], DATE_FORMAT_SHORT);
+                }
+
+                if (!empty($session['date_end']) && $session['date_end'] != '0000-00-00') {
+                    $session_date[] = get_lang('Until').' '.api_format_date($session['date_end'], DATE_FORMAT_SHORT);
+                }
+
+                if (empty($session_date)) {
+                    $session_date_string = '-';
+                } else {
+                    $session_date_string = implode(' ', $session_date);
+                }
+                $sessionUrl = api_get_path(WEB_CODE_PATH).'mySpace/index.php?session_id='.$session['id'];
+                $result[] = array(
+                    'name' => $session['name'],
+                    'date' => $session_date_string,
+                    'course_per_session' => $count_courses_in_session,
+                    'student_per_session' => $count_users_in_session,
+                    'details' => Display::url(Display::return_icon('2rightarrow.gif'), $sessionUrl)
+                );
+            }
+        }
+        break;
     case 'get_sessions':
         $columns = array(
             'name', 'nbr_courses', 'nbr_users', 'category_name', 'date_start','date_end', 'coach_name', 'session_active', 'visibility'
@@ -512,6 +580,67 @@ switch ($action) {
             )
         );
         break;
+    case 'get_session_progress':
+        $columns = array(
+            'lastname',
+            'firstname',
+            'username',
+            #'profile',
+            'total',
+            'courses',
+            'lessons',
+            'exercises',
+            'forums',
+            'homeworks',
+            'wikis',
+            'surveys',
+            //course description
+            'course_description_progress',
+            //exercises
+            'lessons_total' ,
+            'lessons_done' ,
+            'lessons_left' ,
+            'lessons_progress',
+            //exercises
+            'exercises_total' ,
+            'exercises_done' ,
+            'exercises_left' ,
+            'exercises_progress' ,
+            //forums
+            'forums_total' ,
+            'forums_done' ,
+            'forums_left' ,
+            'forums_progress' ,
+            //assignments
+            'assignments_total' ,
+            'assignments_done' ,
+            'assignments_left' ,
+            'assignments_progress' ,
+            //Wiki
+            'wiki_total',
+            'wiki_revisions',
+            'wiki_read',
+            'wiki_unread',
+            'wiki_progress',
+            //surveys
+            'surveys_total' ,
+            'surveys_done' ,
+            'surveys_left' ,
+            'surveys_progress' ,
+            );
+        $sessionId = 0;
+        if (isset($_GET['session_id']) && !empty($_GET['session_id']))
+        {
+            $sessionId = intval($_GET['session_id']);
+        }
+        $result = SessionManager::get_session_progress($sessionId,
+            array(
+                'where' => $where_condition,
+                'order' => "$sidx $sord",
+                'limit'=> "$start , $limit"
+            )
+        );
+        break;
     case 'get_timelines':
         $columns = array('headline', 'actions');
 
@@ -711,7 +840,9 @@ $allowed_actions = array(
     'get_usergroups_teacher',
     'get_gradebooks',
     'get_sessions',
+    'get_sessions_tracking',
     'get_session_lp_progress',
+    'get_session_progress',
     'get_exercise_results',
     'get_hotpotatoes_exercise_results',
     'get_work_teacher',

+ 6 - 2
main/inc/lib/course.lib.php

@@ -1179,7 +1179,8 @@ class CourseManager
         $resumed_report = false,
         $extra_field = null,
         $courseCodeList = array(),
-        $userIdList = array()
+        $userIdList = array(),
+        $filterByActive = null
     ) {
         // variable initialisation
         $session_id     = intval($session_id);
@@ -1279,7 +1280,10 @@ class CourseManager
             $sql .= ' AND user.user_id IN ("'.$userIdList.'")';
         }
 
-        //$userList = array()
+        if (isset($filterByActive)) {
+            $filterByActive = intval($filterByActive);
+            $sql .= ' AND user.active = '.$filterByActive;
+        }
 
         $sql .= ' '.$order_by.' '.$limit;
 

+ 47 - 40
main/inc/lib/fckeditor/editor/filemanager/connectors/php/config.php

@@ -22,7 +22,7 @@
  * Configuration file for the File Manager Connector for PHP.
  */
 
-// Modifications by Ivan Tcholakov, JUN-2009. 
+// Modifications by Ivan Tcholakov, JUN-2009.
 
 // Some language variables are needed.
 $language_file = array('create_course');
@@ -30,69 +30,79 @@ $language_file = array('create_course');
 // Loading the global initialization file, Chamilo LMS.
 require_once '../../../../../../global.inc.php';
 
+// Disabling access for anonymous users.
+api_block_anonymous_users();
+
 // Initialization of the repositories.
 require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php' ;
 
-global $Config ;
+global $Config;
 
 // SECURITY: You must explicitly enable this "connector". (Set it to "true").
 // WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
 //		authenticated users can access this file or use some kind of session checking.
 $Config['Enabled'] = true ;
 
-
 // Path to user files relative to the document root.
-//$Config['UserFilesPath']
+$Config['UserFilesPath'] = null;
+
+$userId = api_get_user_id();
+
+
 if (api_is_in_course()) {
-	if (!api_is_in_group()) {
-		// 1. We are inside a course and not in a group.
-		if (api_is_allowed_to_edit()) {
-			$Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/';
-		} else {
-			// 1.2. Student	
-			$current_session_id = api_get_session_id();
-			if($current_session_id==0)
-			{
-				$Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
-			}
-			else
-			{
-				$Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';		
-			}
-		}
-	} else {
-		// 2. Inside a course and inside a group.
-		global $group_properties;
-		$Config['UserFilesPath'] = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
-	}
+    $coursePath = api_get_path(REL_COURSE_PATH).api_get_course_path();
+    if (!api_is_in_group()) {
+        // 1. We are inside a course and not in a group.
+        if (api_is_allowed_to_edit()) {
+            $Config['UserFilesPath'] = $coursePath.'/document/';
+        } else {
+            // 1.2. Student
+            $current_session_id = api_get_session_id();
+            if ($current_session_id == 0) {
+                $Config['UserFilesPath'] = $coursePath.'/document/shared_folder/sf_user_'.$userId.'/';
+            } else {
+                $Config['UserFilesPath'] = $coursePath.'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.$userId.'/';
+            }
+        }
+    } else {
+        $groupId = api_get_group_id();
+        $groupInfo = GroupManager::get_group_properties($groupId);
+        if (!empty($groupInfo)) {
+            // 2. Inside a course and inside a group.
+            $Config['UserFilesPath'] = $coursePath.'/document'.$groupInfo['directory'].'/';
+        }
+    }
 } else {
-	if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
-		// 3. Platform administration activities.
-		$Config['UserFilesPath'] = api_get_path(REL_PATH).'home/default_platform_document/';
-	} else {
-		// 4. The user is outside courses.
-        $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'rel');
-		$Config['UserFilesPath'] = $my_path['dir'].'my_files/';
-	}
+    if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
+        // 3. Platform administration activities.
+        $Config['UserFilesPath'] = api_get_path(REL_PATH).'home/default_platform_document/';
+    } else {
+        // 4. The user is outside courses.
+        $my_path = UserManager::get_user_picture_path_by_id($userId, 'rel');
+        $Config['UserFilesPath'] = $my_path['dir'].'my_files/';
+    }
 }
 
+if (empty($Config['UserFilesPath'])) {
+    api_not_allowed(true);
+}
 
 // Fill the following value it you prefer to specify the absolute path for the
 // user files directory. Useful if you are using a virtual directory, symbolic
 // link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
 // Attention: The above 'UserFilesPath' must point to the same directory.
-$Config['UserFilesAbsolutePath'] = rtrim(api_get_path(SYS_SERVER_ROOT_PATH), '/') . $Config['UserFilesPath'] ;
+$Config['UserFilesAbsolutePath'] = rtrim(api_get_path(SYS_SERVER_ROOT_PATH), '/').$Config['UserFilesPath'];
 
 // Due to security issues with Apache modules, it is recommended to leave the
 // following setting enabled.
-$Config['ForceSingleExtension'] = true ;
+$Config['ForceSingleExtension'] = true;
 
 // Perform additional checks for image files.
 // If set to true, validate image size (using getimagesize).
 $Config['SecureImageUploads'] = true;
 
 // What the user can do with this connector.
-$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder') ;
+$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder');
 
 // Allowed Resource Types.
 $Config['ConfigAllowedTypes'] = array('File', 'Audio', 'Images', 'Flash', 'Media', 'MP3', 'Video', 'Video/flv') ;
@@ -160,8 +170,7 @@ $Config['ChmodOnFolderCreate'] = $permissions_for_new_directories ;
 			$Config['QuickUploadAbsolutePath']['Image']	= $Config['UserFilesAbsolutePath'] ;
 		into:
 			$Config['QuickUploadPath']['Image']			= $Config['FileTypesPath']['Image'] ;
-			$Config['QuickUploadAbsolutePath']['Image'] 	= $Config['FileTypesAbsolutePath']['Image'] ;
-
+			$Config['QuickUploadAbsolutePath']['Image'] 	= $Config['FileTypesAbsolutePath']['Image'];
 */
 
 // Files
@@ -220,5 +229,3 @@ $Config['FileTypesPath']['Video/flv']			= $Config['UserFilesPath'] . 'video/flv/
 $Config['FileTypesAbsolutePath']['Video/flv']	= $Config['UserFilesAbsolutePath'] . 'video/flv/' ;
 $Config['QuickUploadPath']['Video/flv']			= $Config['UserFilesPath'] . 'video/flv/' ;
 $Config['QuickUploadAbsolutePath']['Video/flv']	= $Config['UserFilesAbsolutePath'] . 'video/flv/' ;
-
-?>

+ 6 - 24
main/inc/lib/fckeditor/editor/plugins/ImageManager/Classes/ImageManager.php

@@ -576,24 +576,15 @@ class ImageManager
 				$chamiloFile = $file['name'];
 				$chamiloFileSize = $file['size'];
 				if(!empty($group_properties['directory'])) {
-					$chamiloFolder=$group_properties['directory'].$chamiloFolder;
+					$chamiloFolder = $group_properties['directory'].$chamiloFolder;
 				}
 
 				$doc_id = add_document($_course, $document_path,'file', $chamiloFileSize , $chamiloFile);
-				$current_session_id = api_get_session_id();
-				api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(),$to_group_id,null,null,null,$current_session_id);//get Dokeos
+				api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(),$to_group_id,null,null,null,api_get_session_id());
 			}
-
-			/*
-			if (!(api_is_platform_admin() || api_is_course_admin())) {
-				//setting invisible by default for the students
-				api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id());
-			}
-			*/
 		   $dimensionsIndex = isset($_REQUEST['uploadSize']) ? $_REQUEST['uploadSize'] : 0;
 		   // If maximum size is specified, constrain image to it.
-           if ($this->config['maxWidth'][$dimensionsIndex] > 0 && $this->config['maxHeight'][$dimensionsIndex] > 0)
-           {
+           if ($this->config['maxWidth'][$dimensionsIndex] > 0 && $this->config['maxHeight'][$dimensionsIndex] > 0) {
 			   $img = Image_Transform::factory(IMAGE_CLASS);
 			   $img->load($path . $result);
 
@@ -609,7 +600,7 @@ class ImageManager
            }
 	   }
 
-		//delete tmp files.
+		// Delete tmp files.
 		Files::delFile($file['tmp_name']);
 		return false;
 	}
@@ -782,13 +773,7 @@ class ImageManager
 			{
 				Return false;
 			}
-
-		}
-		/*
 		}
-		else
-			Return false;
-		*/
 	}
 
 	/**
@@ -820,9 +805,8 @@ class ImageManager
 					$base_dir = substr($path, 0, strpos($path,'/document/')+9); //
 					$new_dir  = substr($fullpath, strlen($base_dir),-1); //
 					$created_dir = create_unexisting_directory($_course, api_get_user_id(), api_get_session_id(), 0,0, $base_dir, $new_dir,$newDir);
-					$doc_id = DocumentManager::get_document_id($_course, $new_dir );
-					$current_session_id = api_get_session_id();
-					api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id(),null,null,null,null,$current_session_id);
+					$doc_id = DocumentManager::get_document_id($_course, $new_dir);
+					api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', api_get_user_id(),null,null,null,null, api_get_session_id());
 				} else {
 				 	return Files::createFolder($fullpath);
 				}
@@ -891,5 +875,3 @@ class ImageManager
 		return $errors;
 	}
 }
-
-?>

+ 42 - 54
main/inc/lib/fckeditor/editor/plugins/ImageManager/config.inc.php

@@ -27,62 +27,53 @@
  in this directory and its subdirectories.
 */
 $language_file = array('document');
-include '../../../../../../inc/global.inc.php';
+
+require_once '../../../../../../inc/global.inc.php';
+
+// Disabling access for anonymous users.
+api_block_anonymous_users();
 
 // Initialization of the repositories.
 require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php';
 
+$userId = api_get_user_id();
+
 // Choosing the repository to be used.
-if (api_is_in_course())
-{
-	if (!api_is_in_group())
-	{
-		// 1. We are inside a course and not in a group.
-		if (api_is_allowed_to_edit())
-		{
-			// 1.1. Teacher
-			$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
-			$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/';
-		}
-		else
-		{
-			// 1.2. Student			
-			$current_session_id = api_get_session_id();
-			if($current_session_id==0)
-			{
-				$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
-				$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
-			}
-			else
-			{
-				$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
-				$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';	
-			}	
-		}
-	}
-	else
-	{
-		// 2. Inside a course and inside a group.
-		$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
-		$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
-	}
-}
-else
-{
-	if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin')
-	{
-		// 3. Platform administration activities.
-		$IMConfig['base_dir'] = $_configuration['root_sys'].'home/default_platform_document/';
-		$IMConfig['base_url'] = $_configuration['root_web'].'home/default_platform_document/';
-	}
-	else
-	{
-		// 4. The user is outside courses.
-        $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'system');
-		$IMConfig['base_dir'] = $my_path['dir'].'my_files/';
-        $my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web');
-		$IMConfig['base_url'] = $my_path['dir'].'my_files/';
-	}
+if (api_is_in_course()) {
+    if (!api_is_in_group()) {
+        // 1. We are inside a course and not in a group.
+        if (api_is_allowed_to_edit()) {
+            // 1.1. Teacher
+            $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
+            $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/';
+        } else {
+            // 1.2. Student
+            $sessionId = api_get_session_id();
+            if ($sessionId == 0) {
+                $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.$userId.'/';
+                $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.$userId.'/';
+            } else {
+                $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$sessionId.'/sf_user_'.$userId.'/';
+                $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$sessionId.'/sf_user_'.$userId.'/';
+            }
+        }
+	} else {
+        // 2. Inside a course and inside a group.
+        $IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
+        $IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
+    }
+} else {
+    if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
+        // 3. Platform administration activities.
+        $IMConfig['base_dir'] = $_configuration['root_sys'].'home/default_platform_document/';
+        $IMConfig['base_url'] = $_configuration['root_web'].'home/default_platform_document/';
+    } else {
+        // 4. The user is outside courses.
+        $my_path = UserManager::get_user_picture_path_by_id($userId, 'system');
+        $IMConfig['base_dir'] = $my_path['dir'].'my_files/';
+        $my_path = UserManager::get_user_picture_path_by_id($userId, 'web');
+        $IMConfig['base_url'] = $my_path['dir'].'my_files/';
+    }
 }
 
 $IMConfig['server_name'] = $_SERVER['SERVER_NAME'];
@@ -91,11 +82,8 @@ $IMConfig['server_name'] = $_SERVER['SERVER_NAME'];
  demo - when true, no saving is allowed
 */
 $IMConfig['demo'] = false;
-
 /*
-
   Possible values: true, false
-
   TRUE - If PHP on the web server is in safe mode, set this to true.
          SAFE MODE restrictions: directory creation will not be possible,
 		 only the GD library can be used, other libraries require

+ 0 - 2
main/inc/lib/fckeditor/editor/plugins/ImageManager/editor.php

@@ -20,7 +20,6 @@ if (isset($_GET['img'])) {
 
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $IMConfig['language']; ?>" lang="<?php echo $IMConfig['language']; ?>">
 <head>
 <title>Edit image</title>
@@ -92,7 +91,6 @@ if (isset($_GET['img'])) {
 <script type="text/javascript" src="assets/slider.js"></script>
 <script type="text/javascript" src="assets/popup.js"></script>
 <script type="text/javascript" src="assets/editor.js"></script>
-
 <style type="text/css" media="screen, projection">
 /*<![CDATA[*/
 body {

+ 23 - 25
main/inc/lib/fckeditor/editor/plugins/ImageManager/editorFrame.php

@@ -1,27 +1,27 @@
 <?php
-	/**
-	 * The frame that contains the image to be edited.
-	 * @author Wei Zhuo
-	 * @author Paul Moers <mail@saulmade.nl> - watermarking and replace code + several small enhancements <http://www.saulmade.nl/FCKeditor/FCKPlugins.php>
-	 * @version $Id: editorFrame.php,v 1.7 2006/12/20 18:19:28 thierrybo Exp $
-	 * @package ImageManager
-	 */
+/**
+ * The frame that contains the image to be edited.
+ * @author Wei Zhuo
+ * @author Paul Moers <mail@saulmade.nl> - watermarking and replace code + several small enhancements <http://www.saulmade.nl/FCKeditor/FCKPlugins.php>
+ * @version $Id: editorFrame.php,v 1.7 2006/12/20 18:19:28 thierrybo Exp $
+ * @package ImageManager
+ */
 
-	require_once('config.inc.php');
-	require_once('Classes/ImageManager.php');
-	require_once('Classes/ImageEditor.php');
+require_once('config.inc.php');
+require_once('Classes/ImageManager.php');
+require_once('Classes/ImageEditor.php');
 
-	//default path is /
-	$relative = '/';
+//default path is /
+$relative = '/';
 
-	$manager = new ImageManager($IMConfig);
-	$editor = new ImageEditor($manager);
+$manager = new ImageManager($IMConfig);
+$editor = new ImageEditor($manager);
 
-	// process any uploaded files
-	$imageRelative = $manager->processUploads();
+// process any uploaded files
+$imageRelative = $manager->processUploads();
 
-	// get image info and process any action
-	$imageInfo = $editor->processImage($imageRelative);
+// get image info and process any action
+$imageInfo = $editor->processImage($imageRelative);
 
 ?>
 <!--[if IE]>
@@ -35,14 +35,12 @@
 <script type="text/javascript" src="assets/wz_dragdrop.js"></script>
 <script type="text/javascript" src="assets/EditorContent.js"></script>
 <script type="text/javascript" src="assets/editorFrame.js"></script>
-
 <style>
-
-	/* for centering the image vertically in IE */
-	html, body
-	{
-		height: 100%;
-	}
+/* for centering the image vertically in IE */
+html, body
+{
+    height: 100%;
+}
 
 </style>
 

+ 6 - 14
main/inc/lib/fckeditor/editor/plugins/ImageManager/manager.php

@@ -6,21 +6,13 @@
  * @package ImageManager
  */
 
-	require_once('config.inc.php');
-	require_once('Classes/ImageManager.php');
+require_once('config.inc.php');
+require_once('Classes/ImageManager.php');
 
-	$manager = new ImageManager($IMConfig);
-	$dirs = $manager->getDirs();
-	$var = explode('/',$_GET['base_url_alt']);
-	/*
-	// if the base_url_alt parameter there is a default_course_document we change the allow upload parameter
-	if (($var[count($var)-2] == 'default_course_document') && !api_is_platform_admin())
-	{
-		$IMConfig['allow_upload']=false;
-	}
-	*/
-	//clean injection string (XSS)
-	$base_url_alt = str_replace('"','',$_GET['base_url_alt']);
+$manager = new ImageManager($IMConfig);
+$dirs = $manager->getDirs();
+$var = explode('/',$_GET['base_url_alt']);
+$base_url_alt = str_replace('"','',$_GET['base_url_alt']);
 
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

+ 151 - 126
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_details_listing.php

@@ -1,137 +1,162 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+?>
+
 <div id="content">
-<table class="tableList" id="tableList" cellpadding="0" cellspacing="0" border="0">
-<thead>
-	<tr>
-		<th width="5"><a href="#" class="check_all" id="tickAll" title="<?php echo TIP_SELECT_ALL; ?>" onclick="checkAll(this);">&nbsp;</a></th>
-		<th width="10" class="fileColumns">&nbsp;</th>
-		<th class="docName"><?php echo LBL_NAME; ?></th>
-		<th  width="70" class="fileColumns"><?php echo LBL_SIZE; ?></th>
-		<!-- hide while implementing this Chamilo -->
-		<!--<th class="fileColumns"><?php // echo LBL_MODIFIED; ?></th> -->						
-	</tr>
-</thead>
-<tbody id="fileList">
-	<?php 
-		$count = 1;
-		$css = "";
-		//list all documents (files and folders) under this current folder, 
-		//echo appendQueryString(appendQueryString(CONFIG_URL_FILEnIMAGE_MANAGER, "path=" . $file['path']), makeQueryString(array('path'))); 
-		foreach($fileList as $file) {
-			$css = ($css == "" || $css == "even"?"odd":"even");
-			$strDisabled = ($file['is_writable']?"":" disabled");
-			$strClass = ($file['is_writable']?"left":" leftDisabled");
-			///First step for hidden some type of Chamilo files and folders
-			//Juan Carlos Raña
+    <table class="tableList" id="tableList" cellpadding="0" cellspacing="0" border="0">
+        <thead>
+        <tr>
+            <th width="5"><a href="#" class="check_all" id="tickAll" title="<?php echo TIP_SELECT_ALL; ?>"
+                             onclick="checkAll(this);">&nbsp;</a></th>
+            <th width="10" class="fileColumns">&nbsp;</th>
+            <th class="docName"><?php echo LBL_NAME; ?></th>
+            <th width="70" class="fileColumns"><?php echo LBL_SIZE; ?></th>
+            <!-- hide while implementing this Chamilo -->
+            <!--<th class="fileColumns"><?php // echo LBL_MODIFIED; ?></th> -->
+        </tr>
+        </thead>
+        <tbody id="fileList">
+        <?php
+        $count = 1;
+        $css = "";
+        //list all documents (files and folders) under this current folder,
+        //echo appendQueryString(appendQueryString(CONFIG_URL_FILEnIMAGE_MANAGER, "path=" . $file['path']), makeQueryString(array('path')));
+        foreach ($fileList as $file) {
+            $css         = ($css == "" || $css == "even" ? "odd" : "even");
+            $strDisabled = ($file['is_writable'] ? "" : " disabled");
+            $strClass    = ($file['is_writable'] ? "left" : " leftDisabled");
+            ///First step for hidden some type of Chamilo files and folders
+            //Juan Carlos Raña
+
+            //hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat_files, certificates
+            $deleted_by_chamilo_file    = ' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
+            $deleted_by_chamilo_folder  = '_DELETED_';
+            $css_folder_chamilo         = 'css';
+            $hotpotatoes_folder_chamilo = 'HotPotatoes_files';
+            $chat_files_chamilo         = 'chat_files';
+            $certificates_chamilo       = 'certificates';
+            //show group's directory only if I'm member. Or if I'm a teacher. TODO: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder). Teachers can access to all groups ?
+            $group_folder = '_groupdocs';
+
+
+            $show_doc_group = true;
+            if (ereg($group_folder, $file['path'])) {
+                $show_doc_group = false;
+                if ($is_user_in_group || ($to_group_id != 0 && api_is_allowed_to_edit())) {
+                    $show_doc_group = true;
+                }
+            }
 
-			//hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat_files, certificates
-			$deleted_by_chamilo_file=' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
-			$deleted_by_chamilo_folder='_DELETED_';
-			$css_folder_chamilo='css';
-			$hotpotatoes_folder_chamilo='HotPotatoes_files';
-			$chat_files_chamilo='chat_files';
-			$certificates_chamilo='certificates';
-			//show group's directory only if I'm member. Or if I'm a teacher. TODO: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder). Teachers can access to all groups ?
-			$group_folder='_groupdocs';
-						
+            ///Second step: hiding as the case
+            //Juan Carlos Raña
 
-			$show_doc_group=true;
-			if(ereg($group_folder, $file['path'])) {
-				$show_doc_group=false;
-				if($is_user_in_group ||( $to_group_id!=0 && api_is_allowed_to_edit())) {
-					$show_doc_group=true;
-				}
-			}
+            if ((!ereg($deleted_by_chamilo_file, $file['name']) &&
+                    !ereg($deleted_by_chamilo_folder, $file['path'])) &&
+                !ereg($css_folder_chamilo, $file['path']) &&
+                !ereg($hotpotatoes_folder_chamilo, $file['path']) &&
+                !ereg($chat_files_chamilo, $file['path']) &&
+                !ereg($certificates_chamilo, $file['path']) &&
+                $show_doc_group && $file['name'][0] != '.'
+            ) {
+                //hide Nanogong  tag
+                if (strpos($file['path'], '_chnano_')) {
+                    $file['path'] = substr_replace($file['path'], '.wav', -12); //into real file name
+                    $file['name'] = substr_replace($file['name'], '.wav', -12); //into web name
+                }
 
-			///Second step: hiding as the case
-			//Juan Carlos Raña
+                if ($file['type'] == 'file') {
+                    if (Security::remove_XSS($_GET['editor']) != 'stand_alone') {
+                        $path_chamilo_file = '../'.$file['path']; // fix for makes a good show when pressed next on window preview, don't only one image
+                    } else {
+                        $path_chamilo_file = $file['path'];
+                    }
 
-			if ((!ereg($deleted_by_chamilo_file, $file['name']) && 
-				 !ereg($deleted_by_chamilo_folder, $file['path'])) && 
-				 !ereg($css_folder_chamilo, $file['path']) && 
-				 !ereg($hotpotatoes_folder_chamilo, $file['path']) && 
-				 !ereg($chat_files_chamilo, $file['path']) && 
-				 !ereg($certificates_chamilo, $file['path']) && 
-				 $show_doc_group && $file['name'][0]!='.') {							
-				//hide Nanogong  tag
-				if (strpos($file['path'], '_chnano_')) {
-					$file['path']= substr_replace($file['path'], '.wav', -12);//into real file name
-					$file['name']= substr_replace($file['name'], '.wav', -12);//into web name
-				}
-				
-				if ($file['type'] == 'file') {
-					if(Security::remove_XSS($_GET['editor'])!='stand_alone') {
-						$path_chamilo_file='../'.$file['path'];// fix for makes a good show when pressed next on window preview, don't only one image
-					} else {
-						$path_chamilo_file=$file['path'];
-					}
+                    ?>
+                    <tr class="<?php echo $css; ?>" id="row<?php echo $count; ?>">
+                        <td align="center" id="tdz<?php echo $count; ?>">
+                            <span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span>
+                            <input type="checkbox" name="check[]" id="cb<?php echo $count; ?>"
+                                   value="<?php echo $file['path']; ?>" <?php echo $strDisabled; ?> />
+                        </td>
+                        <td align="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
+                            <a id="<?php echo $count; ?>" href="<?php echo $path_chamilo_file; // fix for Chamilo ?>"
+                               target="_blank">
+                                <span class="<?php echo $file['cssClass']; ?>">&nbsp;</span></a>
+                        </td>
+                        <td class="<?php echo $strClass; ?> docName" id="tdnd<?php echo $count; ?>">
+                            <a id="<?php echo $count; ?>" href="<?php echo $path_chamilo_file; //fix for Chamilo ?>"
+                               target="_blank">
+                                <?php echo $file['name']; ?></a>
+                        </td>
 
-				?>
-				<tr class="<?php echo $css; ?>" id="row<?php echo $count; ?>"  >
-					<td align="center" id="tdz<?php echo $count; ?>">
-						<span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span>
-						<input type="checkbox"  name="check[]" id="cb<?php echo $count; ?>" value="<?php echo $file['path']; ?>" <?php echo $strDisabled; ?> />
-					</td>
-					<td align="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
-						<a id="<?php echo $count; ?>" href="<?php echo $path_chamilo_file; // fix for Chamilo ?>" target="_blank">
-							<span class="<?php echo $file['cssClass']; ?>">&nbsp;</span></a>
-					</td>					
-					<td class="<?php echo $strClass; ?> docName"  id="tdnd<?php echo $count; ?>">
-						<a id="<?php echo $count; ?>" href="<?php echo $path_chamilo_file; //fix for Chamilo ?>" target="_blank">
-						<?php echo $file['name']; ?></a>
-					</td>
+                        <td class="docInfo" id="tdrd<?php echo $count; ?>"><?php echo transformFileSize(
+                                $file['size']
+                            ); ?></td>
+                        <!-- hide while implementing this Chamilo -->
+                        <!--<td class="docInfo" id="tdth<?php //echo $count; ?>"><?php //echo @date(DATE_TIME_FORMAT,$file['mtime']); ?></td> -->
+                    </tr>
+                <?php
 
-					<td class="docInfo" id="tdrd<?php echo $count; ?>"><?php echo transformFileSize($file['size']); ?></td>
-					<!-- hide while implementing this Chamilo -->
-					<!--<td class="docInfo" id="tdth<?php //echo $count; ?>"><?php //echo @date(DATE_TIME_FORMAT,$file['mtime']); ?></td> -->
-				</tr>
-				<?php
-				
-				} else {
-					?>
-					<tr class="<?php echo $css; ?>" id="row<?php echo $count; ?>" >
-						<td align="center" id="tdz<?php echo $count; ?>"><span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span><input type="checkbox" name="check[]" id="cb<?php echo $count; ?>" value="<?php echo $file['path']; ?>" <?php echo $strDisabled; ?>/>
-						</td>
-					  <?php
+                } else {
+                    ?>
+                    <tr class="<?php echo $css; ?>" id="row<?php echo $count; ?>">
+                        <td align="center" id="tdz<?php echo $count; ?>"><span id="flag<?php echo $count; ?>"
+                                                                               class="<?php echo $file['flag']; ?>">&nbsp;</span><input
+                                type="checkbox" name="check[]" id="cb<?php echo $count; ?>"
+                                value="<?php echo $file['path']; ?>" <?php echo $strDisabled; ?>/>
+                        </td>
+                        <?php
 
-						if (preg_match('/shared_folder/', basename($file['path']))) {
-						//add icon into ajaxfilemanager if sharedfolder is into Chamilo
-						?>
-							<td  lign="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
-								<a id="<?php echo $count; ?>" href="<?php echo $file['path']; ?>" <?php echo $file['cssClass'] == 'filePicture'?'rel="ajaxPhotos"':''; ?>  >
-									<span class="<?php echo ($file['type'] == 'folder '?$file['cssClass']:"folderShared"); ?>">&nbsp;</span></a>
-							</td>
-						<?php
-						} elseif(preg_match('/sf_user_/', basename($file['path']))) {
-						?>
-						<td  lign="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
-							<a id="<?php echo $count; ?>" href="<?php echo $file['path']; ?>" <?php echo $file['cssClass'] == 'filePicture'?'rel="ajaxPhotos"':''; ?>  >
-								<span class="<?php echo ($file['type'] == 'folder '?$file['cssClass']:"unknownUser"); ?>">&nbsp;</span></a>
-						</td>											
-						<?php
-						} else {
-						?>
-							<td  lign="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
-								<a id="<?php echo $count; ?>" href="<?php echo $file['path']; ?>" <?php echo $file['cssClass'] == 'filePicture'?'rel="ajaxPhotos"':''; ?>  >
-									<span class="<?php echo ($file['file']||$file['subdir']?$file['cssClass']:"folderEmpty"); ?>">&nbsp;</span></a>
-							</td>
-						<?php
-						}
-						?>                                            
-						<td class="<?php echo $strClass; ?> docName" id="tdnd<?php echo $count; ?>">
-							<a id="<?php echo $count; ?>" href="<?php echo "../".$file['path']; ?>" target="_blank"><?php echo $file['name']; ?></a>
-						</td>
-						<td class="docInfo" id="tdrd<?php echo $count; ?>">&nbsp;</td>
-						 <!-- hide while implementing this Chamilo -->
-						<!--<td class="docInfo" id="tdth<?php// echo $count; ?>"><?php //echo @date(DATE_TIME_FORMAT,$file['mtime']); ?></td> -->
-					</tr>
-					<?php
-				}
+                        if (preg_match('/shared_folder/', basename($file['path']))) {
+                            //add icon into ajaxfilemanager if sharedfolder is into Chamilo
+                            ?>
+                            <td lign="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
+                                <a id="<?php echo $count; ?>"
+                                   href="<?php echo $file['path']; ?>" <?php echo $file['cssClass'] == 'filePicture' ? 'rel="ajaxPhotos"' : ''; ?>  >
+                                    <span
+                                        class="<?php echo($file['type'] == 'folder ' ? $file['cssClass'] : "folderShared"); ?>">&nbsp;</span></a>
+                            </td>
+                        <?php
+                        } elseif (preg_match('/sf_user_/', basename($file['path']))) {
+                            ?>
+                            <td lign="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
+                                <a id="<?php echo $count; ?>"
+                                   href="<?php echo $file['path']; ?>" <?php echo $file['cssClass'] == 'filePicture' ? 'rel="ajaxPhotos"' : ''; ?>  >
+                                    <span
+                                        class="<?php echo($file['type'] == 'folder ' ? $file['cssClass'] : "unknownUser"); ?>">&nbsp;</span></a>
+                            </td>
+                        <?php
+                        } else {
+                            ?>
+                            <td lign="center" class="fileColumns" id="tdst<?php echo $count; ?>">&nbsp;
+                                <a id="<?php echo $count; ?>"
+                                   href="<?php echo $file['path']; ?>" <?php echo $file['cssClass'] == 'filePicture' ? 'rel="ajaxPhotos"' : ''; ?>  >
+                                    <span
+                                        class="<?php echo($file['file'] || $file['subdir'] ? $file['cssClass'] : "folderEmpty"); ?>">&nbsp;</span></a>
+                            </td>
+                        <?php
+                        }
+                        ?>
+                        <td class="<?php echo $strClass; ?> docName" id="tdnd<?php echo $count; ?>">
+                            <a id="<?php echo $count; ?>" href="<?php echo "../".$file['path']; ?>"
+                               target="_blank"><?php echo $file['name']; ?></a>
+                        </td>
+                        <td class="docInfo" id="tdrd<?php echo $count; ?>">&nbsp;</td>
+                        <!-- hide while implementing this Chamilo -->
+                        <!--<td class="docInfo" id="tdth<?php// echo $count; ?>"><?php //echo @date(DATE_TIME_FORMAT,$file['mtime']); ?></td> -->
+                    </tr>
+                <?php
+                }
 
-			}//end if hidden files and folders deleted by Chamilo
+            }
+            //end if hidden files and folders deleted by Chamilo
 
-			$count++;
-		}
-	?>
-</tbody>
-</table>
+            $count++;
+        }
+        ?>
+        </tbody>
+    </table>
 </div>

+ 138 - 83
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php

@@ -1,64 +1,76 @@
-<div id="content">
-    <?php
-    $count = 1;
-    $thumbnailBaseUrl = CONFIG_URL_IMG_THUMBNAIL;
-
-    foreach ($fileList as $file) {
-
-        ///First step for hidden some type of Chamilo files and folders
-        //Juan Carlos Raña Trabado
-        //hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat, certificates
-        $deleted_by_chamilo_file = ' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
-        $deleted_by_chamilo_folder = '_DELETED_';
-        $css_folder_chamilo = 'css';
-        $hotpotatoes_folder_chamilo = 'HotPotatoes_files';
-        $chat_files_chamilo = 'chat_files';
-        $certificates_chamilo = 'certificates';
-        //hidden directory of the group if the user is not a member of the group
-        $group_folder = '_groupdocs';
-
-
-        //show group's directory only if I'm member. Or I'm a teacher
-        $show_doc_group = true;
-
-        if (preg_match("/$group_folder/", $file['path'])) {
-            $show_doc_group = false;
-            if ($is_user_in_group || ( $to_group_id != 0 && api_is_allowed_to_edit())) {
-                $show_doc_group = true;
-            }
+<?php
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+echo '<div id="content">';
+$count = 1;
+$thumbnailBaseUrl = CONFIG_URL_IMG_THUMBNAIL;
+
+foreach ($fileList as $file) {
+
+    ///First step for hidden some type of Chamilo files and folders
+    //Juan Carlos Raña Trabado
+    //hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat, certificates
+    $deleted_by_chamilo_file    = ' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
+    $deleted_by_chamilo_folder  = '_DELETED_';
+    $css_folder_chamilo         = 'css';
+    $hotpotatoes_folder_chamilo = 'HotPotatoes_files';
+    $chat_files_chamilo         = 'chat_files';
+    $certificates_chamilo       = 'certificates';
+    //hidden directory of the group if the user is not a member of the group
+    $group_folder = '_groupdocs';
+
+
+    //show group's directory only if I'm member. Or I'm a teacher
+    $show_doc_group = true;
+
+    if (preg_match("/$group_folder/", $file['path'])) {
+        $show_doc_group = false;
+        if ($is_user_in_group || ($to_group_id != 0 && api_is_allowed_to_edit())) {
+            $show_doc_group = true;
         }
+    }
 
-        //show icon sharedfolder
-        $shared_folder = 'shared folder';  //'shared folder' not 'shared_folder' because  in $file['name'] _ is replaced with blank see class.manager.php
-        ///Second step: hiding as the case
-        //Juan Carlos Raña Trabado
-        if ((!preg_match("/$deleted_by_chamilo_file/", $file['name']) &&
+    //show icon sharedfolder
+    $shared_folder = 'shared folder'; //'shared folder' not 'shared_folder' because  in $file['name'] _ is replaced with blank see class.manager.php
+    ///Second step: hiding as the case
+    //Juan Carlos Raña Trabado
+    if ((!preg_match("/$deleted_by_chamilo_file/", $file['name']) &&
             !preg_match("/$deleted_by_chamilo_folder/", $file['path'])) &&
-            !preg_match("/$css_folder_chamilo/", $file['path']) &&
-            !preg_match("/$hotpotatoes_folder_chamilo/", $file['path']) &&
-            !preg_match("/$chat_files_chamilo/", $file['path']) &&
-            !preg_match("/$certificates_chamilo/", $file['path']) && $show_doc_group && $file['name'][0] != '.') {
-            //hide Nanogong  tag
-            if (strpos($file['path'], '_chnano_')) {
-                $file['path'] = substr_replace($file['path'], '.wav', -12); //into real file name
-                $file['name'] = substr_replace($file['name'], '.wav', -12); //into web name
-            }
-            ?>
-            <dl class="thumbnailListing" id="dl<?php echo $count; ?>">
+        !preg_match("/$css_folder_chamilo/", $file['path']) &&
+        !preg_match("/$hotpotatoes_folder_chamilo/", $file['path']) &&
+        !preg_match("/$chat_files_chamilo/", $file['path']) &&
+        !preg_match("/$certificates_chamilo/", $file['path']) && $show_doc_group && $file['name'][0] != '.'
+    ) {
+        //hide Nanogong  tag
+        if (strpos($file['path'], '_chnano_')) {
+            $file['path'] = substr_replace($file['path'], '.wav', -12); //into real file name
+            $file['name'] = substr_replace($file['name'], '.wav', -12); //into web name
+        }
+        ?>
+        <dl class="thumbnailListing" id="dl<?php echo $count; ?>">
             <?php
             if (preg_match('/shared_folder/', basename($file['path']))) {
-                //add icon into ajaxfilemanager if sharedfolder is in Chamilo
-                ?>
-                    <dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'folderShared' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>">
-                    <?php
+            //add icon into ajaxfilemanager if sharedfolder is in Chamilo
+            ?>
+            <dt id="dt<?php echo $count; ?>"
+                class="<?php echo($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'folderShared' : $file['cssClass']); ?>"
+                class="<?php echo $file['cssClass']; ?>">
+                <?php
                 } elseif (preg_match('/sf_user_/', basename($file['path']))) {
-                    ?>
-                    <dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'unknownUser' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>">
-                    <?php
+                ?>
+            <dt id="dt<?php echo $count; ?>"
+                class="<?php echo($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'unknownUser' : $file['cssClass']); ?>"
+                class="<?php echo $file['cssClass']; ?>">
+                <?php
                 } else {
-                    ?>
-                    <dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' && empty($file['file']) && empty($file['subdir']) ? 'folderEmpty' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>">
-                    <?php
+                ?>
+            <dt id="dt<?php echo $count; ?>"
+                class="<?php echo($file['type'] == 'folder' && empty($file['file']) && empty($file['subdir']) ? 'folderEmpty' : $file['cssClass']); ?>"
+                class="<?php echo $file['cssClass']; ?>">
+                <?php
                 }
                 switch ($file['cssClass']) {
                     case 'filePicture':
@@ -66,10 +78,10 @@
                         /* Chamilo create  thumbnail */
                         //setting
                         $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png');
-                        $max_thumbnail_width = 100;
-                        $max_thumbnail_height = 100;
-                        $png_compression = 0; //0(none)-9
-                        $jpg_quality = 75; //from 0 to 100 (default is 75). More quality less compression
+                        $max_thumbnail_width     = 100;
+                        $max_thumbnail_height    = 100;
+                        $png_compression         = 0; //0(none)-9
+                        $jpg_quality             = 75; //from 0 to 100 (default is 75). More quality less compression
 
                         $directory_thumbnails = dirname($file['path']).'/.thumbs/';
 
@@ -79,18 +91,22 @@
 
                         //create thumbnails
 
-                        $image = $file['path'];
+                        $image           = $file['path'];
                         $image_thumbnail = $directory_thumbnails.'.'.basename($file['path']);
 
                         if (file_exists($image)) {
                             //check thumbnail
                             $imagetype = explode(".", $image);
-                            $imagetype = strtolower($imagetype[count($imagetype) - 1]); //or check $imagetype = image_type_to_extension(exif_imagetype($image), false);
+                            $imagetype = strtolower(
+                                $imagetype[count($imagetype) - 1]
+                            ); //or check $imagetype = image_type_to_extension(exif_imagetype($image), false);
 
                             if (in_array($imagetype, $allowed_thumbnail_types)) {
 
                                 if (!file_exists($image_thumbnail)) {
-                                    $original_image_size = api_getimagesize($image); //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
+                                    ); //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
 
                                     switch ($imagetype) {
                                         case 'gif':
@@ -107,14 +123,22 @@
                                             break;
                                     }
 
-                                    $new_thumbnail_size = api_calculate_image_size($original_image_size['width'], $original_image_size['height'], $max_thumbnail_width, $max_thumbnail_height);
+                                    $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['width']  = $original_image_size['width'];
                                         $new_thumbnail_size['height'] = $original_image_size['height'];
                                     }
 
-                                    $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
+                                    $crop = imagecreatetruecolor(
+                                        $new_thumbnail_size['width'],
+                                        $new_thumbnail_size['height']
+                                    );
 
                                     // preserve transparency
                                     if ($imagetype == "png") {
@@ -129,15 +153,32 @@
 
                                         //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);
+                                            $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']);
+                                    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':
@@ -156,14 +197,23 @@
 
                                     //clean memory
                                     imagedestroy($crop);
-                                }//end !exist thumbnail
+                                }
+                                //end !exist thumbnail
                                 //show thumbnail
-                                echo '<img src="'.appendQueryString($thumbnailBaseUrl, ' path='.base64_encode($image_thumbnail)).'" id="thumbImg'.$count.'"></a>'."\n";
+                                echo '<img src="'.appendQueryString(
+                                        $thumbnailBaseUrl,
+                                        ' path='.base64_encode($image_thumbnail)
+                                    ).'" id="thumbImg'.$count.'"></a>'."\n";
                             } else {
 
-                                echo '<img src="'.appendQueryString($thumbnailBaseUrl, ' path='.base64_encode($file['path'])).'" id="thumbImg'.$count.'"></a>'."\n";
-                            }//end allowed image types
-                        }//end if exist file image
+                                echo '<img src="'.appendQueryString(
+                                        $thumbnailBaseUrl,
+                                        ' path='.base64_encode($file['path'])
+                                    ).'" id="thumbImg'.$count.'"></a>'."\n";
+                            }
+                            //end allowed image types
+                        }
+                        //end if exist file image
                         ///////////////////////////////////////// End Chamilo create  thumbnail
 
                         break;
@@ -181,17 +231,22 @@
                     $path_chamilo_file = $file['path'];
                 }
                 ?>
-                </dt>
-                <dd id="dd<?php echo $count; ?>" class="thumbnailListing_info">
-                    <span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span>
-                    <input id="cb<?php echo $count; ?>" type="checkbox" name="check[]" <?php echo ($file['is_writable'] ? '' : 'disabled'); ?> class="radio" value="<?php echo $file['path']; ?>" />
-                    <a <?php echo ($file['cssClass'] == 'filePicture' ? 'rel="orgImg"' : ''); ?> href="<?php echo $path_chamilo_file; // fix for Chamilo ?>" title="<?php echo $file['name']; ?>" id="a<?php echo $count; ?>">
-                <?php echo shortenFileName($file['name']); ?>
-                    </a>
-                </dd>
-            </dl>
-        <?php
-    }//end if hidden files and folders deleted by Chamilo
+            </dt>
+            <dd id="dd<?php echo $count; ?>" class="thumbnailListing_info">
+                <span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span>
+                <input id="cb<?php echo $count; ?>" type="checkbox"
+                       name="check[]" <?php echo($file['is_writable'] ? '' : 'disabled'); ?> class="radio"
+                       value="<?php echo $file['path']; ?>"/>
+                <a <?php echo($file['cssClass'] == 'filePicture' ? 'rel="orgImg"' : ''); ?>
+                    href="<?php echo $path_chamilo_file; // fix for Chamilo ?>" title="<?php echo $file['name']; ?>"
+                    id="a<?php echo $count; ?>">
+                    <?php echo shortenFileName($file['name']); ?>
+                </a>
+            </dd>
+        </dl>
+    <?php
+    }
+    //end if hidden files and folders deleted by Chamilo
     $count++;
 }
 ?>

+ 12 - 11
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_load_folders.php

@@ -1,15 +1,16 @@
 <?php
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
 ?>
 <select class="input inputSearch" name="search_folder" id="search_folder">
-	<?php 
-	
-					foreach(getFolderListing(CONFIG_SYS_ROOT_PATH) as $k=>$v)
-					{
-						?>
-      <option value="<?php echo $v; ?>" ><?php echo shortenFileName($k, 30); ?></option>
-      <?php 
-					}
-		
-				?>            	
+    <?php
+    foreach (getFolderListing(CONFIG_SYS_ROOT_PATH) as $k => $v) {
+        ?>
+        <option value="<?php echo $v; ?>"><?php echo shortenFileName($k, 30); ?></option>
+    <?php
+    }
+    ?>
 </select>

+ 81 - 60
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php

@@ -1,26 +1,20 @@
 <?php
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
 
-/**
- * create a folder
- * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
- * @link www.phpletter.com
- * @since 22/May/2007
- *
- * Modify for Chamilo
- * @author Juan Carlos Ra�a
- * @since 18/January/2009
- */
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-//@ob_start(); //Disabled for integration with Chamilo
-//displayArray($_POST); //Disabled for integration with Chamilo
-//writeInfo(@ob_get_clean()); //Disabled for integration with Chamilo
 echo "{";
 $error = "";
-$info = "";
+$info  = "";
 /* 	$_POST['new_folder'] = substr(md5(time()), 1, 5);
   $_POST['currentFolderPath'] = "../../uploaded/"; */
-$_POST['new_folder'] = htmlentities($_POST['new_folder'], ENT_QUOTES); //Chamilo improve security
-$_POST['new_folder'] = str_replace(' ', '_', $_POST['new_folder']); //Interaction with Chamilo. Because fix long names. See: ajaxfilemanager/inc/class.manager.php
+$_POST['new_folder']        = htmlentities($_POST['new_folder'], ENT_QUOTES); //Chamilo improve security
+$_POST['new_folder']        = str_replace(
+    ' ',
+    '_',
+    $_POST['new_folder']
+); //Interaction with Chamilo. Because fix long names. See: ajaxfilemanager/inc/class.manager.php
 $_POST['currentFolderPath'] = htmlentities($_POST['currentFolderPath'], ENT_QUOTES); //Chamilo improve security
 
 if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_NEWFOLDER) {
@@ -29,55 +23,82 @@ 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;
-} 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']);
+    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
+            //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;
+            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);
             }
-            $info .= sprintf(", %s:'%s'", $k, $v);
+        } else {
+            $error = ERR_FOLDER_CREATION_FAILED;
         }
-    } else {
-        $error = ERR_FOLDER_CREATION_FAILED;
     }
-    //$error = "For security reason, folder creation function has been disabled.";
 }
-echo "error:'" . $error . "'";
+echo "error:'".$error."'";
 echo $info;
-echo "}";
+echo "}";

+ 15 - 13
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_delete_file.php

@@ -1,15 +1,9 @@
 <?php
-/**
- * delete selected files
- * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
- * @link www.phpletter.com
- * @since 22/April/2007
- *
- * Modify for Chamilo
- * @author Juan Carlos Ra�a
- * @since 19/March/2009
- */
-require_once dirname(__FILE__).DIRECTORY_SEPARATOR."inc".DIRECTORY_SEPARATOR."config.php";
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
 $error = "";
 if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) {
     $error = SYS_DISABLED;
@@ -59,7 +53,11 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) {
                 }
             } else {
                 $file->delete(addTrailingSlash(backslashToSlash($_GET['delete']))); //deleted by ajaxfilemanager
-                event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', addTrailingSlash(backslashToSlash($_GET['delete'])));
+                event_system(
+                    LOG_USER_PERSONAL_DOC_DELETED,
+                    'document_path',
+                    addTrailingSlash(backslashToSlash($_GET['delete']))
+                );
             }
             //////end bridge to Chamilo
             $file->delete(addTrailingSlash(backslashToSlash($_GET['delete'])));
@@ -150,7 +148,11 @@ if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_DELETE) {
                         }
                     } else {
                         $file->delete(addTrailingSlash(backslashToSlash($doc))); //deleted by ajaxfilemanager
-                        event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', addTrailingSlash(backslashToSlash($doc)));
+                        event_system(
+                            LOG_USER_PERSONAL_DOC_DELETED,
+                            'document_path',
+                            addTrailingSlash(backslashToSlash($doc))
+                        );
                     }
                     //////end bridge to Chamilo
                 } elseif (is_file($doc)

+ 28 - 30
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_download.php

@@ -1,32 +1,30 @@
 <?php
-	/**
-	 * delete selected files
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/April/2007
-	 *
-	 */
+/* For licensing terms, see /license.txt */
 
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	if(!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path']))
-	{
-			
-			$path = $_GET['path'];
-			//check if the file size
-			$fileSize = @filesize($path);
-			
-			if($fileSize > getMemoryLimit())
-			{//larger then the php memory limit, redirect to the file
-				
-				header('Location: ' . $path);
-				exit;				 
-			}else 
-			{//open it up and send out with php 
-				downloadFile($path);	
-				 			
-			}
-	}else 
-	{
-		die(ERR_DOWNLOAD_FILE_NOT_FOUND);
-	}
-?>
+/**
+ * delete selected files
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/April/2007
+ *
+ */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+if (!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path'])) {
+
+    $path = $_GET['path'];
+    //check if the file size
+    $fileSize = @filesize($path);
+
+    if ($fileSize > getMemoryLimit()) {
+        //larger then the php memory limit, redirect to the file
+        header('Location: '.$path);
+        exit;
+    } else { //open it up and send out with php
+        downloadFile($path);
+    }
+} else {
+    die(ERR_DOWNLOAD_FILE_NOT_FOUND);
+}

+ 102 - 115
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_editor_reset.php

@@ -1,116 +1,103 @@
 <?php
-	/**
-	 * reset the image
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");	
-	if(!isset($_POST['path']))
-	{
-		$_POST['path'] = "uploaded/Winter.jpg" .  "?" . makeQueryString(array('path'));
-		//for crop
-		$_POST['mode'] = "crop";
-		$_POST['x'] = 100;
-		$_POST['y'] = 100;
-		$imageInfo = @GetImageSize($_POST['path']);
-		$_POST['width'] = $imageInfo[0];
-		$_POST['height'] = $imageInfo[1];
-		
-	}
-	initSessionHistory($_POST['path']);
-	
-	echo "{";
-	$error = "";
-	$info = "";
-	
-	if(empty($_POST['path']))
-	{
-		$error  =  IMG_SAVE_EMPTY_PATH;
-	}elseif(!file_exists($_POST['path']))
-	{
-		$error  =  IMG_SAVE_NOT_EXISTS;
-	}else if(!isUnderRoot($_POST['path']))
-	{
-		$error = IMG_SAVE_PATH_DISALLOWED;
-	}
-	else
-	{
-		if(!empty($_POST['mode']))
-		{
-			
-			include_once(CLASS_IMAGE);
-			$image = new ImageAjaxFileManager();
-			$image->loadImage($_POST['path']);
-			
-			switch($_POST['mode'])
-			{
-				case "resize":					
-					if(!$image->resize($_POST['width'], $_POST['height'], (!empty($_POST['constraint'])?true:false)))
-					{
-						$error = IMG_SAVE_RESIZE_FAILED;
-					}					
-					break;
-				case "crop":
-					if(!$image->cropToDimensions($_POST['x'], $_POST['y'], intval($_POST['x']) + intval($_POST['width']), intval($_POST['y']) + intval($_POST['height'])))
-					{
-						$error = IMG_SAVE_CROP_FAILED;
-					}
-					
-					break;
-				case "flip":
-					if(!$image->flip($_POST['flip_angle']))
-					{
-						$error = IMG_SAVE_FLIP_FAILED;
-					}
-					break;
-				case "rotate":
-					if(!$image->rotate(intval($_POST['angle'])))
-					{
-						$error = IMG_SAVE_ROTATE_FAILED;
-					}
-					break;
-				default:
-					$error = IMG_SAVE_UNKNOWN_MODE;
-			}
-			if(empty($error))
-			{
-				
-				$sessionNewPath = $session->getSessionDir() . uniqid(md5(time())) . "." . getFileExt($_POST['path']);
-				if(!@copy($_POST['path'], $sessionNewPath))
-				{
-					$error = IMG_SAVE_BACKUP_FAILED;
-				}else 
-				{
-					addSessionHistory($_POST['path'], $sessionNewPath);
-					if($image->saveImage($_POST['path']))
-					{						
-						$imageInfo = $image->getFinalImageInfo();	
-						$info .= ",width:" . $imageInfo['width'] . "\n";
-						$info .= ",height:" . $imageInfo['height'] . "\n";
-						$info .= ",size:'" . transformFileSize($imageInfo['size']) . "'\n";
-					}else 
-					{
-						$error = IMG_SAVE_FAILED;
-					}			
-				}				
-			}else 
-			{
-				//$image->DestroyImages();
-			}
-		}else 
-		{
-			$error = IMG_SAVE_UNKNOWN_MODE;
-		}
-	}
-	
-	echo "error:'" . $error . "'\n";
-	if(isset($image) && is_object($image))
-	{
-		$image->DestroyImages();
-	}
-	echo $info;
-	echo ",history:" . sizeof($_SESSION[$_POST['path']]) . "\n";
-	echo "}";
-?>
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+if (!isset($_POST['path'])) {
+    $_POST['path'] = "uploaded/Winter.jpg"."?".makeQueryString(array('path'));
+    //for crop
+    $_POST['mode']   = "crop";
+    $_POST['x']      = 100;
+    $_POST['y']      = 100;
+    $imageInfo       = @GetImageSize($_POST['path']);
+    $_POST['width']  = $imageInfo[0];
+    $_POST['height'] = $imageInfo[1];
+
+}
+initSessionHistory($_POST['path']);
+
+echo "{";
+$error = "";
+$info  = "";
+
+if (empty($_POST['path'])) {
+    $error = IMG_SAVE_EMPTY_PATH;
+} elseif (!file_exists($_POST['path'])) {
+    $error = IMG_SAVE_NOT_EXISTS;
+} else {
+    if (!isUnderRoot($_POST['path'])) {
+        $error = IMG_SAVE_PATH_DISALLOWED;
+    } else {
+        if (!empty($_POST['mode'])) {
+
+            include_once(CLASS_IMAGE);
+            $image = new ImageAjaxFileManager();
+            $image->loadImage($_POST['path']);
+
+            switch ($_POST['mode']) {
+                case "resize":
+                    if (!$image->resize(
+                        $_POST['width'],
+                        $_POST['height'],
+                        (!empty($_POST['constraint']) ? true : false)
+                    )
+                    ) {
+                        $error = IMG_SAVE_RESIZE_FAILED;
+                    }
+                    break;
+                case "crop":
+                    if (!$image->cropToDimensions(
+                        $_POST['x'],
+                        $_POST['y'],
+                        intval($_POST['x']) + intval($_POST['width']),
+                        intval($_POST['y']) + intval($_POST['height'])
+                    )
+                    ) {
+                        $error = IMG_SAVE_CROP_FAILED;
+                    }
+
+                    break;
+                case "flip":
+                    if (!$image->flip($_POST['flip_angle'])) {
+                        $error = IMG_SAVE_FLIP_FAILED;
+                    }
+                    break;
+                case "rotate":
+                    if (!$image->rotate(intval($_POST['angle']))) {
+                        $error = IMG_SAVE_ROTATE_FAILED;
+                    }
+                    break;
+                default:
+                    $error = IMG_SAVE_UNKNOWN_MODE;
+            }
+            if (empty($error)) {
+
+                $sessionNewPath = $session->getSessionDir().uniqid(md5(time())).".".getFileExt($_POST['path']);
+                if (!@copy($_POST['path'], $sessionNewPath)) {
+                    $error = IMG_SAVE_BACKUP_FAILED;
+                } else {
+                    addSessionHistory($_POST['path'], $sessionNewPath);
+                    if ($image->saveImage($_POST['path'])) {
+                        $imageInfo = $image->getFinalImageInfo();
+                        $info .= ",width:".$imageInfo['width']."\n";
+                        $info .= ",height:".$imageInfo['height']."\n";
+                        $info .= ",size:'".transformFileSize($imageInfo['size'])."'\n";
+                    } else {
+                        $error = IMG_SAVE_FAILED;
+                    }
+                }
+            }
+        } else {
+            $error = IMG_SAVE_UNKNOWN_MODE;
+        }
+    }
+}
+
+echo "error:'".$error."'\n";
+if (isset($image) && is_object($image)) {
+    $image->DestroyImages();
+}
+echo $info;
+echo ",history:".sizeof($_SESSION[$_POST['path']])."\n";
+echo "}";

+ 29 - 32
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_copy.php

@@ -1,34 +1,31 @@
 <?php
-	/**
-	 * copy file
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
+/* For licensing terms, see /license.txt */
 
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	$error = "";
-	$info = '';
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_COPY)
-	{
-		$error = SYS_DISABLED;
-	}
-	elseif(!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1)
-	{
-		$error = ERR_NOT_DOC_SELECTED_FOR_COPY;
-	}
-	elseif(empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath']))
-	{
-		$error = ERR_FOLDER_PATH_NOT_ALLOWED;
-	}else 
-	{		
-		require_once(CLASS_SESSION_ACTION);
-		$sessionAction = new SessionAction();
-		$sessionAction->setAction($_POST['action_value']);
-		$sessionAction->setFolder($_POST['currentFolderPath']);
-		$sessionAction->set($_POST['selectedDoc']);
-		$info = ',num:' . sizeof($_POST['selectedDoc']);
-	}
-	echo "{error:'" . $error .  "'\n" . $info . "}";
-?>
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+/**
+ * copy file
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/May/2007
+ *
+ */
+
+$error = "";
+$info  = '';
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_COPY) {
+    $error = SYS_DISABLED;
+} elseif (!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1) {
+    $error = ERR_NOT_DOC_SELECTED_FOR_COPY;
+} elseif (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) {
+    $error = ERR_FOLDER_PATH_NOT_ALLOWED;
+} else {
+    require_once(CLASS_SESSION_ACTION);
+    $sessionAction = new SessionAction();
+    $sessionAction->setAction($_POST['action_value']);
+    $sessionAction->setFolder($_POST['currentFolderPath']);
+    $sessionAction->set($_POST['selectedDoc']);
+    $info = ',num:'.sizeof($_POST['selectedDoc']);
+}
+echo "{error:'".$error."'\n".$info."}";

+ 29 - 32
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_cut.php

@@ -1,33 +1,30 @@
 <?php
-	/**
-	 * cut file
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	$error = "";
-	$info = '';
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_CUT)
-	{
-		$error = SYS_DISABLED;
-	}
-	elseif(!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1)
-	{
-		$error = ERR_NOT_DOC_SELECTED_FOR_CUT;
-	}
-	elseif(empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath']))
-	{
-		$error = ERR_FOLDER_PATH_NOT_ALLOWED;
-	}else 
-	{		
-		require_once(CLASS_SESSION_ACTION);
-		$sessionAction = new SessionAction();
-		$sessionAction->setAction($_POST['action_value']);
-		$sessionAction->setFolder($_POST['currentFolderPath']);
-		$sessionAction->set($_POST['selectedDoc']);
-		$info = ',num:' . sizeof($_POST['selectedDoc']);
-	}
-	echo "{error:'" . $error .  "'\n" . $info . "}";
-?>
+/* For licensing terms, see /license.txt */
+/**
+ * cut file
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/May/2007
+ *
+ */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+$error = "";
+$info  = '';
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_CUT) {
+    $error = SYS_DISABLED;
+} elseif (!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1) {
+    $error = ERR_NOT_DOC_SELECTED_FOR_CUT;
+} elseif (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) {
+    $error = ERR_FOLDER_PATH_NOT_ALLOWED;
+} else {
+    require_once(CLASS_SESSION_ACTION);
+    $sessionAction = new SessionAction();
+    $sessionAction->setAction($_POST['action_value']);
+    $sessionAction->setFolder($_POST['currentFolderPath']);
+    $sessionAction->set($_POST['selectedDoc']);
+    $info = ',num:'.sizeof($_POST['selectedDoc']);
+}
+echo "{error:'".$error."'\n".$info."}";

+ 206 - 62
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_paste.php

@@ -1,8 +1,11 @@
 <?php
+/* For licensing terms, see /license.txt */
 
-include_once(dirname(__FILE__).DIRECTORY_SEPARATOR."inc".DIRECTORY_SEPARATOR."config.php");
-$error = '';
-$fileMoved = array();
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+$error                   = '';
+$fileMoved               = array();
 $unmovedDocDueToSamePath = array();
 if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
     $error = SYS_DISABLED;
@@ -48,9 +51,9 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                     if ($file->copyTo($doc, $_GET['current_folder_path'])) {
 
                         $finalPath = $destFolderPath.basename($doc);
-                        $objFile = new file($finalPath);
-                        $tem = $objFile->getFileInfo();
-                        $obj = new manager($finalPath, false);
+                        $objFile   = new file($finalPath);
+                        $tem       = $objFile->getFileInfo();
+                        $obj       = new manager($finalPath, false);
 
                         $fileType = $obj->getFileType($finalPath, (is_dir($finalPath) ? true : false));
 
@@ -68,13 +71,13 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                           } */
 
                         $tem['final_path'] = $finalPath;
-                        $tem['path'] = backslashToSlash($finalPath);
-                        $tem['type'] = (is_dir($finalPath) ? 'folder' : 'file');
-                        $tem['size'] = @transformFileSize($tem['size']);
-                        $tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
-                        $tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
-                        $tem['flag'] = 'noFlag';
-                        $tem['url'] = getFileUrl($doc);
+                        $tem['path']       = backslashToSlash($finalPath);
+                        $tem['type']       = (is_dir($finalPath) ? 'folder' : 'file');
+                        $tem['size']       = @transformFileSize($tem['size']);
+                        $tem['ctime']      = date(DATE_TIME_FORMAT, $tem['ctime']);
+                        $tem['mtime']      = date(DATE_TIME_FORMAT, $tem['mtime']);
+                        $tem['flag']       = 'noFlag';
+                        $tem['url']        = getFileUrl($doc);
 
                         /**
                          * Bridge to Chamilo documents tool
@@ -82,10 +85,15 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                          */
                         if (!empty($_course['path'])) {
 
-                            $mainPath = getParentFolderPath($folderInfo['path']); // from ajaxfilemanager sample ../../../../../../../courses/TEST/document/
-                            $fullPath = $tem['final_path']; // from ajaxfilemanager sample ../../../../../../../courses/TEST/document/icons/book_highlight.jpg
-                            $chamiloFolder = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1); // sample /icons/book_highlight.jpg or /icons
-                            $chamiloFile = $tem['name']; //get ajaxmanager
+                            $mainPath        = getParentFolderPath(
+                                $folderInfo['path']
+                            ); // from ajaxfilemanager sample ../../../../../../../courses/TEST/document/
+                            $fullPath        = $tem['final_path']; // from ajaxfilemanager sample ../../../../../../../courses/TEST/document/icons/book_highlight.jpg
+                            $chamiloFolder   = substr(
+                                $fullPath,
+                                strlen($mainPath) - strlen($fullPath) - 1
+                            ); // sample /icons/book_highlight.jpg or /icons
+                            $chamiloFile     = $tem['name']; //get ajaxmanager
                             $chamiloFileSize = filesize($fullPath); //get ajaxmanager
                             if (!empty($group_properties['directory'])) {
                                 $chamiloFolder = $group_properties['directory'].$chamiloFolder; //get Chamilo
@@ -95,25 +103,43 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                                 $full_old_path = $doc; // get from ajaxfilemanager sample ../../../../../../../courses/TEST/document/book_highlight.jpg or if you select a folder: ../../../../../../../courses/TEST/document/trainer/
                                 if (is_dir($full_old_path)) {
                                     //update first folder
-                                    $old_path = substr($full_old_path, strlen($mainPath) - strlen($full_old_path) - 1, -1);
+                                    $old_path = substr(
+                                        $full_old_path,
+                                        strlen($mainPath) - strlen($full_old_path) - 1,
+                                        -1
+                                    );
                                     if (!empty($group_properties['directory'])) {
                                         $old_path = $group_properties['directory'].$old_path; //get Chamilo
                                     }
                                     $new_path = $chamiloFolder; //sample /images
-                                    $dbTable = Database::get_course_table(TABLE_DOCUMENT); //Chamilo
+                                    $dbTable  = Database::get_course_table(TABLE_DOCUMENT); //Chamilo
                                     update_db_info('update', $old_path, $new_path); //Chamilo
-                                    $curdirpath = $new_path;
-                                    $doc_id = DocumentManager::get_document_id($_course, $curdirpath); //Chamilo
+                                    $curdirpath         = $new_path;
+                                    $doc_id             = DocumentManager::get_document_id(
+                                        $_course,
+                                        $curdirpath
+                                    ); //Chamilo
                                     $current_session_id = api_get_session_id();
-                                    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderMoved', api_get_user_id(), $to_group_id, null, null, null, $current_session_id);
+                                    api_item_property_update(
+                                        $_course,
+                                        TOOL_DOCUMENT,
+                                        $doc_id,
+                                        'FolderMoved',
+                                        api_get_user_id(),
+                                        $to_group_id,
+                                        null,
+                                        null,
+                                        null,
+                                        $current_session_id
+                                    );
                                     // update database: inside subdirectories and files
-                                    $course_dir = $_course['path']."/document"; //get Chamilo
+                                    $course_dir      = $_course['path']."/document"; //get Chamilo
                                     $sys_course_path = api_get_path(SYS_COURSE_PATH); //get Chamilo
-                                    $base_work_dir = $sys_course_path.$course_dir; // sample c:/xampp/htdocs/chamilo/courses/TEST/document
-                                    $source_dir = $base_work_dir.$chamiloFolder;
+                                    $base_work_dir   = $sys_course_path.$course_dir; // sample c:/xampp/htdocs/chamilo/courses/TEST/document
+                                    $source_dir      = $base_work_dir.$chamiloFolder;
 
                                     //thanks to donovan
-                                    $path = '';
+                                    $path    = '';
                                     $stack[] = $source_dir;
                                     while ($stack) {
                                         $thisdir = array_pop($stack);
@@ -125,7 +151,7 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                                                     if (is_file($current_file)) {
                                                         $path[] = "{$thisdir}/{$dircont[$i]}";
                                                     } elseif (is_dir($current_file)) {
-                                                        $path[] = "{$thisdir}/{$dircont[$i]}";
+                                                        $path[]  = "{$thisdir}/{$dircont[$i]}";
                                                         $stack[] = $current_file;
                                                     }
                                                 }
@@ -140,36 +166,74 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                                         //Sample $item is C:/xampp/htdocs/chamilo/courses/TEST/document/books/book_highlight.jpg
                                         $file_orig = basename($item);
                                         if ($file_orig[0] != '.' && !in_array($invisibleFileNames)) {
-                                            $source_item = substr($item, (strlen($base_work_dir) - strlen($item))); // sample /books/book_highlight.jpg or /books
-                                            $target_item = $source_item;
+                                            $source_item   = substr(
+                                                $item,
+                                                (strlen($base_work_dir) - strlen($item))
+                                            ); // sample /books/book_highlight.jpg or /books
+                                            $target_item   = $source_item;
                                             $chamiloFolder = $target_item;
-                                            $chamiloFile = basename($target_item);
+                                            $chamiloFile   = basename($target_item);
                                             //
                                             if (is_dir($item)) {
-                                                $old_path = substr($full_old_path, strlen($mainPath) - strlen($full_old_path) - 1, -1);
+                                                $old_path = substr(
+                                                    $full_old_path,
+                                                    strlen($mainPath) - strlen($full_old_path) - 1,
+                                                    -1
+                                                );
                                                 if (!empty($group_properties['directory'])) {
                                                     $old_path = $group_properties['directory'].$old_path; //get Chamilo
                                                 }
                                                 $new_path = $chamiloFolder; //sample /images
-                                                $dbTable = Database::get_course_table(TABLE_DOCUMENT); //Chamilo
+                                                $dbTable  = Database::get_course_table(TABLE_DOCUMENT); //Chamilo
                                                 update_db_info('update', $old_path, $new_path); //Chamilo
-                                                $curdirpath = $new_path;
-                                                $doc_id = DocumentManager::get_document_id($_course, $curdirpath); //Chamilo
+                                                $curdirpath         = $new_path;
+                                                $doc_id             = DocumentManager::get_document_id(
+                                                    $_course,
+                                                    $curdirpath
+                                                ); //Chamilo
                                                 $current_session_id = api_get_session_id();
-                                                api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderMoved', api_get_user_id(), $to_group_id, null, null, null, $current_session_id);
+                                                api_item_property_update(
+                                                    $_course,
+                                                    TOOL_DOCUMENT,
+                                                    $doc_id,
+                                                    'FolderMoved',
+                                                    api_get_user_id(),
+                                                    $to_group_id,
+                                                    null,
+                                                    null,
+                                                    null,
+                                                    $current_session_id
+                                                );
                                             } elseif (is_file($item)) {
-                                                $old_path = substr($full_old_path, strlen($mainPath) - strlen($full_old_path) - 1);
+                                                $old_path = substr(
+                                                    $full_old_path,
+                                                    strlen($mainPath) - strlen($full_old_path) - 1
+                                                );
                                                 if (!empty($group_properties['directory'])) {
                                                     $old_path = $group_properties['directory'].$old_path; //get Chamilo
                                                 }
                                                 $new_path = $chamiloFolder; //sample /images/book_highlight.jpg
-                                                $dbTable = Database::get_course_table(TABLE_DOCUMENT); //Chamilo
+                                                $dbTable  = Database::get_course_table(TABLE_DOCUMENT); //Chamilo
                                                 update_db_info('update', $old_path, $new_path); //Chamilo
                                                 //update items
-                                                $curdirpath = $new_path;
-                                                $doc_id = DocumentManager::get_document_id($_course, $curdirpath); //Chamilo
+                                                $curdirpath         = $new_path;
+                                                $doc_id             = DocumentManager::get_document_id(
+                                                    $_course,
+                                                    $curdirpath
+                                                ); //Chamilo
                                                 $current_session_id = api_get_session_id();
-                                                api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentMoved', api_get_user_id(), $to_group_id, null, null, null, $current_session_id);
+                                                api_item_property_update(
+                                                    $_course,
+                                                    TOOL_DOCUMENT,
+                                                    $doc_id,
+                                                    'DocumentMoved',
+                                                    api_get_user_id(),
+                                                    $to_group_id,
+                                                    null,
+                                                    null,
+                                                    null,
+                                                    $current_session_id
+                                                );
                                             }
                                         }
                                     }
@@ -183,26 +247,54 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                                     $dbTable = Database::get_course_table(TABLE_DOCUMENT); //Chamilo
                                     update_db_info('update', $old_path, $new_path); //Chamilo
                                     //update items
-                                    $curdirpath = $new_path;
-                                    $doc_id = DocumentManager::get_document_id($_course, $curdirpath);
+                                    $curdirpath         = $new_path;
+                                    $doc_id             = DocumentManager::get_document_id($_course, $curdirpath);
                                     $current_session_id = api_get_session_id();
-                                    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentMoved', api_get_user_id(), $to_group_id, null, null, null, $current_session_id);
+                                    api_item_property_update(
+                                        $_course,
+                                        TOOL_DOCUMENT,
+                                        $doc_id,
+                                        'DocumentMoved',
+                                        api_get_user_id(),
+                                        $to_group_id,
+                                        null,
+                                        null,
+                                        null,
+                                        $current_session_id
+                                    );
                                 }
                             } else {
                                 $current_session_id = api_get_session_id();
                                 if ($tem['type'] == "folder") {
                                     //add to database the first folder to target
-                                    $doc_id = add_document($_course, $chamiloFolder, 'folder', $chamiloFileSize, $chamiloFile); //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
+                                    $doc_id = add_document(
+                                        $_course,
+                                        $chamiloFolder,
+                                        'folder',
+                                        $chamiloFileSize,
+                                        $chamiloFile
+                                    ); //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
                                     // add to database inside subdirectories and files
 
-                                    $course_dir = $_course['path']."/document"; //get Chamilo
+                                    $course_dir      = $_course['path']."/document"; //get Chamilo
                                     $sys_course_path = api_get_path(SYS_COURSE_PATH); //get Chamilo
-                                    $base_work_dir = $sys_course_path.$course_dir; // sample c:/xampp/htdocs/chamilo/courses/TEST/document
-                                    $source_dir = $base_work_dir.$chamiloFolder;
+                                    $base_work_dir   = $sys_course_path.$course_dir; // sample c:/xampp/htdocs/chamilo/courses/TEST/document
+                                    $source_dir      = $base_work_dir.$chamiloFolder;
 
                                     //thanks to donovan
-                                    $path = '';
+                                    $path    = '';
                                     $stack[] = $source_dir;
                                     while ($stack) {
                                         $thisdir = array_pop($stack);
@@ -214,7 +306,7 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                                                     if (is_file($current_file)) {
                                                         $path[] = "{$thisdir}/{$dircont[$i]}";
                                                     } elseif (is_dir($current_file)) {
-                                                        $path[] = "{$thisdir}/{$dircont[$i]}";
+                                                        $path[]  = "{$thisdir}/{$dircont[$i]}";
                                                         $stack[] = $current_file;
                                                     }
                                                 }
@@ -229,24 +321,78 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                                         //Sample $item is C:/xampp/htdocs/chamilo/courses/TEST/document/books/book_highlight.jpg
                                         $file_orig = basename($item);
                                         if ($file_orig[0] != '.' && !in_array($invisibleFileNames)) {
-                                            $source_item = substr($item, (strlen($base_work_dir) - strlen($item))); // sample /books/book_highlight.jpg or /books
-                                            $target_item = $source_item;
+                                            $source_item   = substr(
+                                                $item,
+                                                (strlen($base_work_dir) - strlen($item))
+                                            ); // sample /books/book_highlight.jpg or /books
+                                            $target_item   = $source_item;
                                             $chamiloFolder = $target_item;
-                                            $chamiloFile = basename($target_item);
+                                            $chamiloFile   = basename($target_item);
                                             //
                                             if (is_dir($item)) {
-                                                $doc_id = add_document($_course, $chamiloFolder, 'folder', $chamiloFileSize, $chamiloFile); //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
+                                                $doc_id = add_document(
+                                                    $_course,
+                                                    $chamiloFolder,
+                                                    'folder',
+                                                    $chamiloFileSize,
+                                                    $chamiloFile
+                                                ); //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
                                             } elseif (is_file($item)) {
                                                 $chamiloFileSize = filesize($item);
-                                                $doc_id = add_document($_course, $chamiloFolder, 'file', $chamiloFileSize, $chamiloFile); //get Chamilo
-                                                api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(), $to_group_id, null, null, null, $current_session_id); //get Chamilo
+                                                $doc_id          = add_document(
+                                                    $_course,
+                                                    $chamiloFolder,
+                                                    'file',
+                                                    $chamiloFileSize,
+                                                    $chamiloFile
+                                                ); //get Chamilo
+                                                api_item_property_update(
+                                                    $_course,
+                                                    TOOL_DOCUMENT,
+                                                    $doc_id,
+                                                    'DocumentAdded',
+                                                    api_get_user_id(),
+                                                    $to_group_id,
+                                                    null,
+                                                    null,
+                                                    null,
+                                                    $current_session_id
+                                                ); //get Chamilo
                                             }
                                         }
                                     }
                                 } elseif ($tem['type'] == "file") {
-                                    $doc_id = add_document($_course, $chamiloFolder, 'file', $chamiloFileSize, $chamiloFile); //get Chamilo
-                                    api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(), $to_group_id, null, null, null, $current_session_id); //get Chamilo
+                                    $doc_id = add_document(
+                                        $_course,
+                                        $chamiloFolder,
+                                        'file',
+                                        $chamiloFileSize,
+                                        $chamiloFile
+                                    ); //get Chamilo
+                                    api_item_property_update(
+                                        $_course,
+                                        TOOL_DOCUMENT,
+                                        $doc_id,
+                                        'DocumentAdded',
+                                        api_get_user_id(),
+                                        $to_group_id,
+                                        null,
+                                        null,
+                                        null,
+                                        $current_session_id
+                                    ); //get Chamilo
                                 }
                             }
                         }
@@ -258,9 +404,8 @@ if (CONFIG_SYS_VIEW_ONLY || (!CONFIG_OPTIONS_CUT && !CONFIG_OPTIONS_COPY)) {
                         }
 
 
-
                         $fileMoved[sizeof($fileMoved)] = $tem;
-                        $tem = null;
+                        $tem                           = null;
                     }
                 } else {
                     $unmovedDocDueToSamePath[] = $doc;
@@ -290,4 +435,3 @@ foreach ($fileMoved as $i => $file) {
     echo "} ";
 }
 echo "} }";
-?>

+ 104 - 80
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php

@@ -1,101 +1,125 @@
 <?php
-/**
- * processing the uploaded files
- * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
- * @link www.phpletter.com
- * @since 22/May/2007
- *
- */
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+// @todo sleep??
+
 sleep(3);
-require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";
 echo "{";
 $error = "";
-$info = "";
+$info  = "";
 
-include_once CLASS_UPLOAD ;
+include_once CLASS_UPLOAD;
 $upload = new Upload();
 
 $folder = base64_decode($_GET['folder']);
 //$folder = ($_GET['folder']);
 $upload->setInvalidFileExt(explode(",", CONFIG_UPLOAD_INVALID_EXTS));
-if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD) {
-	$error = SYS_DISABLED;
-} elseif(empty($folder) || !isUnderRoot($folder)) {
-	$error = ERR_FOLDER_PATH_NOT_ALLOWED;
-} else	if(!$upload->isFileUploaded('file')) {
-	$error = ERR_FILE_NOT_UPLOADED;
-}else if(!$upload->moveUploadedFile($folder)) {
-	$error = ERR_FILE_MOVE_FAILED;
-} elseif(!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS))) {
-	$error = ERR_FILE_TYPE_NOT_ALLOWED;
-} elseif(defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE)) {
-	 $error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD) {
+    $error = SYS_DISABLED;
+} elseif (empty($folder) || !isUnderRoot($folder)) {
+    $error = ERR_FOLDER_PATH_NOT_ALLOWED;
+} else if (!$upload->isFileUploaded('file')) {
+    $error = ERR_FILE_NOT_UPLOADED;
 } else {
-	include_once(CLASS_FILE);
-	$path = $upload->getFilePath();
-	$obj = new file($path);
-	$tem = $obj->getFileInfo();
+    if (!$upload->moveUploadedFile($folder)) {
+        $error = ERR_FILE_MOVE_FAILED;
+    } elseif (!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS))) {
+        $error = ERR_FILE_TYPE_NOT_ALLOWED;
+    } elseif (defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(
+            CONFIG_UPLOAD_MAXSIZE
+        )
+    ) {
+        $error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
+    } else {
+        include_once(CLASS_FILE);
+        $path = $upload->getFilePath();
+        $obj  = new file($path);
+        $tem  = $obj->getFileInfo();
 
-	if (sizeof($tem)) {
-		include_once(CLASS_MANAGER);
-		$manager = new manager($upload->getFilePath(), false);
-		$fileType = $manager->getFileType($upload->getFileName());
-		foreach($fileType as $k=>$v) {
-			$tem[$k] = $v;
-		}
+        if (sizeof($tem)) {
+            include_once(CLASS_MANAGER);
+            $manager  = new manager($upload->getFilePath(), false);
+            $fileType = $manager->getFileType($upload->getFileName());
+            foreach ($fileType as $k => $v) {
+                $tem[$k] = $v;
+            }
 
-		$tem['path'] = backslashToSlash($path);
-		$tem['type'] = "file";
-		$tem['size'] = transformFileSize($tem['size']);
-		$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
-		$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
-		$tem['short_name'] = shortenFileName($tem['name']);
-		$tem['flag'] = 'noFlag';
+            $tem['path']       = backslashToSlash($path);
+            $tem['type']       = "file";
+            $tem['size']       = transformFileSize($tem['size']);
+            $tem['ctime']      = date(DATE_TIME_FORMAT, $tem['ctime']);
+            $tem['mtime']      = date(DATE_TIME_FORMAT, $tem['mtime']);
+            $tem['short_name'] = shortenFileName($tem['name']);
+            $tem['flag']       = 'noFlag';
 
-		/**
-		* Bridge to Chamilo documents tool
-		* @author Juan Carlos Raña Trabado
-		*/
+            /**
+             * Bridge to Chamilo documents tool
+             * @author Juan Carlos Raña Trabado
+             */
 
-		if(!empty($_course['path'])) {
-			//only inside courses
-			$fullPath= $upload->getFilePath();		//get	ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/image.jpg
-			$folderInfo = $manager->getFolderInfo(); //get	ajaxmanager
-			$mainPath= getParentFolderPath($folderInfo['path']);//get	ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/
-			$chamiloFolder = substr($fullPath, strlen($mainPath)-strlen($fullPath)-1);
-			$chamiloFile = $tem['name'];	//get	ajaxmanager
-			$chamiloFileSize = filesize($fullPath); //get ajaxmanager
-			//get Chamilo
-			if(!empty($group_properties['directory'])) {
-				$chamiloFolder=$group_properties['directory'].$chamiloFolder;//get Chamilo
-			} else {
-				if(!api_is_allowed_to_edit()) {
-					$current_session_id = api_get_session_id();
-					if($current_session_id==0) {
-						$chamiloFolder='/shared_folder/sf_user_'.api_get_user_id().$chamiloFolder;
-					} else {
-						$chamiloFolder='/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().$chamiloFolder;
-					}
-				}
-			}
+            if (!empty($_course['path'])) {
+                //only inside courses
+                $fullPath        = $upload->getFilePath(
+                ); //get	ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/image.jpg
+                $folderInfo      = $manager->getFolderInfo(); //get	ajaxmanager
+                $mainPath        = getParentFolderPath(
+                    $folderInfo['path']
+                ); //get	ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/
+                $chamiloFolder   = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1);
+                $chamiloFile     = $tem['name']; //get	ajaxmanager
+                $chamiloFileSize = filesize($fullPath); //get ajaxmanager
+                //get Chamilo
+                if (!empty($group_properties['directory'])) {
+                    $chamiloFolder = $group_properties['directory'].$chamiloFolder; //get Chamilo
+                } else {
+                    if (!api_is_allowed_to_edit()) {
+                        $current_session_id = api_get_session_id();
+                        if ($current_session_id == 0) {
+                            $chamiloFolder = '/shared_folder/sf_user_'.api_get_user_id().$chamiloFolder;
+                        } else {
+                            $chamiloFolder = '/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id(
+                                ).$chamiloFolder;
+                        }
+                    }
+                }
 
-			$doc_id = add_document($_course, $chamiloFolder,'file', $chamiloFileSize , $chamiloFile); //get Chamilo
-			$current_session_id = api_get_session_id();
-			api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(),$to_group_id,null,null,null,$current_session_id);//get Chamilo
+                $doc_id             = add_document(
+                    $_course,
+                    $chamiloFolder,
+                    'file',
+                    $chamiloFileSize,
+                    $chamiloFile
+                ); //get Chamilo
+                $current_session_id = api_get_session_id();
+                api_item_property_update(
+                    $_course,
+                    TOOL_DOCUMENT,
+                    $doc_id,
+                    'DocumentAdded',
+                    api_get_user_id(),
+                    $to_group_id,
+                    null,
+                    null,
+                    null,
+                    $current_session_id
+                ); //get Chamilo
 
-		}
-		// end bridge
-		$obj->close();
-		foreach($tem as $k=>$v) {
-			$info .= sprintf(", %s:'%s'", $k, $v);
-		}
-		$info .= sprintf(", url:'%s'",  getFileUrl($path));
-		$info .= sprintf(", tipedit:'%s'",  TIP_DOC_RENAME);
-	} else {
-		$error = ERR_FILE_NOT_AVAILABLE;
-	}
+            }
+            // end bridge
+            $obj->close();
+            foreach ($tem as $k => $v) {
+                $info .= sprintf(", %s:'%s'", $k, $v);
+            }
+            $info .= sprintf(", url:'%s'", getFileUrl($path));
+            $info .= sprintf(", tipedit:'%s'", TIP_DOC_RENAME);
+        } else {
+            $error = ERR_FILE_NOT_AVAILABLE;
+        }
+    }
 }
 
-echo "error:'" . $error . "'";
+echo "error:'".$error."'";
 echo $info;
 echo "}";

+ 24 - 27
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php

@@ -1,25 +1,15 @@
 <?php
+/* For licensing terms, see /license.txt */
 
-/**
- * the php script used to get the list of file or folders under a specific folder
- * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
- * @link www.phpletter.com
- * @since 22/May/2007
- *
- * Modify for Chamilo
- * @author Juan Carlos Ra�a Trabado
- * @since 31/December/2008
- */
-require_once '../../../../../../inc/global.inc.php'; // Integrating with Chamilo
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
 
 if (!isset($manager)) {
     /**
      *  this is part of  script for processing file paste
      */
-    //$_GET = $_POST;
-    include_once dirname(__FILE__).DIRECTORY_SEPARATOR."inc".DIRECTORY_SEPARATOR."config.php";
     include_once CLASS_PAGINATION;
-    $pagination = new pagination(false);
+    $pagination    = new pagination(false);
     $search_folder = null;
     if (isset($_GET['search_folder'])) {
         $search_folder = str_replace("'", "", $_GET['search_folder']); //security fix for Chamilo by cfasanando
@@ -37,7 +27,7 @@ if (!isset($manager)) {
         $search->addSearchKeyword('recursive', @$_GET['search_recursively']);
         $search->addSearchKeyword('name', @$_GET['search_name']);
         $search->doSearch();
-        $fileList = $search->getFoundFiles();
+        $fileList   = $search->getFoundFiles();
         $folderInfo = $search->getRootFolderInfo();
     } else {
         include_once(CLASS_MANAGER);
@@ -48,7 +38,7 @@ if (!isset($manager)) {
         $manager = new manager();
         $manager->setSessionAction($sessionAction);
 
-        $fileList = $manager->getFileList();
+        $fileList   = $manager->getFileList();
         $folderInfo = $manager->getFolderInfo();
     }
     $pagination->setUrl(CONFIG_URL_FILEnIMAGE_MANAGER);
@@ -68,18 +58,20 @@ echo $pagination->getPaginationHTML();
 // Chamilo fix for count hidden folders
 $count_hideItem = 0;
 
-$deleted_by_Chamilo_file = ' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
-$deleted_by_Chamilo_folder = '_DELETED_';
-$css_folder_Chamilo = 'css';
+$deleted_by_Chamilo_file    = ' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
+$deleted_by_Chamilo_folder  = '_DELETED_';
+$css_folder_Chamilo         = 'css';
 $hotpotatoes_folder_Chamilo = 'HotPotatoes_files';
-$chat_files_Chamilo = 'chat_files';
-$certificates_Chamilo = 'certificates';
+$chat_files_Chamilo         = 'chat_files';
+$certificates_Chamilo       = 'certificates';
 
 //end previous fix for count hidden folders
 
 echo "<script>";
 
-echo "parentFolder = {path_base64:'".base64_encode(getParentFolderPath($folderInfo['path']))."', path:'".getParentFolderPath($folderInfo['path'])."'};";
+echo "parentFolder = {path_base64:'".base64_encode(
+        getParentFolderPath($folderInfo['path'])
+    )."', path:'".getParentFolderPath($folderInfo['path'])."'};";
 echo 'currentFolder ={';
 $count = 1;
 foreach ($folderInfo as $k => $v) {
@@ -94,23 +86,24 @@ $count = 1;
 
 foreach ($fileList as $file) {
     //show group's directory only if I'm member. Or if I'm a teacher. TODO: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder). Teachers can access to all groups ?
-    $group_folder = '_groupdocs';
+    $group_folder   = '_groupdocs';
     $hide_doc_group = false;
     if (preg_match("/$group_folder/", $file['path'])) {
         $hide_doc_group = true;
-        if ($is_user_in_group || ( $to_group_id != 0 && api_is_allowed_to_edit())) {
+        if ($is_user_in_group || ($to_group_id != 0 && api_is_allowed_to_edit())) {
             $hide_doc_group = false;
         }
     }
 
     if ((!preg_match("/$deleted_by_Chamilo_file/", $file['name']) ||
-        !preg_match("/$deleted_by_Chamilo_folder/", $file['path'])) ||
+            !preg_match("/$deleted_by_Chamilo_folder/", $file['path'])) ||
         preg_match("/$css_folder_Chamilo/", $file['path']) ||
         preg_match("/$hotpotatoes_folder_Chamilo/", $file['path']) ||
         preg_match("/$chat_files_Chamilo/", $file['path']) ||
         preg_match("/$certificates_Chamilo/", $file['path']) ||
         $hide_doc_group ||
-        $file['name'][0] == '.') { //Chamilo fix for hidden items.
+        $file['name'][0] == '.'
+    ) { //Chamilo fix for hidden items.
         $count_hideItem = $count_hideItem + 1;
     }
 
@@ -128,7 +121,11 @@ foreach ($fileList as $file) {
     echo (($j++ > 1) ? "," : '')."'url':'".getFileUrl($file['path'])."'";
     echo "}\n";
 }
-$fileList = array_slice($fileList, $pagination->getPageOffset(), $pagination->getLimit()); //Chamilo fix for hidden files added +$count_hideItem
+$fileList = array_slice(
+    $fileList,
+    $pagination->getPageOffset(),
+    $pagination->getLimit()
+); //Chamilo fix for hidden files added +$count_hideItem
 
 echo "};</script>";
 if (!empty($_GET['view'])) {

+ 14 - 12
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_folder_listing.php

@@ -1,13 +1,15 @@
 <?php
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	echo '{';
-	$count = 1;
-	foreach(getFolderListing(CONFIG_SYS_ROOT_PATH) as $k=>$v)
-	{
-		
-
-		echo (($count > 1)?', ':''). "'" . $v . "':'" . $k . "'"; 
-		$count++;
-	}
-	echo "}";
-?>
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+echo '{';
+$count = 1;
+foreach (getFolderListing(CONFIG_SYS_ROOT_PATH) as $k => $v) {
+
+
+    echo (($count > 1) ? ', ' : '')."'".$v."':'".$k."'";
+    $count++;
+}
+echo "}";

+ 244 - 205
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_editor.php

@@ -1,223 +1,262 @@
 <?php
-		/**
-	 * Ajax image editor platform
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE)
-	{
-		die(SYS_DISABLED);
-	}
-		//$session->gc();// Disabled for integration with Chamilo
-		$_GET['path'] = empty($_GET['path'])?CONFIG_SYS_ROOT_PATH . "ajax_image_editor_demo.jpg":$_GET['path'];
-		if(!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path']))
-		{
-				$path = $_GET['path'];
-		}else 
-		{
-			die(IMG_GEN_IMG_NOT_EXISTS);
-		}
-		require_once(CLASS_HISTORY);
-		$history = new History($path, $session);
-		if(CONFIG_SYS_DEMO_ENABLE)
-		{
-			$sessionImageInfo = $history->getLastestRestorable();
-			$originalSessionImageInfo = $history->getOriginalImage();
-			if(sizeof($originalSessionImageInfo))
-			{
-				$path = backslashToSlash($session->getSessionDir() . $originalSessionImageInfo['info']['name']);
-			}
-		}
-		require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "class.image.php");
-		$image = new ImageAjaxFileManager();
-		
-		$imageInfo = $image->getImageInfo($path);
-
-	?>
+/* For licensing terms, see /license.txt */
+/**
+ * Ajax image editor platform
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/May/2007
+ *
+ */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE) {
+    die(SYS_DISABLED);
+}
+
+$_GET['path'] = empty($_GET['path']) ? CONFIG_SYS_ROOT_PATH."ajax_image_editor_demo.jpg" : $_GET['path'];
+if (!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path'])) {
+    $path = $_GET['path'];
+} else {
+    die(IMG_GEN_IMG_NOT_EXISTS);
+}
+require_once(CLASS_HISTORY);
+$history = new History($path, $session);
+if (CONFIG_SYS_DEMO_ENABLE) {
+    $sessionImageInfo         = $history->getLastestRestorable();
+    $originalSessionImageInfo = $history->getOriginalImage();
+    if (sizeof($originalSessionImageInfo)) {
+        $path = backslashToSlash($session->getSessionDir().$originalSessionImageInfo['info']['name']);
+    }
+}
+require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."inc".DIRECTORY_SEPARATOR."class.image.php");
+$image = new ImageAjaxFileManager();
+
+$imageInfo = $image->getImageInfo($path);
+
+?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="author" content="Logan Cai" />
-<meta name="website" content="http://www.phpletter.com" />
-<script type="text/javascript" src="jscripts/ajaximageeditor_c.js"></script>
-
-<!--<script type="text/javascript" src="jscripts/jquery.js"></script>
-<script type="text/javascript" src="jscripts/form.js"></script>
-<script type="text/javascript" src="jscripts/select.js"></script>
-<script type="text/javascript" src="jscripts/jqModal.js"></script>
-<script type="text/javascript" src="jscripts/rotate.js"></script>
-<script type="text/javascript" src="jscripts/interface.js"></script>-->
-
-
-<script type="text/javascript" src="jscripts/ajaximageeditor.js"></script>
-
-
-
-
-
-
-<script type="text/javascript">
-	var imageHistory = false;
-	var currentFolder =  '<?php echo removeTrailingSlash(backslashToSlash(dirname($path))); ?>';
-	var warningLostChanges = '<?php echo IMG_WARNING_LOST_CHANAGES; ?>';
-	var warningReset = '<?php echo IMG_WARNING_REST; ?>';
-	var warningResetEmpty = '<?php echo IMG_WARNING_EMPTY_RESET; ?>';
-	var warningEditorClose = '<?php echo IMG_WARING_WIN_CLOSE; ?>';
-	var warningUndoImage = '<?php echo IMG_WARNING_UNDO; ?>';
-	var warningFlipHorizotal = '<?php echo IMG_WARING_FLIP_H; ?>';
-	var warningFlipVertical = '<?php echo IMG_WARING_FLIP_V; ?>';
-	var numSessionHistory = <?php echo $history->getNumRestorable(); ?>;
-	var noChangeMadeBeforeSave = '<?php echo IMG_WARNING_NO_CHANGE_BEFORE_SAVE; ?>';
-	var warningInvalidNewName = '<?php echo IMG_SAVE_AS_ERR_NAME_INVALID; ?>';
-	var wordCloseWindow = '<?php echo LBL_ACTION_CLOSE; ?>';
-	var warningNoFolderSelected = '<?php echo IMG_SAVE_AS_NOT_FOLDER_SELECTED; ?>';
-	var urlGetFolderList = '<?php echo appendQueryString(CONFIG_URL_GET_FOLDER_LIST, makeQueryString(array('path'))); ?>';
-	$(document).ready(
-		function()
-		{
-			$('#windowSaveAs').jqm();
-			$('#image_mode').val('');
-			$('#angle').val(0);
-			$(getImageElement()).clone().appendTo("#hiddenImage");
-			changeMode();
-			initDisabledButtons(true);
-			$("#formImageInfo").bind("keypress", function(e) {
-			if (e.keyCode == 13) {
-			
-			return false;
-			
-			}
-			});			
-		}
-	);
-	
-</script>
-<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ajaximageeditor.css" type="text/css" rel="stylesheet" />
-<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jqModal.css" type="text/css" rel="stylesheet" />
-<title>Ajax Image Editor</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <meta name="author" content="Logan Cai"/>
+    <meta name="website" content="http://www.phpletter.com"/>
+    <script type="text/javascript" src="jscripts/ajaximageeditor_c.js"></script>
+
+    <!--<script type="text/javascript" src="jscripts/jquery.js"></script>
+    <script type="text/javascript" src="jscripts/form.js"></script>
+    <script type="text/javascript" src="jscripts/select.js"></script>
+    <script type="text/javascript" src="jscripts/jqModal.js"></script>
+    <script type="text/javascript" src="jscripts/rotate.js"></script>
+    <script type="text/javascript" src="jscripts/interface.js"></script>-->
+
+
+    <script type="text/javascript" src="jscripts/ajaximageeditor.js"></script>
+
+
+    <script type="text/javascript">
+        var imageHistory = false;
+        var currentFolder = '<?php echo removeTrailingSlash(backslashToSlash(dirname($path))); ?>';
+        var warningLostChanges = '<?php echo IMG_WARNING_LOST_CHANAGES; ?>';
+        var warningReset = '<?php echo IMG_WARNING_REST; ?>';
+        var warningResetEmpty = '<?php echo IMG_WARNING_EMPTY_RESET; ?>';
+        var warningEditorClose = '<?php echo IMG_WARING_WIN_CLOSE; ?>';
+        var warningUndoImage = '<?php echo IMG_WARNING_UNDO; ?>';
+        var warningFlipHorizotal = '<?php echo IMG_WARING_FLIP_H; ?>';
+        var warningFlipVertical = '<?php echo IMG_WARING_FLIP_V; ?>';
+        var numSessionHistory = <?php echo $history->getNumRestorable(); ?>;
+        var noChangeMadeBeforeSave = '<?php echo IMG_WARNING_NO_CHANGE_BEFORE_SAVE; ?>';
+        var warningInvalidNewName = '<?php echo IMG_SAVE_AS_ERR_NAME_INVALID; ?>';
+        var wordCloseWindow = '<?php echo LBL_ACTION_CLOSE; ?>';
+        var warningNoFolderSelected = '<?php echo IMG_SAVE_AS_NOT_FOLDER_SELECTED; ?>';
+        var urlGetFolderList = '<?php echo appendQueryString(CONFIG_URL_GET_FOLDER_LIST, makeQueryString(array('path'))); ?>';
+        $(document).ready(
+            function () {
+                $('#windowSaveAs').jqm();
+                $('#image_mode').val('');
+                $('#angle').val(0);
+                $(getImageElement()).clone().appendTo("#hiddenImage");
+                changeMode();
+                initDisabledButtons(true);
+                $("#formImageInfo").bind("keypress", function (e) {
+                    if (e.keyCode == 13) {
+
+                        return false;
+
+                    }
+                });
+            }
+        );
+
+    </script>
+    <link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ajaximageeditor.css" type="text/css" rel="stylesheet"/>
+    <link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jqModal.css" type="text/css" rel="stylesheet"/>
+    <title>Ajax Image Editor</title>
 </head>
 <body>
 <?php
-	//displayArray($_SESSION);
-	 
+//displayArray($_SESSION);
+
 ?>
 <div id="controls">
-	<fieldset id="modes">
-		<legend>Modes</legend>
-		<form name="formAction" id="formAction" method="post" action="<?php echo appendQueryString(CONFIG_URL_IMAGE_UNDO, makeQueryString(array('path'))); ?>">
-			<input type="hidden" name="file_path" id="file_path" value="<?php echo $_GET['path']; ?>" />
-			
-			<p><label  id="label_resize" class="labelMode"><?php echo IMG_MODE_RESIZE; ?></label> <input type="radio" name="mode" value="resize" class="input" checked="checked"  onclick="return changeMode();"/>
-			<label id="label_crop"  class="labelMode"><?php echo IMG_MODE_CROP; ?></label> <input type="radio" name="mode" value="crop" class="input" onclick="return changeMode();" />
-			<label  id="label_rotate"  class="labelMode"><?php echo IMG_MODE_ROTATE; ?></label> <input type="radio" name="mode" value="rotate" class="input" onclick="return changeMode();" />
-			<label  id="label_flip"  class="labelMode"><?php echo IMG_MODE_FLIP; ?></label> <input type="radio" name="mode" value="flip" class="input" onclick="return changeMode();" />
-			 || <label  id="label_constraint"><?php echo IMG_CHECKBOX_CONSTRAINT; ?></label> <input type="checkbox" name="constraint" id="constraint" value="1" class="input" onclick="return toggleConstraint();" />
-			<!--			<label>Watermark:</label> <input type="radio" name="mode" value="watermark" class="input" onclick="return false;" />-->
-			
-			<button id="actionRotateLeft" class="disabledButton" onclick="return leftRotate();" disabled><?php echo IMG_BTN_ROTATE_LEFT; ?></button>
-			<button id="actionRotateRight" class="disabledButton" onclick="return rightRotate();" disabled><?php echo IMG_BTN_ROTATE_RIGHT; ?></button>
-			<button id="actionFlipH" class="disabledButton" onclick="return flipHorizontal();" disabled><?php echo IMG_BTN_FLIP_H; ?></button>
-			<button id="actionFlipV" class="disabledButton" onclick="return flipVertical();" disabled><?php echo IMG_BTN_FLIP_V; ?></button>			
-			<button id="actionReset" class="button" onclick="return resetEditor();"><?php echo IMG_BTN_RESET; ?></button>
-			<button id="actionUndo" class="button" onclick="return undoImage();"><?php echo IMG_BTN_UNDO; ?></button>
-			<button id="actionSave" class="button" onclick="return saveImage();"><?php echo IMG_BTN_SAVE; ?></button>
-      <button id="actionSaveAs" class="button" onclick="return saveAsImagePre();"><?php echo IMG_BTN_SAVE_AS; ?></button>
-			<button id="actionClose" class="button" onclick="return editorClose();"><?php echo IMG_BTN_CLOSE; ?></button></p>
-		</form>
-	</fieldset>
-	<fieldset id="imageInfo">
-		<legend id="imageInfoLegend"><?php echo IMG_INFO; ?></legend>
-		<form name="formImageInfo" action="<?php echo appendQueryString(CONFIG_URL_IMAGE_SAVE, makeQueryString(array('path'))); ?>" method="post" id="formImageInfo">
-			<p><input type="hidden" name="mode" id="image_mode" value="" />
-      <input type="hidden" name="new_name" id="hidden_new_name" value="" />
-      <input type="hidden" name="save_to" id="hidden_save_to" value="" />
-			<input type="hidden" name="path" id="path" value="<?php echo $_GET['path']; ?>"  />
-			<input type="hidden" name="flip_angle" id="flip_angle" value="" />
-			<label><?php echo IMG_LBL_WIDTH; ?></label> <input type="text" name="width" id="width" value="" class="input imageInput"  />
-			<label><?php echo IMG_LBL_HEIGHT; ?></label> <input type="text" name="height" id="height" value="" class="input imageInput" />
-			<label><?php echo IMG_LBL_X; ?></label> <input type="text" name="x" id="x" value="" class="input imageInput"/>
-			<label><?php echo IMG_LBL_Y; ?></label> <input type="text" name="y" id="y" value="" class="input imageInput"/>
-<!--			<b>Percentage:</b> <input type="text" name="percentage" id="percentage" value="" class="input imageInput"/>-->
-			<label><?php echo IMG_LBL_RATIO; ?></label> <input type="text" name="ratio" id="ratio" value="" class="input imageInput"/>
-			<label><?php echo IMG_LBL_ANGLE; ?></label> <input type="text" name="angle" id="angle" value="" class="input imageInput" />
-			
-			</p>
-		</form>
-	</fieldset>
+    <fieldset id="modes">
+        <legend>Modes</legend>
+        <form name="formAction" id="formAction" method="post"
+              action="<?php echo appendQueryString(CONFIG_URL_IMAGE_UNDO, makeQueryString(array('path'))); ?>">
+            <input type="hidden" name="file_path" id="file_path" value="<?php echo $_GET['path']; ?>"/>
+
+            <p><label id="label_resize" class="labelMode"><?php echo IMG_MODE_RESIZE; ?></label> <input type="radio"
+                                                                                                        name="mode"
+                                                                                                        value="resize"
+                                                                                                        class="input"
+                                                                                                        checked="checked"
+                                                                                                        onclick="return changeMode();"/>
+                <label id="label_crop" class="labelMode"><?php echo IMG_MODE_CROP; ?></label> <input type="radio"
+                                                                                                     name="mode"
+                                                                                                     value="crop"
+                                                                                                     class="input"
+                                                                                                     onclick="return changeMode();"/>
+                <label id="label_rotate" class="labelMode"><?php echo IMG_MODE_ROTATE; ?></label> <input type="radio"
+                                                                                                         name="mode"
+                                                                                                         value="rotate"
+                                                                                                         class="input"
+                                                                                                         onclick="return changeMode();"/>
+                <label id="label_flip" class="labelMode"><?php echo IMG_MODE_FLIP; ?></label> <input type="radio"
+                                                                                                     name="mode"
+                                                                                                     value="flip"
+                                                                                                     class="input"
+                                                                                                     onclick="return changeMode();"/>
+                || <label id="label_constraint"><?php echo IMG_CHECKBOX_CONSTRAINT; ?></label> <input type="checkbox"
+                                                                                                      name="constraint"
+                                                                                                      id="constraint"
+                                                                                                      value="1"
+                                                                                                      class="input"
+                                                                                                      onclick="return toggleConstraint();"/>
+                <!--			<label>Watermark:</label> <input type="radio" name="mode" value="watermark" class="input" onclick="return false;" />-->
+
+                <button id="actionRotateLeft" class="disabledButton" onclick="return leftRotate();"
+                        disabled><?php echo IMG_BTN_ROTATE_LEFT; ?></button>
+                <button id="actionRotateRight" class="disabledButton" onclick="return rightRotate();"
+                        disabled><?php echo IMG_BTN_ROTATE_RIGHT; ?></button>
+                <button id="actionFlipH" class="disabledButton" onclick="return flipHorizontal();"
+                        disabled><?php echo IMG_BTN_FLIP_H; ?></button>
+                <button id="actionFlipV" class="disabledButton" onclick="return flipVertical();"
+                        disabled><?php echo IMG_BTN_FLIP_V; ?></button>
+                <button id="actionReset" class="button"
+                        onclick="return resetEditor();"><?php echo IMG_BTN_RESET; ?></button>
+                <button id="actionUndo" class="button"
+                        onclick="return undoImage();"><?php echo IMG_BTN_UNDO; ?></button>
+                <button id="actionSave" class="button"
+                        onclick="return saveImage();"><?php echo IMG_BTN_SAVE; ?></button>
+                <button id="actionSaveAs" class="button"
+                        onclick="return saveAsImagePre();"><?php echo IMG_BTN_SAVE_AS; ?></button>
+                <button id="actionClose" class="button"
+                        onclick="return editorClose();"><?php echo IMG_BTN_CLOSE; ?></button>
+            </p>
+        </form>
+    </fieldset>
+    <fieldset id="imageInfo">
+        <legend id="imageInfoLegend"><?php echo IMG_INFO; ?></legend>
+        <form name="formImageInfo"
+              action="<?php echo appendQueryString(CONFIG_URL_IMAGE_SAVE, makeQueryString(array('path'))); ?>"
+              method="post" id="formImageInfo">
+            <p><input type="hidden" name="mode" id="image_mode" value=""/>
+                <input type="hidden" name="new_name" id="hidden_new_name" value=""/>
+                <input type="hidden" name="save_to" id="hidden_save_to" value=""/>
+                <input type="hidden" name="path" id="path" value="<?php echo $_GET['path']; ?>"/>
+                <input type="hidden" name="flip_angle" id="flip_angle" value=""/>
+                <label><?php echo IMG_LBL_WIDTH; ?></label> <input type="text" name="width" id="width" value=""
+                                                                   class="input imageInput"/>
+                <label><?php echo IMG_LBL_HEIGHT; ?></label> <input type="text" name="height" id="height" value=""
+                                                                    class="input imageInput"/>
+                <label><?php echo IMG_LBL_X; ?></label> <input type="text" name="x" id="x" value=""
+                                                               class="input imageInput"/>
+                <label><?php echo IMG_LBL_Y; ?></label> <input type="text" name="y" id="y" value=""
+                                                               class="input imageInput"/>
+                <!--			<b>Percentage:</b> <input type="text" name="percentage" id="percentage" value="" class="input imageInput"/>-->
+                <label><?php echo IMG_LBL_RATIO; ?></label> <input type="text" name="ratio" id="ratio" value=""
+                                                                   class="input imageInput"/>
+                <label><?php echo IMG_LBL_ANGLE; ?></label> <input type="text" name="angle" id="angle" value=""
+                                                                   class="input imageInput"/>
+
+            </p>
+        </form>
+    </fieldset>
 </div>
 <div id="imageArea">
     <div id="imageContainer">
-    
-	<?php
-	if(Security::remove_XSS($_GET['editor'])!='stand_alone'){
-	
-		$path='../'.$path;//<!-- For Chamilo integrating, enter a back directory "../" to avoid introducing main and can not read the image -->
-	}
-	?>
-        <img src="<?php echo $path; ?>" name="<?php echo basename($path); ?>" width="<?php echo $imageInfo['width']; ?>" height="<?php echo $imageInfo['height']; ?>" />
-        
+
+        <?php
+        if (Security::remove_XSS($_GET['editor']) != 'stand_alone') {
+
+            $path = '../'.$path; //<!-- For Chamilo integrating, enter a back directory "../" to avoid introducing main and can not read the image -->
+        }
+        ?>
+        <img src="<?php echo $path; ?>" name="<?php echo basename($path); ?>" width="<?php echo $imageInfo['width']; ?>"
+             height="<?php echo $imageInfo['height']; ?>"/>
+
     </div>
     <div id="resizeMe">
-    	<div id="resizeSE"></div>
-    	<div id="resizeE"></div>
-    	<div id="resizeNE"></div>
-    	<div id="resizeN"></div>
-    	<div id="resizeNW"></div>
-    	<div id="resizeW"></div>
-    	<div id="resizeSW"></div>
-    	<div id="resizeS"></div>
-		<img id="loading" style="display:none;" src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/ajaxLoading.gif" />
+        <div id="resizeSE"></div>
+        <div id="resizeE"></div>
+        <div id="resizeNE"></div>
+        <div id="resizeN"></div>
+        <div id="resizeNW"></div>
+        <div id="resizeW"></div>
+        <div id="resizeSW"></div>
+        <div id="resizeS"></div>
+        <img id="loading" style="display:none;" src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/ajaxLoading.gif"/>
     </div>
 </div>
-    <div id="hiddenImage">
-    </div>
-		<div id="windowSaveAs" class="jqmWindow" style="display:none">
-    	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo LBL_ACTION_CLOSE; ?></a>
-      <form id="formSaveAs" name="formSaveAs" action="" method="post">
-    	<table class="tableForm" cellpadding="0" cellspacing="0">
-      	<thead>
-        	<tr>
-          	<th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
-          </tr>
-        </thead>
-        <tbody>
-        	<tr>
-          	<th>
-            	<label><?php echo IMG_LBL_NEW_NAME; ?></label>
-            </th>
-            <td>
-            	<input type="text" id="new_name" class="input" name="new_name" value="" />&nbsp;.<?php echo getFileExt($path); ?>
-            </td>
-          </tr>
-          <tr>
-          	<th>
-            	<label><?php echo IMG_LBL_SAVE_TO; ?></label>
-            </th>
-            <td>
-            	<select class="input" name="save_to" id="save_to"></select>
-            </td>
-          </tr>
-          <tr>
-          	<th>&nbsp;
-            </th>
-            <td>
-            <span class="comments">*</span>
-            <?php echo IMG_NEW_NAME_COMMENTS; ?>
-            </td>
-          </tr>
-        </tbody>
-        <tfoot>
-        	<tr>
-        	<th>&nbsp;</th>
-          <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>" onclick="return saveAsImage();" /></td>
-          </tr>
-        </tfoot>
-      </table>
-      </form>
-    </div>
+<div id="hiddenImage">
+</div>
+<div id="windowSaveAs" class="jqmWindow" style="display:none">
+    <a href="#" class="jqmClose" id="windowSaveClose"><?php echo LBL_ACTION_CLOSE; ?></a>
+
+    <form id="formSaveAs" name="formSaveAs" action="" method="post">
+        <table class="tableForm" cellpadding="0" cellspacing="0">
+            <thead>
+            <tr>
+                <th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr>
+                <th>
+                    <label><?php echo IMG_LBL_NEW_NAME; ?></label>
+                </th>
+                <td>
+                    <input type="text" id="new_name" class="input" name="new_name"
+                           value=""/>&nbsp;.<?php echo getFileExt($path); ?>
+                </td>
+            </tr>
+            <tr>
+                <th>
+                    <label><?php echo IMG_LBL_SAVE_TO; ?></label>
+                </th>
+                <td>
+                    <select class="input" name="save_to" id="save_to"></select>
+                </td>
+            </tr>
+            <tr>
+                <th>&nbsp;
+                </th>
+                <td>
+                    <span class="comments">*</span>
+                    <?php echo IMG_NEW_NAME_COMMENTS; ?>
+                </td>
+            </tr>
+            </tbody>
+            <tfoot>
+            <tr>
+                <th>&nbsp;</th>
+                <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>"
+                           onclick="return saveAsImage();"/></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>
 </body>
 </html>

+ 169 - 194
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_save.php

@@ -1,195 +1,170 @@
 <?php
-	/**
-	 * image save function
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");	
-	
-
-	$error = "";
-	$info = "";
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE)
-	{
-		$error = SYS_DISABLED;
-	}
-	elseif(empty($_POST['path']))
-	{
-		$error  =  IMG_SAVE_EMPTY_PATH;
-	}elseif(!file_exists($_POST['path']))
-	{		
-		$error  =  IMG_SAVE_NOT_EXISTS;
-	}elseif(!isUnderRoot($_POST['path']))
-	{
-		$error = IMG_SAVE_PATH_DISALLOWED;
-	}elseif(($sessionDir = $session->getSessionDir()) == '')
-	{
-		$error = SESSION_PERSONAL_DIR_NOT_FOUND;
-	}
-	else
-	{	
-		require_once(CLASS_HISTORY);
-		$history = new History($_POST['path'], $session);
-		if(!empty($_POST['mode']))
-		{
-			//get the original image which is the lastest session image if any when the system is in demo
-			$lastestSessionImageInfo = $history->getLastestRestorable();
-			if(sizeof($lastestSessionImageInfo) && CONFIG_SYS_DEMO_ENABLE)
-			{				
-				$originalSessionImageInfo = $history->getOriginalImage();
-				if(sizeof($originalSessionImageInfo))
-				{					
-					$originalImage = $sessionDir . $originalSessionImageInfo['info']['name'];
-				}				
-			}
-			if(empty($originalImage))
-			{
-				$originalImage = $_POST['path'];
-			}
-			
-			include_once(CLASS_IMAGE);
-			$image = new ImageAjaxFileManager();
-			if($image->loadImage($originalImage))
-			{				
-				
-				switch($_POST['mode'])
-				{
-					case "resize":					
-						if(!$image->resize($_POST['width'], $_POST['height'], (!empty($_POST['constraint'])?true:false)))
-						{
-							$error = IMG_SAVE_RESIZE_FAILED;
-						}					
-						break;
-					case "crop":	
-						if(!$image->crop($_POST['x'], $_POST['y'], $_POST['width'], $_POST['height']))
-						{
-							$error = IMG_SAVE_CROP_FAILED;
-						}
-						break;
-					case "flip":
-						if(!$image->flip($_POST['flip_angle']))
-						{
-							$error = IMG_SAVE_FLIP_FAILED;
-						}
-						break;
-					case "rotate":
-						
-						if(!$image->rotate(intval($_POST['angle'])))
-						{
-							$error = IMG_SAVE_ROTATE_FAILED;
-						}
-						
-						break;
-					default:
-						$error = IMG_SAVE_UNKNOWN_MODE;
-				}
-				
-				
-				if(empty($error))
-				{					
-					$sessionNewPath = $sessionDir  . uniqid(md5(time())) . "." . getFileExt($_POST['path']);					
-					if(!@copy($originalImage, $sessionNewPath))
-					{//keep a copy under the session folder
-						$error = IMG_SAVE_BACKUP_FAILED;						
-					}else 
-					{
-						
-						$isSaveAsRequest = (!empty($_POST['new_name']) && !empty($_POST['save_to'])?true:false);
-						//save the modified image
-						$sessionImageInfo = array('name'=>basename($sessionNewPath), 'restorable'=>1);
-						$history->add($sessionImageInfo);
-						if(CONFIG_SYS_DEMO_ENABLE)
-						{//demo only
-							if(isset($originalSessionImageInfo) && sizeof($originalSessionImageInfo))
-							{
-								$imagePath = $sessionDir . $originalSessionImageInfo['info']['name'];
-							}else 
-							{	
-								$imagePath = $sessionDir  . uniqid(md5(time())) . "." . getFileExt($_POST['path']);
-							}
-						}else 
-						{	
-							if($isSaveAsRequest)
-							{//save as request
-								//check save to folder if exists
-								$imagePath = addTrailingSlash(backslashToSlash($_POST['save_to'])) . $_POST['new_name'] . "." . getFileExt($_POST['path']); 
-								
-								if(!file_exists($_POST['save_to']) || !is_dir($_POST['save_to']))
-								{
-									$error = IMG_SAVE_AS_FOLDER_NOT_FOUND;
-								}elseif(file_exists($imagePath)) 
-								{
-									$error = IMG_SAVE_AS_NEW_IMAGE_EXISTS;
-								}elseif(!preg_match("/^[a-zA-Z0-9_\- ]+$/", $_POST['new_name']))
-								{
-									$error = IMG_SAVE_AS_ERR_NAME_INVALID;
-								}
-								
-							}else 
-							{//save request
-								$imagePath = $originalImage;	
-							}
-												
-						}
-
-						if($image->saveImage($imagePath))
-						{		
-									
-							if(CONFIG_SYS_DEMO_ENABLE)
-							{
-								if(!isset($originalSessionImageInfo) || !sizeof($originalSessionImageInfo))
-								{//keep this original image information on session for future reference if demo only	
-									$originalSessionImageInfo = array('name'=>basename($imagePath), 'restorable'=>0, 'is_original'=>1);
-									$history->add($originalSessionImageInfo);
-								}
-							}
-							$imageInfo = $image->getFinalImageInfo();								
-						}else 
-						{
-							$error = IMG_SAVE_FAILED;
-							
-						}							
-						if(isset($imageInfo))
-						{
-								$info .= ",width:" . $imageInfo['width'] . "";
-								$info .= ",height:" . $imageInfo['height'] . "";
-								$info .= ",size:'" . transformFileSize($imageInfo['size']) . "'";
-								if($isSaveAsRequest)
-								{
-									$info .= ",save_as:'1'";
-								}else 
-								{
-									$info .= ",save_as:'0'";
-								}
-								$info .= ",folder_path:'" . dirname($imagePath) . "'";
-								$info .= ",path:'" . backslashToSlash($imagePath) . "'";	
-													
-						}				
-			
-					}				
-								
-				}			
-			}else 
-			{
-				$error = IMG_SAVE_IMG_OPEN_FAILED . $originalImage;
-			}		
-
-		}else 
-		{
-			$error = IMG_SAVE_UNKNOWN_MODE;
-		}
-	}
-	echo "{";	
-	echo "error:'" . $error . "'";
-	if(isset($image) && is_object($image))
-	{
-		$image->DestroyImages();
-	}
-	echo $info;
-	echo ",history:" . (isset($history) && is_object($history)?($history->getNumRestorable()):0)  . "";
-	echo "}";
-	
-	
-?>
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+/**
+ * image save function
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/May/2007
+ *
+ */
+
+
+$error = "";
+$info  = "";
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE) {
+    $error = SYS_DISABLED;
+} elseif (empty($_POST['path'])) {
+    $error = IMG_SAVE_EMPTY_PATH;
+} elseif (!file_exists($_POST['path'])) {
+    $error = IMG_SAVE_NOT_EXISTS;
+} elseif (!isUnderRoot($_POST['path'])) {
+    $error = IMG_SAVE_PATH_DISALLOWED;
+} elseif (($sessionDir = $session->getSessionDir()) == '') {
+    $error = SESSION_PERSONAL_DIR_NOT_FOUND;
+} else {
+    require_once(CLASS_HISTORY);
+    $history = new History($_POST['path'], $session);
+    if (!empty($_POST['mode'])) {
+        //get the original image which is the lastest session image if any when the system is in demo
+        $lastestSessionImageInfo = $history->getLastestRestorable();
+        if (sizeof($lastestSessionImageInfo) && CONFIG_SYS_DEMO_ENABLE) {
+            $originalSessionImageInfo = $history->getOriginalImage();
+            if (sizeof($originalSessionImageInfo)) {
+                $originalImage = $sessionDir.$originalSessionImageInfo['info']['name'];
+            }
+        }
+        if (empty($originalImage)) {
+            $originalImage = $_POST['path'];
+        }
+
+        include_once(CLASS_IMAGE);
+        $image = new ImageAjaxFileManager();
+        if ($image->loadImage($originalImage)) {
+
+            switch ($_POST['mode']) {
+                case "resize":
+                    if (!$image->resize(
+                        $_POST['width'],
+                        $_POST['height'],
+                        (!empty($_POST['constraint']) ? true : false)
+                    )
+                    ) {
+                        $error = IMG_SAVE_RESIZE_FAILED;
+                    }
+                    break;
+                case "crop":
+                    if (!$image->crop($_POST['x'], $_POST['y'], $_POST['width'], $_POST['height'])) {
+                        $error = IMG_SAVE_CROP_FAILED;
+                    }
+                    break;
+                case "flip":
+                    if (!$image->flip($_POST['flip_angle'])) {
+                        $error = IMG_SAVE_FLIP_FAILED;
+                    }
+                    break;
+                case "rotate":
+
+                    if (!$image->rotate(intval($_POST['angle']))) {
+                        $error = IMG_SAVE_ROTATE_FAILED;
+                    }
+
+                    break;
+                default:
+                    $error = IMG_SAVE_UNKNOWN_MODE;
+            }
+
+
+            if (empty($error)) {
+                $sessionNewPath = $sessionDir.uniqid(md5(time())).".".getFileExt($_POST['path']);
+                if (!@copy($originalImage, $sessionNewPath)) { //keep a copy under the session folder
+                    $error = IMG_SAVE_BACKUP_FAILED;
+                } else {
+
+                    $isSaveAsRequest = (!empty($_POST['new_name']) && !empty($_POST['save_to']) ? true : false);
+                    //save the modified image
+                    $sessionImageInfo = array('name' => basename($sessionNewPath), 'restorable' => 1);
+                    $history->add($sessionImageInfo);
+                    if (CONFIG_SYS_DEMO_ENABLE) { //demo only
+                        if (isset($originalSessionImageInfo) && sizeof($originalSessionImageInfo)) {
+                            $imagePath = $sessionDir.$originalSessionImageInfo['info']['name'];
+                        } else {
+                            $imagePath = $sessionDir.uniqid(md5(time())).".".getFileExt($_POST['path']);
+                        }
+                    } else {
+                        if ($isSaveAsRequest) { //save as request
+                            //check save to folder if exists
+                            $imagePath = addTrailingSlash(
+                                    backslashToSlash($_POST['save_to'])
+                                ).$_POST['new_name'].".".getFileExt($_POST['path']);
+
+                            if (!file_exists($_POST['save_to']) || !is_dir($_POST['save_to'])) {
+                                $error = IMG_SAVE_AS_FOLDER_NOT_FOUND;
+                            } elseif (file_exists($imagePath)) {
+                                $error = IMG_SAVE_AS_NEW_IMAGE_EXISTS;
+                            } elseif (!preg_match("/^[a-zA-Z0-9_\- ]+$/", $_POST['new_name'])) {
+                                $error = IMG_SAVE_AS_ERR_NAME_INVALID;
+                            }
+
+                        } else { //save request
+                            $imagePath = $originalImage;
+                        }
+
+                    }
+
+                    if ($image->saveImage($imagePath)) {
+
+                        if (CONFIG_SYS_DEMO_ENABLE) {
+                            if (!isset($originalSessionImageInfo) || !sizeof(
+                                    $originalSessionImageInfo
+                                )
+                            ) { //keep this original image information on session for future reference if demo only
+                                $originalSessionImageInfo = array(
+                                    'name'        => basename($imagePath),
+                                    'restorable'  => 0,
+                                    'is_original' => 1
+                                );
+                                $history->add($originalSessionImageInfo);
+                            }
+                        }
+                        $imageInfo = $image->getFinalImageInfo();
+                    } else {
+                        $error = IMG_SAVE_FAILED;
+
+                    }
+                    if (isset($imageInfo)) {
+                        $info .= ",width:".$imageInfo['width']."";
+                        $info .= ",height:".$imageInfo['height']."";
+                        $info .= ",size:'".transformFileSize($imageInfo['size'])."'";
+                        if ($isSaveAsRequest) {
+                            $info .= ",save_as:'1'";
+                        } else {
+                            $info .= ",save_as:'0'";
+                        }
+                        $info .= ",folder_path:'".dirname($imagePath)."'";
+                        $info .= ",path:'".backslashToSlash($imagePath)."'";
+
+                    }
+
+                }
+
+            }
+        } else {
+            $error = IMG_SAVE_IMG_OPEN_FAILED.$originalImage;
+        }
+
+    } else {
+        $error = IMG_SAVE_UNKNOWN_MODE;
+    }
+}
+echo "{";
+echo "error:'".$error."'";
+if (isset($image) && is_object($image)) {
+    $image->DestroyImages();
+}
+echo $info;
+echo ",history:".(isset($history) && is_object($history) ? ($history->getNumRestorable()) : 0)."";
+echo "}";

+ 18 - 14
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_thumbnail.php

@@ -1,4 +1,6 @@
 <?php
+/* For licensing terms, see /license.txt */
+
 /**
  * ajax preview
  * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
@@ -7,20 +9,22 @@
  *
  */
 
-include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");	
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
 $path = base64_decode($_GET['path']);
-if(!empty($path) && file_exists($path) && is_file($path)) {
-	require_once CLASS_IMAGE;	
-	$image = new ImageAjaxFileManager(true);
-	if($image->loadImage($path)) {
-		if($image->resize(CONFIG_IMG_THUMBNAIL_MAX_X, CONFIG_IMG_THUMBNAIL_MAX_Y, true, true)) {
-			$image->showImage();
-		} else {
-			echo PREVIEW_NOT_PREVIEW . ".";	
-		}
-	} else {
-		echo PREVIEW_NOT_PREVIEW . "..";			
-	}		
+if (!empty($path) && file_exists($path) && is_file($path)) {
+    require_once CLASS_IMAGE;
+    $image = new ImageAjaxFileManager(true);
+    if ($image->loadImage($path)) {
+        if ($image->resize(CONFIG_IMG_THUMBNAIL_MAX_X, CONFIG_IMG_THUMBNAIL_MAX_Y, true, true)) {
+            $image->showImage();
+        } else {
+            echo PREVIEW_NOT_PREVIEW.".";
+        }
+    } else {
+        echo PREVIEW_NOT_PREVIEW."..";
+    }
 } else {
-	echo PREVIEW_NOT_PREVIEW . "...";
+    echo PREVIEW_NOT_PREVIEW."...";
 }

+ 81 - 91
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_undo.php

@@ -1,94 +1,84 @@
 <?php
-	/**
-	 * ajax image undo function
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");	
-	require_once(CLASS_HISTORY);
-	$history = new History($_POST['file_path'], $session);
-	$lastestSessionImageInfo = $history->getLastestRestorable();
-	echo "{";
-	$error = "";
-	$info = "";
-	if(CONFIG_SYS_VIEW_ONLY)
-	{
-		$error = SYS_DISABLED;
-	}
-	elseif(empty($_POST['file_path']))
-	{
-		$error  =  IMG_SAVE_EMPTY_PATH;
-	}elseif(!file_exists($_POST['file_path']))
-	{
-		$error  =  IMG_SAVE_NOT_EXISTS;
-	}elseif(!isUnderRoot($_POST['file_path']))
-	{
-		$error = IMG_SAVE_PATH_DISALLOWED;
-	}else if(!sizeof($lastestSessionImageInfo))
-	{
-		$error = IMG_UNDO_NO_HISTORY_AVAIALBE;
-	}
-	else
-	{		
-			//get the original image which is the lastest session image if any when the system is in demo
-			$sessionImage = $session->getSessionDir() . $lastestSessionImageInfo['name'];
-			$originalSessionImageInfo = $history->getOriginalImage();
-			if(CONFIG_SYS_DEMO_ENABLE && sizeof($originalSessionImageInfo))
-			{
-				$originalImage = $session->getSessionDir() . $originalSessionImageInfo['info']['name'];				
-			}else 
-			{
-				$originalImage = $_POST['file_path'];
-			}		
-			 
-				include_once(CLASS_IMAGE);
-				$image = new ImageAjaxFileManager();
-				if($image->loadImage($sessionImage))
-				{
-					$imageInfo = $image->getOriginalImageInfo();
-					if(!@copy($sessionImage, $originalImage))
-					{
-						$error = IMG_UNDO_COPY_FAILED;
-					}else 
-					{
-						
-						//remove the session image
-						if(@unlink($sessionImage))
-						{
-							$history->restore();
-						}
-						//only one left, remove the session original if demo
-						
-						if($history->getNumRestorable() == 0 && CONFIG_SYS_DEMO_ENABLE && sizeof($originalSessionImageInfo))
-						{
-							@unlink($session->getSessionDir() . $originalSessionImageInfo['info']['name']);	
-							$originalImage = $_POST['file_path'];
-						}
-					}
-					$imagePath = $originalImage;
-					
-				}else 
-				{
-					$error = IMG_SAVE_IMG_OPEN_FAILED;
-				}
-					if(isset($imageInfo))
-					{
-							$info .= ",width:" . $imageInfo['width'] . "\n";
-							$info .= ",height:" . $imageInfo['height'] . "\n";
-							$info .= ",size:'" . transformFileSize($imageInfo['size']) . "'\n";
-							$info .= ",path:'" . backslashToSlash($imagePath) . "'\n";						
-					}	
 
-	}
-	
-	echo "error:'" . $error . "'\n";
-	if(isset($image) && is_object($image))
-	{
-		$image->DestroyImages();
-	}
-	echo $info;
-	echo ",history:" . ($history->getNumRestorable()) . "\n";
-	echo "}";
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+/**
+ * ajax image undo function
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/May/2007
+ *
+ */
+
+require_once(CLASS_HISTORY);
+$history                 = new History($_POST['file_path'], $session);
+$lastestSessionImageInfo = $history->getLastestRestorable();
+echo "{";
+$error = "";
+$info  = "";
+if (CONFIG_SYS_VIEW_ONLY) {
+    $error = SYS_DISABLED;
+} elseif (empty($_POST['file_path'])) {
+    $error = IMG_SAVE_EMPTY_PATH;
+} elseif (!file_exists($_POST['file_path'])) {
+    $error = IMG_SAVE_NOT_EXISTS;
+} elseif (!isUnderRoot($_POST['file_path'])) {
+    $error = IMG_SAVE_PATH_DISALLOWED;
+} else {
+    if (!sizeof($lastestSessionImageInfo)) {
+        $error = IMG_UNDO_NO_HISTORY_AVAIALBE;
+    } else {
+        //get the original image which is the lastest session image if any when the system is in demo
+        $sessionImage             = $session->getSessionDir().$lastestSessionImageInfo['name'];
+        $originalSessionImageInfo = $history->getOriginalImage();
+        if (CONFIG_SYS_DEMO_ENABLE && sizeof($originalSessionImageInfo)) {
+            $originalImage = $session->getSessionDir().$originalSessionImageInfo['info']['name'];
+        } else {
+            $originalImage = $_POST['file_path'];
+        }
+
+        include_once(CLASS_IMAGE);
+        $image = new ImageAjaxFileManager();
+        if ($image->loadImage($sessionImage)) {
+            $imageInfo = $image->getOriginalImageInfo();
+            if (!@copy($sessionImage, $originalImage)) {
+                $error = IMG_UNDO_COPY_FAILED;
+            } else {
+
+                //remove the session image
+                if (@unlink($sessionImage)) {
+                    $history->restore();
+                }
+                //only one left, remove the session original if demo
+
+                if ($history->getNumRestorable() == 0 && CONFIG_SYS_DEMO_ENABLE && sizeof($originalSessionImageInfo)) {
+                    @unlink($session->getSessionDir().$originalSessionImageInfo['info']['name']);
+                    $originalImage = $_POST['file_path'];
+                }
+            }
+            $imagePath = $originalImage;
+
+        } else {
+            $error = IMG_SAVE_IMG_OPEN_FAILED;
+        }
+        if (isset($imageInfo)) {
+            $info .= ",width:".$imageInfo['width']."\n";
+            $info .= ",height:".$imageInfo['height']."\n";
+            $info .= ",size:'".transformFileSize($imageInfo['size'])."'\n";
+            $info .= ",path:'".backslashToSlash($imagePath)."'\n";
+        }
+
+    }
+}
+
+echo "error:'".$error."'\n";
+if (isset($image) && is_object($image)) {
+    $image->DestroyImages();
+}
+echo $info;
+echo ",history:".($history->getNumRestorable())."\n";
+echo "}";
 ?>

+ 40 - 44
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_login.php

@@ -1,56 +1,52 @@
 <?php
-	/**
-	 * access control login form
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/April/2007
-	 *
-	 */
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-if(isset($_POST['username']))
-{
-	if($auth->login())
-	{
-		header('Location: ' . appendQueryString(CONFIG_URL_HOME, makeQueryString()));
-		exit;		
-	}
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+if (isset($_POST['username'])) {
+    if ($auth->login()) {
+        header('Location: '.appendQueryString(CONFIG_URL_HOME, makeQueryString()));
+        exit;
+    }
 }
 ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<link type="text/css" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/login.css" rel="stylesheet" />
-<title><?php echo LOGIN_PAGE_TITLE; ?></title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <link type="text/css" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/login.css" rel="stylesheet"/>
+    <title><?php echo LOGIN_PAGE_TITLE; ?></title>
 </head>
 <body>
 <div id="container">
     <div id="content">
-			<form name="frmLogin" method="post" action="">
-			    <table class="adminLoginTable" cellpadding="0" cellspacing="0">
-			        <thead>
-			            <tr>
-			                <th colspan="2"><?php echo LOGIN_FORM_TITLE; ?></th>
-			            </tr>
-			        </thead>
-			        <tbody>
-			            <tr>
-			                <th class="padTop"><label><?php echo LOGIN_USERNAME; ?> </label></th>
-			                <td class="padTop"><input type="text" value="" class="input" name="username" id="username" /></td>
-			            </tr>
-			            <tr>
-			                <th><label><?php echo LOGIN_PASSWORD; ?> </label></th>
-			                <td><input type="password" value="" class="input" name="password" id="password" /></td>
-			            </tr>
-			        </tbody>
-			        <tfoot>
-			            <tr>
-			            	<td>&nbsp;</td>
-			              <td><input type="submit" class="button" value="Login" /></td>
-			            </tr>			        
-			        </tfoot>
-			    </table>
-			</form>
+        <form name="frmLogin" method="post" action="">
+            <table class="adminLoginTable" cellpadding="0" cellspacing="0">
+                <thead>
+                <tr>
+                    <th colspan="2"><?php echo LOGIN_FORM_TITLE; ?></th>
+                </tr>
+                </thead>
+                <tbody>
+                <tr>
+                    <th class="padTop"><label><?php echo LOGIN_USERNAME; ?> </label></th>
+                    <td class="padTop"><input type="text" value="" class="input" name="username" id="username"/></td>
+                </tr>
+                <tr>
+                    <th><label><?php echo LOGIN_PASSWORD; ?> </label></th>
+                    <td><input type="password" value="" class="input" name="password" id="password"/></td>
+                </tr>
+                </tbody>
+                <tfoot>
+                <tr>
+                    <td>&nbsp;</td>
+                    <td><input type="submit" class="button" value="Login"/></td>
+                </tr>
+                </tfoot>
+            </table>
+        </form>
     </div>
 </div>
 </body>

+ 40 - 40
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_preview.php

@@ -1,43 +1,43 @@
 <?php
-/**
- * AJAX preview
- * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
- * @author Julio Montoya - adding support for chamilo
- * @link www.phpletter.com
- * @since 22/April/2007
- *
- */
-include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";	
-api_block_anonymous_users();	
-if (!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path'])) {		
-	include_once(CLASS_MANAGER);
-	$manager = new manager($_GET['path'], false);
-	$fileTypes = $manager->getFileType(basename($_GET['path']));
-	if ($fileTypes['preview']) {
-		switch($fileTypes['fileType']) {
-			case "image":
-				$imageInfo = @getimagesize($_GET['path']);
-				if(!empty($imageInfo[0]) && !empty($imageInfo[1])) {
-					$thumInfo = getThumbWidthHeight($imageInfo[0], $imageInfo[1], 400, 135);
-					printf("<img src=\"%s\" width=\"%s\" height=\"%s\" />", getFileUrl($_GET['path']), $thumInfo['width'], $thumInfo['height']);													
-				} else {
-					echo PREVIEW_IMAGE_LOAD_FAILED;
-				}
-				break;
-			case "txt":
-				if(($fp = @fopen($_GET['path'], 'r'))) {
-					echo @fread($fp, @filesize($_GET['path']));
-					@fclose($fp);
-				} else {
-					echo PREVIEW_OPEN_FAILED . ".";
-				}
-				break;					
-			case "video":
-				break;
-		}
-	} else {
-		echo PREVIEW_NOT_PREVIEW . "..";
-	}				
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+if (!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path'])) {
+    include_once(CLASS_MANAGER);
+    $manager   = new manager($_GET['path'], false);
+    $fileTypes = $manager->getFileType(basename($_GET['path']));
+    if ($fileTypes['preview']) {
+        switch ($fileTypes['fileType']) {
+            case "image":
+                $imageInfo = @getimagesize($_GET['path']);
+                if (!empty($imageInfo[0]) && !empty($imageInfo[1])) {
+                    $thumInfo = getThumbWidthHeight($imageInfo[0], $imageInfo[1], 400, 135);
+                    printf(
+                        "<img src=\"%s\" width=\"%s\" height=\"%s\" />",
+                        getFileUrl($_GET['path']),
+                        $thumInfo['width'],
+                        $thumInfo['height']
+                    );
+                } else {
+                    echo PREVIEW_IMAGE_LOAD_FAILED;
+                }
+                break;
+            case "txt":
+                if (($fp = @fopen($_GET['path'], 'r'))) {
+                    echo @fread($fp, @filesize($_GET['path']));
+                    @fclose($fp);
+                } else {
+                    echo PREVIEW_OPEN_FAILED.".";
+                }
+                break;
+            case "video":
+                break;
+        }
+    } else {
+        echo PREVIEW_NOT_PREVIEW."..";
+    }
 } else {
-	echo PREVIEW_NOT_PREVIEW . "...";
+    echo PREVIEW_NOT_PREVIEW."...";
 }

+ 41 - 35
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_as_form.php

@@ -1,57 +1,63 @@
-<?php 
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	
+<?php
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
 ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>Untitled Document</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <title>Untitled Document</title>
 </head>
 
 <body>
-    	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
-      <form id="formSaveAs" name="formSaveAs" action="" method="post">
-    	<table class="tableForm" cellpadding="0" cellspacing="0">
-      	<thead>
-        	<tr>
-          	<th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
-          </tr>
+<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
+
+<form id="formSaveAs" name="formSaveAs" action="" method="post">
+    <table class="tableForm" cellpadding="0" cellspacing="0">
+        <thead>
+        <tr>
+            <th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
+        </tr>
         </thead>
         <tbody>
-        	<tr>
-          	<th>
-            	<label><?php echo IMG_LBL_NEW_NAME; ?></label>
+        <tr>
+            <th>
+                <label><?php echo IMG_LBL_NEW_NAME; ?></label>
             </th>
             <td>
-            	<input type="text" id="new_name" class="input" name="new_name" value="" />
+                <input type="text" id="new_name" class="input" name="new_name" value=""/>
             </td>
-          </tr>
-          <tr>
-          	<th>
-            	<label><?php echo IMG_LBL_SAVE_TO; ?></label>
+        </tr>
+        <tr>
+            <th>
+                <label><?php echo IMG_LBL_SAVE_TO; ?></label>
             </th>
             <td>
-            	<select class="input" name="save_to">
-              	
-              </select>
+                <select class="input" name="save_to">
+
+                </select>
             </td>
-          </tr>
-          <tr>
-          	<th>&nbsp;
+        </tr>
+        <tr>
+            <th>&nbsp;
             </th>
             <td>
-            <span class="comments">*</span>
-            <?php echo IMG_NEW_NAME_COMMENTS; ?>
+                <span class="comments">*</span>
+                <?php echo IMG_NEW_NAME_COMMENTS; ?>
             </td>
-          </tr>
+        </tr>
         </tbody>
         <tfoot>
-        	<tr>
-        	<th>&nbsp;</th>
-          <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>" onclick="return saveAsImage();" /></td>
-          </tr>
+        <tr>
+            <th>&nbsp;</th>
+            <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>"
+                       onclick="return saveAsImage();"/></td>
+        </tr>
         </tfoot>
-      </table>
+    </table>
 </body>
 </html>

+ 76 - 79
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_name.php

@@ -1,81 +1,78 @@
 <?php
-	/**
-	 * ajax save name
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	$error = '';
-	$fileInfo = array();
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_RENAME)
-	{
-		$error = SYS_DISABLED;
-	}
-	elseif(empty($_POST['name']))
-	{
-		$error = ERR_RENAME_EMPTY;
-	}elseif(!preg_match("/^[a-zA-Z0-9 _\-.]+$/", $_POST['name']))
-	{
-		$error = ERR_RENAME_FORMAT;
-	}elseif(empty($_POST['original_path']) || !file_exists($_POST['original_path']))
-	{
-		$error = ERR_RENAME_FILE_NOT_EXISTS;
-	}elseif(substr(slashToBackslash(removeTrailingSlash($_POST['original_path'])), strrpos(slashToBackslash(removeTrailingSlash($_POST['original_path'])), "/") + 1) == $_POST['name'])
-	{
-		$error = ERR_NO_CHANGES_MADE;
-	}elseif(file_exists(addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name']))
-	{
-		$error = ERR_RENAME_EXISTS;
-	}elseif(is_file($_POST['original_path']) && !isValidExt($_POST['name'], explode(",", CONFIG_UPLOAD_VALID_EXTS), explode(",", CONFIG_UPLOAD_INVALID_EXTS)))
-	{
-		$error = ERR_RENAME_FILE_TYPE_NOT_PERMITED;
-	}elseif(!rename(removeTrailingSlash($_POST['original_path']), addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name']))
-	{
-		$error = ERR_RENAME_FAILED;
-	}else 
-	{
-		//update record of session if image exists in session for cut or copy
-		include_once(CLASS_SESSION_ACTION);
-		$sessionAction = new SessionAction();		
-		$selectedDocuments = $sessionAction->get();
-		if(removeTrailingSlash($sessionAction->getFolder()) == getParentPath($_POST['original_path']) && sizeof($selectedDocuments))
-		{
-			if(($key = array_search(basename($_POST['original_path']), $selectedDocuments)) !== false)
-			{
-				$selectedDocuments[$key] = $_POST['name'];
-				$sessionAction->set($selectedDocuments);
-				
-			}
-			
-		}elseif(removeTrailingSlash($sessionAction->getFolder()) == removeTrailingSlash($_POST['original_path']))
-		{
-			$sessionAction->setFolder($_POST['original_path']);
-		}	
-		$path = addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'];
-		if(is_file($path))
-		{
-			include_once(CLASS_FILE);
-			$file = new file($path);
-			$fileInfo = $file->getFileInfo();
-			$fileInfo['mtime'] = date(DATE_TIME_FORMAT,$fileInfo['mtime']);
-		}else
-		{
-			include_once(CLASS_MANAGER);
-			$manager = new manager($path, false);
-			$fileInfo = $manager->getFolderInfo();
-			$fileInfo['mtime'] = date(DATE_TIME_FORMAT,$fileInfo['mtime']);
-		}
-	}
-	
-	echo "{";
-	echo "error:'" . $error . "' ";
-	foreach ($fileInfo as $k=>$v)
-	{
-		echo "," . $k . ":'" . $v . "' ";
-	}
-	echo "}";
-	
-	
+/* For licensing terms, see /license.txt */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+$error    = '';
+$fileInfo = array();
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_RENAME) {
+    $error = SYS_DISABLED;
+} elseif (empty($_POST['name'])) {
+    $error = ERR_RENAME_EMPTY;
+} elseif (!preg_match("/^[a-zA-Z0-9 _\-.]+$/", $_POST['name'])) {
+    $error = ERR_RENAME_FORMAT;
+} elseif (empty($_POST['original_path']) || !file_exists($_POST['original_path'])) {
+    $error = ERR_RENAME_FILE_NOT_EXISTS;
+} elseif (substr(
+        slashToBackslash(removeTrailingSlash($_POST['original_path'])),
+        strrpos(slashToBackslash(removeTrailingSlash($_POST['original_path'])), "/") + 1
+    ) == $_POST['name']
+) {
+    $error = ERR_NO_CHANGES_MADE;
+} elseif (file_exists(addTrailingSlash(getParentPath($_POST['original_path'])).$_POST['name'])) {
+    $error = ERR_RENAME_EXISTS;
+} elseif (is_file($_POST['original_path']) && !isValidExt(
+        $_POST['name'],
+        explode(",", CONFIG_UPLOAD_VALID_EXTS),
+        explode(",", CONFIG_UPLOAD_INVALID_EXTS)
+    )
+) {
+    $error = ERR_RENAME_FILE_TYPE_NOT_PERMITED;
+} elseif (!rename(
+    removeTrailingSlash($_POST['original_path']),
+    addTrailingSlash(getParentPath($_POST['original_path'])).$_POST['name']
+)
+) {
+    $error = ERR_RENAME_FAILED;
+} else {
+    //update record of session if image exists in session for cut or copy
+    include_once(CLASS_SESSION_ACTION);
+    $sessionAction     = new SessionAction();
+    $selectedDocuments = $sessionAction->get();
+    if (removeTrailingSlash($sessionAction->getFolder()) == getParentPath($_POST['original_path']) && sizeof(
+            $selectedDocuments
+        )
+    ) {
+        if (($key = array_search(basename($_POST['original_path']), $selectedDocuments)) !== false) {
+            $selectedDocuments[$key] = $_POST['name'];
+            $sessionAction->set($selectedDocuments);
+
+        }
+
+    } elseif (removeTrailingSlash($sessionAction->getFolder()) == removeTrailingSlash($_POST['original_path'])) {
+        $sessionAction->setFolder($_POST['original_path']);
+    }
+    $path = addTrailingSlash(getParentPath($_POST['original_path'])).$_POST['name'];
+    if (is_file($path)) {
+        include_once(CLASS_FILE);
+        $file              = new file($path);
+        $fileInfo          = $file->getFileInfo();
+        $fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']);
+    } else {
+        include_once(CLASS_MANAGER);
+        $manager           = new manager($path, false);
+        $fileInfo          = $manager->getFolderInfo();
+        $fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']);
+    }
+}
+
+echo "{";
+echo "error:'".$error."' ";
+foreach ($fileInfo as $k => $v) {
+    echo ",".$k.":'".$v."' ";
+}
+echo "}";
+
+
 ?>

+ 57 - 84
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_save_text.php

@@ -1,88 +1,61 @@
 <?php
-	/**
-	 * ajax save name
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	$error = '';
-	$path = addTrailingSlash(backslashToSlash($_POST['folder'])) . $_POST['name'];
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE)
-	{
-		$error = SYS_DISABLED;
-	}
-	elseif(isset($_POST['save_as_request']))
-	{		
-		if(!preg_match('/^[a-zA-Z0-9_\-.]+$/', $_POST['name']))
-		{
-			$error = TXT_SAVE_AS_ERR_NAME_INVALID;
-		}elseif(array_search(strtolower(getFileExt($_POST['name'])), getValidTextEditorExts()) === false)
-		{
-			$error = TXT_DISALLOWED_EXT;
-		}elseif(!isUnderRoot($_POST['folder']))
-		{
-			$error = ERR_FOLDER_PATH_NOT_ALLOWED;
-		}
-		else
-		{
-			
-			if(!empty($_POST['save_as_request']))
-			{//save as request
-				if(file_exists($path))
-				{
-					$error = TXT_FILE_EXIST;
-				}else 
-				{
-					if(($fp = @fopen($path, 'w+')) !== false)
-					{
-						if(@fwrite($fp, $_POST['text']))
-						{
-							@fclose($fp);
-						}else 
-						{
-							$error = TXT_CONTENT_WRITE_FAILED;
-						}
-					}else 
-					{
-						$error = TXT_CREATE_FAILED;
-					}					
-				}
+/* For licensing terms, see /license.txt */
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
 
-				
-			}else 
-			{
-				if(!file_exists($path))
-				{
-					$error = TXT_FILE_NOT_EXIST;
-				}else 
-				{
-					if(($fp = @fopen($path, 'w')) !== false)
-					{
-						if(@fwrite($fp, $_POST['text']))
-						{
-							@fclose($fp);
-						}else 
-						{
-							$error = TXT_CONTENT_UPDATE_FAILED;
-						}
-					}else 
-					{
-						$error = TXT_FILE_OPEN_FAILED;
-					}						
-				}
-			}
-			
-		}
+$error = '';
+$path  = addTrailingSlash(backslashToSlash($_POST['folder'])).$_POST['name'];
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE) {
+    $error = SYS_DISABLED;
+} elseif (isset($_POST['save_as_request'])) {
+    if (!preg_match('/^[a-zA-Z0-9_\-.]+$/', $_POST['name'])) {
+        $error = TXT_SAVE_AS_ERR_NAME_INVALID;
+    } elseif (array_search(strtolower(getFileExt($_POST['name'])), getValidTextEditorExts()) === false) {
+        $error = TXT_DISALLOWED_EXT;
+    } elseif (!isUnderRoot($_POST['folder'])) {
+        $error = ERR_FOLDER_PATH_NOT_ALLOWED;
+    } else {
+
+        if (!empty($_POST['save_as_request'])) { //save as request
+            if (file_exists($path)) {
+                $error = TXT_FILE_EXIST;
+            } else {
+                if (($fp = @fopen($path, 'w+')) !== false) {
+                    if (@fwrite($fp, $_POST['text'])) {
+                        @fclose($fp);
+                    } else {
+                        $error = TXT_CONTENT_WRITE_FAILED;
+                    }
+                } else {
+                    $error = TXT_CREATE_FAILED;
+                }
+            }
+
+
+        } else {
+            if (!file_exists($path)) {
+                $error = TXT_FILE_NOT_EXIST;
+            } else {
+                if (($fp = @fopen($path, 'w')) !== false) {
+                    if (@fwrite($fp, $_POST['text'])) {
+                        @fclose($fp);
+                    } else {
+                        $error = TXT_CONTENT_UPDATE_FAILED;
+                    }
+                } else {
+                    $error = TXT_FILE_OPEN_FAILED;
+                }
+            }
+        }
+
+    }
+
+} else {
+    $error = TXT_UNKNOWN_REQUEST;
+}
+echo "{";
+echo "error:'".$error."',\n";
+echo "path:'".$path."'";
+echo "}";
 
-	}else 
-	{
-		$error = TXT_UNKNOWN_REQUEST;
-	}
-		echo "{";
-		echo "error:'" . $error . "',\n";
-		echo  "path:'" . $path . "'";
-		echo "}";
-	
 ?>

+ 144 - 148
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_text_editor.php

@@ -1,166 +1,162 @@
 <?php
-		/**
-	 * Ajax image editor platform
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE)
-	{
-		die(SYS_DISABLED);
-	}	
-		//$session->gc(); //disabled for Chamilo
-		$_GET['path'] = empty($_GET['path'])?CONFIG_SYS_ROOT_PATH . "ajax_image_editor_demo.jpg":$_GET['path'];
-		if(!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path']))
-		{
-				$path = $_GET['path'];
-		}else 
-		{
-			die(TXT_FILE_NOT_FOUND);
-		}
-		if(file_exists(DIR_AJAX_EDIT_AREA . "reg_syntax" . DIRECTORY_SEPARATOR . getFileExt($path) . ".js"))
-		{
-			$syntax = getFileExt($path);			
-		}else 
-		{
-			switch (getFileExt($path))
-			{
-				case 'htm':
-					$syntax = 'html';
-					break;
-				default:
-					$syntax = 'basic';
-			}
-		}
-		if(array_search(getFileExt($path), getValidTextEditorExts())=== false)
-		{
-			die(TXT_DISALLOWED_EXT);	
-		}
-	?>
+/* For licensing terms, see /license.txt */
+/**
+ * Ajax image editor platform
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/May/2007
+ *
+ */
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
+
+if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE) {
+    die(SYS_DISABLED);
+}
+
+//$session->gc(); //disabled for Chamilo
+$_GET['path'] = empty($_GET['path']) ? CONFIG_SYS_ROOT_PATH."ajax_image_editor_demo.jpg" : $_GET['path'];
+if (!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path'])) {
+    $path = $_GET['path'];
+} else {
+    die(TXT_FILE_NOT_FOUND);
+}
+if (file_exists(DIR_AJAX_EDIT_AREA."reg_syntax".DIRECTORY_SEPARATOR.getFileExt($path).".js")) {
+    $syntax = getFileExt($path);
+} else {
+    switch (getFileExt($path)) {
+        case 'htm':
+            $syntax = 'html';
+            break;
+        default:
+            $syntax = 'basic';
+    }
+}
+if (array_search(getFileExt($path), getValidTextEditorExts()) === false) {
+    die(TXT_DISALLOWED_EXT);
+}
+?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="author" content="Logan Cai" />
-<meta name="website" content="http://www.phpletter.com" />
-<script type="text/javascript" src="jscripts/ajaxtexteditor_c.js"></script>
-<!--<script type="text/javascript" src="jscripts/jquery.js"></script>
-<script type="text/javascript" src="jscripts/form.js"></script>
-<script type="text/javascript" src="jscripts/select.js"></script>
-<script type="text/javascript" src="jscripts/jqModal.js"></script>
-<script type="text/javascript" src="jscripts/ajaxtexteditor.js"></script>
--->
-<script type="text/javascript" src="jscripts/edit_area/edit_area_full.js"></script>
-<script type="text/javascript">
-				var warningExtNotSelected = '<?php echo TXT_EXT_NOT_SELECTED; ?>';
-				var urlGetFolderList = '<?php echo appendQueryString(CONFIG_URL_GET_FOLDER_LIST, makeQueryString(array('path'))); ?>';
-				var warningInvalidName = '<?php echo TXT_SAVE_AS_ERR_NAME_INVALID; ?>';
-				var waringFolderNotSelected = '<?php echo TXT_DEST_FOLDER_NOT_SELECTED; ?>';
-				var currentFolder = '<?php echo dirname($path); ?>';
-				var currentName = '<?php echo basename($path); ?>';
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <meta name="author" content="Logan Cai"/>
+    <meta name="website" content="http://www.phpletter.com"/>
+    <script type="text/javascript" src="jscripts/ajaxtexteditor_c.js"></script>
+    <!--<script type="text/javascript" src="jscripts/jquery.js"></script>
+    <script type="text/javascript" src="jscripts/form.js"></script>
+    <script type="text/javascript" src="jscripts/select.js"></script>
+    <script type="text/javascript" src="jscripts/jqModal.js"></script>
+    <script type="text/javascript" src="jscripts/ajaxtexteditor.js"></script>
+    -->
+    <script type="text/javascript" src="jscripts/edit_area/edit_area_full.js"></script>
+    <script type="text/javascript">
+        var warningExtNotSelected = '<?php echo TXT_EXT_NOT_SELECTED; ?>';
+        var urlGetFolderList = '<?php echo appendQueryString(CONFIG_URL_GET_FOLDER_LIST, makeQueryString(array('path'))); ?>';
+        var warningInvalidName = '<?php echo TXT_SAVE_AS_ERR_NAME_INVALID; ?>';
+        var waringFolderNotSelected = '<?php echo TXT_DEST_FOLDER_NOT_SELECTED; ?>';
+        var currentFolder = '<?php echo dirname($path); ?>';
+        var currentName = '<?php echo basename($path); ?>';
 
-		jQuery(document).ready(
-		function()
-		{
-				editAreaLoader.init({				
-				id: "content"	// id of the textarea to transform		
-				,start_highlight: false	// if start with highlight
-				,allow_resize: "both"
-				,gecko_spellcheck:true
-				,allow_toggle: true
-				,toolbar:"search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, highlight, reset_highlight, |, save, save_as"
-				,save_callback:"save"
-				,save_as_callback:"save_as"
-				,language: "<?php echo (file_exists(DIR_AJAX_EDIT_AREA . 'langs' . DIRECTORY_SEPARATOR .CONFIG_LANG_INDEX . ".js")?CONFIG_LANG_INDEX:'en'); ?>"
-				,syntax: "<?php echo $syntax; ?>"	
-			});				
-				jQuery('#windowSaveAs').jqm();		
-				jQuery('#windowProcessing').jqm({modal:true});				
-		}
-	);		
+        jQuery(document).ready(
+            function () {
+                editAreaLoader.init({
+                    id: "content"	// id of the textarea to transform
+                    , start_highlight: false	// if start with highlight
+                    , allow_resize: "both", gecko_spellcheck: true, allow_toggle: true, toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, highlight, reset_highlight, |, save, save_as", save_callback: "save", save_as_callback: "save_as", language: "<?php echo (file_exists(DIR_AJAX_EDIT_AREA . 'langs' . DIRECTORY_SEPARATOR .CONFIG_LANG_INDEX . ".js")?CONFIG_LANG_INDEX:'en'); ?>", syntax: "<?php echo $syntax; ?>"
+                });
+                jQuery('#windowSaveAs').jqm();
+                jQuery('#windowProcessing').jqm({modal: true});
+            }
+        );
 
-		
 
-			
-</script>
+    </script>
 
-<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ajaxtexteditor.css" type="text/css" rel="stylesheet" />
-<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jqModal.css" type="text/css" rel="stylesheet" />
-<title>Ajax Text Editor</title>
+    <link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ajaxtexteditor.css" type="text/css" rel="stylesheet"/>
+    <link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jqModal.css" type="text/css" rel="stylesheet"/>
+    <title>Ajax Text Editor</title>
 </head>
 <body>
 
 <div id="pageBody">
-	<textarea name="content" id="content" style="height:500px; width: 97%;"><?php echo getFileContent($path); ?></textarea>
+    <textarea name="content" id="content" style="height:500px; width: 97%;"><?php echo getFileContent(
+            $path
+        ); ?></textarea>
 </div>
 <div id="windowProcessing" class="jqmWindow" style="display:none">
-	<form name="frmProcessing" id="frmProcessing" method="post" action="<?php echo appendQueryString(CONFIG_URL_SAVE_TEXT, makeQueryString(array('path')));?>">
-		<input type="hidden" name="folder" id="folder" value="<?php echo dirname($path); ?>" />
-		<input type="hidden" name="name" id="name" value="<?php echo basename($path); ?>" />	
-		<input type="hidden" name="save_as_request" id="save_as_request" value="0" />
-		<div style="display:none"><textarea name="text" id="text"></textarea></div> 
-	</form> 
-	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
-	<p><img src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/loading.gif" /></p>
+    <form name="frmProcessing" id="frmProcessing" method="post"
+          action="<?php echo appendQueryString(CONFIG_URL_SAVE_TEXT, makeQueryString(array('path'))); ?>">
+        <input type="hidden" name="folder" id="folder" value="<?php echo dirname($path); ?>"/>
+        <input type="hidden" name="name" id="name" value="<?php echo basename($path); ?>"/>
+        <input type="hidden" name="save_as_request" id="save_as_request" value="0"/>
+
+        <div style="display:none"><textarea name="text" id="text"></textarea></div>
+    </form>
+    <a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
+
+    <p><img src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/loading.gif"/></p>
 </div>
 <div id="windowSaveAs" class="jqmWindow" style="display:none">
-    	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
-      <form id="formSaveAs" name="formSaveAs" action="" method="post">
-    	<table class="tableForm" cellpadding="0" cellspacing="0">
-      	<thead>
-        	<tr>
-          	<th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
-          </tr>
-        </thead>
-        <tbody>
-        	<tr>
-          	<th>
-            	<label><?php echo IMG_LBL_NEW_NAME; ?></label>
-            </th>
-            <td>
-            	<input type="text" id="new_name" class="input" name="new_name" value="" />
-              &nbsp;.&nbsp;<select id="ext" name="ext">
-              <?php
-								foreach(getValidTextEditorExts() as $v)
-								{
-									?>
-									<option value="<?php echo $v; ?>" <?php echo (strtolower($v) == strtolower(getFileExt($path))?'selected':''); ?>><?php echo $v; ?></option>
-									<?php
-								}
-							?>
-              </select>
-            </td>
-          </tr>
-          <tr>
-          	<th>
-            	<label><?php echo IMG_LBL_SAVE_TO; ?></label>
-            </th>
-            <td>
-            	<select class="input" name="save_to" id="save_to">
-              	
-              </select>
-            </td>
-          </tr>
-          <tr>
-          	<th>&nbsp;
-            </th>
-            <td>
-            <span class="comments">*</span>
-            <?php echo IMG_NEW_NAME_COMMENTS; ?>
-            </td>
-          </tr>
-        </tbody>
-        <tfoot>
-        	<tr>
-        	<th>&nbsp;</th>
-          <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>" onclick="return do_save_as();" /></td>
-          </tr>
-        </tfoot>
-      </table>
-      </form>
-    </div>
+    <a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
+
+    <form id="formSaveAs" name="formSaveAs" action="" method="post">
+        <table class="tableForm" cellpadding="0" cellspacing="0">
+            <thead>
+            <tr>
+                <th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr>
+                <th>
+                    <label><?php echo IMG_LBL_NEW_NAME; ?></label>
+                </th>
+                <td>
+                    <input type="text" id="new_name" class="input" name="new_name" value=""/>
+                    &nbsp;.&nbsp;<select id="ext" name="ext">
+                        <?php
+                        foreach (getValidTextEditorExts() as $v) {
+                            ?>
+                            <option value="<?php echo $v; ?>" <?php echo(strtolower($v) == strtolower(
+                                getFileExt($path)
+                            ) ? 'selected' : ''); ?>><?php echo $v; ?></option>
+                        <?php
+                        }
+                        ?>
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th>
+                    <label><?php echo IMG_LBL_SAVE_TO; ?></label>
+                </th>
+                <td>
+                    <select class="input" name="save_to" id="save_to">
+
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th>&nbsp;
+                </th>
+                <td>
+                    <span class="comments">*</span>
+                    <?php echo IMG_NEW_NAME_COMMENTS; ?>
+                </td>
+            </tr>
+            </tbody>
+            <tfoot>
+            <tr>
+                <th>&nbsp;</th>
+                <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>"
+                           onclick="return do_save_as();"/></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>
 
-</body></html>
+</body>
+</html>
 

+ 677 - 676
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php

@@ -1,422 +1,416 @@
 <?php
-/**
-* file manager platform
-* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-* @link www.phpletter.com
-* @since 22/May/2007
-*
-* Modify system config setting for Chamilo
-* @author Juan Carlos Raña Trabado
-* @since 31/December/2008
-*/
-
-include '../../../../../../inc/global.inc.php'; // Integrating with Chamilo
-api_block_anonymous_users();// from Chamilo
+/* For licensing terms, see /license.txt */
 
-require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";
+/**
+ * file manager platform
+ * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+ * @link www.phpletter.com
+ * @since 22/May/2007
+ *
+ * Modify system config setting for Chamilo
+ * @author Juan Carlos Raña Trabado
+ * @since 31/December/2008
+ */
+
+require_once '../../../../../../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'fckeditor/editor/plugins/ajaxfilemanager/inc/config.php';
 
 require_once CLASS_SESSION_ACTION;
 $sessionAction = new SessionAction();
 
 if (CONFIG_LOAD_DOC_LATTER) {
-	$fileList = array();
-	$folderInfo = array('path'=>getCurrentFolderPath());
+    $fileList   = array();
+    $folderInfo = array('path' => getCurrentFolderPath());
 } else {
-	require_once(CLASS_MANAGER);
-	$manager = new manager();
-	$manager->setSessionAction($sessionAction);
-	$fileList = $manager->getFileList();
-	$folderInfo = $manager->getFolderInfo();
+    require_once(CLASS_MANAGER);
+    $manager = new manager();
+    $manager->setSessionAction($sessionAction);
+    $fileList   = $manager->getFileList();
+    $folderInfo = $manager->getFolderInfo();
 }
 
-if(CONFIG_SYS_THUMBNAIL_VIEW_ENABLE) {
-	$views = array(
-		'detail'=>LBL_BTN_VIEW_DETAILS,
-		'thumbnail'=>LBL_BTN_VIEW_THUMBNAIL,
-	);
+if (CONFIG_SYS_THUMBNAIL_VIEW_ENABLE) {
+    $views = array(
+        'detail'    => LBL_BTN_VIEW_DETAILS,
+        'thumbnail' => LBL_BTN_VIEW_THUMBNAIL,
+    );
 } else {
-	$views = array(
-	  'detail'=>LBL_BTN_VIEW_DETAILS,
-	);
+    $views = array(
+        'detail' => LBL_BTN_VIEW_DETAILS,
+    );
 }
 
-if(!empty($_GET['view'])) {
-	switch($_GET['view']) {
-		case 'detail':
-		case 'thumbnail':
-			$view = Security::remove_XSS($_GET['view']);
-			break;
-		default:
-			$view = CONFIG_DEFAULT_VIEW;
-	}
+if (!empty($_GET['view'])) {
+    switch ($_GET['view']) {
+        case 'detail':
+        case 'thumbnail':
+            $view = Security::remove_XSS($_GET['view']);
+            break;
+        default:
+            $view = CONFIG_DEFAULT_VIEW;
+    }
 } else {
-	$view = CONFIG_DEFAULT_VIEW;
+    $view = CONFIG_DEFAULT_VIEW;
 }
 
 ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" debug="true" xml:lang="<?php echo CONFIG_LANG_DEFAULT; ?>" lang="<?php echo CONFIG_LANG_DEFAULT; ?>"><!--  hack fon lang default Chamilo -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" debug="true" xml:lang="<?php echo CONFIG_LANG_DEFAULT; ?>" lang="<?php echo CONFIG_LANG_DEFAULT; ?>">
+<!--  hack fon lang default Chamilo -->
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>Ajax File Manager</title>
-
-<script type="text/javascript" src="jscripts/jquery.js"></script>
-<script type="text/javascript" src="jscripts/form.js"></script>
-<script type="text/javascript" src="jscripts/select.js"></script>
-<script type="text/javascript" src="jscripts/thickbox.js"></script>
-<script type="text/javascript" src="jscripts/calendar.js"></script>
-<script type="text/javascript" src="jscripts/contextmenu.js"></script>
-<script type="text/javascript" src="jscripts/media.js"></script>
-<script type="text/javascript" src="jscripts/ajaxfileupload.js"></script>
-<script type="text/javascript" src="jscripts/ajaxfilemanager.js"></script>
-<script type="text/javascript">
-
-	var mode_editor = '<?php echo Security::remove_XSS($_GET['editor']);?>';<!-- Chamilo hack for general my files users  -->
-	if (!mode_editor){
-		// Added by Ivan Tcholakov, 22-JUL-2009.
-		// For integration with the editor's dialig system.
-		var oEditor = null ;
-		if ( !window.opener && window.parent ) {
-			// The file manager is inside a dialog.
-			oEditor = window.parent.InnerDialogLoaded() ;
-		}
-		//end hack
-	}
-	var globalSettings = {'upload_init':false};
-	var queryString = '<?php echo makeQueryString(array('path')); ?>';
-	var paths = {'root':'<?php echo addTrailingSlash(backslashToSlash(CONFIG_SYS_ROOT_PATH)); ?>', 'root_title':'<?php echo LBL_FOLDER_ROOT; ?>'};
-
-	<!-- Chamilo hack for breadcrumb into shared folders -->
-	var shared_folder = '<?php echo get_lang('UserFolders');?>';
-
-	<?php
-    $course_session = array();
-    if (isset($currentPath)) {
-        $course_session = explode('_', basename($currentPath));
-        $course_session = strtolower($course_session[sizeof($course_session) - 1]);
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <title>Ajax File Manager</title>
+
+    <script type="text/javascript" src="jscripts/jquery.js"></script>
+    <script type="text/javascript" src="jscripts/form.js"></script>
+    <script type="text/javascript" src="jscripts/select.js"></script>
+    <script type="text/javascript" src="jscripts/thickbox.js"></script>
+    <script type="text/javascript" src="jscripts/calendar.js"></script>
+    <script type="text/javascript" src="jscripts/contextmenu.js"></script>
+    <script type="text/javascript" src="jscripts/media.js"></script>
+    <script type="text/javascript" src="jscripts/ajaxfileupload.js"></script>
+    <script type="text/javascript" src="jscripts/ajaxfilemanager.js"></script>
+    <script type="text/javascript">
+
+        var mode_editor = '<?php echo Security::remove_XSS($_GET['editor']);?>';
+        <!-- Chamilo hack for general my files users  -->
+        if (!mode_editor) {
+            // Added by Ivan Tcholakov, 22-JUL-2009.
+            // For integration with the editor's dialig system.
+            var oEditor = null;
+            if (!window.opener && window.parent) {
+                // The file manager is inside a dialog.
+                oEditor = window.parent.InnerDialogLoaded();
+            }
+            //end hack
+        }
+        var globalSettings = {'upload_init': false};
+        var queryString = '<?php echo makeQueryString(array('path')); ?>';
+        var paths = {'root': '<?php echo addTrailingSlash(backslashToSlash(CONFIG_SYS_ROOT_PATH)); ?>', 'root_title': '<?php echo LBL_FOLDER_ROOT; ?>'};
+
+        <!-- Chamilo hack for breadcrumb into shared folders -->
+        var shared_folder = '<?php echo get_lang('UserFolders'); ?>';
+
+        <?php
+        $course_session = array();
+        if (isset($currentPath)) {
+            $course_session = explode('_', basename($currentPath));
+            $course_session = strtolower($course_session[sizeof($course_session) - 1]);
+        }
+        ?>
+        var shared_folder_session = '<?php echo get_lang('UserFolders').'*';?>';
+        var shared_user_folder = '<?php echo get_lang('User');?>';
+        <!--end hack -->
+
+        var parentFolder = {};
+        var urls = {
+            'upload': '<?php echo CONFIG_URL_UPLOAD; ?>',
+            'preview': '<?php echo CONFIG_URL_PREVIEW; ?>',
+            'cut': '<?php echo CONFIG_URL_CUT; ?>',
+            'copy': '<?php echo CONFIG_URL_COPY; ?>',
+            'paste': '<?php echo CONFIG_URL_FILE_PASTE; ?>',
+            'delete': '<?php echo CONFIG_URL_DELETE; ?>',
+            'rename': '<?php echo CONFIG_URL_SAVE_NAME; ?>',
+            'thumbnail': '<?php echo CONFIG_URL_IMG_THUMBNAIL;  ?>',
+            'create_folder': '<?php echo CONFIG_URL_CREATE_FOLDER; ?>',
+            'text_editor': '<?php echo  CONFIG_URL_TEXT_EDITOR; ?>',
+            'image_editor': '<?php echo  CONFIG_URL_IMAGE_EDITOR; ?>',
+            'download': '<?php echo CONFIG_URL_DOWNLOAD; ?>',
+            'present': '<?php echo getCurrentUrl(); ?>',
+            'home': '<?php echo CONFIG_URL_HOME; ?>',
+            'view': '<?php echo CONFIG_URL_LIST_LISTING; ?>'
+        };
+        var permits = {    'del':<?php echo (CONFIG_OPTIONS_DELETE?1:0); ?>,
+            'cut':<?php echo (CONFIG_OPTIONS_CUT?'1':'0'); ?>,
+            'copy':<?php echo (CONFIG_OPTIONS_COPY?1:0); ?>,
+            'newfolder':<?php echo (CONFIG_OPTIONS_NEWFOLDER?1:0); ?>,
+            'rename':<?php echo (CONFIG_OPTIONS_RENAME?1:0); ?>,
+            'upload':<?php echo (CONFIG_OPTIONS_UPLOAD?1:0); ?>,
+            'edit':<?php echo (CONFIG_OPTIONS_EDITABLE?1:0); ?>,
+            'view_only':<?php echo (CONFIG_SYS_VIEW_ONLY?1:0); ?>};
+        var currentFolder = {};
+        var warningDelete = '<?php echo WARNING_DELETE; ?>';
+        var newFile = {'num': 1, 'label': '<?php echo FILE_LABEL_SELECT; ?>', 'upload': '<?php echo FILE_LBL_UPLOAD; ?>'};
+        var counts = {'new_file': 1};
+        var thickbox = {
+            'width': '<?php echo CONFIG_THICKBOX_MAX_WIDTH; ?>',
+            'height': '<?php echo CONFIG_THICKBOX_MAX_HEIGHT; ?>',
+            'next': '<img src="theme/default/images/next.png" title="<?php echo THICKBOX_NEXT; ?>" style="float:right;">',
+            'previous': '<img src="theme/default/images/prev.png" title="<?php echo THICKBOX_PREVIOUS; ?>" style="float:left">',
+            'close': '<img src="theme/default/images/flagno.png"title="<?php echo THICKBOX_CLOSE; ?>"><?php echo THICKBOX_CLOSE; ?>'
+        };
+
+        var tb_pathToImage = "theme/<?php echo CONFIG_THEME_NAME; ?>/images/loadingAnimation.gif";
+        var msgInvalidFolderName = '<?php echo ERR_FOLDER_FORMAT; ?>';
+        var msgInvalidFileName = '<?php echo ERR_FILE_NAME_FORMAT; ?>';
+        var msgInvalidExt = '<?php echo ERR_FILE_TYPE_NOT_ALLOWED; ?>';
+        var msgNotPreview = '<?php echo PREVIEW_NOT_PREVIEW; ?>';
+
+        var warningCutPaste = '<?php echo WARNING_CUT_PASTE; ?>';
+        var warningCopyPaste = '<?php echo WARNING_COPY_PASTE; ?>';
+        var warningDel = '<?php echo WARNING_DELETE; ?>';
+        var warningNotDocSelected = '<?php echo ERR_NOT_DOC_SELECTED; ?>';
+        //var noFileSelected = '<?php //echo ERR_NOT_FILE_SELECTED; ?>';// Chamilo
+        var noFileSelected = '<?php echo TXT_EXT_NOT_SELECTED; ?>';// Chamilo
+        var unselectAllText = '<?php echo TIP_UNSELECT_ALL; ?>';
+        var selectAllText = '<?php echo TIP_SELECT_ALL; ?>';
+        var action = '<?php echo $sessionAction->getAction(); ?>';
+        var numFiles = <?php echo $sessionAction->count(); ?>;
+        var warningCloseWindow = '<?php echo WARING_WINDOW_CLOSE; ?>';
+        var numRows = 0;
+
+        var wordCloseWindow = '<?php echo LBL_ACTION_CLOSE; ?>';
+        var wordPreviewClick = '<?php echo LBL_CLICK_PREVIEW; ?>';
+
+        var searchRequired = false;
+        var supporedPreviewExts = '<?php echo CONFIG_VIEWABLE_VALID_EXTS; ?>';
+        var supportedUploadExts = '<?php echo CONFIG_UPLOAD_VALID_EXTS; ?>'
+        var elementId = <?php  echo (!empty($_GET['elementId'])?"'" . Security::remove_XSS($_GET['elementId']) . "'":'null'); ?>;
+        var files = {};
+
+        $(document).ready(
+            function () {
+                jQuery(document).bind('keypress', function (event) {
+                    var code = event.charCode || event.keyCode;
+                    if (code && code == 13) {// if enter is pressed
+                        event.preventDefault(); //prevent browser from following the actual href
+                    }
+                    ;
+                });
+                if (typeof(cancelSelectFile) != 'undefined') {
+                    $('#linkClose').show();
+                }
+                $('input[@name=view]').each(
+                    function () {
+                        if (this.value == '<?php echo $view; ?>') {
+                            this.checked = true;
+                        } else {
+                            this.checked = false;
+                        }
+                    }
+                );
+
+                popUpCal.clearText = '<?php echo CALENDAR_CLEAR; ?>';
+                popUpCal.closeText = '<?php echo CALENDAR_CLOSE; ?>';
+                popUpCal.prevText = '<?php echo CALENDAR_PREVIOUS; ?>';
+                popUpCal.nextText = '<?php echo CALENDAR_NEXT; ?>';
+                popUpCal.currentText = '<?php echo CALENDAR_CURRENT; ?>';
+                popUpCal.buttonImageOnly = true;
+                popUpCal.dayNames = new Array('<?php echo CALENDAR_SUN; ?>', '<?php echo CALENDAR_MON; ?>', '<?php echo CALENDAR_TUE; ?>', '<?php echo CALENDAR_WED; ?>', '<?php echo CALENDAR_THU; ?>', '<?php echo CALENDAR_FRI; ?>', '<?php echo CALENDAR_SAT; ?>');
+                popUpCal.monthNames = new Array('<?php echo CALENDAR_JAN; ?>', '<?php echo CALENDAR_FEB; ?>', '<?php echo CALENDAR_MAR; ?>', '<?php echo CALENDAR_APR; ?>', '<?php echo CALENDAR_MAY; ?>', '<?php echo CALENDAR_JUN; ?>', '<?php echo CALENDAR_JUL; ?>', '<?php echo CALENDAR_AUG; ?>', '<?php echo CALENDAR_SEP; ?>', '<?php echo CALENDAR_OCT; ?>', '<?php echo CALENDAR_NOV; ?>', '<?php echo CALENDAR_DEC; ?>');
+                popUpCal.dateFormat = 'YMD-';
+                $('.inputMtime').calendar({autoPopUp: 'both', buttonImage: 'theme/<?php echo CONFIG_THEME_NAME; ?>/images/date_picker.png'});
+                initAfterListingLoaded();
+                //addMoreFile();
+            });
+    </script>
+    <?php
+    if (file_exists(
+            dirname(__FILE__)
+        ).DIRECTORY_SEPARATOR.'jscripts'.DIRECTORY_SEPARATOR.'for_'.CONFIG_EDITOR_NAME.".js"
+    ) {
+        ?>
+        <script type="text/javascript" src="jscripts/<?php echo 'for_'.CONFIG_EDITOR_NAME.'.js'; ?>"></script>
+    <?php
     }
-
-	?>
-	<!--var shared_folder_session = '<?php //echo get_lang('UserFolders').' ('.api_get_session_name($course_session).')';?>'; --><!--// problem does not refresh, does not synchronize with javascript -->
-	var shared_folder_session = '<?php echo get_lang('UserFolders').'*';?>';
-	<?php
-
-	//$userinfo=Database::get_user_info_from_id(substr(basename($folderInfo['path']), 8));	// problem with $folderInfo['path'] does not refresh, sincronisation with javascript?>
-	<!--var shared_user_folder = '<?php //echo api_get_person_name($userinfo['firstname'], $userinfo['lastname']);?>'; --><!--// problem does not refresh, does not synchronize with javascript -->
-	var shared_user_folder = '<?php echo get_lang('User');?>';
-
-	<!--end hack -->
-
-	var parentFolder = {};
-	var urls = {
-        'upload':'<?php echo CONFIG_URL_UPLOAD; ?>',
-        'preview':'<?php echo CONFIG_URL_PREVIEW; ?>',
-        'cut':'<?php echo CONFIG_URL_CUT; ?>',
-        'copy':'<?php echo CONFIG_URL_COPY; ?>',
-        'paste':'<?php echo CONFIG_URL_FILE_PASTE; ?>',
-        'delete':'<?php echo CONFIG_URL_DELETE; ?>',
-        'rename':'<?php echo CONFIG_URL_SAVE_NAME; ?>',
-        'thumbnail':'<?php echo CONFIG_URL_IMG_THUMBNAIL;  ?>',
-        'create_folder':'<?php echo CONFIG_URL_CREATE_FOLDER; ?>',
-        'text_editor':'<?php echo  CONFIG_URL_TEXT_EDITOR; ?>',
-        'image_editor':'<?php echo  CONFIG_URL_IMAGE_EDITOR; ?>',
-        'download':'<?php echo CONFIG_URL_DOWNLOAD; ?>',
-        'present':'<?php echo getCurrentUrl(); ?>',
-        'home':'<?php echo CONFIG_URL_HOME; ?>',
-        'view':'<?php echo CONFIG_URL_LIST_LISTING; ?>'
-    };
-	var permits = {	'del':<?php echo (CONFIG_OPTIONS_DELETE?1:0); ?>,
-					'cut':<?php echo (CONFIG_OPTIONS_CUT?'1':'0'); ?>,
-					'copy':<?php echo (CONFIG_OPTIONS_COPY?1:0); ?>,
-					'newfolder':<?php echo (CONFIG_OPTIONS_NEWFOLDER?1:0); ?>,
-					'rename':<?php echo (CONFIG_OPTIONS_RENAME?1:0); ?>,
-					'upload':<?php echo (CONFIG_OPTIONS_UPLOAD?1:0); ?>,
-					'edit':<?php echo (CONFIG_OPTIONS_EDITABLE?1:0); ?>,
-					'view_only':<?php echo (CONFIG_SYS_VIEW_ONLY?1:0); ?>};
-	var currentFolder = {};
-	var warningDelete = '<?php echo WARNING_DELETE; ?>';
-	var newFile = {'num':1, 'label':'<?php echo FILE_LABEL_SELECT; ?>', 'upload':'<?php echo FILE_LBL_UPLOAD; ?>'};
-	var counts = {'new_file':1};
-	var thickbox = {
-        'width':'<?php echo CONFIG_THICKBOX_MAX_WIDTH; ?>',
-        'height':'<?php echo CONFIG_THICKBOX_MAX_HEIGHT; ?>',
-        'next':'<img src="theme/default/images/next.png" title="<?php echo THICKBOX_NEXT; ?>" style="float:right;">',
-        'previous':'<img src="theme/default/images/prev.png" title="<?php echo THICKBOX_PREVIOUS; ?>" style="float:left">',
-        'close':'<img src="theme/default/images/flagno.png"title="<?php echo THICKBOX_CLOSE; ?>"><?php echo THICKBOX_CLOSE; ?>'
-	};
-
-	var tb_pathToImage = "theme/<?php echo CONFIG_THEME_NAME; ?>/images/loadingAnimation.gif";
-	var msgInvalidFolderName = '<?php echo ERR_FOLDER_FORMAT; ?>';
-	var msgInvalidFileName = '<?php echo ERR_FILE_NAME_FORMAT; ?>';
-	var msgInvalidExt = '<?php echo ERR_FILE_TYPE_NOT_ALLOWED; ?>';
-	var msgNotPreview = '<?php echo PREVIEW_NOT_PREVIEW; ?>';
-
-	var warningCutPaste = '<?php echo WARNING_CUT_PASTE; ?>';
-	var warningCopyPaste = '<?php echo WARNING_COPY_PASTE; ?>';
-	var warningDel = '<?php echo WARNING_DELETE; ?>';
-	var warningNotDocSelected = '<?php echo ERR_NOT_DOC_SELECTED; ?>';
-	//var noFileSelected = '<?php //echo ERR_NOT_FILE_SELECTED; ?>';// Chamilo
-	var noFileSelected = '<?php echo TXT_EXT_NOT_SELECTED; ?>';// Chamilo
-    var unselectAllText = '<?php echo TIP_UNSELECT_ALL; ?>';
-    var selectAllText = '<?php echo TIP_SELECT_ALL; ?>';
-	var action = '<?php echo $sessionAction->getAction(); ?>';
-	var numFiles = <?php echo $sessionAction->count(); ?>;
-	var warningCloseWindow = '<?php echo WARING_WINDOW_CLOSE; ?>';
-	var numRows = 0;
-
-	var wordCloseWindow = '<?php echo LBL_ACTION_CLOSE; ?>';
-	var wordPreviewClick = '<?php echo LBL_CLICK_PREVIEW; ?>';
-
-	var searchRequired = false;
-	var supporedPreviewExts = '<?php echo CONFIG_VIEWABLE_VALID_EXTS; ?>';
-	var supportedUploadExts = '<?php echo CONFIG_UPLOAD_VALID_EXTS; ?>'
-	var elementId = <?php  echo (!empty($_GET['elementId'])?"'" . Security::remove_XSS($_GET['elementId']) . "'":'null'); ?>;
-	var files = {};
-
-    $(document).ready(
-	function() {
-		jQuery(document).bind('keypress', function(event) {
-			var code=event.charCode || event.keyCode;
-			if(code && code == 13) {// if enter is pressed
-	  			event.preventDefault(); //prevent browser from following the actual href
-			};
-		});
-		if(typeof(cancelSelectFile) != 'undefined') {
-			$('#linkClose').show();
-		}
-		$('input[@name=view]').each(
-			function() {
-				if(this.value == '<?php echo $view; ?>') {
-					this.checked = true;
-				} else {
-					this.checked = false;
-				}
-			}
-		);
-
-		popUpCal.clearText = '<?php echo CALENDAR_CLEAR; ?>';
-		popUpCal.closeText = '<?php echo CALENDAR_CLOSE; ?>';
-		popUpCal.prevText = '<?php echo CALENDAR_PREVIOUS; ?>';
-		popUpCal.nextText = '<?php echo CALENDAR_NEXT; ?>';
-		popUpCal.currentText = '<?php echo CALENDAR_CURRENT; ?>';
-		popUpCal.buttonImageOnly = true;
-		popUpCal.dayNames = new Array('<?php echo CALENDAR_SUN; ?>','<?php echo CALENDAR_MON; ?>','<?php echo CALENDAR_TUE; ?>','<?php echo CALENDAR_WED; ?>','<?php echo CALENDAR_THU; ?>','<?php echo CALENDAR_FRI; ?>','<?php echo CALENDAR_SAT; ?>');
-		popUpCal.monthNames = new Array('<?php echo CALENDAR_JAN; ?>','<?php echo CALENDAR_FEB; ?>','<?php echo CALENDAR_MAR; ?>','<?php echo CALENDAR_APR; ?>','<?php echo CALENDAR_MAY; ?>','<?php echo CALENDAR_JUN; ?>','<?php echo CALENDAR_JUL; ?>','<?php echo CALENDAR_AUG; ?>','<?php echo CALENDAR_SEP; ?>','<?php echo CALENDAR_OCT; ?>','<?php echo CALENDAR_NOV; ?>','<?php echo CALENDAR_DEC; ?>');
-		popUpCal.dateFormat = 'YMD-';
-		$('.inputMtime').calendar({autoPopUp:'both', buttonImage:'theme/<?php echo CONFIG_THEME_NAME; ?>/images/date_picker.png'});
-		initAfterListingLoaded();
-		//addMoreFile();
-	} );
-</script>
-<?php
-	if(file_exists(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'jscripts' . DIRECTORY_SEPARATOR . 'for_' . CONFIG_EDITOR_NAME . ".js") {
-	?>
-		<script type="text/javascript" src="jscripts/<?php echo 'for_' . CONFIG_EDITOR_NAME . '.js'; ?>"></script>
-	<?php
-	}
-?>
-<link rel="stylesheet" type="text/css" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/<?php echo CONFIG_EDITOR_NAME; ?>.css" />
-<link rel="stylesheet" type="text/css" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jquery-calendar.css" />
-<link rel="stylesheet" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/thickbox.css" type="text/css" media="screen" />
-<!--[if IE 6]>
-<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ie6.css" type="text/css" rel="Stylesheet" media="screen">
-<![endif]-->
+    ?>
+    <link rel="stylesheet" type="text/css" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/<?php echo CONFIG_EDITOR_NAME; ?>.css"/>
+    <link rel="stylesheet" type="text/css" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jquery-calendar.css"/>
+    <link rel="stylesheet" href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/thickbox.css" type="text/css" media="screen"/>
+    <!--[if IE 6]>
+    <link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ie6.css" type="text/css" rel="Stylesheet" media="screen">
+    <![endif]-->
 </head>
-<body dir="<?php echo CONFIG_LANG_TEXT_DIRECTION_DEFAULT; ?>"><!-- move style to css and hack for default lang Chamilo -->
-	<div id="wrapper">
-  	<div id="header">
-  		<dl id="currentFolderInfo">
-  			<dt><?php echo LBL_CURRENT_FOLDER_PATH; ?></dt>
-  			<dt id="currentFolderPath"><?php echo $folderInfo['path']; ?></dt><!-- hack for breadcrumb for Chamilo change <dd> by <dt> -->
-  		</dl>
-        <br />
-    	<div id="viewList">
-    			<label><?php echo LBL_BTN_VIEW_OPTIONS; ?></label>
-					<?php
-						foreach($views as $k=>$v) {
-							?>
-							<input type="radio" name="view"  class="radio" onclick="return changeView(this);" value="<?php echo $k; ?>" <?php echo ($k==$view?'checked':''); ?>> <?php echo $v; ?> &nbsp;&nbsp;
-							<?php
-						}
-					?></div>
-				<ul id="actionHeader">
-					<li><a href="#" id="actionRefresh" onclick="return windowRefresh();"><span><?php echo LBL_ACTION_REFRESH; ?></span></a></li>
-					<li><a href="#" id="actionSelectAll" class="check_all" onclick="return checkAll(this);"><span><?php echo LBL_ACTION_SELECT_ALL; ?></span></a></li>
-					<?php
-						if (CONFIG_OPTIONS_DELETE) {
-							?>
-							<li><a href="#" id="actionDelete" onclick="return deleteDocuments();"><span><?php echo LBL_ACTION_DELETE; ?></span></a></li>
-							<?php
-						}
-					?>
-					<?php
-						if(CONFIG_OPTIONS_CUT)
-						{
-							?>
-							<li><a href="#" id="actionCut" onclick="return cutDocuments('<?php echo ERR_NOT_DOC_SELECTED_FOR_CUT; ?>');"><span><?php echo LBL_ACTION_CUT; ?></span></a></li>
-							<?php
-						}
-					?>
-					<?php
-						if(CONFIG_OPTIONS_COPY)
-						{
-							?>
-							<li><a href="#" id="actionCopy" onclick="return copyDocuments('<?php echo ERR_NOT_DOC_SELECTED_FOR_COPY; ?>');"><span><?php echo LBL_ACTION_COPY; ?></span></a></li>
-							<?php
-						}
-					?>
-					<?php
-						if(CONFIG_OPTIONS_CUT || CONFIG_OPTIONS_COPY)
-						{
-							?>
-							<li><a href="#" id="actionPaste" onclick="return pasteDocuments('<?php echo ERR_NOT_DOC_SELECTED_FOR_PASTE; ?>');"><span><?php echo LBL_ACTION_PASTE; ?></span></a></li>
-							<?php
-						}
-					?>
-
-					<?php
-						if(CONFIG_OPTIONS_NEWFOLDER)
-						{
-							?>
-							<li><a  id="actionNewFolder" href="#" onclick="return newFolderWin(this);"><span><?php echo LBL_BTN_NEW_FOLDER; ?></span></a></li>
-							<?php
-						}
-					?>
-					<?php
-						if(CONFIG_OPTIONS_UPLOAD)
-						{
-							?>
-							<li><a  id="actionUpload" href="#" onclick="return uploadFileWin(this);"><span><?php echo LBL_BTN_UPLOAD; ?></span></a></li>
-							<?php
-						}
-					?>
-
-<!--					<li><a href="#" id="actionClose" onclick="closeWindow('<?php echo IMG_WARING_WIN_CLOSE; ?>');"><?php echo IMG_BTN_CLOSE; ?></a></li>-->
-					<!--<li><a href="#" class="thickbox" id="actionInfo" onclick="return infoWin(this);"><span>Info</span></a></li> -->
-					<!-- thest functions will be added in the near future
- 					<li ><a href="#" id="actionZip"><span>Zip</span></a><li>
-					<li ><a href="#" id="actionUnzip"><span>Unzip</span></a><li>-->
-				</ul>
-<form action="" method="post" name="formAction" id="formAction">
-	<input type="hidden" name="currentFolderPath" id="currentFolderPathVal" value="" />
-	<select name="selectedDoc[]" id="selectedDoc" style="display:none;" multiple="multiple"></select>
-	<input type="hidden" name="action_value" value="" id="action_value" />
-</form>
+<body dir="<?php echo CONFIG_LANG_TEXT_DIRECTION_DEFAULT; ?>">
+<!-- move style to css and hack for default lang Chamilo -->
+<div id="wrapper">
+<div id="header">
+    <dl id="currentFolderInfo">
+        <dt><?php echo LBL_CURRENT_FOLDER_PATH; ?></dt>
+        <dt id="currentFolderPath"><?php echo $folderInfo['path']; ?></dt>
+        <!-- hack for breadcrumb for Chamilo change <dd> by <dt> -->
+    </dl>
+    <br/>
+    <div id="viewList">
+        <label><?php echo LBL_BTN_VIEW_OPTIONS; ?></label>
+        <?php
+        foreach ($views as $k => $v) {
+            ?>
+            <input type="radio" name="view" class="radio" onclick="return changeView(this);"
+                   value="<?php echo $k; ?>" <?php echo($k == $view ? 'checked' : ''); ?>> <?php echo $v; ?> &nbsp;&nbsp;
+        <?php
+        }
+        ?>
+    </div>
+    <ul id="actionHeader">
+        <li><a href="#" id="actionRefresh"
+               onclick="return windowRefresh();"><span><?php echo LBL_ACTION_REFRESH; ?></span></a></li>
+        <li><a href="#" id="actionSelectAll" class="check_all"
+               onclick="return checkAll(this);"><span><?php echo LBL_ACTION_SELECT_ALL; ?></span></a></li>
+        <?php
+        if (CONFIG_OPTIONS_DELETE) {
+            ?>
+            <li><a href="#" id="actionDelete"
+                   onclick="return deleteDocuments();"><span><?php echo LBL_ACTION_DELETE; ?></span></a></li>
+        <?php
+        }
+        ?>
+        <?php
+        if (CONFIG_OPTIONS_CUT) {
+            ?>
+            <li><a href="#" id="actionCut"
+                   onclick="return cutDocuments('<?php echo ERR_NOT_DOC_SELECTED_FOR_CUT; ?>');"><span><?php echo LBL_ACTION_CUT; ?></span></a>
+            </li>
+        <?php
+        }
+        ?>
+        <?php
+        if (CONFIG_OPTIONS_COPY) {
+            ?>
+            <li><a href="#" id="actionCopy"
+                   onclick="return copyDocuments('<?php echo ERR_NOT_DOC_SELECTED_FOR_COPY; ?>');"><span><?php echo LBL_ACTION_COPY; ?></span></a>
+            </li>
+        <?php
+        }
+        ?>
+        <?php
+        if (CONFIG_OPTIONS_CUT || CONFIG_OPTIONS_COPY) {
+            ?>
+            <li><a href="#" id="actionPaste"
+                   onclick="return pasteDocuments('<?php echo ERR_NOT_DOC_SELECTED_FOR_PASTE; ?>');"><span><?php echo LBL_ACTION_PASTE; ?></span></a>
+            </li>
+        <?php
+        }
+        if (CONFIG_OPTIONS_NEWFOLDER) {
+            ?>
+            <li><a id="actionNewFolder" href="#"
+                   onclick="return newFolderWin(this);"><span><?php echo LBL_BTN_NEW_FOLDER; ?></span></a></li>
+        <?php
+        }
+        if (CONFIG_OPTIONS_UPLOAD) {
+            ?>
+            <li><a id="actionUpload" href="#"
+                   onclick="return uploadFileWin(this);"><span><?php echo LBL_BTN_UPLOAD; ?></span></a></li>
+        <?php
+        }
+        ?>
+    </ul>
+    <form action="" method="post" name="formAction" id="formAction">
+        <input type="hidden" name="currentFolderPath" id="currentFolderPathVal" value=""/>
+        <select name="selectedDoc[]" id="selectedDoc" style="display:none;" multiple="multiple"></select>
+        <input type="hidden" name="action_value" value="" id="action_value"/>
+    </form>
+</div>
+<div id="body">
+<div id="rightCol">
+    <?php
+    if (CONFIG_LOAD_DOC_LATTER) {
+        $currentPath = getCurrentFolderPath();
+        ?>
+        <script type="text/javascript">
+            parentFolder = {'path_base64': '<?php echo base64_encode(getParentFolderPath($currentPath)); ?>', 'path': '<?php echo getParentFolderPath($currentPath); ?>'};
+            currentFolder = {'friendly_path': '<?php echo transformFilePath($currentPath); ?>'};
+            $(document).ready(
+                function () {
+                    var url = getUrl('view', false, false, false);
+                    $('#rightCol').empty();
+                    ajaxStart('#rightCol');
+
+                    $('#rightCol').load(url,
+                        {},
+                        function () {
+                            ajaxStop('#rightCol img.ajaxLoadingImg');
+                            urls.present = getUrl('home', true, true);
+                            initAfterListingLoaded();
+                        });
+                }
+            );
+        </script>
+    <?php
+    } else {
+        include_once CONFIG_URL_LIST_LISTING;
+    }
+    ?>
 </div>
-    <div id="body">
-      <div id="rightCol">
-	      	<?php
-			if(CONFIG_LOAD_DOC_LATTER ) {
-				$currentPath = getCurrentFolderPath();
-				?>
-
-				<script type="text/javascript">
-				parentFolder = {'path_base64':'<?php echo base64_encode(getParentFolderPath($currentPath)); ?>', 'path':'<?php echo getParentFolderPath($currentPath); ?>'};
-
-				currentFolder = {'friendly_path':'<?php echo transformFilePath($currentPath); ?>'};
-					$(document).ready(
-						function()
-						{
-							var url = getUrl('view', false, false, false);
-							$('#rightCol').empty();
-							ajaxStart('#rightCol');
-
-							$('#rightCol').load(url,
-										{},
-										function(){
-												ajaxStop('#rightCol img.ajaxLoadingImg');
-												urls.present = getUrl('home', true, true);
-												initAfterListingLoaded();
-											});
-						}
-					);
-				</script>
-				<?php
-			} else {
-				include_once CONFIG_URL_LIST_LISTING;
-			}
-	      	?>
-      </div>
-
-      <div id="leftCol">
-				<fieldset id="folderFieldSet" >
-
-				<legend><?php echo LBL_FOLDER_INFO; ?></legend>
-				<table cellpadding="0" cellspacing="0" class="tableSummary" id="folderInfo">
-					<tbody>
-						<tr>
-							<th><?php echo LBL_FOLDER_PATH; ?></th>
-							<td colspan="3" id="folderPath"><?php echo transformFilePath($folderInfo['path']); ?></td>
-  						</tr>
-						<tr>
-							<th><?php echo LBL_FOLDER_CREATED; ?></th>
-							<td colspan="3" id="folderCtime"><?php echo (!empty($folderInfo['ctime'])?date(DATE_TIME_FORMAT,$folderInfo['ctime']):'&nbsp;') ; ?></td>
-
-						</tr>
-						<tr>
-							<th><?php echo LBL_FOLDER_MODIFIED; ?></th>
-							 <!-- comment these lines while integrating into Chamilo -->
-							<th><?php //echo LBL_FOLDER_MODIFIED; ?></th>
-						<!--	<td colspan="3" id="folderMtime"><?php //echo (!empty($folderInfo['mtime'])?date(DATE_TIME_FORMAT,$folderInfo['mtime']):'&nbsp;'); ?></td> -->
-						</tr>
-						<tr>
-							<th><?php echo LBL_FOLDER_SUDDIR; ?></th>
-							<td  colspan="3" id="folderSubdir"><?php echo (isset($folderInfo['subdir'])?$folderInfo['subdir']:"&nbsp;"); ?></td>
-
-						</tr>
-						<tr>
-							<th><?php echo LBL_FOLDER_FIELS; ?></th>
-							<td  colspan="3" id="folderFile"><?php echo (isset($folderInfo['file'])?$folderInfo['file']:'&nbsp;'); ?></td>
-						</tr>
-
-						<tr>
-							 <!-- comment these lines while integrating into Chamilo -->
-							<th><?php // echo LBL_FOLDER_WRITABLE; ?></th>
-						<!--	<td id="folderWritable"><span class="<?php //echo (isset($folderInfo['is_readable'])?($folderInfo['is_readable']?'flagYes':'flagNo'):'&nbsp;'); ?>">&nbsp;</span></td> -->
-							<th><?php // echo LBL_FOLDER_READABLE; ?></th>
-							<!--<td  id="folderReadable"><span class="<?php //echo (isset($folderInfo['is_writable'])?($folderInfo['is_writable']?'flagYes':'flagNo'):'&nbsp;'); ?>">&nbsp;</span></td> -->
-						</tr>
-					</tbody>
-				</table>
-				</fieldset>
-			<fieldset id="fileFieldSet" style="display:none" >
-				<legend><?php echo LBL_FILE_INFO; ?></legend>
-				<table cellpadding="0" cellspacing="0" class="tableSummary" id="fileInfo">
-					<tbody>
-						<tr>
-							<th><?php echo LBL_FILE_NAME; ?></th>
-							<td colspan="3" id="fileName"></td>
-						</tr>
-						<tr>
-							<th><?php echo LBL_FILE_CREATED; ?></th>
-							<td colspan="3" id="fileCtime"></td>
-
-						</tr>
-						<tr>
-							 <!-- comment these lines while integrating into Chamilo -->
-							<th><?php //echo LBL_FILE_MODIFIED; ?></th>
-							<!--<td colspan="3" id="fileMtime"></td> -->
-						</tr>
-
-						<tr>
-							<th><?php echo LBL_FILE_SIZE; ?></th>
-							<td  colspan="3" id="fileSize"></td>
-
-						</tr>
-						<tr>
-							<th><?php echo LBL_FILE_TYPE; ?></th>
-							<td  colspan="3" id="fileType"></td>
-						</tr>
-						<tr>
-							 <!-- comment these lines while integrating into Chamilo -->
-							<th><?php //echo LBL_FILE_WRITABLE; ?></th>
-							<!--<td id="fileWritable"><span class="flagYes">&nbsp;</span></td> -->
-							<th><?php //echo LBL_FILE_READABLE; ?></th>
-							<!--<td id="fileReadable"><span class="flagNo">&nbsp;</span></td> -->
-						</tr>
 
-					</tbody>
-				</table>
+<div id="leftCol">
+    <fieldset id="folderFieldSet">
+
+        <legend><?php echo LBL_FOLDER_INFO; ?></legend>
+        <table cellpadding="0" cellspacing="0" class="tableSummary" id="folderInfo">
+            <tbody>
+            <tr>
+                <th><?php echo LBL_FOLDER_PATH; ?></th>
+                <td colspan="3" id="folderPath"><?php echo transformFilePath($folderInfo['path']); ?></td>
+            </tr>
+            <tr>
+                <th><?php echo LBL_FOLDER_CREATED; ?></th>
+                <td colspan="3" id="folderCtime">
+                    <?php echo(!empty($folderInfo['ctime']) ? date(
+                        DATE_TIME_FORMAT,
+                        $folderInfo['ctime']
+                    ) : '&nbsp;'); ?>
+                </td>
+            </tr>
+            <tr>
+                <th><?php echo LBL_FOLDER_MODIFIED; ?></th>
+                <!-- comment these lines while integrating into Chamilo -->
+                <th><?php //echo LBL_FOLDER_MODIFIED; ?></th>
+            </tr>
+            <tr>
+                <th><?php echo LBL_FOLDER_SUDDIR; ?></th>
+                <td colspan="3" id="folderSubdir">
+                    <?php echo(isset($folderInfo['subdir']) ? $folderInfo['subdir'] : "&nbsp;"); ?>
+                </td>
+            </tr>
+            <tr>
+                <th><?php echo LBL_FOLDER_FIELS; ?></th>
+                <td colspan="3" id="folderFile">
+                    <?php echo(isset($folderInfo['file']) ? $folderInfo['file'] : '&nbsp;'); ?>
+                </td>
+            </tr>
+            <tr>
+                <!-- comment these lines while integrating into Chamilo -->
+                <th><?php // echo LBL_FOLDER_WRITABLE; ?></th>
+                <th><?php // echo LBL_FOLDER_READABLE; ?></th>
+            </tr>
+            </tbody>
+        </table>
+    </fieldset>
+    <fieldset id="fileFieldSet" style="display:none">
+        <legend><?php echo LBL_FILE_INFO; ?></legend>
+        <table cellpadding="0" cellspacing="0" class="tableSummary" id="fileInfo">
+            <tbody>
+            <tr>
+                <th><?php echo LBL_FILE_NAME; ?></th>
+                <td colspan="3" id="fileName"></td>
+            </tr>
+            <tr>
+                <th><?php echo LBL_FILE_CREATED; ?></th>
+                <td colspan="3" id="fileCtime"></td>
+            </tr>
+            <tr>
+                <!-- comment these lines while integrating into Chamilo -->
+                <th><?php //echo LBL_FILE_MODIFIED; ?></th>
+                <!--<td colspan="3" id="fileMtime"></td> -->
+            </tr>
+            <tr>
+                <th><?php echo LBL_FILE_SIZE; ?></th>
+                <td colspan="3" id="fileSize"></td>
+            </tr>
+            <tr>
+                <th><?php echo LBL_FILE_TYPE; ?></th>
+                <td colspan="3" id="fileType"></td>
+            </tr>
+            <tr>
+                <!-- comment these lines while integrating into Chamilo -->
+                <th><?php //echo LBL_FILE_WRITABLE; ?></th>
+                <!--<td id="fileWritable"><span class="flagYes">&nbsp;</span></td> -->
+                <th><?php //echo LBL_FILE_READABLE; ?></th>
+                <!--<td id="fileReadable"><span class="flagNo">&nbsp;</span></td> -->
+            </tr>
+            </tbody>
+        </table>
 
         <p class="searchButtons" id="returnCurrentUrl">
         	<span class="right" id="linkSelect">
@@ -424,89 +418,83 @@ if(!empty($_GET['view'])) {
         		<!-- Change button class by Chamilo select_button class -->
         	</span>
         </p>
-		</fieldset>
-
-
-      	<fieldset class="boxSearch">
-      		<legend><?php echo LBL_SEARCH; ?></legend>
-          <table cellpadding="0" cellspacing="0" class="tableSearch">
-          	<tbody>
-	          <tr>
-	          	<td>
-	          		<!-- comment these lines while integrating into Chamilo -->
-	          		<b><?php //echo LBL_SEARCH_NAME; ?></b> <br />
-	            	<input type="text" class="input inputSearch" name="search_name" id="search_name" size="18"/>
-	          	</td>
-
-	         </tr>
-	          <tr>
-	          	<td >
-	          	 <!-- comment these lines while integrating into Chamilo -->
-	          	<b><?php // echo LBL_SEARCH_FOLDER; ?></b><br />
+    </fieldset>
+
+    <fieldset class="boxSearch">
+        <legend><?php echo LBL_SEARCH; ?></legend>
+        <table cellpadding="0" cellspacing="0" class="tableSearch">
+            <tbody>
+            <tr>
+                <td>
+                    <!-- comment these lines while integrating into Chamilo -->
+                    <b><?php //echo LBL_SEARCH_NAME; ?></b> <br/>
+                    <input type="text" class="input inputSearch" name="search_name" id="search_name" size="18"/>
+                </td>
+            </tr>
+            <tr>
+                <td>
+                    <!-- comment these lines while integrating into Chamilo -->
+                    <b><?php // echo LBL_SEARCH_FOLDER; ?></b><br/>
 	          	<span id="searchFolderContainer">
 	          	<?php
-	          		if(CONFIG_LOAD_DOC_LATTER)
-	          		{
-	          			?>
-	          			<script type="text/javascript">
-	          				$(document).ready(
-	          					function()
-	          					{
-	          						ajaxStart('#searchFolderContainer');
-	          						$('#searchFolderContainer').load('<?php echo CONFIG_URL_LOAD_FOLDERS; ?>');
-	          					}
-	          				);
-	          			</script>
-	          			<?php
-	          		}else
-	          		{
-	          	?>
-
-		            <select class="input inputSearchSelect" name="search_folder" id="search_folder"><!-- Chamilo integrating, modify name class for disable by css -->
-		            	<?php
-
-										foreach(getFolderListing(CONFIG_SYS_ROOT_PATH) as $k=>$v)
-										{
-											if(hideFolderName($k))
-											{
-												//show only those permitted by Chamilo
-												?>
-		                  						<option value="<?php echo $v; ?>" <?php echo (removeTrailingSlash(backslashToSlash(($folderInfo['path']))) == removeTrailingSlash(backslashToSlash(($v)))?' selected="selected"':''); ?>><?php echo hideFolderName(shortenFileName($k, 30));
-												?></option>
-
-		                  <?php
-											}
-										}
-
-									?>
-		            </select>
-		      <?php
-	          		}
-		      ?></span>
-	        <!--  </td>
-	         </tr>
-        		<tr>
-        			<td> -->
-        		<b><?php //echo LBL_SEARCH_MTIME; ?></b><br />
-        		<!--<input type="text" class="input inputMtime" name="search_mtime_from" id="search_mtime_from" value="<?php //echo (!empty($_GET['search_mtime_from'])?$_GET['search_mtime_from']:''); ?>" />  -->
-        		<!--<span class="leftToRightArrow">&nbsp;</span> -->
-        		<!--<input type="text" class="input inputMtime" name="search_mtime_to" id="search_mtime_to" value="<?php //echo (!empty($_GET['search_mtime_to'])?$_GET['search_mtime_to']:''); ?>" /> -->
-                 <!--This lines replace above lines while integrating into Chamilo -->
-                <input type="hidden" name="search_mtime_from" id="search_mtime_from" value="<?php //echo (!empty($_GET['search_mtime_from'])?$_GET['search_mtime_from']:''); ?>" />
-        		<input type="hidden" name="search_mtime_to" id="search_mtime_to" value="<?php //echo (!empty($_GET['search_mtime_to'])?$_GET['search_mtime_to']:''); ?>" />
-        	<!--</td></tr>
-			<tr>
-				<td>  --><!-- comment these lines while integrating into Chamilo -->
-                </td><td><!--add a col while integrating -->
-          	<b><?php  // echo LBL_SEARCH_RECURSIVELY; ?></b>&nbsp;&nbsp;
-		<!--change for Chamilo recursively by default  -->
-     <!--     	<input type="radio" name="search_recursively" value="1" id="search_recursively_1" class="radio" <?php //echo (empty($_GET['search_recursively'])?'checked="checked"':''); ?> /> <?php //echo LBL_RECURSIVELY_YES; ?> -->
-        <!--  	<input type="radio" name="search_recursively" value="0" id="search_recursively_0" class="radio" <?php //echo (!empty($_GET['search_recursively'])?'checked="checked"':''); ?> /> <?php //echo LBL_RECURSIVELY_NO; ?> -->
-          	</td>
-
-          </tr>
-          	</tbody>
-</table>
+                if (CONFIG_LOAD_DOC_LATTER) {
+                    ?>
+                    <script type="text/javascript">
+                        $(document).ready(
+                            function () {
+                                ajaxStart('#searchFolderContainer');
+                                $('#searchFolderContainer').load('<?php echo CONFIG_URL_LOAD_FOLDERS; ?>');
+                            }
+                        );
+                    </script>
+                <?php
+                } else {
+                    ?>
+
+                    <select class="input inputSearchSelect" name="search_folder" id="search_folder">
+                        <!-- Chamilo integrating, modify name class for disable by css -->
+                        <?php
+                        foreach (getFolderListing(CONFIG_SYS_ROOT_PATH) as $k => $v) {
+                            if (hideFolderName($k)) {
+                                //show only those permitted by Chamilo
+                                ?>
+                                <option value="<?php echo $v; ?>" <?php echo(removeTrailingSlash(
+                                    backslashToSlash(($folderInfo['path']))
+                                ) == removeTrailingSlash(
+                                    backslashToSlash(($v))
+                                ) ? ' selected="selected"' : ''); ?>><?php echo hideFolderName(shortenFileName($k, 30));
+                                    ?>
+                                </option>
+                            <?php
+                            }
+                        }
+                        ?>
+                    </select>
+                <?php
+                }
+                ?></span>
+                    <b><?php //echo LBL_SEARCH_MTIME; ?></b><br/>
+                    <!--<input type="text" class="input inputMtime" name="search_mtime_from" id="search_mtime_from" value="<?php //echo (!empty($_GET['search_mtime_from'])?$_GET['search_mtime_from']:''); ?>" />  -->
+                    <!--<span class="leftToRightArrow">&nbsp;</span> -->
+                    <!--<input type="text" class="input inputMtime" name="search_mtime_to" id="search_mtime_to" value="<?php //echo (!empty($_GET['search_mtime_to'])?$_GET['search_mtime_to']:''); ?>" /> -->
+                    <!--This lines replace above lines while integrating into Chamilo -->
+                    <input type="hidden" name="search_mtime_from" id="search_mtime_from"
+                           value="<?php //echo (!empty($_GET['search_mtime_from'])?$_GET['search_mtime_from']:''); ?>"/>
+                    <input type="hidden" name="search_mtime_to" id="search_mtime_to"
+                           value="<?php //echo (!empty($_GET['search_mtime_to'])?$_GET['search_mtime_to']:''); ?>"/>
+                    <!--</td></tr>
+                    <tr>
+                        <td>  --><!-- comment these lines while integrating into Chamilo -->
+                </td>
+                <td><!--add a col while integrating -->
+                    <b><?php // echo LBL_SEARCH_RECURSIVELY; ?></b>&nbsp;&nbsp;
+                    <!--change for Chamilo recursively by default  -->
+                    <!--     	<input type="radio" name="search_recursively" value="1" id="search_recursively_1" class="radio" <?php //echo (empty($_GET['search_recursively'])?'checked="checked"':''); ?> /> <?php //echo LBL_RECURSIVELY_YES; ?> -->
+                    <!--  	<input type="radio" name="search_recursively" value="0" id="search_recursively_0" class="radio" <?php //echo (!empty($_GET['search_recursively'])?'checked="checked"':''); ?> /> <?php //echo LBL_RECURSIVELY_NO; ?> -->
+                </td>
+            </tr>
+            </tbody>
+        </table>
         <p class="searchButtons">
         	<span class="left" id="linkClose" style="display:none">
                   <!-- comment these lines while integrating into Chamilo -->
@@ -516,204 +504,217 @@ if(!empty($_GET['view'])) {
         		<input type="button" value="<?php echo BTN_SEARCH; ?>" onclick="return search();" class="search_button">
         	</span>
         </p>
-        </fieldset>
-      </div>
-      <div class="clear"></div>
+    </fieldset>
+</div>
+<div class="clear"></div>
+</div>
+</div>
+<div class="clear"></div>
+<div id="ajaxLoading" style="display:none">
+    <img class="ajaxLoadingImg" src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/ajaxLoading.gif"/></div>
+<div id="winUpload" style="display:none">
+    <div class="jqmContainer">
+        <div class="jqmHeader">
+            <!-- Adding return windowRefresch() for Chamilo -->
+            <a href="#" onclick="tb_remove();return windowRefresh();">
+                <img src="theme/default/images/flagno.png" title="<?php echo LBL_ACTION_CLOSE; ?>">
+                <?php echo LBL_ACTION_CLOSE; ?>
+            </a>
+            <!-- Add close image for Chamilo -->
+        </div>
+        <div class="jqmBody">
+            <form id="formUpload" name="formUpload" method="post" enctype="multipart/form-data" action="">
+                <table class="tableForm" cellpadding="0" cellspacing="0">
+                    <thead>
+                    <tr>
+                        <th colspan="2">
+                            <?php echo FILE_FORM_TITLE; ?>
+                        </th>
+                    </tr>
+                    <tr>
+                        <th colspan="2" align="left">
+                            <label>
+                                <a class="action" href="#" title="<?php echo FILE_LBL_MORE; ?>"
+                                   onclick="return addMoreFile();">
+                                    <label><?php echo FILE_LBL_MORE; ?></label><span class="addMore">&nbsp;</span></a>
+                            </label>
+                        </th>
+                    </tr>
+                    </thead>
+                    <tbody id="fileUploadBody">
+                    <tr style="display:none">
+                        <th><label><?php echo FILE_LABEL_SELECT; ?></label></th>
+                        <td>
+                            <input type="file" class="input" name="file"/>
+                            <input type="button" class="upload_button" value="<?php echo FILE_LBL_UPLOAD; ?>"/><!-- change style of upload button by Chamilo -->
+                            <a href="#" class="action" title="<?php echo get_lang('Cancel') ?>" style="display:none">
+                                <!-- Chamilo lang var added -->
+                                <span class="cancel">&nbsp;</span><span class="uploadProcessing" style="display:none">&nbsp;</span>
+                            </a>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </form>
+        </div>
     </div>
-  </div>
-  <div class="clear"></div>
-  <div id="ajaxLoading" style="display:none">
-  	<img class="ajaxLoadingImg" src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/ajaxLoading.gif" /></div>
-  <div id="winUpload" style="display:none">
-  	<div class="jqmContainer">
-  		<div class="jqmHeader">
-        	<!-- Adding return windowRefresch() for Chamilo -->
-  			<a href="#" onclick="tb_remove();return windowRefresh();">
-  				<img src="theme/default/images/flagno.png"title="<?php echo LBL_ACTION_CLOSE; ?>">
-  				<?php echo LBL_ACTION_CLOSE; ?>
-  			</a>
-  			<!-- Add close image for Chamilo -->
-  		</div>
-  		<div class="jqmBody">
-		  	<form id="formUpload" name="formUpload" method="post" enctype="multipart/form-data" action="">
-		  	<table class="tableForm" cellpadding="0" cellspacing="0">
-		  		<thead>
-		  			<tr>
-		  				<th colspan="2">
-		  					<?php echo FILE_FORM_TITLE; ?>
-		  				</th>
-		  			</tr>
-		  			<tr>
-		  			<th colspan="2" align="left">
-		  				<label>
-		  				<a class="action" href="#" title="<?php echo FILE_LBL_MORE;  ?>" onclick="return addMoreFile();">
-			  				<label><?php echo FILE_LBL_MORE;  ?></label><span class="addMore">&nbsp;</span></a>
-			  			</label>
-
-		  			</th>
-
-		  			</tr>
-		  		</thead>
-		  		<tbody id="fileUploadBody">
-		  			<tr style="display:none">
-		  				<th><label><?php echo FILE_LABEL_SELECT; ?></label></th>
-		  				<td>
-		  					<input type="file" class="input" name="file"  />
-		  					<input type="button" class="upload_button" value="<?php echo FILE_LBL_UPLOAD; ?>" /><!-- change style of upload button by Chamilo -->
-		  					<a href="#" class="action" title="<?php echo get_lang('Cancel')?>" style="display:none" ><!-- Chamilo lang var added -->
-		  						<span class="cancel">&nbsp;</span><span class="uploadProcessing" style="display:none">&nbsp;</span>
-		  					</a>
-
-		  				</td>
-		  			</tr>
-		  		</tbody>
-		  	</table>
-		  	</form>
-  		</div>
-  	</div>
-  </div>
-  <div id="winNewFolder" style="display:none">
-  	<div class="jqmContainer">
-  		<div class="jqmHeader">
-  			<a href="#" onclick="return tb_remove();"><img src="theme/default/images/flagno.png"title="<?php echo LBL_ACTION_CLOSE; ?>"><?php echo LBL_ACTION_CLOSE; ?></a><!-- Add close image for Chamilo -->
-  		</div>
-  		<div class="jqmBody">
-	    	<form id="formNewFolder" name="formNewFolder" method="post" action="">
-	  	<input type="hidden" name="currentFolderPath" value="" id="currentNewfolderPath" />
-	  	<table class="tableForm" cellpadding="0" cellspacing="0">
-	  		<thead>
-	  			<tr>
-	  				<th colspan="2"><?php echo FOLDER_FORM_TITLE; ?></th>
-	  			</tr>
-	  		</thead>
-	  		<tbody>
-	  			<tr>
-	  				<th><label><?php echo FOLDER_LBL_TITLE; ?></label></th>
-	  				<td><input type="text" name="new_folder" id="new_folder" value="" class="input"></td>
-	  			</tr>
-	  		</tbody>
-	  		<tfoot>
-	  			<tr>
-	  				<th>&nbsp;</th>
-	  				<td><input type="button" value="<?php echo FOLDER_LBL_CREATE; ?>" class="create_button" onclick="return doCreateFolder();"  /></td>
-	  			</tr>
-	  		</tfoot>
-	  	</table>
-	  	</form>
-  		</div>
-  	</div>
-  </div>
-  <div id="winPlay" style="display:none">
-  	<div class="jqmContainer">
-  		<div class="jqmHeader">
-  			<a href="#" onclick="return closeWinPlay();"><img src="theme/default/images/flagno.png"title="<?php echo LBL_ACTION_CLOSE; ?>"><?php echo LBL_ACTION_CLOSE; ?></a><!-- Add close image for Chamilo -->
-  		</div>
-  		<div class="jqmBody">
-  			<div id="playGround"></div>
-  		</div>
-  	</div>
-  </div>
-  <div id="winRename" style="display:none">
-  	<div class="jqmContainer">
-  		<div class="jqmHeader">
-            <a href="#" onclick="return tb_remove();"><img src="theme/default/images/flagno.png"title="<?php echo LBL_ACTION_CLOSE; ?>"><?php echo LBL_ACTION_CLOSE; ?></a><!-- Add close image for Chamilo -->
-  		</div>
-  		<div class="jqmBody">
-		  	<form id="formRename" name="formRename" method="post" action="">
-		  	<input type="hidden" name="original_path" id="original_path" />
-		  	<input type="hidden" name="num" id="renameNum" value="" />
-		  	<table class="tableForm" cellpadding="0" cellspacing="0">
-		  		<thead>
-		  			<tr>
-		  				<th colspan="2"><?php echo RENAME_FORM_TITLE; ?></th>
-		  			</tr>
-		  		</thead>
-		  		<tbody>
-		  			<tr>
-		  				<th><label><?php echo RENAME_NEW_NAME; ?></label></th>
-		  				<td><input type="name" id="renameName" class="input" name="name" /> <!--  Chamilo delete style="width:250px"-->
-		          </td>
-		  			</tr>
-		  		</tbody>
-		  		<tfoot>
-		  			<tr>
-		  				<th>&nbsp;</th>
-		  				<td><input type="button" value="<?php echo RENAME_LBL_RENAME; ?>" class="create_button" onclick="return doRename();"  /></td>
-		  			</tr>
-		  		</tfoot>
-		  	</table>
-		  	</form>
-  		</div>
-
-  	</div>
-
-  </div>
-  <div id="winInfo" style="display:none">
-  	<div class="jqmContainer">
-  		<div class="jqmHeader">
-  			<a href="#" onclick="tb_remove();"><?php echo LBL_ACTION_CLOSE; ?></a>
-  		</div>
-  		<div class="jqmBody">
-   	<table class="tableInfo" cellpadding="0" cellspacing="0">
-  		<tbody>
-  			<tr>
-	  			<th nowrap>
-	  				<label>Author:</label>
-	  			</th>
-	  			<td>
-	  				<a href="&#109;a&#105;l&#116;&#111;:&#99;&#97;&#105;&#108;&#111;&#110;&#103;&#113;&#117;&#110;&#64;&#121;&#97;&#104;&#111;&#111;&#46;&#99;&#111;&#109;&#46;&#99;&#110;">Logan Cai</a>
-	  			</td>
-  			</tr>
-  			<tr>
-  				<th nowrap>
-  					<label>Template Designer:</label>
-  				</th>
-  				<td>
-  					<a href="&#109;a&#105;l&#116;&#111;:&#71;&#97;&#98;&#114;&#105;&#101;&#108;&#64;&#52;&#118;&#46;&#99;&#111;&#109;&#46;&#98;&#114;">Gabriel</a>
-  				</td>
-  			</tr>
-  			<tr>
-  				<th  nowrap>
-  					<label>Official Website:</label>
-  				</th>
-  				<td>
-  					<a href="http://www.phpletter.com">http://www.phpletter.com</a>
-  				</td>
-  			</tr>
-  			<tr>
-  				<th  nowrap>
-  					<label>Support Forum:</label>
-  				</th>
-  				<td>
-  					<a href="http://www.phpletter.com/forum/">http://www.phpletter.com/forum/</a>
-  				</td>
-  			</tr>
-  			<tr>
-  				<th nowrap>
-  					<label>&copy;Copyright:</label>
-  				</th>
-  				<td>
-  					All copyright declarations in the source must remain unchange. Please contact us if you need to make changes to it, in order to avoid any Legal Issues.
-  				</td>
-  			</tr>
-  		</tbody>
-  	</table>
-  		</div>
-  	</div>
-  </div>
-  <div id="contextMenu" style="display:none">
-  	<ul>
-  		<li><a href="#" class="contentMenuItem"  id="menuSelect"><?php echo MENU_SELECT; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuPreview"><?php echo MENU_PREVIEW; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuDownload"><?php echo MENU_DOWNLOAD; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuRename"><?php echo MENU_RENAME; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuEdit"><?php echo MENU_EDIT; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuCut"><?php echo MENU_CUT; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuCopy"><?php echo MENU_COPY; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuPaste"><?php echo MENU_PASTE; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuDelete"><?php echo MENU_DELETE; ?></a></li>
-  		<li><a href="#" class="contentMenuItem"  id="menuPlay"><?php echo MENU_PLAY; ?></a></li>
-  	</ul>
-  </div>
+</div>
+<div id="winNewFolder" style="display:none">
+    <div class="jqmContainer">
+        <div class="jqmHeader">
+            <a href="#" onclick="return tb_remove();">
+                <img src="theme/default/images/flagno.png" title="<?php echo LBL_ACTION_CLOSE; ?>"><?php echo LBL_ACTION_CLOSE; ?>
+            </a><!-- Add close image for Chamilo -->
+        </div>
+        <div class="jqmBody">
+            <form id="formNewFolder" name="formNewFolder" method="post" action="">
+                <input type="hidden" name="currentFolderPath" value="" id="currentNewfolderPath"/>
+                <table class="tableForm" cellpadding="0" cellspacing="0">
+                    <thead>
+                    <tr>
+                        <th colspan="2"><?php echo FOLDER_FORM_TITLE; ?></th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr>
+                        <th><label><?php echo FOLDER_LBL_TITLE; ?></label></th>
+                        <td><input type="text" name="new_folder" id="new_folder" value="" class="input"></td>
+                    </tr>
+                    </tbody>
+                    <tfoot>
+                    <tr>
+                        <th>&nbsp;</th>
+                        <td>
+                            <input type="button" value="<?php echo FOLDER_LBL_CREATE; ?>" class="create_button"
+                                   onclick="return doCreateFolder();"/>
+                        </td>
+                    </tr>
+                    </tfoot>
+                </table>
+            </form>
+        </div>
+    </div>
+</div>
+<div id="winPlay" style="display:none">
+    <div class="jqmContainer">
+        <div class="jqmHeader">
+            <a href="#" onclick="return closeWinPlay();">
+                <img src="theme/default/images/flagno.png" title="<?php echo LBL_ACTION_CLOSE; ?>">
+                <?php echo LBL_ACTION_CLOSE; ?>
+            </a><!-- Add close image for Chamilo -->
+        </div>
+        <div class="jqmBody">
+            <div id="playGround"></div>
+        </div>
+    </div>
+</div>
+<div id="winRename" style="display:none">
+    <div class="jqmContainer">
+        <div class="jqmHeader">
+            <a href="#" onclick="return tb_remove();">
+                <img src="theme/default/images/flagno.png" title="<?php echo LBL_ACTION_CLOSE; ?>">
+                <?php echo LBL_ACTION_CLOSE; ?>
+            </a><!-- Add close image for Chamilo -->
+        </div>
+        <div class="jqmBody">
+            <form id="formRename" name="formRename" method="post" action="">
+                <input type="hidden" name="original_path" id="original_path"/>
+                <input type="hidden" name="num" id="renameNum" value=""/>
+                <table class="tableForm" cellpadding="0" cellspacing="0">
+                    <thead>
+                    <tr>
+                        <th colspan="2"><?php echo RENAME_FORM_TITLE; ?></th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr>
+                        <th><label><?php echo RENAME_NEW_NAME; ?></label></th>
+                        <td><input type="name" id="renameName" class="input" name="name"/>
+                            <!--  Chamilo delete style="width:250px"-->
+                        </td>
+                    </tr>
+                    </tbody>
+                    <tfoot>
+                    <tr>
+                        <th>&nbsp;</th>
+                        <td>
+                            <input type="button" value="<?php echo RENAME_LBL_RENAME; ?>" class="create_button" onclick="return doRename();"/>
+                        </td>
+                    </tr>
+                    </tfoot>
+                </table>
+            </form>
+        </div>
+    </div>
+</div>
+<div id="winInfo" style="display:none">
+    <div class="jqmContainer">
+        <div class="jqmHeader">
+            <a href="#" onclick="tb_remove();"><?php echo LBL_ACTION_CLOSE; ?></a>
+        </div>
+        <div class="jqmBody">
+            <table class="tableInfo" cellpadding="0" cellspacing="0">
+                <tbody>
+                <tr>
+                    <th nowrap>
+                        <label>Author:</label>
+                    </th>
+                    <td>
+                        <a href="&#109;a&#105;l&#116;&#111;:&#99;&#97;&#105;&#108;&#111;&#110;&#103;&#113;&#117;&#110;&#64;&#121;&#97;&#104;&#111;&#111;&#46;&#99;&#111;&#109;&#46;&#99;&#110;">Logan
+                            Cai</a>
+                    </td>
+                </tr>
+                <tr>
+                    <th nowrap>
+                        <label>Template Designer:</label>
+                    </th>
+                    <td>
+                        <a href="&#109;a&#105;l&#116;&#111;:&#71;&#97;&#98;&#114;&#105;&#101;&#108;&#64;&#52;&#118;&#46;&#99;&#111;&#109;&#46;&#98;&#114;">Gabriel</a>
+                    </td>
+                </tr>
+                <tr>
+                    <th nowrap>
+                        <label>Official Website:</label>
+                    </th>
+                    <td>
+                        <a href="http://www.phpletter.com">http://www.phpletter.com</a>
+                    </td>
+                </tr>
+                <tr>
+                    <th nowrap>
+                        <label>Support Forum:</label>
+                    </th>
+                    <td>
+                        <a href="http://www.phpletter.com/forum/">http://www.phpletter.com/forum/</a>
+                    </td>
+                </tr>
+                <tr>
+                    <th nowrap>
+                        <label>&copy;Copyright:</label>
+                    </th>
+                    <td>
+                        All copyright declarations in the source must remain unchange. Please contact us if you need to
+                        make changes to it, in order to avoid any Legal Issues.
+                    </td>
+                </tr>
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+<div id="contextMenu" style="display:none">
+    <ul>
+        <li><a href="#" class="contentMenuItem" id="menuSelect"><?php echo MENU_SELECT; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuPreview"><?php echo MENU_PREVIEW; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuDownload"><?php echo MENU_DOWNLOAD; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuRename"><?php echo MENU_RENAME; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuEdit"><?php echo MENU_EDIT; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuCut"><?php echo MENU_CUT; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuCopy"><?php echo MENU_COPY; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuPaste"><?php echo MENU_PASTE; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuDelete"><?php echo MENU_DELETE; ?></a></li>
+        <li><a href="#" class="contentMenuItem" id="menuPlay"><?php echo MENU_PLAY; ?></a></li>
+    </ul>
+</div>
 </body>
 </html>

+ 0 - 5
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php

@@ -11,9 +11,6 @@
  * @since 31/December/2008
  */
 
-//error_reporting(E_ALL);
-//error_reporting(E_ALL ^ E_NOTICE);
-
 //Access Control Setting
 /**
 * turn off => false
@@ -120,8 +117,6 @@ define('CONFIG_SYS_ROOT_PATH',		$PathChamiloAjaxFileManager);
 
 // end chamilo
 
-
-
 define('CONFIG_SYS_FOLDER_SHOWN_ON_TOP', true); //show your folders on the top of list if true or order by name
 define("CONFIG_SYS_DIR_SESSION_PATH", session_save_path()); // Hack by Juan Carlos Raña
 define("CONFIG_SYS_PATTERN_FORMAT", 'list'); //three options: reg ,csv, list, this option define the parttern format for the following patterns

+ 3 - 4
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.php

@@ -16,8 +16,9 @@
 // Loading the global initialization file.
 require_once '../../../../../../inc/global.inc.php';
 
-// Loading document repositories settings.
+api_block_anonymous_users();
 
+// Loading document repositories settings.
 require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php';
 
 //FILESYSTEM CONFIG
@@ -48,7 +49,6 @@ define('DIR_AJAX_JS', DIR_AJAX_ROOT.'jscripts'.DIRECTORY_SEPARATOR);
 define('DIR_AJAX_EDIT_AREA', DIR_AJAX_JS.'edit_area'.DIRECTORY_SEPARATOR);
 define('DIR_LANG', DIR_AJAX_ROOT.'langs'.DIRECTORY_SEPARATOR);
 
-
 //Class Declarations
 define('CLASS_FILE', DIR_AJAX_INC.'class.file.php');
 define("CLASS_UPLOAD", DIR_AJAX_INC.'class.upload.php');
@@ -69,7 +69,6 @@ if (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['config']) && file_exists(dirname
 
 require_once dirname(__FILE__).DIRECTORY_SEPARATOR.$configBaseFileName;
 
-
 // Loading the selected language file.
 require_once DIR_AJAX_LANGS.CONFIG_LANG_DEFAULT.".php";
 
@@ -116,4 +115,4 @@ define('CONFIG_URL_SAVE_TEXT', 'ajax_save_text.php');
 define('CONFIG_URL_LIST_LISTING', 'ajax_get_file_listing.php');
 define('CONFIG_URL_IMG_THUMBNAIL', $web_path.'ajax_image_thumbnail.php');
 define('CONFIG_URL_FILEnIMAGE_MANAGER', 'ajaxfilemanager.php');
-define('CONFIG_URL_FILE_PASTE', 'ajax_file_paste.php');
+define('CONFIG_URL_FILE_PASTE', 'ajax_file_paste.php');

+ 0 - 131
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.tinymce.php

@@ -1,131 +0,0 @@
-<?php
-	/**
-	 * sysem base config setting
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 1/August/2007
-	 *
-	 */
-
-
-error_reporting(E_ALL);
-//error_reporting(E_ALL ^ E_NOTICE);
-
-
-
-	//Access Control Setting
-	/**
-	 * turn off => false
-	 * by session => true
-	 */
-	define('CONFIG_ACCESS_CONTROL_MODE', false);
-	define("CONFIG_LOGIN_USERNAME", 'ajax');
-	define('CONFIG_LOGIN_PASSWORD', '123456');
-	define('CONFIG_LOGIN_PAGE', 'ajax_login.php'); //the url to the login page
-
-	//SYSTEM MODE CONFIG
-		/**
-		 * turn it on when you have this system for demo purpose
-		*  that means changes made to each image is not physically applied to it
-		*  and all uploaded files/created folders will be removed automatically
-		*/
-	define('CONFIG_SYS_DEMO_ENABLE', false);
-	define('CONFIG_SYS_VIEW_ONLY', false); //diabled the system, view only
-	define('CONFIG_SYS_THUMBNAIL_VIEW_ENABLE', true);//REMOVE THE thumbnail view if false
-
-	//User Permissions
-	define('CONFIG_OPTIONS_DELETE', true);
-	define('CONFIG_OPTIONS_CUT', true);
-	define('CONFIG_OPTIONS_COPY', true);
-	define('CONFIG_OPTIONS_NEWFOLDER', true);
-	define('CONFIG_OPTIONS_RENAME', true);
-	define('CONFIG_OPTIONS_UPLOAD', true); //
-	define('CONFIG_OPTIONS_EDITABLE', true); //disable image editor and text editor
-	//FILESYSTEM CONFIG
-		/*
-		* CONFIG_SYS_DEFAULT_PATH is the default folder where the files would be uploaded to
-			and it must be a folder under the CONFIG_SYS_ROOT_PATH or the same folder
-			these two paths accept relative path only, don't use absolute path
-		*/
-
-	define('CONFIG_SYS_DEFAULT_PATH', '../uploaded/'); //accept relative path only
-	define('CONFIG_SYS_ROOT_PATH', '../uploaded/');	//accept relative path only
-	define('CONFIG_SYS_FOLDER_SHOWN_ON_TOP', true); //show your folders on the top of list if true or order by name
-	define("CONFIG_SYS_DIR_SESSION_PATH", 'session/');
-	define("CONFIG_SYS_PATTERN_FORMAT", 'list'); //three options: reg ,csv, list, this option define the parttern format for the following patterns
-		/**
-		 * reg => regulare expression
-		 * csv => a list of comma separated file/folder name, (exactly match the specified file/folders)
-		 * list => a list of comma spearated vague file/folder name (partially match the specified file/folders)
-		 *
-		 */
-	//more details about regular expression please visit http://nz.php.net/manual/en/function.eregi.php
-	define('CONFIG_SYS_INC_DIR_PATTERN', ''); //force listing of folders with such pattern(s). separated by , if multiple
-	define('CONFIG_SYS_EXC_DIR_PATTERN', ''); //will prevent listing of folders with such pattern(s). separated by , if multiple
-	define('CONFIG_SYS_INC_FILE_PATTERN', ''); //force listing of fiels with such pattern(s). separated by , if multiple
-	define('CONFIG_SYS_EXC_FILE_PATTERN', ''); //will prevent listing of files with such pattern(s). separated by , if multiple
-	define('CONFIG_SYS_DELETE_RECURSIVE', 1); //delete all contents within a specific folder if set to be 1
-
-	//UPLOAD OPTIONS CONFIG
-	define('CONFIG_UPLOAD_MAXSIZE', 50 * 1024 ); //by bytes
-	//define('CONFIG_UPLOAD_MAXSIZE', 2048); //by bytes
-	//define('CONFIG_UPLOAD_VALID_EXTS', 'txt');//
-
-	define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html,xml,js,css'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid
-
-	define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste
-	define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
-	//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,bmp,tif,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf,ppt,rtf,doc,pdf,xls,txt,xml,xsl,dtd');//
-	define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,png,tif,html,htm,js,css,xml,xsl,dtd,mp3,wav,wmv,wma,rm,rmvb,mov,swf');
-	//define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,txt'); //
-	define('CONFIG_UPLOAD_INVALID_EXTS', '');
-
-	//Preview
-	define('CONFIG_IMG_THUMBNAIL_MAX_X', 100);
-	define('CONFIG_IMG_THUMBNAIL_MAX_Y', 100);
-	define('CONFIG_THICKBOX_MAX_WIDTH', 700);
-	define('CONFIG_THICKBOX_MAX_HEIGHT', 430);
-
-
-		/**
-		 * CONFIG_URL_PREVIEW_ROOT was replaced by CONFIG_WEBSITE_DOCUMENT_ROOT since v0.8
-		 * Normally, you don't need to bother with CONFIG_WEBSITE_DOCUMENT_ROOT
-		 * Howerver, some Web Hosts do not have standard php.ini setting
-		 * which you will find the file manager can not locate your files correctly
-		 * if you do have such issue, please change it to fit your system.
-		 * so what should you to do get it
-		 *   1. create a php script file (let's call it document_root.php)
-		 *   2. add the following codes in in
-		 * 			<?php
-		 * 				echo dirname(__FILE__);
-		 * 			?>
-		 *   3. upload document_root.php to you website root folder which will only be reached when you visit http://www.domain-name.com or http://localhost/ at localhost computer
-		 *   4. run it via http://www.domain-name.com/document_root.php or http://localhost/docuent_root.php if localhost computer, the url has to be exactly like that
-		 *   5. the value shown on the screen is CONFIG_WEBSITE_DOCUMENT_ROOT should be
-		 *   6. enjoy it
-
-
-		 *
-		 */
-
-
-	define('CONFIG_WEBSITE_DOCUMENT_ROOT', '');
-	//theme related setting
-			/*
-			*	options avaialbe for CONFIG_EDITOR_NAME are:
-					stand_alone
-					tinymce
-					fckeditor
-			*/
-	//CONFIG_EDITOR_NAME replaced CONFIG_THEME_MODE since @version 0.8
-	define('CONFIG_EDITOR_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['editor'])?secureFileName($_GET['editor']):'stand_alone'));
-	define('CONFIG_THEME_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['theme'])?secureFileName($_GET['theme']):'default'));  //change the theme to your custom theme rather than default
-	define('CONFIG_DEFAULT_VIEW', (CONFIG_SYS_THUMBNAIL_VIEW_ENABLE?'detail':'detail')); //thumnail or detail
-	define('CONFIG_DEFAULT_PAGINATION_LIMIT', 10);
-	define('CONFIG_LOAD_DOC_LATTER', false); //all documents will be loaded up after the template has been loaded to the client
-
-	//General Option Declarations
-	//LANGAUGAE DECLARATIONNS
-	define('CONFIG_LANG_INDEX', 'language'); //the index in the session
-	define('CONFIG_LANG_DEFAULT', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['language']) && file_exists(DIR_LANG . secureFileName($_GET['language'] . '.php'))?secureFileName($_GET['language']):'en')); //change it to be your language file base name, such en
-?>

+ 0 - 11
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php

@@ -9,17 +9,6 @@
  */
 require_once dirname(__FILE__).DIRECTORY_SEPARATOR."config.php";
 
-/**
- * force to ensure existence of stripos
- */
-if (!function_exists("stripos")) {
-
-    function stripos($str, $needle, $offset = 0) {
-        return @strpos(strtolower($str), strtolower($needle), $offset);
-    }
-
-}
-
 /**
  * get the current Url but not the query string specified in $excls
  *

+ 14 - 11
main/inc/lib/fckeditor/fckeditor.php

@@ -162,12 +162,11 @@ class FCKeditor
      *
      * @return string
      */
-    public function CreateHtml() {
+    public function CreateHtml()
+    {
         // Adaptation for the Chamilo LMS
-
 		//@todo why the BasePath is relative ? we should use this constant WEB_PATH
         $this->BasePath = api_get_path(REL_PATH).'main/inc/lib/fckeditor/';
-        //$this->BasePath = api_get_path(WEB_PATH).'main/inc/lib/fckeditor/';
 
         $config = $this->get_custom_configuration();
         $this->read_configuration($config);
@@ -463,7 +462,14 @@ class FCKeditor
      * This method returns default configuration for document repository that is to be used by the editor.
      * @return array
      */
-    private function & get_repository_configuration() {
+    private function & get_repository_configuration()
+    {
+        // Disabling access for anonymous users.
+        $isAnonymous = api_is_anonymous();
+
+        if ($isAnonymous) {
+            return array();
+        }
 
         // Preliminary calculations for assembling required paths.
         $base_path = $this->BasePath;
@@ -479,6 +485,7 @@ class FCKeditor
         $script_path = api_get_path(WEB_PATH).$script_path;
 
         $use_advanced_filemanager = api_get_setting('advanced_filemanager') == 'true';
+
         // Let javascripts "know" which file manager has been chosen.
         $config['AdvancedFileManager'] = $use_advanced_filemanager;
 
@@ -493,16 +500,12 @@ class FCKeditor
                 } else {
                     // 1.2. Student
                     $current_session_id = api_get_session_id();
-                    if($current_session_id==0)
-                    {
-
+                    if($current_session_id==0) {
                         $config['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
                         $config['CreateDocumentDir'] = $relative_path_prefix.'courses/'.api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
                         $config['BaseHref'] = $script_path;
-                    }
-                    else
-                    {
-                        $config['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document//shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
+                    } else {
+                        $config['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
                         $config['CreateDocumentDir'] = $relative_path_prefix.'courses/'.api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
                         $config['BaseHref'] = $script_path;
                     }

+ 6 - 18
main/inc/lib/fckeditor/fcktemplates.xml.php

@@ -1,17 +1,5 @@
 <?php
-/**
- *	Chamilo LMS
- *
- *	For a full list of contributors, see "credits.txt".
- *	The full license can be read in "license.txt".
- *
- *	This program is free software; you can redistribute it and/or
- *	modify it under the terms of the GNU General Public License
- *	as published by the Free Software Foundation; either version 2
- *	of the License, or (at your option) any later version.
- *
- *	See the GNU General Public License for more details.
- */
+/* For licensing terms, see /license.txt */
 
 // Setting the encoding to UTF-8.
 header('Content-Type: text/xml; charset=utf-8');
@@ -204,16 +192,16 @@ function load_personal_templates($user_id = 0) {
 
     $table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
     $table_document = Database::get_course_table(TABLE_DOCUMENT);
-    
+
     $course_id = api_get_course_int_id();
 
     // The sql statement for getting all the user defined templates
     $sql = "SELECT template.id, template.title, template.description, template.image, template.ref_doc, document.path
             FROM ".$table_template." template, ".$table_document." document
-            WHERE 
-                user_id='".Database::escape_string($user_id)."' AND 
+            WHERE
+                user_id='".Database::escape_string($user_id)."' AND
                 course_code='".Database::escape_string(api_get_course_id())."' AND
-                document.c_id = $course_id AND 
+                document.c_id = $course_id AND
                 document.id = template.ref_doc";
 
     $result_template = Database::query($sql);
@@ -252,7 +240,7 @@ function load_empty_template() {
         <![CDATA[
            <html>
            <head>
-               <meta charset="<?php echo api_get_system_encoding(); ?>" />        
+               <meta charset="<?php echo api_get_system_encoding(); ?>" />
            </head>
            <body  dir="<?php echo api_get_text_direction(); ?>">
            </body>

+ 1 - 19
main/inc/lib/fckeditor/myconfig.php

@@ -1,23 +1,5 @@
 <?php
-
-/*
- *	Chamilo LMS
- *
- *	Copyright (c) 2009-2011 Juan Carlos Raña
- *	Copyright (c) 2009-2011 Ivan Tcholakov
- *	Copyright (c) 2009 Dokeos SPRL
- *
- *	For a full list of contributors, see "credits.txt".
- *	The full license can be read in "license.txt".
- *
- *	This program is free software; you can redistribute it and/or
- *	modify it under the terms of the GNU General Public License
- *	as published by the Free Software Foundation; either version 2
- *	of the License, or (at your option) any later version.
- *
- *	See the GNU General Public License for more details.
- */
-
+/* For licensing terms, see /license.txt */
 
 /*
  * Custom editor configuration settings, php-side.

+ 72 - 69
main/inc/lib/fckeditor/repository.php

@@ -1,101 +1,104 @@
 <?php
-/**
- *	Chamilo LMS
- *
- *	For a full list of contributors, see "credits.txt".
- *	The full license can be read in "license.txt".
- *
- *	This program is free software; you can redistribute it and/or
- *	modify it under the terms of the GNU General Public License
- *	as published by the Free Software Foundation; either version 2
- *	of the License, or (at your option) any later version.
- *
- *	See the GNU General Public License for more details.
- */
+/* For licensing terms, see /license.txt */
 
 /**
- * Aditional system config settings for document repositories, the Chamilo LMS
+ * Additional system config settings for document repositories, the Chamilo LMS
  * @author Juan Carlos Raña
  * @since 31/December/2008
  */
 
 require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 
+// Disabling access for anonymous users.
+api_block_anonymous_users();
+
 $permissions_for_new_directories = api_get_permissions_for_new_directories();
 $permissions_for_new_files = api_get_permissions_for_new_files();
 
+$userId = api_get_user_id();
+$sessionId = api_get_session_id();
+
 if (!empty($_course['path'])) {
-	require_once api_get_path(LIBRARY_PATH).'document.lib.php';
-	require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
+    require_once api_get_path(LIBRARY_PATH).'document.lib.php';
+    require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
 
     // Get the Chamilo session properties. Before ajaximagemanager!!!
-    $to_group_id = !empty($_SESSION['_gid']) ? $_SESSION['_gid'] : 0 ;
-	$group_properties = GroupManager::get_group_properties($_SESSION['_gid']);
-	$is_user_in_group = GroupManager::is_user_in_group($_user['user_id'],$_SESSION['_gid']);
+    $groupId = api_get_group_id();
+    $group_properties = GroupManager::get_group_properties($groupId);
+    $is_user_in_group = GroupManager::is_user_in_group($userId, $groupId);
 }
 
-$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'system');
+$sessionName = null;
+if (!empty($sessionId)) {
+    $sessionName = api_get_session_name($sessionId);
+}
+
+$my_path = UserManager::get_user_picture_path_by_id($userId, 'system');
 $user_folder = $my_path['dir'].'my_files/';
 
 // Sanity checks for Chamilo.
 
 // Creation of a user owned folder if it does not exist.
 if (!file_exists($user_folder)) {
-	// A recursive call of mkdir function.
-	@mkdir($user_folder, $permissions_for_new_directories, true);
+    // A recursive call of mkdir function.
+    @mkdir($user_folder, $permissions_for_new_directories, true);
 }
 
-// Creation of repository used by paltform administrators if it does not exist.
+// Creation of repository used by platform administrators if it does not exist.
 if (api_is_platform_admin()) {
-	$homepage_folder = api_get_path(SYS_PATH).'home/default_platform_document/';
-	if (!file_exists($homepage_folder)) {
-		@mkdir($homepage_folder, $permissions_for_new_directories);
-	}
+    $homepage_folder = api_get_path(SYS_PATH).'home/default_platform_document/';
+    if (!file_exists($homepage_folder)) {
+        @mkdir($homepage_folder, $permissions_for_new_directories);
+    }
 }
 
-
 // Create course shared folders
 if (api_is_in_course()) {
-	$course_dir      = $_course['path'].'/document';
-	$sys_course_path = api_get_path(SYS_COURSE_PATH);
-	$base_work_dir   = $sys_course_path.$course_dir;
-	$current_session_id = api_get_session_id();
-	$userinfo = Database::get_user_info_from_id(api_get_user_id());
+    $course_dir      = $_course['path'].'/document';
+    $sys_course_path = api_get_path(SYS_COURSE_PATH);
+    $base_work_dir   = $sys_course_path.$course_dir;
+    $userInfo = api_get_user_info();
 
-	if($current_session_id==0){
-		//Create shared folder. Necessary for courses recycled. Allways session_id should be zero. Allway should be created from a base course, never from a session.
-		if (!file_exists($base_work_dir.'/shared_folder')) {
-			$usf_dir_title = get_lang('SharedFolder');
-			$usf_dir_name = '/shared_folder';
-			$to_group_id = 0;
-			$visibility = 0;
-			create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
-		}
-		// Create dynamic user shared folder
-		if (!file_exists($base_work_dir.'/shared_folder/sf_user_'.api_get_user_id())) {
-				$usf_dir_title = api_get_person_name($_user['firstName'], $_user['lastName']);
-				$usf_dir_name = '/shared_folder/sf_user_'.api_get_user_id();
-				$to_group_id = 0;
-				$visibility = 1;
-				create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
-		}
-	}
-	else{
-			//Create shared folder session
-			if (!file_exists($base_work_dir.'/shared_folder_session_'.$current_session_id)) {
-				$usf_dir_title = get_lang('SharedFolder').' ('.api_get_session_name($current_session_id).')';
-				$usf_dir_name = '/shared_folder_session_'.$current_session_id;
-				$to_group_id = 0;
-				$visibility = 0;
-				create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
-			}
-			//Create dynamic user shared folder into a shared folder session
-			if (!file_exists($base_work_dir.'/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id())) {
-				$usf_dir_title = api_get_person_name($_user['firstName'], $_user['lastName']).'('.api_get_session_name($current_session_id).')';
-				$usf_dir_name = '/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id();
-				$to_group_id = 0;
-				$visibility = 1;
-				create_unexisting_directory($_course, $_user['user_id'], api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
-			}
-	}
+    if ($sessionId == 0) {
+        /* Create shared folder. Necessary for courses recycled.
+         Always session_id should be zero. Always should be created from a base course, never from a session.*/
+        if (!file_exists($base_work_dir.'/shared_folder')) {
+            $usf_dir_title = get_lang('SharedFolder');
+            $usf_dir_name = '/shared_folder';
+            $visibility = 0;
+            create_unexisting_directory($_course, $userId, $sessionId, 0, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
+        }
+        // Create dynamic user shared folder
+        if (!file_exists($base_work_dir.'/shared_folder/sf_user_'.$userId)) {
+            $usf_dir_title = $userInfo['complete_name'];
+            $usf_dir_name = '/shared_folder/sf_user_'.$userId;
+            $visibility = 1;
+            create_unexisting_directory($_course, $userId, $sessionId, 0, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
+        }
+    } else {
+        // Create shared folder session
+        if (!file_exists($base_work_dir.'/shared_folder_session_'.$sessionId)) {
+            $usf_dir_title = get_lang('SharedFolder').' ('.$sessionName.')';
+            $usf_dir_name = '/shared_folder_session_'.$sessionId;
+            $visibility = 0;
+            create_unexisting_directory($_course, $userId, $sessionId, 0, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
+        }
+        // Create dynamic user shared folder into a shared folder session.
+        if (!file_exists($base_work_dir.'/shared_folder_session_'.$sessionId.'/sf_user_'.$userId)) {
+            $usf_dir_title = $userInfo['complete_name'].' ('.$sessionName.')';
+            $usf_dir_name = '/shared_folder_session_'.$sessionId.'/sf_user_'.$userId;
+            $visibility = 1;
+            create_unexisting_directory(
+                $_course,
+                $userId,
+                $sessionId,
+                0,
+                $to_user_id,
+                $base_work_dir,
+                $usf_dir_name,
+                $usf_dir_title,
+                $visibility
+            );
+        }
+    }
 }

+ 9 - 33
main/inc/lib/fileDisplay.lib.php

@@ -9,30 +9,6 @@
 /**
  * Code
  */
-/*	GENERIC FUNCTIONS : FOR OLDER PHP VERSIONS */
-if ( ! function_exists('array_search') ) {
-    /**
-     * Searches haystack for needle and returns the key
-     * if it is found in the array, FALSE otherwise.
-     *
-     * Natively implemented in PHP since 4.0.5 version.
-     * This function is intended for previous version.
-     *
-     * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
-     * @param  - needle (mixed)
-     * @param  - haystack (array)
-     * @return - array key or FALSE
-     *
-     * @see    - http://www.php.net/array_search
-     */
-    function array_search($needle, $haystack)
-    {
-        while (list($key, $val) = each($haystack))
-            if ($val == $needle)
-                return $key;
-        return false;
-    }
-}
 
 /* FILE DISPLAY FUNCTIONS */
 /**
@@ -215,26 +191,26 @@ function get_total_folder_size($path, $can_see_invisible = false) {
     $table_itemproperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $table_document 	= Database::get_course_table(TABLE_DOCUMENT);
     $tool_document 		= TOOL_DOCUMENT;
-    
+
     $course_id 			= api_get_course_int_id();
     $session_id         = api_get_session_id();
     $session_condition  = api_get_session_condition($session_id, true, true, 'props.id_session');
 
     $visibility_rule = ' props.visibility ' . ($can_see_invisible ? '<> 2' : '= 1');
-    
+
     $sql = "SELECT SUM(table1.size) FROM (
                 SELECT size FROM $table_itemproperty AS props, $table_document AS docs
-                WHERE 	docs.c_id 	= $course_id AND                        
-                        docs.id 	= props.ref AND 
+                WHERE 	docs.c_id 	= $course_id AND
+                        docs.id 	= props.ref AND
                         docs.path LIKE '$path/%' AND
                         props.c_id 	= $course_id AND
-                        props.tool 	= '$tool_document' AND                            
-                        $visibility_rule  
-                        $session_condition 
+                        props.tool 	= '$tool_document' AND
+                        $visibility_rule
+                        $session_condition
                 GROUP BY ref
             ) as table1";
-    
-    $result = Database::query($sql);    
+
+    $result = Database::query($sql);
     if ($result && Database::num_rows($result) != 0) {
         $row = Database::fetch_row($result);
         return $row[0] == null ? 0 : $row[0];

+ 2 - 2
main/inc/lib/groupmanager.lib.php

@@ -1546,8 +1546,8 @@ class GroupManager
      * Is the user part of this group? This can be a tutor or a normal member
      * you should use this function if the access to a tool or functionality is restricted to the people who are actually in the group
      * before you had to check if the user was 1. a member of the group OR 2. a tutor of the group. This function combines both
-     * @param $user_id the id of the user
-     * @param $group_id the id of the group
+     * @param int $user_id the id of the user
+     * @param int $group_id the id of the group
      * @return boolean true/false
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
      */

+ 3 - 2
main/inc/lib/main_api.lib.php

@@ -923,7 +923,7 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
 
 /**
  * Function used to protect an admin script.
- * 
+ *
  * The function blocks access when the user has no platform admin rights with an error message printed on default output
  * @param bool Whether to allow session admins as well
  * @param bool Whether to allow HR directors as well
@@ -3767,7 +3767,7 @@ function api_max_sort_value($user_course_category, $user_id) {
  * @return boolean true or false
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  */
-function string_2_boolean($string) {
+function api_string_2_boolean($string) {
     if ($string == 'true') {
         return true;
     }
@@ -3777,6 +3777,7 @@ function string_2_boolean($string) {
     return false;
 }
 
+
 /**
  * Determines the number of plugins installed for a given location
  */

+ 408 - 34
main/inc/lib/sessionmanager.lib.php

@@ -12,7 +12,7 @@
  */
 class SessionManager
 {
-    private function __construct()
+    public function __construct()
     {
     }
 
@@ -194,13 +194,15 @@ class SessionManager
 	}
 
     /**
-     * @param string $session_name
+     * @param string $name
      * @return bool
      */
-    function session_name_exists($session_name)
+    public static function session_name_exists($name)
     {
-	    $session_name = Database::escape_string($session_name);
-        $result = Database::fetch_array(Database::query("SELECT COUNT(*) as count FROM ".Database::get_main_table(TABLE_MAIN_SESSION)." WHERE name = '$session_name' "));
+        $name = Database::escape_string($name);
+        $sql = "SELECT COUNT(*) as count FROM ".Database::get_main_table(TABLE_MAIN_SESSION)."
+                WHERE name = '$name'";
+        $result = Database::fetch_array(Database::query($sql));
         return $result['count'] > 0;
 	}
 
@@ -208,7 +210,7 @@ class SessionManager
      * @param string $where_condition
      * @return mixed
      */
-    static function get_count_admin($where_condition = null)
+    public static function get_count_admin($where_condition = null)
     {
         $tbl_session            = Database::get_main_table(TABLE_MAIN_SESSION);
         $tbl_session_category   = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@@ -513,11 +515,11 @@ class SessionManager
         $tbl_course     = Database::get_main_table(TABLE_MAIN_COURSE);
 
 
-        $select = "select  u.username, u.firstname, u.lastname, l.name, v.progress  
+        $select = "select  u.username, u.firstname, u.lastname, l.name, v.progress
                 FROM $tbl_lp_view v
                 INNER JOIN $tbl_lp l ON l.id = v.lp_id
                 INNER JOIN $tbl_user u ON u.user_id = v.user_id
-                INNER JOIN $tbl_course c 
+                INNER JOIN $tbl_course c
                 ";
 
         $where = ' WHERE 1=1 ';
@@ -540,16 +542,250 @@ class SessionManager
         $select .= $where.$order.$limit;
         $result = Database::query($select);
         $formatted_sessions = array();
-        if (Database::num_rows($result) > 0) { 
+        if (Database::num_rows($result) > 0) {
             while ($row = Database::fetch_assoc($result)) {
                 $formatted_sessions[] = $row;
             }
-            /*foreach ($lps as $lp) {
-                error_log(print_r($lp,1));
-            }*/
         }
         return $formatted_sessions;
     }
+    /**
+     * Gets the progress of the given session
+     * @param int   session id
+     * @param array options order and limit keys
+     * @return array table with user name, lp name, progress
+     */
+    public static function get_session_progress($sessionId, $options)
+    {
+
+        //tables
+        $session_course_user    = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
+        $user                   = Database::get_main_table(TABLE_MAIN_USER);
+        $workTable              = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
+        $workTableAssignment    = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
+        $forum                  = Database::get_course_table(TABLE_FORUM);
+        $forum_post             = Database::get_course_table(TABLE_FORUM_POST);
+        $tbl_course_lp          = Database::get_course_table(TABLE_LP_MAIN);
+        $wiki                   = Database::get_course_table(TABLE_WIKI);
+
+        $courses = SessionManager::get_course_list_by_session_id($sessionId);
+        //TODO let select course
+        $course = current($courses);
+        //TODO fix this
+        $course_info = array('real_id' => $course['id']);
+
+        //getting all the students of the course
+        //we are not using this because it only returns user ids
+        /*if (empty($sessionId)
+        {
+            // Registered students in a course outside session.
+            $users = CourseManager :: get_student_list_from_course_code($course_code);
+        } else {
+            // Registered students in session.
+            $users = CourseManager :: get_student_list_from_course_code($course_code, true, $sessionId);
+        }*/
+        $sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code FROM $session_course_user s
+        INNER JOIN $user u ON u.user_id = s.id_user
+        WHERE course_code = '%s'
+        AND s.status <> 2 and id_session = %s";
+
+        $sql_query = sprintf($sql, $course['code'], $sessionId);
+
+        $rs = Database::query($sql_query);
+        while ($user = Database::fetch_array($rs))
+        {
+            $users[$user['user_id']] = $user;
+        }
+
+        /**
+         *  Lessons
+         */
+        $sql = "SELECT * FROM $tbl_course_lp
+        WHERE c_id = %s ";  //AND session_id = %s
+        $sql_query = sprintf($sql, $course_info['real_id']);
+        $result = Database::query($sql_query);
+        $lessons_total = 0;
+        while ($row = Database::fetch_array($result))
+        {
+            if (api_get_item_visibility(api_get_course_info($course['code']), 'learnpath', $row['id'], $sessionId))
+            {
+                $lessons_total++;
+            }
+        }
+
+        /**
+         *  Exercises
+         */
+        require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
+        $exercises = get_all_exercises($course_info, $sessionId);
+        $exercises_total = count($exercises);
+
+        /**
+         *  Assignments
+         */
+        //total
+        $sql = "SELECT count(w.id) as count
+        FROM $workTable w
+        LEFT JOIN  $workTableAssignment a ON (a.publication_id = w.id AND a.c_id = w.c_id)
+        WHERE w.c_id = %s
+        AND parent_id = 0
+        AND active IN (1, 0)
+        AND  session_id = %s";
+        $sql_query = sprintf($sql, $course_info['real_id'], $sessionId);
+        $result = Database::query($sql_query);
+        $row = Database::fetch_array($result);
+        $assignments_total = $row['count'];
+
+        /**
+         * Wiki
+         */
+        $sql = "SELECT count(distinct page_id)  as count FROM $wiki
+            WHERE c_id = %s and session_id = %s";
+        $sql_query = sprintf($sql, $course_info['real_id'], $sessionId);
+        $result = Database::query($sql_query);
+        $row = Database::fetch_array($result);
+        $wiki_total = $row['count'];
+
+        /**
+         * Surveys
+         */
+        $survey_user_list = array();
+        $survey_list = survey_manager::get_surveys($course['code'], $sessionId);
+
+        $surveys_total = count($survey_list);
+        $survey_data = array();
+        foreach ($survey_list as $survey)
+        {
+            $user_list = survey_manager::get_people_who_filled_survey($survey['survey_id'], false, $course_info['real_id']);
+            foreach ($user_list as $user_id)
+            {
+                isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : $survey_user_list[$user_id] = 1;
+            }
+        }
+        /**
+         * Forums
+         */
+        //total
+        $sql = "SELECT count(*) as count
+        FROM $forum f
+        where f.c_id = %s and f.session_id = %s";
+        $sql_query = sprintf($sql, $course_info['real_id'], $sessionId);
+        $result = Database::query($sql_query);
+        $row = Database::fetch_array($result);
+        $forums_total = $row['count'];
+
+
+        //process table info
+        foreach ($users as $user)
+        {
+            //Course description
+            $sql = "SELECT count(*) as count
+            FROM track_e_access
+            WHERE access_tool = 'course_description'
+            AND access_cours_code = '%s'
+            AND access_session_id = %s
+            AND access_user_id = %s ";
+            $sql_query  = sprintf($sql, $course['code'], $sessionId, $user['user_id']);
+            $result     = Database::query($sql_query);
+            $row        = Database::fetch_array($result);
+            $course_description_progress = ($row['count'] > 0) ? 100 : 0;
+
+            //Lessons
+            //TODO: Lessons done and left is calculated by progress per item in lesson, maybe we should calculate it only per completed lesson?
+            $lessons_progress   = Tracking::get_avg_student_progress($user['user_id'], $course['code'], array(), $sessionId);
+            $lessons_done       = ($lessons_progress * $lessons_total) / 100;
+            $lessons_left       = $lessons_total - $lessons_done;
+
+            //Exercises
+            $exercises_progress     = str_replace('%', '', Tracking::get_exercise_student_progress($exercises, $user['user_id'], $course['code'], $sessionId));
+            $exercises_done         = ($exercises_progress * $exercises_total) / 100;
+            $exercises_left         = $exercises_total - $exercises_done;
+
+            //Assignments
+            $assignments_done       = Tracking::count_student_assignments($user['user_id'], $course['code'], $sessionId);
+            $assignments_left       = $assignments_total - $assignments_done;
+            $assignments_progress   =  round((( $assignments_done * 100 ) / $assignments_total ), 2);
+
+            //Wiki
+            $sql = "SELECT count(*) as count
+            FROM $wiki
+            where c_id = %s and session_id = %s and user_id = %s";
+            $sql_query  = sprintf($sql, $course_info['real_id'], $sessionId, $user['user_id']);
+            $result     = Database::query($sql_query);
+            $row        = Database::fetch_array($result);
+            $wiki_revisions =  $row['count'];
+
+            //Surveys
+            $surveys_done       = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0);
+            $surveys_left       = $surveys_total - $surveys_done;
+            $surveys_progress   = round((( $surveys_done * 100 ) /  $surveys_total), 2);
+
+            //Forums
+            #$forums_done = Tracking::count_student_messages($user['user_id'], $course_code, $session_id);
+            $sql = "SELECT count(distinct f.forum_id) as count FROM $forum_post p
+            INNER JOIN $forum f ON f.forum_id = p.forum_id
+            WHERE p.poster_id = %s and f.session_id = %s and p.c_id = %s";
+            $sql_query  = sprintf($sql, $user['user_id'], $sessionId, $course_info['real_id']);
+            $result     = Database::query($sql_query);
+            $row        = Database::fetch_array($result);
+
+            $forums_done        = $row['count'];
+            $forums_left        = $forums_total - $forums_done;
+            $forums_progress    = round((( $forums_done * 100 ) /  $forums_total), 2);
+
+            //Overall Total
+            $overall_total =  ($course_description_progress + $exercises_progress + $forums_progress + $assignments_progress + $wiki_progress + $surveys_progress) / 6;
+
+            $table[] = array(
+                'lastname'  => $user[1],
+                'firstname' => $user[2],
+                'username'  => $user[3],
+                #'profile'   => '',
+                'total'     => round($overall_total,2) . '%',
+                'courses'   => $course_description_progress . '%',
+                'lessons'   => $lessons_progress . '%',
+                'exercises' => $exercises_progress . '%',
+                'forums'    => $forums_progress . '%',
+                'homeworks' => $assignments_progress . '%',
+                'wikis'     => $wiki_progress . '%',
+                'surveys'   => $surveys_progress . '%',
+                //course description
+                'course_description_progress' => $course_description_progress . '%',
+                //lessons
+                'lessons_total'      => $lessons_total,
+                'lessons_done'       => $lessons_done,
+                'lessons_left'       => $lessons_left,
+                'lessons_progress'   => $lessons_progress . '%',
+                //exercises
+                'exercises_total'       => $exercises_total,
+                'exercises_done'        => $exercises_done,
+                'exercises_left'        => $exercises_left,
+                'exercises_progress'    => $exercises_progress . '%',
+                //forums
+                'forums_total'      => $forums_total,
+                'forums_done'       => $forums_done,
+                'forums_left'       => $forums_left,
+                'forums_progress'   => $forums_progress . '%',
+                //assignments
+                'assignments_total'     => $assignments_total,
+                'assignments_done'      => $assignments_done,
+                'assignments_left'      => $assignments_left,
+                'assignments_progress'  => $assignments_progress . '%',
+                //wiki
+                'wiki_total'        => $wiki_total,
+                'wiki_revisions'    => $wiki_revisions,
+                'wiki_read'         => $wiki_read,
+                'wiki_unread'       => $wiki_unread,
+                'wiki_progress'     => $wiki_progress . '%',
+                //survey
+                'surveys_total'     => $surveys_total,
+                'surveys_done'      => $surveys_done,
+                'surveys_left'      => $surveys_left,
+                'surveys_progress'  => $surveys_progress . '%',
+                );
+        }
+        return $table;
+    }
     /**
      * Creates a new course code based in given code
      *
@@ -560,7 +796,7 @@ class SessionManager
      * </code>
      * @return string	wanted unused code
      */
-	function generate_nice_next_session_name($session_name)
+    public static function generate_nice_next_session_name($session_name)
     {
         $session_name_ok = !self::session_name_exists($session_name);
         if (!$session_name_ok) {
@@ -1700,41 +1936,102 @@ class SessionManager
 		return $affected_rows;
 	}
 
+    /**
+     * @param int $userId
+     * @param int $sessionId
+     * @return array
+     */
+    public static function getSessionFollowedByDrh($userId, $sessionId)
+    {
+        $tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
+        $tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
+        $tbl_session_rel_access_url =   Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+
+        $userId = intval($userId);
+        $sessionId = intval($sessionId);
+
+        $select = " SELECT * ";
+        if (api_is_multiple_url_enabled()) {
+            $sql = " $select FROM $tbl_session s
+                    INNER JOIN $tbl_session_rel_user sru ON (sru.id_session = s.id)
+                    LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
+                    WHERE
+                        sru.id_user = '$userId' AND
+                        sru.id_session = '$sessionId' AND
+                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' AND
+                        access_url_id = ".api_get_current_access_url_id()."
+                        ";
+        } else {
+            $sql = "$select FROM $tbl_session s
+                     INNER JOIN $tbl_session_rel_user sru
+                     ON
+                        sru.id_session = s.id AND
+                        sru.id_user = '$userId' AND
+                        sru.id_session = '$sessionId' AND
+                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."'
+                        ";
+        }
+        $result = Database::query($sql);
+        if (Database::num_rows($result)) {
+            $row = Database::fetch_array($result, 'ASSOC');
+            $row['course_list'] = self::get_course_list_by_session_id($sessionId);
+            return $row;
+        }
+        return array();
+    }
+
 	/**
 	 * Get sessions followed by human resources manager
 	 * @param int		Human resources manager or Session admin id
 	 * @return array 	sessions
 	 */
-	public static function get_sessions_followed_by_drh($hr_manager_id)
+	public static function get_sessions_followed_by_drh($userId, $start = null, $limit = null, $getCount = false)
     {
 		// Database Table Definitions
 		$tbl_session 			= 	Database::get_main_table(TABLE_MAIN_SESSION);
 		$tbl_session_rel_user 	= 	Database::get_main_table(TABLE_MAIN_SESSION_USER);
         $tbl_session_rel_access_url =   Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 
-		$hr_manager_id = intval($hr_manager_id);
+		$userId = intval($userId);
 		$assigned_sessions_to_hrm = array();
 
+        $select = " SELECT * ";
+        if ($getCount) {
+            $select = " SELECT count(s.id) as count ";
+        }
+
+         $limitCondition = null;
+        if (!empty($start) && !empty($limit)) {
+            $limitCondition = " LIMIT ".intval($start). ", ".intval($limit);
+        }
+
 		if (api_is_multiple_url_enabled()) {
-           $sql = "SELECT * FROM $tbl_session s
+           $sql = " $select FROM $tbl_session s
                     INNER JOIN $tbl_session_rel_user sru ON (sru.id_session = s.id)
                     LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
                     WHERE
-                        sru.id_user = '$hr_manager_id' AND
+                        sru.id_user = '$userId' AND
                         sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' AND
-                        access_url_id = ".api_get_current_access_url_id()."";
+                        access_url_id = ".api_get_current_access_url_id()."
+                        $limitCondition";
         } else {
-            $sql = "SELECT * FROM $tbl_session s
+            $sql = "$select FROM $tbl_session s
                      INNER JOIN $tbl_session_rel_user sru
                      ON
                         sru.id_session = s.id AND
-                        sru.id_user = '$hr_manager_id' AND
-                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."' ";
+                        sru.id_user = '$userId' AND
+                        sru.relation_type = '".SESSION_RELATION_TYPE_RRHH."'
+                        $limitCondition";
         }
-		$rs_assigned_sessions = Database::query($sql);
-		if (Database::num_rows($rs_assigned_sessions) > 0) {
-			while ($row_assigned_sessions = Database::fetch_array($rs_assigned_sessions))	{
-				$assigned_sessions_to_hrm[$row_assigned_sessions['id']] = $row_assigned_sessions;
+		$result = Database::query($sql);
+        if ($getCount) {
+            $row = Database::fetch_array($result);
+            return $row['count'];
+        }
+
+        if (Database::num_rows($result) > 0) {
+			while ($row = Database::fetch_array($result))	{
+				$assigned_sessions_to_hrm[$row['id']] = $row;
 			}
 		}
 		return $assigned_sessions_to_hrm;
@@ -1913,7 +2210,7 @@ class SessionManager
      * @param int $id
      * @return array
      */
-    static function get_all_sessions_by_promotion($id)
+    public static function get_all_sessions_by_promotion($id)
     {
         $t = Database::get_main_table(TABLE_MAIN_SESSION);
         return Database::select('*', $t, array('where'=>array('promotion_id = ?'=>$id)));
@@ -1923,7 +2220,7 @@ class SessionManager
      * @param int $promotion_id
      * @param array $list
      */
-    static function suscribe_sessions_to_promotion($promotion_id, $list)
+    public static function suscribe_sessions_to_promotion($promotion_id, $list)
     {
         $t = Database::get_main_table(TABLE_MAIN_SESSION);
         $params = array();
@@ -1961,7 +2258,7 @@ class SessionManager
      * @return  int     The new session ID on success, 0 otherwise
      * @todo make sure the extra session fields are copied too
      */
-    public function copy_session($id, $copy_courses = true, $copy_users = true, $create_new_courses = false, $set_exercises_lp_invisible = false)
+    public static function copy_session($id, $copy_courses = true, $copy_users = true, $create_new_courses = false, $set_exercises_lp_invisible = false)
     {
         $id = intval($id);
         $s = self::fetch($id);
@@ -2645,14 +2942,15 @@ class SessionManager
         $numberItems = null,
         $column = 1,
         $direction = 'asc',
-        $keyword = null
+        $keyword = null,
+        $active = null
     ) {
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
         $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
         $tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 
-        $direction = in_array(strtolower($direction),array('asc', 'desc')) ? $direction : 'asc';
+        $direction = in_array(strtolower($direction), array('asc', 'desc')) ? $direction : 'asc';
         $column = Database::escape_string($column);
         $userId = intval($userId);
 
@@ -2664,6 +2962,12 @@ class SessionManager
             $limitCondition = "LIMIT $from, $numberItems";
         }
 
+        $activeCondition = null;
+        if (isset($active)) {
+            $active = intval($active);
+            $activeCondition = " AND active = $active";
+        }
+
         $urlId = api_get_current_access_url_id();
 
         $statusConditions = null;
@@ -2710,7 +3014,9 @@ class SessionManager
                     INNER JOIN $tbl_user u ON (u.user_id = su.id_user AND s.id = id_session)
                     INNER JOIN $tbl_session_rel_access_url url ON (url.session_id = s.id)
                 WHERE access_url_id = $urlId
-                      $statusConditions ";
+                      $statusConditions
+                      $activeCondition
+                ";
 
         if (!empty($keyword)) {
             $keyword = Database::escape_string($keyword);
@@ -2885,6 +3191,77 @@ class SessionManager
         return $htmlResult;
     }
 
+    /**
+     * @param string $keyword
+     * @param int $active
+     * @return array|int
+     */
+    public static function getCountUserTracking($keyword = null, $active = null)
+    {
+        if (!isset($keyword)) {
+            $keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
+        }
+
+        if (!isset($active)) {
+            $active = isset($_GET['active']) ? $_GET['active'] : null;
+        }
+
+        if (api_is_drh()) {
+            if (api_drh_can_access_all_session_content()) {
+                $count = self::getAllUsersFromCoursesFromAllSessionFromStatus(
+                    'drh_all',
+                    api_get_user_id(),
+                    true,
+                    null,
+                    null,
+                    null,
+                    null,
+                    $keyword,
+                    $active
+                );
+            } else {
+                $count = self::getAllUsersFromCoursesFromAllSessionFromStatus(
+                    'drh',
+                    api_get_user_id(),
+                    true,
+                    null,
+                    null,
+                    null,
+                    null,
+                    $keyword,
+                    $active
+                );
+            }
+        } else {
+            if (api_is_platform_admin()) {
+                $count = self::getAllUsersFromCoursesFromAllSessionFromStatus(
+                    'admin',
+                    api_get_user_id(),
+                    true,
+                    null,
+                    null,
+                    null,
+                    null,
+                    $keyword,
+                    $active
+                );
+            } else {
+                $count = self::getAllUsersFromCoursesFromAllSessionFromStatus(
+                    'teacher',
+                    api_get_user_id(),
+                    true,
+                    null,
+                    null,
+                    null,
+                    null,
+                    $keyword,
+                    $active
+                );
+            }
+        }
+        return $count;
+    }
+
     /**
      * Get the list of course tools that have to be dealt with in case of
      * registering any course to a session
@@ -2977,7 +3354,4 @@ class SessionManager
     {
 
     }
-
-
-
 }

+ 50 - 32
main/inc/lib/tracking.lib.php

@@ -1312,7 +1312,7 @@ class Tracking {
      * @param    int        Coach id
      * @return    array    Sessions list
      */
-    public static function get_sessions_coached_by_user($coach_id)
+    public static function get_sessions_coached_by_user($coach_id, $start = 0, $limit = 0, $getCount = false)
     {
         // table definition
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
@@ -1320,52 +1320,70 @@ class Tracking {
 
         $coach_id = intval($coach_id);
 
-        // session where we are general coach
-        $sql = 'SELECT DISTINCT id, name, date_start, date_end
-                    FROM ' . $tbl_session . '
-                    WHERE id_coach=' . $coach_id;
+        $select = " SELECT * FROM ";
 
-        if (api_is_multiple_url_enabled()) {
-            $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
-            $access_url_id = api_get_current_access_url_id();
-            if ($access_url_id != -1){
-                $sql = 'SELECT DISTINCT id, name, date_start, date_end
-                    FROM ' . $tbl_session . ' session INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
-                    ON (session.id = session_rel_url.session_id)
-                    WHERE id_coach=' . $coach_id.' AND access_url_id = '.$access_url_id;
-            }
+        if ($getCount) {
+            $select = " SELECT count(DISTINCT id) as count FROM ";
         }
 
-        $rs = Database::query($sql);
-        while ($row = Database::fetch_array($rs)) {
-            $a_sessions[$row["id"]] = $row;
+        $limitCondition = null;
+        if (!empty($start) && !empty($limit)) {
+            $limitCondition = " LIMIT ".intval($start).", ".intval($limit);
         }
 
-        // session where we are coach of a course
-        $sql = 'SELECT DISTINCT session.id, session.name, session.date_start, session.date_end
-                    FROM ' . $tbl_session . ' as session
-                    INNER JOIN ' . $tbl_session_course_user . ' as session_course_user
+        // session where we are general coach
+        $sql = " $select
+
+                (SELECT DISTINCT id, name, date_start, date_end
+                    FROM $tbl_session
+                    WHERE id_coach = $coach_id
+                UNION
+
+                SELECT DISTINCT session.id, session.name, session.date_start, session.date_end
+                    FROM $tbl_session as session
+                    INNER JOIN $tbl_session_course_user  as session_course_user
                         ON session.id = session_course_user.id_session
-                        AND session_course_user.id_user=' . $coach_id.' AND session_course_user.status=2';
+                        AND session_course_user.id_user= $coach_id AND session_course_user.status=2
+                )
+                as sessions $limitCondition
+                ";
 
         if (api_is_multiple_url_enabled()) {
             $tbl_session_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
             $access_url_id = api_get_current_access_url_id();
             if ($access_url_id != -1){
-                $sql = 'SELECT DISTINCT session.id, session.name, session.date_start, session.date_end
-                    FROM ' . $tbl_session . ' as session
-                    INNER JOIN ' . $tbl_session_course_user . ' as session_course_user
-                        ON session.id = session_course_user.id_session AND session_course_user.id_user=' . $coach_id.' AND session_course_user.status=2
-                    INNER JOIN '.$tbl_session_rel_access_url.' session_rel_url
-                    ON (session.id = session_rel_url.session_id)
-                    WHERE access_url_id = '.$access_url_id;
+                $sql = "
+                    $select
+                    (
+                        SELECT DISTINCT id, name, date_start, date_end
+                        FROM $tbl_session session INNER JOIN $tbl_session_rel_access_url session_rel_url
+                        ON (session.id = session_rel_url.session_id)
+                        WHERE id_coach = $coach_id AND access_url_id = $access_url_id
+
+                        UNION
+
+                        SELECT DISTINCT session.id, session.name, session.date_start, session.date_end
+                        FROM $tbl_session as session
+                        INNER JOIN $tbl_session_course_user as session_course_user
+                            ON session.id = session_course_user.id_session AND session_course_user.id_user= $coach_id AND session_course_user.status=2
+                        INNER JOIN $tbl_session_rel_access_url session_rel_url
+                        ON (session.id = session_rel_url.session_id)
+                        WHERE access_url_id = $access_url_id
+                    ) as sessions $limitCondition
+                    ";
             }
         }
 
         $rs = Database::query($sql);
+        if ($getCount) {
+            $row = Database::fetch_array($rs);
+            return $row['count'];
+        }
+
         while ($row = Database::fetch_array($rs)) {
             $a_sessions[$row["id"]] = $row;
         }
+
         if (is_array($a_sessions)) {
             foreach ($a_sessions as & $session) {
                 if ($session['date_start'] == '0000-00-00') {
@@ -2035,7 +2053,7 @@ class Tracking {
      * Get total clicks by session
      * @param    int        Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered
      * @return    array     data
-     * @todo    implement total click by $course_id 
+     * @todo    implement total click by $course_id
      */
     public static function get_total_clicks_by_session($session_id = null) {
         $tables = array(
@@ -2057,12 +2075,12 @@ class Tracking {
             #TABLE_STATISTIC_TRACK_E_OPEN,
             );
 
-        if (isset($_GET['session_id']) && !empty($_GET['session_id'])) 
+        if (isset($_GET['session_id']) && !empty($_GET['session_id']))
         {
             $sessionId = intval($_GET['session_id']);
         }
 
-        foreach ($tables as $tableName => $fields) 
+        foreach ($tables as $tableName => $fields)
         {
             $sql = sprintf('SELECT %s as user, count(*) as total FROM %s WHERE %s = %s GROUP BY %s', $fields[1], $tableName, $fields[0], $sessionId, $fields[1]);
             $rs = Database::query($sql);

+ 23 - 7
main/inc/local.inc.php

@@ -964,18 +964,18 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset))
             Session::write('_courseUser',$_courseUser);
         }
 
-        //We are in a session course? Check session permissions
+        // We are in a session course? Check session permissions
         if (!empty($session_id)) {
-            //I'm not the teacher of the course
+            // I'm not the teacher of the course
             if ($is_courseAdmin == false) {
-                // this user has no status related to this course
+                // This user has no status related to this course
                 // The user is subscribed in a session? The user is a Session coach a Session admin ?
 
                 $tbl_session             = Database :: get_main_table(TABLE_MAIN_SESSION);
                 $tbl_session_course      = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
                 $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
-                //Session coach, session admin, course coach admin
+                // Session coach, session admin or course coach admin
                 $sql = "SELECT session.id_coach, session_admin_id, session_rcru.id_user
                         FROM $tbl_session session, $tbl_session_course_user session_rcru
                         WHERE  session_rcru.id_session  = session.id AND
@@ -986,9 +986,9 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset))
                         ";
 
                 $result = Database::query($sql);
-                $row     = Database::store_result($result);
+                $row = Database::store_result($result);
 
-                //Am I a session admin?
+                // Am I a session admin?
                 if (isset($row) && isset($row[0]) && $row[0]['session_admin_id'] == $user_id) {
                     $_courseUser['role'] = 'Professor';
                     $is_courseMember     = false;
@@ -1005,6 +1005,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset))
                            "AND session.id_coach = $user_id ".
                            "AND sc.course_code = '$_cid'";
                     $result = Database::query($sql);
+
                     if (Database::num_rows($result)) {
                         $_courseUser['role'] = 'Professor';
                         $is_courseMember     = true;
@@ -1063,7 +1064,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset))
                                     break;
                             }
                         } else {
-                            //unregister user
+                            // Unregister user
                             $is_courseMember     = false;
                             $is_courseTutor      = false;
                             $is_courseAdmin      = false;
@@ -1073,6 +1074,21 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset))
                         }
                     }
                 }
+
+                // Drh can enter to a course as an student see BT#6770
+                if (api_drh_can_access_all_session_content()) {
+                    $sessionInfo = SessionManager::getSessionFollowedByDrh($user_id, $session_id);
+                    if (!empty($sessionInfo) && !empty($sessionInfo['course_list'])) {
+                        if (isset($sessionInfo['course_list'][$_course['real_id']])) {
+                            $_courseUser['role'] = '';
+                            $is_courseMember     = true;
+                            $is_courseTutor      = false;
+                            $is_courseCoach      = false;
+                            $is_sessionAdmin     = false;
+                        }
+                    }
+                }
+
             }
 
             //If I'm the admin platform i'm a teacher of the course

+ 43 - 0
main/lang/slovak/admin.inc.php

@@ -326,6 +326,7 @@ $NoticeText = "Text Oznamu";
 $LinkName = "Text Odkazu";
 $LinkURL = "URL Odkazu";
 $OpenInNewWindow = "Otvoriť v novom okne";
+$langLimitUsersListDefaultMaxComment = "V obrazovkách, ktoré umožňujú pridávanie používateľov k tréningu alebo do tried, v prípade ak prvý nefiltrovaný zoznam obsahuje viac ako je tento počet používateľov, potom sa prepne na prvé písmeno (A)";
 $Plugins = "Zásuvné moduly";
 $HideDLTTMarkupComment = "Skryť značky [=...=] keď  premenná jazyka nie je preložená";
 $Info = "Informácia";
@@ -1013,14 +1014,56 @@ $AllowSkillsToolTitle = "Povoliť nástroj Zručnosti";
 $AllowPublicCertificatesTitle = "Povoliť verejné certifikáty";
 $YouShouldCreateTermAndConditionsForAllAvailableLanguages = "Mali by ste vytvoriť \"Pojmy a podmienky\" pre všetky dostupné jazyky.";
 $ActivateEmailTemplateTitle = "Povoliť e-mailové šablóny upozornení";
+$ActivateEmailTemplateComment = "Definovať domáce e-mail upozornenia, ktoré budú vyhodené pre konkrétne udalosti (a na konkrétnych používateľov)";
 $SystemManagement = "Správa systému";
 $RemoveOldDatabaseMessage = "Odstrániť staré databázy";
 $RemoveOldTables = "Odstrániť staré tabuľky";
+$TotalSpaceUsedByPortalXLimitIsYMB = "Celkové miesto používané portálom %s limit je %s MB";
+$EventMessageManagement = "Správa správ udalosti";
 $Events = "Udalosti";
+$ToBeWarnedUserList = "Ak chcete byť upozornení zoznamom používateľov";
+$HideCampusFromPublicPlatformsList = "Skryť školu zo zoznamu verejných platforiem";
+$ChamiloOfficialServicesProviders = "Oficiálny poskytovatelia Chamilo služieb";
 $Reader = "Čitateľ";
+$Zombies = "Zombi";
+$ActiveOnly = "Iba aktívne";
+$AuthenticationSource = "Zdroj overovania";
+$RegisteredDate = "Dátum registrovania";
+$FilterTermsTitle = "Podmienky filtrovania";
+$FilterTermsComment = "Uveďte zoznam termínov, jeden po riadku, ktoré majú byť filtrované z webových stránok a e-mailov. Tieto podmienky budú nahradené ***.";
+$UseCustomPagesTitle = "Použiť vlastné stránky";
 $StudentPageAfterLoginTitle = "Stránka študenta po prihlásení";
+$StudentPageAfterLoginComment = "Táto stránka sa zobrazí všetkým študentom po prihlásení";
+$TeacherPageAfterLoginTitle = "Stránka lektora po prihlásení";
+$TeacherPageAfterLoginComment = "Táto stránka bude načítaná po prihlásení pre všetkých lektorov";
+$DRHPageAfterLoginTitle = "Stránka manažéra ľudských zdrojov po prihlásení";
+$DRHPageAfterLoginComment = "Táto stránka bude načítaná po prihlásení pre všetkých manažérov ľudských zdrojov";
+$StudentAutosubscribeTitle = "Automatické prihlásenie študenta";
+$StudentAutosubscribeComment = "Automatické prihlásenie študenta - zatiaľ nie je k dispozícii";
+$TeacherAutosubscribeTitle = "Automatické prihlásenie Lektora";
+$TeacherAutosubscribeComment = "Automatické prihlásenie Lektora - zatiaľ nie je k dispozícii";
+$DRHAutosubscribeTitle = "Automatické prihlásenie Riaditeľa ľudských zdrojov";
+$DRHAutosubscribeComment = "Automatické prihlásenie Riaditeľa ľudských zdrojov - zatiaľ nie je k dispozícií";
+$ScormCumulativeSessionTimeTitle = "Súhrny čas stretnutia pre SCORM";
+$ScormCumulativeSessionTimeComment = "Ak je povolené, bude čas stretnutia pre SCORM učebné osnovy súhrnný, inak bude počítaný iba z posledného pokusu o aktualizáciu času.";
+$SessionAdminPageAfterLoginTitle = "Administrátorská stránka stretnutia po prihlásení";
+$SessionAdminPageAfterLoginComment = "Stránka nahraná po prihlásení pre správcu stretnutia";
+$SessionadminAutosubscribeTitle = "Automatické prihlásenie správcu stretnutia";
+$SessionadminAutosubscribeComment = "Automatické prihlásenie správcu stretnutia - zatiaľ nie je k dispozícií";
+$ToolVisibleByDefaultAtCreationTitle = "Nástroj viditeľný pri tvorbe kurzu";
+$ToolVisibleByDefaultAtCreationComment = "Vyberte nástroje, ktoré budú viditeľné pri vytváraní kurzov - zatiaľ nie je k dispozícii";
+$casAddUserActivatePlatform = "CAS vnútorné nastavenie";
+$casAddUserActivateLDAP = "CAS vnútorné nastavenie";
+$UpdateUserInfoCasWithLdapTitle = "CAS vnútorné nastavenie";
+$UpdateUserInfoCasWithLdapComment = "CAS vnútorné nastavenie";
 $ShowAllUsers = "Ukázať všetkých používateľov";
+$ShowUsersNotAddedInTheURL = "Zobraziť používateľov, ktorí nie sú pridaný do URL";
+$UserNotAddedInURL = "Používatelia nepridaní do URL";
+$UsersRegisteredInNoSession = "Používatelia nie sú registrovaní v žiadnom stretnutí";
+$CommandLineInterpreter = "Interpret príkazového riadku (CLI)";
 $PleaseVisitOurWebsite = "Prosím navštívte naše webové stránky: http://www.chamilo.org";
+$SpaceUsedOnSystemCannotBeMeasuredOnWindows = "Priestor použitý na disku nie je možné správne merať na systémoch založených na systéme Windows.";
 $XOldTablesDeleted = "%d staré tabuľky zmazané";
 $XOldDatabasesDeleted = "%d staré databázy zmazané";
+$ExtensionShouldBeLoaded = "Toto rozšírenie by malo byť nahrané.";
 ?>

+ 2 - 0
main/lang/slovak/create_course.inc.php

@@ -103,9 +103,11 @@ $NewCourseCreatedIn = "Nový kurz vytvorený v";
 $ExplicationTrainers = "Lektor je nastavený teraz ako vy. Toto nastavenie môžete zmeniť neskôr v nastavení konfigurácie kurzu";
 $Objectives = "Ciele";
 $TargetAudience = "Cieľová skupina";
+$CourseRequestCreated = "Vaša žiadosť o nový kurz bola úspešne odoslaná. Môžete dostať odpoveď čoskoro, v priebehu jedného alebo dvoch dní.";
 $CreateThisCourseRequest = "Požiadať o vytvorenie kurzu";
 $CourseRequestDate = "Dátum požiadavky";
 $AcceptThisCourseRequest = "Akceptovať tento kurz";
+$ANewCourseWillBeCreated = "Nový kurz %s bude vytvorený. Je to v poriadku pre ďalšie pokračovanie?";
 $DeleteThisCourseRequest = "Odstrániť túto požiadavku kurzu";
 $CourseRequestEdit = "Upraviť požiadavku kurzu";
 $Accept = "Prijať";

+ 16 - 16
main/lang/slovak/exercice.inc.php

@@ -2,6 +2,14 @@
 /*
 for more information: see languages.txt in the lang folder.
 */
+$ImportAikenQuizExplanationExample = "Toto je text pre otázku 1 A. Odpoveď 1 B. Odpoveď 2 C. Odpoveď 3 ANSWER: B Toto je text pre otázku 2 A. Odpoveď 1 B. Odpoveď 2 C. Odpoveď 3 D. Odpoveď 4 ANSWER: D ANSWER_EXPLANATION: to je voliteľná komentár spätnej väzby, ktorý sa zobrazí vedľa správnej odpovede.";
+$ImportAikenQuizExplanation = "Formát Aiken je v jednoduchom textovom súbore (.txt), s niekoľkými blokmi otázok, z ktorých každý je oddelený prázdnym riadkom. Prvý riadok je otázka, riadky s odpoveďou je označený písmenom a bodkou, a správna odpoveď príde s ďalšou ODPOVEĎOU: predpona. Viď príklad nižšie.";
+$ExerciseAikenErrorNoAnswerOptionGiven = "Importovaný súbor má aspoň jednu otázku bez odpovede (alebo odpovede neobsahujú požadovanú predponu listu). Uistite sa, že každá otázka má aspoň jednu odpoveď, a že má predponu písmeno a bodkou alebo zátvorku, ako je tento: A. jednu odpoveď";
+$ExerciseAikenErrorNoCorrectAnswerDefined = "Importovaný súbor obsahuje aspoň jednu otázku bez akejkoľvek správnej definovanej odpovede. Uistite sa, že všetky otázky majú ODPOVEĎ: [Letter] riadok.";
+$ThereWasAProblemWithYourFile = "Bol tam neznámy problém so súborom. Prosím skontrolujte jeho formát a skúste to znova.";
+$YouMustUploadAZipOrTxtFile = "Musíte nahrať .txt alebo .zip súbor";
+$NoTxtFileFoundInTheZip = "Nenájdený žiadny .txt súbor v súbore zip";
+$ImportAikenQuiz = "Importovať Aiken test";
 $ExerciseWasActivatedFromXToY = "Cvičenie bolo aktivované od %s do %s";
 $SelectAnAnswerToContinue = "Vyberte odpoveď pre pokračovanie";
 $IfYouContinueYourAnswerWillBeSavedAnyChangeWillBeNotAllowed = "Ak budete pokračovať vaše odpovede budú uložené, akákoľvek zmena urobená neskôr nie je dovolená. Ste si istí, že chcete pokračovať?";
@@ -11,18 +19,10 @@ $QuestionReused = "Otázka pridaná do cvičenia";
 $QuestionCopied = "Otázka skopírovaná do cvičenia";
 $ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected = "-1 = Budú vybrané všetky otázky. 0 = Budú vybrané žiadne otázky.";
 $EmailNotificationTemplateDescription = "Môžete prispôsobiť e-mail, ktorý sa posiela používateľom pri dokončení cvičenia. Môžete použiť tieto značky:<br>
-1. {{ student.username }}<br>
-2. {{ student.firstname }}<br>
-3. {{ student.lastname }}<br>
-4. {{ student.official_code }}<br>
-5. {{ exercise.title }}<br>
-6. {{ exercise.start_time }}<br>
-7. {{ exercise.end_time }}<br>
-8. {{ course.title }}<br>
-9. {{ course.code }}";
+1. {{ student.username }} 2. {{ student.firstname }} 3. {{ student.lastname }} 4. {{ student.official_code }} 5. {{ exercise.title }} 6. {{ exercise.start_time }} 7. {{ exercise.end_time }} 8. {{ course.title }} 9. {{ course.code }}";
 $EmailNotificationTemplate = "Šablóna e-mailu upozornenia";
 $ExerciseEndButtonDisconnect = "Odhlásiť";
-$ExerciseEndButtonExerciseHome = "Zoznam cvičenia";
+$ExerciseEndButtonExerciseHome = "Zoznam cvičenia.";
 $ExerciseEndButtonCourseHome = "Domov kurzu";
 $ExerciseEndButton = "Domovská stránka kurzu";
 $HideQuestionTitle = "Skryť názov otázky";
@@ -45,7 +45,7 @@ $MediaQuestions = "Zdieľané vyhlásenia";
 $AddedToLPCannotBeAccessed = "Toto zadanie bolo zahrnuté do učebnej osnovy, nemôže byť zobrazené študentmi priamo tu. Ak chcete, aby rovnaké zadanie bolo k dispozícii prostredníctvom nástroja zadanie, prosím urobte kópiu aktuálneho zadania pomocou ikony kopírovania.";
 $langExercice = "Test";
 $langActivate = "Ukázať";
-$langDeactivate = "Schovaj";
+$langDeactivate = "Skryť";
 $langNoEx = "Momentálne tu nie je žiadny test";
 $langNewEx = "Nový test";
 $langQuestion = "Otázka";
@@ -87,9 +87,9 @@ $langUseTagForBlank = "použiť hranaté zátvorky [...] na definovanie jedného
 $langQuestionWeighting = "Váha";
 $langMoreAnswers = "+odp";
 $langLessAnswers = "-odp";
-$langMoreElements = "+elem";
-$langLessElements = "-elem";
-$langTypeTextBelow = "Prosím nižšie napíšte svoj text";
+$langMoreElements = "+prvok";
+$langLessElements = "-prvok";
+$langTypeTextBelow = "Prosím napíšte svoj text nižšie";
 $langDefaultTextInBlanks = "[Briti] žijú vo [Veľkej Británii].";
 $langDefaultMatchingOptA = "bohatý";
 $langDefaultMatchingOptB = "pekný";
@@ -148,7 +148,7 @@ $langIntroduction = "Úvod";
 $langTitleAssistant = "Pomocník pre tvorbu testov";
 $langQuesList = "zoznam otázok";
 $langSaveEx = "uložiť cvičenia";
-$langFinish = "Ukončiť";
+$langFinish = "Ukončiť test";
 $langCancel = "Zrušiť";
 $langQImage = "Otázka s obrázkom";
 $langAddQ = "Pridať otázku";
@@ -164,7 +164,7 @@ $langReplaced = "Vymenený";
 $langSuperior = "hodnota väčšia ako 20";
 $langRep20 = "Nahradiť 20";
 $langDefault = "Prednastavené hodnoty *";
-$langDefComment = "predchádzajúce hodnoty budú nahradené klikom na tlačidlo \"prednastavené hodnoty\"";
+$langDefComment = "predchádzajúce hodnoty budú nahradené kliknutím na tlačidlo \"prednastavené hodnoty\"";
 $langScoreGet = "čierne čísla = skóre";
 $langShowScor = "Zobraziť hodnotenie študentom:";
 $langStep1 = "Etapa 1";

+ 41 - 4
main/lang/slovak/install.inc.php

@@ -2,8 +2,11 @@
 /*
 for more information: see languages.txt in the lang folder.
 */
+$DateTimezoneSettingNotSet = "Zistili sme, že vaša inštalácia PHP nedefinuje nastavenie date.timezone. Toto je požiadavka Chamilo. Prosím uistite sa, že je nastavená konfigurácia php.ini podľa kontroly, inak sa dostanete do problémov. Varovali sme vás!";
 $langStatDB = "Štatistická databáza";
 $langEnableTracking = "Aktivovať štatistiku";
+$langInstituteShortName = "Skrátený názov vašej spoločnosti";
+$langWarningResponsible = "Použite tohto skript iba po zálohovaní. Tím Chamilo nie je zodpovedný za stratené alebo poškodené údaje.";
 $langAllowSelfRegProf = "Povoliť samo-registráciu ako tvorcu kurzu";
 $langEG = "napr.";
 $langDBHost = "Hostiteľ databázy";
@@ -12,6 +15,7 @@ $langDBPassword = "Databázové heslo";
 $langMainDB = "Hlavná Chamilo databáza (DB)";
 $langAllFieldsRequired = "všetky polia povinné";
 $langPrintVers = "Verzia pre tlač";
+$langLocalPath = "Zodpovedajúca lokálnej ceste";
 $langAdminEmail = "Email administrátora";
 $langAdminName = "Meno administrátora";
 $langAdminSurname = "Priezvisko administrátora";
@@ -19,6 +23,7 @@ $langAdminLogin = "Prihlásenie administrátora";
 $langAdminPass = "Heslo administrátora (<font color=\"red\">môžete ho zmeniť</font>)";
 $langEducationManager = "Projektový manažér";
 $langCampusName = "Meno portálu";
+$langDBSettingIntro = "Inštalačný skript vytvorí hlavnú Chamilo databázu(y). Vezmite prosím na vedomie, že Chamilo bude musieť vytvoriť viac databáz. Ak vaša Hostingová služba má povolené používať iba jednu databázu, Chamilo nebude fungovať, ak ste zvolili možnosť \"Jedna databáza\".";
 $langStep1 = "Etapa 1";
 $langStep2 = "Etapa 2";
 $langStep3 = "Etapa 3 zo 6";
@@ -43,7 +48,7 @@ $langAdminPhone = "Telefónne číslo administrátora";
 $OK = "OK";
 $langAdminFirstName = "Meno administrátora";
 $langInstituteURL = "URL organizácie";
-$langDokeosURL = "URL Chamilo-u";
+$langDokeosURL = "URL Chamilo";
 $langUserDB = "Používateľ DB";
 $PleaseWait = "Čakajte prosím";
 $PleaseCheckTheseValues = "Prosím skontrolujte tieto hodnoty";
@@ -60,6 +65,7 @@ $of = "z";
 $Step = "Etapa";
 $MoreDetails = "Pre viac detailov";
 $ServerRequirements = "Požiadavky serveru";
+$ServerRequirementsInfo = "Váš server musí poskytnúť nasledujúce knižnice, aby boli povolené všetky funkcie Chamilo. Chýbajúce knižnice zobrazené písmenami na oranžovo sú nepovinné, ale niektoré funkcie Chamilo môžu byť zakázané, pokiaľ nie sú nainštalované. Stále môžete nainštalovať tieto knižnice neskôr a povoliť chýbajúce funkcie.";
 $PHPVersion = "PHP verzia";
 $support = "podpora";
 $PHPVersionOK = "PHP verzia je OK";
@@ -68,34 +74,65 @@ $RecommendedSettingsInfo = "Odporúčané nastavenia pre konfiguráciu Vášho s
 $Setting = "Nastavenie";
 $Actual = "Aktuálne";
 $DirectoryAndFilePermissions = "Povolenia pre katalógy a súbory";
+$DirectoryAndFilePermissionsInfo = "Niektoré adresáre a súbory, ktoré obsahujú, musia byť zapisovateľné webovým serverom, aby ich Chamilo spustil (používateľ nahral súbory, domovské súbory html, ...). Toto by mohlo znamenať, vykonať ručné zmeny na vašom serveri (mimo toto rozhranie).";
 $NotWritable = "Nie je možné prepísať";
 $Writable = "Možnosť prepísať";
 $ExtensionLDAPNotAvailable = "LDAP rozšírenie nedostupné";
 $ExtensionGDNotAvailable = "GD rozšírenie nedostupné";
+$DokeosLicenseInfo = "Chamilo je free softvér distribuovaný pod licenciou GNU General Public licence (GPL).";
 $IAccept = "Súhlasím";
 $ConfigSettingsInfo = "Nasledujúce hodnoty budú zapísané vo Vašom konfiguračnom súbore";
 $DokeosInstallation = "Chamilo inštalácia";
 $InstallDokeos = "Inštalovať Chamilo";
 $GoToYourNewlyCreatedPortal = "Choďte na Váš novo zriadený portál.";
+$FirstUseTip = "Keď prvýkrát vstúpite na portál, najlepší spôsob, ako ho pochopiť, je vytvoriť kurz s \"Vytvoriť kurz\" odkazom v menu a pohrajte sa s ním trochu.";
 $Version_ = "Verzia";
-$UpdateFromDokeosVersion = "Aktualizácia z Chamilo-u";
-$WelcomToTheDokeosInstaller = "Vitajte v inštalačnom programe Chamilo-u";
+$UpdateFromDokeosVersion = "Aktualizácia z Chamilo";
+$WelcomToTheDokeosInstaller = "Vitajte v inštalátore Chamilo";
 $PleaseSelectInstallationProcessLanguage = "Prosím vyberte jazyk, ktorý chcete použiť pri inštalácii";
 $ReadTheInstallGuide = "čítať návod na inštaláciu";
 $HereAreTheValuesYouEntered = "Tu sú hodnoty, ktoré ste zadali";
 $PrintThisPageToRememberPassAndOthers = "Vytlačte túto stránku, aby ste nezabudli vaše heslo a ďalšie nastavenia";
+$TheInstallScriptWillEraseAllTables = "Inštalačný skript zmaže všetky tabuľky z vybraných databáz. Silno vám odporúčame vykonať ich úplnú zálohu pred potvrdením tohto posledného kroku inštalácie.";
 $Warning = "Upozornenie";
 $ReadWarningBelow = "Čítať upozornenie nižšie";
 $SecurityAdvice = "Rada ohľadne bezpečnosti";
+$YouHaveMoreThanXCourses = "Máte viac ako %d kurzov na vašej platforme Chamilo! Iba %d kurzy boli aktualizované. Ak chcete aktualizovať ďalšie kurzy, %s kliknite tu %s";
+$ToProtectYourSiteMakeXAndYReadOnly = "Ak chcete chrániť svoje stránky, nastavte %s a %s (ale nie ich adresáre) len na čítanie (CHMOD 444).";
 $Error = "Chyba";
 $Back = "Späť";
 $HasNotBeenFound = "nenájdený";
-$PleaseGoBackToStep1 = "Prosím choďte späť na etapu 1";
+$PleaseGoBackToStep1 = "Prosím choďte späť na Krok 1";
 $HasNotBeenFoundInThatDir = "nebol nájdený v tomto katalógu";
+$OldVersionRootPath = "Stará verzia koreňovej cesty";
+$NoWritePermissionPleaseReadInstallGuide = "Niektoré súbory alebo priečinky nemajú oprávnenie na zápis. Aby bolo možné nainštalovať Chamilo, mali by ste najprv zmeniť ich oprávnenie (pomocou CHMOD). Prečítajte si prosím %s inštalačnú príručku %s";
 $DBServerDoesntWorkOrLoginPassIsWrong = "Server databázy nefunguje alebo prihlasovacie meno / heslo nie je správne";
 $PleaseGoBackToStep = "Prosím choďte späť na etapu";
+$DBSettingUpgradeIntro = "Upgrade skript obnoví a aktualizuje Chamilo databázu(y). Za týmto účelom bude tento skript používať databázy a nastavenie definované nižšie. Pretože náš softvér beží na širokej škále systémov a pretože všetky z nich nemusia byť testované, dôrazne odporúčame vykonať úplnú zálohu databázy, pred tým ako budete pokračovať s upgradom!";
 $ExtensionMBStringNotAvailable = "MBString rozšírenie nedostupné";
 $ExtensionMySQLNotAvailable = "MySQL rozšírenie nedostupné";
+$DokeosArtLicense = "Obrázky a mediálne galérie Chamilo používajú obrázky z Nuvola, Crystal Clear a Tango ikon galérií. Ďalšie obrázky a médiá, ako sú diagramy a Flash animácie sú požičané od Wikimedia a Ali Pakdel a Denis Hoa kurzy s ich súhlasom, a je uvoľnený pod BY-SA Creative Commons licencie. Podrobnosti o licencii môžete nájsť na <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" target=\"_blank\">CC webových stránkach</a>, kde je plné znenie licencie poskytované v dolnej časti stránky.";
 $OptionalParameters = "Nepovinné parametre";
 $FailedConectionDatabase = "Pripojenie k databáze bolo neúspešné. Obvykle je to kvôli nesprávnemu používateľovi, heslu alebo predpone databázy zadanej hore. Skontrolujte prosím tieto nastavenia a skúste znova.";
+$EncryptMethodUserPass = "Metóda šifrovania";
+$UpgradeFromDokeos16x = "Upgrade z Chamilo 1.6.x";
+$UpgradeFromDokeos18x = "Upgrade z Chamilo 1.8.x";
+$Step7 = "Krok 7";
+$SuggestionOnlyToEnableCSSUploadFeature = "Navrhnite iba v prípade, ak chcete povoliť CSS funkciu odoslania";
+$SuggestionOnlyToEnableSubLanguageFeature = "Návrh iba v prípade, že chcete povoliť funkciu pod-jazyka";
+$ToProtectYourSiteMakeXReadOnlyAndDeleteY = "Ak chcete chrániť vašu stránku, nastavte celý adresár %s iba na čítanie (chmod 0555 na Linuxe) a odstráňte  %s adresár.";
+$IfYouPlanToUpgradeFromOlderVersionYouMightWantToHaveAlookAtTheChangelog = "Ak plánujete upgrade zo staršej verzie Chamilo, možno sa budete <a href=\"https://translate.chamilo.org/documentation/changelog.html\" target=\"_blank\">chcieť pozrieť na zoznam zmien</a> a vedieť, čo je nové a čo sa zmenilo";
+$WelcomeToTheDokeosInstaller = "Vitajte v inštalácií Chamilo";
+$PHPVersionError = "Vaša PHP verzia nezodpovedá požiadavkám pre tento softvér. Skontrolujte prosím, či máte najnovšiu verziu a skúste to znova.";
+$ExtensionSessionsNotAvailable = "Rozšírenie spojenia nie je k dispozícií";
+$ExtensionZlibNotAvailable = "Zlib rozšírenie nie je k dispozícií";
+$ExtensionPCRENotAvailable = "PCRE rozšírenie nie je k dispozícií";
+$DatabaseXWillBeCreated = "Databáza %s bude vytvorená";
+$ADatabaseWithTheSameNameAlreadyExists = "Databáza s rovnakým názvom <strong>už existuje.</strong>";
+$UserXCantHaveAccessInTheDatabaseX = "Používateľ %s nemá prístup do databázy %s";
+$DatabaseXCantBeCreatedUserXDoestHaveEnoughPermissions = "Databázu %s nie je možné vytvoriť, používateľ %s nemá dostatočné oprávnenia";
+$CourseTestWasCreated = "Skúšobný kurz bol úspešne vytvorený";
+$InstallExecution = "Spustiť proces inštalácie";
+$UpdateExecution = "Aktualizovať proces spustenia";
+$PleaseWaitThisCouldTakeAWhile = "Čakajte prosím. Môže to chvíľu trvať ...";
 ?>

+ 23 - 0
main/lang/slovak/tracking.inc.php

@@ -138,7 +138,9 @@ $langAllRight = "Nie je tu žiadny nezvy&#269;ajný prípad";
 $langDefcon = "Objavené problematické prípady !!";
 $langNULLValue = "Prázdny (alebo NULA)";
 $langTrafficDetails = "Podrobnosti prevádzky";
+$langSeeIndividualTracking = "Pre individuálne sledovane pozrite <a href=../user/user.php>Používateľské</a> nástroje.";
 $langPathNeverOpenedByAnybody = "Táto osnova nebola nikdy otvorená.";
+$SynthesisView = "Syntéza pohľad";
 $Visited = "Navštívený";
 $FirstAccess = "Prvý prístup";
 $LastAccess = "Posledný prístup";
@@ -224,6 +226,7 @@ $FollowingFieldsWillAlsoBeExported = "Nasledujúce polia budú tiež exportovan
 $TotalExercisesScoreObtained = "Celkové skóre získané z cvičení";
 $TotalExercisesScorePossible = "Celkové možné skóre cvičení";
 $TotalExercisesAnswered = "Počet zodpovedaných cvičení";
+$TotalExercisesScorePercentage = "Celkové percentuálne skóre pre testy";
 $ForumForumsNumber = "Počet fór";
 $ForumThreadsNumber = "Počet tém";
 $ForumPostsNumber = "Počet správ";
@@ -233,16 +236,24 @@ $CourseInformation = "Informácie o kurze";
 $NoAdditionalFieldsWillBeExported = "Žiadne ďalšie polia nebudú exportované";
 $langSendNotification = "Poslať oznámenia";
 $TimeOfActiveByTraining = "Čas v kurze";
+$AvgAllUsersInAllCourses = "Priemer všetkých študentov vo všetkých kurzoch";
+$AvgExercisesScore = "Skóre testov";
 $TrainingTime = "Čas";
 $CourseProgress = "Pokrok";
 $ViewMinus = "Ukázať mínus";
 $DashboardBlocks = "Dashboard bloky";
 $DashboardList = "Dashboard zoznam";
 $AddADateTime = "Pridať čas a dátum";
+$DateLock = "Dátum zamknutia";
 $CountOfUsers = "Spočítať používateľov";
+$CountOfSubscriptions = "Počet predplatného";
+$FolderCreated = "Nová zložka vytvorená";
+$LearnpathVisible = "Zviditeľniť učebnú osnovu";
+$LinkInvisible = "Zneviditeľniť Odkaz";
 $LinkAdded = "Odkaz pridaný";
 $Minutes = "Minúty";
 $BackupCreated = "Záloha vytvorená";
+$CountCertificates = "Spočítať certifikáty";
 $AverageHoursPerStudent = "Priem. hodiny/študent";
 $TrainingHoursAccumulated = "Nahromadené tréningové hodiny";
 $ManHours = "Človekohodín";
@@ -260,8 +271,20 @@ $BestAttempt = "Najlepší pokus";
 $Untitled = "Bez názvu";
 $Quantity = "Množstvo";
 $UploadedDocuments = "Nahrané dokumenty";
+$ExerciseProgress = "Postup v Cvičení";
 $NumberOfStudents = "Počet študentov";
+$NumberStudentsAccessingCourse = "Počet študentov vstupujúcich na kurz";
+$AverageOfActivitiesCompletedPerStudent = "Priemerný počet dokončených aktivít na študenta";
+$TotalTimeSpentInTheCourse = "Celkový čas strávený v kurze";
+$AverageTimePerStudentInCourse = "Priemerný čas na študenta strávený v kurze";
+$NumberOfDocumentsInLearnpath = "Počet dokumentov v Učebnej osnove";
+$NumberOfExercisesInLearnpath = "Počet cvičení v Učebnej osnove";
 $NumberOfLinksInLearnpath = "Počet odkazov v učebnej osnove";
+$NumberOfForumsInLearnpath = "Počet Fór v Učebnej osnove";
+$NumberOfAssignmentsInLearnpath = "Počet zadaní v Učebnej osnove";
+$NumberOfAnnouncementsInCourse = "Počet oznámení v kurze";
+$CurrentCoursesReport = "Správa aktuálnych kurzov";
+$NumberOfPublishedExercises = "# publikovaných cvičení";
 $NumberOfPublishedLps = "# publikovaných učebných osnov";
 $EventType = "Typ udalosti";
 $NbInactiveSessions = "Počet neaktívnych stretnutí";

+ 1 - 1
main/lang/slovak/trad4all.inc.php

@@ -50,7 +50,7 @@ $PasswordNormal = "Normálne";
 $PasswordWeak = "Slabé";
 $PasswordIsTooShort = "Heslo je príliš krátke";
 $BadCredentials = "Zlé poverenia";
-$BreadcrumbNavigationDisplayComment = "Zobraziť alebo skryť maličkú navigáciu, tá sa objaví tesne pod hlavnou navigáciou v kartách. Dôrazne sa odporúča, aby sa táto navigácia zobrazovala používateľom, pretože to im umožňuje lokalizovať svoju aktuálnu polohu a ľahko ich to naviguje na predchádzajúce stránky.
+$BreadcrumbNavigationDisplayComment = "Zobraziť alebo skryť maličkú navigáciu, tá sa objaví tesne pod hlavnou navigáciou v kartách. Dôrazne sa odporúča, aby sa táto navigácia zobrazovala používateľom, pretože to im umožňuje lokalizovať svoju aktuálnu polohu a ľahko ich to naviguje na predchádzajúce stránky. 
 
 Niekedy, môže byť však potrebné to skryť (napr. v prípade skúšky), aby sa zabránilo používateľom použiť navigáciu na stránky, na ktorých by to nemalo byť vidieť.";
 $BreadcrumbNavigationDisplayTitle = "Maličká navigácia";

+ 258 - 279
main/mySpace/index.php

@@ -29,10 +29,10 @@ ob_start();
 $export_csv  = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
 $display 	 = isset($_GET['display']) ? Security::remove_XSS($_GET['display']) : null;
 $csv_content = array();
-$nameTools   		= get_lang('MySpace');
+$nameTools = get_lang('MySpace');
 
-$user_id 	 		= api_get_user_id();
-$is_coach 			= api_is_coach($_GET['session_id']); // This is used?
+$user_id = api_get_user_id();
+$is_coach = api_is_coach($_GET['session_id']); // This is used?
 
 $session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
 
@@ -44,20 +44,20 @@ $count_sessions 	= 0;
 $count_courses		= 0;
 $title 				= null;
 
-// access control
+// Access control
 api_block_anonymous_users();
 
 if (!$export_csv) {
     Display :: display_header($nameTools);
 } else {
     if ($_GET['view'] == 'admin') {
-        if($display == 'useroverview') {
+        if ($display == 'useroverview') {
             MySpace::export_tracking_user_overview();
             exit;
-        } else if($display == 'sessionoverview') {
+        } elseif ($display == 'sessionoverview') {
             MySpace::export_tracking_session_overview();
             exit;
-        } else if($display == 'courseoverview') {
+        } elseif ($display == 'courseoverview') {
             MySpace::export_tracking_course_overview();
             exit;
         }
@@ -69,8 +69,7 @@ $tbl_user 					= Database :: get_main_table(TABLE_MAIN_USER);
 $tbl_sessions 				= Database :: get_main_table(TABLE_MAIN_SESSION);
 $tbl_session_course_user 	= Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
-
-/* * FUNCTIONS */
+/* FUNCTIONS */
 function count_coaches() {
 	global $total_no_coaches;
 	return $total_no_coaches;
@@ -85,67 +84,66 @@ function rsort_users($a, $b) {
 }
 
 function count_sessions_coached() {
-	global $count_sessions;
-	return $count_sessions;
+    global $count_sessions;
+    return $count_sessions;
 }
 
 function sort_sessions($a, $b) {
-	global $tracking_column;
-	if ($a[$tracking_column] > $b[$tracking_column]) {
-		return 1;
-	} else {
-		return -1;
-	}
+    global $tracking_column;
+    if ($a[$tracking_column] > $b[$tracking_column]) {
+        return 1;
+    } else {
+        return -1;
+    }
 }
 
 function rsort_sessions($a, $b) {
-	global $tracking_column;
-	if ($b[$tracking_column] > $a[$tracking_column]) {
-		return 1;
-	} else {
-		return -1;
-	}
+    global $tracking_column;
+    if ($b[$tracking_column] > $a[$tracking_column]) {
+        return 1;
+    } else {
+        return -1;
+    }
 }
 
-/* * MAIN CODE  */
+/* MAIN CODE  */
 
 if ($is_session_admin) {
-	header('location:session.php');
-	exit;
+    header('location:session.php');
+    exit;
 }
 
 // Get views
 $views = array('admin', 'teacher', 'coach', 'drh');
 $view  = 'teacher';
 if (isset($_GET['view']) && in_array($_GET['view'], $views)) {
-	$view = $_GET['view'];
+    $view = $_GET['view'];
 }
 
 $menu_items = array();
 global $_configuration;
 
 if ($is_platform_admin) {
-	if ($view == 'admin') {
-		$title = get_lang('CoachList');
-		$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=teacher');
-		$menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=admin');
+    if ($view == 'admin') {
+        $title = get_lang('CoachList');
+        $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=teacher');
+        $menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=admin');
         $menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
         $menu_items[] = Display::url(Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php');
-	} else {
-		$menu_items[] = Display::url(Display::return_icon('teacher_na.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM), '');
-		$menu_items[] = Display::url(Display::return_icon('star.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=admin');
+    } else {
+        $menu_items[] = Display::url(Display::return_icon('teacher_na.png', get_lang('TeacherInterface'), array(), ICON_SIZE_MEDIUM), '');
+        $menu_items[] = Display::url(Display::return_icon('star.png', get_lang('AdminInterface'), array(), ICON_SIZE_MEDIUM), api_get_self().'?view=admin');
         $menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'tracking/exams.php');
         $menu_items[] = Display::url(Display::return_icon('statistics.png', get_lang('CurrentCoursesReport'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'mySpace/current_courses.php');
-	}
+    }
 }
 
 if ($is_drh) {
 	$view = 'drh';
-	$menu_items[] = Display::url(Display::return_icon('user_na.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), '#');
-	$menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php');
-	$menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php');
-	$menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php');
-
+    $menu_items[] = Display::url(Display::return_icon('user_na.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), '#');
+    $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php');
+    $menu_items[] = Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php');
+    $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php');
     $menu_items[] = Display::url(Display::return_icon('empty_evaluation.png', get_lang('CompanyReports'), array(), ICON_SIZE_MEDIUM), 'company_reports.php');
     $menu_items[] = Display::url(Display::return_icon('evaluation_rate.png', get_lang('CompanyReportResumed'), array(), ICON_SIZE_MEDIUM), 'company_reports_resumed.php');
 }
@@ -154,26 +152,25 @@ echo '<div id="actions" class="actions">';
 echo '<span style="float:right">';
 
 if ($display == 'useroverview' || $display == 'sessionoverview' || $display == 'courseoverview') {
-	echo '<a href="'.api_get_self().'?display='.$display.'&export=csv&view='.$view.'">';
-    echo Display::return_icon("export_csv.png", get_lang('ExportAsCSV'),array(), 32);
+    echo '<a href="'.api_get_self().'?display='.$display.'&export=csv&view='.$view.'">';
+    echo Display::return_icon("export_csv.png", get_lang('ExportAsCSV'), array(), 32);
     echo '</a>';
 }
 echo '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
-      Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
+    Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
 echo '</span>';
 
-if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview'))) {
-	echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
+if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview','progressoverview'))) {
+    echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
     if (!api_is_platform_admin()) {
         if (api_get_setting('add_users_by_coach') == 'true') {
-	        if ($is_coach) {
-		        echo "<div align=\"right\">";
+            if ($is_coach) {
+                echo "<div align=\"right\">";
                 echo '<a href="user_import.php?id_session='.$session_id.'&action=export&amp;type=xml">'.
                         Display::return_icon('excel.gif', get_lang('ImportUserList')).'&nbsp;'.get_lang('ImportUserList').'</a>';
                 echo "</div><br />";
-	        }
-	    }
-
+            }
+        }
     } else {
         echo "<div align=\"right\">";
         echo '<a href="user_import.php?id_session='.$session_id.'&action=export&amp;type=xml">'.
@@ -186,63 +183,57 @@ if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogres
 
 // Actions menu
 $nb_menu_items = count($menu_items);
-if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview'))) {
-	if ($nb_menu_items > 1) {
-    	foreach ($menu_items as $key => $item) {
-	    	echo $item;
-		}
-	}
+if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) {
+    if ($nb_menu_items > 1) {
+        foreach ($menu_items as $key => $item) {
+            echo $item;
+        }
+    }
 }
 // Create a filter by session
-    $sessionFilter = new FormValidator('course_filter', 'get', '', '', array('class'=> 'form-search'), false);
-    $url = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_session';
+$sessionFilter = new FormValidator('course_filter', 'get', '', '', array('class'=> 'form-search'), false);
+$url = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_session';
+$sessionList = array();
+$sessionId = isset($_GET['session_id']) ? $_GET['session_id'] : null;
+if (!empty($sessionId)) {
     $sessionList = array();
-    $sessionId = isset($_GET['session_id']) ? $_GET['session_id'] : null;
-    if (!empty($sessionId)) {
-        $sessionList = array();
-        $sessionInfo = SessionManager::fetch($sessionId);
-        $sessionList[] = array('id' => $sessionInfo['id'], 'text' => $sessionInfo['name']);
-    }
-    $sessionFilter->addElement('select_ajax', 'session_name', get_lang('SearchCourseBySession'), null, array('url' => $url, 'defaults' => $sessionList));
-    $courseListUrl = api_get_self();
-
-    #show filter by session
-    if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview'))) {
-        echo '<div class="pull-right">';
-        echo $sessionFilter->return_form();
-        echo '</div>';
-        echo '<script>$(function() {
-            $("#session_name").on("change", function() {
-               var sessionId = $(this).val();
-               window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId;
-            });
-            });</script>';
-    }
+    $sessionInfo = SessionManager::fetch($sessionId);
+    $sessionList[] = array('id' => $sessionInfo['id'], 'text' => $sessionInfo['name']);
+}
+$sessionFilter->addElement('select_ajax', 'session_name', get_lang('SearchCourseBySession'), null, array('url' => $url, 'defaults' => $sessionList));
+$courseListUrl = api_get_self();
+
+#show filter by session
+if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) {
+    echo '<div class="pull-right">';
+    echo $sessionFilter->return_form();
+    echo '</div>';
+    echo '<script>
+    $(function() {
+        $("#session_name").on("change", function() {
+           var sessionId = $(this).val();
+           window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId;
+        });
+    });
+    </script>';
+}
 
 echo '</div>';
 
 if (empty($session_id)) {
 
 	// Getting courses followed by a coach (No session courses)
-	$courses  = CourseManager::get_course_list_as_coach($user_id, false);
+    $courses  = CourseManager::get_course_list_as_coach($user_id, false);
 
-	if (isset($courses[0])) {
-		$courses = $courses[0];
-	}
-
-	// Getting students from courses and courses in sessions (To show the total students that the user follows)
-	$students = CourseManager::get_user_list_from_courses_as_coach($user_id);
-    /*$studentList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh', api_get_user_id());
-    $students = array();
-    foreach ($studentList as $studentData) {
-        $students[] = $studentData['user_id'];
-    }*/
+    if (isset($courses[0])) {
+        $courses = $courses[0];
+    }
 
-	// Sessions for the coach
-	$sessions = Tracking::get_sessions_coached_by_user($user_id);
+    // Getting students from courses and courses in sessions (To show the total students that the user follows)
+    $students = CourseManager::get_user_list_from_courses_as_coach($user_id);
 
-	// If is drh
-	if ($is_drh) {
+    // If is drh
+    if ($is_drh) {
         if (api_drh_can_access_all_session_content()) {
             $studentList = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus('drh_all', api_get_user_id());
 
@@ -265,27 +256,28 @@ if (empty($session_id)) {
             }
             $sessions = SessionManager::get_sessions_followed_by_drh($user_id);
         }
-	}
+    } else {
+        // Sessions for the coach
+        $sessions = Tracking::get_sessions_coached_by_user($user_id);
+    }
 
-    //var_dump(count($students));exit;
+    // Courses for the user
+    $count_courses = count($courses);
 
-	// Courses for the user
-	$count_courses = count($courses);
+    // Sessions for the user
+    $count_sessions = count($sessions);
 
-	// Sessions for the user
-	$count_sessions = count($sessions);
+    // Students
+    $nb_students = count($students);
 
-	// Students
-	$nb_students = count($students);
+    $total_time_spent 			= 0;
+    $total_courses 				= 0;
+    $avg_total_progress 		= 0;
+    $avg_results_to_exercises 	= 0;
+    $nb_inactive_students 		= 0;
+    $nb_posts = $nb_assignments = 0;
 
-	$total_time_spent 			= 0;
-	$total_courses 				= 0;
-	$avg_total_progress 		= 0;
-	$avg_results_to_exercises 	= 0;
-	$nb_inactive_students 		= 0;
-	$nb_posts = $nb_assignments = 0;
-
-	if (!empty($students)) {
+    if (!empty($students)) {
         foreach ($students as $student_id) {
             // inactive students
             $last_connection_date = Tracking :: get_last_connection_date($student_id, true, true);
@@ -310,8 +302,9 @@ if (empty($session_id)) {
                     $avg_student_progress  += Tracking :: get_avg_student_progress($student_id, $course_code);
                     $myavg_temp 			= Tracking :: get_avg_student_score($student_id, $course_code);
 
-                     if (is_numeric($myavg_temp))
+                     if (is_numeric($myavg_temp)) {
                         $avg_student_score += $myavg_temp;
+                     }
 
                     if ($nb_posts !== null && $nb_assignments !== null && $avg_student_progress !== null && $avg_student_score !== null) {
                         //if one of these scores is null, it means that we had a problem connecting to the right database, so don't count it in
@@ -329,55 +322,57 @@ if (empty($session_id)) {
         }
     }
 
-	if ($nb_students > 0 && $view != 'admin') {
-
-		// average progress
-		$avg_total_progress = $avg_total_progress / $nb_students;
-		// average results to the tests
-		$avg_results_to_exercises = $avg_results_to_exercises / $nb_students;
-		// average courses by student
-		$avg_courses_per_student = round($count_courses / $nb_students, 2);
-		// average time spent on the platform
-		$avg_time_spent = $total_time_spent / $nb_students;
-		// average assignments
-		$nb_assignments = $nb_assignments / $nb_students;
-		// average posts
-		$nb_posts = $nb_posts / $nb_students;
+    if ($nb_students > 0 && $view != 'admin') {
+
+        // average progress
+        $avg_total_progress = $avg_total_progress / $nb_students;
+        // average results to the tests
+        $avg_results_to_exercises = $avg_results_to_exercises / $nb_students;
+        // average courses by student
+        $avg_courses_per_student = round($count_courses / $nb_students, 2);
+        // average time spent on the platform
+        $avg_time_spent = $total_time_spent / $nb_students;
+        // average assignments
+        $nb_assignments = $nb_assignments / $nb_students;
+        // average posts
+        $nb_posts = $nb_posts / $nb_students;
 
         echo Display::page_subheader('<img src="'.api_get_path(WEB_IMG_PATH).'teachers.gif">&nbsp;'.get_lang('Overview'));
 
         echo '<div class="report_section">
-					<table class="table table-bordered">
+                    <table class="table table-bordered">
                         <tr>
-							<td>'.get_lang('FollowedUsers').'</td>
-							<td align="right">'.$nb_students.'</td>
-						</tr>
+                            <td>'.get_lang('FollowedUsers').'</td>
+                            <td align="right">'.$nb_students.'</td>
+                        </tr>
                         <tr>
-							<td>'.get_lang('FollowedCourses').'</td>
-							<td align="right">'.$count_courses.'</td>
-						</tr>
+                            <td>'.get_lang('FollowedCourses').'</td>
+                            <td align="right">'.$count_courses.'</td>
+                        </tr>
                         <tr>
-							<td>'.get_lang('FollowedSessions').'</td>
-							<td align="right">'.$count_sessions.'</td>
-						</tr>
+                            <td>'.get_lang('FollowedSessions').'</td>
+                            <td align="right">'.$count_sessions.'</td>
+                        </tr>
                         </table>';
         echo '</div>';
 
-		echo Display::page_subheader('<img src="'.api_get_path(WEB_IMG_PATH).'students.gif">
-		    &nbsp;'.get_lang('Students').' ('.$nb_students.')');
+        echo Display::page_subheader(Display::return_icon('students.gif').'&nbsp;'.get_lang('Students').' ('.$nb_students.')');
+
+        if ($export_csv) {
+            //csv part
+            $csv_content[] = array(get_lang('Students', ''));
+            $csv_content[] = array(get_lang('InactivesStudents', ''), $nb_inactive_students );
+            $csv_content[] = array(get_lang('AverageTimeSpentOnThePlatform', ''), $avg_time_spent);
+            $csv_content[] = array(get_lang('AverageCoursePerStudent', ''), $avg_courses_per_student);
+            $csv_content[] = array(get_lang('AverageProgressInLearnpath', ''), is_null($avg_total_progress) ? null : round($avg_total_progress, 2).'%');
+            $csv_content[] = array(get_lang('AverageResultsToTheExercices', ''), is_null($avg_results_to_exercises) ? null : round($avg_results_to_exercises, 2).'%');
+            $csv_content[] = array(get_lang('AveragePostsInForum', ''), $nb_posts);
+            $csv_content[] = array(get_lang('AverageAssignments', ''), $nb_assignments);
+            $csv_content[] = array();
+        } else {
 
-		if ($export_csv) {
-			//csv part
-			$csv_content[] = array(get_lang('Students', ''));
-			$csv_content[] = array(get_lang('InactivesStudents', ''), $nb_inactive_students );
-			$csv_content[] = array(get_lang('AverageTimeSpentOnThePlatform', ''), $avg_time_spent);
-			$csv_content[] = array(get_lang('AverageCoursePerStudent', ''), $avg_courses_per_student);
-			$csv_content[] = array(get_lang('AverageProgressInLearnpath', ''), is_null($avg_total_progress) ? null : round($avg_total_progress, 2).'%');
-			$csv_content[] = array(get_lang('AverageResultsToTheExercices', ''), is_null($avg_results_to_exercises) ? null : round($avg_results_to_exercises, 2).'%');
-			$csv_content[] = array(get_lang('AveragePostsInForum', ''), $nb_posts);
-			$csv_content[] = array(get_lang('AverageAssignments', ''), $nb_assignments);
-			$csv_content[] = array();
-		} else {
+            $countActiveUsers = SessionManager::getCountUserTracking(null, 1);
+            $countInactiveUsers = SessionManager::getCountUserTracking(null, 0);
 
             $form = new FormValidator('search_user', 'get', api_get_path(WEB_CODE_PATH).'mySpace/student.php');
             $form->addElement('text', 'keyword', get_lang('User'));
@@ -385,60 +380,66 @@ if (empty($session_id)) {
             $form->display();
 
             // html part
-			echo '<div class="report_section">
-					<table class="table table-bordered">
+            echo '<div class="report_section">
+                    <table class="table table-bordered">
                         <tr>
-							<td>'.get_lang('AverageCoursePerStudent').'</td>
-							<td align="right">'.(is_null($avg_courses_per_student) ? '' : $avg_courses_per_student).'</td>
-						</tr>
+                            <td>'.Display::url(get_lang('ActiveUsers'), api_get_path(WEB_CODE_PATH).'mySpace/student.php?active=1').'</td>
+                            <td align="right">'.$countActiveUsers.'</td>
+                        </tr>
+                         <tr>
+                            <td>'.Display::url(get_lang('InactiveUsers'), api_get_path(WEB_CODE_PATH).'mySpace/student.php?active=0').'</td>
+                            <td align="right">'.$countInactiveUsers.'</td>
+                        </tr>
+
                         <tr>
-							<td>'.get_lang('InactivesStudents').'</td>
-							<td align="right">'.$nb_inactive_students.'</td>
-						</tr>
-						<tr>
-							<td>'.get_lang('AverageTimeSpentOnThePlatform').'</td>
-							<td align="right">'.(is_null($avg_time_spent) ? '' : api_time_to_hms($avg_time_spent)).'</td>
-						</tr>
-						<tr>
-							<td>'.get_lang('AverageProgressInLearnpath').'</td>
-							<td align="right">'.(is_null($avg_total_progress) ? '' : round($avg_total_progress, 2).'%').'</td>
-						</tr>
-						<tr>
-							<td>'.get_lang('AvgCourseScore').'</td>
-							<td align="right">'.(is_null($avg_results_to_exercises) ? '' : round($avg_results_to_exercises, 2).'%').'</td>
-						</tr>
-						<tr>
-							<td>'.get_lang('AveragePostsInForum').'</td>
-							<td align="right">'.(is_null($nb_posts) ? '' : round($nb_posts, 2)).'</td>
-						</tr>
-						<tr>
-							<td>'.get_lang('AverageAssignments').'</td>
-							<td align="right">'.(is_null($nb_assignments) ? '' : round($nb_assignments, 2)).'</td>
-						</tr>
-					</table>
-					<a class="btn" href="student.php">
-					'.get_lang('SeeStudentList').'
-					</a>
-				 </div><br />';
-		}
-	} else {
-		$avg_total_progress = null;
-		$avg_results_to_exercises = null;
-		$avg_courses_per_student = null;
-		$avg_time_spent = null;
-		$nb_assignments = null;
-		$nb_posts = null;
-	}
+                            <td>'.get_lang('AverageCoursePerStudent').'</td>
+                            <td align="right">'.(is_null($avg_courses_per_student) ? '' : $avg_courses_per_student).'</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('InactivesStudents').'</td>
+                            <td align="right">'.$nb_inactive_students.'</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('AverageTimeSpentOnThePlatform').'</td>
+                            <td align="right">'.(is_null($avg_time_spent) ? '' : api_time_to_hms($avg_time_spent)).'</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('AverageProgressInLearnpath').'</td>
+                            <td align="right">'.(is_null($avg_total_progress) ? '' : round($avg_total_progress, 2).'%').'</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('AvgCourseScore').'</td>
+                            <td align="right">'.(is_null($avg_results_to_exercises) ? '' : round($avg_results_to_exercises, 2).'%').'</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('AveragePostsInForum').'</td>
+                            <td align="right">'.(is_null($nb_posts) ? '' : round($nb_posts, 2)).'</td>
+                        </tr>
+                        <tr>
+                            <td>'.get_lang('AverageAssignments').'</td>
+                            <td align="right">'.(is_null($nb_assignments) ? '' : round($nb_assignments, 2)).'</td>
+                        </tr>
+                    </table>
+                    <a class="btn" href="'.api_get_path(WEB_CODE_PATH).'mySpace/student.php'.'">
+                    '.get_lang('SeeStudentList').'
+                    </a>
+                 </div><br />';
+        }
+    } else {
+        $avg_total_progress = null;
+        $avg_results_to_exercises = null;
+        $avg_courses_per_student = null;
+        $avg_time_spent = null;
+        $nb_assignments = null;
+        $nb_posts = null;
+    }
 } else {
-	$courses = Tracking::get_courses_followed_by_coach($user_id, $session_id);
-
     // If is drh
 	if ($is_drh) {
         $courses_of_the_platform = CourseManager::get_courses_followed_by_drh($user_id);
         $courses_from_session = SessionManager::get_course_list_by_session_id($session_id);
 
         $courses = array();
-
         foreach ($courses_from_session as $course_item) {
             if (api_drh_can_access_all_session_content()) {
                 $courses[$course_item['code']] = $course_item['code'];
@@ -452,7 +453,9 @@ if (empty($session_id)) {
         if (empty($courses)) {
             Display::display_warning_message(get_lang('NoResults'));
         }
-	}
+	} else {
+        $courses = Tracking::get_courses_followed_by_coach($user_id, $session_id);
+    }
 
     //Courses for the user
     $count_courses = count($courses);
@@ -465,7 +468,7 @@ if ($count_courses || $count_sessions) {
 	//If we are in course
 	if (empty($session_id)) {
 		if ($count_courses) {
-			$title = '<img src="'.api_get_path(WEB_IMG_PATH).'course.gif"> '.get_lang('Courses').' ('.$count_courses.') ';
+			$title = Display::return_icon('course.gif').' '.get_lang('Courses').' ('.$count_courses.') ';
 		}
 	} else {
 		//If we are in Course Session
@@ -512,68 +515,38 @@ if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array
 	// Display list of sessions
 
 	if ($count_sessions > 0 && !isset($_GET['session_id'])) {
-		echo Display::page_subheader('<img src="'.api_get_path(WEB_IMG_PATH).'session.png">&nbsp;'.get_lang('Sessions').' ('.$count_sessions.')');
-
-		$table = new SortableTable('tracking_sessions_myspace', 'count_sessions_coached');
-		$table->set_header(0, get_lang('Title'), false);
-        $table->set_header(1, get_lang('Date'), false);
-        $table->set_header(2, get_lang('NbCoursesPerSession'), false);
-		$table->set_header(3, get_lang('NbStudentPerSession'), false);
-		$table->set_header(4, get_lang('Details'), false);
-
-		$all_data = array();
-		foreach ($sessions as $session) {
-            if (api_drh_can_access_all_session_content()) {
-                $count_courses_in_session = count(SessionManager::get_course_list_by_session_id($session['id']));
-            } else {
-                $count_courses_in_session = count(Tracking::get_courses_followed_by_coach($user_id, $session['id']));
-            }
-
-            $count_users_in_session = count(SessionManager::get_users_by_session($session['id'], 0));
-			$row = array();
-			$row[] = $session['name'];
-
-            $session_date = array();
-			if (!empty($session['date_start']) && $session['date_start'] != '0000-00-00') {
-                $session_date[] = get_lang('From').' '.api_format_date($session['date_start'], DATE_FORMAT_SHORT);
-            }
-
-            if (!empty($session['date_end']) && $session['date_end'] != '0000-00-00') {
-                $session_date[] = get_lang('Until').' '.api_format_date($session['date_end'], DATE_FORMAT_SHORT);
-            }
-
-            if (empty($session_date)) {
-                $session_date_string = '-';
-            } else {
-                $session_date_string = implode(' ', $session_date);
-            }
-
-            $row[] = $session_date_string;
-            $row[] = $count_courses_in_session;
-            $row[] = $count_users_in_session;
-			$row[] = '<a href="'.api_get_self().'?session_id='.$session['id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
-			$all_data[] = $row;
-		}
-
-		if (!isset($tracking_column)) {
-			$tracking_column = 0;
-		}
-
-		if (isset($_GET['tracking_direction']) &&  $_GET['tracking_direction'] == 'DESC') {
-			usort($all_data, 'rsort_sessions');
-		} else {
-			usort($all_data, 'sort_sessions');
-		}
-
-		if ($export_csv) {
-			usort($csv_content, 'sort_sessions');
-		}
-
-		foreach ($all_data as $row) {
-			$table -> addRow($row);
-		}
-
-		/*  Start session over view stats */
+		echo Display::page_subheader(Display::return_icon('session.png').' '.get_lang('Sessions').' ('.$count_sessions.')');
+
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions_tracking';
+
+        //The order is important you need to check the the $column variable in the model.ajax.php file
+        $columns = array(
+            get_lang('Title'),
+            get_lang('Date'),
+            get_lang('NbCoursesPerSession'),
+            get_lang('NbStudentPerSession'),
+            get_lang('Details')
+        );
+
+        // Column config
+        $columnModel   = array(
+            array('name'=>'name',               'index'=>'name',        'width'=>'255',   'align'=>'left'),
+            array('name'=>'date',                'index'=>'date', 'width'=>'150',  'align'=>'left','sortable'=>'false'),
+            array('name'=>'course_per_session',  'index'=>'course_per_session',     'width'=>'150','sortable'=>'false'),
+            array('name'=>'student_per_session', 'index'=>'student_per_session',     'width'=>'100','sortable'=>'false'),
+            array('name'=>'details',             'index'=>'details',     'width'=>'100','sortable'=>'false'),
+        );
+
+        $extraParams = array(
+            'autowidth' => 'true',
+            'height' => 'auto'
+        );
+
+        $js = '<script>
+        $(function() {
+            '.Display::grid_js('session_tracking', $url, $columns, $columnModel, $extraParams, array(), null, true).'
+        });
+        </script>';
 
 		$nb_sessions_past = $nb_sessions_current = 0;
 		$courses = array();
@@ -601,7 +574,6 @@ if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array
 			$csv_content[] = array(get_lang('Sessions', ''));
 			$csv_content[] = array(get_lang('NbActiveSessions', '').';'.$nb_sessions_current);
 			$csv_content[] = array(get_lang('NbInactiveSessions', '').';'.$nb_sessions_past);
-			//$csv_content[] = array(get_lang('NbFutureSessions', '').';'.$nb_sessions_future);
             $csv_content[] = array(get_lang('NbCoursesPerSession', '').';'.$nb_courses_per_session);
 			$csv_content[] = array(get_lang('NbStudentPerSession', '').';'.$nb_students_per_session);
 			$csv_content[] = array();
@@ -620,9 +592,9 @@ if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array
 				</table>
 			</div>';
 		}
-		/*  End session overview */
-		$table -> display();
-	}
+        echo $js;
+        echo Display::grid_html('session_tracking');
+    }
 }
 
 if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourstudents') {
@@ -634,13 +606,13 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
 	}
 	echo ' | <a href="'.api_get_self().'?view=admin&amp;display=sessionoverview">'.get_lang('DisplaySessionOverview').'</a>';
 	echo ' | <a href="'.api_get_self().'?view=admin&amp;display=accessoverview">'.get_lang('DisplayAccessOverview').'</a>';
-    echo ' | <a href="'.api_get_self().'?view=admin&amp;display=lpprogressoverview">'.get_lang('Displaylpprogressoverview').'</a>';
+    echo ' | <a href="'.api_get_self().'?view=admin&amp;display=lpprogressoverview">'.get_lang('DisplayLpProgressOverview').'</a>';
+    echo ' | <a href="'.api_get_self().'?view=admin&amp;display=progressoverview">'.get_lang('DisplayProgressOverview').'</a>';
 	echo ' | <a href="'.api_get_self().'?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';
     echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin">'.get_lang('LPQuestionListResults').'</a>';
     echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin">'.get_lang('LPExerciseResultsBySession').'</a>';
-
-
 	echo '<br /><br />';
+
 	if ($display === 'useroverview') {
 		MySpace::display_tracking_user_overview();
 	} else if($display == 'sessionoverview') {
@@ -657,6 +629,12 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
         } else {
             Display::display_warning_message(get_lang('ChooseSession'));
         }
+    } else if($display == 'progressoverview') {
+        if (!empty($_GET['session_id'])) {
+            echo MySpace::display_tracking_progress_overview($_GET['session_id']);
+        } else {
+            Display::display_warning_message(get_lang('ChooseSession'));
+        }
 	} else if($display == 'courseoverview') {
 		MySpace::display_tracking_course_overview();
 	} else {
@@ -678,18 +656,18 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
 		$parameters['view'] = 'admin';
 		$table->set_additional_parameters($parameters);
 		if ($is_western_name_order) {
-			$table -> set_header(0, get_lang('FirstName'), true);
-			$table -> set_header(1, get_lang('LastName'), true);
+			$table->set_header(0, get_lang('FirstName'), true);
+			$table->set_header(1, get_lang('LastName'), true);
 		} else {
-			$table -> set_header(0, get_lang('LastName'), true);
-			$table -> set_header(1, get_lang('FirstName'), true);
+			$table->set_header(0, get_lang('LastName'), true);
+			$table->set_header(1, get_lang('FirstName'), true);
 		}
-		$table -> set_header(2, get_lang('TimeSpentOnThePlatform'), false);
-		$table -> set_header(3, get_lang('LastConnexion'), false);
-		$table -> set_header(4, get_lang('NbStudents'), false);
-		$table -> set_header(5, get_lang('CountCours'), false);
-		$table -> set_header(6, get_lang('NumberOfSessions'), false);
-		$table -> set_header(7, get_lang('Sessions'), false);
+		$table->set_header(2, get_lang('TimeSpentOnThePlatform'), false);
+		$table->set_header(3, get_lang('LastConnexion'), false);
+		$table->set_header(4, get_lang('NbStudents'), false);
+		$table->set_header(5, get_lang('CountCours'), false);
+		$table->set_header(6, get_lang('NumberOfSessions'), false);
+		$table->set_header(7, get_lang('Sessions'), false);
 
 		if ($is_western_name_order) {
 			$csv_header[] = array (
@@ -830,13 +808,13 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
 		}
 
 		foreach ($all_datas as $row) {
-			$table -> addRow($row, 'align="right"');
+			$table->addRow($row, 'align="right"');
 		}
-		$table -> display();
+		$table->display();
 	}
 }
 
-// send the csv file if asked
+// Send the csv file if asked
 if ($export_csv) {
 	ob_end_clean();
 	Export :: export_table_csv($csv_content, 'reporting_index');
@@ -847,6 +825,7 @@ if ($export_csv) {
 if (!$export_csv) {
 	Display::display_footer();
 }
+
 /**
  * Get number of courses for sortable with pagination
  * @return int

+ 114 - 0
main/mySpace/myspace.lib.php

@@ -293,6 +293,120 @@ class MySpace {
         $table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
 
 
+        $return = '<script>$(function() {'. $table . '});</script>';
+        $return .= Display::grid_html('lps');
+        return $return;
+    }
+    /**
+     * Display a sortable table that contains an overview off all the progress of the user in a session
+     * @author César Perales <cesar.perales@beeznest.com>, Beeznest Team
+     */
+    function display_tracking_progress_overview($sessionId = 0) {
+
+       //The order is important you need to check the the $column variable in the model.ajax.php file
+        $columns = array(
+            get_lang('LastName'),
+            get_lang('FirstName'),
+            get_lang('Username'),
+            #get_lang('Profile'),
+            get_lang('Total'),
+            get_lang('CourseDescription'),
+            get_lang('Lessons'),
+            get_lang('Exercises'),
+            get_lang('Forums'),
+            get_lang('Homeworks'),
+            get_lang('Wikis'),
+            get_lang('Surveys'),
+            //course description
+            get_lang('CourseDescriptionProgress'),
+            //Exercises
+            get_lang('LessonsTotal'),
+            get_lang('LessonsDone'),
+            get_lang('LessonsLeft'),
+            get_lang('LessonsProgress'),
+            //Exercises
+            get_lang('ExercisesTotal'),
+            get_lang('ExercisesDone'),
+            get_lang('ExercisesLeft'),
+            get_lang('ExercisesProgress'),
+            //Forums
+            get_lang('ForumsTotal'),
+            get_lang('ForumsDone'),
+            get_lang('ForumsLeft'),
+            get_lang('ForumsProgress'),
+            //Assignments
+            get_lang('AssignmentsTotal'),
+            get_lang('AssignmentsDone'),
+            get_lang('AssignmentsLeft'),
+            get_lang('AssignmentsProgress'),
+            //Wiki
+            get_lang('WikiTotal'),
+            get_lang('WikiRevisions'),
+            get_lang('WikiRead'),
+            get_lang('WikiUnread'),
+            get_lang('WikiProgress'),
+            //Surveys
+            get_lang('SurveysTotal'),
+            get_lang('SurveysDone'),
+            get_lang('SurveysLeft'),
+            get_lang('SurveysProgress'),
+        );
+
+        //Column config
+        $column_model   = array(
+            array('name'=>'lastname',   'index'=>'lastname',    'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'firstname',  'index'=>'firstname',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'username',   'index'=>'username',    'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            #array('name'=>'profile',   'index'=>'username',    'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'total',      'index'=>'total',       'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'courses',    'index'=>'courses',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons',    'index'=>'lessons',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises',  'index'=>'exercises',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums',     'index'=>'forums',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'homeworks',  'index'=>'homeworks',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wikis',      'index'=>'wikis',       'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys',    'index'=>'surveys',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Course description
+            array('name'=>'course_description_progress',    'index'=>'course_description_progress',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Lessons
+            array('name'=>'lessons_total',    'index'=>'lessons_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons_done',     'index'=>'lessons_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons_left',     'index'=>'lessons_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'lessons_progress', 'index'=>'lessons_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Exercises
+            array('name'=>'exercises_total',    'index'=>'exercises_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises_done',     'index'=>'exercises_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises_left',     'index'=>'exercises_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'exercises_progress', 'index'=>'exercises_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Assignments
+            array('name'=>'forums_total',    'index'=>'forums_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums_done',     'index'=>'forums_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums_left',     'index'=>'forums_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'forums_progress', 'index'=>'forums_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Assignments
+            array('name'=>'assigments_total',    'index'=>'assigments_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'assigments_done',     'index'=>'assigments_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'assigments_left',     'index'=>'assigments_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'assigments_progress', 'index'=>'assigments_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Assignments
+            array('name'=>'wiki_total',         'index'=>'wiki_total',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_revisions',     'index'=>'wiki_revisions',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_read',          'index'=>'wiki_read',       'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_unread',        'index'=>'wiki_unread',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'wiki_progress',      'index'=>'wiki_progress',   'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            //Surveys
+            array('name'=>'surveys_total',    'index'=>'surveys_total',     'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys_done',     'index'=>'surveys_done',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys_left',     'index'=>'surveys_left',      'width'=>'100',  'align'=>'left', 'search' => 'true'),
+            array('name'=>'surveys_progress', 'index'=>'surveys_progress',  'width'=>'100',  'align'=>'left', 'search' => 'true'),
+        );
+
+        $action_links = '';
+        // jqgrid will use this URL to do the selects
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id=' . intval($sessionId);
+        $table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
+
+
         $return = '<script>$(function() {'. $table . '});</script>';
         $return .= Display::grid_html('lps');
         return $return;

+ 18 - 60
main/mySpace/student.php

@@ -24,68 +24,23 @@ $this_section = SECTION_TRACKING;
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
 
 if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
-	$interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
+    $interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
 }
 
 if (isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $_GET["type"] == "coach") {
- 	$interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
+    $interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
 }
 
-function get_count_users() {
-    global $keyword;
-    if (api_is_drh()) {
-        if (api_drh_can_access_all_session_content()) {
-            $count = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
-                'drh_all',
-                api_get_user_id(),
-                true,
-                null,
-                null,
-                null,
-                null,
-                $keyword
-            );
-        } else {
-            $count = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
-                'drh',
-                api_get_user_id(),
-                true,
-                null,
-                null,
-                null,
-                null,
-                $keyword
-            );
-        }
-    } else {
-        if (api_is_platform_admin()) {
-            $count = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
-                'admin',
-                api_get_user_id(),
-                true,
-                null,
-                null,
-                null,
-                null,
-                $keyword);
-        } else {
-            $count = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
-                'teacher',
-                api_get_user_id(),
-                true,
-                null,
-                null,
-                null,
-                null,
-                $keyword
-            );
-        }
-    }
-    return $count;
+function get_count_users($keyword = null, $active = null)
+{
+    return SessionManager::getCountUserTracking($keyword, $active);
 }
 
-function get_users($from, $number_of_items, $column, $direction) {
-    global $keyword;
+function get_users($from, $number_of_items, $column, $direction)
+{
+    $active = isset($_GET['active']) ? $_GET['active'] : null;
+    $keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
+
     $is_western_name_order = api_is_western_name_order();
     $coach_id = api_get_user_id();
     $column = 'u.user_id';
@@ -100,7 +55,8 @@ function get_users($from, $number_of_items, $column, $direction) {
                 $number_of_items,
                 $column,
                 $direction,
-                $keyword
+                $keyword,
+                $active
             );
         } else {
             $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
@@ -111,7 +67,8 @@ function get_users($from, $number_of_items, $column, $direction) {
                 $number_of_items,
                 $column,
                 $direction,
-                $keyword
+                $keyword,
+                $active
             );
         }
     } else {
@@ -124,7 +81,8 @@ function get_users($from, $number_of_items, $column, $direction) {
                 $number_of_items,
                 $column,
                 $direction,
-                $keyword
+                $keyword,
+                $active
             );
         } else {
             $students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
@@ -135,7 +93,8 @@ function get_users($from, $number_of_items, $column, $direction) {
                 $number_of_items,
                 $column,
                 $direction,
-                $keyword
+                $keyword,
+                $active
             );
         }
     }
@@ -144,7 +103,6 @@ function get_users($from, $number_of_items, $column, $direction) {
 
     foreach ($students as $student_data) {
         $student_id = $student_data['user_id'];
-
         if (isset($_GET['id_session'])) {
             $courses = Tracking :: get_course_list_in_session_from_student($student_id, $_GET['id_session']);
         }

+ 2 - 6
main/survey/survey.lib.php

@@ -1265,7 +1265,6 @@ class survey_manager
 	 */
 	static function get_people_who_filled_survey($survey_id, $all_user_info = false, $course_id = null)
     {
-
 		// Database table definition
 		$table_survey_answer 		= Database :: get_course_table(TABLE_SURVEY_ANSWER);
 		$table_user					= Database :: get_main_table(TABLE_MAIN_USER);
@@ -1273,9 +1272,6 @@ class survey_manager
 		// Variable initialisation
 		$return = array();
 
-		// Getting the survey information
-		$survey_data	= survey_manager::get_survey($survey_id);
-
 		if (empty($course_id)) {
             $course_id  = api_get_course_int_id();
         } else {
@@ -1288,11 +1284,11 @@ class survey_manager
 						FROM $table_survey_answer answered_user
 						LEFT JOIN $table_user as user ON answered_user.user = user.user_id
 						WHERE 	answered_user.c_id = $course_id AND
-								survey_id= '".Database::escape_string($survey_data['survey_id'])."' ".
+								survey_id= '".Database::escape_string($survey_id)."' ".
                         $order_clause;
 		} else {
 			$sql = "SELECT DISTINCT user FROM $table_survey_answer
-			        WHERE c_id = $course_id AND survey_id= '".Database::escape_string($survey_data['survey_id'])."'  ";
+			        WHERE c_id = $course_id AND survey_id= '".Database::escape_string($survey_id)."'  ";
 		}
 
 		$res = Database::query($sql);

+ 133 - 71
main/user/user.php

@@ -38,16 +38,14 @@ require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
 global $_configuration;
 
 if (!api_is_platform_admin(true)) {
-	if (!api_is_course_admin() && !api_is_coach()) {
-		if (api_get_course_setting('allow_user_view_user_list') == 0) {
-			api_not_allowed(true);
-		}
-	}
+    if (!api_is_course_admin() && !api_is_coach()) {
+        if (api_get_course_setting('allow_user_view_user_list') == 0) {
+            api_not_allowed(true);
+        }
+    }
 }
 
-/*
-	Constants and variables
-*/
+/* Constants and variables */
 $course_code            = Database::escape_string(api_get_course_id());
 $session_id             = api_get_session_id();
 $is_western_name_order 	= api_is_western_name_order();
@@ -62,40 +60,40 @@ if (!empty($session_id)) {
 
 /* Unregistering a user section	*/
 if (api_is_allowed_to_edit(null, true)) {
-	if (isset($_POST['action'])) {
-		switch ($_POST['action']) {
-			case 'unsubscribe' :
-				// Make sure we don't unsubscribe current user from the course
-				if (is_array($_POST['user'])) {
-					$user_ids = array_diff($_POST['user'], array($_user['user_id']));
-					if (count($user_ids) > 0) {
-						CourseManager::unsubscribe_user($user_ids, $_SESSION['_course']['sysCode']);
-						$message = get_lang('UsersUnsubscribed');
-					}
-				}
-		}
-	}
+    if (isset($_POST['action'])) {
+        switch ($_POST['action']) {
+            case 'unsubscribe':
+                // Make sure we don't unsubscribe current user from the course
+                if (is_array($_POST['user'])) {
+                    $user_ids = array_diff($_POST['user'], array($_user['user_id']));
+                    if (count($user_ids) > 0) {
+                        CourseManager::unsubscribe_user($user_ids, $_SESSION['_course']['sysCode']);
+                        $message = get_lang('UsersUnsubscribed');
+                    }
+                }
+        }
+    }
 }
 
 $user_image_pdf_size = 80;
 
 if (api_is_allowed_to_edit(null, true)) {
-	if (isset($_GET['action'])) {
-		switch ($_GET['action']) {
-			case 'export' :
-				$table_course_user      = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-				$table_users            = Database::get_main_table(TABLE_MAIN_USER);
-				$is_western_name_order  = api_is_western_name_order();
-
-				$data = array();
-				$a_users = array();
-
-				if (api_is_multiple_url_enabled()) {
-					$current_access_url_id = api_get_current_access_url_id();
-				}
+    if (isset($_GET['action'])) {
+        switch ($_GET['action']) {
+            case 'export':
+                $table_course_user      = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+                $table_users            = Database::get_main_table(TABLE_MAIN_USER);
+                $is_western_name_order  = api_is_western_name_order();
+
+                $data = array();
+                $a_users = array();
+
+                if (api_is_multiple_url_enabled()) {
+                    $current_access_url_id = api_get_current_access_url_id();
+                }
 
-				$extra_fields = UserManager::get_extra_user_data(api_get_user_id(), false, false, false, true);
-				$extra_fields = array_keys($extra_fields);
+                $extra_fields = UserManager::get_extra_user_data(api_get_user_id(), false, false, false, true);
+                $extra_fields = array_keys($extra_fields);
 
                 $select_email_condition = '';
 
@@ -114,7 +112,7 @@ if (api_is_allowed_to_edit(null, true)) {
                     }
                 }
 
-                 $legal = '';
+                $legal = '';
 
                 if (isset($course_info['activate_legal']) AND $course_info['activate_legal'] == 1) {
                     $legal = ', legal_agreement';
@@ -132,8 +130,7 @@ if (api_is_allowed_to_edit(null, true)) {
 
 				$a_users[0] = array_merge($a_users[0], $extra_fields);
 
-				// users subscribed to the course through a session
-
+				// users subscribed to the course through a session.
                 if (api_get_session_id()) {
                     $table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
                     $sql_query = "SELECT DISTINCT
@@ -325,8 +322,7 @@ if (api_is_allowed_to_edit(null, true)) {
     }
 }
 
-
-/*		FUNCTIONS	*/
+/* FUNCTIONS */
 
 function display_user_search_form() {
 	echo '<form method="get" action="user.php">';
@@ -354,11 +350,9 @@ if ($origin != 'learnpath') {
     Display::display_reduced_header();
 }
 
+/* MAIN CODE */
 
-
-/*		MAIN CODE*/
-
-//statistics
+// Statistics
 event_access_tool(TOOL_USER);
 
 /*	Setting the permissions for this page */
@@ -389,8 +383,6 @@ if ( api_is_allowed_to_edit(null, true)) {
         $actions .= ' <a class="btn" href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';
     }
 
-    //$actions .= ' <a class="btn" href="social_groups.php?'.api_get_cidreq().'">'.get_lang('SocialGroups').'</a>';
-
 	// Build search-form
 	$form = new FormValidator('search_user', 'get', '', '', null, false);
 	$renderer = $form->defaultRenderer();
@@ -403,38 +395,89 @@ if ( api_is_allowed_to_edit(null, true)) {
 }
 
 if (isset($message)) {
-	Display::display_confirmation_message($message);
+    Display::display_confirmation_message($message);
 }
 
-/* 		DISPLAY LIST OF USERS */
+/* DISPLAY LIST OF USERS */
 /**
- *  * Get the users to display on the current page.
+ * Get the users to display on the current page.
  */
 function get_number_of_users() {
 	$counter = 0;
-	if (!empty($_SESSION["id_session"])){
-		$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], $_SESSION['id_session']);
-
+    $sessionId = api_get_session_id();
+    $courseCode = api_get_course_id();
+    $active = isset($_GET['active']) ? $_GET['active'] : null;
+
+	if (!empty($sessionId)) {
+        $a_course_users = CourseManager::get_user_list_from_course_code(
+            $courseCode,
+            $sessionId,
+            null,
+            null,
+            null,
+            null,
+            false,
+            false,
+            null,
+            null,
+            null,
+            $active
+        );
 	} else {
-		$a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], 0);
+		$a_course_users = CourseManager::get_user_list_from_course_code(
+            $courseCode,
+            0,
+            null,
+            null,
+            null,
+            null,
+            false,
+            false,
+            null,
+            null,
+            null,
+            $active
+        );
 	}
-	foreach ($a_course_users as $user_id => $o_course_user) {
-		if ((isset($_GET['keyword']) && searchUserKeyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
+
+	foreach ($a_course_users as $o_course_user) {
+		if ((isset($_GET['keyword']) &&
+                searchUserKeyword(
+                    $o_course_user['firstname'],
+                    $o_course_user['lastname'],
+                    $o_course_user['username'],
+                    $o_course_user['official_code'],
+                    $_GET['keyword']
+                )
+            ) || !isset($_GET['keyword']) || empty($_GET['keyword'])
+        ) {
 			$counter++;
 		}
 	}
 	return $counter;
 }
 
+/**
+ * @param string $firstname
+ * @param string $lastname
+ * @param string $username
+ * @param string $official_code
+ * @param $keyword
+ * @return bool
+ */
 function searchUserKeyword($firstname, $lastname, $username, $official_code, $keyword) {
-	if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos($username, $keyword) !== false || api_strripos($official_code, $keyword) !== false) {
+	if (
+        api_strripos($firstname, $keyword) !== false ||
+        api_strripos($lastname, $keyword) !== false ||
+        api_strripos($username, $keyword) !== false ||
+        api_strripos($official_code, $keyword) !== false
+    ) {
 		return true;
 	} else {
 		return false;
 	}
 }
 
-
 /**
  * Get the users to display on the current page.
  */
@@ -487,18 +530,38 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 
     $session_id = api_get_session_id();
     $course_code = api_get_course_id();
-
-    $a_course_users = CourseManager :: get_user_list_from_course_code($course_code, $session_id, $limit, $order_by);
+    $active = isset($_GET['active']) ? $_GET['active'] : null;
+    $a_course_users = CourseManager :: get_user_list_from_course_code(
+        $course_code,
+        $session_id,
+        $limit,
+        $order_by,
+        null,
+        null,
+        false,
+        false,
+        null,
+        array(),
+        array(),
+        $active
+    );
 
 	foreach ($a_course_users as $user_id => $o_course_user) {
-		if ((isset($_GET['keyword']) && searchUserKeyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
+		if ((
+                isset($_GET['keyword']) &&
+                searchUserKeyword(
+                    $o_course_user['firstname'],
+                    $o_course_user['lastname'],
+                    $o_course_user['username'],
+                    $o_course_user['official_code'],
+                    $_GET['keyword'])
+            ) || !isset($_GET['keyword']) || empty($_GET['keyword'])
+        ) {
 
 			$groups_name = GroupManager :: get_user_group_name($user_id);
 			$temp = array();
 			if (api_is_allowed_to_edit(null, true)) {
-				//if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
-                	$temp[] = $user_id;
-                //}
+                $temp[] = $user_id;
 				$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
 				$user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
 				if (!api_is_anonymous()) {
@@ -531,10 +594,10 @@ function get_user_data($from, $number_of_items, $column, $direction) {
 				}
                 $temp[] = $default_status;
 
-                //Active
+                // Active
 				$temp[] = $o_course_user['active'];
 
-                //User id for actions
+                // User id for actions
 				$temp[] = $user_id;
 			} else {
 				$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
@@ -564,7 +627,6 @@ function get_user_data($from, $number_of_items, $column, $direction) {
                     //User id for actions
                     $temp[] = $user_id;
                 }
-				//$temp[] = $o_course_user['official_code'];
 			}
 			$a_users[$user_id] = $temp;
 		}
@@ -593,7 +655,9 @@ function active_filter($active, $url_params, $row) {
 		$image='error';
 	}
 	$result = '';
-	if ($row[count($row)-1]<>$_user['user_id']) {  // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
+    /* you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is
+        locked out and nobody can change it anymore.*/
+	if ($row[count($row)-1]<>$_user['user_id']) {
 		$result = '<center><img src="../img/icons/16/'.$image.'.png" border="0" style="vertical-align: middle;" alt="'.get_lang(ucfirst($action)).'" title="'.get_lang(ucfirst($action)).'"/></center>';
 	}
 	return $result;
@@ -616,8 +680,7 @@ function modify_filter($user_id) {
 		$result .= '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&student='.$user_id.'&amp;details=true&amp;course='.$_course['id'].'&amp;origin=user_course&amp;id_session='.api_get_session_id().'" title="'.get_lang('Tracking').'"  ><img border="0" alt="'.get_lang('Tracking').'" src="../img/icons/22/stats.png" /></a>';
 	}
 
-
-    //if platform admin, show the login_as icon (this drastically shortens
+    // If platform admin, show the login_as icon (this drastically shortens
     // time taken by support to test things out)
     if (api_is_platform_admin()) {
         $result .= ' <a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&amp;user_id='.$user_id.'&amp;sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.gif', get_lang('LoginAs')).'</a>&nbsp;&nbsp;';
@@ -653,7 +716,6 @@ $default_column = 3;
 
 $table = new SortableTable('user_list', 'get_number_of_users', 'get_user_data', $default_column);
 $parameters['keyword'] = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
-// Create a sortable table with user-data
 $parameters['sec_token'] = Security::get_token();
 
 $table->set_additional_parameters($parameters);

+ 1 - 0
main/work/add_user.php

@@ -103,3 +103,4 @@ if (!empty($userToAddList)) {
 }
 
 echo '<hr /><div class="clear"></div>';
+Display::display_footer();

+ 1 - 1
main/work/student_work.php

@@ -83,7 +83,7 @@ foreach ($workPerUser as $work) {
     $workExtraData = get_work_assignment_by_id($workId);
 
     foreach ($work->user_results as $userResult) {
-        $table->setCellContents($row, $column, $work->title.' ['.strip_tags($userResult['title']).']');
+        $table->setCellContents($row, $column, $work->title.' ['.trim(strip_tags($userResult['title'])).']');
         $table->setCellAttributes($row, $column, array('width' => '300px'));
         $column++;
         $table->setCellContents($row, $column, $userResult['sent_date']);

+ 10 - 1
main/work/work.lib.php

@@ -1515,6 +1515,7 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null)
  * @param string $column
  * @param string $direction
  * @param string $where_condition
+ * @param bool $getCount
  * @return array
  */
 function getWorkListStudent($start, $limit, $column, $direction, $where_condition, $getCount = false)
@@ -1544,6 +1545,7 @@ function getWorkListStudent($start, $limit, $column, $direction, $where_conditio
         $group_query = " WHERE w.c_id = $course_id AND post_group_id = '0' ";
         $subdirs_query = "AND parent_id = 0";
     }
+
     $active_condition = ' AND active IN (1, 0)';
 
     if ($getCount) {
@@ -1578,6 +1580,7 @@ function getWorkListStudent($start, $limit, $column, $direction, $where_conditio
     while ($work = Database::fetch_array($result, 'ASSOC')) {
 
         $isSubscribed = userIsSubscribedToWork(api_get_user_id(), $work['id'], $course_id);
+
         if ($isSubscribed == false) {
             continue;
         }
@@ -1626,7 +1629,12 @@ function getWorkListTeacher($start, $limit, $column, $direction, $where_conditio
     // Get list from database
     if ($is_allowed_to_edit) {
         $active_condition = ' active IN (0, 1)';
-        $sql = "SELECT w.*, a.expires_on, expires_on, ends_on, enable_qualification
+        if ($getCount) {
+            $select = " SELECT count(w.id) as count";
+        } else {
+            $select = " SELECT w.*, a.expires_on, expires_on, ends_on, enable_qualification ";
+        }
+        $sql = " $select
                 FROM $workTable w
                 LEFT JOIN $workTableAssignment a ON (a.publication_id = w.id AND a.c_id = w.c_id)
                 WHERE w.c_id = $course_id
@@ -1635,6 +1643,7 @@ function getWorkListTeacher($start, $limit, $column, $direction, $where_conditio
                     (parent_id = 0) $where_condition ";
 
         $sql .= " AND post_group_id = '".$group_id."' ";
+
         $sql .= " ORDER BY $column $direction ";
         $sql .= " LIMIT $start, $limit";
 

+ 1 - 1
tests/main/inc/lib/main_api.lib.test.php

@@ -531,7 +531,7 @@ class TestMainApi extends UnitTestCase {
 
 	function testString2Boolean(){
 		global $string;
-		$res=string_2_boolean($string);
+		$res=api_string_2_boolean($string);
 		$this->assertFalse($res);
 	}