Browse Source

Moving the quota constant to global.inc and deleting unused script document/quota.php

Julio Montoya 12 years ago
parent
commit
d1eda3ee4f
3 changed files with 16 additions and 92 deletions
  1. 0 62
      main/document/quota.php
  2. 10 2
      main/inc/global.inc.php
  3. 6 28
      main/inc/lib/document.lib.php

+ 0 - 62
main/document/quota.php

@@ -1,62 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-/**
- *	This script displays info about the course disk use and quota:
- *	how large (in megabytes) is the documents area of the course,
- *	what is the maximum allowed for this course...
- *
- *	@author Roan Embrechts
- *	@package chamilo.document
- */
-/**
- * Code
- */
-
-// Name of the language file that needs to be included
-exit;
-$language_file = 'document';
-
-// Including the global dokeos file
-require_once '../inc/global.inc.php';
-
-// Including additional libraries
-require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
-require_once api_get_path(LIBRARY_PATH).'document.lib.php';
-
-// Some constants and variables
-$courseDir = $_course['path'].'/document';
-$maxFilledSpace = DEFAULT_DOCUMENT_QUOTA;
-
-// Breadcrumbs
-$interbreadcrumb[] = array('url' => 'document.php','name' => get_lang('ToolDocument'));
-
-// Title of the page
-$nameTools = get_lang('DocumentQuota');
-
-// Display the header
-Display::display_header($nameTools,'Doc');
-
-/*	FUNCTIONS */
-
-
-// Actions
-echo '<div class="actions">';
-// link back to the documents overview
-echo '<a href="document.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
-echo '</div>';
-
-// Getting the course quota
-$course_quota = DocumentManager::get_course_quota();
-
-// Setting the full path
-//$full_path = $baseWorkDir.$courseDir;
-
-// Calculating the total space
-$already_consumed_space = DocumentManager::documents_total_space($_course);
-
-// Displaying the quota
-DocumentManager::display_quota($course_quota, $already_consumed_space);
-
-// Display the footer
-Display::display_footer();

+ 10 - 2
main/inc/global.inc.php

@@ -601,6 +601,14 @@ if (!isset($_SESSION['login_as']) && isset($_user)) {
 // This block can be removed to speed things up a bit as it should only ever
 // be used in development versions.
 if ($_configuration['language_measure_frequency'] == 1) {
-  require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php';
-  $langstats = new langstats();
+    require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php';
+    $langstats = new langstats();
 }
+
+//Default quota for the course documents folder
+$default_quota = api_get_setting('default_document_quotum');
+//Just in case the setting is not correctly set 
+if (empty($default_quota)) {
+    $default_quota = 100000000;
+}
+define('DEFAULT_DOCUMENT_QUOTA', $default_quota);

+ 6 - 28
main/inc/lib/document.lib.php

@@ -12,25 +12,9 @@
 /**
  * Code
  */
-
-/* CONSTANTS */
-
-define('DISK_QUOTA_FIELD', 'disk_quota'); //name of the database field
-
-//Default quota for the course documents folder
-$default_quota = api_get_setting('default_document_quotum');
-//Just in case the setting is not correctly set 
-if (empty($default_quota)) {
-    $default_quota = 100000000;
-}
-define('DEFAULT_DOCUMENT_QUOTA', $default_quota);
-/**
- *	@package chamilo.library
- */
 class DocumentManager {
     
     private function __construct() {
-
     }
 
     /**
@@ -45,12 +29,12 @@ class DocumentManager {
         $course_code  = Database::escape_string($course_info['code']);
         $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
 
-        $sql_query      = "SELECT ".DISK_QUOTA_FIELD." FROM $course_table WHERE code = '$course_code'";
+        $sql_query      = "SELECT disk_quota FROM $course_table WHERE code = '$course_code'";
         $sql_result     = Database::query($sql_query);
         $course_quota   = null;
         if (Database::num_rows($sql_result)) {
             $result         = Database::fetch_array($sql_result);
-            $course_quota   = $result[DISK_QUOTA_FIELD];
+            $course_quota   = $result['disk_quota'];
         }
 
         if (is_null($course_quota) || empty($course_quota)) {
@@ -1182,15 +1166,10 @@ class DocumentManager {
 
         //When using hotpotatoes files, new files are generated in the hotpotatoe folder, if user_id=1 does the exam a new html file will be generated: hotpotatoe.html.(user_id).t.html
         //so we remove that string in order to find correctly the origin file
-         
-        if (strpos($doc_path, 'HotPotatoes_files')) {       
-            $doc_path = str_replace(api_get_user_id(), '', $doc_path);
-            $doc_path = str_replace('.t.html', '', $doc_path);                       
-            $path_info = pathinfo($doc_path);            
-            $explode_result = explode('.', $path_info['basename']);            
-            $doc_path = str_replace($path_info['basename'], $explode_result[0].'.'.$path_info['extension'], $doc_path);
+        if (strpos($doc_path, 'HotPotatoes_files')) {
+            $doc_path = substr($doc_path, 0, strlen($doc_path) - 8);
         }
-        
+
         if (!in_array($file_type, array('file','folder'))) {
             $file_type = 'file';
         }
@@ -2974,5 +2953,4 @@ class DocumentManager {
         return array('ods', 'odt');
     }
 }
-//end class DocumentManager
-
+//end class DocumentManager