ソースを参照

Changing temp/cache folder creation

Julio Montoya 12 年 前
コミット
6365383075

+ 1 - 1
app/console-config.php

@@ -21,7 +21,7 @@ $config->setProxyNamespace('Proxies');
 
 $courseList = CourseManager::get_real_course_list();
 
-$app['chamilo.log'] = $app['cache.path'].'chamilo-cli.log';
+$app['chamilo.log'] = $app['log.path'].'/chamilo-cli.log';
 
 // Loading db connections
 

+ 1 - 1
main/course_home/course_home.php

@@ -139,7 +139,7 @@ Session::erase('_gid');
 $is_speacialcourse = CourseManager::is_special_course($course_code);
 
 if ($is_speacialcourse) {
-    $autoreg = Security::remove_XSS($_GET['autoreg']);
+    $autoreg = isset($_GET['autoreg']) ? Security::remove_XSS($_GET['autoreg']) : null;
     if ($autoreg == 1) {
         CourseManager::subscribe_user($user_id, $course_code, $status = STUDENT);
     }

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

@@ -430,7 +430,7 @@ define('_PCRE_XML_ENCODING', '/<\?xml.*encoding=[\'"](.*?)[\'"].*\?>/m');
  * api_get_path(REL_CODE_PATH)                  /chamilo/main/
  * api_get_path(SYS_SERVER_ROOT_PATH)           /var/www/ - This is the physical folder where the system Chamilo has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
  * api_get_path(SYS_PATH)                       /var/www/chamilo/
- * api_get_path(SYS_ARCHIVE_PATH)               /var/www/chamilo/archive/
+ * api_get_path(SYS_ARCHIVE_PATH)               /var/www/chamilo/app/cache/
  * api_get_path(SYS_COURSE_PATH)                /var/www/chamilo/courses/
  * api_get_path(SYS_CODE_PATH)                  /var/www/chamilo/main/
  * api_get_path(SYS_CSS_PATH)                   /var/www/chamilo/main/css

+ 2 - 4
main/inc/lib/security.lib.php

@@ -265,10 +265,8 @@ class Security
         }
         static $purifier = array();
         if (!isset($purifier[$user_status])) {
-            $cache_dir = api_get_path(SYS_ARCHIVE_PATH).'Serializer';
-            if (!file_exists($cache_dir)) {
-                mkdir($cache_dir, 0777);
-            }
+            global $app;
+            $cache_dir = $app['htmlpurifier.serializer'];
             $config = HTMLPurifier_Config::createDefault();
             //$config->set('Cache.DefinitionImpl', null); // Enable this line for testing purposes, for turning off caching. Don't forget to disable this line later!
             $config->set('Cache.SerializerPath', $cache_dir);

+ 18 - 18
main/inc/lib/system/io/temp.class.php

@@ -3,16 +3,16 @@
 /**
  * Temporary file/folder. The file/folder is automatically deleted at
  * the end of the script/during garbage collection.
- * 
+ *
  * The object implements __toString so it can be used as string variable.
- * 
+ *
  * Usage
- * 
+ *
  *      $path = Temp::file();
  *      file_puts_content($path, $content);
- * 
+ *
  * or
- * 
+ *
  *      $path = Temp::dir();
  *      ...
  *
@@ -22,15 +22,15 @@
  */
 class Temp
 {
-    
+
     protected static $files = array();
-    
+
     /**
      * Returns the list of temporary files opened by the script.
      * This is mostly due to pin temporary files and prevent garbage collection.
-     * This ensure files are not unlinked while still using it to send data in 
+     * This ensure files are not unlinked while still using it to send data in
      * an upload.
-     * 
+     *
      * @return array
      */
     public static function files()
@@ -40,9 +40,9 @@ class Temp
 
     /**
      * Recursively delete files and/or folders.
-     * 
+     *
      * @param string $path
-     * @return boolean 
+     * @return boolean
      */
     public static function delete($path)
     {
@@ -70,8 +70,8 @@ class Temp
     /**
      * Set the temp root directory. Temporary files are by default created in this directory.
      * Defaults to sys_get_temp_dir().
-     * 
-     * @param string $value 
+     *
+     * @param string $value
      */
     public static function set_temp_root($value)
     {
@@ -89,8 +89,8 @@ class Temp
 
     /**
      * Returns a path to a non-existing temporary file located under temp_dir.
-     * 
-     * @return string 
+     *
+     * @return string
      */
     public static function get_temporary_name()
     {
@@ -104,7 +104,7 @@ class Temp
     /**
      *
      * @param string $path
-     * @return Temp 
+     * @return Temp
      */
     public static function file($path = '')
     {
@@ -115,7 +115,7 @@ class Temp
     /**
      *
      * @param string $path
-     * @return Temp 
+     * @return Temp
      */
     public static function dir($path = '')
     {
@@ -129,7 +129,7 @@ class Temp
     /**
      *
      * @param string $path
-     * @return Temp 
+     * @return Temp
      */
     public static function create($path = '')
     {

+ 6 - 12
main/user/user.php

@@ -4,10 +4,6 @@
 *	This script displays a list of the users of the current course.
 *	Course admins can change user perimssions, subscribe and unsubscribe users...
 *
-*	EXPERIMENTAL: support for virtual courses
-*	- show users registered in virtual and real courses;
-*	- only show the users of a virtual course if the current user;
-*	is registered in that virtual course.
 *
 *	Exceptions: platform admin and the course admin will see all virtual courses.
 *	This is a new feature, there may be bugs.
@@ -32,8 +28,6 @@ $this_section = SECTION_COURSES;
 // notice for unauthorized people.
 api_protect_course_script(true);
 
-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) {
@@ -87,7 +81,7 @@ if (api_is_allowed_to_edit(null, true)) {
 				$data = array();
 				$a_users = array();
 
-				if ($_configuration['multiple_access_urls']) {
+				if (api_is_multiple_url_enabled()) {
 					$current_access_url_id = api_get_current_access_url_id();
 				}
 
@@ -134,7 +128,7 @@ if (api_is_allowed_to_edit(null, true)) {
                     $table_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
                     $sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").",  user.username, $select_email_condition phone, user.official_code, active $legal
                                   FROM $table_session_course_user as session_course_user, $table_users as user,  $table_session_user as su";
-                    if ($_configuration['multiple_access_urls']) {
+                    if (api_is_multiple_url_enabled()) {
                         $sql_query .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au ';
                     }
                     $sql_query .=" WHERE course_code = '$course_code' AND
@@ -143,7 +137,7 @@ if (api_is_allowed_to_edit(null, true)) {
                                         su.moved_to = 0 AND su.moved_status <> ".SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION."  AND
                                         session_course_user.id_session = $session_id";
 
-                    if ($_configuration['multiple_access_urls']) {
+                    if (api_is_multiple_url_enabled()) {
                         $sql_query .= " AND user.user_id = au.user_id AND access_url_id =  $current_access_url_id  ";
                     }
 
@@ -192,12 +186,12 @@ if (api_is_allowed_to_edit(null, true)) {
 					$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 					$sql_query = "SELECT DISTINCT user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname").", user.username, $select_email_condition phone, user.official_code, active $legal
 								  FROM $table_course_user as course_user, $table_users as user ";
-					if ($_configuration['multiple_access_urls']) {
+					if (api_is_multiple_url_enabled()) {
 						$sql_query .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au ';
 					}
 					$sql_query .= " WHERE course_code = '$course_code' AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND course_user.user_id = user.user_id ";
 
-					if ($_configuration['multiple_access_urls']) {
+					if (api_is_multiple_url_enabled()) {
 						$sql_query .= " AND user.user_id = au.user_id  AND access_url_id =  $current_access_url_id  ";
 					}
 
@@ -243,7 +237,7 @@ if (api_is_allowed_to_edit(null, true)) {
 
 				switch ($_GET['type']) {
 					case 'csv' :
-						Export::export_table_csv($a_users);
+						Export::export_table_csv_utf8($a_users);
 						exit;
 					case 'xls' :
 						Export::export_table_xls($a_users);

+ 1 - 1
src/ChamiloLMS/Command/Database/InstallCommand.php

@@ -238,7 +238,7 @@ class InstallCommand extends CommonCommand
         if ($configurationWasSaved) {
             global $app;
 
-            $app['chamilo.log'] = $app['cache.path'].'chamilo_install.log';
+            $app['chamilo.log'] = $app['log.path'].'/chamilo_install.log';
 
             //Installing database
             $result = $this->install($version, $newConfigurationArray, $output);

+ 28 - 22
src/ChamiloLMS/Resources/config/prod.php

@@ -8,36 +8,44 @@ $app['jquery_ui_theme'] = 'smoothness';
 // Cache
 $app['cache.path'] = api_get_path(SYS_ARCHIVE_PATH);
 
-$app['log.path'] = api_get_path(SYS_PATH_APP).'logs/';
+$app['cache.paths'] = new stdClass();
+
+//Monolog
+$app['cache.paths']->folders[] = $app['log.path'] = $app['cache.path'].'logs';
 
 //Twig cache
-$app['twig.cache.path'] = $app['cache.path'].'twig';
+$app['cache.paths']->folders[] = $app['twig.cache.path'] = $app['cache.path'].'twig';
 
 // Http cache
-$app['http_cache.cache_dir'] = $app['cache.path'].'http';
+$app['cache.paths']->folders[] = $app['http_cache.cache_dir'] = $app['cache.path'].'http';
 
 // Doctrine ORM
-$app['db.orm.proxies_dir'] = $app['cache.path'].'proxies_dir';
+$app['cache.paths']->folders[] = $app['db.orm.proxies_dir'] = $app['cache.path'].'proxies_dir';
 
 //Profiler
-$app['profiler.cache_dir'] = $app['cache.path'].'profiler';
+$app['cache.paths']->folders[] = $app['profiler.cache_dir'] = $app['cache.path'].'profiler';
 
-//Monolog log file
-$app['chamilo.log'] = $app['cache.path'].'chamilo.log';
+//HTMLPurifier
+$app['cache.paths']->folders[] = $app['htmlpurifier.serializer'] = $app['cache.path'].'serializer';
 
 //PCLZIP temp dir
-define('PCLZIP_TEMPORARY_DIR', $app['cache.path']);
+define('PCLZIP_TEMPORARY_DIR', $app['cache.path'].'pclzip');
+$app['cache.paths']->folders[] = PCLZIP_TEMPORARY_DIR;
 
-//mpdf libs
+//MPDF libs
+define("_MPDF_TEMP_PATH", $app['cache.path'].'/mpdf');
+define("_JPGRAPH_PATH", $app['cache.path'].'/mpdf');
+define("_MPDF_TTFONTDATAPATH", $app['cache.path'].'/mpdf');
 
-define("_MPDF_TEMP_PATH", $app['cache.path']);
-define("_JPGRAPH_PATH", $app['cache.path']);
-define("_MPDF_TTFONTDATAPATH", $app['cache.path']);
+$app['cache.paths']->folders[] = _MPDF_TEMP_PATH;
 
 //QR code
+define('QR_CACHE_DIR', $app['cache.path'].'qr');
+define('QR_LOG_DIR', $app['cache.path'].'qr');
+$app['cache.paths']->folders[] = QR_CACHE_DIR;
 
-define('QR_CACHE_DIR', $app['cache.path']);
-define('QR_LOG_DIR', $app['cache.path']);
+//Chamilo temp class
+$app['cache.paths']->folders[] = $app['cache.path'].'temp';
 
 // Assetic
 /*
@@ -94,17 +102,15 @@ if (!is_dir($app['assetic.path_to_web'].'/js')) {
 }
  *
  */
-if (!is_dir($app['db.orm.proxies_dir'])) {
-    @mkdir($app['db.orm.proxies_dir'], api_get_permissions_for_new_directories());
-}
 
-if (!is_dir($app['twig.cache.path'])) {
-    @mkdir($app['twig.cache.path'], api_get_permissions_for_new_directories());
+foreach($app['cache.paths']->folders as $folder) {
+    if (!is_dir($folder)) {
+        @mkdir($folder, api_get_permissions_for_new_directories());
+    }
 }
 
-if (!is_dir($app['profiler.cache_dir'])) {
-    @mkdir($app['profiler.cache_dir'], api_get_permissions_for_new_directories());
-}
+//Monolog log file
+$app['chamilo.log'] = $app['cache.path'].'chamilo.log';
 
 if (is_file($app['chamilo.log']) && !is_writable($app['chamilo.log'])) {
     unlink($app['chamilo.log']);