From d1eda3ee4fd317439d51d9e1a7ec1ba0901087db Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 28 May 2012 16:44:30 +0200 Subject: [PATCH] Moving the quota constant to global.inc and deleting unused script document/quota.php --- main/document/quota.php | 62 ----------------------------------- main/inc/global.inc.php | 12 +++++-- main/inc/lib/document.lib.php | 34 ++++--------------- 3 files changed, 16 insertions(+), 92 deletions(-) delete mode 100644 main/document/quota.php diff --git a/main/document/quota.php b/main/document/quota.php deleted file mode 100644 index 08783ee6d1..0000000000 --- a/main/document/quota.php +++ /dev/null @@ -1,62 +0,0 @@ - '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 '
'; -// link back to the documents overview -echo ''.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).''; -echo '
'; - -// 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(); diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index c58c323008..d65189401a 100644 --- a/main/inc/global.inc.php +++ b/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); diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 03cc0aec29..b9595d59a9 100755 --- a/main/inc/lib/document.lib.php +++ b/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 \ No newline at end of file