From 3896a7f05d27c569df20329ef5827d012055a0ff Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Wed, 18 Mar 2015 17:13:08 -0500 Subject: [PATCH 01/23] Add missing configuration parameters - refs #4507 --- main/inc/conf/configuration.dist.php | 205 +++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 main/inc/conf/configuration.dist.php diff --git a/main/inc/conf/configuration.dist.php b/main/inc/conf/configuration.dist.php new file mode 100644 index 0000000000..0a6cfdbb50 --- /dev/null +++ b/main/inc/conf/configuration.dist.php @@ -0,0 +1,205 @@ + Go to your portal Chamilo > Administration > CAS to activate CAS +// You can leave these lines uncommented even if you don't use CAS authentification +$extAuthSource["cas"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/cas/login.php"; +$extAuthSource["cas"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/cas/newUser.php"; +// +// NEW LDAP IMPLEMENTATION BASED ON external_login info +// -> Uncomment the two lines bellow to activate LDAP AND edit main/auth/external_login/ldap.conf.php for configuration +// $extAuthSource["extldap"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/login.ldap.php"; +// $extAuthSource["extldap"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/newUser.ldap.php"; +// +// FACEBOOK IMPLEMENTATION BASED ON external_login info +// -> Uncomment the line bellow to activate Facebook Auth AND edit main/auth/external_login/ldap.conf.php for configuration +// $_configuration['facebook_auth'] = 1; +// +// OTHER EXTERNAL LOGIN INFORMATION +// To fetch external login information, uncomment those 2 lines and modify files auth/external_login/newUser.php and auth/external_login/updateUser.php files +// $extAuthSource["external_login"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/newUser.php"; +// $extAuthSource["external_login"]["updateUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/updateUser.php"; + +/** + * + * Hosting settings - Allows you to set limits to the Chamilo portal when + * hosting it for a third party. These settings can be overwritten by an + * optionally-loaded extension file with only the settings (no comments). + * The settings use an index at the first level to represent the ID of the + * URL in case you use multi-url (otherwise it will always use 1, which is + * the ID of the only URL inside the access_url table). + */ +// Set a maximum number of users. Default (0) = no limit +$_configuration[1]['hosting_limit_users'] = 0; +// Set a maximum number of teachers. Default (0) = no limit +$_configuration[1]['hosting_limit_teachers'] = 0; +// Set a maximum number of courses. Default (0) = no limit +$_configuration[1]['hosting_limit_courses'] = 0; +// Set a maximum number of sessions. Default (0) = no limit +$_configuration[1]['hosting_limit_sessions'] = 0; +// Set a maximum disk space used, in MB (set to 1024 for 1GB, 5120 for 5GB). +// Default (0) = no limit +$_configuration[1]['hosting_limit_disk_space'] = 0; + +/** + * Content Delivery Network (CDN) settings. Only use if you need a separate + * server to serve your static data. If you don't know what a CDN is, you + * don't need it. These settings are for simple Origin Pull CDNs and are + * experimental. Enable only if you really know what you're doing. + * This might conflict with multiple-access urls. + */ +// Set the following setting to true to start using the CDN +$_configuration['cdn_enable'] = false; +// The following setting will be ignored if the previous one is set to false +$_configuration['cdn'] = array( + //You can define several CDNs and split them by extensions + //Replace the following by your full CDN URL, which should point to + // your Chamilo's root directory. DO NOT INCLUDE a final slash! (won't work) + 'http://cdn.chamilo.org' => array('.css','.js','.jpg','.jpeg','.png','.gif','.avi','.flv'), + // copy the line above and modify following your needs +); + +/** + * Misc. settings + */ +// Verbose backup +$_configuration['verbose_backup'] = false; +// security word for password recovery +$_configuration['security_key'] = 'adbeb884dffd2cb44d7ea5c2f49fc5c0'; +// Hash function method +$_configuration['password_encryption'] = 'sha1'; +// You may have to restart your web server if you change this +$_configuration['session_stored_in_db'] = false; +// Session lifetime +$_configuration['session_lifetime'] = 360000; +// Activation for multi-url access +//$_configuration['multiple_access_urls'] = true; +$_configuration['software_name'] = 'Chamilo'; +$_configuration['software_url'] = 'http://www.chamilo.org/'; +//Deny the elimination of users +$_configuration['deny_delete_users'] = false; +// Version settings +$_configuration['system_version'] = '1.9.8'; +$_configuration['system_stable'] = true; + +/** + * Settings to be included as settings_current in future versions + */ +// Hide the main home section for connected users (to show announcements instead) +//$_configuration['hide_home_top_when_connected'] = true; +// Hide the global announcements for non-connected users +//$_configuration['hide_global_announcements_when_not_connected'] = true; +// Use this course as template for all new courses (define course real ID as value) +//$_configuration['course_creation_use_template'] = 14; +// Uncomment the following to prevent all admins to use the "login as" feature +//$_configuration['login_as_forbidden_globally'] = true; +// Add password strength checker +//$_configuration['allow_strength_pass_checker'] = true; +// Enable captcha +//$_configuration['enable_captcha'] = true; +//$_configuration['allow_captcha'] = true; +// Prevent account from logging in for a certain amount of time if captcha is wrong for the specified number of times +//$_configuration['captcha_number_mistakes_to_block_account'] = 5; +// Prevent account from logging in for the specified number of minutes +//$_configuration['captcha_time_to_block'] = 5;//minutes +// Allow DRH role to access all content and users from the sessions he follows +//$_configuration['drh_can_access_all_session_content'] = true; +// Display group's forum in general forum tool +//$_configuration['display_groups_forum_in_general_tool'] = true; +// Boost query on last connection time +//$_configuration['save_user_last_login'] = true; +// Allow course tutors in sessions to add existing students to their session +//$_configuration['allow_tutors_to_assign_students_to_session'] = 'false'; +// Allow select the return link in the LP view +//$_configuration['allow_lp_return_link'] = false; +// If true the export link is blocked. +//$_configuration['hide_scorm_export_link'] = false; +// If true the copy link is blocked. +//$_configuration['hide_scorm_copy_link'] = false; +// Enable Gravatar profile image if no local image has been given +//$_configuration['gravatar_enabled'] = true; +// If Gravatar is enabled, tells which type of picture we want (default is "mm"). Options: mm | identicon | monsterid | wavatar +//$_configuration['gravatar_type'] = 'mm'; From e11305b247f7f33e2a00aa55757754d8c4a86690 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 19 Mar 2015 08:20:35 +0100 Subject: [PATCH 02/23] Fix login. --- main/inc/lib/api.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index f30444e560..5d32250209 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -3304,10 +3304,10 @@ function api_not_allowed($print_headers = false, $message = null) // If the user has no user ID, then his session has expired $action = api_get_self().'?'.Security::remove_XSS($_SERVER['QUERY_STRING']); $action = str_replace('&', '&', $action); - $form = new FormValidator('formLogin', 'post', $action, null, array('class'=>'form-stacked')); - $form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'span3 autocapitalize_off')); //new - $form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'), 'class' => 'span3')); //new - $form->addElement('style_submit_button', 'submitAuth', get_lang('LoginEnter'), array('class' => 'btn span3')); + $form = new FormValidator('formLogin', 'post', $action, null, array(), FormValidator::LAYOUT_BOX_NO_LABEL); + $form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'autocapitalize_off')); + $form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'))); + $form->addButton('submitAuth', get_lang('LoginEnter'), '', 'primary'); // see same text in auth/gotocourse.php and main_api.lib.php function api_not_allowed (above) $content = Display::return_message(get_lang('NotAllowed'), 'error', false); From a8832fb987b0e7af451bb2005980591edf0d4e48 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 19 Mar 2015 09:32:28 +0100 Subject: [PATCH 03/23] Minor - format code. --- main/inc/lib/formvalidator/FormValidator.class.php | 4 ++-- main/inc/lib/message.lib.php | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php index 9050abc388..306b07c6a3 100755 --- a/main/inc/lib/formvalidator/FormValidator.class.php +++ b/main/inc/lib/formvalidator/FormValidator.class.php @@ -578,12 +578,12 @@ EOT; /** * @param string $name * @param string $label - * @param string $options + * @param array $options * @param array $attributes * * @return HTML_QuickForm_select */ - public function addSelect($name, $label, $options = '', $attributes = array()) + public function addSelect($name, $label, $options = array(), $attributes = array()) { return $this->addElement('select', $name, $label, $options, $attributes); } diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index d9334c8bbc..8f598b79eb 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -1329,8 +1329,8 @@ class MessageManager /** * Get array of links (download) for message attachment files - * @param int message id - * @param string type message list (inbox/outbox) + * @param int $message_id + * @param string $type message list (inbox/outbox) * @return array */ public static function get_links_message_attachment_files($message_id, $type = '') @@ -1342,7 +1342,8 @@ class MessageManager $links_attach_file = array(); if (!empty($message_id)) { - $sql = "SELECT * FROM $tbl_message_attach WHERE message_id = '$message_id'"; + $sql = "SELECT * FROM $tbl_message_attach + WHERE message_id = '$message_id'"; $rs_file = Database::query($sql); if (Database::num_rows($rs_file) > 0) { @@ -1363,14 +1364,15 @@ class MessageManager /** * Get message list by id - * @param int message id + * @param int $message_id * @return array */ public static function get_message_by_id($message_id) { $tbl_message = Database::get_main_table(TABLE_MESSAGE); $message_id = intval($message_id); - $sql = "SELECT * FROM $tbl_message WHERE id = '$message_id' AND msg_status <> '".MESSAGE_STATUS_DELETED."' "; + $sql = "SELECT * FROM $tbl_message + WHERE id = '$message_id' AND msg_status <> '".MESSAGE_STATUS_DELETED."' "; $res = Database::query($sql); $item = array(); if (Database::num_rows($res) > 0) { From bfafc94c4ebcccdc288c5690df4804d1d1db348d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 19 Mar 2015 09:45:28 +0100 Subject: [PATCH 04/23] Fix search form. --- main/inc/lib/usermanager.lib.php | 104 +++++++++++++++++------- main/social/search.php | 32 ++++---- main/template/default/social/search.tpl | 22 ++--- 3 files changed, 101 insertions(+), 57 deletions(-) diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index ad24822037..1e7b129af4 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -1770,7 +1770,16 @@ class UserManager $fields = array(); $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD); $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS); - $columns = array('id', 'field_variable', 'field_type', 'field_display_text', 'field_default_value', 'field_order', 'field_filter', 'tms'); + $columns = array( + 'id', + 'field_variable', + 'field_type', + 'field_display_text', + 'field_default_value', + 'field_order', + 'field_filter', + 'tms' + ); $column = intval($column); $sort_direction = ''; if (in_array(strtoupper($direction), array('ASC', 'DESC'))) { @@ -1809,7 +1818,9 @@ class UserManager 10 => '', ); - $sqlo = "SELECT * FROM $t_ufo WHERE field_id = ".$rowf['id']." ORDER BY option_order ASC"; + $sqlo = "SELECT * FROM $t_ufo + WHERE field_id = ".$rowf['id']." + ORDER BY option_order ASC"; $reso = Database::query($sqlo); if (Database::num_rows($reso) > 0) { while ($rowo = Database::fetch_array($reso)) { @@ -3771,16 +3782,17 @@ class UserManager } /** - * Get extra filtrable user fields (type select) + * Get extra filtrable user fields (only type select) * @return array */ public static function get_extra_filtrable_fields() { $extraFieldList = UserManager::get_extra_fields(); + $extraFiltrableFields = array(); if (is_array($extraFieldList)) { foreach ($extraFieldList as $extraField) { - //if is enabled to filter and is a "" field type if ($extraField[8] == 1 && $extraField[2] == 4) { $extraFiltrableFields[] = array( 'name' => $extraField[3], @@ -3791,7 +3803,7 @@ class UserManager } } - if (is_array($extraFiltrableFields) && count($extraFiltrableFields) > 0 ) { + if (is_array($extraFiltrableFields) && count($extraFiltrableFields) > 0) { return $extraFiltrableFields; } } @@ -3811,7 +3823,10 @@ class UserManager if (UserManager::is_extra_field_available($extraField['variable'])) { if (isset($_GET[$varName]) && $_GET[$varName]!='0') { $useExtraFields = true; - $extraFieldResult[]= UserManager::get_extra_user_data_by_value($extraField['variable'], $_GET[$varName]); + $extraFieldResult[]= UserManager::get_extra_user_data_by_value( + $extraField['variable'], + $_GET[$varName] + ); } } } @@ -3847,35 +3862,74 @@ class UserManager */ public static function get_search_form($query) { - $extraFiltrableFields = UserManager::get_extra_filtrable_fields(); - $extraFields = null; - if (is_array($extraFiltrableFields) && count($extraFiltrableFields)>0 ) { - foreach ($extraFiltrableFields as $extraField) { - $extraFields .= ''; + $searchType = isset($_GET['search_type']) ? $_GET['search_type'] : null; + $form = new FormValidator( + 'search_user', + 'get', + api_get_path(WEB_PATH).'main/social/search.php', + '', + array(), + FormValidator::LAYOUT_INLINE + ); + + $form->addText('q', get_lang('UsersGroups')); + $options = array( + 0 => get_lang('Select'), + 1 => get_lang('User'), + 2 => get_lang('Group'), + ); + $form->addSelect( + 'search_type', + get_lang('Type'), + $options, + array('onchange' => 'javascript: extra_field_toogle();') + ); + + // Extra fields + + $extraFields = UserManager::get_extra_filtrable_fields(); + $defaults = []; + if (is_array($extraFields) && count($extraFields) > 0) { + foreach ($extraFields as $extraField) { $varName = 'field_'.$extraField['variable']; - $extraFields .= ' '; - $extraFields .= '  '; + $form->addSelect($varName, $extraField['name'], $options); } } - $searchType = isset($_GET['search_type']) ? $_GET['search_type'] : null; + $defaults['search_type'] = intval($searchType); + $defaults['q'] = api_htmlentities(Security::remove_XSS($query)); + $form->setDefaults($defaults); + + $form->addButtonSearch(get_lang('Search')); + + $js = ''; + + return $js.$form->returnForm(); return '