diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index c43dfbffa6..9e83fdc897 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -25,20 +25,20 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - - name: Checkout - uses: actions/checkout@v1 + - name: Checkout + uses: actions/checkout@v1 - - name: Setup PHP Action - uses: shivammathur/setup-php@1.6.1 - with: - php-version: ${{ matrix.php-versions }} - extensions: mbstring, xml, ctype, iconv, mysql, gd, soap, intl, zip, bcmath + - name: Setup PHP Action + uses: shivammathur/setup-php@1.6.1 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, xml, ctype, iconv, mysql, gd, soap, intl, zip, bcmath - - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest - - name: Composer analyse - run: composer analyse + - name: Composer analyse + run: composer analyse # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" # Docs: https://getcomposer.org/doc/articles/scripts.md diff --git a/public/main/admin/access_url_add_courses_to_url.php b/public/main/admin/access_url_add_courses_to_url.php index 6ed564b431..d19d829110 100644 --- a/public/main/admin/access_url_add_courses_to_url.php +++ b/public/main/admin/access_url_add_courses_to_url.php @@ -5,7 +5,6 @@ * It displays a list of users and a list of courses; * you can select multiple users and courses and then click on. * - * * @author Julio Montoya */ $cidReset = true; diff --git a/public/main/admin/access_url_add_usergroup_to_url.php b/public/main/admin/access_url_add_usergroup_to_url.php index 90186a5a1a..dfc47bc045 100644 --- a/public/main/admin/access_url_add_usergroup_to_url.php +++ b/public/main/admin/access_url_add_usergroup_to_url.php @@ -5,7 +5,6 @@ * It displays a list of users and a list of courses; * you can select multiple users and courses and then click on. * - * * @author Julio Montoya */ $cidReset = true; diff --git a/public/main/admin/access_url_add_users_to_url.php b/public/main/admin/access_url_add_users_to_url.php index bf9f8766d5..2f34824601 100644 --- a/public/main/admin/access_url_add_users_to_url.php +++ b/public/main/admin/access_url_add_users_to_url.php @@ -5,7 +5,6 @@ * It displays a list of users and a list of courses; * you can select multiple users and courses and then click on. * - * * @author Julio Montoya */ $cidReset = true; diff --git a/public/main/admin/access_url_edit_users_to_url.php b/public/main/admin/access_url_edit_users_to_url.php index c43b227472..f0fe915a51 100644 --- a/public/main/admin/access_url_edit_users_to_url.php +++ b/public/main/admin/access_url_edit_users_to_url.php @@ -98,7 +98,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) { $user_info = api_get_user_info($user); if (!empty($user_info)) { $user_added_list[] = $i.'. '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, null, $user_info['username']); - ++$i; + $i++; } } if (!empty($user_added_list)) { @@ -114,7 +114,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) { $user_info = api_get_user_info($user); if (!empty($user_info)) { $user_deleted_list[] = $i.'. '.api_get_person_name($user_info['firstname'], $user_info['lastname']); - ++$i; + $i++; } } if (!empty($user_deleted_list)) { diff --git a/public/main/admin/access_urls.php b/public/main/admin/access_urls.php index 1dc3aaa856..728a3049e4 100644 --- a/public/main/admin/access_urls.php +++ b/public/main/admin/access_urls.php @@ -5,7 +5,6 @@ /** * Frontend script for multiple access urls. * - * * @author Julio Montoya * @author Yannick Warnier */ diff --git a/public/main/admin/add_users_to_usergroup.php b/public/main/admin/add_users_to_usergroup.php index bcbe9c5c08..efcf642b6d 100644 --- a/public/main/admin/add_users_to_usergroup.php +++ b/public/main/admin/add_users_to_usergroup.php @@ -169,7 +169,7 @@ if (is_array($extra_field_list)) { if ($use_extra_fields) { $final_result = []; if (count($extra_field_result) > 1) { - for ($i = 0; $i < count($extra_field_result) - 1; ++$i) { + for ($i = 0; $i < count($extra_field_result) - 1; $i++) { if (is_array($extra_field_result[$i + 1])) { $final_result = array_intersect($extra_field_result[$i], $extra_field_result[$i + 1]); } diff --git a/public/main/admin/course_request_accepted.php b/public/main/admin/course_request_accepted.php index fa2b0747c7..e468b2317a 100644 --- a/public/main/admin/course_request_accepted.php +++ b/public/main/admin/course_request_accepted.php @@ -5,7 +5,6 @@ /** * A list containig the accepted course requests. * - * * @author José Manuel Abuin Mosquera , 2010 * @author Bruno Rubio Gayo , 2010 * Centro de Supercomputacion de Galicia (CESGA) diff --git a/public/main/admin/course_request_edit.php b/public/main/admin/course_request_edit.php index 3229661aed..06521521d0 100644 --- a/public/main/admin/course_request_edit.php +++ b/public/main/admin/course_request_edit.php @@ -5,7 +5,6 @@ /** * A page for detailed preview or edition of a given course request. * - * * @author Ivan Tcholakov , 2010 */ $cidReset = true; diff --git a/public/main/admin/course_request_rejected.php b/public/main/admin/course_request_rejected.php index 793c80fcba..b9e91335fe 100644 --- a/public/main/admin/course_request_rejected.php +++ b/public/main/admin/course_request_rejected.php @@ -5,7 +5,6 @@ /** * A list containing the rejected course requests. * - * * @author José Manuel Abuin Mosquera , 2010 * @author Bruno Rubio Gayo , 2010 * Centro de Supercomputacion de Galicia (CESGA) diff --git a/public/main/admin/course_request_review.php b/public/main/admin/course_request_review.php index 7c05a3802f..3f3e364961 100644 --- a/public/main/admin/course_request_review.php +++ b/public/main/admin/course_request_review.php @@ -5,7 +5,6 @@ /** * A list containing the pending course requests. * - * * @author José Manuel Abuin Mosquera , 2010 * Centro de Supercomputacion de Galicia (CESGA) * @author Ivan Tcholakov (technical adaptation for Chamilo 1.8.8), 2010 diff --git a/public/main/admin/dashboard_add_users_to_user.php b/public/main/admin/dashboard_add_users_to_user.php index a32e8b4cd1..2aae315f90 100644 --- a/public/main/admin/dashboard_add_users_to_user.php +++ b/public/main/admin/dashboard_add_users_to_user.php @@ -153,7 +153,7 @@ function search_users($needle, $type = 'multiple') $rs = Database::query($sql); $i = 0; while ($user = Database :: fetch_array($rs)) { - ++$i; + $i++; if ($i <= 10) { $person_name = api_get_person_name($user['firstname'], $user['lastname']); $return .= ''.$person_name.' ('.$user['username'].')
'; diff --git a/public/main/admin/email_tester.php b/public/main/admin/email_tester.php index 7a7f78a503..14e77dfb38 100644 --- a/public/main/admin/email_tester.php +++ b/public/main/admin/email_tester.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * Index page of the admin tools. - * - * @package chamilo.admin */ // Resetting the course id. $cidReset = true; diff --git a/public/main/admin/export_certificates.php b/public/main/admin/export_certificates.php index 34aeeba24d..6d37fdb605 100644 --- a/public/main/admin/export_certificates.php +++ b/public/main/admin/export_certificates.php @@ -1,9 +1,6 @@ get($field_id); $check = Security::check_token('request'); $token = Security::get_token(); -if ($action == 'add') { +if ('add' == $action) { $interbreadcrumb[] = ['url' => 'extra_fields.php?type='.$extra_field->type, 'name' => $extra_field->pageName]; $interbreadcrumb[] = [ 'url' => 'extra_fields.php?type='.$extra_field->type.'&action=edit&id='.$extra_field_info['id'], @@ -47,7 +44,7 @@ if ($action == 'add') { 'name' => get_lang('Edit extra field options'), ]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; -} elseif ($action == 'edit') { +} elseif ('edit' == $action) { $interbreadcrumb[] = ['url' => 'extra_fields.php?type='.$extra_field->type, 'name' => $extra_field->pageName]; $interbreadcrumb[] = [ 'url' => 'extra_fields.php?type='.$extra_field->type.'&action=edit&id='.$extra_field_info['id'], @@ -148,7 +145,7 @@ $obj->fieldId = $field_id; // Action handling: Add switch ($action) { case 'add': - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&'.$params; diff --git a/public/main/admin/extra_field_workflow.php b/public/main/admin/extra_field_workflow.php index 28e9f27f8a..467a696206 100644 --- a/public/main/admin/extra_field_workflow.php +++ b/public/main/admin/extra_field_workflow.php @@ -3,9 +3,6 @@ use Chamilo\CoreBundle\Entity\ExtraFieldOptionRelFieldOption; -/** - * @package chamilo.admin - */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -35,7 +32,7 @@ $extraFieldInfo = $extraField->get($field_id); $check = Security::check_token('request'); $token = Security::get_token(); -if ($action == 'add') { +if ('add' == $action) { $interbreadcrumb[] = ['url' => 'extra_fields.php?type='.$extraField->type, 'name' => $extraField->pageName]; $interbreadcrumb[] = [ 'url' => 'extra_fields.php?type='.$extraField->type.'&action=edit&id='.$extraFieldInfo['id'], @@ -46,7 +43,7 @@ if ($action == 'add') { 'name' => get_lang('Edit extra field options'), ]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; -} elseif ($action == 'edit') { +} elseif ('edit' == $action) { $interbreadcrumb[] = [ 'url' => 'extra_fields.php?type='.$extraField->type, 'name' => $extraField->pageName, @@ -234,7 +231,7 @@ if ($form->validate()) { ] ); - if ($value == 1) { + if (1 == $value) { if (empty($extraFieldOptionRelFieldOption)) { $extraFieldOptionRelFieldOption = new ExtraFieldOptionRelFieldOption(); $extraFieldOptionRelFieldOption diff --git a/public/main/admin/extra_fields.php b/public/main/admin/extra_fields.php index 33582f7f69..aa1cde0c3f 100644 --- a/public/main/admin/extra_fields.php +++ b/public/main/admin/extra_fields.php @@ -1,9 +1,6 @@ 'grade_models.php', 'name' => get_lang('Grading model')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; -} elseif ($action == 'edit') { +} elseif ('edit' == $action) { $interbreadcrumb[] = ['url' => 'grade_models.php', 'name' => get_lang('Grading model')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')]; } else { @@ -136,7 +136,7 @@ $obj = new GradeModel(); // Action handling: Add switch ($action) { case 'add': - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } diff --git a/public/main/admin/gradebook_dependency.php b/public/main/admin/gradebook_dependency.php index 4eab16f3ce..419c929699 100644 --- a/public/main/admin/gradebook_dependency.php +++ b/public/main/admin/gradebook_dependency.php @@ -8,7 +8,7 @@ require_once __DIR__.'/../inc/global.inc.php'; api_protect_admin_script(); $allow = api_get_configuration_value('gradebook_dependency'); -if ($allow == false) { +if (false == $allow) { api_not_allowed(true); } diff --git a/public/main/admin/gradebook_list.php b/public/main/admin/gradebook_list.php index c2ca71510b..0d8e1e1628 100644 --- a/public/main/admin/gradebook_list.php +++ b/public/main/admin/gradebook_list.php @@ -10,7 +10,7 @@ require_once __DIR__.'/../inc/global.inc.php'; api_protect_admin_script(); $allow = api_get_configuration_value('gradebook_dependency'); -if ($allow == false) { +if (false == $allow) { api_not_allowed(true); } diff --git a/public/main/admin/index.php b/public/main/admin/index.php index 9b29fb9e19..76644d4c0a 100644 --- a/public/main/admin/index.php +++ b/public/main/admin/index.php @@ -7,8 +7,6 @@ use League\Flysystem\Filesystem; /** * Index page of the admin tools. - * - * @package chamilo.admin */ // Resetting the course id. $cidReset = true; @@ -162,7 +160,7 @@ if (api_is_platform_admin()) { $items[] = ['url' => 'course_list.php', 'label' => get_lang('Course list')]; $items[] = ['url' => 'course_add.php', 'label' => get_lang('Add course')]; - if (api_get_setting('course_validation') == 'true') { + if ('true' == api_get_setting('course_validation')) { $items[] = ['url' => 'course_request_review.php', 'label' => get_lang('Review incoming course requests')]; $items[] = ['url' => 'course_request_accepted.php', 'label' => get_lang('Accepted course requests')]; $items[] = ['url' => 'course_request_rejected.php', 'label' => get_lang('Rejected course requests')]; @@ -174,7 +172,7 @@ if (api_is_platform_admin()) { $items[] = ['url' => 'subscribe_user2course.php', 'label' => get_lang('Add a user to a course')]; $items[] = ['url' => 'course_user_import.php', 'label' => get_lang('Import users list')]; - if (api_get_setting('gradebook_enable_grade_model') == 'true') { + if ('true' == api_get_setting('gradebook_enable_grade_model')) { $items[] = ['url' => 'grade_models.php', 'label' => get_lang('Grading model')]; } @@ -381,14 +379,14 @@ if (api_is_platform_admin()) { } } - if (api_get_plugin_setting('dictionary', 'enable_plugin_dictionary') == 'true') { + if ('true' == api_get_plugin_setting('dictionary', 'enable_plugin_dictionary')) { $items[] = [ 'url' => api_get_path(WEB_PLUGIN_PATH).'dictionary/terms.php', 'label' => get_lang('Dictionary'), ]; } - if (api_get_setting('allow_terms_conditions') == 'true') { + if ('true' == api_get_setting('allow_terms_conditions')) { $items[] = ['url' => 'legal_add.php', 'label' => get_lang('Terms and Conditions')]; } @@ -452,7 +450,7 @@ if (api_is_platform_admin()) { 'label' => get_lang('Tickets'), ]; - if (api_get_configuration_value('db_manager_enabled') == true && + if (true == api_get_configuration_value('db_manager_enabled') && api_is_global_platform_admin() ) { $host = $_configuration['db_host']; @@ -601,7 +599,7 @@ $tpl = new Template(); // Display the Site Use Cookie Warning Validation $useCookieValidation = api_get_setting('cookie_warning'); -if ($useCookieValidation === 'true') { +if ('true' === $useCookieValidation) { if (isset($_POST['acceptCookies'])) { api_set_site_use_cookie_warning_cookie(); } elseif (!api_site_use_cookie_warning_cookie_exist()) { diff --git a/public/main/admin/languages.php b/public/main/admin/languages.php index aba7509c66..a333210aa9 100644 --- a/public/main/admin/languages.php +++ b/public/main/admin/languages.php @@ -27,9 +27,9 @@ $action = isset($_GET['action']) ? $_GET['action'] : null; //Ajax request if (isset($_POST['sent_http_request'])) { if (isset($_POST['visibility']) && - $_POST['visibility'] == strval(intval($_POST['visibility'])) && $_POST['visibility'] == 0) { + $_POST['visibility'] == strval(intval($_POST['visibility'])) && 0 == $_POST['visibility']) { if (isset($_POST['id']) && $_POST['id'] == strval(intval($_POST['id']))) { - if (SubLanguageManager::check_if_language_is_used($_POST['id']) == false) { + if (false == SubLanguageManager::check_if_language_is_used($_POST['id'])) { SubLanguageManager::make_unavailable_language($_POST['id']); echo 'set_hidden'; } else { @@ -38,7 +38,7 @@ if (isset($_POST['sent_http_request'])) { } } if (isset($_POST['visibility']) && - $_POST['visibility'] == strval(intval($_POST['visibility'])) && $_POST['visibility'] == 1 + $_POST['visibility'] == strval(intval($_POST['visibility'])) && 1 == $_POST['visibility'] ) { if (isset($_POST['id']) && $_POST['id'] == strval(intval($_POST['id']))) { SubLanguageManager::make_available_language($_POST['id']); @@ -186,7 +186,7 @@ switch ($action) { $failedDisabledLanguages = ''; $checkFailed = false; foreach ($allLanguages as $language) { - if (SubLanguageManager::check_if_language_is_used($language['id']) == false) { + if (false == SubLanguageManager::check_if_language_is_used($language['id'])) { SubLanguageManager::make_unavailable_language($language['id']); } else { if (intval(SubLanguageManager::get_platform_language_id()) !== intval($language['id'])) { @@ -205,7 +205,7 @@ switch ($action) { break; case 'make_unavailable_confirmed': $language_info = SubLanguageManager::get_all_information_of_language($id); - if ($language_info['available'] == 1) { + if (1 == $language_info['available']) { SubLanguageManager::make_unavailable_language($id); $platform_language = api_get_setting('platformLanguage'); UserManager::update_all_user_languages($language_info['english_name'], $platform_language); @@ -224,7 +224,7 @@ if (isset($_POST['Submit']) && $_POST['Submit']) { WHERE id='$postId'"; $result = Database::query($sql); // changing the Platform language - if ($_POST['platformlanguage'] && $_POST['platformlanguage'] != '') { + if ($_POST['platformlanguage'] && '' != $_POST['platformlanguage']) { api_set_setting('platformLanguage', $_POST['platformlanguage'], null, null, api_get_current_access_url_id()); header("Location: $url"); exit; @@ -285,7 +285,7 @@ while ($row = Database::fetch_array($result_select)) { $row_td[] = $row['id']; $checked = ''; // the first column is the original name of the language OR a form containing the original name - if ($action == 'edit' && $row['id'] == $id) { + if ('edit' == $action && $row['id'] == $id) { if ($row['english_name'] == api_get_setting('platformLanguage')) { $checked = ' checked="checked" '; } @@ -321,13 +321,13 @@ while ($row = Database::fetch_array($result_select)) { $allow_add_term_sub_language = null; $allow_use_sub_language = ''; $allow_add_term_sub_language = ''; - if (api_get_setting('allow_use_sub_language') === 'true') { + if ('true' === api_get_setting('allow_use_sub_language')) { $verified_if_is_sub_language = SubLanguageManager::check_if_language_is_sub_language($row['id']); - if ($verified_if_is_sub_language === false) { + if (false === $verified_if_is_sub_language) { $verified_if_is_father = SubLanguageManager::check_if_language_is_father($row['id']); $allow_use_sub_language = " ". Display::return_icon('new_language.png', get_lang('Create sub-language'), [], ICON_SIZE_SMALL).""; - if ($verified_if_is_father === true) { + if (true === $verified_if_is_father) { $allow_add_term_sub_language = ''; } else { $allow_add_term_sub_language = ''; @@ -346,7 +346,7 @@ while ($row = Database::fetch_array($result_select)) { Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."  ".$setplatformlanguage.$allow_use_sub_language.$allow_add_term_sub_language.$allow_delete_sub_language; } else { - if ($row['available'] == 1) { + if (1 == $row['available']) { $row_td[] = "". Display::return_icon('visible.png', get_lang('Make unavailable'), ['id' => 'imglinktool_'.$row['id']], ICON_SIZE_SMALL)." ".Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)." ".$setplatformlanguage.$allow_use_sub_language.$allow_add_term_sub_language.$allow_delete_sub_language; } else { diff --git a/public/main/admin/ldap_form_add_users_group.php b/public/main/admin/ldap_form_add_users_group.php index 29f4eff775..2ff3d51801 100644 --- a/public/main/admin/ldap_form_add_users_group.php +++ b/public/main/admin/ldap_form_add_users_group.php @@ -2,9 +2,6 @@ /* For licensing terms, see /license.txt */ /** * Form to add users through LDAP (deprecated?). - * - * @package chamilo.admin - * Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) */ /** @@ -12,7 +9,7 @@ */ $nbre = 0; echo '
'; -if ($statut == 1) { +if (1 == $statut) { echo get_lang( 'e-mailNotifySubscription' ).': '.get_lang( diff --git a/public/main/admin/ldap_import_students.php b/public/main/admin/ldap_import_students.php index 1e422e1179..1fab273f80 100644 --- a/public/main/admin/ldap_import_students.php +++ b/public/main/admin/ldap_import_students.php @@ -3,9 +3,6 @@ /** * Script to import students from LDAP. - * - * @package chamilo.admin - * Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) */ // resetting the course id $cidReset = true; @@ -127,7 +124,7 @@ if (empty($annee) && empty($course)) { echo ''.get_lang('Back to start new search').''; echo '

'; echo ''; -} elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes')) { +} elseif (!empty($annee) && !empty($course) && ('yes' == $_POST['confirmed'])) { $id = $_POST['username_form']; $UserList = []; $userid_match_login = []; diff --git a/public/main/admin/ldap_import_students_to_session.php b/public/main/admin/ldap_import_students_to_session.php index 80202b8e99..149a0f221d 100644 --- a/public/main/admin/ldap_import_students_to_session.php +++ b/public/main/admin/ldap_import_students_to_session.php @@ -2,9 +2,6 @@ /* For licensing terms, see /license.txt */ /** * Edition script for sessions categories. - * - * @package chamilo.admin - * Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard) */ // resetting the course id @@ -131,7 +128,7 @@ elseif (!empty($annee) && !empty($id_session) && empty($_POST['confirmed'])) { echo ''.get_lang('Back to start new search').''; echo '

'; echo ''; -} elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed'] == 'yes')) { +} elseif (!empty($annee) && !empty($id_session) && ('yes' == $_POST['confirmed'])) { $id = $_POST['username_form']; $UserList = []; $userid_match_login = []; @@ -155,7 +152,7 @@ elseif (!empty($annee) && !empty($id_session) && empty($_POST['confirmed'])) { 'registered_at' => api_get_utc_datetime(), ] ); - if ($res_user !== false) { + if (false !== $res_user) { $num++; } } diff --git a/public/main/admin/ldap_users_list.php b/public/main/admin/ldap_users_list.php index 0e46cf3017..4102206440 100644 --- a/public/main/admin/ldap_users_list.php +++ b/public/main/admin/ldap_users_list.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * @author Mustapha Alouani - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -16,7 +14,7 @@ $action = @$_GET["action"] ?: null; $login_as_user_id = @$_GET["user_id"] ?: null; // Login as ... -if ($action == "login_as" && !empty($login_as_user_id)) { +if ("login_as" == $action && !empty($login_as_user_id)) { login_user($login_as_user_id); } @@ -123,7 +121,7 @@ if (isset($_POST['action'])) { $UserList[] = ldap_add_user($user_id); } } - if (isset($_GET['id_session']) && (trim($_GET['id_session']) != "")) { + if (isset($_GET['id_session']) && ("" != trim($_GET['id_session']))) { addUserToSession($UserList, $_GET['id_session']); } if (count($UserList) > 0) { diff --git a/public/main/admin/ldap_users_synchro.php b/public/main/admin/ldap_users_synchro.php index ffbfebcc38..0831d3a461 100644 --- a/public/main/admin/ldap_users_synchro.php +++ b/public/main/admin/ldap_users_synchro.php @@ -1,8 +1,6 @@ validate()) { $default['content'] = $content; if (isset($values['language'])) { - if ($submit == 'back') { + if ('back' == $submit) { header('Location: legal_add.php'); exit; - } elseif ($submit === 'save') { + } elseif ('save' === $submit) { $id = LegalManager::add($lang, $content, $type, $changes, $values); if (!empty($id)) { Display::addFlash(Display::return_message(get_lang('Term and condition saved'), 'success')); @@ -84,7 +82,7 @@ if ($form->validate()) { $tok = Security::get_token(); header('Location: legal_list.php?sec_token='.$tok); exit(); - } elseif ($submit === 'preview') { + } elseif ('preview' === $submit) { $defaults['type'] = $type; $defaults['content'] = $content; $defaults['changes'] = $changes; @@ -138,7 +136,7 @@ if (isset($_POST['language'])) { $preview = LegalManager::show_last_condition($term_preview); - if ($term_preview['type'] != -1) { + if (-1 != $term_preview['type']) { $preview = LegalManager::replaceTags($preview); $form->addElement('label', get_lang('Preview'), $preview); } diff --git a/public/main/admin/legal_list.php b/public/main/admin/legal_list.php index 33ea338284..33dd15e2f3 100644 --- a/public/main/admin/legal_list.php +++ b/public/main/admin/legal_list.php @@ -5,8 +5,6 @@ use Chamilo\CoreBundle\Repository\LegalRepository; /** * Sessions list script. - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/admin/promotions.php b/public/main/admin/promotions.php index afc5cc4379..b2f467300c 100644 --- a/public/main/admin/promotions.php +++ b/public/main/admin/promotions.php @@ -1,9 +1,6 @@ 'promotions.php', 'name' => get_lang('Promotions'), ]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; -} elseif ($action == 'edit') { +} elseif ('edit' == $action) { $interbreadcrumb[] = [ 'url' => 'promotions.php', 'name' => get_lang('Promotions'), @@ -43,14 +40,14 @@ if ($action == 'add') { Display::display_header(''); // Tool name -if (isset($_GET['action']) && $_GET['action'] == 'add') { +if (isset($_GET['action']) && 'add' == $_GET['action']) { $tool = 'Add'; $interbreadcrumb[] = [ 'url' => api_get_self(), 'name' => get_lang('Promotion'), ]; } -if (isset($_GET['action']) && $_GET['action'] == 'edit') { +if (isset($_GET['action']) && 'edit' == $_GET['action']) { $tool = 'Modify'; $interbreadcrumb[] = [ 'url' => api_get_self(), @@ -120,7 +117,7 @@ $promotion = new Promotion(); switch ($action) { case 'add': - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } @@ -200,7 +197,7 @@ switch ($action) { $promotion->display(); break; case 'copy': - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } if ($check) { diff --git a/public/main/admin/questions.php b/public/main/admin/questions.php index b3aa89c305..f6e3165e0f 100644 --- a/public/main/admin/questions.php +++ b/public/main/admin/questions.php @@ -7,9 +7,6 @@ use ChamiloSession as Session; use Doctrine\Common\Collections\Criteria; use Knp\Component\Pager\Paginator; -/** - * @package chamilo.admin - */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -177,7 +174,7 @@ if ($formSent) { /** @var CQuiz $exercise */ foreach ($exerciseList as $exercise) { $question->questionData .= $exercise->getTitle(); - if ($exercise->getActive() == -1) { + if (-1 == $exercise->getActive()) { $question->questionData .= '- ('.get_lang('The test has been deleted').' #'.$exercise->getIid().') '; } $question->questionData .= '
'; diff --git a/public/main/admin/settings.lib.php b/public/main/admin/settings.lib.php index 281450fe88..44ba28560c 100644 --- a/public/main/admin/settings.lib.php +++ b/public/main/admin/settings.lib.php @@ -13,8 +13,6 @@ use Symfony\Component\Filesystem\Filesystem; * @author Guillaume Viguier * * @since Chamilo 1.8.7 - * - * @package chamilo.admin */ define('CSS_UPLOAD_PATH', api_get_path(SYS_PATH).'Resources/public/css/themes/'); @@ -314,7 +312,7 @@ function handleStylesheets() ); } else { // Uploading a new stylesheet. - if ($urlId == 1) { + if (1 == $urlId) { $show_upload_form = true; } else { if ($is_style_changeable) { @@ -385,7 +383,7 @@ function handleStylesheets() ) ); - if ($webPlatformLogoPath !== null) { + if (null !== $webPlatformLogoPath) { $logoForm->addLabel( get_lang('Current logo'), '' @@ -540,7 +538,7 @@ function uploadStylesheet($values, $picture) $info = pathinfo($picture['name']); - if ($info['extension'] == 'zip') { + if ('zip' == $info['extension']) { // Try to open the file and extract it in the theme. $zip = new ZipArchive(); if ($zip->open($picture['tmp_name'])) { @@ -554,7 +552,7 @@ function uploadStylesheet($values, $picture) for ($i = 0; $i < $num_files; $i++) { $file = $zip->statIndex($i); - if (substr($file['name'], -1) != '/') { + if ('/' != substr($file['name'], -1)) { $path_parts = pathinfo($file['name']); if (!in_array($path_parts['extension'], $allowedFiles)) { $valid = false; @@ -562,7 +560,7 @@ function uploadStylesheet($values, $picture) } } - if (strpos($file['name'], '/') === false) { + if (false === strpos($file['name'], '/')) { $single_directory = false; } } @@ -588,14 +586,14 @@ function uploadStylesheet($values, $picture) $mode = api_get_permissions_for_new_directories(); for ($i = 0; $i < $num_files; $i++) { $entry = $zip->getNameIndex($i); - if (substr($entry, -1) == '/') { + if ('/' == substr($entry, -1)) { continue; } $pos_slash = strpos($entry, '/'); $entry_without_first_dir = substr($entry, $pos_slash + 1); // If there is still a slash, we need to make sure the directories are created. - if (strpos($entry_without_first_dir, '/') !== false) { + if (false !== strpos($entry_without_first_dir, '/')) { if (!is_dir($extraction_path.dirname($entry_without_first_dir))) { // Create it. @mkdir($extraction_path.dirname($entry_without_first_dir), $mode, true); @@ -664,7 +662,7 @@ function storeRegions() if (!empty($areas_to_installed)) { $plugin_obj->removeAllRegions($plugin); foreach ($areas_to_installed as $region) { - if (!empty($region) && $region != '-1') { + if (!empty($region) && '-1' != $region) { $plugin_obj->add_to_region($plugin, $region); } } @@ -781,7 +779,7 @@ function handleSearch() } $specific_fields = get_specific_field_list(); - if ($search_enabled == 'true') { + if ('true' == $search_enabled) { $values = api_get_settings_options('search_show_unlinked_results'); $group = formGenerateElementsGroup( $form, @@ -834,7 +832,7 @@ function handleSearch() $form->display(); echo ''; - if ($search_enabled == 'true') { + if ('true' == $search_enabled) { $xapianPath = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb'; /* @@ -913,14 +911,14 @@ function handleTemplates() * isset() combos all over the place. */ $action = isset($_GET['action']) ? $_GET['action'] : "invalid"; - if ($action != 'add') { + if ('add' != $action) { echo ''; } - if ($action == 'add' || ($action == 'edit' && is_numeric($_GET['id']))) { + if ('add' == $action || ('edit' == $action && is_numeric($_GET['id']))) { addEditTemplate(); // Add event to the system log. @@ -934,7 +932,7 @@ function handleTemplates() $user_id ); } else { - if ($action == 'delete' && is_numeric($_GET['id'])) { + if ('delete' == $action && is_numeric($_GET['id'])) { deleteTemplate($_GET['id']); // Add event to the system log @@ -1108,7 +1106,7 @@ function addEditTemplate() ); // Setting the form elements: the header. - if ($_GET['action'] == 'add') { + if ('add' == $_GET['action']) { $title = get_lang('Add a template'); } else { $title = get_lang('Template edition'); @@ -1137,7 +1135,7 @@ function addEditTemplate() $form->addElement('static', 'file_comment', '', get_lang('This image will represent the template in the templates list. It should be no larger than 100x70 pixels')); // Getting all the information of the template when editing a template. - if ($_GET['action'] == 'edit') { + if ('edit' == $_GET['action']) { $defaults['template_id'] = $id; $defaults['template_text'] = $template->getContent(); // Forcing get_lang(). @@ -1231,7 +1229,7 @@ function addEditTemplate() $bootstrap = api_get_bootstrap_and_font_awesome(); $viewport = ''; - if ($_GET['action'] == 'add') { + if ('add' == $_GET['action']) { $templateContent = ''.$viewport.''.$values['title'].''.$bootstrap.'' .$values['template_text']; $template @@ -1414,9 +1412,9 @@ function generateSettingsForm($settings, $settings_by_access_list) if (!empty($_configuration['multiple_access_urls'])) { if (api_is_global_platform_admin()) { - if ($row['access_url_locked'] == 0) { - if ($url_id == 1) { - if ($row['access_url_changeable'] == '1') { + if (0 == $row['access_url_locked']) { + if (1 == $url_id) { + if ('1' == $row['access_url_changeable']) { $form->addElement( 'html', '
'.get_lang('Remove picture').' '.Display::return_icon('delete.png', get_lang('Remove picture')).''; $form->addElement('html', '
'.$delete_url.'
'); } @@ -1767,12 +1765,12 @@ function searchSetting($search) $title = api_strtolower(get_lang($setting['title'])); // try the title - if (strpos($title, $search) === false) { + if (false === strpos($title, $search)) { $comment = api_strtolower(get_lang($setting['comment'])); //Try the comment - if (strpos($comment, $search) === false) { + if (false === strpos($comment, $search)) { //Try the variable name - if (strpos($setting['variable'], $search) === false) { + if (false === strpos($setting['variable'], $search)) { continue; } else { $found = true; @@ -1870,7 +1868,7 @@ function showSearchSettingsTable($data) function showSearchToolsStatusTable() { //@todo windows support - if (api_is_windows_os() == false) { + if (false == api_is_windows_os()) { $list_of_programs = ['pdftotext', 'ps2pdf', 'catdoc', 'html2text', 'unrtf', 'catppt', 'xls2csv']; foreach ($list_of_programs as $program) { $output = []; @@ -1940,7 +1938,7 @@ function isStyleChangeable() if ($urlId) { $style_info = api_get_settings('stylesheets', '', 1, 0); $url_info = api_get_access_url($urlId); - if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) { + if (1 == $style_info[0]['access_url_changeable'] && 1 == $url_info['active']) { $changeable = true; } } else { @@ -1962,13 +1960,13 @@ function getCategorySettings($category = '') $url_id = api_get_current_access_url_id(); $settings_by_access_list = []; - if ($url_id == 1) { + if (1 == $url_id) { $settings = api_get_settings($category, 'group', $url_id); } else { $url_info = api_get_access_url($url_id); - if ($url_info['active'] == 1) { + if (1 == $url_info['active']) { $categoryToSearch = $category; - if ($category == 'search_setting') { + if ('search_setting' == $category) { $categoryToSearch = ''; } // The default settings of Chamilo @@ -1988,7 +1986,7 @@ function getCategorySettings($category = '') } // One more validation if is changeable. - if ($row['access_url_changeable'] == 1) { + if (1 == $row['access_url_changeable']) { $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; } else { $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = []; @@ -1997,7 +1995,7 @@ function getCategorySettings($category = '') } } - if (isset($category) && $category == 'search_setting') { + if (isset($category) && 'search_setting' == $category) { if (!empty($_REQUEST['search_field'])) { $settings = searchSetting($_REQUEST['search_field']); } diff --git a/public/main/admin/settings.php b/public/main/admin/settings.php index 884e79ca5a..6ecb425f84 100644 --- a/public/main/admin/settings.php +++ b/public/main/admin/settings.php @@ -9,8 +9,6 @@ use ChamiloSession as Session; * * @author Patrick Cool * @author Julio Montoya - Multiple URL site - * - * @package chamilo.admin */ // Resetting the course id. @@ -27,7 +25,7 @@ $_SESSION['this_section'] = $this_section; api_protect_admin_script(); // Submit stylesheets. -if (isset($_POST['save']) && isset($_GET['category']) && $_GET['category'] === 'Stylesheets') { +if (isset($_POST['save']) && isset($_GET['category']) && 'Stylesheets' === $_GET['category']) { storeStylesheets(); Display::addFlash(Display::return_message(get_lang('Saved.'))); } @@ -68,7 +66,7 @@ if (isset($_GET['delete_watermark'])) { Display::addFlash(Display::return_message(get_lang('File deleted'))); } -if (isset($_GET['action']) && $_GET['action'] == 'delete_grading') { +if (isset($_GET['action']) && 'delete_grading' == $_GET['action']) { $id = intval($_GET['id']); api_delete_setting_option($id); } @@ -166,19 +164,19 @@ if (!empty($_GET['category']) && } } - if (isset($values['allow_social_tool']) && $values['allow_social_tool'] == 'true') { + if (isset($values['allow_social_tool']) && 'true' == $values['allow_social_tool']) { $values['allow_message_tool'] = 'true'; } foreach ($settings as $item) { $key = $item['variable']; - if ($key === 'prevent_multiple_simultaneous_login') { + if ('prevent_multiple_simultaneous_login' === $key) { Session::write('first_user_login', 1); } if (in_array($key, $settings_to_avoid)) { continue; } - if ($key == 'search_field' || $key == 'submit_fixed_in_bottom') { + if ('search_field' == $key || 'submit_fixed_in_bottom' == $key) { continue; } $key = Database::escape_string($key); @@ -195,14 +193,14 @@ if (!empty($_GET['category']) && $keys = []; foreach ($values as $key => $value) { - if (strcmp($key, 'MAX_FILE_SIZE') === 0) { + if (0 === strcmp($key, 'MAX_FILE_SIZE')) { continue; } if (in_array($key, $settings_to_avoid)) { continue; } // Avoid form elements which have nothing to do with settings - if ($key == 'search_field' || $key == 'submit_fixed_in_bottom') { + if ('search_field' == $key || 'submit_fixed_in_bottom' == $key) { continue; } @@ -223,9 +221,9 @@ if (!empty($_GET['category']) && case 'course_validation_terms_and_conditions_url': // URL validation for some settings. $value = trim(Security::remove_XSS($value)); - if ($value != '') { + if ('' != $value) { // Here we accept absolute URLs only. - if (strpos($value, '://') === false) { + if (false === strpos($value, '://')) { $value = 'http://'.$value; } if (!api_valid_url($value, true)) { @@ -238,7 +236,7 @@ if (!empty($_GET['category']) && case 'emailAdministrator': // Validation against e-mail address for some settings. $value = trim(Security::remove_XSS($value)); - if ($value != '' && !api_valid_email($value)) { + if ('' != $value && !api_valid_email($value)) { // If the new (non-empty) e-mail address is invalid, then the old e-mail address stays. // If the new e-mail address is empty, then it will be stored (i.e. the setting will be deleted). $value = $old_value; @@ -256,8 +254,8 @@ if (!empty($_GET['category']) && while ($row_subkeys = Database::fetch_array($res)) { // If subkey is changed: - if ((isset($value[$row_subkeys['subkey']]) && api_get_setting($key, $row_subkeys['subkey']) == 'false') || - (!isset($value[$row_subkeys['subkey']]) && api_get_setting($key, $row_subkeys['subkey']) == 'true') + if ((isset($value[$row_subkeys['subkey']]) && 'false' == api_get_setting($key, $row_subkeys['subkey'])) || + (!isset($value[$row_subkeys['subkey']]) && 'true' == api_get_setting($key, $row_subkeys['subkey'])) ) { $keys[] = $key; break; diff --git a/public/main/admin/skill.php b/public/main/admin/skill.php index d84efdba5e..58f86cc3b9 100644 --- a/public/main/admin/skill.php +++ b/public/main/admin/skill.php @@ -5,8 +5,6 @@ use Chamilo\CoreBundle\Entity\Skill; /** * This script manages the skills, levels and profiles assignments. - * - * @package chamilo.skill */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/admin/skill_badge.php b/public/main/admin/skill_badge.php index 69aef43e05..16de1eb6a3 100644 --- a/public/main/admin/skill_badge.php +++ b/public/main/admin/skill_badge.php @@ -4,8 +4,6 @@ * Show information about Mozilla OpenBadges. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.admin.openbadges */ $cidReset = true; @@ -19,7 +17,7 @@ Skill::isAllowed(); $backpack = 'https://backpack.openbadges.org/'; $configBackpack = api_get_setting('openbadges_backpack'); -if (strcmp($backpack, $configBackpack) !== 0) { +if (0 !== strcmp($backpack, $configBackpack)) { $backpack = $configBackpack; } diff --git a/public/main/admin/skill_badge_create.php b/public/main/admin/skill_badge_create.php index 6eb970928f..138c5752e4 100644 --- a/public/main/admin/skill_badge_create.php +++ b/public/main/admin/skill_badge_create.php @@ -5,8 +5,6 @@ * Show information about Mozilla OpenBadges. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.admin.openbadges */ $cidReset = true; @@ -32,12 +30,12 @@ $badgeStudio = [ 'script_js' => '', ]; -if ($_SERVER['REQUEST_METHOD'] === 'POST') { +if ('POST' === $_SERVER['REQUEST_METHOD']) { $params = [ 'id' => $skillId, ]; - if ((isset($_FILES['image']) && $_FILES['image']['error'] == 0) || + if ((isset($_FILES['image']) && 0 == $_FILES['image']['error']) || !empty($_POST['badge_studio_image']) ) { $dirPermissions = api_get_permissions_for_new_directories(); diff --git a/public/main/admin/skill_badge_list.php b/public/main/admin/skill_badge_list.php index 4a6f1fe456..46258bab37 100644 --- a/public/main/admin/skill_badge_list.php +++ b/public/main/admin/skill_badge_list.php @@ -6,8 +6,6 @@ * * @author Angel Fernando Quiroz Campos * - * @package chamilo.admin.openbadges - * * @deprecated use skill_list.php */ $cidReset = true; diff --git a/public/main/admin/skill_create.php b/public/main/admin/skill_create.php index d7b3e03e2a..b77b57b082 100644 --- a/public/main/admin/skill_create.php +++ b/public/main/admin/skill_create.php @@ -5,8 +5,6 @@ * Create skill form. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.admin */ $cidReset = true; diff --git a/public/main/admin/skill_edit.php b/public/main/admin/skill_edit.php index 87d9b04a6c..e44c6055a2 100644 --- a/public/main/admin/skill_edit.php +++ b/public/main/admin/skill_edit.php @@ -5,8 +5,6 @@ * Skill edit form. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.admin */ $cidReset = true; diff --git a/public/main/admin/skill_level.php b/public/main/admin/skill_level.php index 61b4bb3de2..f53fa99bbb 100644 --- a/public/main/admin/skill_level.php +++ b/public/main/admin/skill_level.php @@ -5,8 +5,6 @@ use Chamilo\SkillBundle\Entity\Level; /** * Add a skill Level. - * - * @package chamilo.skill */ $cidReset = true; diff --git a/public/main/admin/skill_list.php b/public/main/admin/skill_list.php index 463e94d316..e482304a78 100644 --- a/public/main/admin/skill_list.php +++ b/public/main/admin/skill_list.php @@ -5,8 +5,6 @@ * Skill list for management. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.admin */ $cidReset = true; diff --git a/public/main/admin/skill_profile.php b/public/main/admin/skill_profile.php index 072813b8f7..1c32075733 100644 --- a/public/main/admin/skill_profile.php +++ b/public/main/admin/skill_profile.php @@ -6,8 +6,6 @@ use Chamilo\SkillBundle\Entity\Profile; /** * Add a skill Profile. - * - * @package chamilo.skill */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/admin/skill_rel_course.php b/public/main/admin/skill_rel_course.php index fc973f44e6..ed79005424 100644 --- a/public/main/admin/skill_rel_course.php +++ b/public/main/admin/skill_rel_course.php @@ -6,7 +6,7 @@ use Chamilo\SkillBundle\Entity\SkillRelCourse; $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; -if (api_get_configuration_value('allow_skill_rel_items') == false) { +if (false == api_get_configuration_value('allow_skill_rel_items')) { api_not_allowed(true); } diff --git a/public/main/admin/skill_translate.php b/public/main/admin/skill_translate.php index b07286c7e5..7ef1ca60e0 100644 --- a/public/main/admin/skill_translate.php +++ b/public/main/admin/skill_translate.php @@ -23,13 +23,13 @@ if (isset($_GET['skill'])) { /** @var Skill $skill */ $skill = $em->find('ChamiloCoreBundle:Skill', intval($_GET['skill'])); - if ($action === 'name') { + if ('name' === $action) { $variableLanguage = ChamiloApi::getLanguageVar( $skill->getName(false), 'Skill' ); $originalName = $skill->getName(false); - } elseif ($action === 'code') { + } elseif ('code' === $action) { $variableLanguage = ChamiloApi::getLanguageVar( $skill->getShortCode(false), 'SkillCode' @@ -93,7 +93,7 @@ $form->setDefaults([ 'variable_language' => '$'.$variableLanguage, 'original_name' => $originalName, 'sub_language' => $languageId, - 'new_language' => $action === 'code' ? $skill->getShortCode() : $skill->getName(), + 'new_language' => 'code' === $action ? $skill->getShortCode() : $skill->getName(), ]); $form->addRule('sub_language', get_lang('Required'), 'required'); $form->freeze(['variable_language', 'original_name']); diff --git a/public/main/admin/skills.php b/public/main/admin/skills.php index 0d8db2379a..e1e0c945d3 100644 --- a/public/main/admin/skills.php +++ b/public/main/admin/skills.php @@ -1,9 +1,6 @@ 'index.php', 'name' => get_lang('Administration')]; -if ($action == 'add_skill') { +if ('add_skill' == $action) { $interbreadcrumb[] = ['url' => 'skills_gradebook.php', 'name' => get_lang('Skills and assessments')]; $tool_name = get_lang('Add'); } diff --git a/public/main/admin/skills_import.php b/public/main/admin/skills_import.php index f50e5e1ff4..f25223604a 100644 --- a/public/main/admin/skills_import.php +++ b/public/main/admin/skills_import.php @@ -3,7 +3,6 @@ /** * This tool allows platform admins to add skills by uploading a CSV or XML file. * - * @package chamilo.admin * @documentation Some interesting basic skills can be found in the "Skills" * section here: http://en.wikipedia.org/wiki/Personal_knowledge_management */ @@ -112,7 +111,7 @@ $extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true); $user_id_error = []; $error_message = ''; -if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) { +if (!empty($_POST['formSent']) && 0 !== $_FILES['import_file']['size']) { $file_type = $_POST['file_type']; Security::clear_token(); $tok = Security::get_token(); @@ -123,7 +122,7 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) { $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'], '.') + 1)); if (in_array($ext_import_file, $allowed_file_mimetype)) { - if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { + if (0 === strcmp($file_type, 'csv') && $ext_import_file == $allowed_file_mimetype[0]) { $skills = parse_csv_data($_FILES['import_file']['tmp_name']); $errors = validate_data($skills); $error_kind_file = false; @@ -149,7 +148,7 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) { } } - if (strcmp($file_type, 'csv') === 0) { + if (0 === strcmp($file_type, 'csv')) { save_data($skills_to_insert); } else { $error_message = get_lang('You must import a file corresponding to the selected format'); @@ -161,7 +160,7 @@ if (!empty($_POST['formSent']) && $_FILES['import_file']['size'] !== 0) { $see_message_import = get_lang('File imported'); } - if (count($errors) != 0) { + if (0 != count($errors)) { $warning_message = '
    '; foreach ($errors as $index => $error_skill) { $warning_message .= '
  • '.$error_skill['error'].': '; diff --git a/public/main/admin/skills_profile.php b/public/main/admin/skills_profile.php index 7ca942cdfe..1a0ad9a60e 100644 --- a/public/main/admin/skills_profile.php +++ b/public/main/admin/skills_profile.php @@ -3,9 +3,6 @@ use ChamiloSession as Session; -/** - * @package chamilo.admin - */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_PLATFORM_ADMIN; diff --git a/public/main/admin/skills_wheel.php b/public/main/admin/skills_wheel.php index 0852e80843..14234f44a0 100644 --- a/public/main/admin/skills_wheel.php +++ b/public/main/admin/skills_wheel.php @@ -1,9 +1,6 @@ '.get_lang('Download').''; } else { // Display forms especial export - if (isset($_POST['backup_option']) && $_POST['backup_option'] == 'select_items') { + if (isset($_POST['backup_option']) && 'select_items' == $_POST['backup_option']) { $cb = new CourseBuilder(); $course = $cb->build_session_course(); - if ($course === false) { + if (false === $course) { echo Display::return_message(get_lang('There were no courses registered or may not have made the association with the sessions'), 'error'); form_special_export(); } else { @@ -163,7 +163,7 @@ function create_zip() if (empty($path)) { $path = '/'; } - $remove_dir = ($path != '/') ? substr($path, 0, strlen($path) - strlen(basename($path))) : '/'; + $remove_dir = ('/' != $path) ? substr($path, 0, strlen($path) - strlen(basename($path))) : '/'; $sys_archive_path = api_get_path(SYS_ARCHIVE_PATH).'special_export/'; $sys_course_path = api_get_path(SYS_COURSE_PATH); $temp_zip_dir = $sys_archive_path; @@ -172,7 +172,7 @@ function create_zip() } else { $handle = opendir($temp_zip_dir); while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != "..") { + if ("." != $file && ".." != $file) { $Diff = (time() - filemtime("$temp_zip_dir/$file")) / 60 / 60; //the "age" of the file in hours if ($Diff > 4) { unlink("$temp_zip_dir/$file"); @@ -193,8 +193,8 @@ function create_zip() function rename_zip($FileZip) { - Event::event_download(($FileZip['PATH'] == '/') ? 'full_export_'.date('Ymd').'.zip (folder)' : basename($FileZip['PATH']).'.zip (folder)'); - $name = ($FileZip['PATH'] == '/') ? 'full_export_'.date('Ymd').'.zip' : basename($FileZip['PATH']).'.zip'; + Event::event_download(('/' == $FileZip['PATH']) ? 'full_export_'.date('Ymd').'.zip (folder)' : basename($FileZip['PATH']).'.zip (folder)'); + $name = ('/' == $FileZip['PATH']) ? 'full_export_'.date('Ymd').'.zip' : basename($FileZip['PATH']).'.zip'; if (file_exists($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name)) { unlink($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name); } @@ -227,7 +227,7 @@ function fullexportspecial() if (count($list_course) > 0) { foreach ($list_course as $_course) { - if ($FileZip['PATH'] == '/') { + if ('/' == $FileZip['PATH']) { $querypath = ''; // to prevent ...path LIKE '//%'... in query } else { $querypath = $FileZip['PATH']; @@ -290,7 +290,7 @@ function fullexportspecial() } $name = rename_zip($FileZip); - if ($name === false) { + if (false === $name) { $export = false; return false; diff --git a/public/main/admin/specific_fields.php b/public/main/admin/specific_fields.php index 4949ff473c..b822972bba 100644 --- a/public/main/admin/specific_fields.php +++ b/public/main/admin/specific_fields.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * Manage specific fields. - * - * @package chamilo.admin */ // Resetting the course id. $cidReset = true; @@ -64,7 +62,7 @@ function edit_filter($id, $url_params, $row) return $return; } -if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { +if (isset($_REQUEST['action']) && 'delete' == $_REQUEST['action']) { delete_specific_field($_REQUEST['field_id']); header('Location: specific_fields.php?message='.get_lang('Field removed')); exit; diff --git a/public/main/admin/specific_fields_add.php b/public/main/admin/specific_fields_add.php index a2d6730cf7..6e13a10093 100644 --- a/public/main/admin/specific_fields_add.php +++ b/public/main/admin/specific_fields_add.php @@ -3,8 +3,6 @@ /** * Add form. - * - * @package chamilo.admin */ // Resetting the course id. @@ -35,7 +33,7 @@ $interbreadcrumb[] = [ $tool_name = get_lang('Add a specific search field'); -if (isset($_GET['action']) && $_GET['action'] === 'edit') { +if (isset($_GET['action']) && 'edit' === $_GET['action']) { $tool_name = get_lang('Edit specific search field'); } // Create the form @@ -63,7 +61,7 @@ $form->addButtonCreate(get_lang('Add'), 'submit'); if ($form->validate()) { $field = $form->exportValues(); $field_name = $field['field_name']; - if (is_numeric($field['field_id']) && $field['field_id'] != 0 && !empty($field['field_id'])) { + if (is_numeric($field['field_id']) && 0 != $field['field_id'] && !empty($field['field_id'])) { edit_specific_field($field['field_id'], $field['field_name']); $message = get_lang('Field added.'); } else { diff --git a/public/main/admin/statistics.php b/public/main/admin/statistics.php index 33e1cacf2f..7761b5ae9f 100644 --- a/public/main/admin/statistics.php +++ b/public/main/admin/statistics.php @@ -1,9 +1,6 @@ 'table table-responsive']); @@ -541,7 +541,7 @@ switch ($report) { $content .= $table->toHtml(); } - if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'export') { + if (isset($_REQUEST['action']) && 'export' === $_REQUEST['action']) { $data = $table->toArray(); Export::arrayToXls($data); exit; @@ -674,7 +674,7 @@ switch ($report) { $content .= Statistics::printToolStats(); break; case 'coursebylanguage': - $content .= ''; + $content .= ''; $result = Statistics::printCourseByLanguageStats(); $content .= Statistics::printStats(get_lang('CountCourseByLanguage'), $result, true); break; @@ -687,21 +687,21 @@ switch ($report) { $startDate = $values['daterange_start']; $endDate = $values['daterange_end']; - $content .= '
    '; - $content .= '
    '; - $content .= '
    '; - $content .= '
    '; - $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; - $content .= '
    '; - $content .= '
    '; - $content .= '
    '; - $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; - $content .= '
    '; - $content .= '
    '; - $content .= '
    '; - $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; + $content .= '
    '; $conditions = []; $extraConditions = ''; @@ -751,7 +751,7 @@ switch ($report) { get_lang('UserBirthday'), ]; - if (isset($_REQUEST['action_table']) && $_REQUEST['action_table'] === 'export') { + if (isset($_REQUEST['action_table']) && 'export' === $_REQUEST['action_table']) { $first = 0; $limit = $totalCount; $data[] = $headers; @@ -798,14 +798,14 @@ switch ($report) { $item[] = $residence; $item[] = $career; $item[] = $statusList[$user['status']]; - $item[] = $user['active'] == 1 ? get_lang('Yes') : get_lang('No'); + $item[] = 1 == $user['active'] ? get_lang('Yes') : get_lang('No'); $item[] = $certificate ? get_lang('Yes') : get_lang('No'); $item[] = $birthDate; $data[] = $item; $row++; } - if (isset($_REQUEST['action_table']) && $_REQUEST['action_table'] === 'export') { + if (isset($_REQUEST['action_table']) && 'export' === $_REQUEST['action_table']) { Export::arrayToXls($data); exit; } @@ -821,10 +821,10 @@ switch ($report) { $table->set_header($column, $header, false); $column++; } - $content .= $table->return_table(); + $content .= $table->return_table(); } - $content = $form->returnForm().$content; + $content = $form->returnForm().$content; break; case 'users': @@ -880,7 +880,7 @@ switch ($report) { $content .= ZombieReport::create(['report' => 'zombies'])->display(true); break; case 'activities': - $content .=Statistics::printActivitiesStats(); + $content .= Statistics::printActivitiesStats(); break; case 'messagesent': $messages_sent = Statistics::getMessages('sent'); diff --git a/public/main/admin/sub_language.php b/public/main/admin/sub_language.php index aceb5c1d8b..13bc3ca9ca 100644 --- a/public/main/admin/sub_language.php +++ b/public/main/admin/sub_language.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * Script for sub-language administration. - * - * @package chamilo.admin.sub_language */ $cidReset = true; $this_script = 'sub_language'; @@ -76,7 +74,7 @@ if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) { if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { $sublanguage_folder_error = $sub_language_file.' '.get_lang('is not writeable'); } - if (SubLanguageManager::check_if_exist_language_by_id($_GET['id']) === true) { + if (true === SubLanguageManager::check_if_exist_language_by_id($_GET['id'])) { $language_id_exist = true; } else { $language_id_exist = false; @@ -89,7 +87,7 @@ if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) { $intro = sprintf(get_lang('Define new terms for sub-language %s by searching some term, then save each translation by clicking the save button. You will then have to switch your own user language to see the new terms appear.'), strtolower($sub_language_name)); $path_folder = api_get_path(SYS_LANG_PATH).$all_data_of_language['dokeos_folder']; -if (!is_dir($path_folder) || strlen($all_data_of_language['dokeos_folder']) == 0) { +if (!is_dir($path_folder) || 0 == strlen($all_data_of_language['dokeos_folder'])) { api_not_allowed(true); } @@ -162,7 +160,7 @@ function search_language_term( } $founded = false; // searching the item in the parent tool - if (preg_match($term, $parent_variable_value) !== 0) { + if (0 !== preg_match($term, $parent_variable_value)) { $founded = true; } if ($founded) { @@ -230,16 +228,16 @@ function search_language_term( $founded = false; if ($search_in_english && $search_in_variable) { // searching the item in the parent tool - if (preg_match($term, $variable_value) !== 0 || preg_match($term, $name_variable) !== 0) { + if (0 !== preg_match($term, $variable_value) || 0 !== preg_match($term, $name_variable)) { $founded = true; } } else { if ($search_in_english) { - if (preg_match($term, $variable_value) !== 0) { + if (0 !== preg_match($term, $variable_value)) { $founded = true; } } else { - if (preg_match($term, $name_variable) !== 0) { + if (0 !== preg_match($term, $name_variable)) { $founded = true; } } @@ -305,7 +303,7 @@ function search_language_term( $founded = false; // searching the item in the parent tool - if (preg_match($term, $variable_value) !== 0) { + if (0 !== preg_match($term, $variable_value)) { $founded = true; } if ($founded) { diff --git a/public/main/admin/sub_language_add.php b/public/main/admin/sub_language_add.php index c7eda54f27..88a333a90d 100644 --- a/public/main/admin/sub_language_add.php +++ b/public/main/admin/sub_language_add.php @@ -3,8 +3,6 @@ /** * This script allows for the addition of sub-languages. - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -45,7 +43,7 @@ function add_sub_language($original_name, $english_name, $isocode, $sublanguage_ $sql = 'INSERT INTO '.$tbl_admin_languages.'(original_name,english_name,isocode,dokeos_folder,available,parent_id) VALUES ("'.$original_name.'","'.$english_name.'","'.$isocode.'","'.$english_name.'","'.$sublanguage_available.'","'.$parent_id.'")'; $res = Database::query($sql); - if ($res === false) { + if (false === $res) { return false; } @@ -84,11 +82,11 @@ function check_if_language_exist($original_name, $english_name, $isocode, $subla $has_error = false; $message_information = []; - if ($count_original_name == 1) { + if (1 == $count_original_name) { $has_error = true; $message_information['original_name'] = true; } - if ($count_english_name == 1) { + if (1 == $count_english_name) { $has_error = true; $message_information['english_name'] = true; } @@ -100,10 +98,10 @@ function check_if_language_exist($original_name, $english_name, $isocode, $subla $has_error = true; $message_information['isocode'] = true; } - if ($has_error === true) { + if (true === $has_error) { $message_information['execute_add'] = false; } - if ($has_error === false) { + if (false === $has_error) { $message_information['execute_add'] = true; } @@ -136,7 +134,7 @@ function ckeck_if_is_parent_of_sub_language($parent_id) { $sql = 'SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id); $rs = Database::query($sql); - if (Database::num_rows($rs) > 0 && Database::result($rs, 0, 'count') == 1) { + if (Database::num_rows($rs) > 0 && 1 == Database::result($rs, 0, 'count')) { return true; } else { return false; @@ -162,7 +160,7 @@ function allow_get_all_information_of_sub_language($parent_id, $sub_language_id) if (isset($_GET['sub_language_id']) && $_GET['sub_language_id'] == strval(intval($_GET['sub_language_id']))) { $language_name = SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']); - if (check_if_exist_language_by_id($_GET['sub_language_id']) === true) { + if (true === check_if_exist_language_by_id($_GET['sub_language_id'])) { $sub_language_id = $_GET['sub_language_id']; $sub_language_id_exist = true; } else { @@ -174,7 +172,7 @@ $language_name = ''; if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) { $language_details = SubLanguageManager::get_all_information_of_language($_GET['id']); $language_name = $language_details['original_name']; - if (check_if_exist_language_by_id($_GET['id']) === true) { + if (true === check_if_exist_language_by_id($_GET['id'])) { $parent_id = $_GET['id']; $language_id_exist = true; } else { @@ -189,7 +187,7 @@ if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) { if ((isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) && (isset($_GET['sub_language_id']) && $_GET['sub_language_id'] == strval(intval($_GET['sub_language_id']))) ) { - if (check_if_exist_language_by_id($_GET['id']) === true && check_if_exist_language_by_id($_GET['sub_language_id']) === true) { + if (true === check_if_exist_language_by_id($_GET['id']) && true === check_if_exist_language_by_id($_GET['sub_language_id'])) { $get_all_information = allow_get_all_information_of_sub_language($_GET['id'], $_GET['sub_language_id']); $original_name = $get_all_information['original_name']; $english_name = $get_all_information['english_name']; @@ -199,8 +197,8 @@ if ((isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) && $language_name = get_lang('Create sub-languageForLanguage').' ( '.strtolower($language_name).' )'; -if (ckeck_if_is_parent_of_sub_language($parent_id) === true && - isset($_GET['action']) && $_GET['action'] == 'deletesublanguage' +if (true === ckeck_if_is_parent_of_sub_language($parent_id) && + isset($_GET['action']) && 'deletesublanguage' == $_GET['action'] ) { $language_name = get_lang('Delete sub-language'); } @@ -219,28 +217,28 @@ if (isset($_POST['SubmitAddNewLanguage'])) { $check_information = check_if_language_exist($original_name, $english_name, $isocode, $sublanguage_available); foreach ($check_information as $index_information => $value_information) { $allow_insert_info = false; - if ($index_information == 'original_name') { + if ('original_name' == $index_information) { $msg .= Display::return_message( get_lang('Already exists').' "'.get_lang('Original name').'" '.'('.$original_name.')', 'error' ); } - if ($index_information == 'english_name') { + if ('english_name' == $index_information) { $msg .= Display::return_message( get_lang('Already exists').' "'.get_lang('English name').'" '.'('.$english_name.')', 'error' ); } - if ($index_information == 'isocode') { + if ('isocode' == $index_information) { $msg .= Display::return_message(get_lang('This code does not exist').': '.$isocode.'', 'error'); } - if ($index_information == 'execute_add' && $value_information === true) { + if ('execute_add' == $index_information && true === $value_information) { $allow_insert_info = true; } } if (strlen($original_name) > 0 && strlen($english_name) > 0 && strlen($isocode) > 0) { - if ($allow_insert_info === true && $language_id_exist === true) { + if (true === $allow_insert_info && true === $language_id_exist) { $english_name = str_replace(' ', '_', $english_name); //Fixes BT#1636 $english_name = api_strtolower($english_name); @@ -251,7 +249,7 @@ if (isset($_POST['SubmitAddNewLanguage'])) { $mkdir_result = SubLanguageManager::add_language_directory($english_name); if ($mkdir_result) { $sl_id = add_sub_language($original_name, $english_name, $isocode, $sublanguage_available, $parent_id); - if ($sl_id === false) { + if (false === $sl_id) { SubLanguageManager::remove_language_directory($english_name); $msg .= Display::return_message(get_lang('The /main/lang directory, used on this portal to store the languages, is not writable. Please contact your platform administrator and report this message.'), 'error'); } else { @@ -267,7 +265,7 @@ if (isset($_POST['SubmitAddNewLanguage'])) { $msg .= Display::return_message(get_lang('The /main/lang directory, used on this portal to store the languages, is not writable. Please contact your platform administrator and report this message.'), 'error'); } } else { - if ($language_id_exist === false) { + if (false === $language_id_exist) { $msg .= Display::return_message(get_lang('The parent language does not exist.'), 'error'); } } @@ -282,14 +280,14 @@ echo $msg; if (isset($_POST['SubmitAddDeleteLanguage'])) { $rs = SubLanguageManager::remove_sub_language($_GET['id'], $_GET['sub_language_id']); - if ($rs === true) { + if (true === $rs) { echo Display::return_message(get_lang('The sub language has been removed'), 'confirm'); } else { echo Display::return_message(get_lang('The sub-language has not been removed.'), 'error'); } } // ckeck_if_is_parent_of_sub_language($parent_id)===false -if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { +if (isset($_GET['action']) && 'definenewsublanguage' == $_GET['action']) { $text = $language_name; $form = new FormValidator( 'addsublanguage', @@ -313,7 +311,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { $form->setDefaults($values); $form->display(); } else { - if (isset($_GET['action']) && $_GET['action'] == 'deletesublanguage') { + if (isset($_GET['action']) && 'deletesublanguage' == $_GET['action']) { $text = $language_name; $form = new FormValidator( 'deletesublanguage', @@ -328,7 +326,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { $form->addButtonCreate(get_lang('Delete sub-language'), 'SubmitAddDeleteLanguage'); $form->display(); } - if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { + if (isset($_GET['action']) && 'definenewsublanguage' == $_GET['action']) { echo Display::return_message(get_lang('The sub-language of this language has been added')); } } diff --git a/public/main/admin/sub_language_ajax.inc.php b/public/main/admin/sub_language_ajax.inc.php index e449450545..2bf6c765cb 100644 --- a/public/main/admin/sub_language_ajax.inc.php +++ b/public/main/admin/sub_language_ajax.inc.php @@ -5,8 +5,6 @@ use Chamilo\CoreBundle\Entity\ExtraField; /** * Sub language AJAX script to update variables. - * - * @package chamilo.admin.sub_language */ $this_script = 'sub_language'; require_once __DIR__.'/../inc/global.inc.php'; @@ -41,7 +39,7 @@ if (isset($new_language) && isset($language_variable) && isset($file_id)) { $variables_with_problems = ''; if (!empty($result_array)) { foreach ($result_array as $key => $result) { - if ($result == false) { + if (false == $result) { $variables_with_problems .= $key.'
    '; } } diff --git a/public/main/admin/subscribe_user2course.php b/public/main/admin/subscribe_user2course.php index 222ed57455..35d84128db 100644 --- a/public/main/admin/subscribe_user2course.php +++ b/public/main/admin/subscribe_user2course.php @@ -7,8 +7,6 @@ * you can select multiple users and courses and then click on * 'Add to this(these) course(s)'. * - * @package chamilo.admin - * * @todo use formvalidator for the form */ $cidReset = true; @@ -55,7 +53,7 @@ $new_field_list = []; if (is_array($extra_field_list)) { foreach ($extra_field_list as $extra_field) { // if is enabled to filter and is a "'; - $extraHidden = $fieldtype == ExtraField::FIELD_TYPE_TAG ? '' : ''; + $extraHidden = ExtraField::FIELD_TYPE_TAG == $fieldtype ? '' : ''; echo $extraHidden; echo '  '; } diff --git a/public/main/admin/system_announcements.php b/public/main/admin/system_announcements.php index ca8aa4d31c..bb424f61cf 100644 --- a/public/main/admin/system_announcements.php +++ b/public/main/admin/system_announcements.php @@ -4,8 +4,6 @@ /** * This page allows the administrator to manage the system announcements. - * - * @package chamilo.admin.announcement */ // Resetting the course id. @@ -44,13 +42,13 @@ if (!empty($action)) { "url" => "system_announcements.php", "name" => get_lang('Portal news'), ]; - if ($action == 'add') { + if ('add' == $action) { $interbreadcrumb[] = [ "url" => '#', "name" => get_lang('Add an announcement'), ]; } - if ($action == 'edit') { + if ('edit' == $action) { $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')]; } } else { @@ -87,7 +85,7 @@ function showCareer() { // Displaying the header. Display::display_header($tool_name); -if ($action != 'add' && $action != 'edit') { +if ('add' != $action && 'edit' != $action) { echo ''; @@ -107,7 +105,7 @@ switch ($action) { case 'make_visible': case 'make_invisible': $status = false; - if ($action == 'make_visible') { + if ('make_visible' == $action) { $status = true; } @@ -172,10 +170,10 @@ switch ($action) { } if ($action_todo) { - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { + if (isset($_REQUEST['action']) && 'add' == $_REQUEST['action']) { $form_title = get_lang('Add news'); $url = api_get_self(); - } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { + } elseif (isset($_REQUEST['action']) && 'edit' == $_REQUEST['action']) { $form_title = get_lang('Edit News'); $url = api_get_self().'?id='.intval($_GET['id']); } @@ -316,12 +314,12 @@ if ($action_todo) { $values['group'] = isset($values['group']) ? $values['group'] : '0'; $form->addElement('checkbox', 'send_mail', null, get_lang('Send mail')); - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') { + if (isset($_REQUEST['action']) && 'add' == $_REQUEST['action']) { $form->addElement('checkbox', 'add_to_calendar', null, get_lang('Add to calendar')); $text = get_lang('Add news'); $class = 'add'; $form->addElement('hidden', 'action', 'add'); - } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { + } elseif (isset($_REQUEST['action']) && 'edit' == $_REQUEST['action']) { $text = get_lang('Edit News'); $class = 'save'; $form->addElement('hidden', 'action', 'edit'); @@ -340,7 +338,7 @@ if ($action_todo) { $visibilityResult[$key] = (int) $values[$key]; } - if ($values['lang'] == 'all') { + if ('all' == $values['lang']) { $values['lang'] = null; } @@ -360,7 +358,7 @@ if ($action_todo) { empty($values['send_email_test']) ? false : true ); - if ($announcement_id !== false) { + if (false !== $announcement_id) { // ADD Picture $picture = $_FILES['picture']; if (!empty($picture['name'])) { diff --git a/public/main/admin/teachers_time_by_session_report.php b/public/main/admin/teachers_time_by_session_report.php index b82a1232b3..837c4cd21c 100644 --- a/public/main/admin/teachers_time_by_session_report.php +++ b/public/main/admin/teachers_time_by_session_report.php @@ -7,8 +7,6 @@ use Doctrine\Common\Collections\Criteria; /** * Generate a teacher time report in platform by session only. - * - * @package chamilo.admin */ $cidReset = true; diff --git a/public/main/admin/update_schema.php b/public/main/admin/update_schema.php index df58d8c5f4..aee5a2ed32 100644 --- a/public/main/admin/update_schema.php +++ b/public/main/admin/update_schema.php @@ -8,7 +8,7 @@ require_once __DIR__.'/../inc/global.inc.php'; // Access restrictions api_protect_admin_script(true); -if (api_get_configuration_value('sync_db_with_schema') != true) { +if (true != api_get_configuration_value('sync_db_with_schema')) { api_not_allowed(true); } diff --git a/public/main/admin/user_add.php b/public/main/admin/user_add.php index 8549a122f4..fa1699abe6 100644 --- a/public/main/admin/user_add.php +++ b/public/main/admin/user_add.php @@ -1,9 +1,6 @@ applyFilter('official_code', 'trim'); // e-mail $form->addElement('text', 'email', get_lang('e-mail'), ['size' => '40', 'autocomplete' => 'off', 'id' => 'email']); $form->addRule('email', get_lang('e-mailWrong'), 'email'); -if (api_get_setting('registration', 'email') == 'true') { +if ('true' == api_get_setting('registration', 'email')) { $form->addRule('email', get_lang('e-mailWrong'), 'required'); } -if (api_get_setting('login_is_email') == 'true') { +if ('true' == api_get_setting('login_is_email')) { $form->addRule('email', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); $form->addRule('email', get_lang('This login is already in use'), 'username_available'); } @@ -163,7 +160,7 @@ $allowed_picture_types = api_get_supported_image_extensions(false); $form->addRule('picture', get_lang('Only PNG, JPG or GIF images allowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types); // Username -if (api_get_setting('login_is_email') != 'true') { +if ('true' != api_get_setting('login_is_email')) { $form->addElement('text', 'username', get_lang('Login'), ['id' => 'username', 'maxlength' => USERNAME_MAX_LENGTH, 'autocomplete' => 'off']); $form->addRule('username', get_lang('Required field'), 'required'); $form->addRule('username', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); @@ -182,7 +179,7 @@ if (isset($extAuthSource) && count($extAuthSource) > 0) { // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS // extAuthSource always on for CAS even if not activated // same action for file user_edit.php - if (($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true') || ($key != CAS_AUTH_SOURCE)) { + if ((CAS_AUTH_SOURCE == $key && 'true' === api_get_setting('cas_activate')) || (CAS_AUTH_SOURCE != $key)) { $auth_sources[$key] = $key; $nb_ext_auth_source_added++; } @@ -245,7 +242,7 @@ $form->addElement( ); //drh list (display only if student) -$display = (isset($_POST['status']) && $_POST['status'] == STUDENT) || !isset($_POST['status']) ? 'block' : 'none'; +$display = (isset($_POST['status']) && STUDENT == $_POST['status']) || !isset($_POST['status']) ? 'block' : 'none'; //@todo remove the drh list here. This code is unused $form->addElement('html', '
    '); @@ -368,28 +365,28 @@ if ($form->validate()) { $hr_dept_id = isset($user['hr_dept_id']) ? (int) $user['hr_dept_id'] : 0; if (isset($extAuthSource) && count($extAuthSource) > 0 && - $user['password']['password_auto'] == '2' + '2' == $user['password']['password_auto'] ) { $auth_source = $user['password']['auth_source']; $password = 'PLACEHOLDER'; } else { $auth_source = PLATFORM_AUTH_SOURCE; - $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; + $password = '1' == $user['password']['password_auto'] ? api_generate_password() : $user['password']['password']; } $expiration_date = null; - if ($user['radio_expiration_date'] == '1') { + if ('1' == $user['radio_expiration_date']) { $expiration_date = $user['expiration_date']; } $active = (int) $user['active']; - if (api_get_setting('login_is_email') == 'true') { + if ('true' == api_get_setting('login_is_email')) { $username = $email; } $extra = []; foreach ($user as $key => $value) { - if (substr($key, 0, 6) == 'extra_') { + if ('extra_' == substr($key, 0, 6)) { // An extra field $extra[substr($key, 6)] = $value; } diff --git a/public/main/admin/user_edit.php b/public/main/admin/user_edit.php index 5ef41e57b1..45b0ad8608 100644 --- a/public/main/admin/user_edit.php +++ b/public/main/admin/user_edit.php @@ -3,9 +3,6 @@ use ChamiloSession as Session; -/** - * @package chamilo.admin - */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -80,7 +77,7 @@ $sql = "SELECT u.*, a.user_id AS is_admin FROM $table_user u LEFT JOIN $table_admin a ON a.user_id = u.id WHERE u.id = '".$user_id."'"; $res = Database::query($sql); -if (Database::num_rows($res) != 1) { +if (1 != Database::num_rows($res)) { header('Location: user_list.php'); exit; } @@ -136,11 +133,11 @@ $form->applyFilter('official_code', 'trim'); // e-mail $form->addElement('text', 'email', get_lang('e-mail')); $form->addRule('email', get_lang('e-mailWrong'), 'email'); -if (api_get_setting('registration', 'email') == 'true') { +if ('true' == api_get_setting('registration', 'email')) { $form->addRule('email', get_lang('e-mailWrong'), 'required'); } -if (api_get_setting('login_is_email') == 'true') { +if ('true' == api_get_setting('login_is_email')) { $form->addRule('email', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); $form->addRule('email', get_lang('This login is already in use'), 'username_available', $user_data['username']); } @@ -167,7 +164,7 @@ if (strlen($user_data['picture_uri']) > 0) { } // Username -if (api_get_setting('login_is_email') != 'true') { +if ('true' != api_get_setting('login_is_email')) { $form->addElement('text', 'username', get_lang('Login'), ['maxlength' => USERNAME_MAX_LENGTH]); $form->addRule('username', get_lang('Required field'), 'required'); $form->addRule('username', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); @@ -192,7 +189,7 @@ if (isset($extAuthSource) && !empty($extAuthSource) && count($extAuthSource) > 0 // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS // extAuthSource always on for CAS even if not activated // same action for file user_add.php - if (($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true') || ($key != CAS_AUTH_SOURCE)) { + if ((CAS_AUTH_SOURCE == $key && 'true' === api_get_setting('cas_activate')) || (CAS_AUTH_SOURCE != $key)) { $auth_sources[$key] = $key; $nb_ext_auth_source_added++; } @@ -238,7 +235,7 @@ $form->addElement( ] ); -$display = isset($user_data['status']) && ($user_data['status'] == STUDENT || (isset($_POST['status']) && $_POST['status'] == STUDENT)) ? 'block' : 'none'; +$display = isset($user_data['status']) && (STUDENT == $user_data['status'] || (isset($_POST['status']) && STUDENT == $_POST['status'])) ? 'block' : 'none'; // Platform admin if (api_is_platform_admin()) { @@ -246,7 +243,7 @@ if (api_is_platform_admin()) { $group[] = $form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); $group[] = $form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); - $user_data['status'] == 1 ? $display = 'block' : $display = 'none'; + 1 == $user_data['status'] ? $display = 'block' : $display = 'none'; $form->addElement('html', '
    '); $form->addGroup($group, 'admin', get_lang('Administration'), null, false); @@ -367,7 +364,7 @@ $error_drh = false; if ($form->validate()) { $user = $form->getSubmitValues(1); $reset_password = intval($user['reset_password']); - if ($reset_password == 2 && empty($user['password'])) { + if (2 == $reset_password && empty($user['password'])) { Display::addFlash(Display::return_message(get_lang('The password is too short'))); header('Location: '.api_get_self().'?user_id='.$user_id); exit(); @@ -375,7 +372,7 @@ if ($form->validate()) { $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); - if ($user['status'] == DRH && $is_user_subscribed_in_course) { + if (DRH == $user['status'] && $is_user_subscribed_in_course) { $error_drh = true; } else { $picture_element = $form->getElement('picture'); @@ -409,7 +406,7 @@ if ($form->validate()) { $language = $user['language']; $address = isset($user['address']) ? $user['address'] : null; - if (!$user_data['platform_admin'] && $user['radio_expiration_date'] == '1') { + if (!$user_data['platform_admin'] && '1' == $user['radio_expiration_date']) { $expiration_date = $user['expiration_date']; } else { $expiration_date = null; @@ -418,11 +415,11 @@ if ($form->validate()) { $active = $user_data['platform_admin'] ? 1 : intval($user['active']); //If the user is set to admin the status will be overwrite by COURSEMANAGER = 1 - if ($platform_admin == 1) { + if (1 == $platform_admin) { $status = COURSEMANAGER; } - if (api_get_setting('login_is_email') == 'true') { + if ('true' == api_get_setting('login_is_email')) { $username = $email; } @@ -467,7 +464,7 @@ if ($form->validate()) { UserManager::add_user_as_admin($userObj); if ($user_id != $currentUserId) { - if ($platform_admin == 1) { + if (1 == $platform_admin) { $userObj = api_get_user_entity($user_id); UserManager::add_user_as_admin($userObj); } else { diff --git a/public/main/admin/user_export.php b/public/main/admin/user_export.php index bdc300fac7..9c4cf71afb 100644 --- a/public/main/admin/user_export.php +++ b/public/main/admin/user_export.php @@ -1,9 +1,6 @@ validate()) { u.firstname AS FirstName, u.email AS Email, u.username AS UserName, - ".(($_configuration['password_encryption'] != 'none') ? " " : "u.password AS Password, ")." + ".(('none' != $_configuration['password_encryption']) ? " " : "u.password AS Password, ")." u.auth_source AS AuthSource, u.status AS Status, u.official_code AS OfficialCode, @@ -112,7 +109,7 @@ if ($form->validate()) { if (api_is_multiple_url_enabled()) { $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); - if ($access_url_id != -1) { + if (-1 != $access_url_id) { $sql .= " FROM $user_table u INNER JOIN $tbl_user_rel_access_url as user_rel_url ON (u.user_id= user_rel_url.user_id) @@ -128,8 +125,8 @@ if ($form->validate()) { $extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false); if (!empty($export['addcsvheader'])) { - if ($export['addcsvheader'] == '1' && ($export['file_type'] == 'csv' || $export['file_type'] == 'xls')) { - if ($_configuration['password_encryption'] != 'none') { + if ('1' == $export['addcsvheader'] && ('csv' == $export['file_type'] || 'xls' == $export['file_type'])) { + if ('none' != $_configuration['password_encryption']) { $data[] = [ 'UserId', 'LastName', diff --git a/public/main/admin/user_import.php b/public/main/admin/user_import.php index adbc5528fd..e0e4c88af4 100644 --- a/public/main/admin/user_import.php +++ b/public/main/admin/user_import.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * This tool allows platform admins to add users by uploading a CSV or XML file. - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -33,7 +31,7 @@ function validate_data($users, $checkUniqueEmail = false) // 1. Check if mandatory fields are set. $mandatory_fields = ['LastName', 'FirstName']; - if (api_get_setting('registration', 'email') == 'true' || $checkUniqueEmail) { + if ('true' == api_get_setting('registration', 'email') || $checkUniqueEmail) { $mandatory_fields[] = 'Email'; } @@ -60,7 +58,7 @@ function validate_data($users, $checkUniqueEmail = false) } // 2.1.1 $hasDash = strpos($username, '-'); - if ($hasDash !== false) { + if (false !== $hasDash) { $user['message'] .= Display::return_message( get_lang('The username cannot contain the \' - \' character'), 'warning' @@ -82,7 +80,7 @@ function validate_data($users, $checkUniqueEmail = false) if (isset($user['Email'])) { $result = api_valid_email($user['Email']); - if ($result === false) { + if (false === $result) { $user['message'] .= Display::return_message(get_lang('Please enter a valid e-mail address !'), 'warning'); $user['has_error'] = true; } @@ -356,7 +354,7 @@ function parse_csv_data($users, $fileName, $sendEmail = 0, $checkUniqueEmail = t $users = array_splice($users, 0, $readMax); } - if ($resumeImport === false) { + if (false === $resumeImport) { $users = $usersFromOrigin; } @@ -435,7 +433,7 @@ function parse_xml_data($file) foreach ($crawler as $domElement) { $row = []; foreach ($domElement->childNodes as $node) { - if ($node->nodeName != '#text') { + if ('#text' != $node->nodeName) { $row[$node->nodeName] = $node->nodeValue; } } @@ -507,11 +505,11 @@ if (isset($extAuthSource) && is_array($extAuthSource)) { $tool_name = get_lang('Import users list'); $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')]; -$reloadImport = (isset($_REQUEST['reload_import']) && (int) $_REQUEST['reload_import'] === 1); +$reloadImport = (isset($_REQUEST['reload_import']) && 1 === (int) $_REQUEST['reload_import']); $extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true); -if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['size'] !== 0) { +if (isset($_POST['formSent']) && $_POST['formSent'] && 0 !== $_FILES['import_file']['size']) { $file_type = $_POST['file_type']; Security::clear_token(); $tok = Security::get_token(); @@ -526,7 +524,7 @@ if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['s $users = []; if (in_array($ext_import_file, $allowed_file_mimetype)) { - if (strcmp($file_type, 'csv') === 0 && + if (0 === strcmp($file_type, 'csv') && $ext_import_file == $allowed_file_mimetype[0] ) { Session::erase('user_import_data_'.$userId); @@ -540,7 +538,7 @@ if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['s ); $users = validate_data($users, $checkUniqueEmail); $error_kind_file = false; - } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { + } elseif (0 === strcmp($file_type, 'xml') && $ext_import_file == $allowed_file_mimetype[1]) { $users = parse_xml_data($_FILES['import_file']['tmp_name']); $users = validate_data($users, $checkUniqueEmail); $error_kind_file = false; @@ -622,7 +620,7 @@ if (!empty($importData)) { if ($isResume) { $resumeStop = $importData['counter'] >= count($importData['complete_list']); - if ($resumeStop == false) { + if (false == $resumeStop) { $formContinue->addButtonImport(get_lang('ContinueImport'), 'import_continue'); } } @@ -642,7 +640,7 @@ if (!empty($importData)) { processUsers($users, $importData['send_email']); $reload = ''; - if ($isResume && $resumeStop === false) { + if ($isResume && false === $resumeStop) { $reload = '?reload_import=1'; } @@ -778,7 +776,7 @@ if (api_get_configuration_value('plugin_redirection_enabled')) { <OfficialCode>xxx</OfficialCode> <language>english/spanish/(other)</language> <PhoneNumber>xxx</PhoneNumber> - <Status>user/teacher/drh</Status>', $result_xml; echo '
    '; } ?> diff --git a/public/main/admin/user_information.php b/public/main/admin/user_information.php index 53dc5aa8c2..4463a5bf70 100644 --- a/public/main/admin/user_information.php +++ b/public/main/admin/user_information.php @@ -8,8 +8,6 @@ use Chamilo\UserBundle\Entity\User; * Script showing information about a user (name, e-mail, courses and sessions). * * @author Bart Mollet - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -158,7 +156,7 @@ $data = [ get_lang('Phone') => $user['phone'], get_lang('Course code') => $user['official_code'], get_lang('Online') => !empty($user['user_is_online']) ? Display::return_icon('online.png') : Display::return_icon('offline.png'), - get_lang('Status') => $user['status'] == 1 ? get_lang('Trainer') : get_lang('Learner'), + get_lang('Status') => 1 == $user['status'] ? get_lang('Trainer') : get_lang('Learner'), ]; $userInfo = [ @@ -167,7 +165,7 @@ $userInfo = [ 'phone' => $user['phone'], 'official_code' => $user['official_code'], 'user_is_online' => !empty($user['user_is_online']) ? Display::return_icon('online.png') : Display::return_icon('offline.png'), - 'status' => $user['status'] == 1 ? get_lang('Trainer') : get_lang('Learner'), + 'status' => 1 == $user['status'] ? get_lang('Trainer') : get_lang('Learner'), 'avatar' => $user['avatar'], ]; @@ -204,7 +202,7 @@ $data = [ get_lang('Latest login') => $userInfo['last_connection'], ]; -if (api_get_setting('allow_terms_conditions') === 'true') { +if ('true' === api_get_setting('allow_terms_conditions')) { $extraFieldValue = new ExtraFieldValue('user'); $value = $extraFieldValue->get_values_by_handler_and_field_variable( $userId, @@ -250,12 +248,12 @@ foreach ($data as $label => $item) { /** * Show social activity. */ -if (api_get_setting('allow_social_tool') === 'true') { +if ('true' === api_get_setting('allow_social_tool')) { $userObject = api_get_user_entity($userId); $data = []; // Calculate values - if (api_get_setting('allow_message_tool') === 'true') { + if ('true' === api_get_setting('allow_message_tool')) { $messagesSent = SocialManager::getCountMessagesSent($userId); $data[] = [get_lang('Number of messages sent'), $messagesSent]; $messagesReceived = SocialManager::getCountMessagesReceived($userId); @@ -342,7 +340,7 @@ if (count($sessions) > 0) { ''. Display::return_icon('course_home.png', get_lang('Course home')).''; - if (!empty($my_course['status']) && $my_course['status'] == STUDENT) { + if (!empty($my_course['status']) && STUDENT == $my_course['status']) { $tools .= ''. Display::return_icon('delete.png', get_lang('Delete')).''; } @@ -457,7 +455,7 @@ if (Database::num_rows($res) > 0) { Display::return_icon('course_home.png', get_lang('Course home')).''. ''. Display::return_icon('edit.png', get_lang('Edit')).''; - if ($course->status == STUDENT) { + if (STUDENT == $course->status) { $tools .= ''. Display::return_icon('delete.png', get_lang('Delete')).''; } @@ -478,7 +476,7 @@ if (Database::num_rows($res) > 0) { $row = [ Display::url($courseCode, $courseInfo['course_public_url']), $course->title, - $course->status == STUDENT ? get_lang('Learner') : get_lang('Trainer'), + STUDENT == $course->status ? get_lang('Learner') : get_lang('Trainer'), $timeSpent, $totalForumMessages, $tools, @@ -571,7 +569,7 @@ if (isset($_GET['action'])) { break; } - if (CourseManager::getUserInCourseStatus($userId, $courseInfo['real_id']) == STUDENT) { + if (STUDENT == CourseManager::getUserInCourseStatus($userId, $courseInfo['real_id'])) { CourseManager::unsubscribe_user($userId, $courseInfo['code'], $sessionId); Display::addFlash(Display::return_message(get_lang('User is now unsubscribed'))); } else { @@ -658,7 +656,7 @@ if ($hrmList) { echo '
    '; } -if ($user['status'] == DRH) { +if (DRH == $user['status']) { $usersAssigned = UserManager::get_users_followed_by_drh($userId); if ($usersAssigned) { diff --git a/public/main/admin/user_linking_requests.php b/public/main/admin/user_linking_requests.php index 1d044d3725..3dee1d7dc7 100644 --- a/public/main/admin/user_linking_requests.php +++ b/public/main/admin/user_linking_requests.php @@ -121,7 +121,7 @@ function getData(User $hrm, $status = HRM_REQUEST) $line = []; $studentLink = api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$request['user_id']; $line[] = ''.api_get_person_name($request['firstname'], $request['lastname']).''; - if ($status == HRM_REQUEST) { + if (HRM_REQUEST == $status) { $line[] = Display::url( $iconAccept, $urlAccept.$request['user_id'] diff --git a/public/main/admin/user_list.php b/public/main/admin/user_list.php index 57dc478120..c2ec46ead9 100644 --- a/public/main/admin/user_list.php +++ b/public/main/admin/user_list.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * @author Bart Mollet * @author Julio Montoya BeezNest 2011 - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -20,7 +18,7 @@ $currentUserId = api_get_user_id(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; // Login as can be used by different roles -if (isset($_GET['user_id']) && $action == 'login_as') { +if (isset($_GET['user_id']) && 'login_as' == $action) { $check = Security::check_token('get'); if ($check && api_can_login_as($_GET['user_id'])) { $result = UserManager::loginAsUser($_GET['user_id']); @@ -268,7 +266,7 @@ function prepare_user_sql_query($getCount) } } - if ($atLeastOne == false) { + if (false == $atLeastOne) { $keywordListValues = []; } @@ -296,7 +294,7 @@ function prepare_user_sql_query($getCount) $keyword_admin = ''; if (isset($keywordListValues['keyword_status']) && - $keywordListValues['keyword_status'] == PLATFORM_ADMIN + PLATFORM_ADMIN == $keywordListValues['keyword_status'] ) { $query_admin_table = " , $admin_table a "; $keyword_admin = ' AND a.user_id = u.id '; @@ -341,7 +339,7 @@ function prepare_user_sql_query($getCount) } $preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users'); - if (api_is_session_admin() && $preventSessionAdminsToManageAllUsers === 'true') { + if (api_is_session_admin() && 'true' === $preventSessionAdminsToManageAllUsers) { $sql .= ' AND u.creator_id = '.$currentUserId; } @@ -374,7 +372,7 @@ function prepare_user_sql_query($getCount) if (empty($value)) { continue; } - if ($info['field_type'] == ExtraField::FIELD_TYPE_TAG) { + if (ExtraField::FIELD_TYPE_TAG == $info['field_type']) { $result = $extraField->getAllUserPerTag( $info['id'], $value @@ -468,7 +466,7 @@ function get_user_data($from, $number_of_items, $column, $direction) alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; - if ($user[7] == 1 && !empty($user['exp'])) { + if (1 == $user[7] && !empty($user['exp'])) { // check expiration date $expiration_time = convert_sql_date($user['exp']); // if expiration date is passed, store a special value for active field @@ -805,20 +803,20 @@ function active_filter($active, $params, $row) { $_user = api_get_user_info(); - if ($active == '1') { + if ('1' == $active) { $action = 'Lock'; $image = 'accept'; - } elseif ($active == '-1') { + } elseif ('-1' == $active) { $action = 'edit'; $image = 'warning'; - } elseif ($active == '0') { + } elseif ('0' == $active) { $action = 'Unlock'; $image = 'error'; } $result = ''; - if ($action === 'edit') { + if ('edit' === $action) { $result = Display::return_icon( $image.'.png', get_lang('Account expired'), @@ -1116,7 +1114,7 @@ $table->set_column_filter(8, 'active_filter'); $table->set_column_filter(11, 'modify_filter'); // Hide email column if login is email, to avoid column with same data -if (api_get_setting('login_is_email') === 'true') { +if ('true' === api_get_setting('login_is_email')) { $table->setHideColumn(6); } @@ -1135,7 +1133,7 @@ $table_result = $table->return_table(); $extra_search_options = ''; // Try to search the user everywhere -if ($table->get_total_number_of_items() == 0) { +if (0 == $table->get_total_number_of_items()) { if (api_get_multiple_access_url() && isset($_REQUEST['keyword'])) { $keyword = Database::escape_string($_REQUEST['keyword']); $conditions = ['username' => $keyword]; diff --git a/public/main/admin/user_list_consent.php b/public/main/admin/user_list_consent.php index dfa022293f..a666631a87 100644 --- a/public/main/admin/user_list_consent.php +++ b/public/main/admin/user_list_consent.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * @author Bart Mollet * @author Julio Montoya BeezNest 2011 - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -100,7 +98,7 @@ function prepare_user_sql_query($getCount) } } - if ($atLeastOne == false) { + if (false == $atLeastOne) { $keywordListValues = []; } @@ -121,7 +119,7 @@ function prepare_user_sql_query($getCount) $keyword_admin = ''; if (isset($keywordListValues['keyword_status']) && - $keywordListValues['keyword_status'] == PLATFORM_ADMIN + PLATFORM_ADMIN == $keywordListValues['keyword_status'] ) { $query_admin_table = " , $admin_table a "; $keyword_admin = ' AND a.user_id = u.id '; @@ -159,7 +157,7 @@ function prepare_user_sql_query($getCount) } $preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users'); - if (api_is_session_admin() && $preventSessionAdminsToManageAllUsers === 'true') { + if (api_is_session_admin() && 'true' === $preventSessionAdminsToManageAllUsers) { $sql .= " AND u.creator_id = ".api_get_user_id(); } @@ -225,7 +223,7 @@ function get_user_data($from, $number_of_items, $column, $direction) alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; - if ($user[7] == 1 && !empty($user[10])) { + if (1 == $user[7] && !empty($user[10])) { // check expiration date $expiration_time = convert_sql_date($user[10]); // if expiration date is passed, store a special value for active field @@ -396,20 +394,20 @@ function active_filter($active, $params, $row) { $_user = api_get_user_info(); - if ($active == '1') { + if ('1' == $active) { $action = 'Lock'; $image = 'accept'; - } elseif ($active == '-1') { + } elseif ('-1' == $active) { $action = 'edit'; $image = 'warning'; - } elseif ($active == '0') { + } elseif ('0' == $active) { $action = 'Unlock'; $image = 'error'; } $result = ''; - if ($action === 'edit') { + if ('edit' === $action) { $result = Display::return_icon( $image.'.png', get_lang('Account expired'), diff --git a/public/main/admin/user_move_stats.php b/public/main/admin/user_move_stats.php index 3f8e4a792f..90f13d7f8c 100644 --- a/public/main/admin/user_move_stats.php +++ b/public/main/admin/user_move_stats.php @@ -3,8 +3,6 @@ /** * User move script (to move between courses and sessions). - * - * @package chamilo.admin */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -19,18 +17,18 @@ function compare_data($result_message) { foreach ($result_message as $table => $data) { $title = $table; - if ($table == 'TRACK_E_EXERCISES') { + if ('TRACK_E_EXERCISES' == $table) { $title = get_lang('Tests'); - } elseif ($table == 'TRACK_E_EXERCISES_IN_LP') { + } elseif ('TRACK_E_EXERCISES_IN_LP' == $table) { $title = get_lang('TestsInLp'); - } elseif ($table == 'LP_VIEW') { + } elseif ('LP_VIEW' == $table) { $title = get_lang('Learning paths'); } echo '

    '.get_lang($title).'


    '; if (is_array($data)) { foreach ($data as $id => $item) { - if ($table == 'TRACK_E_EXERCISES' || $table == 'TRACK_E_EXERCISES_IN_LP') { + if ('TRACK_E_EXERCISES' == $table || 'TRACK_E_EXERCISES_IN_LP' == $table) { echo "

    ".get_lang('Attempt')." #$id

    "; echo '

    '; echo get_lang('Test').' #'.$item['exe_exo_id']; @@ -102,7 +100,7 @@ if (isset($_REQUEST['load_ajax'])) { $result_message_compare = []; $update_database = true; - if (isset($_REQUEST['view_stat']) && $_REQUEST['view_stat'] == 1) { + if (isset($_REQUEST['view_stat']) && 1 == $_REQUEST['view_stat']) { $update_database = false; } @@ -610,7 +608,7 @@ if (isset($_REQUEST['load_ajax'])) { echo ''; echo ''; - if ($origin_session_id == 0) { + if (0 == $origin_session_id) { echo '

    '.get_lang('Original course').'

    '; } else { echo '

    '.get_lang('Original session').' #'.$origin_session_id.'

    '; @@ -618,7 +616,7 @@ if (isset($_REQUEST['load_ajax'])) { compare_data($result_message); echo ''; echo ''; - if ($new_session_id == 0) { + if (0 == $new_session_id) { echo '

    '.get_lang('Destination course').'

    '; } else { echo '

    '.get_lang('Destination session').' #'.$new_session_id.'

    '; diff --git a/public/main/admin/user_update_import.php b/public/main/admin/user_update_import.php index 639b2de1df..8bb8ba0753 100644 --- a/public/main/admin/user_update_import.php +++ b/public/main/admin/user_update_import.php @@ -4,8 +4,6 @@ /** * This tool allows platform admins to add users by uploading a CSV or XML file. - * - * @package chamilo.admin */ /** @@ -26,7 +24,7 @@ function validate_data($users) // 1. Check if mandatory fields are set. $mandatory_fields = ['LastName', 'FirstName']; - if (api_get_setting('registration', 'email') == 'true') { + if ('true' == api_get_setting('registration', 'email')) { $mandatory_fields[] = 'Email'; } $classExistList = []; @@ -153,7 +151,7 @@ function updateUsers($users) $userName = $user['UserName']; $userInfo = api_get_user_info_from_username($userName); $user_id = $userInfo['user_id']; - if ($user_id == 0) { + if (0 == $user_id) { return false; } $firstName = isset($user['FirstName']) ? $user['FirstName'] : $userInfo['firstname']; @@ -165,7 +163,7 @@ function updateUsers($users) $changePassMethod = 2; } $authSource = isset($user['AuthSource']) ? $user['AuthSource'] : ''; - if ($changePassMethod === 2 && !empty($authSource) && $authSource != $userInfo['auth_source']) { + if (2 === $changePassMethod && !empty($authSource) && $authSource != $userInfo['auth_source']) { $changePassMethod = 3; } $email = isset($user['Email']) ? $user['Email'] : $userInfo['email']; @@ -272,7 +270,7 @@ function parse_xml_data($file) foreach ($crawler as $domElement) { $row = []; foreach ($domElement->childNodes as $node) { - if ($node->nodeName != '#text') { + if ('#text' != $node->nodeName) { $row[$node->nodeName] = $node->nodeValue; } } @@ -301,7 +299,7 @@ $extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true); $user_id_error = []; $error_message = ''; -if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['size'] !== 0) { +if (isset($_POST['formSent']) && $_POST['formSent'] && 0 !== $_FILES['import_file']['size']) { $file_type = 'csv'; Security::clear_token(); $tok = Security::get_token(); @@ -312,11 +310,11 @@ if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['s $ext_import_file = $uploadInfo['extension']; if (in_array($ext_import_file, $allowed_file_mimetype)) { - if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { + if (0 === strcmp($file_type, 'csv') && $ext_import_file == $allowed_file_mimetype[0]) { $users = parse_csv_data($_FILES['import_file']['tmp_name']); $errors = validate_data($users); $error_kind_file = false; - } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { + } elseif (0 === strcmp($file_type, 'xml') && $ext_import_file == $allowed_file_mimetype[1]) { $users = parse_xml_data($_FILES['import_file']['tmp_name']); $errors = validate_data($users); $error_kind_file = false; @@ -345,7 +343,7 @@ if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['s } $inserted_in_course = []; - if (strcmp($file_type, 'csv') === 0) { + if (0 === strcmp($file_type, 'csv')) { updateUsers($users_to_insert); } @@ -356,7 +354,7 @@ if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['s } $warning_message = ''; - if (count($errors) != 0) { + if (0 != count($errors)) { $warning_message = '
      '; foreach ($errors as $index => $error_user) { $warning_message .= '
    • '.$error_user['error'].': '; diff --git a/public/main/admin/usergroup_export.php b/public/main/admin/usergroup_export.php index 8cdc7ed534..09b149469e 100644 --- a/public/main/admin/usergroup_export.php +++ b/public/main/admin/usergroup_export.php @@ -1,9 +1,6 @@ $class) { // 1. Check of class name is available. - if (!isset($class['name']) || strlen(trim($class['name'])) == 0) { + if (!isset($class['name']) || 0 == strlen(trim($class['name']))) { $class['line'] = $index + 2; $class['error'] = get_lang('Missing class name'); $errors[] = $class; @@ -109,7 +107,7 @@ $form->addButtonImport(get_lang('Import')); if ($form->validate()) { $classes = Import::csvToArray($_FILES['import_file']['tmp_name']); $errors = validate_data($classes); - if (count($errors) == 0) { + if (0 == count($errors)) { $number_of_added_classes = save_data($classes); Display::addFlash(Display::return_message($number_of_added_classes.' '.get_lang('Added'), 'normal')); } else { diff --git a/public/main/admin/usergroup_user_import.php b/public/main/admin/usergroup_user_import.php index 2bc71bf5f3..f478a5a880 100644 --- a/public/main/admin/usergroup_user_import.php +++ b/public/main/admin/usergroup_user_import.php @@ -1,8 +1,6 @@ validate()) { $users_classes = parse_csv_data($_FILES['import_file']['tmp_name']); $errors = validate_data($users_classes); - if (count($errors) == 0) { + if (0 == count($errors)) { $deleteUsersNotInList = isset($_REQUEST['unsubscribe']) && !empty($_REQUEST['unsubscribe']) ? true : false; $return = save_data($users_classes, $deleteUsersNotInList); } @@ -169,7 +167,7 @@ if (isset($return) && $return) { echo $return; } -if (count($errors) != 0) { +if (0 != count($errors)) { $error_message = "\n"; foreach ($errors as $index => $error_class_user) { $error_message .= get_lang('Line').' '.$error_class_user['line'].': '.$error_class_user['error'].''; diff --git a/public/main/admin/usergroup_users.php b/public/main/admin/usergroup_users.php index a298908600..fb26ff4fed 100644 --- a/public/main/admin/usergroup_users.php +++ b/public/main/admin/usergroup_users.php @@ -17,7 +17,7 @@ $usergroup->protectScript($userGroupInfo, true, true); $allowEdit = api_is_platform_admin() || isset($userGroupInfo['author_id']) && $userGroupInfo['author_id'] == api_get_user_id(); $calendarPlugin = null; -if ($allowEdit && api_get_plugin_setting('learning_calendar', 'enabled') === 'true') { +if ($allowEdit && 'true' === api_get_plugin_setting('learning_calendar', 'enabled')) { $calendarPlugin = LearningCalendarPlugin::create(); } @@ -326,7 +326,7 @@ $(function() { $usergroup->showGroupTypeSetting = true; // Action handling: Adding a note -if ($allowEdit && $action === 'delete' && is_numeric($_GET['id'])) { +if ($allowEdit && 'delete' === $action && is_numeric($_GET['id'])) { $res = $usergroup->delete_user_rel_group($_GET['user_id'], $_GET['id']); Display::addFlash(Display::return_message(get_lang('Deleted'), 'confirmation')); header('Location: '.api_get_self().'?id='.$id); diff --git a/public/main/admin/usergroups.php b/public/main/admin/usergroups.php index 00fb4ba92c..1931878075 100644 --- a/public/main/admin/usergroups.php +++ b/public/main/admin/usergroups.php @@ -1,9 +1,6 @@ 'usergroups.php', 'name' => get_lang('Classes')]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } $form = new FormValidator( diff --git a/public/main/announcements/announcements.php b/public/main/announcements/announcements.php index d3c0656a8f..d6ae8e2453 100644 --- a/public/main/announcements/announcements.php +++ b/public/main/announcements/announcements.php @@ -14,7 +14,6 @@ use Chamilo\CourseBundle\Entity\CAnnouncement; * Announcements tool and also add the resource linker here. The database also needed refactoring * as there was no title field (the title was merged into the content field) */ - $use_anonymous = true; require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/attendance/attendance_controller.php b/public/main/attendance/attendance_controller.php index cd61ab0136..9cff8b882b 100644 --- a/public/main/attendance/attendance_controller.php +++ b/public/main/attendance/attendance_controller.php @@ -603,9 +603,9 @@ class AttendanceController } else { $result[$class_day['id']] = ' '; } - ++$cols; + $cols++; } - ++$count; + $count++; $data_table[] = $result; } } @@ -620,7 +620,7 @@ class AttendanceController $tables = []; $changed = 1; - for ($i = 0; $i <= $rows; ++$i) { + for ($i = 0; $i <= $rows; $i++) { $row = isset($data_table[$i]) ? $data_table[$i] : null; $key = 1; $max_dates_per_page = 10; @@ -630,14 +630,14 @@ class AttendanceController if (!empty($item)) { foreach ($item as $value) { if ($count_j >= $max_dates_per_page) { - ++$key; + $key++; $max_dates_per_page = $max_dates_per_page_original * $key; //magic hack $tables[$key][$i][] = $tables[1][$i][0]; $tables[$key][$i][] = $tables[1][$i][1]; } $tables[$key][$i][] = $value; - ++$count_j; + $count_j++; } } } diff --git a/public/main/attendance/attendance_sheet.php b/public/main/attendance/attendance_sheet.php index 5953c248f4..1e7a1ca03d 100644 --- a/public/main/attendance/attendance_sheet.php +++ b/public/main/attendance/attendance_sheet.php @@ -251,7 +251,7 @@ if (api_is_allowed_to_edit(null, true) || @@ -393,7 +393,7 @@ if (api_is_allowed_to_edit(null, true) || '; } echo ''; - ++$i; + $i++; } echo ''; echo '
'; ?> diff --git a/public/main/auth/catalog_layout.php b/public/main/auth/catalog_layout.php index 0a1602e528..89c2d323fa 100644 --- a/public/main/auth/catalog_layout.php +++ b/public/main/auth/catalog_layout.php @@ -4,10 +4,8 @@ * Layout (principal view) used for structuring course/session catalog. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.auth */ -if (api_get_setting('course_catalog_published') !== 'true') { +if ('true' !== api_get_setting('course_catalog_published')) { // Access rights: anonymous users can't do anything usefull here. api_block_anonymous_users(); } diff --git a/public/main/auth/courses.php b/public/main/auth/courses.php index 9f0d8b28c3..69729af1a8 100644 --- a/public/main/auth/courses.php +++ b/public/main/auth/courses.php @@ -23,14 +23,14 @@ $limit = CoursesController::getLimitArray(); // Section for the tabs. $this_section = SECTION_CATALOG; -if (api_get_setting('course_catalog_published') !== 'true') { +if ('true' !== api_get_setting('course_catalog_published')) { // Access rights: anonymous users can't do anything useful here. api_block_anonymous_users(); } // For students $user_can_view_page = true; -if (api_get_setting('allow_students_to_browse_courses') === 'false') { +if ('false' === api_get_setting('allow_students_to_browse_courses')) { $user_can_view_page = false; } @@ -224,7 +224,7 @@ switch ($action) { } $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription'); - if ($registrationAllowed === 'true') { + if ('true' === $registrationAllowed) { $entityManager = Database::getManager(); $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); @@ -262,7 +262,7 @@ switch ($action) { if ($count <= 0) { // no course in session -> return to catalog $url = api_get_path(WEB_CODE_PATH).'auth/courses.php'; - } elseif ($count == 1) { + } elseif (1 == $count) { // only one course, so redirect directly to this course foreach ($coursesList as $course) { $url = api_get_path(WEB_COURSE_PATH).$course['directory'].'/index.php?id_session='.$sessionId; diff --git a/public/main/auth/courses_categories.php b/public/main/auth/courses_categories.php index fa23f757fa..5701f7a5e3 100644 --- a/public/main/auth/courses_categories.php +++ b/public/main/auth/courses_categories.php @@ -9,7 +9,7 @@ use Chamilo\CoreBundle\Framework\Container; * * @author Christian Fasanando - Beeznest */ -if (isset($_REQUEST['action']) && Security::remove_XSS($_REQUEST['action']) !== 'subscribe') { +if (isset($_REQUEST['action']) && 'subscribe' !== Security::remove_XSS($_REQUEST['action'])) { $stok = Security::get_token(); } else { $stok = Security::getTokenFromSession(); @@ -74,7 +74,7 @@ echo '
if ($showCourses) { echo '
'; - if (!isset($_GET['hidden_links']) || intval($_GET['hidden_links']) != 1) { + if (!isset($_GET['hidden_links']) || 1 != intval($_GET['hidden_links'])) { ?> @@ -114,7 +114,7 @@ if ($showCourses) { echo '
'; -if ($showCourses && $action != 'display_sessions') { +if ($showCourses && 'display_sessions' != $action) { if (!empty($message)) { echo Display::return_message($message, 'confirmation', false); } @@ -130,7 +130,7 @@ if ($showCourses && $action != 'display_sessions') { echo "

".get_lang('Search results for:')." ".$searchTerm."
"; } - $showTeacher = api_get_setting('display_teacher_in_courselist') === 'true'; + $showTeacher = 'true' === api_get_setting('display_teacher_in_courselist'); $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $user_id = api_get_user_id(); $categoryListFromDatabase = CourseCategory::getCategories(); @@ -145,7 +145,7 @@ if ($showCourses && $action != 'display_sessions') { if (!empty($browse_courses_in_category)) { echo '

'; foreach ($browse_courses_in_category as $course) { - $course_hidden = $course['visibility'] == COURSE_VISIBILITY_HIDDEN; + $course_hidden = COURSE_VISIBILITY_HIDDEN == $course['visibility']; if ($course_hidden) { continue; @@ -155,13 +155,13 @@ if ($showCourses && $action != 'display_sessions') { $userRegisteredInCourseAsTeacher = CourseManager::is_course_teacher($user_id, $course['code']); $userRegistered = $userRegisteredInCourse && $userRegisteredInCourseAsTeacher; - $course_public = $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD; - $course_open = $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM; - $course_private = $course['visibility'] == COURSE_VISIBILITY_REGISTERED; - $course_closed = $course['visibility'] == COURSE_VISIBILITY_CLOSED; + $course_public = COURSE_VISIBILITY_OPEN_WORLD == $course['visibility']; + $course_open = COURSE_VISIBILITY_OPEN_PLATFORM == $course['visibility']; + $course_private = COURSE_VISIBILITY_REGISTERED == $course['visibility']; + $course_closed = COURSE_VISIBILITY_CLOSED == $course['visibility']; - $course_subscribe_allowed = $course['subscribe'] == 1; - $course_unsubscribe_allowed = $course['unsubscribe'] == 1; + $course_subscribe_allowed = 1 == $course['subscribe']; + $course_unsubscribe_allowed = 1 == $course['unsubscribe']; $count_connections = $course['count_connections']; $creation_date = substr($course['creation_date'], 0, 10); @@ -405,7 +405,7 @@ function return_title($course) $html .= ''.$course['title'].''; $html .= '
'; - if (api_get_configuration_value('hide_course_rating') === false) { + if (false === api_get_configuration_value('hide_course_rating')) { $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $rating = Display::return_rating_system( 'star_'.$course['real_id'], @@ -452,7 +452,7 @@ function return_already_registered_label($in_status) { $icon = ''; $title = get_lang("YouAreATrainerOfThisCourse"); - if ($in_status == 'student') { + if ('student' == $in_status) { $icon = ''; $title = get_lang("Already subscribed"); } diff --git a/public/main/auth/courses_controller.php b/public/main/auth/courses_controller.php index 1996374a12..7dba9d110d 100644 --- a/public/main/auth/courses_controller.php +++ b/public/main/auth/courses_controller.php @@ -16,8 +16,6 @@ use Chamilo\CoreBundle\Repository\SequenceRepository; * it should be included inside a dispatcher file (e.g: index.php) * * @author Christian Fasanando - BeezNest - * - * @package chamilo.auth */ class CoursesController { @@ -62,7 +60,7 @@ class CoursesController $listCategories = CoursesAndSessionsCatalog::getCourseCategoriesTree(); $data['countCoursesInCategory'] = CourseCategory::countCoursesInCategory($category_code); - if ($action === 'display_random_courses') { + if ('display_random_courses' === $action) { // Random value is used instead limit filter $data['browse_courses_in_category'] = CoursesAndSessionsCatalog::getCoursesInCategory(null, 12); $data['countCoursesInCategory'] = count($data['browse_courses_in_category']); @@ -85,7 +83,7 @@ class CoursesController $user_coursecodes = []; // we need only the course codes as these will be used to match against the courses of the category - if ($user_courses != '') { + if ('' != $user_courses) { foreach ($user_courses as $key => $value) { $user_coursecodes[] = $value['code']; } @@ -150,7 +148,7 @@ class CoursesController $user_coursecodes = []; // we need only the course codes as these will be used to match against the courses of the category - if ($user_courses != '') { + if ('' != $user_courses) { foreach ($user_courses as $value) { $user_coursecodes[] = $value['code']; } @@ -254,7 +252,7 @@ class CoursesController } $catalogSessionAutoSubscriptionAllowed = false; - if (api_get_setting('catalog_allow_session_auto_subscription') === 'true') { + if ('true' === api_get_setting('catalog_allow_session_auto_subscription')) { $catalogSessionAutoSubscriptionAllowed = true; } @@ -357,7 +355,7 @@ class CoursesController public function sessionList($action, $nameTools, $limit = []) { $date = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); - $hiddenLinks = isset($_GET['hidden_links']) ? $_GET['hidden_links'] == 1 : false; + $hiddenLinks = isset($_GET['hidden_links']) ? 1 == $_GET['hidden_links'] : false; $limit = isset($limit) ? $limit : self::getLimitArray(); $countSessions = CoursesAndSessionsCatalog::browseSessions($date, [], false, true); @@ -381,7 +379,7 @@ class CoursesController $tpl->assign('actions', self::getTabList(2)); $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses()); $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions()); - $tpl->assign('show_tutor', api_get_setting('show_session_coach') === 'true'); + $tpl->assign('show_tutor', 'true' === api_get_setting('show_session_coach')); $tpl->assign('course_url', $courseUrl); $tpl->assign('catalog_pagination', $pagination); $tpl->assign('hidden_links', $hiddenLinks); @@ -405,7 +403,7 @@ class CoursesController public function sessionsListByName(array $limit) { $keyword = isset($_POST['keyword']) ? $_POST['keyword'] : null; - $hiddenLinks = isset($_GET['hidden_links']) ? (int) $_GET['hidden_links'] == 1 : false; + $hiddenLinks = isset($_GET['hidden_links']) ? 1 == (int) $_GET['hidden_links'] : false; $courseUrl = CourseCategory::getCourseCategoryUrl( 1, $limit['length'], @@ -421,7 +419,7 @@ class CoursesController $tpl->assign('actions', self::getTabList(2)); $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses()); $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions()); - $tpl->assign('show_tutor', api_get_setting('show_session_coach') === 'true' ? true : false); + $tpl->assign('show_tutor', 'true' === api_get_setting('show_session_coach') ? true : false); $tpl->assign('course_url', $courseUrl); $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel()); $tpl->assign('hidden_links', $hiddenLinks); @@ -429,7 +427,7 @@ class CoursesController $tpl->assign('keyword', Security::remove_XSS($keyword)); $tpl->assign('sessions', $sessionsBlocks); - $layout = $tpl->get_template('auth/session_catalog.html.twig'); + $layout = $tpl->get_template('auth/session_catalog.html.twig'); $content = $tpl->fetch($layout); $tpl->assign('content', $content); $tpl->display_one_col_template(); @@ -447,14 +445,14 @@ class CoursesController $url = CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); $headers = []; if (CoursesAndSessionsCatalog::showCourses()) { - $headers[] = [ + $headers[] = [ 'url' => api_get_self(), 'content' => get_lang('CourseManagement'), ]; } if (CoursesAndSessionsCatalog::showSessions()) { - $headers[] = [ + $headers[] = [ 'url' => $url, 'content' => get_lang('SessionList'), ]; @@ -472,7 +470,7 @@ class CoursesController { $searchTag = isset($_POST['search_tag']) ? $_POST['search_tag'] : null; $searchDate = isset($_POST['date']) ? $_POST['date'] : date('Y-m-d'); - $hiddenLinks = isset($_GET['hidden_links']) ? (int) $_GET['hidden_links'] == 1 : false; + $hiddenLinks = isset($_GET['hidden_links']) ? 1 == (int) $_GET['hidden_links'] : false; $courseUrl = CourseCategory::getCourseCategoryUrl( 1, $limit['length'], @@ -487,7 +485,7 @@ class CoursesController $tpl = new Template(); $tpl->assign('show_courses', CoursesAndSessionsCatalog::showCourses()); $tpl->assign('show_sessions', CoursesAndSessionsCatalog::showSessions()); - $tpl->assign('show_tutor', api_get_setting('show_session_coach') === 'true' ? true : false); + $tpl->assign('show_tutor', 'true' === api_get_setting('show_session_coach') ? true : false); $tpl->assign('course_url', $courseUrl); $tpl->assign('already_subscribed_label', $this->getAlreadyRegisteredInSessionLabel()); $tpl->assign('hidden_links', $hiddenLinks); @@ -584,7 +582,7 @@ class CoursesController $hasRequirements = false; foreach ($sequences['sequences'] as $sequence) { - if (count($sequence['requirements']) === 0) { + if (0 === count($sequence['requirements'])) { continue; } $hasRequirements = true; diff --git a/public/main/auth/inscription.php b/public/main/auth/inscription.php index e5469b82eb..7243daa80a 100644 --- a/public/main/auth/inscription.php +++ b/public/main/auth/inscription.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * This script displays a form for registering new users. - * - * @package chamilo.auth */ //quick hack to adapt the registration form result to the selected registration language @@ -27,7 +25,7 @@ $allowedFields = [ ]; $allowedFieldsConfiguration = api_get_configuration_value('allow_fields_inscription'); -if ($allowedFieldsConfiguration !== false) { +if (false !== $allowedFieldsConfiguration) { $allowedFields = isset($allowedFieldsConfiguration['fields']) ? $allowedFieldsConfiguration['fields'] : []; $allowedFields['extra_fields'] = isset($allowedFieldsConfiguration['extra_fields']) ? $allowedFieldsConfiguration['extra_fields'] : []; } @@ -36,8 +34,8 @@ $extraFieldsLoaded = false; $htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1'); // User is not allowed if Terms and Conditions are disabled and // registration is disabled too. -$isNotAllowedHere = api_get_setting('allow_terms_conditions') === 'false' && - api_get_setting('allow_registration') === 'false'; +$isNotAllowedHere = 'false' === api_get_setting('allow_terms_conditions') && + 'false' === api_get_setting('allow_registration'); if ($isNotAllowedHere) { api_not_allowed(true, get_lang('Sorry, you are trying to access the registration page for this portal, but registration is currently disabled. Please contact the administrator (see contact information in the footer). If you already have an account on this site.')); @@ -59,7 +57,7 @@ if ($extraConditions && isset($extraConditions['conditions'])) { $extraConditions = $extraConditions['conditions']; foreach ($extraConditions as $condition) { $exists = $userExtraField->get_handler_field_info_by_field_variable($condition['variable']); - if ($exists == false) { + if (false == $exists) { $params = [ 'field_type' => ExtraField::FIELD_TYPE_CHECKBOX, 'variable' => $condition['variable'], @@ -77,7 +75,7 @@ if ($extraConditions && isset($extraConditions['conditions'])) { $form = new FormValidator('registration'); $user_already_registered_show_terms = false; -if (api_get_setting('allow_terms_conditions') === 'true') { +if ('true' === api_get_setting('allow_terms_conditions')) { $user_already_registered_show_terms = isset($_SESSION['term_and_condition']['user_id']); } @@ -104,11 +102,11 @@ if (!empty($course_code_redirect)) { Session::write('exercise_redirect', $exercise_redirect); } -if ($user_already_registered_show_terms === false && - api_get_setting('allow_registration') !== 'false' +if (false === $user_already_registered_show_terms && + 'false' !== api_get_setting('allow_registration') ) { // STUDENT/TEACHER - if (api_get_setting('allow_registration_as_teacher') != 'false') { + if ('false' != api_get_setting('allow_registration_as_teacher')) { if (in_array('status', $allowedFields)) { $form->addRadio( 'status', @@ -138,13 +136,13 @@ if ($user_already_registered_show_terms === false && // EMAIL $form->addElement('text', 'email', get_lang('e-mail'), ['size' => 40]); - if (api_get_setting('registration', 'email') === 'true') { + if ('true' === api_get_setting('registration', 'email')) { $form->addRule('email', get_lang('Required field'), 'required'); } - if (api_get_setting('login_is_email') === 'true') { + if ('true' === api_get_setting('login_is_email')) { $form->applyFilter('email', 'trim'); - if (api_get_setting('registration', 'email') != 'true') { + if ('true' != api_get_setting('registration', 'email')) { $form->addRule('email', get_lang('Required field'), 'required'); } $form->addRule( @@ -162,7 +160,7 @@ if ($user_already_registered_show_terms === false && $form->addRule('email', get_lang('e-mailWrong'), 'email'); // USERNAME - if (api_get_setting('login_is_email') != 'true') { + if ('true' != api_get_setting('login_is_email')) { $form->addText( 'username', get_lang('Username'), @@ -215,7 +213,7 @@ if ($user_already_registered_show_terms === false && get_lang('Phone'), ['size' => 20] ); - if (api_get_setting('registration', 'phone') == 'true') { + if ('true' == api_get_setting('registration', 'phone')) { $form->addRule( 'phone', get_lang('Required field'), @@ -226,7 +224,7 @@ if ($user_already_registered_show_terms === false && // Language if (in_array('language', $allowedFields)) { - if (api_get_setting('registration', 'language') == 'true') { + if ('true' == api_get_setting('registration', 'language')) { $form->addSelectLanguage( 'language', get_lang('Language') @@ -241,7 +239,7 @@ if ($user_already_registered_show_terms === false && get_lang('Code'), ['size' => 40] ); - if (api_get_setting('registration', 'officialcode') == 'true') { + if ('true' == api_get_setting('registration', 'officialcode')) { $form->addRule( 'official_code', get_lang('Required field'), @@ -251,8 +249,8 @@ if ($user_already_registered_show_terms === false && } // EXTENDED FIELDS - if (api_get_setting('extended_profile') == 'true' && - api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true' + if ('true' == api_get_setting('extended_profile') && + 'true' == api_get_setting('extendedprofile_registration', 'mycomptetences') ) { $form->addHtmlEditor( 'competences', @@ -263,8 +261,8 @@ if ($user_already_registered_show_terms === false && ); } - if (api_get_setting('extended_profile') == 'true' && - api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true' + if ('true' == api_get_setting('extended_profile') && + 'true' == api_get_setting('extendedprofile_registration', 'mydiplomas') ) { $form->addHtmlEditor( 'diplomas', @@ -275,8 +273,8 @@ if ($user_already_registered_show_terms === false && ); } - if (api_get_setting('extended_profile') == 'true' && - api_get_setting('extendedprofile_registration', 'myteach') == 'true' + if ('true' == api_get_setting('extended_profile') && + 'true' == api_get_setting('extendedprofile_registration', 'myteach') ) { $form->addHtmlEditor( 'teach', @@ -287,8 +285,8 @@ if ($user_already_registered_show_terms === false && ); } - if (api_get_setting('extended_profile') == 'true' && - api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true' + if ('true' == api_get_setting('extended_profile') && + 'true' == api_get_setting('extendedprofile_registration', 'mypersonalopenarea') ) { $form->addHtmlEditor( 'openarea', @@ -299,24 +297,24 @@ if ($user_already_registered_show_terms === false && ); } - if (api_get_setting('extended_profile') === 'true') { - if (api_get_setting('extendedprofile_registration', 'mycomptetences') === 'true' && - api_get_setting('extendedprofile_registrationrequired', 'mycomptetences') === 'true' + if ('true' === api_get_setting('extended_profile')) { + if ('true' === api_get_setting('extendedprofile_registration', 'mycomptetences') && + 'true' === api_get_setting('extendedprofile_registrationrequired', 'mycomptetences') ) { $form->addRule('competences', get_lang('Required field'), 'required'); } - if (api_get_setting('extendedprofile_registration', 'mydiplomas') === 'true' && - api_get_setting('extendedprofile_registrationrequired', 'mydiplomas') === 'true' + if ('true' === api_get_setting('extendedprofile_registration', 'mydiplomas') && + 'true' === api_get_setting('extendedprofile_registrationrequired', 'mydiplomas') ) { $form->addRule('diplomas', get_lang('Required field'), 'required'); } - if (api_get_setting('extendedprofile_registration', 'myteach') === 'true' && - api_get_setting('extendedprofile_registrationrequired', 'myteach') === 'true' + if ('true' === api_get_setting('extendedprofile_registration', 'myteach') && + 'true' === api_get_setting('extendedprofile_registrationrequired', 'myteach') ) { $form->addRule('teach', get_lang('Required field'), 'required'); } - if (api_get_setting('extendedprofile_registration', 'mypersonalopenarea') === 'true' && - api_get_setting('extendedprofile_registrationrequired', 'mypersonalopenarea') === 'true' + if ('true' === api_get_setting('extendedprofile_registration', 'mypersonalopenarea') && + 'true' === api_get_setting('extendedprofile_registrationrequired', 'mypersonalopenarea') ) { $form->addRule('openarea', get_lang('Required field'), 'required'); } @@ -359,7 +357,7 @@ if ($user_already_registered_show_terms === false && // CAPTCHA $captcha = api_get_setting('allow_captcha'); - $allowCaptcha = $captcha === 'true'; + $allowCaptcha = 'true' === $captcha; if ($allowCaptcha) { $ajax = api_get_path(WEB_AJAX_PATH).'form.ajax.php?a=get_captcha'; @@ -406,7 +404,7 @@ if ($user_already_registered_show_terms === false && } } -if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') { +if (isset($_SESSION['user_language_choice']) && '' != $_SESSION['user_language_choice']) { $defaults['language'] = $_SESSION['user_language_choice']; } else { $defaults['language'] = api_get_setting('platformLanguage'); @@ -435,10 +433,10 @@ $tool_name = get_lang('Registration'); if (!CustomPages::enabled()) { // Load terms & conditions from the current lang - if (api_get_setting('allow_terms_conditions') === 'true') { + if ('true' === api_get_setting('allow_terms_conditions')) { $get = array_keys($_GET); if (isset($get)) { - if (isset($get[0]) && $get[0] == 'legal') { + if (isset($get[0]) && 'legal' == $get[0]) { $language = api_get_interface_language(); $language = api_get_language_id($language); $term_preview = LegalManager::get_last_condition($language); @@ -466,7 +464,7 @@ if (!CustomPages::enabled()) { } } - if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_registered_show_terms) { + if ('true' === api_get_setting('allow_terms_conditions') && $user_already_registered_show_terms) { $tool_name = get_lang('Terms and Conditions'); } } @@ -476,18 +474,18 @@ if ($isNotAllowedHere) { api_not_allowed(true, get_lang('Sorry, you are trying to access the registration page for this portal, but registration is currently disabled. Please contact the administrator (see contact information in the footer). If you already have an account on this site.')); } -if (api_get_setting('allow_registration') === 'approval') { +if ('approval' === api_get_setting('allow_registration')) { $content .= Display::return_message(get_lang('Your account has to be approved')); } $showTerms = false; // Terms and conditions -if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_registered_show_terms) { +if ('true' === api_get_setting('allow_terms_conditions') && $user_already_registered_show_terms) { if (!api_is_platform_admin()) { - if (api_get_setting('show_terms_if_profile_completed') === 'true') { + if ('true' === api_get_setting('show_terms_if_profile_completed')) { $userInfo = api_get_user_info(); - if ($userInfo && $userInfo['status'] != ANONYMOUS) { - if ((int) $userInfo['profile_completed'] !== 1) { + if ($userInfo && ANONYMOUS != $userInfo['status']) { + if (1 !== (int) $userInfo['profile_completed']) { api_not_allowed(true); } } @@ -517,7 +515,7 @@ if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_regist $form->addHidden('legal_info', $term_preview['id'].':'.$term_preview['language_id']); // Show if only HTML type - if ($term_preview['type'] == '2') { + if ('2' == $term_preview['type']) { $termExtraFields = new ExtraFieldValue('terms_and_condition'); $values = $termExtraFields->getAllValuesByItem($term_preview['id']); foreach ($values as $value) { @@ -527,7 +525,7 @@ if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_regist } } - if ($term_preview['type'] == 1) { + if (1 == $term_preview['type']) { $form->addElement( 'checkbox', 'legal_accept', @@ -547,7 +545,7 @@ if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_regist $allowDoubleValidation = api_get_configuration_value('allow_double_validation_in_registration'); $formContainsSendButton = false; -if ($allowDoubleValidation && $showTerms == false) { +if ($allowDoubleValidation && false == $showTerms) { $htmlHeadXtra[] = '"; -$pluginCalendar = api_get_plugin_setting('learning_calendar', 'enabled') === 'true'; +$pluginCalendar = 'true' === api_get_plugin_setting('learning_calendar', 'enabled'); if ($pluginCalendar) { $plugin = LearningCalendarPlugin::create(); @@ -55,7 +53,7 @@ if (!empty($courseUserList)) { $courseId = $result['c_id']; $courseInfo = api_get_course_info_by_id($courseId); - if ($count == 1) { + if (1 == $count) { $first = ''.get_lang('First').''; } if ($count == $last_item) { @@ -99,9 +97,9 @@ if (!empty($dates)) { $content .= ''; } -if (api_get_configuration_value('private_messages_about_user_visible_to_user') === true) { +if (true === api_get_configuration_value('private_messages_about_user_visible_to_user')) { $allowMessages = api_get_configuration_value('private_messages_about_user'); - if ($allowMessages === true) { + if (true === $allowMessages) { // Messages $content .= Display::page_subheader2(get_lang('Messages')); $content .= MessageManager::getMessagesAboutUserToString(api_get_user_info()); diff --git a/public/main/auth/profile.php b/public/main/auth/profile.php index fdf5906a2a..d7399ecc1f 100644 --- a/public/main/auth/profile.php +++ b/public/main/auth/profile.php @@ -16,7 +16,7 @@ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_MYPROFILE; -$allowSocialTool = api_get_setting('allow_social_tool') == 'true'; +$allowSocialTool = 'true' == api_get_setting('allow_social_tool'); if ($allowSocialTool) { $this_section = SECTION_SOCIAL; } @@ -74,7 +74,7 @@ function show_image(image,width,height) { '; $jquery_ready_content = ''; -if (api_get_setting('allow_message_tool') === 'true') { +if ('true' === api_get_setting('allow_message_tool')) { $jquery_ready_content = <<addElement( 'size' => USERNAME_MAX_LENGTH, ] ); -if (!in_array('login', $profileList) || api_get_setting('login_is_email') == 'true') { +if (!in_array('login', $profileList) || 'true' == api_get_setting('login_is_email')) { $form->freeze('username'); } $form->applyFilter('username', 'stripslashes'); @@ -162,7 +162,7 @@ if (!in_array('officialcode', $profileList)) { $form->applyFilter('official_code', 'stripslashes'); $form->applyFilter('official_code', 'trim'); $form->applyFilter('official_code', 'html_filter'); -if (api_get_setting('registration', 'officialcode') === 'true' && +if ('true' === api_get_setting('registration', 'officialcode') && in_array('officialcode', $profileList) ) { $form->addRule('official_code', get_lang('Required field'), 'required'); @@ -174,7 +174,7 @@ if (!in_array('email', $profileList)) { $form->freeze('email'); } -if (api_get_setting('registration', 'email') == 'true' && in_array('email', $profileList) +if ('true' == api_get_setting('registration', 'email') && in_array('email', $profileList) ) { $form->applyFilter('email', 'stripslashes'); $form->applyFilter('email', 'trim'); @@ -192,11 +192,11 @@ $form->applyFilter('phone', 'trim'); $form->applyFilter('phone', 'html_filter'); // PICTURE -if (api_get_setting('profile.is_editable') === 'true' && in_array('picture', $profileList)) { +if ('true' === api_get_setting('profile.is_editable') && in_array('picture', $profileList)) { $form->addFile( 'picture', [ - $user_data['picture_uri'] != '' ? get_lang('Update Image') : get_lang('Add image'), + '' != $user_data['picture_uri'] ? get_lang('Update Image') : get_lang('Add image'), get_lang('Only PNG, JPG or GIF images allowed'), ], [ @@ -228,7 +228,7 @@ if (!in_array('language', $profileList)) { } // THEME -if (api_get_setting('profile.is_editable') === 'true' && api_get_setting('user_selected_theme') === 'true') { +if ('true' === api_get_setting('profile.is_editable') && 'true' === api_get_setting('user_selected_theme')) { $form->addElement('SelectTheme', 'theme', get_lang('Graphical theme')); if (!in_array('theme', $profileList)) { $form->freeze('theme'); @@ -237,7 +237,7 @@ if (api_get_setting('profile.is_editable') === 'true' && api_get_setting('user_s } // EXTENDED PROFILE this make the page very slow! -if (api_get_setting('extended_profile') === 'true') { +if ('true' === api_get_setting('extended_profile')) { $width_extended_profile = 500; // MY COMPETENCES $form->addHtmlEditor( @@ -299,8 +299,8 @@ if (api_get_setting('extended_profile') === 'true') { } // PASSWORD, if auth_source is platform -if ($user_data['auth_source'] == PLATFORM_AUTH_SOURCE && - api_get_setting('profile.is_editable') === 'true' && +if (PLATFORM_AUTH_SOURCE == $user_data['auth_source'] && + 'true' === api_get_setting('profile.is_editable') && in_array('password', $profileList) ) { $form->addElement('password', 'password0', [get_lang('Pass'), get_lang('Enter2passToChange')], ['size' => 40]); @@ -348,7 +348,7 @@ if (in_array('apikeys', $profileList)) { ); } // SUBMIT -if (api_get_setting('profile.is_editable') === 'true') { +if ('true' === api_get_setting('profile.is_editable')) { $form->addButtonUpdate(get_lang('Save settings'), 'apply_change'); } else { $form->freeze(); @@ -414,8 +414,8 @@ if ($form->validate()) { } $allow_users_to_change_email_with_no_password = true; - if (isset($user_data['auth_source']) && $user_data['auth_source'] == PLATFORM_AUTH_SOURCE && - api_get_setting('allow_users_to_change_email_with_no_password') === 'false' + if (isset($user_data['auth_source']) && PLATFORM_AUTH_SOURCE == $user_data['auth_source'] && + 'false' === api_get_setting('allow_users_to_change_email_with_no_password') ) { $allow_users_to_change_email_with_no_password = false; } @@ -573,9 +573,9 @@ if ($form->validate()) { unset($user_data['api_key_generate']); foreach ($user_data as $key => $value) { - if (substr($key, 0, 6) === 'extra_') { //an extra field + if ('extra_' === substr($key, 0, 6)) { //an extra field continue; - } elseif (strpos($key, 'remove_extra_') !== false) { + } elseif (false !== strpos($key, 'remove_extra_')) { } else { if (in_array($key, $available_values_to_modify)) { $sql .= " $key = '".Database::escape_string($value)."',"; @@ -624,7 +624,7 @@ if ($form->validate()) { Session::write('_locale_user', $user_data['language']); } - if ($passwordWasChecked == false) { + if (false == $passwordWasChecked) { Display::addFlash( Display:: return_message(get_lang('Your new profile has been saved'), 'normal', false) ); @@ -666,8 +666,8 @@ if ($form->validate()) { $actions = ''; if ($allowSocialTool) { - if (api_get_setting('extended_profile') === 'true') { - if (api_get_setting('allow_message_tool') === 'true') { + if ('true' === api_get_setting('extended_profile')) { + if ('true' === api_get_setting('allow_message_tool')) { $actions .= ''. Display::return_icon('shared_profile.png', get_lang('View shared profile')).''; $actions .= ''. @@ -675,7 +675,7 @@ if ($allowSocialTool) { } $show = isset($_GET['show']) ? '&show='.Security::remove_XSS($_GET['show']) : ''; - if (isset($_GET['type']) && $_GET['type'] === 'extended') { + if (isset($_GET['type']) && 'extended' === $_GET['type']) { $actions .= ''. Display::return_icon('edit.png', get_lang('Edit normal profile'), '', 16).''; } else { @@ -685,7 +685,7 @@ if ($allowSocialTool) { } } -$show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') === 'true' ? true : false; +$show_delete_account_button = 'true' === api_get_setting('platform_unsubscribe_allowed') ? true : false; $tpl = new Template(get_lang('Profile')); @@ -698,7 +698,7 @@ if ($actions) { SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); -$allowJustification = api_get_plugin_setting('justification', 'tool_enable') === 'true'; +$allowJustification = 'true' === api_get_plugin_setting('justification', 'tool_enable'); $justification = ''; if ($allowJustification) { $plugin = Justification::create(); diff --git a/public/main/auth/sort_my_courses.php b/public/main/auth/sort_my_courses.php index 0c20f916e1..a7aab9f71e 100644 --- a/public/main/auth/sort_my_courses.php +++ b/public/main/auth/sort_my_courses.php @@ -194,7 +194,7 @@ switch ($action) { Database::query($sql); Display::addFlash(Display::return_message(get_lang('Update successful'))); - if ($redirect === 'home') { + if ('home' === $redirect) { $url = api_get_path(WEB_PATH).'user_portal.php'; header('Location: '.$url); exit; @@ -211,7 +211,7 @@ Display::display_header(); $stok = Security::get_token(); $courses_without_category = isset($courses_in_category[0]) ? $courses_in_category[0] : null; echo '
'; -if ($action != 'createcoursecategory') { +if ('createcoursecategory' != $action) { echo ''; echo Display::return_icon('new_folder.png', get_lang('Create a personal courses category'), '', '32'); echo ''; @@ -234,7 +234,7 @@ if (!empty($user_course_categories)) { echo ''; $url = $currentUrl.'?categoryid='.$row['id'].'&sec_token='.$stok; if ($allowCollapsable) { - if (isset($row['collapsed']) && $row['collapsed'] == 0) { + if (isset($row['collapsed']) && 0 == $row['collapsed']) { echo Display::url( '', $url.'&action=set_collapsable&option=1' @@ -306,13 +306,13 @@ if (!empty($user_course_categories)) { echo CourseManager::getTeacherListFromCourseCodeToString($course['code']); echo '
'; - if (api_get_setting('display_teacher_in_courselist') === 'true') { + if ('true' === api_get_setting('display_teacher_in_courselist')) { echo $course['tutor']; } echo ''; ?>
')) return false"> @@ -386,13 +386,13 @@ if (!empty($courses_without_category)) { echo CourseManager::getTeacherListFromCourseCodeToString($course['code']); echo '
'; - if (api_get_setting('display_teacher_in_courselist') === 'true') { + if ('true' === api_get_setting('display_teacher_in_courselist')) { echo $course['tutor']; } echo ''; ?>
')) return false;"> diff --git a/public/main/auth/unsubscribe_account.php b/public/main/auth/unsubscribe_account.php index 755834539d..8f18c35b29 100644 --- a/public/main/auth/unsubscribe_account.php +++ b/public/main/auth/unsubscribe_account.php @@ -3,7 +3,7 @@ require_once __DIR__.'/../inc/global.inc.php'; -if (api_get_setting('platform_unsubscribe_allowed') != 'true') { +if ('true' != api_get_setting('platform_unsubscribe_allowed')) { api_not_allowed(); } diff --git a/public/main/badge/assertion.php b/public/main/badge/assertion.php index 132e0f4464..7fe0786fdb 100644 --- a/public/main/badge/assertion.php +++ b/public/main/badge/assertion.php @@ -5,8 +5,6 @@ * Show information about a new assertion. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.badge */ require_once __DIR__.'/../inc/global.inc.php'; @@ -15,7 +13,7 @@ $skillId = isset($_GET['skill']) ? (int) $_GET['skill'] : 0; $courseId = isset($_GET['course']) ? (int) $_GET['course'] : 0; $sessionId = isset($_GET['session']) ? (int) $_GET['session'] : 0; -if ($userId === 0 || $skillId === 0) { +if (0 === $userId || 0 === $skillId) { exit; } @@ -32,7 +30,7 @@ $userSkill = $objSkillRelUser->getByUserAndSkill( $sessionId ); -if ($userSkill == false) { +if (false == $userSkill) { exit; } diff --git a/public/main/badge/assign.php b/public/main/badge/assign.php index ab241f1e00..4a3d7eea3d 100644 --- a/public/main/badge/assign.php +++ b/public/main/badge/assign.php @@ -120,7 +120,7 @@ if (!$profile) { break; } - if (!$profile && $parent['parent_id'] == 0) { + if (!$profile && 0 == $parent['parent_id']) { $profile = $skillLevelRepo->findAll(); $profile = isset($profile[0]) ? $profile[0] : false; } @@ -227,7 +227,7 @@ $form->addHidden('user', $user->getId()); $form->addHidden('id', $skillId); $form->addRule('skill', get_lang('Required field'), 'required'); -$showLevels = api_get_configuration_value('hide_skill_levels') === false; +$showLevels = false === api_get_configuration_value('hide_skill_levels'); if ($showLevels) { $form->addSelect('acquired_level', get_lang('Level acquired'), $acquiredLevel); @@ -364,7 +364,7 @@ if (api_is_drh()) { 'url' => api_get_path(WEB_CODE_PATH).'mySpace/index.php', "name" => get_lang('Reporting'), ]; - if ($user->getStatus() == COURSEMANAGER) { + if (COURSEMANAGER == $user->getStatus()) { $interbreadcrumb[] = [ "url" => api_get_path(WEB_CODE_PATH).'mySpace/teachers.php', 'name' => get_lang('Trainers'), diff --git a/public/main/badge/class.php b/public/main/badge/class.php index a880b85e92..2c23e93ff3 100644 --- a/public/main/badge/class.php +++ b/public/main/badge/class.php @@ -5,8 +5,6 @@ * Show information about the OpenBadge class. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.badge */ require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/badge/criteria.php b/public/main/badge/criteria.php index 847ca27262..1f1ebf0c7e 100644 --- a/public/main/badge/criteria.php +++ b/public/main/badge/criteria.php @@ -5,8 +5,6 @@ * Show information about OpenBadge criteria. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.badge */ require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/badge/issued.php b/public/main/badge/issued.php index be3d143d7b..dce091b4c7 100644 --- a/public/main/badge/issued.php +++ b/public/main/badge/issued.php @@ -10,8 +10,6 @@ use SkillRelUser as SkillRelUserManager; * * @author Angel Fernando Quiroz Campos * @author José Loguercio Silva - * - * @package chamilo.badge */ require_once __DIR__.'/../inc/global.inc.php'; @@ -55,7 +53,7 @@ if (!Skill::isToolAvailable()) { api_not_allowed(true); } -$showLevels = api_get_configuration_value('hide_skill_levels') === false; +$showLevels = false === api_get_configuration_value('hide_skill_levels'); $skillInfo = [ 'id' => $skill->getId(), @@ -145,7 +143,7 @@ if (!$profile) { break; } - if (!$profile && $parent['parent_id'] == 0) { + if (!$profile && 0 == $parent['parent_id']) { $profile = $skillLevelRepo->findAll(); if ($profile) { $profile = $profile[0]; @@ -233,7 +231,7 @@ if ($allowExport) { $backpack = 'https://backpack.openbadges.org/'; $configBackpack = api_get_setting('openbadges_backpack'); - if (strcmp($backpack, $configBackpack) !== 0) { + if (0 !== strcmp($backpack, $configBackpack)) { $backpack = $configBackpack; } diff --git a/public/main/badge/issued_all.php b/public/main/badge/issued_all.php index 346741fa97..b06e6d9a29 100644 --- a/public/main/badge/issued_all.php +++ b/public/main/badge/issued_all.php @@ -9,8 +9,6 @@ use SkillRelUser as SkillRelUserManager; * Show information about all issued badges with same skill by user. * * @author José Loguercio Silva - * - * @package chamilo.badge */ require_once __DIR__.'/../inc/global.inc.php'; @@ -130,7 +128,7 @@ foreach ($userSkills as $index => $skillIssue) { break; } - if (!$profile && $parent['parent_id'] == 0) { + if (!$profile && 0 == $parent['parent_id']) { $profile = $skillLevelRepo->findAll(); $profile = !empty($profile) ? $profile[0] : []; } @@ -220,7 +218,7 @@ foreach ($userSkills as $index => $skillIssue) { $backpack = 'https://backpack.openbadges.org/'; $configBackpack = api_get_setting('openbadges_backpack'); - if (strcmp($backpack, $configBackpack) !== 0) { + if (0 !== strcmp($backpack, $configBackpack)) { $backpack = $configBackpack; } @@ -275,7 +273,7 @@ foreach ($userSkills as $index => $skillIssue) { $template = new Template(get_lang('Issued badge information')); $template->assign('user_badges', $allUserBadges); -$template->assign('show_level', api_get_configuration_value('hide_skill_levels') == false); +$template->assign('show_level', false == api_get_configuration_value('hide_skill_levels')); $content = $template->fetch( $template->get_template('skill/issued_all.tpl') diff --git a/public/main/badge/issuer.php b/public/main/badge/issuer.php index 1bfb97e834..9302200dd6 100644 --- a/public/main/badge/issuer.php +++ b/public/main/badge/issuer.php @@ -5,8 +5,6 @@ * Show information about the OpenBadge issuer. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.badge */ require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/blog/blog.php b/public/main/blog/blog.php index 7d04c30aa7..93fd38fcc2 100644 --- a/public/main/blog/blog.php +++ b/public/main/blog/blog.php @@ -135,15 +135,15 @@ if (!empty($_GET['unregister'])) { Blog::unsubscribeUser($_GET['blog_id'], $_GET['user_id']); } -if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') { - if (isset($_GET['do']) && $_GET['do'] == 'delete') { +if (isset($_GET['action']) && 'manage_tasks' == $_GET['action']) { + if (isset($_GET['do']) && 'delete' == $_GET['do']) { Blog::deleteTask($blog_id, (int) $_GET['task_id']); Display::addFlash( Display::return_message(get_lang('The task has been deleted.'), 'success') ); } - if (isset($_GET['do']) && $_GET['do'] == 'delete_assignment') { + if (isset($_GET['do']) && 'delete_assignment' == $_GET['do']) { Blog::deleteAssignedTask($blog_id, intval($_GET['task_id']), intval($_GET['user_id'])); Display::addFlash( Display::return_message(get_lang('The task assignment has been deleted.'), 'success') @@ -151,10 +151,10 @@ if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') { } } -if (isset($_GET['action']) && $_GET['action'] == 'view_post') { +if (isset($_GET['action']) && 'view_post' == $_GET['action']) { $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0; - if (isset($_GET['do']) && $_GET['do'] == 'delete_comment') { + if (isset($_GET['do']) && 'delete_comment' == $_GET['do']) { if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { Blog::deleteComment($blog_id, (int) $_GET['post_id'], (int) $_GET['comment_id']); Display::addFlash( @@ -167,7 +167,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post') { } } - if (isset($_GET['do']) && $_GET['do'] == 'delete_article') { + if (isset($_GET['do']) && 'delete_article' == $_GET['do']) { if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) { Blog::deletePost($blog_id, (int) $_GET['article_id']); $action = ''; // Article is gone, go to blog home @@ -180,8 +180,8 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post') { ); } } - if (isset($_GET['do']) && $_GET['do'] == 'rate') { - if (isset($_GET['type']) && $_GET['type'] == 'post') { + if (isset($_GET['do']) && 'rate' == $_GET['do']) { + if (isset($_GET['type']) && 'post' == $_GET['type']) { if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) { Blog::addRating('post', $blog_id, (int) $_GET['post_id'], (int) $_GET['rating']); Display::addFlash( @@ -189,7 +189,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post') { ); } } - if (isset($_GET['type']) && $_GET['type'] == 'comment') { + if (isset($_GET['type']) && 'comment' == $_GET['type']) { if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) { Blog::addRating('comment', $blog_id, (int) $_GET['comment_id'], (int) $_GET['rating']); Display::addFlash( @@ -269,7 +269,7 @@ $calendarBlog = Blog::displayMiniMonthCalendar($month, $year, $blog_id); //task blogs $taskBlog = Blog::getPersonalTasksList(); -if (isset($flag) && $flag == '1') { +if (isset($flag) && '1' == $flag) { $action = "manage_tasks"; Blog::displayTaskAssignmentForm($blog_id); } @@ -295,7 +295,7 @@ if (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) { $result = Database::query($sql); $row = Database::fetch_array($result); - if ($row['number'] == 1) { + if (1 == $row['number']) { $user_task = true; } } @@ -368,19 +368,19 @@ switch ($action) { case 'manage_tasks': if (api_is_allowed('BLOG_'.$blog_id, 'task_management')) { $task = null; - if (isset($_GET['do']) && $_GET['do'] == 'add') { + if (isset($_GET['do']) && 'add' == $_GET['do']) { $task .= Blog::displayTaskCreateForm($blog_id); } - if (isset($_GET['do']) && $_GET['do'] == 'assign') { + if (isset($_GET['do']) && 'assign' == $_GET['do']) { $task .= Blog::displayTaskAssignmentForm($blog_id); } - if (isset($_GET['do']) && $_GET['do'] == 'edit') { + if (isset($_GET['do']) && 'edit' == $_GET['do']) { $task .= Blog::displayTaskEditForm( $blog_id, intval($_GET['task_id']) ); } - if (isset($_GET['do']) && $_GET['do'] == 'edit_assignment') { + if (isset($_GET['do']) && 'edit_assignment' == $_GET['do']) { $task .= Blog::displayAssignedTaskEditForm( $blog_id, intval($_GET['task_id']), diff --git a/public/main/blog/blog_admin.php b/public/main/blog/blog_admin.php index 8053cd05d8..b7307561d5 100644 --- a/public/main/blog/blog_admin.php +++ b/public/main/blog/blog_admin.php @@ -26,16 +26,16 @@ if (api_is_allowed_to_edit()) { // showing the header if we are not in the learning path, if we are in // the learning path, we do not include the banner so we have to explicitly // include the stylesheet, which is normally done in the header - if ($origin != 'learnpath') { + if ('learnpath' != $origin) { $interbreadcrumb[] = [ 'url' => 'blog_admin.php?'.api_get_cidreq(), 'name' => $nameTools, ]; $my_url = ''; - if ($action == 'add') { + if ('add' == $action) { $current_section = get_lang('Create a new project'); $my_url = 'action=add'; - } elseif ($action == 'edit') { + } elseif ('edit' == $action) { $current_section = get_lang('Edit a project'); $my_url = 'action=edit&blog_id='.Security::remove_XSS($_GET['blog_id']); } @@ -58,16 +58,16 @@ if (api_is_allowed_to_edit()) { echo Display::return_message(get_lang('The project has been edited.'), 'confirmation'); } } - if (isset($_GET['action']) && $_GET['action'] == 'visibility') { + if (isset($_GET['action']) && 'visibility' == $_GET['action']) { Blog::changeBlogVisibility(intval($_GET['blog_id'])); echo Display::return_message(get_lang('The visibility has been changed.'), 'confirmation'); } - if (isset($_GET['action']) && $_GET['action'] == 'delete') { + if (isset($_GET['action']) && 'delete' == $_GET['action']) { Blog::deleteBlog(intval($_GET['blog_id'])); echo Display::return_message(get_lang('The project has been deleted.'), 'confirmation'); } - if (isset($_GET['action']) && $_GET['action'] == 'add') { + if (isset($_GET['action']) && 'add' == $_GET['action']) { // we show the form if // 1. no post data // 2. there is post data and one of the required form elements is empty @@ -76,7 +76,7 @@ if (api_is_allowed_to_edit()) { } } - if (isset($_GET['action']) && $_GET['action'] == 'edit') { + if (isset($_GET['action']) && 'edit' == $_GET['action']) { // we show the form if // 1. no post data // 2. there is post data and one of the three form elements is empty diff --git a/public/main/calendar/agenda.php b/public/main/calendar/agenda.php index 470873fbcc..3aa543c3f3 100644 --- a/public/main/calendar/agenda.php +++ b/public/main/calendar/agenda.php @@ -86,7 +86,7 @@ $nameTools = get_lang('Agenda'); Event::event_access_tool(TOOL_CALENDAR_EVENT); -if ($type === 'fromjs') { +if ('fromjs' === $type) { // split the "id" parameter only if string and there are _ separators if (preg_match('/_/', $eventId)) { $id_list = explode('_', $eventId); @@ -95,18 +95,18 @@ if ($type === 'fromjs') { } $eventId = $id_list[1]; $event_type = $id_list[0]; - $event_type = $event_type === 'platform' ? 'admin' : $event_type; + $event_type = 'platform' === $event_type ? 'admin' : $event_type; } $agenda = new Agenda($event_type); $allowToEdit = $agenda->getIsAllowedToEdit(); $actions = $agenda->displayActions('calendar'); -if (!$allowToEdit && $event_type === 'course') { +if (!$allowToEdit && 'course' === $event_type) { api_not_allowed(true); } -if ($event_type === 'course') { +if ('course' === $event_type) { $agendaUrl = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?'.api_get_cidreq().'&type=course'; } else { $agendaUrl = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?&type='.$event_type; diff --git a/public/main/calendar/agenda_js.php b/public/main/calendar/agenda_js.php index a174ecdb10..13f0f9a2bc 100644 --- a/public/main/calendar/agenda_js.php +++ b/public/main/calendar/agenda_js.php @@ -9,7 +9,7 @@ $typeList = ['personal', 'course', 'admin', 'platform']; $type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], $typeList) ? $_REQUEST['type'] : 'personal'; $userId = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null; -if ($type == 'personal' || $type == 'admin') { +if ('personal' == $type || 'admin' == $type) { $cidReset = true; // fixes #5162 } require_once __DIR__.'/../inc/global.inc.php'; @@ -22,12 +22,12 @@ $htmlHeadXtra[] = api_get_asset('fullcalendar/dist/locale-all.js'); $htmlHeadXtra[] = api_get_asset('fullcalendar/dist/gcal.js'); $htmlHeadXtra[] = api_get_css_asset('fullcalendar/dist/fullcalendar.min.css');*/ -if (api_is_platform_admin() && ($type == 'admin' || $type == 'platform')) { +if (api_is_platform_admin() && ('admin' == $type || 'platform' == $type)) { $type = 'admin'; } if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) { - if ($_REQUEST['cidReq'] == -1) { + if (-1 == $_REQUEST['cidReq']) { // When is out of the course tool (e.g My agenda) header('Location: '.api_get_self()); exit; @@ -109,7 +109,7 @@ switch ($type) { $tpl->assign('js_format_date', 'll'); $region_value = api_get_language_isocode(); -if ($region_value == 'en') { +if ('en' == $region_value) { $region_value = 'en-GB'; } $tpl->assign('region_value', $region_value); @@ -156,7 +156,7 @@ $tpl->assign('type', $type); $type_event_class = $type.'_event'; $type_label = get_lang(ucfirst($type).'Calendar'); -if ($type == 'course' && !empty($group_id)) { +if ('course' == $type && !empty($group_id)) { $type_event_class = 'group_event'; $type_label = get_lang('Agenda'); } @@ -170,7 +170,7 @@ if (empty($defaultView)) { /* month, basicWeek, agendaWeek, agendaDay */ $tpl->assign('default_view', $defaultView); -if ($type == 'course' && !empty($session_id)) { +if ('course' == $type && !empty($session_id)) { $type_event_class = 'session_event'; $type_label = get_lang('Session calendar'); } @@ -219,7 +219,7 @@ if (!empty($userId)) { $agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type; } -if ($type == 'course' && !empty($courseId)) { +if ('course' == $type && !empty($courseId)) { $agenda_ajax_url .= '&'.api_get_cidreq(); } @@ -268,7 +268,7 @@ $form->addHtmlEditor( ] ); -if ($agenda->type === 'course') { +if ('course' === $agenda->type) { $form->addHtml(''); diff --git a/public/main/calendar/agenda_list.php b/public/main/calendar/agenda_list.php index 5b91400f92..9e7d28e1a9 100644 --- a/public/main/calendar/agenda_list.php +++ b/public/main/calendar/agenda_list.php @@ -47,7 +47,7 @@ $events = $agenda->getEvents( $this_section = SECTION_MYAGENDA; -if (!empty($currentCourseId) && $currentCourseId != -1) { +if (!empty($currentCourseId) && -1 != $currentCourseId) { // Agenda is inside a course tool $url = api_get_self().'?'.api_get_cidreq(); $this_section = SECTION_COURSES; @@ -89,11 +89,11 @@ $tpl->assign('agenda_actions', $actions); $tpl->assign('is_allowed_to_edit', api_is_allowed_to_edit()); if (api_is_allowed_to_edit()) { - if ($action === 'change_visibility') { + if ('change_visibility' === $action) { $courseInfo = api_get_course_info(); $courseCondition = ''; // This happens when list agenda is not inside a course - if (($type === 'course' || $type === 'session' && !empty($courseInfo))) { + if (('course' === $type || 'session' === $type && !empty($courseInfo))) { // For course and session event types // Just needs course ID $agenda->changeVisibility($_GET['id'], $_GET['visibility'], $courseInfo); diff --git a/public/main/calendar/download.php b/public/main/calendar/download.php index 3dfe8fdc35..a6fa1bf461 100644 --- a/public/main/calendar/download.php +++ b/public/main/calendar/download.php @@ -6,8 +6,6 @@ * Html files are parsed to fix a few problems with URLs, * but this code will hopefully be replaced soon by an Apache URL * rewrite mechanism. - * - * @package chamilo.calendar */ session_cache_limiter('public'); @@ -50,7 +48,7 @@ $full_file_name = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/upload/ca //if the rewrite rule asks for a directory, we redirect to the document explorer if (is_dir($full_file_name)) { - while ($doc_url[$dul = strlen($doc_url) - 1] == '/') { + while ('/' == $doc_url[$dul = strlen($doc_url) - 1]) { $doc_url = substr($doc_url, 0, $dul); } // create the path @@ -79,7 +77,7 @@ if (Database::num_rows($result)) { api_get_path(SYS_COURSE_PATH).$course_info['path'].'/upload/calendar/' )) { $result = DocumentManager::file_send_for_download($full_file_name, true, $title); - if ($result === false) { + if (false === $result) { api_not_allowed(true); } } diff --git a/public/main/course_description/add.php b/public/main/course_description/add.php index 472f05d7f9..c5a58b2edc 100644 --- a/public/main/course_description/add.php +++ b/public/main/course_description/add.php @@ -5,8 +5,6 @@ * View (MVC patter) for adding a course description. * * @author Christian Fasanando - * - * @package chamilo.course_description */ // protect a course script @@ -26,7 +24,7 @@ echo ''. ''; ksort($categories); foreach ($categories as $id => $title) { - if ($i == ADD_BLOCK) { + if (ADD_BLOCK == $i) { echo ''. Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).''; break; @@ -39,7 +37,7 @@ foreach ($categories as $id => $title) { echo '
'; // error messages -if (isset($error) && intval($error) == 1) { +if (isset($error) && 1 == intval($error)) { echo Display::return_message( get_lang('The form contains incorrect or incomplete data. Please check your input.'), 'error', diff --git a/public/main/course_description/course_description_controller.php b/public/main/course_description/course_description_controller.php index 66f8d1f7e7..f28df0e225 100644 --- a/public/main/course_description/course_description_controller.php +++ b/public/main/course_description/course_description_controller.php @@ -7,8 +7,6 @@ * it should be included inside a dispatcher file (e.g: index.php). * * @author Christian Fasanando - * - * @package chamilo.course_description */ class CourseDescriptionController { @@ -66,8 +64,8 @@ class CourseDescriptionController foreach ($data['descriptions'] as $id => $description) { if (!empty($description['content']) - && strpos($description['content'], ' $title) { - if ($i == ADD_BLOCK) { + if (ADD_BLOCK == $i) { $actionLeft .= ''. Display::return_icon( $data['default_description_icon'][$id], @@ -140,7 +138,7 @@ class CourseDescriptionController $data = []; $data['id'] = $id; $affected_rows = null; - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { + if ("POST" == strtoupper($_SERVER['REQUEST_METHOD'])) { if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) { if (1) { $title = $_POST['title']; @@ -251,7 +249,7 @@ class CourseDescriptionController $course_description->set_session_id($session_id); $data = []; - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { + if ("POST" == strtoupper($_SERVER['REQUEST_METHOD'])) { if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) { if (1) { $title = $_POST['title']; diff --git a/public/main/course_description/edit.php b/public/main/course_description/edit.php index aa6da33de2..40dd298eb9 100644 --- a/public/main/course_description/edit.php +++ b/public/main/course_description/edit.php @@ -5,8 +5,6 @@ * View (MVC patter) for editing a course description. * * @author Christian Fasanando - * - * @package chamilo.course_description */ // protect a course script @@ -45,7 +43,7 @@ echo ''. ksort($categories); foreach ($categories as $id => $title) { - if ($i == ADD_BLOCK) { + if (ADD_BLOCK == $i) { echo ''. Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).''; break; @@ -58,7 +56,7 @@ foreach ($categories as $id => $title) { echo '
'; // error messages -if (isset($error) && intval($error) == 1) { +if (isset($error) && 1 == intval($error)) { echo Display::return_message(get_lang('The form contains incorrect or incomplete data. Please check your input.'), 'error', false); } diff --git a/public/main/course_description/index.php b/public/main/course_description/index.php index b8e4673b9f..83ff56843e 100644 --- a/public/main/course_description/index.php +++ b/public/main/course_description/index.php @@ -6,8 +6,6 @@ * to the controllers depend on the current action. * * @author Christian Fasanando - * - * @package chamilo.course_description */ require_once __DIR__.'/../inc/global.inc.php'; $current_course_tool = TOOL_COURSE_DESCRIPTION; @@ -42,34 +40,34 @@ if (isset($_GET['id'])) { $id = intval($_GET['id']); } -if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') { +if (isset($_GET['isStudentView']) && 'true' == $_GET['isStudentView']) { $action = 'listing'; } // interbreadcrumb $interbreadcrumb[] = ["url" => "index.php?".api_get_cidreq(), "name" => get_lang('Description')]; -if ($description_type == 1) { +if (1 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Description')]; } -if ($description_type == 2) { +if (2 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Objectives')]; } -if ($description_type == 3) { +if (3 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Topics')]; } -if ($description_type == 4) { +if (4 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Methodology')]; } -if ($description_type == 5) { +if (5 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Course material')]; } -if ($description_type == 6) { +if (6 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Resources')]; } -if ($description_type == 7) { +if (7 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Assessment')]; } -if ($description_type == 8) { +if (8 == $description_type) { $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Thematic advance')]; } if ($description_type >= 9) { diff --git a/public/main/course_description/layout.php b/public/main/course_description/layout.php index 997b971d6c..acd6b76898 100644 --- a/public/main/course_description/layout.php +++ b/public/main/course_description/layout.php @@ -5,8 +5,6 @@ * Layout (principal view) used for structuring other views. * * @author Christian Fasanando - * - * @package chamilo.course_description */ // protect a course script diff --git a/public/main/course_info/delete_course.php b/public/main/course_info/delete_course.php index 554d9f42fd..beda829704 100644 --- a/public/main/course_info/delete_course.php +++ b/public/main/course_info/delete_course.php @@ -7,8 +7,6 @@ use ChamiloSession as Session; * This script is about deleting a course. * It displays a message box ('are you sure you wish to delete this course') * and deletes the course if the user answers affirmatively. - * - * @package chamilo.course_info */ require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_COURSES; @@ -26,7 +24,7 @@ if (!api_is_allowed_to_edit()) { $tool_name = get_lang('Completely delete this course'); -if (isset($_GET['delete']) && $_GET['delete'] === 'yes') { +if (isset($_GET['delete']) && 'yes' === $_GET['delete']) { CourseManager::delete_course($_course['sysCode']); // DELETE CONFIRMATION MESSAGE diff --git a/public/main/course_info/download.php b/public/main/course_info/download.php index 737d07ac0e..fa6f5a7c58 100644 --- a/public/main/course_info/download.php +++ b/public/main/course_info/download.php @@ -5,8 +5,6 @@ use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver; /** * Download script for course info. - * - * @package chamilo.course_info */ require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_COURSES; @@ -32,7 +30,7 @@ if (in_array($extension, ['xml', 'csv']) && (api_is_platform_admin(true) || api_is_drh()) ) { $content_type = 'application/force-download'; -} elseif ($extension === 'zip' && $_cid && (api_is_platform_admin(true) || api_is_course_admin())) { +} elseif ('zip' === $extension && $_cid && (api_is_platform_admin(true) || api_is_course_admin())) { $content_type = 'application/force-download'; } diff --git a/public/main/course_info/infocours.php b/public/main/course_info/infocours.php index 43e2a4c1d1..7a7b2f5d93 100644 --- a/public/main/course_info/infocours.php +++ b/public/main/course_info/infocours.php @@ -40,7 +40,7 @@ $router = Container::getRouter(); $translator = Container::getTranslator(); $show_delete_watermark_text_message = false; -if (api_get_setting('pdf_export_watermark_by_course') == 'true') { +if ('true' == api_get_setting('pdf_export_watermark_by_course')) { if (isset($_GET['delete_watermark'])) { PDF::delete_watermark($course_code); $show_delete_watermark_text_message = true; @@ -165,11 +165,11 @@ $form->addRule( ); $form->addElement('checkbox', 'delete_picture', null, get_lang('Delete picture')); -if (api_get_setting('pdf_export_watermark_by_course') == 'true') { +if ('true' == api_get_setting('pdf_export_watermark_by_course')) { $url = PDF::get_watermark($course_code); $form->addText('pdf_export_watermark_text', get_lang('PDF watermark text'), false, ['size' => '60']); $form->addElement('file', 'pdf_export_watermark_path', get_lang('Upload a watermark image')); - if ($url != false) { + if (false != $url) { $delete_url = ''.Display::return_icon('delete.png', get_lang('Remove picture')).''; $form->addElement( 'html', @@ -184,7 +184,7 @@ if (api_get_setting('pdf_export_watermark_by_course') == 'true') { ); } -if (api_get_setting('allow_course_theme') == 'true') { +if ('true' == api_get_setting('allow_course_theme')) { $group = []; $group[] = $form->createElement( 'SelectTheme', @@ -311,7 +311,7 @@ $form->addPanelOption( // Documents $globalGroup = []; -if (api_get_setting('documents_default_visibility_defined_in_course') == 'true') { +if ('true' == api_get_setting('documents_default_visibility_defined_in_course')) { $group = [ $form->createElement('radio', 'documents_default_visibility', null, get_lang('Visible'), 'visible'), $form->createElement('radio', 'documents_default_visibility', null, get_lang('invisible'), 'invisible'), @@ -610,7 +610,7 @@ $group[] = $form->createElement('radio', 'enable_lp_auto_launch', null, get_lang $globalGroup[get_lang('Enable learning path auto-launch')] = $group; -if (api_get_setting('allow_course_theme') == 'true') { +if ('true' == api_get_setting('allow_course_theme')) { // Allow theme into Learning path $group = []; $group[] = $form->createElement( @@ -632,7 +632,7 @@ if (api_get_setting('allow_course_theme') == 'true') { } $allowLPReturnLink = api_get_setting('allow_lp_return_link'); -if ($allowLPReturnLink === 'true') { +if ('true' === $allowLPReturnLink) { $group = [ $form->createElement( 'radio', @@ -662,8 +662,8 @@ if ($allowLPReturnLink === 'true') { $exerciseInvisible = api_get_setting('exercise_invisible_in_session'); $configureExerciseVisibility = api_get_setting('configure_exercise_visibility_in_course'); -if ($exerciseInvisible === 'true' && - $configureExerciseVisibility === 'true' +if ('true' === $exerciseInvisible && + 'true' === $configureExerciseVisibility ) { $group = [ $form->createElement( @@ -795,7 +795,7 @@ $form->addPanelOption( 'accordionSettings' ); -if (api_get_setting('allow_public_certificates') === 'true') { +if ('true' === api_get_setting('allow_public_certificates')) { $group = []; $group[] = $form->createElement( 'radio', @@ -926,7 +926,7 @@ $courseSettings = CourseManager::getCourseSettingVariables($appPlugin); foreach ($courseSettings as $setting) { $result = api_get_course_setting($setting); - if ($result != '-1') { + if ('-1' != $result) { $values[$setting] = $result; } } @@ -969,7 +969,7 @@ if ($form->validate() && $isEditable) { $courseInfo = api_get_course_info_by_id($courseId); // Check if - if ($courseInfo['visibility'] == COURSE_VISIBILITY_HIDDEN && + if (COURSE_VISIBILITY_HIDDEN == $courseInfo['visibility'] && $visibility != $courseInfo['visibility'] ) { $num = CourseManager::countActiveCourses($urlId); diff --git a/public/main/course_info/legal.php b/public/main/course_info/legal.php index eee5cfd5ff..88b750c3b2 100644 --- a/public/main/course_info/legal.php +++ b/public/main/course_info/legal.php @@ -23,7 +23,7 @@ $enabled = api_get_plugin_setting('courselegal', 'tool_enable'); $pluginExtra = null; $pluginLegal = false; -if ($enabled == 'true') { +if ('true' == $enabled) { $pluginLegal = true; require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php'; $plugin = CourseLegalPlugin::create(); @@ -54,7 +54,7 @@ $form = new FormValidator('legal', 'GET', api_get_self().'?course_code='.$course $pluginMessage = null; $hideForm = false; if ($pluginLegal && isset($userData) && !empty($userData)) { - if ($userData['web_agreement'] == 1) { + if (1 == $userData['web_agreement']) { if (empty($userData['mail_agreement'])) { $pluginMessage = Display::return_message( $plugin->get_lang('You need to confirm your agreement to our terms first. Please check your e-mail.') @@ -80,7 +80,7 @@ $url = api_get_course_url($course_code, $session_id); if ($form->validate()) { $accept_legal = $form->exportValue('accept_legal'); - if ($accept_legal == 1) { + if (1 == $accept_legal) { CourseManager::save_user_legal($user_id, $course_code, $session_id); if (api_check_user_access_to_legal($course_info['visibility'])) { Session::write($variable, true); @@ -140,7 +140,7 @@ if (empty($session_id)) { Display :: display_header(); echo $pluginMessage; -if ($hideForm == false) { +if (false == $hideForm) { $form->display(); } Display :: display_footer(); diff --git a/public/main/course_info/maintenance.php b/public/main/course_info/maintenance.php index 0f03471555..8a6b8e603b 100644 --- a/public/main/course_info/maintenance.php +++ b/public/main/course_info/maintenance.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * @author Created on 18 October 2006 by Elixir Interactive http://www.elixir-interactive.com - * - * @package chamilo.course_info */ require_once __DIR__.'/../inc/global.inc.php'; $current_course_tool = TOOL_COURSE_MAINTENANCE; diff --git a/public/main/course_info/maintenance_coach.php b/public/main/course_info/maintenance_coach.php index fd928dd352..032e30b15b 100644 --- a/public/main/course_info/maintenance_coach.php +++ b/public/main/course_info/maintenance_coach.php @@ -5,8 +5,6 @@ * * @author Julio Montoya * @author Angel Fernando Quiroz Campos - * - * @package chamilo.course_info */ require_once __DIR__.'/../inc/global.inc.php'; @@ -19,7 +17,7 @@ api_protect_course_script(true); api_block_anonymous_users(); $sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers'); -if ($sessionsCopy !== 'true') { +if ('true' !== $sessionsCopy) { api_not_allowed(true); } diff --git a/public/main/course_progress/index.php b/public/main/course_progress/index.php index 7e751e1620..cc1f66929b 100644 --- a/public/main/course_progress/index.php +++ b/public/main/course_progress/index.php @@ -8,8 +8,6 @@ use ChamiloSession as Session; * * @author Christian Fasanando * @author Julio Montoya Bugfixes session support - * - * @package chamilo.course_progress */ // including files @@ -55,15 +53,15 @@ if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], $actions)) { $action = $_REQUEST['action']; } -if (isset($_POST['action']) && $_POST['action'] == 'thematic_delete_select') { +if (isset($_POST['action']) && 'thematic_delete_select' == $_POST['action']) { $action = 'thematic_delete_select'; } -if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') { +if (isset($_GET['isStudentView']) && 'true' == $_GET['isStudentView']) { $action = 'thematic_details'; } -if ($action == 'thematic_details' || $action == 'thematic_list') { +if ('thematic_details' == $action || 'thematic_list' == $action) { Session::write('thematic_control', $action); } @@ -181,27 +179,27 @@ function check_per_custom_date(obj) { $thematicControl = Session::read('thematic_control'); -if ($action == 'thematic_list') { +if ('thematic_list' == $action) { $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Thematic control')]; } -if ($action == 'thematic_add') { +if ('thematic_add' == $action) { $interbreadcrumb[] = [ 'url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('Thematic control'), ]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('New thematic section')]; } -if ($action == 'thematic_edit') { +if ('thematic_edit' == $action) { $interbreadcrumb[] = [ 'url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('Thematic control'), ]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit thematic section')]; } -if ($action == 'thematic_details') { +if ('thematic_details' == $action) { $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Thematic control')]; } -if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') { +if ('thematic_plan_list' == $action || 'thematic_plan_delete' == $action) { $interbreadcrumb[] = [ 'url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('Thematic control'), @@ -213,7 +211,7 @@ if ($action == 'thematic_plan_list' || $action == 'thematic_plan_delete') { ]; } } -if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') { +if ('thematic_plan_add' == $action || 'thematic_plan_edit' == $action) { $interbreadcrumb[] = [ 'url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('Thematic control'), @@ -223,14 +221,14 @@ if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') { 'name' => get_lang('Thematic plan').' ('.$cleanThematicTitle.')', ]; } -if ($action == 'thematic_advance_list' || $action == 'thematic_advance_delete') { +if ('thematic_advance_list' == $action || 'thematic_advance_delete' == $action) { $interbreadcrumb[] = [ 'url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('Thematic control'), ]; $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Thematic advance').' ('.$cleanThematicTitle.')']; } -if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { +if ('thematic_advance_add' == $action || 'thematic_advance_edit' == $action) { $interbreadcrumb[] = [ 'url' => 'index.php?'.api_get_cidreq().'&action='.$thematicControl, 'name' => get_lang('Thematic control'), @@ -242,7 +240,7 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('NewThematic advance')]; } -if ($action == 'thematic_plan_list') { +if ('thematic_plan_list' == $action) { $htmlHeadXtra[] = " '; // If they are looking at group documents they can't see the root -if ($groupId != 0 && $curdirpath == '/') { +if (0 != $groupId && '/' == $curdirpath) { $curdirpath = $group_properties['directory']; $curdirpathurl = urlencode($group_properties['directory']); } @@ -838,7 +838,7 @@ if ($groupId != 0 && $curdirpath == '/') { //if (!$isAllowedToEdit || api_is_coach()) { before if (!$isAllowedToEdit && api_is_coach()) { - if ($curdirpath != '/' && + if ('/' != $curdirpath && !(DocumentManager::is_visible($curdirpath, $courseInfo, $sessionId, 'folder')) ) { api_not_allowed(true); @@ -854,7 +854,7 @@ if ($is_certificate_mode) { 'name' => get_lang('Assessments'), ]; } else { - if ((isset($_GET['id']) && $_GET['id'] != 0) || isset($_GET['curdirpath']) || isset($_GET['createdir'])) { + if ((isset($_GET['id']) && 0 != $_GET['id']) || isset($_GET['curdirpath']) || isset($_GET['createdir'])) { $interbreadcrumb[] = [ 'url' => 'document.php?'.api_get_cidreq(), 'name' => get_lang('Documents'), @@ -876,7 +876,7 @@ if (empty($document_data['parents'])) { ]; } else { // Hack in order to not add the document to the breadcrumb in case it is a link - if ($document_data['filetype'] != 'link') { + if ('link' != $document_data['filetype']) { $interbreadcrumb[] = [ 'url' => '#', 'name' => $document_data['title'], @@ -888,7 +888,7 @@ if (empty($document_data['parents'])) { foreach ($document_data['parents'] as $document_sub_data) { //fixing double group folder in breadcrumb if ($groupId) { - if ($counter == 0) { + if (0 == $counter) { $counter++; continue; } @@ -922,7 +922,7 @@ $jquery = null; if (!empty($documentAndFolders)) { foreach ($documentAndFolders as $file) { - if ($file['filetype'] == 'file') { + if ('file' == $file['filetype']) { $path_info = pathinfo($file['path']); $extension = ''; if (!empty($path_info['extension'])) { @@ -938,7 +938,7 @@ if (!empty($documentAndFolders)) { false, $sessionId ); - if ($sessionId != 0 && !$document_data) { + if (0 != $sessionId && !$document_data) { /* If there is a session defined and asking for the document * from the session* didn't work, try it from the course (out of a session context) */ @@ -950,7 +950,7 @@ if (!empty($documentAndFolders)) { ); } - if ($extension == 'ogg') { + if ('ogg' == $extension) { $extension = 'oga'; } @@ -979,7 +979,7 @@ $htmlHeadXtra[] = ' Event::event_access_tool(TOOL_DOCUMENT); /* DISPLAY */ -if ($groupId != 0) { // Add group name after for group documents +if (0 != $groupId) { // Add group name after for group documents $add_group_to_title = ' ('.$group_properties['name'].')'; } $moveForm = ''; @@ -989,7 +989,7 @@ if ($isAllowedToEdit || $groupMemberWithUploadRights || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) || DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId) ) { - if (isset($_GET['move']) && $_GET['move'] != '') { + if (isset($_GET['move']) && '' != $_GET['move']) { $my_get_move = intval($_REQUEST['move']); if (api_is_coach()) { @@ -1095,7 +1095,7 @@ if ($isAllowedToEdit || $groupMemberWithUploadRights || // Security fix: make sure they can't move files that are not in the document table if (!empty($document_to_move)) { - if ($document_to_move['filetype'] === 'link') { + if ('link' === $document_to_move['filetype']) { if (!DocumentManager::cloudLinkExists($_course, $moveTo, $document_to_move['comment'])) { DocumentManager::updateDbInfo( 'update', @@ -1121,7 +1121,7 @@ if ($isAllowedToEdit || $groupMemberWithUploadRights || $curdirpath = $moveTo; $curdirpathurl = urlencode($moveTo); } else { - if ($moveTo === '/') { + if ('/' === $moveTo) { // Move to course root $newParent = api_get_course_entity(); } else { @@ -1220,7 +1220,7 @@ if ($isAllowedToEdit || } $readonlyAlreadyChecked = true; } - if ($data['filetype'] != 'link') { + if ('link' != $data['filetype']) { // Files and folders $deleteDocument = DocumentManager::delete_document( $courseInfo, @@ -1269,10 +1269,10 @@ if ($isAllowedToEdit || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) ) { // Create directory with $_POST data - if (isset($_POST['create_dir']) && $_POST['dirname'] != '') { + if (isset($_POST['create_dir']) && '' != $_POST['dirname']) { // Needed for directory creation $post_dir_name = $_POST['dirname']; - if ($post_dir_name == '../' || $post_dir_name == '.' || $post_dir_name == '..') { + if ('../' == $post_dir_name || '.' == $post_dir_name || '..' == $post_dir_name) { $message = Display::return_message(get_lang('CannotCreate folder'), 'error'); } else { // dir_id is the parent folder id. @@ -1284,7 +1284,7 @@ if ($isAllowedToEdit || false, $sessionId ); - if ($sessionId != 0 && !$document_data) { + if (0 != $sessionId && !$document_data) { // If there is a session defined and asking for the // document * from the session* didn't work, try it from // the course (out of a session context) @@ -1297,7 +1297,7 @@ if ($isAllowedToEdit || } $curdirpath = $document_data['path']; } - $added_slash = $curdirpath == '/' ? '' : '/'; + $added_slash = '/' == $curdirpath ? '' : '/'; $dir_name = $curdirpath.$added_slash.api_replace_dangerous_char($post_dir_name); $dir_name = disable_dangerous_file($dir_name); $visibility = empty($groupId) ? null : 1; @@ -1449,7 +1449,7 @@ if ($isAllowedToEdit || // END ACTION MENU // Attach certificate in the gradebook if (isset($_GET['curdirpath']) && - strpos($_GET['curdirpath'], '/certificates') !== false && + false !== strpos($_GET['curdirpath'], '/certificates') && isset($_GET['set_certificate']) && $_GET['set_certificate'] == strval(intval($_GET['set_certificate'])) ) { @@ -1486,7 +1486,7 @@ if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { ); } -if ($groupId != 0) { +if (0 != $groupId) { $userAccess = GroupManager::user_has_access( api_get_user_id(), $groupIid, @@ -1511,13 +1511,13 @@ if ($groupId != 0) { ); } -if (!isset($folders) || $folders === false) { +if (!isset($folders) || false === $folders) { $folders = []; } $btngroup = ['class' => 'btn btn-default']; /* GO TO PARENT DIRECTORY */ $actionsLeft = ''; -if ($curdirpath != '/' && +if ('/' != $curdirpath && $curdirpath != $group_properties['directory'] && !$is_certificate_mode ) { @@ -1526,7 +1526,7 @@ if ($curdirpath != '/' && $actionsLeft .= ''; } -if ($is_certificate_mode && $curdirpath != '/certificates') { +if ($is_certificate_mode && '/certificates' != $curdirpath) { $actionsLeft .= Display::url( Display::return_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM), api_get_self().'?'.api_get_cidreq().'&id='.$parent_id.$certificateLink @@ -1555,7 +1555,7 @@ if ($isAllowedToEdit || ); // Create new draw - if (api_get_setting('enabled_support_svg') == 'true') { + if ('true' == api_get_setting('enabled_support_svg')) { if (api_browser_support('svg')) { $actionsLeft .= Display::url( Display::return_icon('new_draw.png', get_lang('Draw'), '', ICON_SIZE_MEDIUM), @@ -1572,7 +1572,7 @@ if ($isAllowedToEdit || } // Create new paint - if (api_get_setting('enabled_support_pixlr') == 'true') { + if ('true' == api_get_setting('enabled_support_pixlr')) { $actionsLeft .= Display::url( Display::return_icon( 'new_paint.png', @@ -1586,7 +1586,7 @@ if ($isAllowedToEdit || } // Record an image clip from my webcam - if (api_get_setting('enable_webcam_clip') == 'true') { + if ('true' == api_get_setting('enable_webcam_clip')) { $actionsLeft .= Display::url( Display::return_icon('webcam.png', get_lang('Webcam Clip'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'document/webcam_clip.php?'.api_get_cidreq().'&id='.$document_id @@ -1594,7 +1594,7 @@ if ($isAllowedToEdit || } // Record audio (nanogong) - if (api_get_setting('enable_record_audio') === 'true') { + if ('true' === api_get_setting('enable_record_audio')) { $actionsLeft .= Display::url( Display::return_icon('new_recording.png', get_lang('Record my voice'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'document/record_audio.php?'.api_get_cidreq().'&id='.$document_id @@ -1602,7 +1602,7 @@ if ($isAllowedToEdit || } // Create new audio from text - if (api_get_setting('enabled_text2audio') == 'true') { + if ('true' == api_get_setting('enabled_text2audio')) { $actionsLeft .= Display::url( Display::return_icon('new_sound.png', get_lang('Create audio'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'document/create_audio.php?'.api_get_cidreq().'&id='.$document_id @@ -1699,7 +1699,7 @@ $total_size = 0; $getSizeURL = api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=get_dir_size&'.api_get_cidreq(); $sortable_data = []; -if (!empty($documentAndFolders) && ($groupId === 0 || $userAccess)) { +if (!empty($documentAndFolders) && (0 === $groupId || $userAccess)) { $sortable_data = DocumentManager::processDocumentAndFolders( $documentAndFolders, $courseInfo, @@ -1712,14 +1712,14 @@ if (!empty($documentAndFolders) && ($groupId === 0 || $userAccess)) { if (!empty($documentAndFolders)) { // Show download zipped folder icon if (!$is_certificate_mode && ( - api_get_setting('students_download_folders') == 'true' || + 'true' == api_get_setting('students_download_folders') || $isAllowedToEdit || api_is_platform_admin() ) ) { //for student does not show icon into other shared folder, and does not show into main path (root) if (DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) && - $curdirpath != '/' || + '/' != $curdirpath || $isAllowedToEdit || api_is_platform_admin() ) { @@ -1749,7 +1749,7 @@ if (!empty($moveTo)) { $document_id = DocumentManager::get_document_id($courseInfo, $moveTo); } -if (isset($_GET['createdir']) && isset($_POST['dirname']) && $_POST['dirname'] != '') { +if (isset($_GET['createdir']) && isset($_POST['dirname']) && '' != $_POST['dirname']) { $post_dir_name = $_POST['dirname']; $document_id = DocumentManager::get_document_id($courseInfo, $_POST['dirname']); } @@ -1785,12 +1785,12 @@ if (!empty($documentAndFolders) && !empty($sortable_data)) { $column_show[] = 0; $column_order = []; - if (count(reset($sortable_data)) == 12) { + if (12 == count(reset($sortable_data))) { //teacher $column_order[2] = 8; //name $column_order[3] = 7; $column_order[4] = 6; - } elseif (count(reset($sortable_data)) == 10) { + } elseif (10 == count(reset($sortable_data))) { //student $column_order[1] = 6; $column_order[2] = 5; diff --git a/public/main/document/document_quota.php b/public/main/document/document_quota.php index f89f10df49..e2a7086a46 100644 --- a/public/main/document/document_quota.php +++ b/public/main/document/document_quota.php @@ -3,8 +3,6 @@ /** * Document quota management script. - * - * @package chamilo.document */ use Chamilo\CoreBundle\Framework\Container; @@ -90,11 +88,11 @@ if (!empty($group_list)) { $document_list = DocumentManager::getAllDocumentData(api_get_course_info()); if (!empty($document_list)) { foreach ($document_list as $document_data) { - if ($document_data['creator_id'] == api_get_user_id() && $document_data['filetype'] === 'file') { + if ($document_data['creator_id'] == api_get_user_id() && 'file' === $document_data['filetype']) { $quota_bytes += $document_data['size']; } } - if ($quota_bytes != 0) { + if (0 != $quota_bytes) { $quotaPercentage = round($quota_bytes / $total_quota_bytes, 2) * 100; } @@ -103,7 +101,7 @@ if (!empty($document_list)) { $quotaPercentage, ]; //if a sesson is active - if ($sessionId != 0) { + if (0 != $sessionId) { if (!empty($course_list)) { $total_courses_quota = 0; $total_quota_bytes = 0; @@ -112,7 +110,7 @@ if (!empty($document_list)) { $total_quota_bytes += DocumentManager::get_course_quota($course_data['id']); } } - if ($quota_bytes != 0) { + if (0 != $quota_bytes) { $quotaPercentage = round($quota_bytes / $total_quota_bytes, 2) * 100; } } diff --git a/public/main/document/document_slideshow.inc.php b/public/main/document/document_slideshow.inc.php index d4edbf770d..47ae1b92f5 100644 --- a/public/main/document/document_slideshow.inc.php +++ b/public/main/document/document_slideshow.inc.php @@ -17,8 +17,6 @@ * * @author Patrick Cool, responsible author * @author Roan Embrechts, minor cleanup - * - * @package chamilo.document */ /** * General code that belongs in document.php. @@ -53,7 +51,7 @@ if (isset($all_files) && is_array($all_files) && count($all_files) > 0) { }*/ $tablename_column = isset($_GET['tablename_column']) ? Security::remove_XSS($_GET['tablename_column']) : 0; -if ($tablename_column == 0) { +if (0 == $tablename_column) { $tablename_column = 1; } else { $tablename_column = intval($tablename_column) - 1; @@ -68,7 +66,7 @@ function sort_files($table) $temp = []; foreach ($table as &$file_array) { - if ($file_array['filetype'] == 'file') { + if ('file' == $file_array['filetype']) { $slideshow_extension = strrchr($file_array['path'], '.'); $slideshow_extension = strtolower($slideshow_extension); if (in_array($slideshow_extension, $accepted_extensions)) { @@ -78,7 +76,7 @@ function sort_files($table) } } - if ($tablename_direction == 'DESC') { + if ('DESC' == $tablename_direction) { usort($temp, 'rsort_table'); } else { usort($temp, 'sort_table'); diff --git a/public/main/document/download_scorm.php b/public/main/document/download_scorm.php index f5ae5fd6bf..37023632d3 100644 --- a/public/main/document/download_scorm.php +++ b/public/main/document/download_scorm.php @@ -5,8 +5,6 @@ use ChamiloSession as Session; /** * This file is responsible for passing requested documents to the browser. - * - * @package chamilo.document */ session_cache_limiter('none'); @@ -57,7 +55,7 @@ if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) { $fixLinks = api_get_configuration_value('lp_replace_http_to_https'); $result = DocumentManager::file_send_for_download($full_file_name, false, '', $fixLinks); - if ($result === false) { + if (false === $result) { api_not_allowed(true, get_lang('The file was not found'), 404); } } else { diff --git a/public/main/document/download_uploaded_files.php b/public/main/document/download_uploaded_files.php index 7bb24eb2e3..58f44bf661 100644 --- a/public/main/document/download_uploaded_files.php +++ b/public/main/document/download_uploaded_files.php @@ -29,7 +29,7 @@ if (!is_dir($toolPath)) { if (Security::check_abs_path($toolPath.$file, $toolPath.'/')) { $fullFilePath = $toolPath.$file; $result = DocumentManager::file_send_for_download($fullFilePath, false, ''); - if ($result === false) { + if (false === $result) { api_not_allowed(true); } } diff --git a/public/main/document/downloadfolder.inc.php b/public/main/document/downloadfolder.inc.php index 0a449b8aff..f243a7c41d 100644 --- a/public/main/document/downloadfolder.inc.php +++ b/public/main/document/downloadfolder.inc.php @@ -7,8 +7,6 @@ use ChamiloSession as Session; /** * Functions and main code for the download folder feature. - * - * @package chamilo.document */ set_time_limit(0); @@ -52,7 +50,7 @@ if (empty($path)) { } // A student should not be able to download a root shared directory -if (($path == '/shared_folder' || +if (('/shared_folder' == $path || $path == '/shared_folder_session_'.api_get_session_id()) && (!api_is_allowed_to_edit() || !api_is_platform_admin()) ) { @@ -62,14 +60,14 @@ if (($path == '/shared_folder' || // Creating a ZIP file. $tempZipFile = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip"; -$name = ($path == '/') ? 'documents.zip' : $documentInfo['title'].'.zip'; +$name = ('/' == $path) ? 'documents.zip' : $documentInfo['title'].'.zip'; $zip = api_create_zip($name); $doc_table = Database::get_course_table(TABLE_DOCUMENT); $prop_table = Database::get_course_table(TABLE_ITEM_PROPERTY); // We need this path to clean it out of the zip file // I'm not using dir name as it gives too much problems (cfr.) -$remove_dir = ($path != '/') ? substr($path, 0, strlen($path) - strlen(basename($path))) : '/'; +$remove_dir = ('/' != $path) ? substr($path, 0, strlen($path) - strlen(basename($path))) : '/'; // Put the files in the zip // 2 possibilities: Admins get all files and folders in the selected folder (except for the deleted ones) @@ -101,9 +99,9 @@ function fixDocumentNameCallback($p_event, &$p_header) $documentNameFixed ); - if ($remove_dir != '/') { + if ('/' != $remove_dir) { $documentNameFixed = str_replace($remove_dir, '/', $documentNameFixed); - if (substr($documentNameFixed, 0, 1) == '/') { + if ('/' == substr($documentNameFixed, 0, 1)) { $documentNameFixed = substr($documentNameFixed, 1, api_strlen($documentNameFixed)); } } else { @@ -131,7 +129,7 @@ Event::event_download($name); // Admins are allowed to download invisible files if (api_is_allowed_to_edit()) { // Set the path that will be used in the query - if ($path === '/') { + if ('/' === $path) { $querypath = ''; // To prevent ...path LIKE '//%'... in query } else { $querypath = $path; @@ -192,7 +190,7 @@ if (api_is_allowed_to_edit()) { $zip->finish(); } else { // For other users, we need to create a zip file with only visible files and folders - if ($path == '/') { + if ('/' == $path) { $querypath = ''; // To prevent ...path LIKE '//%'... in query } else { $querypath = $path; diff --git a/public/main/document/edit_document.php b/public/main/document/edit_document.php index 74c2933b49..3202b89739 100644 --- a/public/main/document/edit_document.php +++ b/public/main/document/edit_document.php @@ -24,8 +24,6 @@ use ChamiloSession as Session; * database, regardless of wether they are visible/invisible, have * comments or not. * - * @package chamilo.document - * * @todo improve script structure (FormValidator is used to display form, but * not for validation at the moment) */ @@ -244,7 +242,7 @@ if (isset($_POST['comment'])) { if (!empty($document_id)) { $linkExists = false; - if ($file_type == 'link') { + if ('link' == $file_type) { $linkExists = DocumentManager::cloudLinkExists($course_info, $file, $_POST['comment']); } @@ -256,7 +254,7 @@ if (isset($_POST['comment'])) { $em->persist($document); $em->flush(); - if ($file_type != 'link') { + if ('link' != $file_type) { Display::addFlash(Display::return_message(get_lang('Update successful'))); } else { Display::addFlash(Display::return_message(get_lang('Cloud file link updated.'))); @@ -268,17 +266,17 @@ if (isset($_POST['comment'])) { } if ($is_allowed_to_edit) { - if (isset($_POST['formSent']) && $_POST['formSent'] == 1 && !empty($document_id)) { + if (isset($_POST['formSent']) && 1 == $_POST['formSent'] && !empty($document_id)) { $content = isset($_POST['content']) ? trim(str_replace(["\r", "\n"], '', stripslashes($_POST['content']))) : null; $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY); - if ($dir == '/') { + if ('/' == $dir) { $dir = ''; } $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; $read_only_flag = empty($read_only_flag) ? 0 : 1; - if ($read_only_flag == 0 && !empty($content)) { + if (0 == $read_only_flag && !empty($content)) { $documentRepository->updateDocumentContent($document, $content); } @@ -339,7 +337,7 @@ if ($owner_id == api_get_user_id() || // Form title $form->addHeader($nameTools); - $key_label_title = $file_type != 'link' ? 'Title' : 'LinkName'; + $key_label_title = 'link' != $file_type ? 'Title' : 'LinkName'; $form->addText( 'title', get_lang($key_label_title), @@ -356,13 +354,13 @@ if ($owner_id == api_get_user_id() || // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved. $showSystemFolders = api_get_course_setting('show_system_folders'); - $condition = stripos($dir, '/HotPotatoes_files') === false; - if ($showSystemFolders == 1) { + $condition = false === stripos($dir, '/HotPotatoes_files'); + if (1 == $showSystemFolders) { $condition = true; } - if (($extension == 'htm' || $extension == 'html') && $condition) { - if (empty($readonly) && $readonly == 0) { + if (('htm' == $extension || 'html' == $extension) && $condition) { + if (empty($readonly) && 0 == $readonly) { $form->addHtmlEditor('content', get_lang('Content'), true, true, $editorConfig); } } @@ -371,7 +369,7 @@ if ($owner_id == api_get_user_id() || $form->addLabel(get_lang('Created on'), Display::dateToStringAgoAndLongDate($createdDate)); } - if ($file_type != 'link') { + if ('link' != $file_type) { if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) { $form->addLabel(get_lang('Update successfulOn'), Display::dateToStringAgoAndLongDate($last_edit_date)); } @@ -384,7 +382,7 @@ if ($owner_id == api_get_user_id() || } } - if ($file_type == 'link') { + if ('link' == $file_type) { // URLs in whitelist $urlWL = DocumentManager::getFileHostingWhiteList(); sort($urlWL); @@ -405,16 +403,16 @@ if ($owner_id == api_get_user_id() || $form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]); } - if ($file_type != 'link') { + if ('link' != $file_type) { if ($owner_id == api_get_user_id() || api_is_platform_admin()) { $checked = &$form->addElement('checkbox', 'readonly', null, get_lang('Read only')); - if ($readonly == 1) { + if (1 == $readonly) { $checked->setChecked(true); } } } - if ($file_type == 'link') { + if ('link' == $file_type) { $form->addRule('title', get_lang('Please enter a name for this Cloud link'), 'required'); $form->addRule('comment', get_lang('Please enter the URL'), 'required'); // Well formed url pattern (must have the protocol) @@ -427,7 +425,7 @@ if ($owner_id == api_get_user_id() || if ($is_certificate_mode) { $form->addButtonUpdate(get_lang('Save certificate')); - } elseif ($file_type == 'link') { + } elseif ('link' == $file_type) { $form->addButtonUpdate(get_lang('Save link')); } else { $form->addButtonUpdate(get_lang('Save document')); @@ -470,12 +468,12 @@ if ($owner_id == api_get_user_id() || ); } - if ($extension == 'svg' && !api_browser_support('svg') && - api_get_setting('enabled_support_svg') == 'true' + if ('svg' == $extension && !api_browser_support('svg') && + 'true' == api_get_setting('enabled_support_svg') ) { echo Display::return_message(get_lang('Your browser does not support SVG files. To use the drawing tool you must have an advanced browser such as Firefox or Chrome'), 'warning'); } - if ($file_type != 'link') { + if ('link' != $file_type) { // HTML-editor echo '
@@ -523,20 +521,20 @@ function show_return($document_id, $path, $call_from_tool = '', $slide_id = 0, $ $actionsLeft .= ''. Display::return_icon('back.png', get_lang('Back').' '.get_lang('To').' '.get_lang('Certificate overview'), '', ICON_SIZE_MEDIUM).''; $actionsLeft .= ''.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).''; - } elseif ($call_from_tool == 'slideshow') { + } elseif ('slideshow' == $call_from_tool) { /*$actionsLeft .= ''. Display::return_icon('slideshow.png', get_lang('Back to').' '.get_lang('View Slideshow'), '', ICON_SIZE_MEDIUM).''; */ - } elseif ($call_from_tool == 'editdraw') { + } elseif ('editdraw' == $call_from_tool) { $actionsLeft .= ''. Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Documents overview'), '', ICON_SIZE_MEDIUM).''; $actionsLeft .= ''.Display::return_icon('draw.png', get_lang('Back to').' '.get_lang('Draw'), [], 32).''; - } elseif ($call_from_tool == 'editodf') { + } elseif ('editodf' == $call_from_tool) { $actionsLeft .= ''. Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Documents overview'), '', ICON_SIZE_MEDIUM).''; $actionsLeft .= ''.Display::return_icon('draw.png', get_lang('Back to').' '.get_lang('Write'), [], 32).''; $actionsLeft .= ''.Display::return_icon('expand.png', get_lang('Expand'), ['id' => 'expand'], ICON_SIZE_MEDIUM).Display::return_icon('contract.png', get_lang('Collapse'), ['id' => 'contract', 'class' => 'hide'], ICON_SIZE_MEDIUM).''; - } elseif ($call_from_tool == 'editpaint' && api_get_setting('enabled_support_pixlr') === 'true') { + } elseif ('editpaint' == $call_from_tool && 'true' === api_get_setting('enabled_support_pixlr')) { $actionsLeft .= ''. Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Documents overview'), [], ICON_SIZE_MEDIUM).''; $actionsLeft .= ''.Display::return_icon('paint.png', get_lang('Back to').' '.get_lang('Paint'), [], 32).''; diff --git a/public/main/document/edit_draw.php b/public/main/document/edit_draw.php index 7d9f682b9a..000bcc6f8c 100644 --- a/public/main/document/edit_draw.php +++ b/public/main/document/edit_draw.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * This file allows creating new svg and png documents with an online editor. * - * @package chamilo.document - * * @author Juan Carlos Ra�a Trabado * * @since 25/september/2010 @@ -45,7 +43,7 @@ $group_id = api_get_group_id(); //path for svg-edit save Session::write('draw_dir', Security::remove_XSS($dir)); -if ($dir == '/') { +if ('/' == $dir) { Session::write('draw_dir', ''); } Session::write('draw_file', basename(Security::remove_XSS($file_path))); @@ -65,15 +63,15 @@ if (strstr($dir, '..')) { $dir = '/'; } -if ($dir[0] == '.') { +if ('.' == $dir[0]) { $dir = substr($dir, 1); } -if ($dir[0] != '/') { +if ('/' != $dir[0]) { $dir = '/'.$dir; } -if ($dir[strlen($dir) - 1] != '/') { +if ('/' != $dir[strlen($dir) - 1]) { $dir .= '/'; } diff --git a/public/main/document/edit_odf.php b/public/main/document/edit_odf.php index 75fe56e84b..6c1802857d 100644 --- a/public/main/document/edit_odf.php +++ b/public/main/document/edit_odf.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * ODF document editor script. - * - * @package chamilo.document */ require_once __DIR__.'/../inc/global.inc.php'; @@ -43,7 +41,7 @@ $showOdfEditor = false; $webOdfSupportedFiles = DocumentManager::get_web_odf_extension_list(); if (in_array(strtolower($pathinfo['extension']), $webOdfSupportedFiles) && - api_get_configuration_value('enabled_support_odf') === true + true === api_get_configuration_value('enabled_support_odf') ) { $showOdfEditor = true; } diff --git a/public/main/document/edit_paint.php b/public/main/document/edit_paint.php index cf1a4b7997..d67160c268 100644 --- a/public/main/document/edit_paint.php +++ b/public/main/document/edit_paint.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * This file allows creating new svg and png documents with an online editor. * - * @package chamilo.document - * * @todo used the document_id instead of the curdirpath * * @author Juan Carlos Raña Trabado @@ -63,15 +61,15 @@ if (strstr($dir, '..')) { $dir = '/'; } -if ($dir[0] == '.') { +if ('.' == $dir[0]) { $dir = substr($dir, 1); } -if ($dir[0] != '/') { +if ('/' != $dir[0]) { $dir = '/'.$dir; } -if ($dir[strlen($dir) - 1] != '/') { +if ('/' != $dir[strlen($dir) - 1]) { $dir .= '/'; } @@ -148,7 +146,7 @@ $target = $target_path; $locktarget = "true"; $locktitle = "false"; -if ($_SERVER['HTTP_HOST'] == "localhost") { +if ("localhost" == $_SERVER['HTTP_HOST']) { $path_and_file = api_get_path(SYS_PATH).'/crossdomain.xml'; if (!file_exists($path_and_file)) { $crossdomain = ' diff --git a/public/main/document/exit_pixlr.php b/public/main/document/exit_pixlr.php index ff6f7a1dab..449314be29 100644 --- a/public/main/document/exit_pixlr.php +++ b/public/main/document/exit_pixlr.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * This file allows creating new svg and png documents with an online editor. * - * @package chamilo.document - * * @author Juan Carlos Ra�a Trabado * * @since 30/january/2011 diff --git a/public/main/document/record_audio.php b/public/main/document/record_audio.php index 2c645512cf..2c1726ca04 100644 --- a/public/main/document/record_audio.php +++ b/public/main/document/record_audio.php @@ -5,8 +5,6 @@ use ChamiloSession as Session; /** * This file allows record audio files. - * - * @package chamilo.document */ require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_COURSES; @@ -43,7 +41,7 @@ $dir = $document_data['path']; //make some vars $wamidir = $dir; -if ($wamidir == "/") { +if ("/" == $wamidir) { $wamidir = ''; } $wamiurlplay = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$wamidir."/"; @@ -56,15 +54,15 @@ if (strstr($dir, '..')) { $dir = '/'; } -if ($dir[0] == '.') { +if ('.' == $dir[0]) { $dir = substr($dir, 1); } -if ($dir[0] != '/') { +if ('/' != $dir[0]) { $dir = '/'.$dir; } -if ($dir[strlen($dir) - 1] != '/') { +if ('/' != $dir[strlen($dir) - 1]) { $dir .= '/'; } @@ -117,7 +115,7 @@ if (isset($document_data['parents'])) { foreach ($document_data['parents'] as $document_sub_data) { //fixing double group folder in breadcrumb if (api_get_group_id()) { - if ($counter == 0) { + if (0 == $counter) { $counter++; continue; } diff --git a/public/main/document/save_pixlr.php b/public/main/document/save_pixlr.php index 4fba030414..fef375c6ac 100644 --- a/public/main/document/save_pixlr.php +++ b/public/main/document/save_pixlr.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * This file allows creating new svg and png documents with an online editor. * - * @package chamilo.document - * * @author Juan Carlos Raña Trabado * * @since 30/january/2011 @@ -74,23 +72,23 @@ $filename = Security::remove_XSS($filename); $filename = api_replace_dangerous_char($filename); $filename = disable_dangerous_file($filename); -if (strlen(trim($filename)) == 0) { +if (0 == strlen(trim($filename))) { echo "The title is empty"; //if title is empty, headers Content-Type = application/octet-stream, // then not create a new title here please exit; } //check file_get_contents -if ($contents === false) { +if (false === $contents) { echo "I cannot read: ".$urlcontents; exit; } // Extension security -if ($extension != 'jpg' && $extension != 'png' && $extension != 'pxd') { +if ('jpg' != $extension && 'png' != $extension && 'pxd' != $extension) { die(); } -if ($extension == 'pxd') { +if ('pxd' == $extension) { echo "pxd file type does not supported"; // not secure because check security headers and finfo() return Content-Type = application/octet-stream exit; @@ -99,7 +97,7 @@ if ($extension == 'pxd') { //Verify that the file is an image. Headers method $headers = get_headers($urlcontents, 1); $content_type = explode("/", $headers['Content-Type']); -if ($content_type[0] != "image") { +if ("image" != $content_type[0]) { echo "Invalid file type"; exit; } @@ -108,7 +106,7 @@ if ($content_type[0] != "image") { $finfo = new finfo(FILEINFO_MIME); $current_mime = $finfo->buffer($contents); -if (strpos($current_mime, 'image') === false) { +if (false === strpos($current_mime, 'image')) { echo "Invalid mime type file"; exit; } diff --git a/public/main/document/show_content.php b/public/main/document/show_content.php index 41c11b5478..1df8e13a59 100644 --- a/public/main/document/show_content.php +++ b/public/main/document/show_content.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * @author jmontoya - * - * @package chamilo.document */ require_once __DIR__.'/../inc/global.inc.php'; @@ -33,7 +31,7 @@ $document_data = DocumentManager::get_document_data_by_id( $session_id ); -if ($session_id != 0 && !$document_data) { +if (0 != $session_id && !$document_data) { $document_data = DocumentManager::get_document_data_by_id( $document_id, $course_code, @@ -78,7 +76,7 @@ if (is_dir($file_url_sys)) { //fix the screen when you try to access a protected course through the url $is_allowed_in_course = api_is_allowed_in_course(); -if ($is_allowed_in_course == false) { +if (false == $is_allowed_in_course) { api_not_allowed(true); } @@ -107,7 +105,7 @@ $browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' $file_url_web = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$header_file.'?'.api_get_cidreq(); $pathinfo = pathinfo($header_file); -if ($pathinfo['extension'] == 'swf') { +if ('swf' == $pathinfo['extension']) { $width = '83%'; $height = '83%'; } else { diff --git a/public/main/document/showinframes.php b/public/main/document/showinframes.php index d9c9a1f49b..674b598311 100644 --- a/public/main/document/showinframes.php +++ b/public/main/document/showinframes.php @@ -19,8 +19,6 @@ * @version 0.6 * * @author Roan Embrechts (roan.embrechts@vub.ac.be) - * - * @package chamilo.document */ require_once __DIR__.'/../inc/global.inc.php'; @@ -28,7 +26,7 @@ api_protect_course_script(); $header_file = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null; $document_id = (int) $_GET['id']; -$originIsLearnpath = isset($_GET['origin']) && $_GET['origin'] === 'learnpathitem'; +$originIsLearnpath = isset($_GET['origin']) && 'learnpathitem' === $_GET['origin']; $courseInfo = api_get_course_info(); $course_code = api_get_course_id(); $session_id = api_get_session_id(); @@ -50,7 +48,7 @@ $document_data = DocumentManager::get_document_data_by_id( $session_id ); -if ($session_id != 0 && !$document_data) { +if (0 != $session_id && !$document_data) { $document_data = DocumentManager::get_document_data_by_id( $document_id, $course_code, @@ -76,7 +74,7 @@ $file_url_web = api_get_path(WEB_COURSE_PATH).$file_root; $is_allowed_to_edit = api_is_allowed_to_edit(); //fix the screen when you try to access a protected course through the url $is_allowed_in_course = api_is_allowed_in_course() || $is_allowed_to_edit; -if ($is_allowed_in_course == false) { +if (false == $is_allowed_in_course) { api_not_allowed(true); } @@ -105,7 +103,7 @@ $group_id = api_get_group_id(); $current_group = GroupManager::get_group_properties($group_id); $current_group_name = $current_group['name']; -if (isset($group_id) && $group_id != '') { +if (isset($group_id) && '' != $group_id) { $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'), @@ -191,7 +189,7 @@ if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) { $isChatFolder = false; if (isset($document_data['parents']) && isset($document_data['parents'][0])) { $chatFolder = $document_data['parents'][0]; - if (isset($chatFolder['path']) && $chatFolder['path'] == '/chat_files') { + if (isset($chatFolder['path']) && '/chat_files' == $chatFolder['path']) { $isChatFolder = true; } } @@ -250,7 +248,7 @@ if ($show_web_odf) { echo '
'; $browser = api_get_navigator(); $pdfUrl = api_get_path(WEB_LIBRARY_PATH).'javascript/ViewerJS/index.html#'.$file_url; - if ($browser['name'] == 'Mozilla' && preg_match('|.*\.pdf|i', $header_file)) { + if ('Mozilla' == $browser['name'] && preg_match('|.*\.pdf|i', $header_file)) { $pdfUrl = $file_url; } echo '
'; diff --git a/public/main/document/slideshow.php b/public/main/document/slideshow.php index a30f9f020d..cd1510c09b 100644 --- a/public/main/document/slideshow.php +++ b/public/main/document/slideshow.php @@ -7,8 +7,6 @@ use ChamiloSession as Session; * @author Patrick Cool patrick.cool@UGent.be Ghent University Mai 2004 * @author Julio Montoya Lots of improvements, cleaning, adding security * @author Juan Carlos Raña Trabado herodoto@telefonica.net January 2008 - * - * @package chamilo.document */ require_once __DIR__.'/../inc/global.inc.php'; @@ -27,7 +25,7 @@ if (empty($slide_id)) { $edit_slide_id = $slide_id; } -if ($path != '/') { +if ('/' != $path) { $folder = $path.'/'; } else { $folder = '/'; @@ -70,7 +68,7 @@ require 'document_slideshow.inc.php'; // Calculating the current slide, next slide, previous slide and the number of slides $slide = null; -if ($slide_id != 'all') { +if ('all' != $slide_id) { $slide = $slide_id ? $slide_id : 0; $previous_slide = $slide - 1; $next_slide = $slide + 1; @@ -79,7 +77,7 @@ $total_slides = count($image_files_only); echo '
'; -if ($slide_id != 'all') { +if ('all' != $slide_id) { $image = null; if (isset($image_files_only[$slide])) { $image = $sys_course_path.$_course['path'].'/document'.$folder.$image_files_only[$slide]; @@ -87,7 +85,7 @@ if ($slide_id != 'all') { if (file_exists($image)) { echo '
'; // Back forward buttons - if ($slide == 0) { + if (0 == $slide) { $imgp = 'action_prev_na.png'; $first = Display::return_icon('action_first_na.png'); } else { @@ -144,7 +142,7 @@ echo Display::url( ); // Show thumbnails -if ($slide_id != 'all') { +if ('all' != $slide_id) { echo ''. Display::return_icon('thumbnails.png', get_lang('Show Thumbnails'), '', ICON_SIZE_MEDIUM).''; } else { @@ -161,7 +159,7 @@ echo '
'; if (isset($_POST['Submit'])) { // We come from slideshowoptions.php Session::write('image_resizing', Security::remove_XSS($_POST['radio_resizing'])); - if ($_POST['radio_resizing'] == 'resizing' && $_POST['width'] != '' && $_POST['height'] != '') { + if ('resizing' == $_POST['radio_resizing'] && '' != $_POST['width'] && '' != $_POST['height']) { Session::write('image_resizing_width', Security::remove_XSS($_POST['width'])); Session::write('image_resizing_height', Security::remove_XSS($_POST['height'])); } else { @@ -173,7 +171,7 @@ if (isset($_POST['Submit'])) { $target_width = $target_height = null; $imageResize = Session::read('image_resizing'); // The target height and width depends if we choose resizing or no resizing -if ($imageResize == 'resizing') { +if ('resizing' == $imageResize) { $target_width = Session::read('image_resizing_width'); $target_height = Session::read('image_resizing_height'); } @@ -182,7 +180,7 @@ if ($imageResize == 'resizing') { // This is for viewing all the images in the slideshow as thumbnails. $image_tag = []; $html = ''; -if ($slide_id == 'all') { +if ('all' == $slide_id) { // Config for make thumbnails $allowed_thumbnail_types = ['jpg', 'jpeg', 'gif', 'png']; $max_thumbnail_width = 250; @@ -252,13 +250,13 @@ if ($slide_id == 'all') { $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); // preserve transparency - if ($imagetype == 'png') { + if ('png' == $imagetype) { imagesavealpha($crop, true); $color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127); imagefill($crop, 0, 0, $color); } - if ($imagetype == 'gif') { + if ('gif' == $imagetype) { $transindex = imagecolortransparent($source_img); $palletsize = imagecolorstotal($source_img); //GIF89a for transparent and anim (first clip), either GIF87a @@ -310,11 +308,11 @@ if ($slide_id == 'all') { }//end !exist thumbnail //show thumbnail and link $one_image_thumbnail_file = '.thumbs/.'.$one_image_file; //get path thumbnail - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; + $doc_url = ($path && '/' !== $path) ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; $image_tag[] = ''; } else { // If images aren't support by gd (not gif, jpg, jpeg, png) - if ($imagetype == 'bmp') { + if ('bmp' == $imagetype) { // use getimagesize instead api_getimagesize($image); // because api_getimagesize doesn't support bmp files. // Put here for each show, only for a few bmp files isn't heavy @@ -341,7 +339,7 @@ if ($slide_id == 'all') { $image_height = $max_thumbnail_height; } - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; + $doc_url = ($path && '/' !== $path) ? $path.'/'.$one_image_file : $path.$one_image_file; $image_tag[] = ''; - if ($slide < $total_slides - 1 && $slide_id != 'all') { + if ($slide < $total_slides - 1 && 'all' != $slide_id) { echo ""; } else { echo ""; } - if ($path == '/') { + if ('/' == $path) { $path = ''; } list($width, $height) = getimagesize($image); // Auto resize - if ($imageResize == 'resizing') { + if ('resizing' == $imageResize) { ?>
addElement( 'onclick="javascript: check_unzip();" value="1"' ); -if (api_get_setting('search_enabled') === 'true') { +if ('true' === api_get_setting('search_enabled')) { //TODO: include language file $supportedFormats = get_lang('Supported formats for index').': HTML, PDF, TXT, PDF, Postscript, MS Word, RTF, MS Power Point'; $form->addElement( diff --git a/public/main/document/webcam_clip.php b/public/main/document/webcam_clip.php index d1e64bafdf..110e9bccd8 100644 --- a/public/main/document/webcam_clip.php +++ b/public/main/document/webcam_clip.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * This file allows record wav files. * - * @package chamilo.document - * * @author Juan Carlos Raña Trabado herodoto@telefonica.net * * @since 7/jun/2012 @@ -48,7 +46,7 @@ $dir = $documentData['path']; //make some vars $webcamdir = $dir; -if ($webcamdir == "/") { +if ("/" == $webcamdir) { $webcamdir = ''; } @@ -59,15 +57,15 @@ if (strstr($dir, '..')) { $dir = '/'; } -if ($dir[0] == '.') { +if ('.' == $dir[0]) { $dir = substr($dir, 1); } -if ($dir[0] != '/') { +if ('/' != $dir[0]) { $dir = '/'.$dir; } -if ($dir[strlen($dir) - 1] != '/') { +if ('/' != $dir[strlen($dir) - 1]) { $dir .= '/'; } @@ -123,7 +121,7 @@ if (isset($documentData['parents'])) { foreach ($documentData['parents'] as $documentSubData) { //fixing double group folder in breadcrumb if ($groupId) { - if ($counter == 0) { + if (0 == $counter) { $counter++; continue; } diff --git a/public/main/document/webcam_receiver.php b/public/main/document/webcam_receiver.php index 1ec9dbf6bd..f659925e72 100644 --- a/public/main/document/webcam_receiver.php +++ b/public/main/document/webcam_receiver.php @@ -22,7 +22,7 @@ if (isset($params['webcamname']) && isset($params['webcamdir']) && isset($params die(); } -if ($webcamuserid != api_get_user_id() || api_get_user_id() == 0 || $webcamuserid == 0) { +if ($webcamuserid != api_get_user_id() || 0 == api_get_user_id() || 0 == $webcamuserid) { api_not_allowed(); die(); } @@ -39,7 +39,7 @@ $webcamdir = Security::remove_XSS($webcamdir); $ext = explode('.', $webcamname); $ext = strtolower($ext[sizeof($ext) - 1]); -if ($ext != 'jpg') { +if ('jpg' != $ext) { die(); } diff --git a/public/main/dropbox/dropbox_class.inc.php b/public/main/dropbox/dropbox_class.inc.php index 6acc9fa971..c6c7c82113 100644 --- a/public/main/dropbox/dropbox_class.inc.php +++ b/public/main/dropbox/dropbox_class.inc.php @@ -39,8 +39,6 @@ * @copyright 2004 * @author Jan Bols * with contributions by René Haentjens - * - * @package chamilo.dropbox */ class Dropbox_Work { @@ -163,7 +161,7 @@ class Dropbox_Work WHERE c_id = $course_id AND file_id = ".intval($this->id)." AND user_id = ".$this->uploader_id; $result = Database::query($sql); $row = Database::fetch_array($result); - if ($row['count'] == 0) { + if (0 == $row['count']) { // Insert entries into person table $sql = "INSERT INTO ".Database::get_course_table(TABLE_DROPBOX_PERSON)." (c_id, file_id, user_id) VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")"; @@ -213,7 +211,7 @@ class Dropbox_Work $this->category = $res['cat_id']; // Getting the feedback on the work. - if ($action == 'viewfeedback' && $this->id == $_GET['id']) { + if ('viewfeedback' == $action && $this->id == $_GET['id']) { $feedback2 = []; $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_FEEDBACK)." WHERE c_id = $course_id AND file_id='".$id."' @@ -319,12 +317,12 @@ class Dropbox_SentWork extends Dropbox_Work if (is_int($recipient_ids)) { $justSubmit = true; $recipient_ids = [$recipient_ids + $this->id]; - } elseif (count($recipient_ids) == 0) { + } elseif (0 == count($recipient_ids)) { $justSubmit = true; $recipient_ids = [$uploader_id]; } - if (!is_array($recipient_ids) || count($recipient_ids) == 0) { + if (!is_array($recipient_ids) || 0 == count($recipient_ids)) { die(get_lang('An error has occured. Please contact your system administrator.').' (code 209)'); } diff --git a/public/main/dropbox/dropbox_download.php b/public/main/dropbox/dropbox_download.php index b2a67e1553..b8bf7e89e6 100644 --- a/public/main/dropbox/dropbox_download.php +++ b/public/main/dropbox/dropbox_download.php @@ -1,8 +1,6 @@ title; $result = DocumentManager::file_send_for_download($path, true, $file); - if ($result === false) { + if (false === $result) { api_not_allowed(true); } exit; diff --git a/public/main/dropbox/dropbox_functions.inc.php b/public/main/dropbox/dropbox_functions.inc.php index ea0fad8dcf..0159affcc7 100644 --- a/public/main/dropbox/dropbox_functions.inc.php +++ b/public/main/dropbox/dropbox_functions.inc.php @@ -37,9 +37,9 @@ function handle_multiple_actions() $is_courseTutor = api_is_course_tutor(); // STEP 1: are we performing the actions on the received or on the sent files? - if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'download_received') { + if ('delete_received' == $_POST['action'] || 'download_received' == $_POST['action']) { $part = 'received'; - } elseif ($_POST['action'] == 'delete_sent' || $_POST['action'] == 'download_sent') { + } elseif ('delete_sent' == $_POST['action'] || 'download_sent' == $_POST['action']) { $part = 'sent'; } @@ -49,7 +49,7 @@ function handle_multiple_actions() $checked_file_ids = $_POST['id']; } else { foreach ($_POST as $key => $value) { - if (strstr($value, $part.'_') && $key != 'view_received_category' && $key != 'view_sent_category') { + if (strstr($value, $part.'_') && 'view_received_category' != $key && 'view_sent_category' != $key) { $checked_files = true; $checked_file_ids[] = intval(substr($value, strrpos($value, '_'))); } @@ -57,19 +57,19 @@ function handle_multiple_actions() } $checked_file_ids = $_POST['id']; - if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) { + if (!is_array($checked_file_ids) || 0 == count($checked_file_ids)) { return get_lang('Check at least one file.'); } // Deleting - if ($_POST['action'] == 'delete_received' || $_POST['action'] == 'delete_sent') { + if ('delete_received' == $_POST['action'] || 'delete_sent' == $_POST['action']) { $dropboxfile = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); foreach ($checked_file_ids as $key => $value) { - if ($_GET['view'] == 'received') { + if ('received' == $_GET['view']) { $dropboxfile->deleteReceivedWork($value); $message = get_lang('The received file has been deleted.'); } - if ($_GET['view'] == 'sent' || empty($_GET['view'])) { + if ('sent' == $_GET['view'] || empty($_GET['view'])) { $dropboxfile->deleteSentWork($value); $message = get_lang('The sent file has been deleted.'); } @@ -97,7 +97,7 @@ function handle_multiple_actions() } // STEP 3D: downloading - if ($_POST['action'] == 'download_sent' || $_POST['action'] == 'download_received') { + if ('download_sent' == $_POST['action'] || 'download_received' == $_POST['action']) { zip_download($checked_file_ids); } } @@ -133,7 +133,7 @@ function delete_category($action, $id, $user_id = null) } $cat = get_dropbox_category($id); - if (count($cat) == 0) { + if (0 == count($cat)) { return false; } @@ -142,12 +142,12 @@ function delete_category($action, $id, $user_id = null) } // an additional check that might not be necessary - if ($action == 'deletereceivedcategory') { + if ('deletereceivedcategory' == $action) { $sentreceived = 'received'; $entries_table = Database::get_course_table(TABLE_DROPBOX_POST); $id_field = 'file_id'; $return_message = get_lang('The folder has been deleted'); - } elseif ($action == 'deletesentcategory') { + } elseif ('deletesentcategory' == $action) { $sentreceived = 'sent'; $entries_table = Database::get_course_table(TABLE_DROPBOX_FILE); $id_field = 'id'; @@ -168,10 +168,10 @@ function delete_category($action, $id, $user_id = null) while ($row = Database::fetch_array($result)) { $dropboxfile = new Dropbox_Person($user_id, $is_courseAdmin, $is_courseTutor); - if ($action == 'deletereceivedcategory') { + if ('deletereceivedcategory' == $action) { $dropboxfile->deleteReceivedWork($row[$id_field]); } - if ($action == 'deletesentcategory') { + if ('deletesentcategory' == $action) { $dropboxfile->deleteSentWork($row[$id_field]); } } @@ -231,11 +231,11 @@ function store_move($id, $target, $part) $_user = api_get_user_info(); $course_id = api_get_course_int_id(); - if ((isset($id) && $id != '') && - (isset($target) && $target != '') && - (isset($part) && $part != '') + if ((isset($id) && '' != $id) && + (isset($target) && '' != $target) && + (isset($part) && '' != $part) ) { - if ($part == 'received') { + if ('received' == $part) { $sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_POST)." SET cat_id = ".intval($target)." WHERE c_id = $course_id AND dest_user_id = ".intval($_user['user_id'])." @@ -243,7 +243,7 @@ function store_move($id, $target, $part) Database::query($sql); $return_message = get_lang('The received file has been moved.'); } - if ($part == 'sent') { + if ('sent' == $part) { $sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FILE)." SET cat_id = ".intval($target)." WHERE @@ -285,8 +285,8 @@ function get_dropbox_categories($filter = '') $result = Database::query($sql); while ($row = Database::fetch_array($result)) { - if (($filter == 'sent' && $row['sent'] == 1) || - ($filter == 'received' && $row['received'] == 1) || $filter == '' + if (('sent' == $filter && 1 == $row['sent']) || + ('received' == $filter && 1 == $row['received']) || '' == $filter ) { $return_array[$row['cat_id']] = $row; } @@ -314,7 +314,7 @@ function get_dropbox_category($id) $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)." WHERE c_id = $course_id AND cat_id='".$id."'"; $res = Database::query($sql); - if ($res === false) { + if (false === $res) { return []; } $row = Database::fetch_assoc($res); @@ -344,10 +344,10 @@ function store_addcategory() $_user = api_get_user_info(); // check if the target is valid - if ($_POST['target'] == 'sent') { + if ('sent' == $_POST['target']) { $sent = 1; $received = 0; - } elseif ($_POST['target'] == 'received') { + } elseif ('received' == $_POST['target']) { $sent = 0; $received = 1; } else { @@ -355,7 +355,7 @@ function store_addcategory() } // check if the category name is valid - if ($_POST['category_name'] == '') { + if ('' == $_POST['category_name']) { return ['type' => 'error', 'message' => get_lang('Please give a category name')]; } @@ -373,7 +373,7 @@ function store_addcategory() $result = Database::query($sql); // step 3b, we add the category if it does not exist yet. - if (Database::num_rows($result) == 0) { + if (0 == Database::num_rows($result)) { $params = [ 'cat_id' => 0, 'c_id' => $course_id, @@ -447,25 +447,25 @@ function display_addcategory_form($category_name = '', $id = 0, $action = '') // (happens when createinrecievedfiles AND createinsentfiles are not checked) $category_name = $row['cat_name']; } - if ($row['received'] == '1') { + if ('1' == $row['received']) { $target = 'received'; } - if ($row['sent'] == '1') { + if ('1' == $row['sent']) { $target = 'sent'; } $title = get_lang('Edit this category'); } - if ($action == 'addreceivedcategory') { + if ('addreceivedcategory' == $action) { $target = 'received'; } - if ($action == 'addsentcategory') { + if ('addsentcategory' == $action) { $target = 'sent'; } - if ($action == 'editcategory') { + if ('editcategory' == $action) { $text = get_lang('Edit category'); - } elseif ($action == 'addreceivedcategory' || $action == 'addsentcategory') { + } elseif ('addreceivedcategory' == $action || 'addsentcategory' == $action) { $text = get_lang('Create category'); } @@ -547,7 +547,7 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = ); $allowOverwrite = api_get_setting('dropbox_allow_overwrite'); - if ($allowOverwrite == 'true' && empty($idCondition)) { + if ('true' == $allowOverwrite && empty($idCondition)) { $form->addElement( 'checkbox', 'cb_overwrite', @@ -560,7 +560,7 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = // List of all users in this course and all virtual courses combined with it if (api_get_session_id()) { $complete_user_list_for_dropbox = []; - if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) { + if ('true' == api_get_setting('dropbox_allow_student_to_student') || STUDENT != $_user['status']) { $complete_user_list_for_dropbox = CourseManager:: get_user_list_from_course_code( $course_info['code'], api_get_session_id(), @@ -585,7 +585,7 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = $generalCoachList = []; $courseCoachList = []; foreach ($complete_user_list2 as $coach) { - if ($coach['type'] == 'general_coach') { + if ('general_coach' == $coach['type']) { $generalCoachList[] = $coach; } else { $courseCoachList[] = $coach; @@ -593,7 +593,7 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = } $hideCourseCoach = api_get_setting('dropbox_hide_course_coach'); - if ($hideCourseCoach == 'false') { + if ('false' == $hideCourseCoach) { $complete_user_list_for_dropbox = array_merge( $complete_user_list_for_dropbox, $courseCoachList @@ -601,14 +601,14 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = } $hideGeneralCoach = api_get_setting('dropbox_hide_general_coach'); - if ($hideGeneralCoach == 'false') { + if ('false' == $hideGeneralCoach) { $complete_user_list_for_dropbox = array_merge( $complete_user_list_for_dropbox, $generalCoachList ); } } else { - if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) { + if ('true' == api_get_setting('dropbox_allow_student_to_student') || STUDENT != $_user['status']) { $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code( $course_info['code'], api_get_session_id(), @@ -655,16 +655,16 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = if (( $dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin - || $allowStudentToStudent == 'true' - || $current_user['status'] != 5 // Always allow teachers. - || $current_user['is_tutor'] == 1 // Always allow tutors. + || 'true' == $allowStudentToStudent + || 5 != $current_user['status'] // Always allow teachers. + || 1 == $current_user['is_tutor'] // Always allow tutors. ) && $current_user['user_id'] != $_user['user_id']) { // Don't include yourself. if ($current_user['user_id'] == $current_user_id) { continue; } $userId = $current_user['user_id']; $userInfo = api_get_user_info($userId); - if ($userInfo['status'] != INVITEE) { + if (INVITEE != $userInfo['status']) { $groupNameListToString = ''; if (!empty($groups)) { $groupNameList = array_column($groups, 'name'); @@ -684,7 +684,7 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = */ $allowGroups = api_get_setting('dropbox_allow_group'); if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) - && $allowGroups == 'true' || $allowStudentToStudent == 'true' + && 'true' == $allowGroups || 'true' == $allowStudentToStudent ) { $complete_group_list_for_dropbox = GroupManager::get_group_list(null, $course_info); @@ -698,7 +698,7 @@ function display_add_form($viewReceivedCategory, $viewSentCategory, $view, $id = } $allowUpload = api_get_setting('dropbox_allow_just_upload'); - if ($allowUpload == 'true') { + if ('true' == $allowUpload) { $options['user_'.$_user['user_id']] = get_lang('---Just upload---'); } @@ -817,7 +817,7 @@ function getUserOwningThisMailing($mailingPseudoId, $owner = 0, $or_die = '') if (!($res = Database::fetch_array($result))) { die(get_lang('An error has occured. Please contact your system administrator.').' (code 901)'); } - if ($owner == 0) { + if (0 == $owner) { return $res['uploader_id']; } if ($res['uploader_id'] == $owner) { @@ -887,11 +887,11 @@ function store_add_dropbox($file = [], $work = null) $thisIsJustUpload = false; foreach ($_POST['recipients'] as $rec) { - if ($rec == 'mailing') { + if ('mailing' == $rec) { $thisIsAMailing = true; - } elseif ($rec == 'upload') { + } elseif ('upload' == $rec) { $thisIsJustUpload = true; - } elseif (strpos($rec, 'user_') === 0 && + } elseif (0 === strpos($rec, 'user_') && !CourseManager::is_user_subscribed_in_course( substr($rec, strlen('user_')), $_course['code'], @@ -906,7 +906,7 @@ function store_add_dropbox($file = [], $work = null) ); return false; - } elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) { + } elseif (0 !== strpos($rec, 'group_') && 0 !== strpos($rec, 'user_')) { Display::addFlash( Display::return_message( get_lang('Invalid group detected.'), @@ -920,7 +920,7 @@ function store_add_dropbox($file = [], $work = null) } // we are doing a mailing but an additional recipient is selected - if ($thisIsAMailing && (count($_POST['recipients']) != 1)) { + if ($thisIsAMailing && (1 != count($_POST['recipients']))) { Display::addFlash( Display::return_message( get_lang('Mailing cannot be combined with other recipients'), @@ -934,7 +934,7 @@ function store_add_dropbox($file = [], $work = null) // we are doing a just upload but an additional recipient is selected. // note: why can't this be valid? It is like sending a document to // yourself AND to a different person (I do this quite often with my e-mails) - if ($thisIsJustUpload && (count($_POST['recipients']) != 1)) { + if ($thisIsJustUpload && (1 != count($_POST['recipients']))) { Display::addFlash( Display::return_message( get_lang('Just Upload cannot be combined with other recipients'), @@ -1040,9 +1040,9 @@ function store_add_dropbox($file = [], $work = null) // creating the array that contains all the users who will receive the file $new_work_recipients = []; foreach ($_POST['recipients'] as $rec) { - if (strpos($rec, 'user_') === 0) { + if (0 === strpos($rec, 'user_')) { $new_work_recipients[] = substr($rec, strlen('user_')); - } elseif (strpos($rec, 'group_') === 0) { + } elseif (0 === strpos($rec, 'group_')) { $groupInfo = GroupManager::get_group_properties(substr($rec, strlen('group_'))); $userList = GroupManager::get_subscribed_users($groupInfo); foreach ($userList as $usr) { @@ -1353,7 +1353,7 @@ function zip_download($fileList) Session::erase('dropbox_files_to_download'); $name = 'dropbox-'.api_get_utc_datetime().'.zip'; $result = DocumentManager::file_send_for_download($temp_zip_file, true, $name); - if ($result === false) { + if (false === $result) { api_not_allowed(true); } @unlink($temp_zip_file); @@ -1402,7 +1402,7 @@ function generate_html_overview($files, $dont_show_columns = [], $make_link = [] $counter = 0; foreach ($files as $value) { // Adding the header. - if ($counter == 0) { + if (0 == $counter) { $columns_array = array_keys($value); $return .= "\n"; foreach ($columns_array as $columns_array_key => $columns_array_value) { diff --git a/public/main/dropbox/dropbox_init.inc.php b/public/main/dropbox/dropbox_init.inc.php index 69e255920f..fba67de5e1 100644 --- a/public/main/dropbox/dropbox_init.inc.php +++ b/public/main/dropbox/dropbox_init.inc.php @@ -14,8 +14,6 @@ use ChamiloSession as Session; * @author Roan Embrechts, virtual course support * @author Patrick Cool , Ghent University (see history version 1.3) * - * @package chamilo.dropbox - * * @todo complete refactoring. Currently there are about at least 3 sql queries needed for every individual dropbox document. * first we find all the documents that were sent (resp. received) by the user * then for every individual document the user(s)information who received (resp. sent) the document is searched @@ -107,8 +105,6 @@ Version 1.1 * download file / folder (download icon) * same action on multiple documents * extended feedback - * - * @package chamilo.dropbox */ require_once __DIR__.'/../inc/global.inc.php'; $is_allowed_in_course = api_is_allowed_in_course(); @@ -155,7 +151,7 @@ if (empty($session_id)) { // off all the documents that have already been sent. // @todo consider moving the javascripts in a function that displays the javascripts // only when it is needed. -if ($action == 'add') { +if ('add' == $action) { $dropbox_person = new Dropbox_Person( $user_id, $is_courseAdmin, @@ -200,7 +196,7 @@ function checkForm (frm) "; $allowOverwrite = api_get_setting('dropbox_allow_overwrite'); -if ($allowOverwrite == 'true') { +if ('true' == $allowOverwrite) { //sentArray keeps list of all files still available in the sent files list //of the user. //This is used to show or hide the overwrite file-radio button of the upload form @@ -284,7 +280,7 @@ $(function () { }); "; $checked_files = false; -if (!$view || $view == 'received') { +if (!$view || 'received' == $view) { $part = 'received'; } elseif ($view = 'sent') { $part = 'sent'; @@ -293,9 +289,9 @@ if (!$view || $view == 'received') { exit; } -if (($postAction == 'download_received' || $postAction == 'download_sent') and !$_POST['store_feedback']) { +if (('download_received' == $postAction || 'download_sent' == $postAction) and !$_POST['store_feedback']) { $checked_file_ids = $_POST['id']; - if (!is_array($checked_file_ids) || count($checked_file_ids) == 0) { + if (!is_array($checked_file_ids) || 0 == count($checked_file_ids)) { header('Location: index.php?'.api_get_cidreq().'&view='.$view.'&error=CheckAtLeastOneFile'); } else { handle_multiple_actions(); @@ -310,7 +306,7 @@ if (($postAction == 'download_received' || $postAction == 'download_sent') and ! if ((!$is_allowed_in_course || !$is_course_member) && !api_is_allowed_to_edit(null, true) ) { - if ($origin != 'learnpath') { + if ('learnpath' != $origin) { api_not_allowed(true); //print headers/footers } else { api_not_allowed(); @@ -319,14 +315,14 @@ if ((!$is_allowed_in_course || !$is_course_member) && } /* BREADCRUMBS */ -if ($view == 'received') { +if ('received' == $view) { $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq(), 'name' => get_lang('Dropbox'), ]; $nameTools = get_lang('Received Files'); - if ($action == 'addreceivedcategory') { + if ('addreceivedcategory' == $action) { $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=received&'.api_get_cidreq(), 'name' => get_lang('Received Files'), @@ -335,25 +331,25 @@ if ($view == 'received') { } } -if ($view == 'sent' || empty($view)) { +if ('sent' == $view || empty($view)) { $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq(), 'name' => get_lang('Dropbox'), ]; $nameTools = get_lang('Sent Files'); - if ($action == 'addsentcategory') { + if ('addsentcategory' == $action) { $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=sent&'.api_get_cidreq(), 'name' => get_lang('Sent Files'), ]; $nameTools = get_lang('Add a new folder'); } - if ($action == 'add') { + if ('add' == $action) { $nameTools = get_lang('Share a new file'); } - if ($action == 'update') { + if ('update' == $action) { $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'dropbox/index.php?view=sent&'.api_get_cidreq(), 'name' => get_lang('Sent Files'), @@ -363,7 +359,7 @@ if ($view == 'sent' || empty($view)) { } /* HEADER & TITLE */ -if (isset($origin) && $origin == 'learnpath') { +if (isset($origin) && 'learnpath' == $origin) { $htmlHeadXtra[] = $javascript; Display::display_reduced_header($nameTools, 'Dropbox'); } else { diff --git a/public/main/dropbox/index.php b/public/main/dropbox/index.php index a68d9ac03d..1dacdc055f 100644 --- a/public/main/dropbox/index.php +++ b/public/main/dropbox/index.php @@ -9,7 +9,7 @@ $_course = api_get_course_info(); $last_access = ''; // get the last time the user accessed the tool if (isset($_SESSION[$_course['id']]) && - $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '' + '' == $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] ) { $last_access = get_last_tool_access(TOOL_DROPBOX); $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access; @@ -58,8 +58,8 @@ if (isset($_GET['dropbox_direction']) && in_array($_GET['dropbox_direction'], [' $sort_params = Security::remove_XSS(implode('&', $sort_params)); // Display the form for adding a new dropbox item. -if ($action == 'add') { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { +if ('add' == $action) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } display_add_form( @@ -77,8 +77,8 @@ if (isset($_POST['submitWork'])) { } // Display the form for adding a category -if ($action == 'addreceivedcategory' || $action == 'addsentcategory') { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { +if ('addreceivedcategory' == $action || 'addsentcategory' == $action) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } $categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : ''; @@ -86,12 +86,12 @@ if ($action == 'addreceivedcategory' || $action == 'addsentcategory') { } // Editing a category: displaying the form -if ($action == 'editcategory' && isset($_GET['id'])) { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { +if ('editcategory' == $action && isset($_GET['id'])) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } if (!$_POST) { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } display_addcategory_form('', $_GET['id'], 'editcategory'); @@ -100,16 +100,16 @@ if ($action == 'editcategory' && isset($_GET['id'])) { // Storing a new or edited category if (isset($_POST['StoreCategory'])) { - if (api_get_session_id() != 0 && + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true) ) { api_not_allowed(); } $return_information = store_addcategory(); - if ($return_information['type'] == 'confirmation') { + if ('confirmation' == $return_information['type']) { echo Display::return_message($return_information['message'], 'confirmation'); } - if ($return_information['type'] == 'error') { + if ('error' == $return_information['type']) { echo Display::return_message( get_lang('The form contains incorrect or incomplete data. Please check your input.').'
'.$return_information['message'], 'error' @@ -119,8 +119,8 @@ if (isset($_POST['StoreCategory'])) { } // Move a File -if (($action == 'movesent' || $action == 'movereceived') && isset($_GET['move_id'])) { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { +if (('movesent' == $action || 'movereceived' == $action) && isset($_GET['move_id'])) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } display_move_form( @@ -146,8 +146,8 @@ if (isset($_POST['do_move'])) { } // Delete a file -if (($action == 'deletereceivedfile' || $action == 'deletesentfile') && isset($_GET['id']) && is_numeric($_GET['id'])) { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { +if (('deletereceivedfile' == $action || 'deletesentfile' == $action) && isset($_GET['id']) && is_numeric($_GET['id'])) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } $dropboxfile = new Dropbox_Person( @@ -155,11 +155,11 @@ if (($action == 'deletereceivedfile' || $action == 'deletesentfile') && isset($_ $is_courseAdmin, $is_courseTutor ); - if ($action == 'deletereceivedfile') { + if ('deletereceivedfile' == $action) { $dropboxfile->deleteReceivedWork($_GET['id']); $message = get_lang('The received file has been deleted.'); } - if ($action == 'deletesentfile') { + if ('deletesentfile' == $action) { $dropboxfile->deleteSentWork($_GET['id']); $message = get_lang('The sent file has been deleted.'); } @@ -167,10 +167,10 @@ if (($action == 'deletereceivedfile' || $action == 'deletesentfile') && isset($_ } // Delete a category -if (($action == 'deletereceivedcategory' || $action == 'deletesentcategory') && +if (('deletereceivedcategory' == $action || 'deletesentcategory' == $action) && isset($_GET['id']) && is_numeric($_GET['id']) ) { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } $message = delete_category($action, $_GET['id']); @@ -184,10 +184,10 @@ if (($action == 'deletereceivedcategory' || $action == 'deletesentcategory') && if (!isset($_POST['feedback']) && ( strstr($postAction, 'move_received') || strstr($postAction, 'move_sent') || - $postAction == 'delete_received' || - $postAction == 'download_received' || - $postAction == 'delete_sent' || - $postAction == 'download_sent' + 'delete_received' == $postAction || + 'download_received' == $postAction || + 'delete_sent' == $postAction || + 'download_sent' == $postAction ) ) { $display_message = handle_multiple_actions(); @@ -196,7 +196,7 @@ if (!isset($_POST['feedback']) && ( // Store Feedback if (isset($_POST['feedback'])) { - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { + if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } $check = Security::check_token(); @@ -216,32 +216,32 @@ $dropbox_data_sent = []; $movelist = []; $dropbox_data_recieved = []; -if ($action != 'add') { +if ('add' != $action) { // Getting all the categories in the dropbox for the given user $dropbox_categories = get_dropbox_categories(); // Greating the arrays with the categories for the received files and for the sent files foreach ($dropbox_categories as $category) { - if ($category['received'] == '1') { + if ('1' == $category['received']) { $dropbox_received_category[] = $category; } - if ($category['sent'] == '1') { + if ('1' == $category['sent']) { $dropbox_sent_category[] = $category; } } // ACTIONS - if ($view == 'received' || !$showSentReceivedTabs) { + if ('received' == $view || !$showSentReceivedTabs) { // This is for the categories - if (isset($viewReceivedCategory) && $viewReceivedCategory != '') { + if (isset($viewReceivedCategory) && '' != $viewReceivedCategory) { $view_dropbox_category_received = $viewReceivedCategory; } else { $view_dropbox_category_received = 0; } /* Menu Received */ - if (api_get_session_id() == 0) { + if (0 == api_get_session_id()) { echo '
'; - if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { + if (0 != $view_dropbox_category_received && api_is_allowed_to_session_edit(false, true)) { echo ''. Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('root'), '', ICON_SIZE_MEDIUM). ""; @@ -255,7 +255,7 @@ if ($action != 'add') { } else { if (api_is_allowed_to_session_edit(false, true)) { echo '
'; - if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { + if (0 != $view_dropbox_category_received && api_is_allowed_to_session_edit(false, true)) { echo ''. Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('root'), '', ICON_SIZE_MEDIUM).""; echo get_lang('Category').': '.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).' '; @@ -270,23 +270,23 @@ if ($action != 'add') { } } - if (!$view || $view == 'sent' || !$showSentReceivedTabs) { + if (!$view || 'sent' == $view || !$showSentReceivedTabs) { // This is for the categories - if (isset($viewSentCategory) && $viewSentCategory != '') { + if (isset($viewSentCategory) && '' != $viewSentCategory) { $view_dropbox_category_sent = $viewSentCategory; } else { $view_dropbox_category_sent = 0; } /* Menu Sent */ - if (api_get_session_id() == 0) { + if (0 == api_get_session_id()) { echo '
'; if (empty($viewSentCategory)) { echo "". Display::return_icon('upload_file.png', get_lang('Share a new file'), '', ICON_SIZE_MEDIUM). ""; } - if ($view_dropbox_category_sent != 0) { + if (0 != $view_dropbox_category_sent) { echo ''. Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('root'), '', ICON_SIZE_MEDIUM). ""; @@ -304,7 +304,7 @@ if ($action != 'add') { Display::return_icon('upload_file.png', get_lang('Share a new file'), '', ICON_SIZE_MEDIUM). ""; } - if ($view_dropbox_category_sent != 0) { + if (0 != $view_dropbox_category_sent) { echo get_lang('You are in folder').': '.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).' '; echo ''. Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('root'), '', ICON_SIZE_MEDIUM). @@ -321,14 +321,14 @@ if ($action != 'add') { if ($showSentReceivedTabs) { ?>
'; @@ -7213,7 +7213,7 @@ class Exercise if (999 == $mediaQuestionId) { $counterNoMedias += count($questionList); } else { - ++$counterNoMedias; + $counterNoMedias++; } $nextValue += count($questionList); @@ -7251,7 +7251,7 @@ class Exercise // Normal question list render (medias compressed) foreach ($questionList as $questionId) { - ++$i; + $i++; // For sequential exercises if (ONE_PER_PAGE == $this->type) { @@ -7310,8 +7310,8 @@ class Exercise $isLastQuestionInMedia, $questionList ); - ++$letterCounter; - ++$counter; + $letterCounter++; + $counter++; } } } else { @@ -7325,7 +7325,7 @@ class Exercise null, $questionList ); - ++$i; + $i++; } } else { // Normal question render. @@ -7604,7 +7604,7 @@ class Exercise rsort($questionScoreList); // add the first $numberRandomQuestions value of score array to get max_score - for ($i = 0; $i < min($numberRandomQuestions, count($questionScoreList)); ++$i) { + for ($i = 0; $i < min($numberRandomQuestions, count($questionScoreList)); $i++) { $out_max_score += $questionScoreList[$i]; } } elseif ($this->random > 0 && $this->randomByCat > 0) { @@ -7626,7 +7626,7 @@ class Exercise // here we've got an array with first key, the category_id, second key, score of question for this cat foreach ($tab_categories_scores as $tab_scores) { rsort($tab_scores); - for ($i = 0; $i < min($numberRandomQuestions, count($tab_scores)); ++$i) { + for ($i = 0; $i < min($numberRandomQuestions, count($tab_scores)); $i++) { $out_max_score += $tab_scores[$i]; } } @@ -7788,7 +7788,7 @@ class Exercise return null; } - --$currentQuestion; + $currentQuestion--; if (!empty($result['question_list'])) { $answeredQuestions = []; @@ -7806,7 +7806,7 @@ class Exercise break; } } - ++$counterAnsweredQuestions; + $counterAnsweredQuestions++; } $counterRemindListQuestions = 0; @@ -7819,7 +7819,7 @@ class Exercise break; } } - ++$counterRemindListQuestions; + $counterRemindListQuestions++; } if ($counterRemindListQuestions < $currentQuestion) { @@ -7857,13 +7857,13 @@ class Exercise if (in_array($questionId, $mediaQuestionList)) { return $position; } else { - ++$position; + $position++; } } else { if ($id == $questionId) { return $position; } else { - ++$position; + $position++; } } } @@ -8137,12 +8137,12 @@ class Exercise if (true === $hideLabel) { $answerUsed = (int) $array['used']; $answerMissing = (int) $array['missing'] - $answerUsed; - for ($i = 1; $i <= $answerUsed; ++$i) { + for ($i = 1; $i <= $answerUsed; $i++) { $html .= ''. Display::return_icon('attempt-check.png', null, null, ICON_SIZE_SMALL). ''; } - for ($i = 1; $i <= $answerMissing; ++$i) { + for ($i = 1; $i <= $answerMissing; $i++) { $html .= ''. Display::return_icon('attempt-nocheck.png', null, null, ICON_SIZE_SMALL). ''; @@ -8998,7 +8998,7 @@ class Exercise // Just in case we save the order in other array $temp_question_list[$counter] = $new_object->question_id; - ++$counter; + $counter++; } if (!empty($temp_question_list)) { diff --git a/public/main/exercise/exercise.php b/public/main/exercise/exercise.php index 4afc5bd86f..8cb7a25934 100644 --- a/public/main/exercise/exercise.php +++ b/public/main/exercise/exercise.php @@ -270,9 +270,9 @@ if ($is_allowedToEdit && !empty($action)) { $currentPosition = $category->getPosition(); if ('up_category' === $action) { - --$currentPosition; + $currentPosition--; } else { - ++$currentPosition; + $currentPosition++; } $category->setPosition($currentPosition); $em->persist($category); @@ -408,7 +408,7 @@ if (false === api_get_configuration_value('allow_exercise_categories')) { $up = Display::url(Display::return_icon('up_na.png'), '#'); } $down = Display::url($downIcon, $modifyUrl.'&action=down_category&category_id_edit='.$categoryIdItem); - ++$counter; + $counter++; if ($total === $counter) { $down = Display::url(Display::return_icon('down_na.png'), '#'); } diff --git a/public/main/exercise/exercise_reminder.php b/public/main/exercise/exercise_reminder.php index d0a26072a6..01d01b56f7 100644 --- a/public/main/exercise/exercise_reminder.php +++ b/public/main/exercise/exercise_reminder.php @@ -222,7 +222,7 @@ foreach ($question_list as $questionId) {
'; - ++$counter; + $counter++; $questionTitle = $counter.'. '.strip_tags($objQuestionTmp->selectTitle()); // Check if the question doesn't have an answer if (!in_array($questionId, $exercise_result)) { diff --git a/public/main/exercise/exercise_report.php b/public/main/exercise/exercise_report.php index b835cba162..5fd76716e4 100644 --- a/public/main/exercise/exercise_report.php +++ b/public/main/exercise/exercise_report.php @@ -184,7 +184,7 @@ if (isset($_REQUEST['comments']) && $array_content_id_exe = $post_content_id; } - for ($i = 0; $i < $loop_in_track; ++$i) { + for ($i = 0; $i < $loop_in_track; $i++) { $my_marks = isset($_POST['marks_'.$array_content_id_exe[$i]]) ? $_POST['marks_'.$array_content_id_exe[$i]] : ''; $my_comments = ''; if (isset($_POST['comments_'.$array_content_id_exe[$i]])) { diff --git a/public/main/exercise/exercise_result.class.php b/public/main/exercise/exercise_result.class.php index 059bd39c37..948bfe5dda 100644 --- a/public/main/exercise/exercise_result.class.php +++ b/public/main/exercise/exercise_result.class.php @@ -6,7 +6,6 @@ * Class ExerciseResult * which allows you to export exercises results in multiple presentation forms. * - * * @author Yannick Warnier */ class ExerciseResult @@ -238,7 +237,7 @@ class ExerciseResult } $userWithResults[$result['excruid']] = 1; - ++$i; + $i++; } } @@ -277,7 +276,7 @@ class ExerciseResult $return[$i]['lp_name'] = null; $return[$i]['is_user_subscribed'] = get_lang('Yes'); - ++$latestId; + $latestId++; } } } @@ -628,7 +627,7 @@ class ExerciseResult $list[$column][] = $row['status']; $list[$column][] = $row['lp_name']; $list[$column][] = $row['is_user_subscribed']; - ++$column; + $column++; } Export::arrayToXls($list, $filename); diff --git a/public/main/exercise/exercise_result.php b/public/main/exercise/exercise_result.php index 6a8deb664e..81c3e929d4 100644 --- a/public/main/exercise/exercise_result.php +++ b/public/main/exercise/exercise_result.php @@ -10,7 +10,6 @@ use ChamiloSession as Session; * that exercise. * Then it shows the results on the screen. * - * * @author Olivier Brouckaert, main author * @author Roan Embrechts, some refactoring * @author Julio Montoya switchable fill in blank option added @@ -158,7 +157,7 @@ if ($objExercise->selectAttempts() > 0) { } exit; } else { - ++$attempt_count; + $attempt_count++; $remainingAttempts = $objExercise->selectAttempts() - $attempt_count; if ($remainingAttempts) { $attemptMessage = sprintf(get_lang('Remaining %d attempts'), $remainingAttempts); diff --git a/public/main/exercise/exercise_show.php b/public/main/exercise/exercise_show.php index 5ae359e749..2f6b8d17ff 100644 --- a/public/main/exercise/exercise_show.php +++ b/public/main/exercise/exercise_show.php @@ -716,7 +716,7 @@ foreach ($questionList as $questionId) { ); if (empty($model)) { - for ($i = 0; $i <= $questionWeighting; ++$i) { + for ($i = 0; $i <= $questionWeighting; $i++) { $attributes = []; if ($questionScore == $i) { $attributes['selected'] = 'selected'; @@ -839,12 +839,12 @@ foreach ($questionList as $questionId) { ]; $check = $objQuestionTmp->isQuestionWaitingReview($scoreToReview); if (false === $check) { - ++$countPendingQuestions; + $countPendingQuestions++; } } unset($objAnswerTmp); - ++$i; + $i++; $contents = ob_get_clean(); $question_content = '
'; @@ -857,7 +857,7 @@ foreach ($questionList as $questionId) { $score ); } - ++$counter; + $counter++; $question_content .= $contents; $question_content .= '
'; $exercise_content .= Display::panel($question_content); diff --git a/public/main/exercise/exercise_submit.php b/public/main/exercise/exercise_submit.php index 04b863264f..c6b498282d 100644 --- a/public/main/exercise/exercise_submit.php +++ b/public/main/exercise/exercise_submit.php @@ -20,7 +20,6 @@ use ChamiloSession as Session; * Notice : This script is also used to show a question before modifying it by * the administrator * - * * @author Olivier Brouckaert * @author Julio Montoya * Fill in blank option added (2008) @@ -432,7 +431,7 @@ if (empty($exercise_stat_info)) { if ($last['question_id'] == $question) { break; } - ++$count; + $count++; } $current_question = $count; } @@ -762,7 +761,7 @@ if (null === $current_question) { $current_question = $objExercise->getPositionInCompressedQuestionList($latestQuestionId); } } else { - ++$current_question; + $current_question++; } if (0 != $question_count) { @@ -988,8 +987,8 @@ if (2 == $reminder) { if (!empty($myRemindList)) { // Checking which questions we are going to call from the remind list - for ($i = 0; $i < count($data_tracking); ++$i) { - for ($j = 0; $j < count($myRemindList); ++$j) { + for ($i = 0; $i < count($data_tracking); $i++) { + for ($j = 0; $j < count($myRemindList); $j++) { if (!empty($remind_question_id)) { if ($remind_question_id == $myRemindList[$j]) { if ($remind_question_id == $data_tracking[$i]) { @@ -1053,7 +1052,7 @@ if (!empty($error)) { $i = 0; if (!empty($questionList)) { foreach ($questionList as $questionId) { - ++$i; + $i++; $objQuestionTmp = Question::read($questionId); // for sequential exercises @@ -1065,7 +1064,7 @@ if (!empty($error)) { if (HOT_SPOT == $objQuestionTmp->selectType() || HOT_SPOT_DELINEATION == $objQuestionTmp->selectType() ) { - ++$number_of_hotspot_questions; + $number_of_hotspot_questions++; } break; @@ -1074,7 +1073,7 @@ if (!empty($error)) { if (HOT_SPOT == $objQuestionTmp->selectType() || HOT_SPOT_DELINEATION == $objQuestionTmp->selectType() ) { - ++$number_of_hotspot_questions; + $number_of_hotspot_questions++; } } } @@ -1396,7 +1395,7 @@ if (!empty($error)) { if (ONE_PER_PAGE == $objExercise->type) { // if it is not the right question, goes to the next loop iteration if ($current_question != $i) { - ++$i; + $i++; continue; } else { @@ -1409,7 +1408,7 @@ if (!empty($error)) { // destruction of the Question object unset($objQuestionTmp); echo Display::return_message(get_lang('You already answered the question')); - ++$i; + $i++; break; } @@ -1564,7 +1563,7 @@ if (!empty($error)) { echo Display::div($exerciseActions, ['class' => 'form-actions']); echo '
'; - ++$i; + $i++; // for sequential exercises if (ONE_PER_PAGE == $objExercise->type) { // quits the loop diff --git a/public/main/exercise/exercise_submit_modal.php b/public/main/exercise/exercise_submit_modal.php index af3a0b1377..17338dcc93 100644 --- a/public/main/exercise/exercise_submit_modal.php +++ b/public/main/exercise/exercise_submit_modal.php @@ -357,7 +357,7 @@ if (!empty($links)) { echo '
'.$links.'
'; echo '
'; } else { - ++$questionNum; + $questionNum++; echo ''; diff --git a/public/main/exercise/export/aiken/aiken_import.inc.php b/public/main/exercise/export/aiken/aiken_import.inc.php index 865b592247..eb78809a50 100644 --- a/public/main/exercise/export/aiken/aiken_import.inc.php +++ b/public/main/exercise/export/aiken/aiken_import.inc.php @@ -209,7 +209,7 @@ function aiken_import_exercise($file) } foreach ($question_array['answer'] as $key => $answers) { - ++$key; + $key++; $answer->new_answer[$key] = $answers['value']; $answer->new_position[$key] = $key; $answer->new_comment[$key] = ''; @@ -359,7 +359,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) return 'ExerciseAikenErrorNoAnswerOptionGiven'; } - ++$question_index; + $question_index++; //emptying answers array when moving to next question $answers_array = []; $new_question = true; diff --git a/public/main/exercise/export/exercise_import.inc.php b/public/main/exercise/export/exercise_import.inc.php index 7cfdcf7804..07ee69e9b4 100644 --- a/public/main/exercise/export/exercise_import.inc.php +++ b/public/main/exercise/export/exercise_import.inc.php @@ -225,7 +225,7 @@ function import_exercise($file) $i = $split[1]; } else { $i = $j; - ++$j; + $j++; $matchAnswerIds[$key] = $j; } @@ -455,7 +455,7 @@ function parseQti2($xmlData) if (!isset($currentMatchSet)) { $currentMatchSet = 1; } else { - ++$currentMatchSet; + $currentMatchSet++; } $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentMatchSet] = []; @@ -707,7 +707,7 @@ function qtiProcessManifest($filePath) ]; $tableDocuments = Database::get_course_table(TABLE_DOCUMENT); $countResources = count($xml->resources->resource->file); - for ($i = 0; $i < $countResources; ++$i) { + for ($i = 0; $i < $countResources; $i++) { $file = $xml->resources->resource->file[$i]; $href = ''; foreach ($file->attributes() as $key => $value) { diff --git a/public/main/exercise/export/qti2/qti2_classes.php b/public/main/exercise/export/qti2/qti2_classes.php index 6cfd9644bf..3119441ba9 100644 --- a/public/main/exercise/export/qti2/qti2_classes.php +++ b/public/main/exercise/export/qti2/qti2_classes.php @@ -253,7 +253,7 @@ class ImsAnswerMatching extends Answer implements ImsAnswerInterface $out .= ' '."\n"; - ++$i; + $i++; } } $out .= ' '."\n"; @@ -277,7 +277,7 @@ class ImsAnswerMatching extends Answer implements ImsAnswerInterface $out .= ' left_'.$leftKey.' right_'.$i.''."\n"; $gradeArray['left_'.$leftKey.' right_'.$i] = $leftElement['grade']; } - ++$i; + $i++; } } } diff --git a/public/main/exercise/export/qti2/qti2_export.php b/public/main/exercise/export/qti2/qti2_export.php index 9996af46b6..404c7ad1c1 100644 --- a/public/main/exercise/export/qti2/qti2_export.php +++ b/public/main/exercise/export/qti2/qti2_export.php @@ -106,7 +106,6 @@ class ImsAssessmentItem * * This is a default behaviour, some classes may want to override this. * - * * @return string string, the XML flow for an Item */ public function export($standalone = false) @@ -392,7 +391,6 @@ class ImsItem * * This is a default behaviour, some classes may want to override this. * - * * @return string string, the XML flow for an Item * * @author Amand Tihon diff --git a/public/main/exercise/export/scorm/ScormAnswerFillInBlanks.php b/public/main/exercise/export/scorm/ScormAnswerFillInBlanks.php index c2e1011a56..616e1860ce 100644 --- a/public/main/exercise/export/scorm/ScormAnswerFillInBlanks.php +++ b/public/main/exercise/export/scorm/ScormAnswerFillInBlanks.php @@ -29,7 +29,7 @@ class ScormAnswerFillInBlanks extends Answer // display empty [input] with the right width for student to fill it $answer = ''; $answerList = []; - for ($i = 0; $i < count($listAnswerInfo['common_words']) - 1; ++$i) { + for ($i = 0; $i < count($listAnswerInfo['common_words']) - 1; $i++) { // display the common words $answer .= $listAnswerInfo['common_words'][$i]; // display the blank word diff --git a/public/main/exercise/export/scorm/ScormAnswerMatching.php b/public/main/exercise/export/scorm/ScormAnswerMatching.php index 8dfe3fec39..e1572a5819 100644 --- a/public/main/exercise/export/scorm/ScormAnswerMatching.php +++ b/public/main/exercise/export/scorm/ScormAnswerMatching.php @@ -29,7 +29,7 @@ class ScormAnswerMatching extends Answer // Options (A, B, C, ...) that will be put into the list-box $options = []; $letter = 'A'; - for ($answerId = 1; $answerId <= $nbrAnswers; ++$answerId) { + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $answerCorrect = $this->isCorrect($answerId); $answer = $this->selectAnswer($answerId); $realAnswerId = $this->selectAutoId($answerId); @@ -37,7 +37,7 @@ class ScormAnswerMatching extends Answer $options[$realAnswerId]['Lettre'] = $letter; // answers that will be shown at the right side $options[$realAnswerId]['Reponse'] = $answer; - ++$letter; + $letter++; } } @@ -46,7 +46,7 @@ class ScormAnswerMatching extends Answer $jstmpc = ''; // Answers - for ($answerId = 1; $answerId <= $nbrAnswers; ++$answerId) { + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $identifier = 'question_'.$questionId.'_matching_'; $answer = $this->selectAnswer($answerId); $answerCorrect = $this->isCorrect($answerId); @@ -80,7 +80,7 @@ class ScormAnswerMatching extends Answer $weight = $myWeight[0]; } $jstmpw .= 'questions_answers_ponderation['.$questionId.']['.$counter.'] = '.$weight.";\n"; - ++$counter; + $counter++; } } diff --git a/public/main/exercise/export/scorm/ScormAnswerMultipleChoice.php b/public/main/exercise/export/scorm/ScormAnswerMultipleChoice.php index b73fa94672..10c5bf46cd 100644 --- a/public/main/exercise/export/scorm/ScormAnswerMultipleChoice.php +++ b/public/main/exercise/export/scorm/ScormAnswerMultipleChoice.php @@ -45,7 +45,7 @@ class ScormAnswerMultipleChoice extends Answer } $jstmpw .= 'questions_answers_ponderation['.$questionId.']['.$i.'] = '.$this->weighting[$i].';'; $jstmpw .= 'questions_answers_correct['.$questionId.']['.$i.'] = '.$this->correct[$i].';'; - ++$id; + $id++; } $js[] = 'questions_answers['.$questionId.'] = new Array('.substr($jstmp, 0, -1).');'."\n"; $js[] = 'questions_types['.$questionId.'] = \'mcma\';'."\n"; @@ -73,7 +73,7 @@ class ScormAnswerMultipleChoice extends Answer } $jstmpw .= 'questions_answers_ponderation['.$questionId.']['.$i.'] = '.$this->weighting[$i].';'; $jstmpw .= 'questions_answers_correct['.$questionId.']['.$i.'] = '.$this->correct[$i].';'; - ++$id; + $id++; } $js[] = 'questions_answers['.$questionId.'] = new Array('.substr($jstmp, 0, -1).');'; $js[] = 'questions_types['.$questionId.'] = "exact";'; @@ -100,7 +100,7 @@ class ScormAnswerMultipleChoice extends Answer } $jstmpw .= 'questions_answers_ponderation['.$questionId.']['.$i.'] = '.$this->weighting[$i].';'; $jstmpw .= 'questions_answers_correct['.$questionId.']['.$i.'] = '.$this->correct[$i].';'; - ++$id; + $id++; } $js[] = 'questions_answers['.$questionId.'] = new Array('.substr($jstmp, 0, -1).');'; $js[] = 'questions_types['.$questionId.'] = \'mcua\';'; diff --git a/public/main/exercise/export/scorm/ScormExercise.php b/public/main/exercise/export/scorm/ScormExercise.php index 37a86f7815..1c05886683 100644 --- a/public/main/exercise/export/scorm/ScormExercise.php +++ b/public/main/exercise/export/scorm/ScormExercise.php @@ -115,7 +115,6 @@ class ScormExercise * * This is a default behaviour, some classes may want to override this. * - * * @return string string, the XML flow for an Item */ public function export() @@ -173,7 +172,7 @@ class ScormExercise list($jstmp, $htmltmp) = $scormQuestion->exportQuestionToScorm($q, $counter); $js .= $jstmp."\n"; $html .= $htmltmp."\n"; - ++$counter; + $counter++; } return [$js, $html]; diff --git a/public/main/exercise/export/scorm/scorm_classes.php b/public/main/exercise/export/scorm/scorm_classes.php index 696b437d0d..6518221722 100644 --- a/public/main/exercise/export/scorm/scorm_classes.php +++ b/public/main/exercise/export/scorm/scorm_classes.php @@ -109,7 +109,7 @@ class ScormAnswerHotspot extends Answer border: 1px solid #4271b5; height: 448px; width: 200px;">'.get_lang('Image zones').'
    '; - for ($answerId = 1; $answerId <= $nbrAnswers; ++$answerId) { + for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { $answerList .= '
  1. '.$this->selectAnswer($answerId).'
  2. '; } $answerList .= '
'; diff --git a/public/main/exercise/fill_blanks.class.php b/public/main/exercise/fill_blanks.class.php index ff15aa865b..58803f885b 100644 --- a/public/main/exercise/fill_blanks.class.php +++ b/public/main/exercise/fill_blanks.class.php @@ -429,7 +429,7 @@ class FillBlanks extends Question if ($nb > 0) { $answer .= '::'; // weighting - for ($i = 0; $i < $nb; ++$i) { + for ($i = 0; $i < $nb; $i++) { // enter the weighting of word $i $answer .= $form->getSubmitValue('weighting['.$i.']'); // not the last word, add "," @@ -442,7 +442,7 @@ class FillBlanks extends Question // input width $answer .= ':'; - for ($i = 0; $i < $nb; ++$i) { + for ($i = 0; $i < $nb; $i++) { // enter the width of input for word $i $answer .= $form->getSubmitValue('sizeofinput['.$i.']'); // not the last word, add "," @@ -754,7 +754,7 @@ class FillBlanks extends Question if (count($listDetails) < 3) { $listWeightings = explode(',', $listDetails[0]); $listSizeOfInput = []; - for ($i = 0; $i < count($listWeightings); ++$i) { + for ($i = 0; $i < count($listWeightings); $i++) { $listSizeOfInput[] = 200; } $blankSeparatorNumber = 0; // 0 is [...] @@ -791,7 +791,7 @@ class FillBlanks extends Question $listWords[0], function (&$value, $key, $tabBlankChar) { $trimChars = ''; - for ($i = 0; $i < count($tabBlankChar); ++$i) { + for ($i = 0; $i < count($tabBlankChar); $i++) { $trimChars .= $tabBlankChar[$i]; } $value = trim($value, $trimChars); @@ -813,17 +813,17 @@ class FillBlanks extends Question $listBrackets = []; $listWords = []; if ($isStudentAnswer) { - for ($i = 0; $i < count($listAnswerResults['words']); ++$i) { + for ($i = 0; $i < count($listAnswerResults['words']); $i++) { $listBrackets[] = $listAnswerResults['words_with_bracket'][$i]; $listWords[] = $listAnswerResults['words'][$i]; if ($i + 1 < count($listAnswerResults['words'])) { // should always be - ++$i; + $i++; } $listAnswerResults['student_answer'][] = $listAnswerResults['words'][$i]; if ($i + 1 < count($listAnswerResults['words'])) { // should always be - ++$i; + $i++; } $listAnswerResults['student_score'][] = $listAnswerResults['words'][$i]; } @@ -963,7 +963,7 @@ class FillBlanks extends Question // for each bracket, if student has at least one answer ( choice > -2) then he pass the question foreach ($list as $choice) { if ($choice > -2 && !$found) { - ++$outRes; + $outRes++; $found = true; } } @@ -985,7 +985,7 @@ class FillBlanks extends Question $separatorEnd = $listWithStudentAnswer['blank_separator_end']; // lets rebuild the sentence with [correct answer][student answer][answer is correct] $result = ''; - for ($i = 0; $i < count($listWithStudentAnswer['common_words']) - 1; ++$i) { + for ($i = 0; $i < count($listWithStudentAnswer['common_words']) - 1; $i++) { $answerValue = null; if (isset($listWithStudentAnswer['student_answer'][$i])) { $answerValue = $listWithStudentAnswer['student_answer'][$i]; @@ -1142,7 +1142,7 @@ class FillBlanks extends Question // rebuild the answer with good HTML style // this is the student answer, right or wrong - for ($i = 0; $i < count($listStudentAnswerInfo['student_answer']); ++$i) { + for ($i = 0; $i < count($listStudentAnswerInfo['student_answer']); $i++) { if (1 == $listStudentAnswerInfo['student_score'][$i]) { $listStudentAnswerInfo['student_answer'][$i] = self::getHtmlRightAnswer( $listStudentAnswerInfo['student_answer'][$i], @@ -1163,7 +1163,7 @@ class FillBlanks extends Question } // rebuild the sentence with student answer inserted - for ($i = 0; $i < count($listStudentAnswerInfo['common_words']); ++$i) { + for ($i = 0; $i < count($listStudentAnswerInfo['common_words']); $i++) { $result .= isset($listStudentAnswerInfo['common_words'][$i]) ? $listStudentAnswerInfo['common_words'][$i] : ''; $studentLabel = isset($listStudentAnswerInfo['student_answer'][$i]) ? $listStudentAnswerInfo['student_answer'][$i] : ''; $result .= $studentLabel; @@ -1233,7 +1233,7 @@ class FillBlanks extends Question $listPossibleAnswers = self::getFillTheBlankMenuAnswers($correct, false); $correctAnswerHtml .= "".$listPossibleAnswers[0].''; $correctAnswerHtml .= ' ('; - for ($i = 1; $i < count($listPossibleAnswers); ++$i) { + for ($i = 1; $i < count($listPossibleAnswers); $i++) { $correctAnswerHtml .= $listPossibleAnswers[$i]; if ($i != count($listPossibleAnswers) - 1) { $correctAnswerHtml .= ' | '; diff --git a/public/main/exercise/global_multiple_answer.class.php b/public/main/exercise/global_multiple_answer.class.php index 5ea69568f3..8068f8006f 100644 --- a/public/main/exercise/global_multiple_answer.class.php +++ b/public/main/exercise/global_multiple_answer.class.php @@ -76,7 +76,7 @@ class GlobalMultipleAnswer extends Question $scoreG = 0; //Global /* boucle pour sauvegarder les donn�es dans le tableau defaults */ - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { /* si la reponse est de type objet */ if (is_object($answer)) { $defaults['answer['.$i.']'] = $answer->answer[$i]; @@ -209,10 +209,10 @@ class GlobalMultipleAnswer extends Question // Reponses correctes $nbr_corrects = 0; - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $goodAnswer = trim($form->getSubmitValue('correct['.$i.']')); if ($goodAnswer) { - ++$nbr_corrects; + $nbr_corrects++; } } // Set question weighting (score total) @@ -228,7 +228,7 @@ class GlobalMultipleAnswer extends Question // cr�ation variable pour r�cuperer la valeur de la coche pour la prise en compte des n�gatifs $test = $form->getSubmitValue('pts'); - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $answer = trim($form->getSubmitValue('answer['.$i.']')); $comment = trim($form->getSubmitValue('comment['.$i.']')); $goodAnswer = trim($form->getSubmitValue('correct['.$i.']')); diff --git a/public/main/exercise/hotspot_actionscript.as.php b/public/main/exercise/hotspot_actionscript.as.php index 216b0c0721..79a9928b2d 100644 --- a/public/main/exercise/hotspot_actionscript.as.php +++ b/public/main/exercise/hotspot_actionscript.as.php @@ -117,7 +117,7 @@ while ($hotspot = Database::fetch_assoc($result)) { // This is a good answer, count + 1 for nmbr of clicks if ($hotspot['hotspot_type'] > 0) { - ++$nmbrTries; + $nmbrTries++; } $hotSpot['coord'] = $hotspot['hotspot_coordinates']; diff --git a/public/main/exercise/hotspot_actionscript_admin.as.php b/public/main/exercise/hotspot_actionscript_admin.as.php index ddd212f430..866b62c080 100644 --- a/public/main/exercise/hotspot_actionscript_admin.as.php +++ b/public/main/exercise/hotspot_actionscript_admin.as.php @@ -9,7 +9,6 @@ use ChamiloSession as Session; /** * This file generates the ActionScript variables code used by the HotSpot .swf. * - * * @author Toon Keppens */ require_once __DIR__.'/../inc/global.inc.php'; @@ -67,7 +66,7 @@ $answer_type = $objQuestion->getType(); $answers = Session::read('tmp_answers'); $nbrAnswers = count($answers['answer']); -for ($i = 1; $i <= $nbrAnswers; ++$i) { +for ($i = 1; $i <= $nbrAnswers; $i++) { $hotSpot = []; $hotSpot['id'] = null; $hotSpot['answer'] = $answers['answer'][$i]; @@ -102,7 +101,7 @@ for ($i = 1; $i <= $nbrAnswers; ++$i) { // This is a good answer, count + 1 for nmbr of clicks if ($answers['weighting'][$i] > 0) { - ++$nmbrTries; + $nmbrTries++; } $hotSpot['coord'] = $answers['hotspot_coordinates'][$i]; diff --git a/public/main/exercise/hotspot_admin.inc.php b/public/main/exercise/hotspot_admin.inc.php index 6444551402..67cfcc1116 100644 --- a/public/main/exercise/hotspot_admin.inc.php +++ b/public/main/exercise/hotspot_admin.inc.php @@ -7,7 +7,6 @@ use ChamiloSession as Session; * This script allows to manage answers. It is included from the * script admin.php. * - * * @author Toon Keppens */ $modifyAnswers = (int) $_GET['hotspotadmin']; @@ -75,7 +74,7 @@ if ($submitAnswers || $buttonBack) { echo '$submitAnswers or $buttonBack was set'."
\n"; } $questionWeighting = $nbrGoodAnswers = 0; - for ($i = 1; $i <= $nbrAnswers; ++$i) { + for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { echo str_repeat(' ', 4).'$answerType is HOT_SPOT'."
\n"; } @@ -112,7 +111,7 @@ if ($submitAnswers || $buttonBack) { } // end for() if (empty($msgErr)) { - for ($i = 1; $i <= $nbrAnswers; ++$i) { + for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { echo str_repeat(' ', 4).'$answerType is HOT_SPOT'."
\n"; } @@ -167,7 +166,7 @@ if ($submitAnswers || $buttonBack) { $threadhold2 = $_POST['threadhold2']; $threadhold3 = $_POST['threadhold3']; - for ($i = 1; $i <= $nbrAnswers; ++$i) { + for ($i = 1; $i <= $nbrAnswers; $i++) { $reponse[$i] = trim($reponse[$i]); $comment[$i] = trim($comment[$i]); $weighting[$i] = $weighting[$i]; @@ -279,7 +278,7 @@ if ($submitAnswers || $buttonBack) { $destination_noerror = $threadhold_total.'@@'.$try_str.'@@'.$lp_str.'@@'.$question_str.'@@'.$url_str; if (empty($msgErr)) { - for ($i = 1; $i <= $nbrAnswers; ++$i) { + for ($i = 1; $i <= $nbrAnswers; $i++) { if ($debug > 0) { echo str_repeat(' ', 4).'$answerType is HOT_SPOT'."
\n"; } @@ -345,7 +344,7 @@ if (isset($modifyAnswers)) { if (HOT_SPOT_DELINEATION == $answerType) { $try = isset($_POST['try']) ? $_POST['try'] : []; - for ($i = 1; $i <= $nbrAnswers; ++$i) { + for ($i = 1; $i <= $nbrAnswers; $i++) { if (isset($try[$i]) && 'on' == $try[$i]) { $try[$i] = 1; } else { @@ -366,7 +365,7 @@ if (isset($modifyAnswers)) { // the magic happens here ... // we do this to not count the if no error section if ($nbrAnswers >= 2) { - --$nbrAnswers; + $nbrAnswers--; } } @@ -378,7 +377,7 @@ if (isset($modifyAnswers)) { $destination_items = []; $destination = []; - for ($i = 1; $i <= $nbrAnswers; ++$i) { + for ($i = 1; $i <= $nbrAnswers; $i++) { $reponse[$i] = $objAnswer->selectAnswer($i); if (EXERCISE_FEEDBACK_TYPE_EXAM != $objExercise->getFeedbackType()) { @@ -448,7 +447,7 @@ if (isset($modifyAnswers)) { $lest_answer = 1; // At least 1 answer if ($nbrAnswers > $lest_answer) { - --$nbrAnswers; + $nbrAnswers--; // Remove the last answer $tmp = array_pop($_SESSION['tmp_answers']['answer']); $tmp = array_pop($_SESSION['tmp_answers']['comment']); @@ -465,7 +464,7 @@ if (isset($modifyAnswers)) { } else { // At least 1 answer if ($nbrAnswers > 1) { - --$nbrAnswers; + $nbrAnswers--; // Remove the last answer $tmp = array_pop($_SESSION['tmp_answers']['answer']); if (EXERCISE_FEEDBACK_TYPE_EXAM != $objExercise->getFeedbackType()) { @@ -484,7 +483,7 @@ if (isset($modifyAnswers)) { if ($moreAnswers) { if ($nbrAnswers < 12) { - ++$nbrAnswers; + $nbrAnswers++; // Add a new answer $_SESSION['tmp_answers']['answer'][] = ''; @@ -505,7 +504,7 @@ if (isset($modifyAnswers)) { if ($moreOARAnswers) { if ($nbrAnswers < 12) { // Add a new answer - ++$nbrAnswers; + $nbrAnswers++; $_SESSION['tmp_answers']['answer'][] = ''; $_SESSION['tmp_answers']['comment'][] = ''; @@ -626,7 +625,7 @@ if (isset($modifyAnswers)) { // Loading list of LPs $flat_list = $list->get_flat_list(); - for ($i = 1; $i <= $nbrAnswers; ++$i) { + for ($i = 1; $i <= $nbrAnswers; $i++) { // is an delineation if (HOT_SPOT_DELINEATION == $answerType) { $option_lp = ''; @@ -676,7 +675,7 @@ if (isset($modifyAnswers)) { //-------- IF it is a delineation if ('delineation' == $_SESSION['tmp_answers']['hotspot_type'][$i]) { $option1 = $option2 = $option3 = ''; - for ($k = 1; $k <= 100; ++$k) { + for ($k = 1; $k <= 100; $k++) { $selected1 = $selected2 = $selected3 = ''; if ($k == $threadhold1[$i]) { $selected1 = 'selected="selected"'; diff --git a/public/main/exercise/hotspot_answers.as.php b/public/main/exercise/hotspot_answers.as.php index d41819ef58..c1d23a1bab 100644 --- a/public/main/exercise/hotspot_answers.as.php +++ b/public/main/exercise/hotspot_answers.as.php @@ -10,7 +10,6 @@ use Chamilo\CourseBundle\Entity\CQuizQuestion; /** * This file generates a json answer to the question preview. * - * * @author Toon Keppens, Julio Montoya adding hotspot "medical" support */ require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/exercise/hotspot_save.inc.php b/public/main/exercise/hotspot_save.inc.php index fc05b9e562..f48a8e6c36 100644 --- a/public/main/exercise/hotspot_save.inc.php +++ b/public/main/exercise/hotspot_save.inc.php @@ -31,7 +31,7 @@ if ('poly' == $_GET['type'] || 'delineation' == $_GET['type'] || 'oar' == $_GET[ $delimiter = '|'; } $hotspot_coordinates .= $coord.$delimiter; - ++$i; + $i++; } $hotspot_coordinates = api_substr($hotspot_coordinates, 0, -2); } diff --git a/public/main/exercise/hotspot_savescore.inc.php b/public/main/exercise/hotspot_savescore.inc.php index 3fc053afd1..60939b774c 100644 --- a/public/main/exercise/hotspot_savescore.inc.php +++ b/public/main/exercise/hotspot_savescore.inc.php @@ -7,7 +7,6 @@ use ChamiloSession as Session; /** * This file saves every click in the hotspot tool into track_e_hotspots. * - * * @author Toon Keppens * * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ diff --git a/public/main/exercise/hotspot_updatescore.inc.php b/public/main/exercise/hotspot_updatescore.inc.php index 5b0b82b36f..7b139a2d7b 100644 --- a/public/main/exercise/hotspot_updatescore.inc.php +++ b/public/main/exercise/hotspot_updatescore.inc.php @@ -7,7 +7,6 @@ use ChamiloSession as Session; /** * This file saves every click in the hotspot tool into track_e_hotspots. * - * * @author Toon Keppens * * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ diff --git a/public/main/exercise/matching.class.php b/public/main/exercise/matching.class.php index ad3339e892..9f6cdd4093 100644 --- a/public/main/exercise/matching.class.php +++ b/public/main/exercise/matching.class.php @@ -39,11 +39,11 @@ class Matching extends Question $answer = new Answer($this->id); $answer->read(); if ($answer->nbrAnswers > 0) { - for ($i = 1; $i <= $answer->nbrAnswers; ++$i) { + for ($i = 1; $i <= $answer->nbrAnswers; $i++) { $correct = $answer->isCorrect($i); if (empty($correct)) { $matches[$answer->selectAutoId($i)] = chr(64 + $counter); - ++$counter; + $counter++; } } } @@ -53,24 +53,24 @@ class Matching extends Question $nb_matches = $form->getSubmitValue('nb_matches'); $nb_options = $form->getSubmitValue('nb_options'); if (isset($_POST['lessOptions'])) { - --$nb_matches; - --$nb_options; + $nb_matches--; + $nb_options--; } if (isset($_POST['moreOptions'])) { - ++$nb_matches; - ++$nb_options; + $nb_matches++; + $nb_options++; } } elseif (!empty($this->id)) { if ($answer->nbrAnswers > 0) { $nb_matches = $nb_options = 0; - for ($i = 1; $i <= $answer->nbrAnswers; ++$i) { + for ($i = 1; $i <= $answer->nbrAnswers; $i++) { if ($answer->isCorrect($i)) { - ++$nb_matches; + $nb_matches++; $defaults['answer['.$nb_matches.']'] = $answer->selectAnswer($i); $defaults['weighting['.$nb_matches.']'] = float_format($answer->selectWeighting($i), 1); $defaults['matches['.$nb_matches.']'] = $answer->correct[$i]; } else { - ++$nb_options; + $nb_options++; $defaults['option['.$nb_options.']'] = $answer->selectAnswer($i); } } @@ -84,12 +84,12 @@ class Matching extends Question } if (empty($matches)) { - for ($i = 1; $i <= $nb_options; ++$i) { + for ($i = 1; $i <= $nb_options; $i++) { // fill the array with A, B, C..... $matches[$i] = chr(64 + $i); } } else { - for ($i = $counter; $i <= $nb_options; ++$i) { + for ($i = $counter; $i <= $nb_options; $i++) { // fill the array with A, B, C..... $matches[$i] = chr(64 + $i); } @@ -126,7 +126,7 @@ class Matching extends Question 'Height' => '125', ]; - for ($i = 1; $i <= $nb_matches; ++$i) { + for ($i = 1; $i <= $nb_matches; $i++) { $renderer = &$form->defaultRenderer(); $renderer->setElementTemplate( '{error}{element}', @@ -189,7 +189,7 @@ class Matching extends Question ); } - for ($i = 1; $i <= $nb_options; ++$i) { + for ($i = 1; $i <= $nb_options; $i++) { $renderer = &$form->defaultRenderer(); $renderer->setElementTemplate( '{error}{element}', @@ -244,15 +244,15 @@ class Matching extends Question $objAnswer = new Answer($this->id); // Insert the options - for ($i = 1; $i <= $nb_options; ++$i) { - ++$position; + for ($i = 1; $i <= $nb_options; $i++) { + $position++; $option = $form->getSubmitValue('option['.$i.']'); $objAnswer->createAnswer($option, 0, '', 0, $position); } // Insert the answers - for ($i = 1; $i <= $nb_matches; ++$i) { - ++$position; + for ($i = 1; $i <= $nb_matches; $i++) { + $position++; $answer = $form->getSubmitValue('answer['.$i.']'); $matches = $form->getSubmitValue('matches['.$i.']'); $weighting = $form->getSubmitValue('weighting['.$i.']'); diff --git a/public/main/exercise/multiple_answer.class.php b/public/main/exercise/multiple_answer.class.php index 5cdd10883e..2168db63c1 100644 --- a/public/main/exercise/multiple_answer.class.php +++ b/public/main/exercise/multiple_answer.class.php @@ -76,7 +76,7 @@ class MultipleAnswer extends Question echo Display::return_message(get_lang('You have to create at least one answer')); } - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $form->addHtml(''); if (is_object($answer)) { $defaults['answer['.$i.']'] = $answer->answer[$i]; @@ -187,7 +187,7 @@ class MultipleAnswer extends Question $objAnswer = new Answer($this->id); $nb_answers = $form->getSubmitValue('nb_answers'); - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $answer = trim(str_replace(['

', '

'], '', $form->getSubmitValue('answer['.$i.']'))); $comment = trim(str_replace(['

', '

'], '', $form->getSubmitValue('comment['.$i.']'))); $weighting = trim($form->getSubmitValue('weighting['.$i.']')); diff --git a/public/main/exercise/multiple_answer_combination.class.php b/public/main/exercise/multiple_answer_combination.class.php index fd78c1d2ef..e342802767 100644 --- a/public/main/exercise/multiple_answer_combination.class.php +++ b/public/main/exercise/multiple_answer_combination.class.php @@ -68,7 +68,7 @@ class MultipleAnswerCombination extends Question echo Display::return_message(get_lang('You have to create at least one answer')); } - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $form->addHtml(''); if (is_object($answer)) { @@ -181,7 +181,7 @@ class MultipleAnswerCombination extends Question $objAnswer = new Answer($this->id); $nb_answers = $form->getSubmitValue('nb_answers'); - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $answer = trim($form->getSubmitValue('answer['.$i.']')); $comment = trim($form->getSubmitValue('comment['.$i.']')); if (1 == $i) { diff --git a/public/main/exercise/multiple_answer_true_false.class.php b/public/main/exercise/multiple_answer_true_false.class.php index 7731a42ec8..4003fe004b 100644 --- a/public/main/exercise/multiple_answer_true_false.class.php +++ b/public/main/exercise/multiple_answer_true_false.class.php @@ -79,7 +79,7 @@ class MultipleAnswerTrueFalse extends Question // Can be more options $optionData = Question::readQuestionOption($this->id, $course_id); - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $form->addHtml(''); $renderer->setElementTemplate( @@ -118,7 +118,7 @@ class MultipleAnswerTrueFalse extends Question if (!empty($optionData)) { foreach ($optionData as $id => $data) { $form->addElement('radio', 'correct['.$i.']', null, null, $id); - ++$j; + $j++; if (3 == $j) { break; } @@ -206,7 +206,7 @@ class MultipleAnswerTrueFalse extends Question $scores = explode(':', $this->extra); if (!empty($scores)) { - for ($i = 1; $i <= 3; ++$i) { + for ($i = 1; $i <= 3; $i++) { $defaults['option['.$i.']'] = $scores[$i - 1]; } } @@ -249,7 +249,7 @@ class MultipleAnswerTrueFalse extends Question Question::updateQuestionOption($id, $optionData, $course_id); } } else { - for ($i = 1; $i <= 3; ++$i) { + for ($i = 1; $i <= 3; $i++) { $last_id = Question::saveQuestionOption( $this->id, $this->options[$i], @@ -272,13 +272,13 @@ class MultipleAnswerTrueFalse extends Question the true, false, doubt options registered in this format XX:YY:ZZZ where XX is a float score value.*/ $extra_values = []; - for ($i = 1; $i <= 3; ++$i) { + for ($i = 1; $i <= 3; $i++) { $score = trim($form->getSubmitValue('option['.$i.']')); $extra_values[] = $score; } $this->setExtra(implode(':', $extra_values)); - for ($i = 1; $i <= $nb_answers; ++$i) { + for ($i = 1; $i <= $nb_answers; $i++) { $answer = trim($form->getSubmitValue('answer['.$i.']')); $comment = trim($form->getSubmitValue('comment['.$i.']')); $goodAnswer = trim($form->getSubmitValue('correct['.$i.']')); diff --git a/public/main/exercise/oral_expression.class.php b/public/main/exercise/oral_expression.class.php index 5b428d28ae..320b3abfb3 100644 --- a/public/main/exercise/oral_expression.class.php +++ b/public/main/exercise/oral_expression.class.php @@ -72,10 +72,10 @@ class OralExpression extends Question /** * initialize the attributes to generate the file path. * - * @param integer $sessionId - * @param integer $userId - * @param integer $exerciseId - * @param integer $exeId + * @param int $sessionId + * @param int $userId + * @param int $exerciseId + * @param int $exeId */ public function initFile($sessionId, $userId, $exerciseId, $exeId) { @@ -204,7 +204,7 @@ class OralExpression extends Question /** * Tricky stuff to deal with the feedback = 0 in exercises (all question per page). * - * @param integer $exe_id + * @param int $exe_id */ public function replaceWithRealExe($exe_id) { diff --git a/public/main/exercise/overview.php b/public/main/exercise/overview.php index 1010d1aadc..cf4cdb23f6 100644 --- a/public/main/exercise/overview.php +++ b/public/main/exercise/overview.php @@ -294,7 +294,7 @@ if (!empty($attempts)) { $row['attempt_link'] = $attempt_link; } $my_attempt_array[] = $row; - --$i; + $i--; } $header_names = []; @@ -365,7 +365,7 @@ if (!empty($attempts)) { $column = 0; foreach ($header_names as $item) { $table->setHeaderContents(0, $column, $item); - ++$column; + $column++; } $row = 1; if (!empty($my_attempt_array)) { @@ -373,8 +373,8 @@ if (!empty($attempts)) { $column = 0; $table->setCellContents($row, $column, $data); $table->setRowAttributes($row, null, true); - ++$column; - ++$row; + $column++; + $row++; } } $table_content = $table->toHtml(); diff --git a/public/main/exercise/qti2.php b/public/main/exercise/qti2.php index 2ae493f2e7..7f462b05cb 100644 --- a/public/main/exercise/qti2.php +++ b/public/main/exercise/qti2.php @@ -5,7 +5,6 @@ /** * Code for Qti2 import integration. * - * * @author Ronny Velasquez * * @version $Id: qti2.php 2010-03-12 12:14:25Z $ diff --git a/public/main/exercise/question.class.php b/public/main/exercise/question.class.php index 5d8e294b74..4d953187f4 100644 --- a/public/main/exercise/question.class.php +++ b/public/main/exercise/question.class.php @@ -864,7 +864,7 @@ abstract class Question $newExercise = new Exercise($courseId); $newExercise->read($exerciseId, false); $count = $newExercise->getQuestionCount(); - ++$count; + $count++; $sql = "INSERT INTO $exerciseRelQuestionTable (c_id, question_id, exercice_id, question_order) VALUES ({$this->course['real_id']}, ".$id.', '.$exerciseId.", '$count')"; Database::query($sql); diff --git a/public/main/exercise/question_list_admin.inc.php b/public/main/exercise/question_list_admin.inc.php index 588fd4f8f4..7bacd4293f 100644 --- a/public/main/exercise/question_list_admin.inc.php +++ b/public/main/exercise/question_list_admin.inc.php @@ -25,7 +25,7 @@ if ($deleteQuestion) { // if the question has been removed from the exercise if ($objExercise->removeFromList($deleteQuestion)) { - --$nbrQuestions; + $nbrQuestions--; } } // destruction of the Question object @@ -179,7 +179,7 @@ if (!$inATest) { $pagination->setCurrentPageNumber($page); $pagination->renderer = function ($data) use ($url) { $render = '
'; - ++$counter; + $counter++; } } @@ -322,7 +322,7 @@ if (api_is_allowed_to_edit() && $counter > 0) { $table_list .= ''.get_lang('Date changed').''; $table_list .= ''; - for ($i = 0; $i < count($historyList); ++$i) { + for ($i = 0; $i < count($historyList); $i++) { $userInfo = api_get_user_info($historyList[$i]['qualify_user_id']); $table_list .= ''.$userInfo['complete_name'].''; $table_list .= ''.$historyList[$i]['qualify'].''; diff --git a/public/main/forum/index.php b/public/main/forum/index.php index 584b88df77..e568a12571 100644 --- a/public/main/forum/index.php +++ b/public/main/forum/index.php @@ -401,7 +401,7 @@ if (is_array($forumCategories)) { } if ($show_forum) { - ++$form_count; + $form_count++; /*$mywhatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;*/ diff --git a/public/main/forum/viewforum.php b/public/main/forum/viewforum.php index 62a4aa9c9a..bc50c7362a 100644 --- a/public/main/forum/viewforum.php +++ b/public/main/forum/viewforum.php @@ -305,7 +305,7 @@ if ('liststd' == $my_action && .$current_qualify_thread.'">' .Display::return_icon($icon_qualify, get_lang('Grade activity')).''; } - ++$counter_stdlist; + $counter_stdlist++; } } else { if ('qualify' === $listType) { @@ -653,7 +653,7 @@ if (is_array($threads)) { echo $html; } - ++$count; + $count++; } } diff --git a/public/main/forum/viewforumcategory.php b/public/main/forum/viewforumcategory.php index 66d66b62d3..b39a3aa59a 100644 --- a/public/main/forum/viewforumcategory.php +++ b/public/main/forum/viewforumcategory.php @@ -303,7 +303,7 @@ if ('add' != $action) { } $form_count = isset($form_count) ? $form_count : 0; if (true === $show_forum) { - ++$form_count; + $form_count++; $html = '
'; $html .= '
'; $my_whatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null; diff --git a/public/main/forum/viewthread.php b/public/main/forum/viewthread.php index 39969b2fe9..af5b6f5fcf 100644 --- a/public/main/forum/viewthread.php +++ b/public/main/forum/viewthread.php @@ -662,7 +662,7 @@ foreach ($posts as $post) { // The post has been displayed => it can be removed from the what's new array //unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]); //unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]); - ++$count; + $count++; } $template->assign('posts', $postList); diff --git a/public/main/gamification/my_progress.php b/public/main/gamification/my_progress.php index 746a043c22..f74ad71dd0 100644 --- a/public/main/gamification/my_progress.php +++ b/public/main/gamification/my_progress.php @@ -7,8 +7,6 @@ use Chamilo\CoreBundle\Repository\TrackECourseAccessRepository; * See the progress for a user when the gamification mode is active. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.gamification */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -18,7 +16,7 @@ $nameTools = get_lang('Progress'); api_block_anonymous_users(); -if (api_get_setting('gamification_mode') == '0') { +if ('0' == api_get_setting('gamification_mode')) { api_not_allowed(true); } diff --git a/public/main/gradebook/certificate_report.php b/public/main/gradebook/certificate_report.php index 63a4b8bbb9..1a17e5ff9c 100644 --- a/public/main/gradebook/certificate_report.php +++ b/public/main/gradebook/certificate_report.php @@ -5,8 +5,6 @@ * List all certificates filtered by session/course and month/year. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.gradebook */ $cidReset = true; diff --git a/public/main/gradebook/exercise_jump.php b/public/main/gradebook/exercise_jump.php index 3472e58b9e..b2cc2887e6 100644 --- a/public/main/gradebook/exercise_jump.php +++ b/public/main/gradebook/exercise_jump.php @@ -9,8 +9,6 @@ * Most code here is ripped from /main/course_home/course_home.php. * * @author Bert Steppé - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); @@ -57,7 +55,7 @@ if (!empty($doExerciseUrl)) { if ($exercise->exercise_was_added_in_lp) { if (!empty($exercise->lpList)) { $count = count($exercise->lpList); - if ($count == 1) { + if (1 == $count) { // If the exercise was added once redirect to the LP $firstLp = current($exercise->lpList); if (isset($firstLp['lp_id'])) { diff --git a/public/main/gradebook/get_badges.php b/public/main/gradebook/get_badges.php index 1d45d2b247..c5b08fa515 100644 --- a/public/main/gradebook/get_badges.php +++ b/public/main/gradebook/get_badges.php @@ -5,8 +5,6 @@ * Show the achieved badges by an user. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.badge */ require_once __DIR__.'/../inc/global.inc.php'; @@ -45,7 +43,7 @@ foreach ($userSkills as $skill) { $backpack = 'https://backpack.openbadges.org/'; $configBackpack = api_get_setting('openbadges_backpack'); -if (strcmp($backpack, $configBackpack) !== 0) { +if (0 !== strcmp($backpack, $configBackpack)) { $backpack = $configBackpack; } diff --git a/public/main/gradebook/gradebook.php b/public/main/gradebook/gradebook.php index 0e018c6d74..b33720fa06 100644 --- a/public/main/gradebook/gradebook.php +++ b/public/main/gradebook/gradebook.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ // $cidReset : This is the main difference with gradebook.php, here we say, @@ -52,7 +50,7 @@ $filter_warning_msg = true; if (isset($_GET['createallcategories'])) { GradebookUtils::block_students(); $coursecat = Category :: get_not_created_course_categories(api_get_user_id()); - if (!count($coursecat) == 0) { + if (0 == !count($coursecat)) { foreach ($coursecat as $row) { $cat = new Category(); $cat->set_name($row[1]); @@ -92,7 +90,7 @@ if (isset($_GET['movecat'])) { } else { $get_target_cat = Security::remove_XSS($_GET['targetcat']); $targetcat = Category :: load($get_target_cat); - $course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); + $course_to_crsind = (null != $cats[0]->get_course_code() && null == $targetcat[0]->get_course_code()); if (!($course_to_crsind && !isset($_GET['confirm']))) { $cats[0]->move_to_cat($targetcat[0]); @@ -128,7 +126,7 @@ if (isset($_GET['moveeval'])) { } else { $get_target_cat = Security::remove_XSS($_GET['targetcat']); $targetcat = Category :: load($get_target_cat); - $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); + $course_to_crsind = (null != $evals[0]->get_course_code() && null == $targetcat[0]->get_course_code()); if (!($course_to_crsind && !isset($_GET['confirm']))) { $evals[0]->move_to_cat($targetcat[0]); @@ -187,8 +185,8 @@ if (isset($_GET['deletecat'])) { GradebookUtils::block_students(); $cats = Category :: load($_GET['deletecat']); //delete all categories,subcategories and results - if ($cats[0] != null) { - if ($cats[0]->get_id() != 0) { + if (null != $cats[0]) { + if (0 != $cats[0]->get_id()) { // better don't try to delete the root... $cats[0]->delete_all(); } @@ -222,7 +220,7 @@ if (isset($_GET['visibleeval'])) { if (isset($_GET['deleteeval'])) { GradebookUtils::block_students(); $eval = Evaluation :: load($_GET['deleteeval']); - if ($eval[0] != null) { + if (null != $eval[0]) { $eval[0]->delete_with_results(); } $confirmation_message = get_lang('Assessment deleted'); @@ -253,7 +251,7 @@ if (isset($_GET['deletelink'])) { //fixing #5229 if (!empty($_GET['deletelink'])) { $link = LinkFactory:: load($_GET['deletelink']); - if ($link[0] != null) { + if (null != $link[0]) { $link[0]->delete(); } unset($link); @@ -283,7 +281,7 @@ if ($course_to_crsind && !isset($_GET['confirm'])) { if (isset($_POST['action'])) { GradebookUtils::block_students(); $number_of_selected_items = count($_POST['id']); - if ($number_of_selected_items == '0') { + if ('0' == $number_of_selected_items) { $warning_message = get_lang('No resource selected'); $filter_warning_msg = false; } else { @@ -293,25 +291,25 @@ if (isset($_POST['action'])) { $number_of_deleted_evaluations = 0; $number_of_deleted_links = 0; foreach ($_POST['id'] as $indexstr) { - if (api_substr($indexstr, 0, 4) == 'CATE') { + if ('CATE' == api_substr($indexstr, 0, 4)) { $cats = Category :: load(api_substr($indexstr, 4)); - if ($cats[0] != null) { + if (null != $cats[0]) { $cats[0]->delete_all(); } $number_of_deleted_categories++; } - if (api_substr($indexstr, 0, 4) == 'EVAL') { + if ('EVAL' == api_substr($indexstr, 0, 4)) { $eval = Evaluation :: load(api_substr($indexstr, 4)); - if ($eval[0] != null) { + if (null != $eval[0]) { $eval[0]->delete_with_results(); } $number_of_deleted_evaluations++; } - if (api_substr($indexstr, 0, 4) == 'LINK') { + if ('LINK' == api_substr($indexstr, 0, 4)) { $id = api_substr($indexstr, 4); if (!empty($id)) { $link = LinkFactory :: load(); - if ($link[0] != null) { + if (null != $link[0]) { $link[0]->delete(); } $number_of_deleted_links++; @@ -323,18 +321,18 @@ if (isset($_POST['action'])) { break; case 'setvisible': foreach ($_POST['id'] as $indexstr) { - if (api_substr($indexstr, 0, 4) == 'CATE') { + if ('CATE' == api_substr($indexstr, 0, 4)) { $cats = Category:: load(api_substr($indexstr, 4)); $cats[0]->set_visible(1); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); } - if (api_substr($indexstr, 0, 4) == 'EVAL') { + if ('EVAL' == api_substr($indexstr, 0, 4)) { $eval = Evaluation:: load(api_substr($indexstr, 4)); $eval[0]->set_visible(1); $eval[0]->save(); } - if (api_substr($indexstr, 0, 4) == 'LINK') { + if ('LINK' == api_substr($indexstr, 0, 4)) { $link = LinkFactory:: load(api_substr($indexstr, 4)); $link[0]->set_visible(1); $link[0]->save(); @@ -345,18 +343,18 @@ if (isset($_POST['action'])) { break; case 'setinvisible': foreach ($_POST['id'] as $indexstr) { - if (api_substr($indexstr, 0, 4) == 'CATE') { + if ('CATE' == api_substr($indexstr, 0, 4)) { $cats = Category:: load(api_substr($indexstr, 4)); $cats[0]->set_visible(0); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); } - if (api_substr($indexstr, 0, 4) == 'EVAL') { + if ('EVAL' == api_substr($indexstr, 0, 4)) { $eval = Evaluation:: load(api_substr($indexstr, 4)); $eval[0]->set_visible(0); $eval[0]->save(); } - if (api_substr($indexstr, 0, 4) == 'LINK') { + if ('LINK' == api_substr($indexstr, 0, 4)) { $link = LinkFactory:: load(api_substr($indexstr, 4)); $link[0]->set_visible(0); $link[0]->save(); @@ -482,7 +480,7 @@ if ($simple_search_form->validate() && (empty($keyword))) { if (!empty($keyword)) { $cats = Category :: load($category); $allcat = []; - if ((isset($_GET['selectcat']) && $_GET['selectcat'] == 0) && isset($_GET['search'])) { + if ((isset($_GET['selectcat']) && 0 == $_GET['selectcat']) && isset($_GET['search'])) { $allcat = $cats[0]->get_subcategories(null); $allcat_info = Category::find_category($keyword, $allcat); $alleval = []; @@ -605,7 +603,7 @@ if (isset($_GET['studentoverview'])) { $addparams['studentoverview'] = ''; } if (isset($allcat_info) && count($allcat_info) >= 0 && - (isset($_GET['selectcat']) && $_GET['selectcat'] == 0) && + (isset($_GET['selectcat']) && 0 == $_GET['selectcat']) && isset($_GET['search']) && strlen(trim($_GET['search'])) > 0 ) { $allcat = $allcat_info; @@ -633,7 +631,7 @@ if (empty($allcat) && empty($alleval) && empty($alllink) && ); } // Here we are in a sub category -if ($category != '0') { +if ('0' != $category) { DisplayGradebook::header( $cats[0], 1, @@ -646,7 +644,7 @@ if ($category != '0') { // This is the root category DisplayGradebook:: header( $cats[0], - count($allcat) == '0' && !isset($_GET['search']) ? 0 : 1, + '0' == count($allcat) && !isset($_GET['search']) ? 0 : 1, 0, $is_course_admin, $is_platform_admin, diff --git a/public/main/gradebook/gradebook_add_cat.php b/public/main/gradebook/gradebook_add_cat.php index cafc33e0a9..834f3b3cc5 100644 --- a/public/main/gradebook/gradebook_add_cat.php +++ b/public/main/gradebook/gradebook_add_cat.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; $_in_course = true; @@ -44,8 +42,8 @@ if ($form->validate()) { $values = $form->exportValues(); $select_course = isset($values['select_course']) ? $values['select_course'] : []; $cat = new Category(); - if ($values['hid_parent_id'] == '0') { - if ($select_course == 'COURSEINDEPENDENT') { + if ('0' == $values['hid_parent_id']) { + if ('COURSEINDEPENDENT' == $select_course) { $cat->set_name($values['name']); $cat->set_course_code(null); } else { diff --git a/public/main/gradebook/gradebook_add_eval.php b/public/main/gradebook/gradebook_add_eval.php index 2f61f597cf..bce5b04ca3 100644 --- a/public/main/gradebook/gradebook_add_eval.php +++ b/public/main/gradebook/gradebook_add_eval.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; $current_course_tool = TOOL_GRADEBOOK; @@ -75,8 +73,8 @@ if ($form->validate()) { ]; Event::registerLog($logInfo); - if ($eval->get_course_code() == null) { - if ($values['adduser'] == 1) { + if (null == $eval->get_course_code()) { + if (1 == $values['adduser']) { //Disabling code when course code is null see issue #2705 //header('Location: gradebook_add_user.php?selecteval=' . $eval->get_id()); exit; @@ -86,7 +84,7 @@ if ($form->validate()) { } } else { $val_addresult = isset($values['addresult']) ? $values['addresult'] : null; - if ($val_addresult == 1) { + if (1 == $val_addresult) { header('Location: gradebook_add_result.php?selecteval='.$eval->get_id().'&'.api_get_cidreq()); exit; } else { @@ -130,7 +128,7 @@ $(function() { }); '; -if ($evaladd->get_course_code() == null) { +if (null == $evaladd->get_course_code()) { Display::addFlash(Display::return_message(get_lang('Course independent evaluation'), 'normal', false)); } diff --git a/public/main/gradebook/gradebook_add_link.php b/public/main/gradebook/gradebook_add_link.php index 30394589ad..c6b489e96c 100644 --- a/public/main/gradebook/gradebook_add_link.php +++ b/public/main/gradebook/gradebook_add_link.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; require_once '../forum/forumfunction.inc.php'; @@ -24,7 +22,7 @@ $tbl_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $session_id = api_get_session_id(); $typeSelected = isset($_GET['typeselected']) ? intval($_GET['typeselected']) : null; -if ($session_id == 0) { +if (0 == $session_id) { $all_categories = Category::load( null, null, @@ -60,7 +58,7 @@ if ($typeform->validate() && isset($_GET['newtypeselected'])) { } // link type selected, show 2nd form to retrieve the link data -if (isset($typeSelected) && $typeSelected != '0') { +if (isset($typeSelected) && '0' != $typeSelected) { $url = api_get_self().'?selectcat='.$selectCat.'&typeselected='.$typeSelected.'&course_code='.$courseCode.'&'.api_get_cidreq(); $addform = new LinkAddEditForm( @@ -101,7 +99,7 @@ if (isset($typeSelected) && $typeSelected != '0') { // Update view_properties if (isset($typeSelected) && 5 == $typeSelected && - (isset($addvalues['select_link']) && $addvalues['select_link'] != "") + (isset($addvalues['select_link']) && "" != $addvalues['select_link']) ) { $sql1 = 'SELECT thread_title from '.$tbl_forum_thread.' WHERE @@ -117,7 +115,7 @@ if (isset($typeSelected) && $typeSelected != '0') { type = 5;'; $res_l = Database::query($sql_l); $row = Database::fetch_row($res_l); - if ($row[0] == 0) { + if (0 == $row[0]) { $link->add(); $sql = 'UPDATE '.$tbl_forum_thread.' SET thread_qualify_max= "'.api_float_val($addvalues['weight']).'", @@ -142,7 +140,7 @@ if (isset($typeSelected) && $typeSelected != '0') { Event::registerLog($logInfo); $addvalue_result = !empty($addvalues['addresult']) ? $addvalues['addresult'] : []; - if ($addvalue_result == 1) { + if (1 == $addvalue_result) { header('Location: gradebook_add_result.php?selecteval='.$link->get_ref_id().'&'.api_get_cidreq()); exit; } else { diff --git a/public/main/gradebook/gradebook_add_link_select_course.php b/public/main/gradebook/gradebook_add_link_select_course.php index 58fa5ad205..c7ad8204b3 100644 --- a/public/main/gradebook/gradebook_add_link_select_course.php +++ b/public/main/gradebook/gradebook_add_link_select_course.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; $current_course_tool = TOOL_GRADEBOOK; diff --git a/public/main/gradebook/gradebook_add_result.php b/public/main/gradebook/gradebook_add_result.php index cf717c08b1..c3f4f897f9 100644 --- a/public/main/gradebook/gradebook_add_result.php +++ b/public/main/gradebook/gradebook_add_result.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ //$cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -32,7 +30,7 @@ $table = $add_result_form->toHtml(); if ($add_result_form->validate()) { $values = $add_result_form->exportValues(); $nr_users = $values['nr_users']; - if ($nr_users == '0') { + if ('0' == $nr_users) { Display::addFlash(Display::return_message(get_lang('There are no learners to add results for'), 'warning', false)); header('Location: gradebook_view_result.php?addresultnostudents=&selecteval='.$selectEval.'&'.api_get_cidreq()); exit; @@ -47,7 +45,7 @@ if ($add_result_form->validate()) { $res->set_evaluation_id($values['evaluation_id']); $res->set_user_id(key($scores)); //if no scores are given, don't set the score - if (!empty($row) || $row == '0') { + if (!empty($row) || '0' == $row) { $res->set_score($row); } $res->add(); diff --git a/public/main/gradebook/gradebook_add_user.php b/public/main/gradebook/gradebook_add_user.php index 220cc6d409..453805354f 100644 --- a/public/main/gradebook/gradebook_add_user.php +++ b/public/main/gradebook/gradebook_add_user.php @@ -3,8 +3,6 @@ /* For licensing terms, see /license.txt */ /** * Script. - * - * @package chamilo.gradebook */ //Disabling code when course code is null (gradebook as a tab) see issue #2705 @@ -18,7 +16,7 @@ GradebookUtils::block_students(); $evaluation = Evaluation::load($_GET['selecteval']); $newstudents = $evaluation[0]->get_not_subscribed_students(); -if (count($newstudents) == '0') { +if ('0' == count($newstudents)) { header('Location: gradebook_view_result.php?nouser=&selecteval='.intval($_GET['selecteval']).'&'.api_get_cidreq()); exit; } @@ -39,7 +37,7 @@ if (isset($_POST['submit_button'])) { $users[$key] = intval($value); } - if (count($users) == 0) { + if (0 == count($users)) { header('Location: '.api_get_self().'?erroroneuser=&selecteval='.Security::remove_XSS($_GET['selecteval'])); exit; } else { diff --git a/public/main/gradebook/gradebook_display_certificate.php b/public/main/gradebook/gradebook_display_certificate.php index 0414a551dc..dff4385e26 100644 --- a/public/main/gradebook/gradebook_display_certificate.php +++ b/public/main/gradebook/gradebook_display_certificate.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; $current_course_tool = TOOL_GRADEBOOK; @@ -44,7 +42,7 @@ $filter = api_get_setting('certificate_filter_by_official_code'); $userList = []; $filterForm = null; $certificate_list = []; -if ($filter === 'true') { +if ('true' === $filter) { $options = UserManager::getOfficialCodeGrouped(); $options = array_merge(['all' => get_lang('All')], $options); $form = new FormValidator( @@ -58,7 +56,7 @@ if ($filter === 'true') { if ($form->validate()) { $officialCode = $form->getSubmitValue('filter'); - if ($officialCode == 'all') { + if ('all' == $officialCode) { $certificate_list = GradebookUtils::get_list_users_certificates($categoryId); } else { $userList = UserManager::getUsersByOfficialCode($officialCode); @@ -80,8 +78,8 @@ $content = ''; $courseCode = api_get_course_id(); -$allowExportToZip = api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' && - api_get_course_setting('customcertificate_course_enable', $courseInfo) == 1; +$allowExportToZip = 'true' == api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') && + 1 == api_get_course_setting('customcertificate_course_enable', $courseInfo); $tags = Certificate::notificationTags(); @@ -163,7 +161,7 @@ switch ($action) { if (!empty($userList)) { foreach ($userList as $userInfo) { - if ($userInfo['status'] == INVITEE) { + if (INVITEE == $userInfo['status']) { continue; } Category::generateUserCertificate($categoryId, $userInfo['user_id']); @@ -189,13 +187,13 @@ $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AssessmentsListOfLearner $this_section = SECTION_COURSES; Display::display_header(''); -if (isset($_GET['action']) && $_GET['action'] == 'delete') { +if (isset($_GET['action']) && 'delete' == $_GET['action']) { $check = Security::check_token('get'); if ($check) { $certificate = new Certificate($_GET['certificate_id']); $result = $certificate->delete(true); Security::clear_token(); - if ($result == true) { + if (true == $result) { echo Display::return_message(get_lang('Certificate removed'), 'confirmation'); } else { echo Display::return_message(get_lang('Certificate can\'t be removed'), 'error'); @@ -273,7 +271,7 @@ $actions .= Display::url( $hideCertificateExport = api_get_setting('hide_certificate_export_link'); -if (count($certificate_list) > 0 && $hideCertificateExport !== 'true') { +if (count($certificate_list) > 0 && 'true' !== $hideCertificateExport) { $actions .= Display::url( Display::return_icon('pdf.png', get_lang('Export all certificates to PDF'), [], ICON_SIZE_MEDIUM), $url.'&action=export_all_certificates' @@ -296,7 +294,7 @@ echo Display::toolbarAction('actions', [$actions]); echo $filterForm; -if (count($certificate_list) == 0) { +if (0 == count($certificate_list)) { echo Display::return_message(get_lang('No results available'), 'warning'); } else { echo ''; diff --git a/public/main/gradebook/gradebook_display_summary.php b/public/main/gradebook/gradebook_display_summary.php index da652b2ed3..8658637098 100644 --- a/public/main/gradebook/gradebook_display_summary.php +++ b/public/main/gradebook/gradebook_display_summary.php @@ -3,9 +3,6 @@ use ChamiloSession as Session; -/** - * @package chamilo.gradebook - */ require_once __DIR__.'/../inc/global.inc.php'; $current_course_tool = TOOL_GRADEBOOK; @@ -30,10 +27,10 @@ $userList = CourseManager::get_user_list_from_course_code( ); $loadStats = []; -if (api_get_setting('gradebook_detailed_admin_view') === 'true') { +if ('true' === api_get_setting('gradebook_detailed_admin_view')) { $loadStats = [1, 2, 3]; } else { - if (api_get_configuration_value('gradebook_enable_best_score') !== false) { + if (false !== api_get_configuration_value('gradebook_enable_best_score')) { $loadStats = [2]; } } @@ -174,7 +171,7 @@ echo ''; $allowSkillRelItem = api_get_configuration_value('allow_skill_rel_items'); -if (count($userList) == 0) { +if (0 == count($userList)) { echo Display::return_message(get_lang('No results available'), 'warning'); } else { echo '

'; diff --git a/public/main/gradebook/gradebook_edit_all.php b/public/main/gradebook/gradebook_edit_all.php index 69a2247d10..15be6046cc 100644 --- a/public/main/gradebook/gradebook_edit_all.php +++ b/public/main/gradebook/gradebook_edit_all.php @@ -4,8 +4,6 @@ /** * Script. * - * @package chamilo.gradebook - * * @author Julio Montoya - fixes in order to use gradebook models + some code cleaning */ require_once __DIR__.'/../inc/global.inc.php'; @@ -86,7 +84,7 @@ $table_evaluated[LINK_SURVEY] = [ ]; $submitted = isset($_POST['submitted']) ? $_POST['submitted'] : ''; -if ($submitted == 1) { +if (1 == $submitted) { Display::addFlash(Display::return_message(get_lang('Weights updated successfully'))); if (isset($_POST['evaluation'])) { $eval_log = new Evaluation(); @@ -206,7 +204,7 @@ if ($form->validate()) { foreach ($links as $link) { $weightToApply = $weight; - if ($diffApplied == false) { + if (false == $diffApplied) { if (!empty($diff)) { $weightToApply = $weight - $diff; $diffApplied = true; @@ -221,7 +219,7 @@ if ($form->validate()) { foreach ($evaluations as $evaluation) { $weightToApply = $weight; - if ($diffApplied == false) { + if (false == $diffApplied) { if (!empty($diff)) { $weightToApply = $weight - $diff; $diffApplied = true; diff --git a/public/main/gradebook/gradebook_edit_cat.php b/public/main/gradebook/gradebook_edit_cat.php index fa1f3ab110..8d3718c4ad 100644 --- a/public/main/gradebook/gradebook_edit_cat.php +++ b/public/main/gradebook/gradebook_edit_cat.php @@ -1,9 +1,6 @@ validate()) { $cat->setGenerateCertificates(false); } - if ($values['hid_parent_id'] == 0) { + if (0 == $values['hid_parent_id']) { $cat->set_certificate_min_score($values['certif_min_score']); } diff --git a/public/main/gradebook/gradebook_edit_eval.php b/public/main/gradebook/gradebook_edit_eval.php index 41c2b17b37..c9db8b32d4 100644 --- a/public/main/gradebook/gradebook_edit_eval.php +++ b/public/main/gradebook/gradebook_edit_eval.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); diff --git a/public/main/gradebook/gradebook_edit_link.php b/public/main/gradebook/gradebook_edit_link.php index e60344ab4a..a721e363dc 100644 --- a/public/main/gradebook/gradebook_edit_link.php +++ b/public/main/gradebook/gradebook_edit_link.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; @@ -29,7 +27,7 @@ $linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']) : $course_code = api_get_course_id(); $session_id = api_get_session_id(); -if ($session_id == 0) { +if (0 == $session_id) { $cats = Category:: load( null, null, diff --git a/public/main/gradebook/gradebook_edit_result.php b/public/main/gradebook/gradebook_edit_result.php index 00ffcc1c5d..2a2ca05c18 100644 --- a/public/main/gradebook/gradebook_edit_result.php +++ b/public/main/gradebook/gradebook_edit_result.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); diff --git a/public/main/gradebook/gradebook_flatview.php b/public/main/gradebook/gradebook_flatview.php index d0738da9db..97979bfd74 100644 --- a/public/main/gradebook/gradebook_flatview.php +++ b/public/main/gradebook/gradebook_flatview.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php'; @@ -37,7 +35,7 @@ $interbreadcrumb[] = [ $showeval = isset($_POST['showeval']) ? '1' : '0'; $showlink = isset($_POST['showlink']) ? '1' : '0'; -if ($showlink == '0' && $showeval == '0') { +if ('0' == $showlink && '0' == $showeval) { $showlink = '1'; $showeval = '1'; } @@ -55,7 +53,7 @@ if ($showlink) { $alllinks = $cat[0]->get_links($userId, true); } -if (isset($export_flatview_form) && !$file_type === 'pdf') { +if (isset($export_flatview_form) && 'pdf' === !$file_type) { Display::addFlash( Display::return_message( $export_flatview_form->toHtml(), @@ -127,12 +125,12 @@ $parameters = ['selectcat' => $categoryId]; $flatViewTable->set_additional_parameters($parameters); $params = []; -if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') { +if (isset($_GET['export_pdf']) && 'category' == $_GET['export_pdf']) { $params['only_total_category'] = true; $params['join_firstname_lastname'] = true; $params['show_official_code'] = true; $params['export_pdf'] = true; - if ($cat[0]->is_locked() == true || api_is_platform_admin()) { + if (true == $cat[0]->is_locked() || api_is_platform_admin()) { //Display::set_header(null, false, false); GradebookUtils::export_pdf_flatview( $flatViewTable, @@ -211,7 +209,7 @@ if (isset($_GET['print'])) { } if (!empty($_GET['export_report']) && - $_GET['export_report'] === 'export_report' + 'export_report' === $_GET['export_report'] ) { if (api_is_platform_admin() || api_is_course_admin() || api_is_session_general_coach() || $isDrhOfCourse) { $user_id = null; @@ -274,7 +272,7 @@ if (isset($_GET['exportpdf'])) { Display::display_header(get_lang('List View')); } -if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') { +if (isset($_GET['isStudentView']) && 'false' == $_GET['isStudentView']) { DisplayGradebook::display_header_reduce_flatview( $cat[0], $showeval, @@ -282,7 +280,7 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') { $simple_search_form ); $flatViewTable->display(); -} elseif (isset($_GET['selectcat']) && isset($_GET['isStudentView']) && ($_SESSION['studentview'] == 'teacherview')) { +} elseif (isset($_GET['selectcat']) && isset($_GET['isStudentView']) && ('teacherview' == $_SESSION['studentview'])) { DisplayGradebook::display_header_reduce_flatview( $cat[0], $showeval, diff --git a/public/main/gradebook/gradebook_scoring_system.php b/public/main/gradebook/gradebook_scoring_system.php index a2f0f513b4..713978e8bb 100644 --- a/public/main/gradebook/gradebook_scoring_system.php +++ b/public/main/gradebook/gradebook_scoring_system.php @@ -3,15 +3,13 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); GradebookUtils::block_students(); -if (api_get_setting('teachers_can_change_score_settings') != 'true') { +if ('true' != api_get_setting('teachers_can_change_score_settings')) { api_not_allowed(); } @@ -50,7 +48,7 @@ $select_cat = intval($_GET['selectcat']); $displayScore = ScoreDisplay :: instance(); $customdisplays = $displayScore->get_custom_score_display_settings(); -$nr_items = count($customdisplays) != '0' ? count($customdisplays) : '1'; +$nr_items = '0' != count($customdisplays) ? count($customdisplays) : '1'; $scoreform = new ScoreDisplayForm( 'scoring_system_form', api_get_self().'?selectcat='.$select_cat.'&'.api_get_cidreq() diff --git a/public/main/gradebook/gradebook_showlog_eval.php b/public/main/gradebook/gradebook_showlog_eval.php index c43bf772d0..e4fdda8b7e 100644 --- a/public/main/gradebook/gradebook_showlog_eval.php +++ b/public/main/gradebook/gradebook_showlog_eval.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); @@ -48,7 +46,7 @@ while ($row = Database::fetch_row($result)) { foreach ($list_info as $key => $info_log) { $list_info[$key][5] = $info_log[5] ? api_convert_and_format_date($info_log[5]) : 'N/A'; - $list_info[$key][3] = $info_log[3] == 1 ? get_lang('AssessmentsVisible') : get_lang('AssessmentsInvisible'); + $list_info[$key][3] = 1 == $info_log[3] ? get_lang('AssessmentsVisible') : get_lang('AssessmentsInvisible'); $userInfo = api_get_user_info($info_log[6]); if ($userInfo) { $list_info[$key][6] = $userInfo['complete_name_with_message_link']; diff --git a/public/main/gradebook/gradebook_showlog_link.php b/public/main/gradebook/gradebook_showlog_link.php index 733f03907a..a5248f82a7 100644 --- a/public/main/gradebook/gradebook_showlog_link.php +++ b/public/main/gradebook/gradebook_showlog_link.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; @@ -47,7 +45,7 @@ while ($row = Database::fetch_row($result)) { foreach ($list_info as $key => $info_log) { $list_info[$key][5] = ($info_log[5]) ? api_convert_and_format_date($info_log[5]) : 'N/A'; - $list_info[$key][3] = ($info_log[3] == 1) ? get_lang('AssessmentsVisible') : get_lang('AssessmentsInvisible'); + $list_info[$key][3] = (1 == $info_log[3]) ? get_lang('AssessmentsVisible') : get_lang('AssessmentsInvisible'); } $parameters = [ diff --git a/public/main/gradebook/gradebook_statistics.php b/public/main/gradebook/gradebook_statistics.php index 8c50e901ba..f00146b1ee 100644 --- a/public/main/gradebook/gradebook_statistics.php +++ b/public/main/gradebook/gradebook_statistics.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; @@ -95,7 +93,7 @@ if (!$displayScore->is_custom() || empty($displays)) { $model = ExerciseLib::getCourseScoreModel(); foreach ($keys as $key) { $bar = ($highest_ratio > 0 ? ($nr_items[$key] / $highest_ratio) * 100 : 0); - $html .= ''; + $html .= ''; $html .= ''; if (empty($model)) { $html .= ''; diff --git a/public/main/gradebook/gradebook_view_result.php b/public/main/gradebook/gradebook_view_result.php index 8a705cfc39..9708874b7e 100644 --- a/public/main/gradebook/gradebook_view_result.php +++ b/public/main/gradebook/gradebook_view_result.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php'; @@ -185,7 +183,7 @@ if (isset($_GET['editres'])) { $result->set_user_id($values['hid_user_id']); $result->set_evaluation_id($select_eval); $row_value = isset($values['score']) ? $values['score'] : 0; - if (!empty($row_value) || $row_value == 0) { + if (!empty($row_value) || 0 == $row_value) { $row_value = api_number_format( $row_value, api_get_setting('gradebook_number_decimals') @@ -262,7 +260,7 @@ if (isset($_GET['import'])) { } } } - if ($importedresult['user_id'] == null) { + if (null == $importedresult['user_id']) { header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&incorrectdata='); exit; } @@ -276,7 +274,7 @@ if (isset($_GET['import'])) { exit; } } - if ($added != '1') { + if ('1' != $added) { if ($importedresult['score'] > $eval[0]->get_max()) { header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&overwritemax='); exit; @@ -309,7 +307,7 @@ if (isset($_GET['import'])) { header('Location: '.api_get_self().'?import=&selecteval='.$select_eval.'&importnofile='); exit; } - if ($overwritescore != 0) { + if (0 != $overwritescore) { Display::addFlash( Display::return_message( get_lang('The import should overwrite the score.').' '.$overwritescore @@ -318,7 +316,7 @@ if (isset($_GET['import'])) { header('Location: '.api_get_self().'?selecteval='.$select_eval.'&importoverwritescore='.$overwritescore); exit; } - if ($nr_results_added == 0) { + if (0 == $nr_results_added) { Display::addFlash( Display::return_message( get_lang('There was a problem sending your file. Nothing has been received.'), @@ -365,7 +363,7 @@ if (isset($_GET['export'])) { $filename = 'export_results_'.gmdate('Y-m-d_H-i-s'); $results = Result::load(null, null, $select_eval); $data = []; //when file type is csv, add a header to the output file - if ($file_type == 'csv') { + if ('csv' == $file_type) { $alldata[] = [ 'username', 'official_code', @@ -377,7 +375,7 @@ if (isset($_GET['export'])) { } // export results to pdf file - if ($file_type == 'pdf') { + if ('pdf' == $file_type) { $number_decimals = api_get_setting('gradebook_number_decimals'); $datagen = new ResultsDataGenerator($eval[0], $allresults); @@ -416,7 +414,7 @@ if (isset($_GET['export'])) { [$head_ape_name, 40], [get_lang('Score'), 12], ]; - if ($number_decimals == null) { + if (null == $number_decimals) { $head_table[] = [get_lang('Letters'), 15]; } $head_display_score = ''; @@ -457,7 +455,7 @@ if (isset($_GET['export'])) { } else { $result[] = $user_info['lastname'].', '.$user_info['firstname']; } - if ($number_decimals == null) { + if (null == $number_decimals) { if (empty($data['scoreletter']) && !is_numeric($data['score'])) { $result[] = get_lang('The user did not take the exam.'); } else { @@ -525,7 +523,7 @@ if (isset($_GET['resultdelete'])) { if (isset($_POST['action'])) { $number_of_selected_items = count($_POST['id']); - if ($number_of_selected_items == '0') { + if ('0' == $number_of_selected_items) { Display::addFlash( Display::return_message( get_lang('No resource selected'), @@ -674,7 +672,7 @@ if (isset($_GET['import_score_error'])) { ); } -if ($file_type == null) { +if (null == $file_type) { //show the result header if (isset($export_result_form) && !(isset($edit_res_form))) { echo $export_result_form->display(); diff --git a/public/main/gradebook/index.php b/public/main/gradebook/index.php index 60adf33c29..030bcea2d4 100644 --- a/public/main/gradebook/index.php +++ b/public/main/gradebook/index.php @@ -229,7 +229,7 @@ if ($selectCat > 0 && $isStudentView) { if (isset($_GET['createallcategories'])) { GradebookUtils::block_students(); $coursecat = Category::get_not_created_course_categories($stud_id); - if (!count($coursecat) == 0) { + if (0 == !count($coursecat)) { foreach ($coursecat as $row) { $cat = new Category(); $cat->set_name($row[1]); @@ -273,7 +273,7 @@ if (isset($_GET['movecat'])) { } } else { $targetcat = Category::load($_GET['targetcat']); - $course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); + $course_to_crsind = (null != $cats[0]->get_course_code() && null == $targetcat[0]->get_course_code()); if (!($course_to_crsind && !isset($_GET['confirm']))) { $cats[0]->move_to_cat($targetcat[0]); @@ -307,7 +307,7 @@ if (isset($_GET['moveeval'])) { } } else { $targetcat = Category::load($_GET['targetcat']); - $course_to_crsind = $evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null; + $course_to_crsind = null != $evals[0]->get_course_code() && null == $targetcat[0]->get_course_code(); if (!($course_to_crsind && !isset($_GET['confirm']))) { $evals[0]->move_to_cat($targetcat[0]); @@ -367,8 +367,8 @@ if (isset($_GET['deletecat'])) { $cats = Category::load($_GET['deletecat']); if (isset($cats[0])) { // Delete all categories,subcategories and results - if ($cats[0] != null) { - if ($cats[0]->get_id() != 0) { + if (null != $cats[0]) { + if (0 != $cats[0]->get_id()) { // better don't try to delete the root... $cats[0]->delete_all(); } @@ -409,7 +409,7 @@ if (isset($_GET['lockedeval'])) { $confirmation_message = get_lang('Evaluation has been unlocked'); } $eval = Evaluation::load($locked); - if ($eval[0] != null) { + if (null != $eval[0]) { $eval[0]->lock($type_locked); } @@ -419,7 +419,7 @@ if (isset($_GET['lockedeval'])) { if (isset($_GET['deleteeval'])) { GradebookUtils::block_students(); $eval = Evaluation::load($_GET['deleteeval']); - if ($eval[0] != null) { + if (null != $eval[0]) { $eval[0]->delete_with_results(); } $confirmation_message = get_lang('Assessment deleted'); @@ -454,7 +454,7 @@ if (isset($_GET['deletelink'])) { //fixing #5229 if (!empty($get_delete_link)) { $link = LinkFactory::load($get_delete_link); - if ($link[0] != null) { + if (null != $link[0]) { // Clean forum qualify $sql = 'UPDATE '.$tbl_forum_thread.' SET thread_qualify_max = 0, @@ -501,7 +501,7 @@ if (isset($_POST['action'])) { GradebookUtils::block_students(); $number_of_selected_items = count($_POST['id']); - if ($number_of_selected_items == 0) { + if (0 == $number_of_selected_items) { $warning_message = get_lang('No resource selected'); $filter_warning_msg = false; } else { @@ -511,27 +511,27 @@ if (isset($_POST['action'])) { $number_of_deleted_evaluations = 0; $number_of_deleted_links = 0; foreach ($_POST['id'] as $indexstr) { - if (substr($indexstr, 0, 4) == 'CATE') { + if ('CATE' == substr($indexstr, 0, 4)) { $cats = Category::load(substr($indexstr, 4)); - if ($cats[0] != null) { + if (null != $cats[0]) { $cats[0]->delete_all(); } $number_of_deleted_categories++; } - if (substr($indexstr, 0, 4) == 'EVAL') { + if ('EVAL' == substr($indexstr, 0, 4)) { $eval = Evaluation::load(substr($indexstr, 4)); - if ($eval[0] != null) { + if (null != $eval[0]) { $eval[0]->delete_with_results(); } $number_of_deleted_evaluations++; } - if (substr($indexstr, 0, 4) == 'LINK') { + if ('LINK' == substr($indexstr, 0, 4)) { //fixing #5229 $id = substr($indexstr, 4); if (!empty($id)) { $link = LinkFactory::load($id); - if ($link[0] != null) { + if (null != $link[0]) { $link[0]->delete(); } $number_of_deleted_links++; @@ -548,18 +548,18 @@ if (isset($_POST['action'])) { break; case 'setvisible': foreach ($_POST['id'] as $indexstr) { - if (substr($indexstr, 0, 4) == 'CATE') { + if ('CATE' == substr($indexstr, 0, 4)) { $cats = Category::load(substr($indexstr, 4)); $cats[0]->set_visible(1); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); } - if (substr($indexstr, 0, 4) == 'EVAL') { + if ('EVAL' == substr($indexstr, 0, 4)) { $eval = Evaluation::load(substr($indexstr, 4)); $eval[0]->set_visible(1); $eval[0]->save(); } - if (substr($indexstr, 0, 4) == 'LINK') { + if ('LINK' == substr($indexstr, 0, 4)) { $link = LinkFactory::load(substr($indexstr, 4)); $link[0]->set_visible(1); $link[0]->save(); @@ -570,18 +570,18 @@ if (isset($_POST['action'])) { break; case 'setinvisible': foreach ($_POST['id'] as $indexstr) { - if (substr($indexstr, 0, 4) == 'CATE') { + if ('CATE' == substr($indexstr, 0, 4)) { $cats = Category::load(substr($indexstr, 4)); $cats[0]->set_visible(0); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); } - if (substr($indexstr, 0, 4) == 'EVAL') { + if ('EVAL' == substr($indexstr, 0, 4)) { $eval = Evaluation::load(substr($indexstr, 4)); $eval[0]->set_visible(0); $eval[0]->save(); } - if (substr($indexstr, 0, 4) == 'LINK') { + if ('LINK' == substr($indexstr, 0, 4)) { $link = LinkFactory::load(substr($indexstr, 4)); $link[0]->set_visible(0); $link[0]->save(); @@ -807,7 +807,7 @@ if (!empty($selectCat)) { $cat = new Category(); $course_id = CourseManager::get_course_by_category($selectCat); $show_message = $cat->show_message_resource_delete($course_id); - if ($show_message == '') { + if ('' == $show_message) { // Student if (!api_is_allowed_to_edit() && !api_is_excluded_user_type()) { $certificate = Category::generateUserCertificate( @@ -815,7 +815,7 @@ if (!empty($selectCat)) { $stud_id ); - if ($hideCertificateExport !== 'true' && isset($certificate['pdf_url'])) { + if ('true' !== $hideCertificateExport && isset($certificate['pdf_url'])) { $actionsLeft .= Display::url( Display::returnFontAwesomeIcon('file-pdf-o').get_lang('Download certificate in PDF'), $certificate['pdf_url'], @@ -834,7 +834,7 @@ if (!empty($selectCat)) { } if (!api_is_allowed_to_edit(null, true)) { - $allowButton = api_get_configuration_value('gradebook_hide_pdf_report_button') === false; + $allowButton = false === api_get_configuration_value('gradebook_hide_pdf_report_button'); if ($allowButton) { $actionsLeft .= Display::url( Display::returnFontAwesomeIcon('file-pdf-o').get_lang('Download report in PDF'), @@ -844,7 +844,7 @@ if (!api_is_allowed_to_edit(null, true)) { } } -if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)) { +if (isset($first_time) && 1 == $first_time && api_is_allowed_to_edit(null, true)) { echo ''; } else { // Tool introduction @@ -871,11 +871,11 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) ); if (!empty($cats)) { - if ((api_get_setting('gradebook_enable_grade_model') === 'true') && + if (('true' === api_get_setting('gradebook_enable_grade_model')) && ( api_is_platform_admin() || ( api_is_allowed_to_edit(null, true) && - api_get_setting('teachers_can_change_grade_model_settings') === 'true' + 'true' === api_get_setting('teachers_can_change_grade_model_settings') ) ) ) { @@ -884,8 +884,8 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) $grade_models = $obj->get_all(); $grade_model_id = $cats[0]->get_grade_model_id(); // No children. - if ((count($cats) == 1 && empty($grade_model_id)) || - (count($cats) == 1 && $grade_model_id != -1) + if ((1 == count($cats) && empty($grade_model_id)) || + (1 == count($cats) && -1 != $grade_model_id) ) { if (!empty($grade_models)) { $form_grade = new FormValidator('grade_model_settings'); @@ -937,7 +937,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) $i = 0; $allcat = []; $model = ExerciseLib::getCourseScoreModel(); - $allowGraph = api_get_configuration_value('gradebook_hide_graph') === false; + $allowGraph = false === api_get_configuration_value('gradebook_hide_graph'); $isAllow = api_is_allowed_to_edit(null, true); /** @var Category $cat */ @@ -946,7 +946,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) $alleval = $cat->get_evaluations($stud_id, false, $course_code, $session_id); $alllink = $cat->get_links($stud_id, true, $course_code, $session_id); - if ($cat->get_parent_id() != 0) { + if (0 != $cat->get_parent_id()) { $i++; } else { // This is the father @@ -963,7 +963,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) $certificate ); - if ($isAllow && api_get_setting('gradebook_enable_grade_model') === 'true') { + if ($isAllow && 'true' === api_get_setting('gradebook_enable_grade_model')) { // Showing the grading system if (!empty($grade_models[$grade_model_id])) { echo Display::return_message( @@ -973,16 +973,16 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) } $exportToPdf = false; - if ($action === 'export_table') { + if ('export_table' === $action) { $exportToPdf = true; } $loadStats = []; if (!$isAllow) { - if (api_get_setting('gradebook_detailed_admin_view') === 'true') { + if ('true' === api_get_setting('gradebook_detailed_admin_view')) { $loadStats = [1, 2, 3]; } else { - if (api_get_configuration_value('gradebook_enable_best_score') !== false) { + if (false !== api_get_configuration_value('gradebook_enable_best_score')) { $loadStats = [2]; } } @@ -1014,7 +1014,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true) $graph = $gradebookTable->getGraph(); } - if ($action === 'export_table') { + if ('export_table' === $action) { ob_clean(); $params = [ 'pdf_title' => sprintf(get_lang('Grades from course: %s'), $courseInfo['name']), diff --git a/public/main/gradebook/lib/GradebookUtils.php b/public/main/gradebook/lib/GradebookUtils.php index 9c4d1913a5..739b23bedb 100644 --- a/public/main/gradebook/lib/GradebookUtils.php +++ b/public/main/gradebook/lib/GradebookUtils.php @@ -130,7 +130,7 @@ class GradebookUtils } } else { $isCoach = api_is_coach(api_get_session_id(), api_get_course_int_id()); - if ($isCoach === false) { + if (false === $isCoach) { if (!api_is_allowed_to_edit()) { api_not_allowed(); } @@ -224,9 +224,9 @@ class GradebookUtils $selectcat = $selectcat->get_id(); $modify_icons = null; - if ($show_message === false) { - $visibility_icon = ($cat->is_visible() == 0) ? 'invisible' : 'visible'; - $visibility_command = ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible'; + if (false === $show_message) { + $visibility_icon = (0 == $cat->is_visible()) ? 'invisible' : 'visible'; + $visibility_command = (0 == $cat->is_visible()) ? 'set_visible' : 'set_invisible'; $modify_icons .= ''. Display::return_icon( @@ -262,7 +262,7 @@ class GradebookUtils if (api_is_allowed_to_edit(null, true)) { // Locking button - if (api_get_setting('gradebook_locking_enabled') == 'true') { + if ('true' == api_get_setting('gradebook_locking_enabled')) { if ($cat->is_locked()) { if (api_is_platform_admin()) { $modify_icons .= ' '. @@ -280,7 +280,7 @@ class GradebookUtils } } - if (empty($grade_model_id) || $grade_model_id == -1) { + if (empty($grade_model_id) || -1 == $grade_model_id) { if ($cat->is_locked() && !api_is_platform_admin()) { $modify_icons .= Display::return_icon( 'edit_na.png', @@ -361,9 +361,9 @@ class GradebookUtils $message_eval = $cat->show_message_resource_delete($eval->get_course_code()); $courseParams = api_get_cidreq_params($eval->get_course_code(), $eval->getSessionId()); - if ($message_eval === false && api_is_allowed_to_edit(null, true)) { - $visibility_icon = $eval->is_visible() == 0 ? 'invisible' : 'visible'; - $visibility_command = $eval->is_visible() == 0 ? 'set_visible' : 'set_invisible'; + if (false === $message_eval && api_is_allowed_to_edit(null, true)) { + $visibility_icon = 0 == $eval->is_visible() ? 'invisible' : 'visible'; + $visibility_command = 0 == $eval->is_visible() ? 'set_visible' : 'set_invisible'; if ($is_locked && !api_is_platform_admin()) { $modify_icons = Display::return_icon( 'edit_na.png', @@ -458,9 +458,9 @@ class GradebookUtils $link->get_session_id() ); - if ($message_link === false) { - $visibility_icon = $link->is_visible() == 0 ? 'invisible' : 'visible'; - $visibility_command = $link->is_visible() == 0 ? 'set_visible' : 'set_invisible'; + if (false === $message_link) { + $visibility_icon = 0 == $link->is_visible() ? 'invisible' : 'visible'; + $visibility_command = 0 == $link->is_visible() ? 'set_visible' : 'set_invisible'; if ($is_locked && !api_is_platform_admin()) { $modify_icons = Display::return_icon( @@ -498,7 +498,7 @@ class GradebookUtils ''; $allowStats = api_get_configuration_value('allow_gradebook_stats'); - if ($allowStats && $link->get_type() == LINK_EXERCISE) { + if ($allowStats && LINK_EXERCISE == $link->get_type()) { $modify_icons .= Display::url( Display::return_icon('reload.png', get_lang('Generate statistics')), api_get_self().'?itemId='.$link->get_id().'&action=generate_link_stats&selectcat='.$selectcat.'&'.$courseParams @@ -697,7 +697,7 @@ class GradebookUtils WHERE gc.cat_id = $cat_id AND user_id = $user_id "; $rs_exist = Database::query($sql); $row = Database::fetch_array($rs_exist); - if ($row['count'] == 0) { + if (0 == $row['count']) { $params = [ 'cat_id' => $cat_id, 'user_id' => $user_id, @@ -987,7 +987,7 @@ class GradebookUtils if ($my_cat->get_course_code() == api_get_course_id()) { $grade_model_id = $my_cat->get_grade_model_id(); if (empty($grade_model_id)) { - if ($my_cat->get_parent_id() == 0) { + if (0 == $my_cat->get_parent_id()) { //$default_weight = $my_cat->get_weight(); $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id()); $cats_added[] = $my_cat->get_id(); @@ -1052,7 +1052,7 @@ class GradebookUtils $parent_id = $cat[0]->get_parent_id(); if (isset($cat[0]) && isset($parent_id)) { - if ($parent_id == 0) { + if (0 == $parent_id) { $grade_model_id = $cat[0]->get_grade_model_id(); } else { $parent_cat = Category::load($parent_id); @@ -1061,18 +1061,18 @@ class GradebookUtils } $use_grade_model = true; - if (empty($grade_model_id) || $grade_model_id == -1) { + if (empty($grade_model_id) || -1 == $grade_model_id) { $use_grade_model = false; } if ($use_grade_model) { - if ($parent_id == 0) { + if (0 == $parent_id) { $title = api_strtoupper(get_lang('Average')).'
'.get_lang('Detailed'); } else { $title = api_strtoupper(get_lang('Average')).'
'.$cat[0]->get_description().' - ('.$cat[0]->get_name().')'; } } else { - if ($parent_id == 0) { + if (0 == $parent_id) { $title = api_strtoupper(get_lang('Average')).'
'.get_lang('Detailed'); } else { $title = api_strtoupper(get_lang('Average')); @@ -1110,10 +1110,10 @@ class GradebookUtils $attributes['align'] = 'center'; $attributes['style'] = null; - if ($key === 'name') { + if ('name' === $key) { $attributes['align'] = 'left'; } - if ($key === 'total') { + if ('total' === $key) { $attributes['style'] = 'font-weight:bold'; } $table->setCellContents($row, $column, $printable_data_cell); @@ -1136,7 +1136,7 @@ class GradebookUtils 'add_signatures' => ['Drh', 'Teacher', 'Date'], ]; - $page_format = $params['orientation'] === 'landscape' ? 'A4-L' : 'A4'; + $page_format = 'landscape' === $params['orientation'] ? 'A4-L' : 'A4'; ob_start(); $pdf = new PDF($page_format, $page_format, $pdfParams); $pdf->html_to_pdf_with_template($flatviewtable->return_table(), false, false, true); @@ -1157,7 +1157,7 @@ class GradebookUtils $badges = []; foreach ($list_values as $value) { $class = 'warning'; - if ($counter == 1) { + if (1 == $counter) { $class = 'success'; } $counter++; @@ -1604,10 +1604,10 @@ class GradebookUtils $alllink = $cats[0]->get_links($userId); $loadStats = []; - if (api_get_setting('gradebook_detailed_admin_view') === 'true') { + if ('true' === api_get_setting('gradebook_detailed_admin_view')) { $loadStats = [1, 2, 3]; } else { - if (api_get_configuration_value('gradebook_enable_best_score') !== false) { + if (false !== api_get_configuration_value('gradebook_enable_best_score')) { $loadStats = [2]; } } diff --git a/public/main/gradebook/lib/be/abstractlink.class.php b/public/main/gradebook/lib/be/abstractlink.class.php index 99ca925583..ed9c7bc36b 100644 --- a/public/main/gradebook/lib/be/abstractlink.class.php +++ b/public/main/gradebook/lib/be/abstractlink.class.php @@ -12,8 +12,6 @@ use Chamilo\CoreBundle\Entity\GradebookLink; * * @author Bert Steppé * @author Julio Montoya security improvements - * - * @package chamilo.gradebook */ abstract class AbstractLink implements GradebookItem { @@ -176,7 +174,7 @@ abstract class AbstractLink implements GradebookItem public function is_locked() { - return isset($this->locked) && $this->locked == 1 ? true : false; + return isset($this->locked) && 1 == $this->locked ? true : false; } public function is_visible() @@ -306,7 +304,7 @@ abstract class AbstractLink implements GradebookItem $paramcount++; } if (isset($type)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -315,7 +313,7 @@ abstract class AbstractLink implements GradebookItem $paramcount++; } if (isset($ref_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -324,7 +322,7 @@ abstract class AbstractLink implements GradebookItem $paramcount++; } if (isset($user_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -333,7 +331,7 @@ abstract class AbstractLink implements GradebookItem $paramcount++; } if (isset($course_code)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -345,7 +343,7 @@ abstract class AbstractLink implements GradebookItem } } if (isset($category_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -354,7 +352,7 @@ abstract class AbstractLink implements GradebookItem $paramcount++; } if (isset($visible)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -393,7 +391,7 @@ abstract class AbstractLink implements GradebookItem $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); - if ($row['count'] == 0) { + if (0 == $row['count']) { $em = Database::getManager(); $link = new GradebookLink(); $link @@ -551,7 +549,7 @@ abstract class AbstractLink implements GradebookItem $links = $rootcat[0]->get_links((api_is_allowed_to_edit() ? null : api_get_user_id()), true); $foundlinks = []; foreach ($links as $link) { - if (!(api_strpos(api_strtolower($link->get_name()), api_strtolower($name_mask)) === false)) { + if (!(false === api_strpos(api_strtolower($link->get_name()), api_strtolower($name_mask)))) { $foundlinks[] = $link; } } @@ -658,7 +656,7 @@ abstract class AbstractLink implements GradebookItem } // If no ranking was detected. - if ($ranking == 0) { + if (0 == $ranking) { return []; } diff --git a/public/main/gradebook/lib/be/attendancelink.class.php b/public/main/gradebook/lib/be/attendancelink.class.php index 5f811f2846..e1c9045ef3 100644 --- a/public/main/gradebook/lib/be/attendancelink.class.php +++ b/public/main/gradebook/lib/be/attendancelink.class.php @@ -5,8 +5,6 @@ * Gradebook link to attendance item. * * @author Christian Fasanando (christian1827@gmail.com) - * - * @package chamilo.gradebook */ class AttendanceLink extends AbstractLink { @@ -61,7 +59,7 @@ class AttendanceLink extends AbstractLink $result = Database::query($sql); while ($data = Database::fetch_array($result)) { - if (isset($data['attendance_qualify_title']) && $data['attendance_qualify_title'] != '') { + if (isset($data['attendance_qualify_title']) && '' != $data['attendance_qualify_title']) { $cats[] = [$data['id'], $data['attendance_qualify_title']]; } else { $cats[] = [$data['id'], $data['name']]; @@ -88,7 +86,7 @@ class AttendanceLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } /** @@ -141,7 +139,7 @@ class AttendanceLink extends AbstractLink while ($data = Database::fetch_array($scores)) { if (!(array_key_exists($data['user_id'], $students))) { - if ($attendance['attendance_qualify_max'] != 0) { + if (0 != $attendance['attendance_qualify_max']) { $students[$data['user_id']] = $data['score']; $rescount++; $sum += $data['score'] / $attendance['attendance_qualify_max']; @@ -154,7 +152,7 @@ class AttendanceLink extends AbstractLink } } - if ($rescount == 0) { + if (0 == $rescount) { return [null, null]; } else { switch ($type) { @@ -198,7 +196,7 @@ class AttendanceLink extends AbstractLink $this->get_attendance_data(); $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; - if (isset($attendance_qualify_title) && $attendance_qualify_title != '') { + if (isset($attendance_qualify_title) && '' != $attendance_qualify_title) { return $this->attendance_data['attendance_qualify_title']; } else { return $attendance_title; @@ -223,7 +221,7 @@ class AttendanceLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } public function get_link() @@ -264,7 +262,7 @@ class AttendanceLink extends AbstractLink private function get_attendance_data() { $tbl_name = $this->get_attendance_table(); - if ($tbl_name == '') { + if ('' == $tbl_name) { return false; } elseif (!isset($this->attendance_data)) { $sql = 'SELECT * FROM '.$this->get_attendance_table().' att diff --git a/public/main/gradebook/lib/be/category.class.php b/public/main/gradebook/lib/be/category.class.php index d2ce253002..31f41896f4 100644 --- a/public/main/gradebook/lib/be/category.class.php +++ b/public/main/gradebook/lib/be/category.class.php @@ -7,8 +7,6 @@ use ChamiloSession as Session; /** * Class Category * Defines a gradebook Category object. - * - * @package chamilo.gradebook */ class Category implements GradebookItem { @@ -136,7 +134,7 @@ class Category implements GradebookItem */ public function is_locked() { - return isset($this->locked) && $this->locked == 1 ? true : false; + return isset($this->locked) && 1 == $this->locked ? true : false; } /** @@ -386,7 +384,7 @@ class Category implements GradebookItem $id = null, $session_id = null ) { - if (isset($id) && (int) $id === 0) { + if (isset($id) && 0 === (int) $id) { $cats = []; $cats[] = self::create_root_category(); @@ -443,7 +441,7 @@ class Category implements GradebookItem ) { //if the category given is explicitly 0 (not null), then create // a root category object (in memory) - if (isset($id) && (int) $id === 0) { + if (isset($id) && 0 === (int) $id) { $cats = []; $cats[] = self::create_root_category(); @@ -460,7 +458,7 @@ class Category implements GradebookItem if (isset($user_id)) { $user_id = intval($user_id); - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -470,13 +468,13 @@ class Category implements GradebookItem } if (isset($course_code)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; } - if ($course_code == '0') { + if ('0' == $course_code) { $sql .= ' c_id is null '; } else { $courseInfo = api_get_course_info($course_code); @@ -501,7 +499,7 @@ class Category implements GradebookItem } if (isset($parent_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND '; } else { $sql .= ' WHERE '; @@ -511,7 +509,7 @@ class Category implements GradebookItem } if (isset($visible)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -520,7 +518,7 @@ class Category implements GradebookItem } if (!empty($order_by)) { - if (!empty($order_by) && $order_by != '') { + if (!empty($order_by) && '' != $order_by) { $sql .= ' '.$order_by; } } @@ -601,11 +599,11 @@ class Category implements GradebookItem if (!empty($id)) { $parent_id = $this->get_parent_id(); $grade_model_id = $this->get_grade_model_id(); - if ($parent_id == 0) { + if (0 == $parent_id) { //do something if (isset($grade_model_id) && !empty($grade_model_id) && - $grade_model_id != '-1' + '-1' != $grade_model_id ) { $obj = new GradeModel(); $components = $obj->get_components($grade_model_id); @@ -683,10 +681,10 @@ class Category implements GradebookItem if (!empty($this->id)) { $parent_id = $this->get_parent_id(); $grade_model_id = $this->get_grade_model_id(); - if ($parent_id == 0) { + if (0 == $parent_id) { if (isset($grade_model_id) && !empty($grade_model_id) && - $grade_model_id != '-1' + '-1' != $grade_model_id ) { $obj = new GradeModel(); $components = $obj->get_components($grade_model_id); @@ -870,7 +868,7 @@ class Category implements GradebookItem public function is_course() { return isset($this->course_code) && !empty($this->course_code) - && (!isset($this->parent) || $this->parent == 0); + && (!isset($this->parent) || 0 == $this->parent); } /** @@ -901,7 +899,7 @@ class Category implements GradebookItem } } // Classic - if (!empty($stud_id) && $type == '') { + if (!empty($stud_id) && '' == $type) { if (!empty($course_code)) { $cats = $this->get_subcategories( $stud_id, @@ -935,7 +933,7 @@ class Category implements GradebookItem ); $catweight = 0; - if ($cat->get_weight() != 0) { + if (0 != $cat->get_weight()) { $catweight = $cat->get_weight(); $weightsum += $catweight; } @@ -951,14 +949,14 @@ class Category implements GradebookItem foreach ($evals as $eval) { $eval->setStudentList($this->getStudentList()); $evalres = $eval->calc_score($stud_id); - if (isset($evalres) && $eval->get_weight() != 0) { + if (isset($evalres) && 0 != $eval->get_weight()) { $evalweight = $eval->get_weight(); $weightsum += $evalweight; if (!empty($evalres[1])) { $ressum += $evalres[0] / $evalres[1] * $evalweight; } } else { - if ($eval->get_weight() != 0) { + if (0 != $eval->get_weight()) { $evalweight = $eval->get_weight(); $weightsum += $evalweight; } @@ -976,14 +974,14 @@ class Category implements GradebookItem } $linkres = $link->calc_score($stud_id, null); - if (!empty($linkres) && $link->get_weight() != 0) { + if (!empty($linkres) && 0 != $link->get_weight()) { $linkweight = $link->get_weight(); - $link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; + $link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1]; $weightsum += $linkweight; $ressum += $linkres[0] / $link_res_denom * $linkweight; } else { // Adding if result does not exists - if ($link->get_weight() != 0) { + if (0 != $link->get_weight()) { $linkweight = $link->get_weight(); $weightsum += $linkweight; } @@ -1023,7 +1021,7 @@ class Category implements GradebookItem ); $catweight = 0; - if ($cat->get_weight() != 0) { + if (0 != $cat->get_weight()) { $catweight = $cat->get_weight(); $weightsum += $catweight; } @@ -1039,14 +1037,14 @@ class Category implements GradebookItem } if (!empty($evals)) { - if ($type === 'best') { + if ('best' === $type) { $studentList = $this->getStudentList(); foreach ($studentList as $student) { $studentId = $student['user_id']; foreach ($evals as $eval) { $linkres = $eval->calc_score($studentId, null); $linkweight = $eval->get_weight(); - $link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; + $link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1]; $ressum = $linkres[0] / $link_res_denom * $linkweight; if (!isset($totalScorePerStudent[$studentId])) { @@ -1061,7 +1059,7 @@ class Category implements GradebookItem $evalres = $eval->calc_score(null, $type); $eval->setStudentList($this->getStudentList()); - if (isset($evalres) && $eval->get_weight() != 0) { + if (isset($evalres) && 0 != $eval->get_weight()) { $evalweight = $eval->get_weight(); $weightsum += $evalweight; if (!empty($evalres[1])) { @@ -1072,7 +1070,7 @@ class Category implements GradebookItem $bestResult = $ressum; } } else { - if ($eval->get_weight() != 0) { + if (0 != $eval->get_weight()) { $evalweight = $eval->get_weight(); $weightsum += $evalweight; } @@ -1083,13 +1081,13 @@ class Category implements GradebookItem if (!empty($links)) { $studentList = $this->getStudentList(); - if ($type === 'best') { + if ('best' === $type) { foreach ($studentList as $student) { $studentId = $student['user_id']; foreach ($links as $link) { $linkres = $link->calc_score($studentId, null); $linkweight = $link->get_weight(); - $link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; + $link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1]; $ressum = $linkres[0] / $link_res_denom * $linkweight; if (!isset($totalScorePerStudent[$studentId])) { @@ -1109,9 +1107,9 @@ class Category implements GradebookItem $linkres = $link->calc_score($stud_id, $type); - if (!empty($linkres) && $link->get_weight() != 0) { + if (!empty($linkres) && 0 != $link->get_weight()) { $linkweight = $link->get_weight(); - $link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; + $link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1]; $weightsum += $linkweight; $ressum += $linkres[0] / $link_res_denom * $linkweight; @@ -1120,7 +1118,7 @@ class Category implements GradebookItem } } else { // Adding if result does not exists - if ($link->get_weight() != 0) { + if (0 != $link->get_weight()) { $linkweight = $link->get_weight(); $weightsum += $linkweight; } @@ -1290,7 +1288,7 @@ class Category implements GradebookItem )'; } } elseif (api_is_platform_admin()) { - if (isset($session_id) && $session_id != 0) { + if (isset($session_id) && 0 != $session_id) { $sql .= ' AND session_id='.$session_id; } else { $sql .= ' AND coalesce(session_id,0)=0'; @@ -1325,7 +1323,7 @@ class Category implements GradebookItem $course_code = null, $session_id = null ) { - if ($user_id == null) { + if (null == $user_id) { return self::load(null, null, $course_code, 0, null, $session_id); } @@ -1376,7 +1374,7 @@ class Category implements GradebookItem */ public function is_movable() { - return !(!isset($this->id) || $this->id == 0 || $this->is_course()); + return !(!isset($this->id) || 0 == $this->id || $this->is_course()); } /** @@ -1621,7 +1619,7 @@ class Category implements GradebookItem $this->id, $studentId ); - if (count($evals) != 0) { + if (0 != count($evals)) { return true; } else { $cats = self::load( @@ -1709,7 +1707,7 @@ class Category implements GradebookItem // 1 student if (isset($studentId)) { // Special case: this is the root - if ($this->id == 0) { + if (0 == $this->id) { return $this->get_root_categories_for_student($studentId, $course_code, $session_id); } else { return self::load( @@ -1727,7 +1725,7 @@ class Category implements GradebookItem // Course admin if (api_is_allowed_to_edit() && !api_is_platform_admin()) { // root - if ($this->id == 0) { + if (0 == $this->id) { // inside a course return $this->get_root_categories_for_teacher( api_get_user_id(), @@ -1806,7 +1804,7 @@ class Category implements GradebookItem // 1 student if (isset($studentId) && !empty($studentId)) { // Special case: this is the root - if ($this->id == 0) { + if (0 == $this->id) { $evals = Evaluation::get_evaluations_with_result_for_student( 0, $studentId @@ -1827,7 +1825,7 @@ class Category implements GradebookItem !api_is_platform_admin() ) { // root - if ($this->id == 0) { + if (0 == $this->id) { $evals = Evaluation::load( null, api_get_user_id(), @@ -1910,7 +1908,7 @@ class Category implements GradebookItem $sessionId = empty($sessionId) ? $this->get_session_id() : $sessionId; // no links in root or course independent categories - if ($this->id == 0) { + if (0 == $this->id) { } elseif (isset($studentId)) { // 1 student $studentId $links = LinkFactory::load( @@ -2020,7 +2018,7 @@ class Category implements GradebookItem { $categories = []; foreach ($allcat as $search_cat) { - if (!(strpos(strtolower($search_cat->get_name()), strtolower($name_mask)) === false)) { + if (!(false === strpos(strtolower($search_cat->get_name()), strtolower($name_mask)))) { $categories[] = $search_cat; } } @@ -2050,7 +2048,7 @@ class Category implements GradebookItem */ public function lockAllItems($locked) { - if (api_get_setting('gradebook_locking_enabled') == 'true') { + if ('true' == api_get_setting('gradebook_locking_enabled')) { $this->lock($locked); $evals_to_lock = $this->get_evaluations(); if (!empty($evals_to_lock)) { @@ -2067,7 +2065,7 @@ class Category implements GradebookItem } $event_type = LOG_GRADEBOOK_UNLOCKED; - if ($locked == 1) { + if (1 == $locked) { $event_type = LOG_GRADEBOOK_LOCKED; } Event::addEvent($event_type, LOG_GRADEBOOK_ID, $this->id); @@ -2202,7 +2200,7 @@ class Category implements GradebookItem $fileWasGenerated = $certificate_obj->isHtmlFileGenerated(); // Fix when using custom certificate BT#15937 - if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true') { + if ('true' === api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate')) { $infoCertificate = CustomCertificatePlugin::getCertificateData($my_certificate['id'], $user_id); if (!empty($infoCertificate)) { $fileWasGenerated = true; @@ -2231,7 +2229,7 @@ class Category implements GradebookItem $hideExportLink = api_get_setting('hide_certificate_export_link'); $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students'); - if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true')) { + if ('true' === $hideExportLink || (api_is_student() && 'true' === $hideExportLinkStudent)) { $exportToPDF = null; } @@ -2286,7 +2284,7 @@ class Category implements GradebookItem $params['right'] = 0; $params['top'] = 0; $params['bottom'] = 0; - $page_format = $params['orientation'] == 'landscape' ? 'A4-L' : 'A4'; + $page_format = 'landscape' == $params['orientation'] ? 'A4-L' : 'A4'; $pdf = new PDF($page_format, $params['orientation'], $params); $certificate_list = GradebookUtils::get_list_users_certificates($catId, $userList); @@ -2803,7 +2801,7 @@ class Category implements GradebookItem $score = $item->calc_score($userId); $itemValue = 0; if (!empty($score)) { - $divider = $score[1] == 0 ? 1 : $score[1]; + $divider = 0 == $score[1] ? 1 : $score[1]; $itemValue = $score[0] / $divider * $item->get_weight(); } diff --git a/public/main/gradebook/lib/be/dropboxlink.class.php b/public/main/gradebook/lib/be/dropboxlink.class.php index 8594b87d06..4002ccd80c 100644 --- a/public/main/gradebook/lib/be/dropboxlink.class.php +++ b/public/main/gradebook/lib/be/dropboxlink.class.php @@ -5,8 +5,6 @@ * Gradebook link to dropbox item. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class DropboxLink extends EvalLink { diff --git a/public/main/gradebook/lib/be/evallink.class.php b/public/main/gradebook/lib/be/evallink.class.php index 4269ff5e16..f4194a1e85 100644 --- a/public/main/gradebook/lib/be/evallink.class.php +++ b/public/main/gradebook/lib/be/evallink.class.php @@ -5,9 +5,6 @@ * Class to be used as basis for links referring to Evaluation objects. * * @author Bert Steppé - * - * @package chamilo.gradebook - * @package chamilo.gradebook */ abstract class EvalLink extends AbstractLink { diff --git a/public/main/gradebook/lib/be/evaluation.class.php b/public/main/gradebook/lib/be/evaluation.class.php index febbdbc59e..f0cf64be7e 100644 --- a/public/main/gradebook/lib/be/evaluation.class.php +++ b/public/main/gradebook/lib/be/evaluation.class.php @@ -6,8 +6,6 @@ use ChamiloSession as Session; /** * Class Evaluation. - * - * @package chamilo.gradebook */ class Evaluation implements GradebookItem { @@ -151,7 +149,7 @@ class Evaluation implements GradebookItem public function is_locked() { - return isset($this->locked) && $this->locked == 1 ? true : false; + return isset($this->locked) && 1 == $this->locked ? true : false; } public function set_id($id) @@ -238,7 +236,7 @@ class Evaluation implements GradebookItem } if (isset($user_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -247,10 +245,10 @@ class Evaluation implements GradebookItem $paramcount++; } - if (isset($course_code) && $course_code != '-1') { + if (isset($course_code) && '-1' != $course_code) { $courseInfo = api_get_course_info($course_code); if ($courseInfo) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -261,7 +259,7 @@ class Evaluation implements GradebookItem } if (isset($category_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -271,7 +269,7 @@ class Evaluation implements GradebookItem } if (isset($visible)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -281,7 +279,7 @@ class Evaluation implements GradebookItem } if (isset($locked)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -457,7 +455,7 @@ class Evaluation implements GradebookItem $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } /** @@ -475,7 +473,7 @@ class Evaluation implements GradebookItem $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } /** @@ -576,7 +574,7 @@ class Evaluation implements GradebookItem $data = Session::read('calc_score'); $results = isset($data[$key]) ? $data[$key] : null; - if ($useSession == false) { + if (false == $useSession) { $results = null; } $results = null; @@ -602,7 +600,7 @@ class Evaluation implements GradebookItem $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id; $data = Session::read('calc_score'); $allResults = isset($data[$key]) ? $data[$key] : null; - if ($useSession == false) { + if (false == $useSession) { $allResults = null; } @@ -615,7 +613,7 @@ class Evaluation implements GradebookItem /** @var Result $res */ foreach ($allResults as $res) { $score = $res->get_score(); - if (!empty($score) || $score == '0') { + if (!empty($score) || '0' == $score) { $count++; $sum += $score / $this->get_max(); $sumResult += $score; @@ -789,7 +787,7 @@ class Evaluation implements GradebookItem ); $foundevals = []; foreach ($evals as $eval) { - if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) { + if (!(false === api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)))) { $foundevals[] = $eval; } } diff --git a/public/main/gradebook/lib/be/exerciselink.class.php b/public/main/gradebook/lib/be/exerciselink.class.php index 389f9e32cf..67fcdd05a4 100644 --- a/public/main/gradebook/lib/be/exerciselink.class.php +++ b/public/main/gradebook/lib/be/exerciselink.class.php @@ -6,8 +6,6 @@ * Defines a gradebook ExerciseLink object. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class ExerciseLink extends AbstractLink { @@ -24,7 +22,7 @@ class ExerciseLink extends AbstractLink parent::__construct(); $this->set_type(LINK_EXERCISE); $this->is_hp = $hp; - if ($this->is_hp == 1) { + if (1 == $this->is_hp) { $this->set_type(LINK_HOTPOTATOES); } } @@ -111,7 +109,7 @@ class ExerciseLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } /** @@ -212,7 +210,7 @@ class ExerciseLink extends AbstractLink $exercise->read($exerciseId); if (!$this->is_hp) { - if ($exercise->exercise_was_added_in_lp == false) { + if (false == $exercise->exercise_was_added_in_lp) { $sql = "SELECT * FROM $tblStats WHERE exe_exo_id = $exerciseId AND @@ -240,7 +238,7 @@ class ExerciseLink extends AbstractLink c_id = $courseId "; } - if (!empty($stud_id) && $type != 'ranking') { + if (!empty($stud_id) && 'ranking' != $type) { $sql .= " AND exe_user_id = $stud_id "; } $sql .= ' ORDER BY exe_id DESC'; @@ -306,7 +304,7 @@ class ExerciseLink extends AbstractLink } if (!isset($students[$data['exe_user_id']])) { - if ($data['max_score'] != 0) { + if (0 != $data['max_score']) { $students[$data['exe_user_id']] = $data['score']; $student_count++; if ($data['score'] > $bestResult) { @@ -319,7 +317,7 @@ class ExerciseLink extends AbstractLink } } - if ($student_count == 0) { + if (0 == $student_count) { if ($cacheAvailable) { $cacheDriver->save($key, null); } @@ -437,7 +435,7 @@ class ExerciseLink extends AbstractLink */ public function get_type_name() { - if ($this->is_hp == 1) { + if (1 == $this->is_hp) { return 'HotPotatoes'; } @@ -499,7 +497,7 @@ class ExerciseLink extends AbstractLink public function get_exercise_data() { $tableItemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); - if ($this->is_hp == 1) { + if (1 == $this->is_hp) { $table = Database::get_course_table(TABLE_DOCUMENT); } else { $table = Database::get_course_table(TABLE_QUIZ_TEST); @@ -508,7 +506,7 @@ class ExerciseLink extends AbstractLink $exerciseId = $this->get_ref_id(); if (empty($this->exercise_data)) { - if ($this->is_hp == 1) { + if (1 == $this->is_hp) { $sql = "SELECT * FROM $table ex INNER JOIN $tableItemProperty ip ON (ip.ref = ex.id AND ip.c_id = ex.c_id) diff --git a/public/main/gradebook/lib/be/forumthreadlink.class.php b/public/main/gradebook/lib/be/forumthreadlink.class.php index 769dd91284..caa2fea1ce 100644 --- a/public/main/gradebook/lib/be/forumthreadlink.class.php +++ b/public/main/gradebook/lib/be/forumthreadlink.class.php @@ -5,8 +5,6 @@ * Class ForumThreadLink. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class ForumThreadLink extends AbstractLink { @@ -72,7 +70,7 @@ class ForumThreadLink extends AbstractLink $result = Database::query($sql); while ($data = Database::fetch_array($result)) { - if (isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != '') { + if (isset($data['thread_title_qualify']) && '' != $data['thread_title_qualify']) { $cats[] = [$data['thread_id'], $data['thread_title_qualify']]; } else { $cats[] = [$data['thread_id'], $data['thread_title']]; @@ -100,7 +98,7 @@ class ForumThreadLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } /** @@ -148,7 +146,7 @@ class ForumThreadLink extends AbstractLink // for 1 student if (isset($stud_id)) { - if ($threadInfo['thread_peer_qualify'] == 0) { + if (0 == $threadInfo['thread_peer_qualify']) { // Classic way of calculate score if ($data = Database::fetch_array($scores)) { return [ @@ -188,7 +186,7 @@ class ForumThreadLink extends AbstractLink while ($data = Database::fetch_array($scores)) { if (!(array_key_exists($data['user_id'], $students))) { - if ($assignment['thread_qualify_max'] != 0) { + if (0 != $assignment['thread_qualify_max']) { $students[$data['user_id']] = $data['qualify']; $counter++; $sum += $data['qualify'] / $assignment['thread_qualify_max']; @@ -201,7 +199,7 @@ class ForumThreadLink extends AbstractLink } } - if ($counter == 0) { + if (0 == $counter) { return [null, null]; } else { switch ($type) { @@ -245,7 +243,7 @@ class ForumThreadLink extends AbstractLink $this->get_exercise_data(); $thread_title = isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; $thread_title_qualify = isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; - if (isset($thread_title_qualify) && $thread_title_qualify != '') { + if (isset($thread_title_qualify) && '' != $thread_title_qualify) { return $this->exercise_data['thread_title_qualify']; } @@ -274,7 +272,7 @@ class ForumThreadLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } public function get_link() diff --git a/public/main/gradebook/lib/be/gradebookitem.class.php b/public/main/gradebook/lib/be/gradebookitem.class.php index 2929c0199f..4a36789d3a 100644 --- a/public/main/gradebook/lib/be/gradebookitem.class.php +++ b/public/main/gradebook/lib/be/gradebookitem.class.php @@ -5,8 +5,6 @@ * Interface for all displayable items in the gradebook. * * @author Bert Steppé - * - * @package chamilo.gradebook */ interface GradebookItem { diff --git a/public/main/gradebook/lib/be/learnpathlink.class.php b/public/main/gradebook/lib/be/learnpathlink.class.php index 1c32840dbe..e6422c3446 100644 --- a/public/main/gradebook/lib/be/learnpathlink.class.php +++ b/public/main/gradebook/lib/be/learnpathlink.class.php @@ -6,8 +6,6 @@ * * @author Yannick Warnier * @author Bert Steppé - * - * @package chamilo.gradebook */ class LearnpathLink extends AbstractLink { @@ -65,7 +63,7 @@ class LearnpathLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_array($result, 'NUM'); - return $number[0] != 0; + return 0 != $number[0]; } /** @@ -128,7 +126,7 @@ class LearnpathLink extends AbstractLink } } - if ($rescount == 0) { + if (0 == $rescount) { return [null, null]; } else { switch ($type) { @@ -160,7 +158,7 @@ class LearnpathLink extends AbstractLink $session_id ).'&gradebook=view'; - if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { + if (!api_is_allowed_to_edit() || null == $this->calc_score(api_get_user_id())) { $url .= '&action=view&lp_id='.$this->get_ref_id(); } else { $url .= '&action=build&lp_id='.$this->get_ref_id(); @@ -199,7 +197,7 @@ class LearnpathLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result, 'NUM'); - return $number[0] != 0; + return 0 != $number[0]; } public function get_type_name() diff --git a/public/main/gradebook/lib/be/linkfactory.class.php b/public/main/gradebook/lib/be/linkfactory.class.php index c1fc20d7cb..65bfb25e60 100644 --- a/public/main/gradebook/lib/be/linkfactory.class.php +++ b/public/main/gradebook/lib/be/linkfactory.class.php @@ -6,8 +6,6 @@ * Factory for link objects. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class LinkFactory { diff --git a/public/main/gradebook/lib/be/result.class.php b/public/main/gradebook/lib/be/result.class.php index b11e7bfefa..4b2deb042e 100644 --- a/public/main/gradebook/lib/be/result.class.php +++ b/public/main/gradebook/lib/be/result.class.php @@ -5,8 +5,6 @@ * Defines a gradebook Result object. * * @author Bert Steppé, Stijn Konings - * - * @package chamilo.gradebook */ class Result { @@ -107,7 +105,7 @@ class Result $result = Database::query($sql); $existEvaluation = Database::result($result, 0, 0); - if ($existEvaluation != 0) { + if (0 != $existEvaluation) { if ($sessionId) { $sql = 'SELECT c_id, user_id as user_id, status FROM '.$tbl_session_rel_course_user.' @@ -134,7 +132,7 @@ class Result evaluation_id="'.intval($evaluation_id).'";'; $res_verified = Database::query($sql_verified); $info_verified = Database::result($res_verified, 0, 0); - if ($info_verified == 0) { + if (0 == $info_verified) { $sql_insert = 'INSERT INTO '.$tbl_grade_results.'(user_id,evaluation_id,created_at,score) VALUES ("'.intval($list_user_course_list[$i]['user_id']).'","'.intval($evaluation_id).'","'.$current_date.'",0);'; Database::query($sql_insert); @@ -164,7 +162,7 @@ class Result $paramcount++; } if (!empty($user_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; @@ -173,7 +171,7 @@ class Result $paramcount++; } if (!empty($evaluation_id)) { - if ($paramcount != 0) { + if (0 != $paramcount) { $sql .= ' AND'; } else { $sql .= ' WHERE'; diff --git a/public/main/gradebook/lib/be/studentpublicationlink.class.php b/public/main/gradebook/lib/be/studentpublicationlink.class.php index 375a4b6a2e..695250dc1b 100644 --- a/public/main/gradebook/lib/be/studentpublicationlink.class.php +++ b/public/main/gradebook/lib/be/studentpublicationlink.class.php @@ -5,8 +5,6 @@ * Gradebook link to student publication item. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class StudentPublicationLink extends AbstractLink { @@ -139,7 +137,7 @@ class StudentPublicationLink extends AbstractLink 'session' => $session, ]); - return count($results) != 0; + return 0 != count($results); } /** @@ -250,7 +248,7 @@ class StudentPublicationLink extends AbstractLink foreach ($scores as $data) { if (!(array_key_exists($data->getUserId(), $students))) { - if ($assignment->getQualification() != 0) { + if (0 != $assignment->getQualification()) { $students[$data->getUserId()] = $data->getQualification(); $rescount++; $sum += $data->getQualification() / $assignment->getQualification(); @@ -264,7 +262,7 @@ class StudentPublicationLink extends AbstractLink } } - if ($rescount == 0) { + if (0 == $rescount) { return [null, null]; } @@ -337,7 +335,7 @@ class StudentPublicationLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } public function get_icon_name() diff --git a/public/main/gradebook/lib/be/surveylink.class.php b/public/main/gradebook/lib/be/surveylink.class.php index d4b4728272..8023b92284 100644 --- a/public/main/gradebook/lib/be/surveylink.class.php +++ b/public/main/gradebook/lib/be/surveylink.class.php @@ -5,8 +5,6 @@ * Gradebook link to a survey item. * * @author Ivan Tcholakov , 2010 - * - * @package chamilo.gradebook */ class SurveyLink extends AbstractLink { @@ -125,7 +123,7 @@ class SurveyLink extends AbstractLink $sql_result = Database::query($sql); $data = Database::fetch_array($sql_result); - return $data[0] != 0; + return 0 != $data[0]; } /** @@ -186,7 +184,7 @@ class SurveyLink extends AbstractLink } $sum = $sum / $max_score; - if ($rescount == 0) { + if (0 == $rescount) { return [null, null]; } @@ -223,7 +221,7 @@ class SurveyLink extends AbstractLink $result = Database::query($sql); $number = Database::fetch_row($result); - return $number[0] != 0; + return 0 != $number[0]; } public function get_link() @@ -238,7 +236,7 @@ class SurveyLink extends AbstractLink $sessionId = $this->get_session_id(); $courseId = $this->getCourseId(); - if ($tbl_name != '') { + if ('' != $tbl_name) { $sql = 'SELECT survey_id FROM '.$this->get_survey_table().' WHERE @@ -285,7 +283,7 @@ class SurveyLink extends AbstractLink { $tbl_name = $this->get_survey_table(); - if ($tbl_name == '') { + if ('' == $tbl_name) { return false; } elseif (empty($this->survey_data)) { $courseId = $this->getCourseId(); diff --git a/public/main/gradebook/lib/fe/catform.class.php b/public/main/gradebook/lib/fe/catform.class.php index f758f146fe..c65ae0e091 100644 --- a/public/main/gradebook/lib/fe/catform.class.php +++ b/public/main/gradebook/lib/fe/catform.class.php @@ -5,8 +5,6 @@ * Class CatForm. * * @author Stijn Konings - * - * @package chamilo.gradebook */ class CatForm extends FormValidator { @@ -97,7 +95,7 @@ class CatForm extends FormValidator { // check if we are a root category // if so, you can only choose between courses - if ($this->category_object->get_parent_id() == '0') { + if ('0' == $this->category_object->get_parent_id()) { $this->setDefaults( [ 'select_course' => $this->category_object->get_course_code(), @@ -154,7 +152,7 @@ class CatForm extends FormValidator $category_name = $this->category_object->get_name(); // The main course category: - if (isset($this->category_object) && $this->category_object->get_parent_id() == 0) { + if (isset($this->category_object) && 0 == $this->category_object->get_parent_id()) { if (empty($category_name)) { $category_name = $course_code; } @@ -222,7 +220,7 @@ class CatForm extends FormValidator $this->addRule('name', get_lang('Required field'), 'required'); if (isset($this->category_object) && - $this->category_object->get_parent_id() == 0 + 0 == $this->category_object->get_parent_id() ) { // we can't change the root category $this->freeze('name'); @@ -284,7 +282,7 @@ class CatForm extends FormValidator } if (isset($this->category_object) && - $this->category_object->get_parent_id() == 0 + 0 == $this->category_object->get_parent_id() ) { $model = ExerciseLib::getCourseScoreModel(); if (empty($model)) { @@ -344,8 +342,8 @@ class CatForm extends FormValidator ); if (isset($this->category_object) && - $this->category_object->get_parent_id() == 0 && - (api_is_platform_admin() || api_get_setting('teachers_can_change_grade_model_settings') == 'true') + 0 == $this->category_object->get_parent_id() && + (api_is_platform_admin() || 'true' == api_get_setting('teachers_can_change_grade_model_settings')) ) { // Getting grade models $obj = new GradeModel(); @@ -373,7 +371,7 @@ class CatForm extends FormValidator } if (count($test_cats) > 1 || !empty($links)) { - if (api_get_setting('gradebook_enable_grade_model') == 'true') { + if ('true' == api_get_setting('gradebook_enable_grade_model')) { $this->freeze('grade_model_id'); } } @@ -416,7 +414,7 @@ class CatForm extends FormValidator } } - if ($this->form_type == self::TYPE_ADD) { + if (self::TYPE_ADD == $this->form_type) { $this->addButtonCreate(get_lang('Add category')); } else { $this->addElement('hidden', 'editcat', intval($_GET['editcat'])); @@ -425,7 +423,7 @@ class CatForm extends FormValidator $setting = api_get_setting('tool_visible_by_default_at_creation'); $visibility_default = 1; - if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') { + if (isset($setting['gradebook']) && 'false' == $setting['gradebook']) { $visibility_default = 0; } diff --git a/public/main/gradebook/lib/fe/dataform.class.php b/public/main/gradebook/lib/fe/dataform.class.php index 0c3d61ef4b..9b0b1e00cb 100644 --- a/public/main/gradebook/lib/fe/dataform.class.php +++ b/public/main/gradebook/lib/fe/dataform.class.php @@ -5,8 +5,6 @@ * Extends FormValidator with import and export forms. * * @author Stijn Konings - * - * @package chamilo.gradebook */ class DataForm extends FormValidator { @@ -34,15 +32,15 @@ class DataForm extends FormValidator ) { parent:: __construct($form_name, $method, $action, $target); $this->form_type = $form_type; - if ($this->form_type == self::TYPE_IMPORT) { + if (self::TYPE_IMPORT == $this->form_type) { $this->build_import_form(); - } elseif ($this->form_type == self::TYPE_EXPORT) { - if ($locked_status == 0) { + } elseif (self::TYPE_EXPORT == $this->form_type) { + if (0 == $locked_status) { $this->build_export_form_option(false); } else { $this->build_export_form(); } - } elseif ($this->form_type == self::TYPE_EXPORT_PDF) { + } elseif (self::TYPE_EXPORT_PDF == $this->form_type) { $this->build_pdf_export_form(); } $this->setDefaults(); diff --git a/public/main/gradebook/lib/fe/displaygradebook.php b/public/main/gradebook/lib/fe/displaygradebook.php index 34584e4fc9..b2b4397c92 100644 --- a/public/main/gradebook/lib/fe/displaygradebook.php +++ b/public/main/gradebook/lib/fe/displaygradebook.php @@ -3,8 +3,6 @@ /** * Class DisplayGradebook. - * - * @package chamilo.gradebook */ class DisplayGradebook { @@ -21,16 +19,16 @@ class DisplayGradebook $header = null; if (api_is_allowed_to_edit(null, true)) { $header = '
'; - if ($page !== 'statistics') { + if ('statistics' !== $page) { $header .= ''. Display::return_icon('back.png', get_lang('Assessment home'), '', ICON_SIZE_MEDIUM) .''; - if (($evalobj->get_course_code() != null) && !$evalobj->has_results()) { + if ((null != $evalobj->get_course_code()) && !$evalobj->has_results()) { $header .= ' '.Display::return_icon('evaluation_rate.png', get_lang('Grade learners'), '', ICON_SIZE_MEDIUM).''; } - if (api_is_platform_admin() || $evalobj->is_locked() == false) { + if (api_is_platform_admin() || false == $evalobj->is_locked()) { $header .= ''. Display::return_icon('import_evaluation.png', get_lang('Import marks'), '', ICON_SIZE_MEDIUM).''; } @@ -39,7 +37,7 @@ class DisplayGradebook $header .= ''. Display::return_icon('export_evaluation.png', get_lang('PDF Report'), '', ICON_SIZE_MEDIUM).''; - if (api_is_platform_admin() || $evalobj->is_locked() == false) { + if (api_is_platform_admin() || false == $evalobj->is_locked()) { $header .= ''. Display::return_icon('edit.png', get_lang('Grade learners'), '', ICON_SIZE_MEDIUM).''; $header .= ''. @@ -61,7 +59,7 @@ class DisplayGradebook if ($evalobj->has_results()) { // TODO this check needed ? $score = $evalobj->calc_score(); - if ($score != null) { + if (null != $score) { $model = ExerciseLib::getCourseScoreModel(); if (empty($model)) { $average = get_lang('Average').' : '.$scoredisplay->display_score($score, SCORE_AVERAGE).''; @@ -86,11 +84,11 @@ class DisplayGradebook } $description = ''; - if (!$evalobj->get_description() == '') { + if ('' == !$evalobj->get_description()) { $description = get_lang('Description').' : '.$evalobj->get_description().'
'; } - if ($evalobj->get_course_code() == null) { + if (null == $evalobj->get_course_code()) { $course = get_lang('Independent from course'); } else { $course = CourseManager::getCourseNameFromCode($evalobj->get_course_code()); @@ -112,7 +110,7 @@ class DisplayGradebook $evalinfo .= '
'.get_lang('No results in evaluation for now').''; } - if ($page != 'statistics') { + if ('statistics' != $page) { if (api_is_allowed_to_edit(null, true)) { $evalinfo .= '
'. Display::return_icon( @@ -144,7 +142,7 @@ class DisplayGradebook public static function display_header_reduce_flatview($catobj, $showeval, $showlink, $simple_search_form) { $header = '
'; - if ($catobj->get_parent_id() == 0) { + if (0 == $catobj->get_parent_id()) { $select_cat = $catobj->get_id(); $url = Category::getUrl(); } else { @@ -310,7 +308,7 @@ class DisplayGradebook ); } - if (!$is_course_admin && ($status != 1 || $sessionStatus == 0) && $selectcat != 0) { + if (!$is_course_admin && (1 != $status || 0 == $sessionStatus) && 0 != $selectcat) { $catcourse = Category::load($catobj->get_id()); /** @var Category $category */ $category = $catcourse[0]; @@ -326,7 +324,7 @@ class DisplayGradebook $item = $allEvalsLinks[$count]; $score = $item->calc_score($userId); if (!empty($score)) { - $divide = $score[1] == 0 ? 1 : $score[1]; + $divide = 0 == $score[1] ? 1 : $score[1]; $item_value = $score[0] / $divide * $item->get_weight(); $item_value_total += $item_value; } @@ -336,7 +334,7 @@ class DisplayGradebook $total_score = [$item_value_total, $item_total]; $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT); - if (!$catobj->get_id() == '0' && !isset($_GET['studentoverview']) && !isset($_GET['search'])) { + if ('0' == !$catobj->get_id() && !isset($_GET['studentoverview']) && !isset($_GET['search'])) { $additionalButtons = null; if (!empty($certificateLinkInfo)) { $additionalButtons .= '
'; @@ -350,10 +348,10 @@ class DisplayGradebook } // show navigation tree and buttons? - if ($showtree == '1' || isset($_GET['studentoverview'])) { + if ('1' == $showtree || isset($_GET['studentoverview'])) { $header = '
'.$key.''.Display::bar_progress($bar).'
'; $header .= ''; - if (!$selectcat == '0') { + if ('0' == !$selectcat) { $header .= ''; - if (!empty($simple_search_form) && $message_resource === false) { + if (!empty($simple_search_form) && false === $message_resource) { $header .= ''; } else { $header .= ''; } if (!($is_course_admin && - $message_resource === false && - isset($_GET['selectcat']) && $_GET['selectcat'] != 0) && + false === $message_resource && + isset($_GET['selectcat']) && 0 != $_GET['selectcat']) && isset($_GET['studentoverview']) ) { $header .= ''; } - if ($selectcat != '0' && $accessToRead) { + if ('0' != $selectcat && $accessToRead) { if (!$message_resource) { $actionsLeft .= ''. Display::return_icon('statistics.png', get_lang('List View'), '', ICON_SIZE_MEDIUM).''; - if ($my_category['generate_certificates'] == 1) { + if (1 == $my_category['generate_certificates']) { $actionsLeft .= Display::url( Display::return_icon( 'certificate_list.png', @@ -486,8 +484,8 @@ class DisplayGradebook ).'&cidReq='.$catobj->get_course_code().'&id_session='.$catobj->get_session_id().'">'. Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).''; - if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' && - api_get_course_setting('customcertificate_course_enable') == 1 + if ('true' == api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') && + 1 == api_get_course_setting('customcertificate_course_enable') ) { $actionsRight .= ''. Display::return_icon('ranking.png', get_lang('Skills ranking'), '', ICON_SIZE_MEDIUM).''; @@ -585,7 +583,7 @@ class DisplayGradebook $msg = $weight.' - '.$min_certification.$edit_icon; //@todo show description - $description = (($catobj->get_description() == '' || is_null($catobj->get_description())) ? '' : ''.get_lang('Assessment description').''.': '.$catobj->get_description()); + $description = (('' == $catobj->get_description() || is_null($catobj->get_description())) ? '' : ''.get_lang('Assessment description').''.': '.$catobj->get_description()); echo Display::return_message($msg, 'normal', false); if (!empty($description)) { echo Display::div($description, []); @@ -620,7 +618,7 @@ class DisplayGradebook $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('No results available'); $scoreinfo = get_lang('Statistics of').' : '.$user['complete_name'].'
'; - if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) { + if (('0' == !$catobj->get_id()) && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) { $scoreinfo .= '
'.get_lang('Total for this category.').' : '.$scorecourse_display.''; } $scoreinfo .= '
'.get_lang('Total').' : '.$scoretotal_display.''; @@ -676,7 +674,7 @@ class DisplayGradebook for ($count = 0; $count < count($evals_links); $count++) { $item = $evals_links[$count]; $score = $item->calc_score($userId); - $my_score_denom = ($score[1] == 0) ? 1 : $score[1]; + $my_score_denom = (0 == $score[1]) ? 1 : $score[1]; $item_value += $score[0] / $my_score_denom * $item->get_weight(); $item_total += $item->get_weight(); } @@ -690,7 +688,7 @@ class DisplayGradebook $info .= '
'; $info .= get_lang('Name').' : '.$user['complete_name_with_message_link'].'
'; - if (api_get_setting('show_email_addresses') == 'true') { + if ('true' == api_get_setting('show_email_addresses')) { $info .= get_lang('e-mail').' : '.$user['email'].'
'; } diff --git a/public/main/gradebook/lib/fe/evalform.class.php b/public/main/gradebook/lib/fe/evalform.class.php index f52d5a7ca9..c9fe494618 100644 --- a/public/main/gradebook/lib/fe/evalform.class.php +++ b/public/main/gradebook/lib/fe/evalform.class.php @@ -7,8 +7,6 @@ * Extends FormValidator with add&edit forms for evaluations * * @author Stijn Konings - * - * @package chamilo.gradebook */ class EvalForm extends FormValidator { @@ -98,12 +96,12 @@ class EvalForm extends FormValidator $user2 = $item2['user']; if (api_sort_by_first_name()) { $result = api_strcmp($user1['firstname'], $user2['firstname']); - if ($result == 0) { + if (0 == $result) { return api_strcmp($user1['lastname'], $user2['lastname']); } } else { $result = api_strcmp($user1['lastname'], $user2['lastname']); - if ($result == 0) { + if (0 == $result) { return api_strcmp($user1['firstname'], $user2['firstname']); } } @@ -471,7 +469,7 @@ class EvalForm extends FormValidator ] ); $this->build_basic_form(); - if ($this->evaluation_object->get_course_code() == null) { + if (null == $this->evaluation_object->get_course_code()) { $this->addElement('checkbox', 'adduser', null, get_lang('Add users to evaluation')); } else { $this->addElement('checkbox', 'addresult', null, get_lang('Grade learners')); @@ -486,7 +484,7 @@ class EvalForm extends FormValidator { $parent_cat = Category::load($this->evaluation_object->get_category_id()); //@TODO $weight_mask is replaced? - if ($parent_cat[0]->get_parent_id() == 0) { + if (0 == $parent_cat[0]->get_parent_id()) { $weight_mask = $this->evaluation_object->get_weight(); } else { $cat = Category::load($parent_cat[0]->get_parent_id()); @@ -522,7 +520,7 @@ class EvalForm extends FormValidator private function build_basic_form($edit = 0) { $form_title = get_lang('Add classroom activity'); - if (!empty($_GET['editeval']) && $_GET['editeval'] == 1) { + if (!empty($_GET['editeval']) && 1 == $_GET['editeval']) { $form_title = get_lang('Edit evaluation'); } @@ -554,7 +552,7 @@ class EvalForm extends FormValidator false ); - if (count($all_categories) == 1) { + if (1 == count($all_categories)) { $this->addElement('hidden', 'hid_category_id', $cat_id); } else { $select_gradebook = $this->addElement( @@ -571,7 +569,7 @@ class EvalForm extends FormValidator if ($my_cat->get_course_code() == api_get_course_id()) { $grade_model_id = $my_cat->get_grade_model_id(); if (empty($grade_model_id)) { - if ($my_cat->get_parent_id() == 0) { + if (0 == $my_cat->get_parent_id()) { $default_weight = $my_cat->get_weight(); $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id()); $cats_added[] = $my_cat->get_id(); @@ -697,7 +695,7 @@ class EvalForm extends FormValidator ); $setting = api_get_setting('tool_visible_by_default_at_creation'); $visibility_default = 1; - if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') { + if (isset($setting['gradebook']) && 'false' == $setting['gradebook']) { $visibility_default = 0; } $this->setDefaults(['visible' => $visibility_default]); @@ -719,7 +717,7 @@ class EvalForm extends FormValidator if ($this->evaluation_object->get_category_id() < 0) { $link = LinkFactory::get_evaluation_link($this->evaluation_object->get_id()); $doc_url = $link->get_view_url($id); - if ($doc_url != null) { + if (null != $doc_url) { $opendocurl_start .= ''; $opendocurl_end = ''; } diff --git a/public/main/gradebook/lib/fe/exportgradebook.php b/public/main/gradebook/lib/fe/exportgradebook.php index 1a882ec217..56a5876b9d 100644 --- a/public/main/gradebook/lib/fe/exportgradebook.php +++ b/public/main/gradebook/lib/fe/exportgradebook.php @@ -2,8 +2,6 @@ /* For licensing terms, see /license.txt */ /** * Script. - * - * @package chamilo.gradebook */ /** @@ -165,7 +163,7 @@ function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footer $content_table .= '
'; foreach ($data as $key => $content) { if (isset($content)) { - $key == 1 ? $align = 'align="left"' : $align = 'align="center"'; + 1 == $key ? $align = 'align="left"' : $align = 'align="center"'; $content_table .= ''; } } @@ -203,22 +201,22 @@ function export_pdf($pdf, $newarray, $header_names, $format) { $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->ezSetCmMargins(0, 0, 0, 0); - $pdf->ezSetY(($format == 'portrait') ? '820' : '570'); + $pdf->ezSetY(('portrait' == $format) ? '820' : '570'); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); - if ($format == 'portrait') { + if ('portrait' == $format) { $pdf->line(40, 790, 540, 790); $pdf->line(40, 40, 540, 40); } else { $pdf->line(40, 540, 790, 540); $pdf->line(40, 40, 790, 40); } - $pdf->ezSetY(($format == 'portrait') ? '750' : '520'); + $pdf->ezSetY(('portrait' == $format) ? '750' : '520'); $pdf->ezTable($newarray, $header_names, '', [ 'showHeadings' => 1, 'shaded' => 1, 'showLines' => 1, 'rowGap' => 3, - 'width' => (($format == 'portrait') ? '500' : '750'), + 'width' => (('portrait' == $format) ? '500' : '750'), ]); $pdf->ezStream(); } diff --git a/public/main/gradebook/lib/fe/flatviewtable.class.php b/public/main/gradebook/lib/fe/flatviewtable.class.php index dfe1133f80..4abf88c37a 100644 --- a/public/main/gradebook/lib/fe/flatviewtable.class.php +++ b/public/main/gradebook/lib/fe/flatviewtable.class.php @@ -14,8 +14,6 @@ use CpChart\Image as pImage; * @author Stijn Konings * @author Bert Steppé - (refactored, optimised) * @author Julio Montoya Armas - Gradebook Graphics - * - * @package chamilo.gradebook */ class FlatViewTable extends SortableTable { @@ -317,7 +315,7 @@ class FlatViewTable extends SortableTable $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; } echo ''; - if ($i % 2 == 0 && $i != 0) { + if (0 == $i % 2 && 0 != $i) { echo '

'; } else { echo '   '; @@ -410,12 +408,12 @@ class FlatViewTable extends SortableTable // retrieve sorting type if ($is_western_name_order) { - $users_sorting = ($this->column == 0 ? FlatViewDataGenerator::FVDG_SORT_FIRSTNAME : FlatViewDataGenerator::FVDG_SORT_LASTNAME); + $users_sorting = (0 == $this->column ? FlatViewDataGenerator::FVDG_SORT_FIRSTNAME : FlatViewDataGenerator::FVDG_SORT_LASTNAME); } else { - $users_sorting = ($this->column == 0 ? FlatViewDataGenerator::FVDG_SORT_LASTNAME : FlatViewDataGenerator::FVDG_SORT_FIRSTNAME); + $users_sorting = (0 == $this->column ? FlatViewDataGenerator::FVDG_SORT_LASTNAME : FlatViewDataGenerator::FVDG_SORT_FIRSTNAME); } - if ($this->direction == 'DESC') { + if ('DESC' == $this->direction) { $users_sorting |= FlatViewDataGenerator::FVDG_SORT_DESC; } else { $users_sorting |= FlatViewDataGenerator::FVDG_SORT_ASC; diff --git a/public/main/gradebook/lib/fe/gradebooktable.class.php b/public/main/gradebook/lib/fe/gradebooktable.class.php index d96b7149cd..ed17b6d721 100644 --- a/public/main/gradebook/lib/fe/gradebooktable.class.php +++ b/public/main/gradebook/lib/fe/gradebooktable.class.php @@ -12,8 +12,6 @@ use CpChart\Image as pImage; * * @author Stijn Konings * @author Bert Steppé (refactored, optimised) - * - * @package chamilo.gradebook */ class GradebookTable extends SortableTable { @@ -93,7 +91,7 @@ class GradebookTable extends SortableTable $column = 0; if ($this->teacherView) { - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $this->set_header($column++, '', '', 'width="25px"'); } } @@ -101,7 +99,7 @@ class GradebookTable extends SortableTable $this->set_header($column++, get_lang('Type'), '', 'width="35px"'); $this->set_header($column++, get_lang('Name'), false); - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $this->set_header($column++, get_lang('Description'), false); } @@ -133,7 +131,7 @@ class GradebookTable extends SortableTable if ($this->teacherView) { } else { if (!empty($cats)) { - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $this->set_header($column++, get_lang('Detail'), false); } } @@ -155,7 +153,7 @@ class GradebookTable extends SortableTable ); } else { if (empty($_GET['selectcat']) && !$this->teacherView) { - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $this->set_header( $column++, get_lang('Certificates'), @@ -324,7 +322,7 @@ class GradebookTable extends SortableTable break; } - if ($this->direction == 'DESC') { + if ('DESC' == $this->direction) { $sorting |= GradebookDataGenerator::GDG_SORT_DESC; } else { $sorting |= GradebookDataGenerator::GDG_SORT_ASC; @@ -404,12 +402,12 @@ class GradebookTable extends SortableTable $item = $data[0]; // If the item is invisible, wrap it in a span with class invisible - $invisibility_span_open = $isAllowedToEdit && $item->is_visible() == '0' ? '' : ''; - $invisibility_span_close = $isAllowedToEdit && $item->is_visible() == '0' ? '' : ''; + $invisibility_span_open = $isAllowedToEdit && '0' == $item->is_visible() ? '' : ''; + $invisibility_span_close = $isAllowedToEdit && '0' == $item->is_visible() ? '' : ''; // Id if ($this->teacherView) { - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $row[] = $this->build_id_column($item); } } @@ -418,7 +416,7 @@ class GradebookTable extends SortableTable $row[] = $this->build_type_column($item); // Name. - if (get_class($item) === 'Category') { + if ('Category' === get_class($item)) { $row[] = $invisibility_span_open.''.$item->get_name().''.$invisibility_span_close; $main_categories[$item->get_id()]['name'] = $item->get_name(); } else { @@ -432,7 +430,7 @@ class GradebookTable extends SortableTable $total_categories_weight += $item->get_weight(); // Description. - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; } @@ -465,7 +463,7 @@ class GradebookTable extends SortableTable if ($this->teacherView) { $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); - if ($show_message === false) { + if (false === $show_message) { $row[] = $this->build_edit_column($item); } } else { @@ -553,8 +551,8 @@ class GradebookTable extends SortableTable } } - if (get_class($item) === 'Category') { - if ($this->exportToPdf == false) { + if ('Category' === get_class($item)) { + if (false == $this->exportToPdf) { $row[] = $this->build_edit_column($item); } } @@ -564,7 +562,7 @@ class GradebookTable extends SortableTable $sortable_data[] = $row; // Loading children - if (get_class($item) === 'Category') { + if ('Category' === get_class($item)) { $parent_id = $item->get_id(); $cats = Category::load( $parent_id, @@ -600,8 +598,8 @@ class GradebookTable extends SortableTable $item = $data[0]; //if the item is invisible, wrap it in a span with class invisible - $invisibility_span_open = $isAllowedToEdit && $item->is_visible() == '0' ? '' : ''; - $invisibility_span_close = $isAllowedToEdit && $item->is_visible() == '0' ? '' : ''; + $invisibility_span_open = $isAllowedToEdit && '0' == $item->is_visible() ? '' : ''; + $invisibility_span_close = $isAllowedToEdit && '0' == $item->is_visible() ? '' : ''; if (isset($item)) { $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name(); @@ -609,7 +607,7 @@ class GradebookTable extends SortableTable } if ($this->teacherView) { - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $row[] = $this->build_id_column($item); } } @@ -622,7 +620,7 @@ class GradebookTable extends SortableTable $this->build_name_link($item, $type).$invisibility_span_close; // Description. - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $row[] = $invisibility_span_open.$data[2].$invisibility_span_close; } @@ -634,13 +632,13 @@ class GradebookTable extends SortableTable // Admins get an edit column. if (api_is_allowed_to_edit(null, true) && - isset($_GET['user_id']) == false && - (isset($_GET['action']) && $_GET['action'] != 'export_all' || !isset($_GET['action'])) + false == isset($_GET['user_id']) && + (isset($_GET['action']) && 'export_all' != $_GET['action'] || !isset($_GET['action'])) ) { $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); - if ($show_message === false) { - if ($this->exportToPdf == false) { + if (false === $show_message) { + if (false == $this->exportToPdf) { $row[] = $this->build_edit_column($item); } } @@ -678,13 +676,13 @@ class GradebookTable extends SortableTable } if (!empty($cats)) { - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $row[] = null; } } } - if ($this->exportToPdf == false) { + if (false == $this->exportToPdf) { $row['child_of'] = $parent_id; } $sortable_data[] = $row; @@ -730,7 +728,7 @@ class GradebookTable extends SortableTable /** @var Category $myCat */ foreach ($main_cat as $myCat) { $myParentId = $myCat->get_parent_id(); - if ($myParentId == 0) { + if (0 == $myParentId) { $main_weight = (int) $myCat->get_weight(); } } @@ -893,7 +891,7 @@ class GradebookTable extends SortableTable if ($this->teacherView) { if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && - $view !== 'presence' + 'presence' !== $view ) { $id_cat = (int) $_GET['selectcat']; $category = Category::load($id_cat); @@ -1188,15 +1186,15 @@ class GradebookTable extends SortableTable $show_message = $cat->show_message_resource_delete($course_id); // course/platform admin can go to the view_results page - if (api_is_allowed_to_edit() && $show_message === false) { - if ($item->get_type() == 'presence') { + if (api_is_allowed_to_edit() && false === $show_message) { + if ('presence' == $item->get_type()) { return ' ' .'' .$item->get_name() .''; } else { $extra = Display::label(get_lang('Score')); - if ($type == 'simple') { + if ('simple' == $type) { $extra = ''; } @@ -1205,13 +1203,13 @@ class GradebookTable extends SortableTable .$item->get_name() .' '.$extra; } - } elseif (ScoreDisplay::instance()->is_custom() && $show_message === false) { + } elseif (ScoreDisplay::instance()->is_custom() && false === $show_message) { // students can go to the statistics page (if custom display enabled) return ' ' .'' .$item->get_name() .''; - } elseif ($show_message === false && !api_is_allowed_to_edit() && !ScoreDisplay::instance()->is_custom()) { + } elseif (false === $show_message && !api_is_allowed_to_edit() && !ScoreDisplay::instance()->is_custom()) { return ' ' .'' .$item->get_name() @@ -1229,14 +1227,14 @@ class GradebookTable extends SortableTable $url = $item->get_link(); $text = $item->get_name(); - if (isset($url) && $show_message === false) { + if (isset($url) && false === $show_message) { $text = ' ' .$item->get_name() .''; } $extra = Display::label($item->get_type_name(), 'info'); - if ($type == 'simple') { + if ('simple' == $type) { $extra = ''; } $extra .= $item->getSkillsFromItem(); diff --git a/public/main/gradebook/lib/fe/linkaddeditform.class.php b/public/main/gradebook/lib/fe/linkaddeditform.class.php index 5029b43e64..455669e732 100644 --- a/public/main/gradebook/lib/fe/linkaddeditform.class.php +++ b/public/main/gradebook/lib/fe/linkaddeditform.class.php @@ -6,8 +6,6 @@ * * @author Stijn Konings * @author Bert Steppé - * - * @package chamilo.gradebook */ class LinkAddEditForm extends FormValidator { @@ -46,7 +44,7 @@ class LinkAddEditForm extends FormValidator } // ELEMENT: name - if ($form_type == self::TYPE_ADD || $link->is_allowed_to_change_name()) { + if (self::TYPE_ADD == $form_type || $link->is_allowed_to_change_name()) { if ($link->needs_name_and_description()) { $this->addText('name', get_lang('Name'), true, ['size' => '40', 'maxlength' => '40']); } else { @@ -70,7 +68,7 @@ class LinkAddEditForm extends FormValidator ); } - if (count($category_object) == 1) { + if (1 == count($category_object)) { $this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id()); } else { $select_gradebook = $this->addElement( @@ -87,7 +85,7 @@ class LinkAddEditForm extends FormValidator if ($my_cat->get_course_code() == api_get_course_id()) { $grade_model_id = $my_cat->get_grade_model_id(); if (empty($grade_model_id)) { - if ($my_cat->get_parent_id() == 0) { + if (0 == $my_cat->get_parent_id()) { $default_weight = $my_cat->get_weight(); $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id()); } else { @@ -121,9 +119,9 @@ class LinkAddEditForm extends FormValidator $this->addElement('hidden', 'weight'); - if ($form_type == self::TYPE_EDIT) { + if (self::TYPE_EDIT == $form_type) { $parent_cat = Category::load($link->get_category_id()); - if ($parent_cat[0]->get_parent_id() == 0) { + if (0 == $parent_cat[0]->get_parent_id()) { $values['weight'] = $link->get_weight(); } else { $cat = Category::load($parent_cat[0]->get_parent_id()); @@ -139,7 +137,7 @@ class LinkAddEditForm extends FormValidator } // ELEMENT: max if ($link->needs_max()) { - if ($form_type == self::TYPE_EDIT && $link->has_results()) { + if (self::TYPE_EDIT == $form_type && $link->has_results()) { $this->addText( 'max', get_lang('Maximum score'), @@ -164,7 +162,7 @@ class LinkAddEditForm extends FormValidator 0 ); } - if ($form_type == self::TYPE_EDIT) { + if (self::TYPE_EDIT == $form_type) { $defaults['max'] = $link->get_max(); } } @@ -177,33 +175,33 @@ class LinkAddEditForm extends FormValidator get_lang('Description'), ['rows' => '3', 'cols' => '34'] ); - if ($form_type == self::TYPE_EDIT) { + if (self::TYPE_EDIT == $form_type) { $defaults['description'] = $link->get_description(); } } // ELEMENT: visible - $visible = ($form_type == self::TYPE_EDIT && $link->is_visible()) ? '1' : '0'; + $visible = (self::TYPE_EDIT == $form_type && $link->is_visible()) ? '1' : '0'; $this->addElement('checkbox', 'visible', null, get_lang('Visible'), $visible); - if ($form_type == self::TYPE_EDIT) { + if (self::TYPE_EDIT == $form_type) { $defaults['visible'] = $link->is_visible(); } // ELEMENT: add results - if ($form_type == self::TYPE_ADD && $link->needs_results()) { + if (self::TYPE_ADD == $form_type && $link->needs_results()) { $this->addElement('checkbox', 'addresult', get_lang('Grade learners')); } // submit button - if ($form_type == self::TYPE_ADD) { + if (self::TYPE_ADD == $form_type) { $this->addButtonCreate(get_lang('Add this learning activity to the assessment')); } else { $this->addButtonUpdate(get_lang('Edit link')); } - if ($form_type == self::TYPE_ADD) { + if (self::TYPE_ADD == $form_type) { $setting = api_get_setting('tool_visible_by_default_at_creation'); $visibility_default = 1; - if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') { + if (isset($setting['gradebook']) && 'false' == $setting['gradebook']) { $visibility_default = 0; } $defaults['visible'] = $visibility_default; diff --git a/public/main/gradebook/lib/fe/linkform.class.php b/public/main/gradebook/lib/fe/linkform.class.php index 91bfb57b32..e75b0d9775 100644 --- a/public/main/gradebook/lib/fe/linkform.class.php +++ b/public/main/gradebook/lib/fe/linkform.class.php @@ -7,8 +7,6 @@ * * @author Stijn Konings * @author Bert Steppé (made more generic) - * - * @package chamilo.gradebook */ class LinkForm extends FormValidator { @@ -50,9 +48,9 @@ class LinkForm extends FormValidator if (isset($extra)) { $this->extra = $extra; } - if ($form_type == self::TYPE_CREATE) { + if (self::TYPE_CREATE == $form_type) { $this->build_create(); - } elseif ($form_type == self::TYPE_MOVE) { + } elseif (self::TYPE_MOVE == $form_type) { $this->build_move(); } } @@ -102,19 +100,19 @@ class LinkForm extends FormValidator foreach ($linkTypes as $linkType) { // The hot potatoe link will be added "inside" the exercise option. - if ($linkType == LINK_HOTPOTATOES) { + if (LINK_HOTPOTATOES == $linkType) { continue; } $link = $this->createLink($linkType, $courseCode); // disable this element if the link works with a dropdownlist // and if there are no links left - if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') { + if (!$link->needs_name_and_description() && '0' == count($link->get_all_links())) { $select->addoption($link->get_type_name(), $linkType, 'disabled'); } else { $select->addoption($link->get_type_name(), $linkType); } - if ($link->get_type() == LINK_EXERCISE) { + if (LINK_EXERCISE == $link->get_type()) { // Adding hot potatoes $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode); $linkHot->setHp(true); diff --git a/public/main/gradebook/lib/fe/resulttable.class.php b/public/main/gradebook/lib/fe/resulttable.class.php index c5717a6eb2..42aec9a580 100644 --- a/public/main/gradebook/lib/fe/resulttable.class.php +++ b/public/main/gradebook/lib/fe/resulttable.class.php @@ -49,7 +49,7 @@ class ResultTable extends SortableTable } $scoredisplay = ScoreDisplay::instance(); $column = 0; - if ($this->iscourse == '1') { + if ('1' == $this->iscourse) { $this->set_header($column++, '', false); $this->set_form_actions([ 'delete' => get_lang('Delete'), @@ -98,7 +98,7 @@ class ResultTable extends SortableTable $scoredisplay = ScoreDisplay::instance(); // determine sorting type - $col_adjust = $this->iscourse == '1' ? 1 : 0; + $col_adjust = '1' == $this->iscourse ? 1 : 0; switch ($this->column) { // first name or last name @@ -126,7 +126,7 @@ class ResultTable extends SortableTable break; } - if ($this->direction === 'DESC') { + if ('DESC' === $this->direction) { $sorting |= ResultsDataGenerator::RDG_SORT_DESC; } else { $sorting |= ResultsDataGenerator::RDG_SORT_ASC; @@ -140,7 +140,7 @@ class ResultTable extends SortableTable $sortable_data = []; foreach ($data_array as $item) { $row = []; - if ($this->iscourse == '1') { + if ('1' == $this->iscourse) { $row[] = $item['result_id']; } if ($isWesternNameOrder) { @@ -230,7 +230,7 @@ class ResultTable extends SortableTable $allowMultipleAttempts = api_get_configuration_value('gradebook_multiple_evaluation_attempts'); $baseUrl = api_get_self().'?selecteval='.$this->evaluation->get_id().'&'.api_get_cidreq(); $editColumn = ''; - if (api_is_allowed_to_edit(null, true) && $locked_status == 0) { + if (api_is_allowed_to_edit(null, true) && 0 == $locked_status) { if ($allowMultipleAttempts) { if (!empty($item['percentage_score'])) { $editColumn .= @@ -250,7 +250,7 @@ class ResultTable extends SortableTable Display::return_icon('delete.png', get_lang('Delete'), '', '22').''; } - if ($this->evaluation->get_course_code() == null) { + if (null == $this->evaluation->get_course_code()) { $editColumn .= ' '; $editColumn .= Display::return_icon('delete.png', get_lang('Delete')); $editColumn .= ''; @@ -264,7 +264,7 @@ class ResultTable extends SortableTable $link = LinkFactory::get_evaluation_link($this->evaluation->get_id()); $doc_url = $link->get_view_url($item['id']); - if ($doc_url != null) { + if (null != $doc_url) { $editColumn .= ' '; $editColumn .= Display::return_icon('link.gif', get_lang('Open document')).''; } diff --git a/public/main/gradebook/lib/fe/scoredisplayform.class.php b/public/main/gradebook/lib/fe/scoredisplayform.class.php index a0c0a38d3a..791711e75d 100644 --- a/public/main/gradebook/lib/fe/scoredisplayform.class.php +++ b/public/main/gradebook/lib/fe/scoredisplayform.class.php @@ -7,8 +7,6 @@ * * @author Stijn Konings * @author Bert Steppé - * - * @package chamilo.gradebook */ class ScoreDisplayForm extends FormValidator { @@ -22,7 +20,7 @@ class ScoreDisplayForm extends FormValidator $displayscore = ScoreDisplay::instance(); $customdisplays = $displayscore->get_custom_score_display_settings(); - $nr_items = (count($customdisplays) != '0') ? count($customdisplays) : '1'; + $nr_items = ('0' != count($customdisplays)) ? count($customdisplays) : '1'; $this->setDefaults( [ 'scorecolpercent' => $displayscore->get_color_split_value(), @@ -61,7 +59,7 @@ class ScoreDisplayForm extends FormValidator ] ); - if (api_get_setting('teachers_can_change_score_settings') != 'true') { + if ('true' != api_get_setting('teachers_can_change_score_settings')) { $this->freeze('scorecolpercent'); } @@ -115,7 +113,7 @@ class ScoreDisplayForm extends FormValidator '.get_lang('Add').' - '.get_lang('Delete').' + '.get_lang('Delete').''; diff --git a/public/main/gradebook/lib/fe/userform.class.php b/public/main/gradebook/lib/fe/userform.class.php index 0921fd222a..9ced5af6b5 100644 --- a/public/main/gradebook/lib/fe/userform.class.php +++ b/public/main/gradebook/lib/fe/userform.class.php @@ -6,8 +6,6 @@ * Extends formvalidator with import and export forms. * * @author Stijn Konings - * - * @package chamilo.gradebook */ class UserForm extends FormValidator { @@ -33,9 +31,9 @@ class UserForm extends FormValidator if (isset($result_object)) { $this->result_object = $result_object; } - if ($this->form_type == self::TYPE_USER_INFO) { + if (self::TYPE_USER_INFO == $this->form_type) { $this->build_user_info_form(); - } elseif ($this->form_type == self::TYPE_SIMPLE_SEARCH) { + } elseif (self::TYPE_SIMPLE_SEARCH == $this->form_type) { $this->build_simple_search(); } $this->setDefaults(); diff --git a/public/main/gradebook/lib/fe/usertable.class.php b/public/main/gradebook/lib/fe/usertable.class.php index a32354a26e..b0ad224907 100644 --- a/public/main/gradebook/lib/fe/usertable.class.php +++ b/public/main/gradebook/lib/fe/usertable.class.php @@ -7,8 +7,6 @@ * * @author Stijn Konings * @author Bert Steppé (refactored, optimised, use of caching, datagenerator class) - * - * @package chamilo.gradebook */ class UserTable extends SortableTable { @@ -80,7 +78,7 @@ class UserTable extends SortableTable $sorting = UserDataGenerator::UDG_SORT_MASK; break; } - if ($this->direction === 'DESC') { + if ('DESC' === $this->direction) { $sorting |= UserDataGenerator::UDG_SORT_DESC; } else { $sorting |= UserDataGenerator::UDG_SORT_ASC; @@ -89,7 +87,7 @@ class UserTable extends SortableTable // generate the data to display $sortable_data = []; foreach ($data_array as $data) { - if ($data[2] != '') { + if ('' != $data[2]) { // filter by course removed $row = []; $row[] = $this->build_type_column($data[0]); diff --git a/public/main/gradebook/lib/flatview_data_generator.class.php b/public/main/gradebook/lib/flatview_data_generator.class.php index 486ace4cee..86ed9327ca 100644 --- a/public/main/gradebook/lib/flatview_data_generator.class.php +++ b/public/main/gradebook/lib/flatview_data_generator.class.php @@ -7,8 +7,6 @@ * used for the teacher's flat view. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class FlatViewDataGenerator { @@ -118,7 +116,7 @@ class FlatViewDataGenerator } $parent_id = $this->category->get_parent_id(); - if ($parent_id == 0 || + if (0 == $parent_id || isset($this->params['only_subcat']) && $this->params['only_subcat'] == $this->category->get_id() ) { @@ -150,7 +148,7 @@ class FlatViewDataGenerator ); $evaluationsAdded = []; - if ($parent_id == 0 && !empty($allcat)) { + if (0 == $parent_id && !empty($allcat)) { // Means there are any subcategory /** @var Category $sub_cat */ foreach ($allcat as $sub_cat) { @@ -162,7 +160,7 @@ class FlatViewDataGenerator api_get_self().'?selectcat='.$sub_cat->get_id().'&'.api_get_cidreq() ).$add_weight; - if (api_get_setting('gradebook_detailed_admin_view') === 'true') { + if ('true' === api_get_setting('gradebook_detailed_admin_view')) { $links = $sub_cat->get_links(); $evaluations = $sub_cat->get_evaluations(); @@ -194,7 +192,7 @@ class FlatViewDataGenerator } else { if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && - $this->params['only_total_category'] == false) + false == $this->params['only_total_category']) ) { for ($count = 0; ($count < $items_count) && ($items_start + $count < count($this->evals_links)); $count++) { /** @var AbstractLink $item */ @@ -359,7 +357,7 @@ class FlatViewDataGenerator $parent_id = $this->category->get_parent_id(); - if ($parent_id == 0 || + if (0 == $parent_id || (isset($this->params['only_subcat']) && $this->params['only_subcat'] == $this->category->get_id()) ) { $main_weight = $this->category->get_weight(); @@ -441,12 +439,12 @@ class FlatViewDataGenerator ); $evaluationsAdded = []; - if ($parent_id == 0 && !empty($allcat)) { + if (0 == $parent_id && !empty($allcat)) { /** @var Category $sub_cat */ foreach ($allcat as $sub_cat) { $score = $sub_cat->calc_score($user_id); - if (api_get_setting('gradebook_detailed_admin_view') === 'true') { + if ('true' === api_get_setting('gradebook_detailed_admin_view')) { $links = $sub_cat->get_links(); /** @var ExerciseLink $link */ $linkScoreList = []; @@ -471,7 +469,7 @@ class FlatViewDataGenerator } $real_score = $score; - $divide = $score[1] == 0 ? 1 : $score[1]; + $divide = 0 == $score[1] ? 1 : $score[1]; $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()]; $item_value = $score[0] / $divide * $main_weight; @@ -486,7 +484,7 @@ class FlatViewDataGenerator $defaultStyle = (int) $style; } - if (api_get_setting('gradebook_show_percentage_in_reports') === 'false') { + if ('false' === api_get_setting('gradebook_show_percentage_in_reports')) { $defaultShowPercentageValue = SCORE_SIMPLE; if (!empty($style)) { $defaultShowPercentageValue = $style; @@ -518,10 +516,10 @@ class FlatViewDataGenerator if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && - $this->params['only_total_category'] == false) + false == $this->params['only_total_category']) ) { if (!$show_all) { - if (api_get_setting('gradebook_detailed_admin_view') === 'true') { + if ('true' === api_get_setting('gradebook_detailed_admin_view')) { $finalList = array_merge($linkScoreList, $evalScoreList); if (empty($finalList)) { $average = 0; @@ -660,7 +658,7 @@ class FlatViewDataGenerator // Fixing total when using one or multiple gradebooks. if (empty($parentCategoryIdFilter)) { - if ($this->category->get_parent_id() == 0) { + if (0 == $this->category->get_parent_id()) { if (isset($score[0])) { $item_value = $score[0] / $divide * $item->get_weight(); } else { @@ -686,7 +684,7 @@ class FlatViewDataGenerator SCORE_ONLY_SCORE ); - if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { + if ('false' == api_get_setting('gradebook_show_percentage_in_reports')) { $defaultShowPercentageValue = SCORE_SIMPLE; if (!empty($style)) { $defaultShowPercentageValue = $style; @@ -716,7 +714,7 @@ class FlatViewDataGenerator } if (!isset($this->params['only_total_category']) || - (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false) + (isset($this->params['only_total_category']) && false == $this->params['only_total_category']) ) { if (!$show_all) { if (in_array( @@ -847,11 +845,11 @@ class FlatViewDataGenerator $item = $this->evals_links[$count]; $score = $item->calc_score($user[0]); - $divide = (($score[1]) == 0) ? 1 : $score[1]; + $divide = (0 == ($score[1])) ? 1 : $score[1]; $item_value += $score[0] / $divide * $item->get_weight(); $item_total += $item->get_weight(); - $score_denom = ($score[1] == 0) ? 1 : $score[1]; + $score_denom = (0 == $score[1]) ? 1 : $score[1]; $score_final = ($score[0] / $score_denom) * 100; $row[] = $score_final; } @@ -901,12 +899,12 @@ class FlatViewDataGenerator 'ORDER BY id' ); $parent_id = $this->category->get_parent_id(); - if ($parent_id == 0 && !empty($allcat)) { + if (0 == $parent_id && !empty($allcat)) { foreach ($allcat as $sub_cat) { $score = $sub_cat->calc_score($user[0]); $real_score = $score; $main_weight = $this->category->get_weight(); - $divide = $score[1] == 0 ? 1 : $score[1]; + $divide = 0 == $score[1] ? 1 : $score[1]; //$sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()]; $item_value = $score[0] / $divide * $main_weight; @@ -943,10 +941,10 @@ class FlatViewDataGenerator for ($count = 0; $count < count($this->evals_links); $count++) { $item = $this->evals_links[$count]; $score = $item->calc_score($user[0]); - $divide = $score[1] == 0 ? 1 : $score[1]; + $divide = 0 == $score[1] ? 1 : $score[1]; $item_value += $score[0] / $divide * $item->get_weight(); $item_total += $item->get_weight(); - $score_denom = ($score[1] == 0) ? 1 : $score[1]; + $score_denom = (0 == $score[1]) ? 1 : $score[1]; $score_final = ($score[0] / $score_denom) * 100; $row[] = [ $score_final, diff --git a/public/main/gradebook/lib/gradebook_data_generator.class.php b/public/main/gradebook/lib/gradebook_data_generator.class.php index 6a6af288a6..0c5f2bbd3c 100644 --- a/public/main/gradebook/lib/gradebook_data_generator.class.php +++ b/public/main/gradebook/lib/gradebook_data_generator.class.php @@ -9,8 +9,6 @@ use ChamiloSession as Session; * used for the general gradebook view. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class GradebookDataGenerator { @@ -256,7 +254,7 @@ class GradebookDataGenerator $evalres = $eval->calc_score($user['user_id'], null); $eval->setStudentList($studentList); - if (isset($evalres) && $eval->get_weight() != 0) { + if (isset($evalres) && 0 != $eval->get_weight()) { $evalweight = $eval->get_weight(); $weightsum += $evalweight; if (!empty($evalres[1])) { @@ -267,7 +265,7 @@ class GradebookDataGenerator $bestResult = $ressum; } } else { - if ($eval->get_weight() != 0) { + if (0 != $eval->get_weight()) { $evalweight = $eval->get_weight(); $weightsum += $evalweight; } @@ -284,9 +282,9 @@ class GradebookDataGenerator } $linkres = $link->calc_score($user['user_id'], null); - if (!empty($linkres) && $link->get_weight() != 0) { + if (!empty($linkres) && 0 != $link->get_weight()) { $linkweight = $link->get_weight(); - $link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1]; + $link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1]; $weightsum += $linkweight; $ressum += $linkres[0] / $link_res_denom * $linkweight; @@ -295,7 +293,7 @@ class GradebookDataGenerator } } else { // Adding if result does not exists - if ($link->get_weight() != 0) { + if (0 != $link->get_weight()) { $linkweight = $link->get_weight(); $weightsum += $linkweight; } @@ -484,7 +482,7 @@ class GradebookDataGenerator public function sort_by_description($item1, $item2) { $result = api_strcmp($item1->get_description(), $item2->get_description()); - if ($result == 0) { + if (0 == $result) { return $this->sort_by_name($item1, $item2); } @@ -565,7 +563,7 @@ class GradebookDataGenerator true ); $type = $item->get_item_type(); - if ($type == 'L' && get_class($item) === 'ExerciseLink') { + if ('L' == $type && 'ExerciseLink' === get_class($item)) { $display = ExerciseLib::show_score($score[0], $score[1], false); } @@ -597,7 +595,7 @@ class GradebookDataGenerator ); $type = $item->get_item_type(); - if ($type === 'L' && get_class($item) === 'ExerciseLink') { + if ('L' === $type && 'ExerciseLink' === get_class($item)) { $display = ExerciseLib::show_score($score[0], $score[1], false); $result = ExerciseLib::convertScoreToPlatformSetting($score[0], $score[1]); $score[0] = $result['score']; @@ -659,7 +657,7 @@ class GradebookDataGenerator switch ($item->get_item_type()) { // category case 'C': - if ($score != null) { + if (null != $score) { if (empty($model)) { return [ 'display' => $scoreDisplay->display_score( @@ -704,7 +702,7 @@ class GradebookDataGenerator ); $type = $item->get_item_type(); - if ($type == 'L' && get_class($item) == 'ExerciseLink') { + if ('L' == $type && 'ExerciseLink' == get_class($item)) { $display = ExerciseLib::show_score( $score[0], $score[1], diff --git a/public/main/gradebook/lib/gradebook_result.class.php b/public/main/gradebook/lib/gradebook_result.class.php index e07145ec76..9319ab23fe 100644 --- a/public/main/gradebook/lib/gradebook_result.class.php +++ b/public/main/gradebook/lib/gradebook_result.class.php @@ -5,8 +5,6 @@ * Gradebook results class. * * @author Yannick Warnier - * - * @package chamilo.gradebook */ class GradeBookResult { diff --git a/public/main/gradebook/lib/results_data_generator.class.php b/public/main/gradebook/lib/results_data_generator.class.php index 218a00a70c..5fde377829 100644 --- a/public/main/gradebook/lib/results_data_generator.class.php +++ b/public/main/gradebook/lib/results_data_generator.class.php @@ -7,8 +7,6 @@ * used for the teacher's evaluation results view. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class ResultsDataGenerator { @@ -106,7 +104,7 @@ class ResultsDataGenerator true ); - if ($pdf && $number_decimals == null) { + if ($pdf && null == $number_decimals) { $user['scoreletter'] = $result->get_score(); } if ($scoreDisplay->is_custom()) { @@ -213,10 +211,10 @@ class ResultsDataGenerator $realscore, $ignore_score_color = false ) { - if ($score != null) { + if (null != $score) { $scoreDisplay = ScoreDisplay::instance(); $type = SCORE_CUSTOM; - if ($realscore === true) { + if (true === $realscore) { $type = SCORE_DIV_PERCENT; } diff --git a/public/main/gradebook/lib/scoredisplay.class.php b/public/main/gradebook/lib/scoredisplay.class.php index 6273cf675e..21356652bd 100644 --- a/public/main/gradebook/lib/scoredisplay.class.php +++ b/public/main/gradebook/lib/scoredisplay.class.php @@ -7,8 +7,6 @@ * This class works as a singleton: call instance() to retrieve an object. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class ScoreDisplay { @@ -34,7 +32,7 @@ class ScoreDisplay $value = api_get_setting('gradebook_score_display_coloring'); // Setting coloring. - $this->coloring_enabled = $value == 'true' ? true : false; + $this->coloring_enabled = 'true' == $value ? true : false; if ($this->coloring_enabled) { $value = api_get_setting('gradebook_score_display_colorsplit'); @@ -45,7 +43,7 @@ class ScoreDisplay // Setting custom enabled $value = api_get_setting('gradebook_score_display_custom'); - $this->custom_enabled = $value == 'true' ? true : false; + $this->custom_enabled = 'true' == $value ? true : false; if ($this->custom_enabled) { $params = ['category = ?' => ['Gradebook']]; @@ -68,14 +66,14 @@ class ScoreDisplay if (count($this->custom_display) > 0) { $value = api_get_setting('gradebook_score_display_upperlimit'); $value = $value['my_display_upperlimit']; - $this->upperlimit_included = $value == 'true' ? true : false; + $this->upperlimit_included = 'true' == $value ? true : false; $this->custom_display_conv = $this->convert_displays($this->custom_display); } } //If teachers can override the portal parameters - if (api_get_setting('teachers_can_change_score_settings') == 'true') { + if ('true' == api_get_setting('teachers_can_change_score_settings')) { //Load course settings if ($this->custom_enabled) { $this->custom_display = $this->get_custom_displays(); @@ -302,20 +300,20 @@ class ScoreDisplay $disableColor = false, $ignoreDecimals = false ) { - $my_score = $score == 0 ? 1 : $score; + $my_score = 0 == $score ? 1 : $score; - if ($type == SCORE_BAR) { + if (SCORE_BAR == $type) { $percentage = $my_score[0] / $my_score[1] * 100; return Display::bar_progress($percentage); } - if ($type == SCORE_NUMERIC) { + if (SCORE_NUMERIC == $type) { $percentage = $my_score[0] / $my_score[1] * 100; return round($percentage); } - if ($type == SCORE_SIMPLE) { + if (SCORE_SIMPLE == $type) { $simpleScore = $this->format_score($my_score[0], $ignoreDecimals); return $simpleScore; @@ -327,7 +325,7 @@ class ScoreDisplay // if no custom display set, use default display $display = $this->display_default($my_score, $type, $ignoreDecimals); } - if ($this->coloring_enabled && $disableColor == false) { + if ($this->coloring_enabled && false == $disableColor) { $my_score_denom = isset($score[1]) && !empty($score[1]) && $score[1] > 0 ? $score[1] : 1; $scoreCleaned = isset($score[0]) ? $score[0] : 0; if (($scoreCleaned / $my_score_denom) < ($this->color_split_value / 100)) { @@ -453,7 +451,7 @@ class ScoreDisplay */ private function display_as_decimal($score) { - $score_denom = ($score[1] == 0) ? 1 : $score[1]; + $score_denom = (0 == $score[1]) ? 1 : $score[1]; return $this->format_score($score[0] / $score_denom); } @@ -463,7 +461,7 @@ class ScoreDisplay */ private function display_as_percent($score) { - $score_denom = ($score[1] == 0) ? 1 : $score[1]; + $score_denom = (0 == $score[1]) ? 1 : $score[1]; return $this->format_score($score[0] / $score_denom * 100).' %'; } @@ -478,7 +476,7 @@ class ScoreDisplay */ private function display_as_div($score, $ignoreDecimals = false) { - if ($score == 1) { + if (1 == $score) { return '0 / 0'; } else { $score[0] = isset($score[0]) ? $this->format_score($score[0], $ignoreDecimals) : 0; @@ -497,7 +495,7 @@ class ScoreDisplay */ private function display_custom($score) { - $my_score_denom = $score[1] == 0 ? 1 : $score[1]; + $my_score_denom = 0 == $score[1] ? 1 : $score[1]; $scaledscore = $score[0] / $my_score_denom; if ($this->upperlimit_included) { @@ -509,7 +507,7 @@ class ScoreDisplay } else { if (!empty($this->custom_display_conv)) { foreach ($this->custom_display_conv as $displayitem) { - if ($scaledscore < $displayitem['score'] || $displayitem['score'] == 1) { + if ($scaledscore < $displayitem['score'] || 1 == $displayitem['score']) { return $displayitem['display']; } } diff --git a/public/main/gradebook/lib/user_data_generator.class.php b/public/main/gradebook/lib/user_data_generator.class.php index 24399f49d2..6d537df6f7 100644 --- a/public/main/gradebook/lib/user_data_generator.class.php +++ b/public/main/gradebook/lib/user_data_generator.class.php @@ -7,8 +7,6 @@ * used for a student's general view. * * @author Bert Steppé - * - * @package chamilo.gradebook */ class UserDataGenerator { @@ -48,7 +46,7 @@ class UserDataGenerator $coursecode = $eval->get_course_code(); if (isset($coursecode)) { $result = Result::load(null, $userid, $eval->get_id()); - if (count($result) == 0) { + if (0 == count($result)) { $toadd = false; } } @@ -56,7 +54,7 @@ class UserDataGenerator $evals_filtered_copy = $evals; } } - if (count($result) == 0) { + if (0 == count($result)) { $evals_filtered = $evals; } else { $evals_filtered = $evals_filtered_copy; @@ -440,7 +438,7 @@ class UserDataGenerator private function get_category_name_to_display($cat) { if (isset($cat)) { - if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null) { + if ('0' == $cat->get_parent_id() || null == $cat->get_parent_id()) { return ''; } else { return $cat->get_name(); diff --git a/public/main/gradebook/my_certificates.php b/public/main/gradebook/my_certificates.php index 12fc64b171..9dd66ecf4b 100644 --- a/public/main/gradebook/my_certificates.php +++ b/public/main/gradebook/my_certificates.php @@ -5,8 +5,6 @@ * List of achieved certificates by the current user. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.gradebook */ $cidReset = true; @@ -43,7 +41,7 @@ $template->assign('session_list', $sessionList); $templateName = $template->get_template('gradebook/my_certificates.tpl'); $content = $template->fetch($templateName); -if (api_get_setting('allow_public_certificates') === 'true') { +if ('true' === api_get_setting('allow_public_certificates')) { $template->assign( 'actions', Display::toolbarButton( diff --git a/public/main/gradebook/search.php b/public/main/gradebook/search.php index 2bee320a9d..8d91835e2f 100644 --- a/public/main/gradebook/search.php +++ b/public/main/gradebook/search.php @@ -5,14 +5,12 @@ * Search user certificates if them are publics. * * @author Angel Fernando Quiroz Campos - * - * @package chamilo.gradebook */ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; -if (api_get_setting('allow_public_certificates') != 'true') { +if ('true' != api_get_setting('allow_public_certificates')) { api_not_allowed( true, Display::return_message(get_lang('Certificates are not publicly available'), 'warning') diff --git a/public/main/gradebook/skill_rel_user.php b/public/main/gradebook/skill_rel_user.php index 08fd949bb9..aa1501e6dd 100644 --- a/public/main/gradebook/skill_rel_user.php +++ b/public/main/gradebook/skill_rel_user.php @@ -5,7 +5,7 @@ use Chamilo\SkillBundle\Entity\SkillRelItem; require_once __DIR__.'/../inc/global.inc.php'; -if (api_get_configuration_value('allow_skill_rel_items') == false) { +if (false == api_get_configuration_value('allow_skill_rel_items')) { api_not_allowed(true); } diff --git a/public/main/gradebook/user_stats.php b/public/main/gradebook/user_stats.php index dada12f786..4d97788d44 100644 --- a/public/main/gradebook/user_stats.php +++ b/public/main/gradebook/user_stats.php @@ -3,8 +3,6 @@ /** * Script. - * - * @package chamilo.gradebook */ require_once __DIR__.'/../inc/global.inc.php'; diff --git a/public/main/group/group_category.php b/public/main/group/group_category.php index ae16689df8..ee1f282c04 100644 --- a/public/main/group/group_category.php +++ b/public/main/group/group_category.php @@ -119,7 +119,7 @@ $form->addText('title', get_lang('Title')); // Groups per user $possible_values = []; -for ($i = 1; $i <= 10; ++$i) { +for ($i = 1; $i <= 10; $i++) { $possible_values[$i] = $i; } $possible_values[GroupManager::GROUP_PER_MEMBER_NO_LIMIT] = get_lang('All'); diff --git a/public/main/group/group_creation.php b/public/main/group/group_creation.php index 51c7475ac1..9aaa63c2cd 100644 --- a/public/main/group/group_creation.php +++ b/public/main/group/group_creation.php @@ -23,7 +23,7 @@ if (isset($_POST['action'])) { $useOnlyFirstCategory = true; } - for ($i = 0; $i < $_POST['number_of_groups']; ++$i) { + for ($i = 0; $i < $_POST['number_of_groups']; $i++) { $group1['name'] = empty($_POST['group_'.$i.'_name']) ? get_lang('Group').' '.$i : $_POST['group_'.$i.'_name']; $group1['category'] = isset($_POST['group_'.$i.'_category']) ? $_POST['group_'.$i.'_category'] : null; if ($useOnlyFirstCategory) { @@ -193,7 +193,7 @@ EOT; $form->addGroup($group_el, 'groups', null, '
'. Display::return_icon( 'back.png', @@ -383,14 +381,14 @@ class DisplayGradebook $line = ''; } $header .= ''.$simple_search_form->toHtml().' @@ -413,8 +411,8 @@ class DisplayGradebook if ($accessToRead) { $my_category = $catobj->showAllCategoryInfo($catobj->get_id()); - if ($selectcat != '0' && $accessToEdit) { - if ($my_api_cidreq == '') { + if ('0' != $selectcat && $accessToEdit) { + if ('' == $my_api_cidreq) { $my_api_cidreq = 'cidReq='.$my_category['course_code']; } if ($show_add_link && !$message_resource) { @@ -423,7 +421,7 @@ class DisplayGradebook ICON_SIZE_MEDIUM).''; $cats = Category::load($selectcat); - if ($cats[0]->get_course_code() != null && !$message_resource) { + if (null != $cats[0]->get_course_code() && !$message_resource) { $actionsLeft .= ''. Display::return_icon('new_online_evaluation.png', get_lang('Add online activity'), '', ICON_SIZE_MEDIUM).''; @@ -434,7 +432,7 @@ class DisplayGradebook } } } - if ((empty($grade_model_id) || $grade_model_id == -1) && $accessToEdit) { + if ((empty($grade_model_id) || -1 == $grade_model_id) && $accessToEdit) { $actionsLeft .= ''. Display::return_icon( 'new_folder.png', @@ -444,12 +442,12 @@ class DisplayGradebook ).''.($item < 10 ? '0'.$item : $item).''.$content.' ', false); } // Properties for all groups - for ($group_number = 0; $group_number < $_POST['number_of_groups']; ++$group_number) { + for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number++) { $group_el = []; $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name'); if ('true' === api_get_setting('allow_group_categories')) { diff --git a/public/main/help/allowed_html_tags.php b/public/main/help/allowed_html_tags.php index 268cc52ca8..dfefc28d21 100644 --- a/public/main/help/allowed_html_tags.php +++ b/public/main/help/allowed_html_tags.php @@ -4,8 +4,6 @@ /** * This script displays a help window with an overview of the allowed HTML- * tags and their attributes. - * - * @package chamilo.help */ require '../inc/global.inc.php'; @@ -24,7 +22,7 @@ header('Content-Type: text/html; charset='.api_get_system_encoding()); /*]]>*/