From 4612d643b478a144f44956cdcaa08cf68c7d25b7 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 12 Jul 2017 12:55:38 +0200 Subject: [PATCH] Minor - format code. --- main/inc/lib/login.lib.php | 31 +++++++++++------------ main/inc/lib/model.lib.php | 3 ++- main/inc/lib/notebook.lib.php | 9 ++++--- main/inc/lib/promotion.lib.php | 10 ++++++-- main/inc/lib/statistics.lib.php | 24 +++++++++++++----- main/inc/lib/sub_language.class.php | 2 +- main/inc/lib/system_announcements.lib.php | 29 +++++++++++++++++---- main/inc/lib/table_sort.class.php | 10 +++++--- main/inc/lib/tracking.lib.php | 14 +++++++--- 9 files changed, 90 insertions(+), 42 deletions(-) diff --git a/main/inc/lib/login.lib.php b/main/inc/lib/login.lib.php index 8d9fc651e6..5559cb20e4 100755 --- a/main/inc/lib/login.lib.php +++ b/main/inc/lib/login.lib.php @@ -18,7 +18,7 @@ class Login * @param array $user array with keys: email, password, uid, loginName * @param boolean $reset * @param boolean $by_username - * @return unknown + * @return string */ public static function get_user_account_list($user, $reset = false, $by_username = false) { @@ -73,6 +73,7 @@ class Login * This function sends the actual password to the user * * @param int $user + * @return string * @author Olivier Cauberghe , Ghent University */ public static function send_password_to_user($user, $by_username = false) @@ -107,7 +108,6 @@ class Login $email_admin = api_get_setting('emailAdministrator'); if (api_mail_html('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) { - return get_lang('YourPasswordHasBeenReset'); } else { $admin_email = Display:: encrypted_mailto_link( @@ -128,8 +128,9 @@ class Login /** * Handle encrypted password, send an email to a user with his password * - * @param int user id - * @param bool $by_username + * @param int user id + * @param bool $by_username + * @return string * * @author Olivier Cauberghe , Ghent University */ @@ -252,7 +253,6 @@ class Login $user = Database::fetch_array($result); if ($user['auth_source'] == 'extldap') { - return get_lang('CouldNotResetPassword'); } } else { @@ -534,7 +534,6 @@ class Login if ($reset) { if (isset($user_id) && $user_id && isset($_cid) && $_cid) { - //Check if user is subscribed in a course $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $sql = "SELECT * FROM $course_user_table @@ -570,7 +569,6 @@ class Login //We are in a session course? Check session permissions if (!empty($session_id)) { - //I'm not the teacher of the course if ($is_courseAdmin == false) { // this user has no status related to this course @@ -673,7 +671,7 @@ class Login case COURSE_VISIBILITY_OPEN_WORLD: //3 $is_allowed_in_course = true; break; - case COURSE_VISIBILITY_OPEN_PLATFORM : //2 + case COURSE_VISIBILITY_OPEN_PLATFORM: //2 if (isset($user_id) && !api_is_anonymous($user_id)) { $is_allowed_in_course = true; } @@ -760,7 +758,8 @@ class Login } else { Session::erase('_gid'); } - } elseif (isset($_SESSION['_gid']) or isset($_gid)) { // Keys missing => not anymore in the group - course relation + } elseif (isset($_SESSION['_gid']) || isset($_gid)) { + // Keys missing => not anymore in the group - course relation Session::erase('_gid'); } } elseif (isset($_SESSION['_gid'])) { // continue with the previous values @@ -812,15 +811,15 @@ class Login $email = false; } - if ($email) { - $condition = "LOWER(email) = '".Database::escape_string($username)."' "; - } else { + if ($email) { + $condition = "LOWER(email) = '".Database::escape_string($username)."' "; + } else { $condition = "LOWER(username) = '".Database::escape_string($username)."'"; } - $tbl_user = Database::get_main_table(TABLE_MAIN_USER); - $query = "SELECT - user_id AS uid, + $tbl_user = Database::get_main_table(TABLE_MAIN_USER); + $query = "SELECT + user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, @@ -834,7 +833,7 @@ class Login auth_source FROM $tbl_user WHERE ( $condition AND active = 1) "; - $result = Database::query($query); + $result = Database::query($query); $num_rows = Database::num_rows($result); if ($result && $num_rows > 0) { return Database::fetch_assoc($result); diff --git a/main/inc/lib/model.lib.php b/main/inc/lib/model.lib.php index 84ee530330..e31873a28b 100755 --- a/main/inc/lib/model.lib.php +++ b/main/inc/lib/model.lib.php @@ -77,7 +77,7 @@ class Model { $clean_params = array(); if (!empty($params)) { - foreach ($params as $key=>$value) { + foreach ($params as $key => $value) { if (in_array($key, $this->columns)) { $clean_params[$key] = $value; } @@ -142,6 +142,7 @@ class Model /** * Get the count of elements + * @return int */ public function get_count() { diff --git a/main/inc/lib/notebook.lib.php b/main/inc/lib/notebook.lib.php index 9edbdee7ae..85df5ad165 100755 --- a/main/inc/lib/notebook.lib.php +++ b/main/inc/lib/notebook.lib.php @@ -2,10 +2,10 @@ /* For licensing terms, see /license.txt */ /** - * This class provides methods for the notebook management. - * Include/require it in your code to use its features. - * @author Carlos Vargas , move code of main/notebook up here - * @package chamilo.library + * This class provides methods for the notebook management. + * Include/require it in your code to use its features. + * @author Carlos Vargas , move code of main/notebook up here + * @package chamilo.library */ class NotebookManager { @@ -130,6 +130,7 @@ class NotebookManager * * @author Christian Fasanando * @author Patrick Cool , Ghent University, Belgium + * @return bool * @version januari 2009, dokeos 1.8.6 */ public static function update_note($values) diff --git a/main/inc/lib/promotion.lib.php b/main/inc/lib/promotion.lib.php index 08fc8efa0f..3d3a3b49b7 100755 --- a/main/inc/lib/promotion.lib.php +++ b/main/inc/lib/promotion.lib.php @@ -160,8 +160,14 @@ class Promotion extends Model { // Action links echo '
'; - echo ''.Display::return_icon('back.png', - get_lang('Back'), '', '32').''; + echo ''. + Display::return_icon( + 'back.png', + get_lang('Back'), + '', + '32' + ) + .''; echo ''. Display::return_icon( 'new_promotion.png', diff --git a/main/inc/lib/statistics.lib.php b/main/inc/lib/statistics.lib.php index db41fe86dc..d105ec58b1 100644 --- a/main/inc/lib/statistics.lib.php +++ b/main/inc/lib/statistics.lib.php @@ -100,8 +100,12 @@ class Statistics * @param bool $onlyActive Count only active users (false to only return currently active users) * @return int Number of users counted */ - public static function countUsers($status = null, $categoryCode = null, $countInvisibleCourses = true, $onlyActive = false) - { + public static function countUsers( + $status = null, + $categoryCode = null, + $countInvisibleCourses = true, + $onlyActive = false + ) { // Database table definitions $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER); $course_table = Database::get_main_table(TABLE_MAIN_COURSE); @@ -223,8 +227,12 @@ class Statistics * @param string $direction * @return array */ - public static function getActivitiesData($from, $numberOfItems, $column, $direction) - { + public static function getActivitiesData( + $from, + $numberOfItems, + $column, + $direction + ) { $track_e_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); $table_user = Database::get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); @@ -396,8 +404,12 @@ class Statistics * @param bool $showTotal * @param bool $isFileSize */ - public static function printStats($title, $stats, $showTotal = true, $isFileSize = false) - { + public static function printStats( + $title, + $stats, + $showTotal = true, + $isFileSize = false + ) { $total = 0; $data = self::rescale($stats); echo ' diff --git a/main/inc/lib/sub_language.class.php b/main/inc/lib/sub_language.class.php index 28e08fab5f..ee4a8e0b25 100644 --- a/main/inc/lib/sub_language.class.php +++ b/main/inc/lib/sub_language.class.php @@ -392,7 +392,7 @@ class SubLanguageManager */ public static function set_platform_language($language_id) { - if (empty($language_id) or (intval($language_id) != $language_id)) { + if (empty($language_id) || (intval($language_id) != $language_id)) { return false; } $language_id = intval($language_id); diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php index 2cf142bfa5..5c23af0919 100755 --- a/main/inc/lib/system_announcements.lib.php +++ b/main/inc/lib/system_announcements.lib.php @@ -67,7 +67,10 @@ class SystemAnnouncementManager $groups = array(); foreach ($temp_user_groups as $user_group) { $groups = array_merge($groups, array($user_group['id'])); - $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id'])); + $groups = array_merge( + $groups, + $userGroup->get_parent_groups($user_group['id']) + ); } $groups_string = '('.implode($groups, ',').')'; @@ -379,8 +382,16 @@ class SystemAnnouncementManager //Fixing urls that are sent by email //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); - $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); - $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); + $content = str_replace( + 'src=\"'.api_get_path(REL_HOME_PATH), + 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), + $content + ); + $content = str_replace( + 'file='.api_get_path(REL_HOME_PATH), + 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), + $content + ); $lang = is_null($lang) ? '' : $lang; $current_access_url_id = 1; @@ -568,8 +579,16 @@ class SystemAnnouncementManager //Fixing urls that are sent by email //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); - $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); - $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); + $content = str_replace( + 'src=\"'.api_get_path(REL_HOME_PATH), + 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), + $content + ); + $content = str_replace( + 'file='.api_get_path(REL_HOME_PATH), + 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), + $content + ); if ($sendEmailTest) { self::send_system_announcement_by_email( diff --git a/main/inc/lib/table_sort.class.php b/main/inc/lib/table_sort.class.php index cf2af1851a..9bcbad86c1 100755 --- a/main/inc/lib/table_sort.class.php +++ b/main/inc/lib/table_sort.class.php @@ -11,7 +11,7 @@ define('SORT_DATE', 3); define('SORT_IMAGE', 4); /** - * @package chamilo.library + * Class TableSort */ class TableSort { @@ -25,8 +25,12 @@ class TableSort * @return array The sorted dataset * @author bart.mollet@hogent.be */ - public static function sort_table($data, $column = 0, $direction = SORT_ASC, $type = SORT_REGULAR) - { + public static function sort_table( + $data, + $column = 0, + $direction = SORT_ASC, + $type = SORT_REGULAR + ) { if (!is_array($data) || empty($data)) { return array(); } diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 10a846bafe..9949265687 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -3972,8 +3972,11 @@ class Tracking * @param int Session id (optional) * @return int Chat last connections by course in x days */ - public static function chat_connections_during_last_x_days_by_course($course_code, $last_days, $session_id = 0) - { + public static function chat_connections_during_last_x_days_by_course( + $course_code, + $last_days, + $session_id = 0 + ) { $course_info = api_get_course_info($course_code); if (empty($course_info)) { return null; @@ -4009,8 +4012,11 @@ class Tracking * @param int Session id (optional) * @return string datetime formatted without day (e.g: February 23, 2010 10:20:50 ) */ - public static function chat_last_connection($student_id, $courseId, $session_id = 0) - { + public static function chat_last_connection( + $student_id, + $courseId, + $session_id = 0 + ) { $student_id = intval($student_id); $courseId = intval($courseId); $session_id = intval($session_id);