From f1e0e305e4dbd96c802c56787d7f910191903205 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Sun, 24 Mar 2013 18:30:53 +0100 Subject: [PATCH] Minor style changes --- main/create_course/add_course.php | 3 +- main/inc/global.inc.php | 31 +++---- .../ajaxfilemanager/inc/class.session.php | 91 +++++++++---------- main/inc/lib/message.lib.php | 6 +- main/inc/lib/template.lib.php | 46 ++++------ src/ChamiloLMS/Controller/IndexController.php | 6 +- 6 files changed, 82 insertions(+), 101 deletions(-) mode change 100755 => 100644 main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.session.php diff --git a/main/create_course/add_course.php b/main/create_course/add_course.php index 44c9736fde..f89d6c68c4 100644 --- a/main/create_course/add_course.php +++ b/main/create_course/add_course.php @@ -64,7 +64,7 @@ $interbreadcrumb[] = array('url' => api_get_path(WEB_PATH).'user_portal.php', 'n // Displaying the header. $tool_name = $course_validation_feature ? get_lang('CreateCourseRequest') : get_lang('CreateSite'); -$tpl = new Template($tool_name); +$tpl = $app['template']; if (api_get_setting('allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) { api_not_allowed(true); @@ -110,7 +110,6 @@ $form->applyFilter('category_code', 'html_filter'); $categories_select->addOption('-', ''); CourseManager::select_and_sort_categories($categories_select); - // Course code $form->add_textfield( 'wanted_code', diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index 5c6f9895b0..7e25a20364 100644 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -339,23 +339,8 @@ if (is_writable($app['cache.path'])) { 'monolog.name' => 'chamilo', ) ); - - -//Adding web profiler - if (is_writable($app['cache.path'])) { - if ($app['debug']) { - //if (api_get_setting('allow_web_profiler') == 'true') { - $app->register($p = new Silex\Provider\WebProfilerServiceProvider(), array( - 'profiler.cache_dir' => $app['profiler.cache_dir'], - )); - $app->mount('/_profiler', $p); - //} - } - } - } - //Setting Doctrine service provider (DBAL) if (isset($_configuration['main_database'])) { $app->register(new Silex\Provider\DoctrineServiceProvider(), array( @@ -590,12 +575,8 @@ if ($alreadyInstalled && $checkConnection) { $_plugins = isset($_SESSION['_plugins']) ? $_SESSION['_plugins'] : null; } } - api_set_settings_and_plugins(); } - - - // Load allowed tag definitions for kses and/or HTMLPurifier. require_once $lib_path.'formvalidator/Rule/allowed_tags.inc.php'; @@ -619,6 +600,18 @@ if ($alreadyInstalled) { } } +//Adding web profiler +if (is_writable($app['cache.path'])) { + //if ($app['debug']) { + if (api_get_setting('allow_web_profiler') == 'true') { + $app->register($p = new Silex\Provider\WebProfilerServiceProvider(), array( + 'profiler.cache_dir' => $app['profiler.cache_dir'], + )); + $app->mount('/_profiler', $p); + } + //} +} + // Email service provider $app->register(new Silex\Provider\SwiftmailerServiceProvider(), array( 'swiftmailer.options' => array( diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.session.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.session.php old mode 100755 new mode 100644 index 6a607afd08..af09e318eb --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.session.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.session.php @@ -9,7 +9,7 @@ */ require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php"); -class Session +class Session { var $lifeTime; var $fp = null; @@ -19,13 +19,13 @@ class Session var $sessionFile = null; var $ext = '.txt'; var $gcCounter = 5; //call gc to delete expired session each ten request - var $gcCounterFileName = 'gc_counter.ajax.php'; - var $gcCounterFile = null; - var $gcLogFileName = 'gc_log.ajax.php'; - var $gcLogFile = null; - var $debug = true; //turn it on when you want to see gc log - - + var $gcCounterFileName = 'gc_counter.ajax.php'; + var $gcCounterFile = null; + var $gcLogFileName = 'gc_log.ajax.php'; + var $gcLogFile = null; + var $debug = true; //turn it on when you want to see gc log + + /** * constructor * @@ -44,37 +44,37 @@ class Session if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH)) { die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable."); - } + } if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH)) { die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable."); } $this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH)); - $this->lifeTime = get_cfg_var("session.gc_maxlifetime"); - $this->gcCounterFile = $this->dir . $this->gcCounterFileName; + $this->lifeTime = get_cfg_var("session.gc_maxlifetime"); + $this->gcCounterFile = $this->dir . $this->gcCounterFileName; $this->gcLogFile = $this->dir . $this->gcLogFileName; $this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR); - $this->init(); + $this->init(); } /** * constructor * - */ - function Session() + */ + function Session() { - $this->__construct(); + $this->__construct(); } /** * session init * @return boolean */ - function init() + function init() { - - + + } - + function gc() { //init the counter file @@ -93,17 +93,17 @@ class Session die(SESSION_COUNTER_FILE_WRITE_FAILED); } @fclose($fp); - }else + }else { die(SESSION_COUNTER_FILE_CREATE_FAILED); - } + } } /** * garbage collection function * */ - function _gc() + function _gc() { //remove expired file from session folder $dirHandler = @opendir($this->dir); @@ -117,33 +117,33 @@ class Session // This is to preserve the empty index.html and during development - the hidden .svn folder. No need for Chamilo because ajaxfilemanager sessions are disabled //if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() ) if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() - && $file != 'index.html' && $file != '.svn') - { + && $file != 'index.html' && $file != '.svn') + { $path=$this->dir.$file; $output .= $path ; //check if this is a expired session file if(filemtime($path) + $this->lifeTime < time()) - { + { if($fo->delete($path)) { $output .= ' Deleted at ' . date('d/M/Y H:i:s'); - }else + }else { $output .= " Failed at " . date('d/M/Y H:i:s'); - } + } } $output .= "\n"; - + } } if($this->debug) { $this->_log($output); } - + @closedir($dirHandler); - } + } if(CONFIG_SYS_DEMO_ENABLE) { //remove expired files from uploaded folder @@ -156,34 +156,34 @@ class Session while(false !== ($file = readdir($dirHandler))) { if($file != '.' && $file != '..') - { + { $path=CONFIG_SYS_ROOT_PATH.$file; $output .= $path ; //check if this is a expired session file if(filemtime($path) + $this->lifeTime < time()) - { + { if($fo->delete($path)) { $output .= ' Deleted at ' . date('d/M/Y H:i:s'); - }else + }else { $output .= " Failed at " . date('d/M/Y H:i:s'); - } + } } $output .= "\n"; - + } } if($this->debug) { $this->_log($output); } - + @closedir($dirHandler); - - } + + } } - + } /** * log action taken by the gc @@ -201,7 +201,7 @@ class Session @fclose($fp); } } - + /** * get the current session directory * @@ -216,17 +216,16 @@ class Session { return ''; } - }else + }else { if(!@is_dir($this->sessionDir)) { return ''; - } + } } return $this->sessionDir; } - - -} -?> \ No newline at end of file + + +} \ No newline at end of file diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 1c08f95160..a56d0ed041 100644 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -41,16 +41,14 @@ class MessageManager if (!api_get_user_id()) { return false; } - $query = "SELECT count(id) as count FROM $table_message WHERE user_receiver_id = ".api_get_user_id( - )." AND msg_status = ".MESSAGE_STATUS_UNREAD; + $query = "SELECT count(id) as count FROM $table_message + WHERE user_receiver_id = ".api_get_user_id()." AND msg_status = ".MESSAGE_STATUS_UNREAD; $result = Database::query($query); if (Database::num_rows($result)) { $result = Database::fetch_array($result); return $result['count']; } - ; - return 0; } diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 8436748649..76062bcd64 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -29,6 +29,10 @@ class Template public $app; public $navigation_array; + /** + * @param null $title + * @param null $app + */ function __construct($title = null, $app = null) { if (empty($app)) { @@ -64,18 +68,18 @@ class Template //Setting system variables $this->set_system_parameters(); - //Setting user variables - $this->set_user_parameters(); + //Setting user variables + $this->setUserParameters(); //Setting course variables - $this->set_course_parameters(); + $this->setCourseParameters(); //header and footer are showed by default - $this->set_footer($show_footer); - $this->set_header($show_header); + $this->setFooter($show_footer); + $this->setHeader($show_header); - $this->set_header_parameters(); - $this->set_footer_parameters(); + $this->setHeaderParameters(); + $this->setFooterParameters(); $this->assign('style', $this->style); @@ -218,7 +222,7 @@ class Template * Sets the footer visibility * @param bool true if we show the footer */ - function set_footer($status) + function setFooter($status) { $this->show_footer = $status; $this->assign('show_footer', $status); @@ -228,7 +232,7 @@ class Template * Sets the header visibility * @param bool true if we show the header */ - function set_header($status) + function setHeader($status) { $this->show_header = $status; $this->assign('show_header', $status); @@ -280,15 +284,14 @@ class Template } /** Set course parameters */ - private function set_course_parameters() + private function setCourseParameters() { //Setting course id - $course_id = api_get_course_int_id(); - $this->course_id = $course_id; + $this->course_id = api_get_course_int_id(); } /** Set user parameters */ - private function set_user_parameters() + private function setUserParameters() { $user_info = array(); $user_info['logged'] = 0; @@ -491,7 +494,7 @@ class Template /** * Set header parameters */ - private function set_header_parameters() { + private function setHeaderParameters() { global $interbreadcrumb; if (isset($this->app['breadcrumb']) && !empty($this->app['breadcrumb'])) { @@ -505,7 +508,6 @@ class Template $_configuration = $this->app['configuration']; $this_section = $this->app['this_section']; - $nameTools = $this->title; $navigation = $this->navigation_array; @@ -648,7 +650,7 @@ class Template /** * Set footer parameteres */ - private function set_footer_parameters() + private function setFooterParameters() { global $_configuration; @@ -977,18 +979,6 @@ class Template // Social if (api_get_setting('allow_social_tool') == 'true') { $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php'; - /* - // get count unread message and total invitations - $count_unread_message = MessageManager::get_number_of_messages(true); - - $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); - $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false); - if (!empty($group_pending_invitations )) { - $group_pending_invitations = count($group_pending_invitations); - } - $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message); - $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) :'');*/ - $navigation['social']['title'] = get_lang('SocialNetwork'); } diff --git a/src/ChamiloLMS/Controller/IndexController.php b/src/ChamiloLMS/Controller/IndexController.php index 70f38c0055..a0dea5e0a5 100644 --- a/src/ChamiloLMS/Controller/IndexController.php +++ b/src/ChamiloLMS/Controller/IndexController.php @@ -85,6 +85,7 @@ class IndexController// extends Controller // Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world. //$_setting['display_courses_to_anonymous_users'] = 'true'; // Delete session neccesary for legal terms + if (api_get_setting('allow_terms_conditions') == 'true') { unset($_SESSION['term_and_condition']); } @@ -110,7 +111,7 @@ class IndexController// extends Controller facebook_connect(); } - $this->set_login_form($app); + $this->setLoginForm($app); if (!api_is_anonymous()) { \PageController::return_profile_block(); @@ -153,6 +154,7 @@ class IndexController// extends Controller if (api_is_platform_admin() || api_is_drh()) { \PageController::return_skills_links(); } + $response = $app['template']->render_layout('layout_2_col.tpl'); //return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, public')); @@ -202,7 +204,7 @@ class IndexController// extends Controller /** * @param \Silex\Application $app */ - function set_login_form(Application $app) + function setLoginForm(Application $app) { $userId = api_get_user_id(); $loginForm = null;