From 6d5affd675a8dc299ac40a516f4daf02aedb7017 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 26 Apr 2017 09:26:28 -0500 Subject: [PATCH 1/3] Minor - Replace deprecated function calls #scrutinizer --- main/admin/course_user_import_by_email.php | 16 ++++++------- main/inc/lib/zombie/zombie_report.class.php | 14 +++++++---- main/survey/survey.download.inc.php | 14 +++++------ main/tracking/question_course_report.php | 16 ++++++------- .../lib/register_course_widget.class.php | 23 ++++--------------- 5 files changed, 37 insertions(+), 46 deletions(-) diff --git a/main/admin/course_user_import_by_email.php b/main/admin/course_user_import_by_email.php index 79e461d760..c0dde5a93b 100755 --- a/main/admin/course_user_import_by_email.php +++ b/main/admin/course_user_import_by_email.php @@ -99,8 +99,8 @@ function save_data($users_courses) foreach ($to_subscribe as $courseId) { $courseInfo = api_get_course_info_by_id($courseId); $course_code = $courseInfo['code']; - if (CourseManager :: course_exists($course_code)) { - $course_info = CourseManager::get_course_information($course_code); + if (CourseManager::course_exists($course_code)) { + $course_info = api_get_course_info($course_code); $inserted_in_course[$course_code] = $course_info['title']; CourseManager::subscribe_user( @@ -117,9 +117,9 @@ function save_data($users_courses) foreach ($to_unsubscribe as $courseId) { $courseInfo = api_get_course_info_by_id($courseId); $course_code = $courseInfo['code']; - if (CourseManager :: course_exists($course_code)) { + if (CourseManager::course_exists($course_code)) { CourseManager::unsubscribe_user($user_id, $course_code); - $course_info = CourseManager::get_course_information($course_code); + $course_info = api_get_course_info($course_code); CourseManager::unsubscribe_user($user_id, $course_code); $inserted_in_course[$course_info['code']] = $course_info['title']; } @@ -137,7 +137,7 @@ function save_data($users_courses) */ function parse_csv_data($file) { - $courses = Import :: csvToArray($file); + $courses = Import::csv_reader($file); return $courses; } @@ -198,7 +198,7 @@ if ($form->validate()) { } // Displaying the header. -Display :: display_header($tool_name); +Display::display_header($tool_name); if (count($errors) != 0) { $error_message = ''; - Display :: display_error_message($error_message, false); + echo Display::return_message($error_message, 'error', false); } // Displaying the form. @@ -229,4 +229,4 @@ echo STUDENT.': '.get_lang('Student').'
'; parameters_form)) { - $this->parameters_form = FormValidator::create($parameters); + $this->parameters_form = new FormValidator( + $parameters['name'], + $parameters['method'], + null, + null, + $parameters['attributes'] + ); } return $this->parameters_form; @@ -104,7 +110,7 @@ class ZombieReport implements Countable return ''; } - $result = $form->return_form(); + $result = $form->returnForm(); if ($return) { return $result; } else { @@ -312,9 +318,9 @@ class ZombieReport implements Countable $result = $this->display_parameters($return); if ($this->perform_action()) { if ($return) { - $result .= Display::return_confirmation_message(get_lang('Done')); + $result .= Display::return_message(get_lang('Done'), 'confirmation'); } else { - Display::display_confirmation_message(get_lang('Done')); + echo Display::return_message(get_lang('Done'), 'confirmation'); } } $result .= $this->display_data($return); diff --git a/main/survey/survey.download.inc.php b/main/survey/survey.download.inc.php index 60ae32de0b..45009b7fce 100755 --- a/main/survey/survey.download.inc.php +++ b/main/survey/survey.download.inc.php @@ -14,7 +14,7 @@ function check_download_survey($course, $invitation, $doc_url) { // Getting all the course information - $_course = CourseManager::get_course_information($course); + $_course = api_get_course_info($course); $course_id = $_course['real_id']; // Database table definitions @@ -30,16 +30,16 @@ function check_download_survey($course, $invitation, $doc_url) invitation_code = '".Database::escape_string($invitation)."'"; $result = Database::query($sql); if (Database::num_rows($result) < 1) { - Display :: display_error_message(get_lang('WrongInvitationCode'), false); - Display :: display_footer(); + echo Display::return_message(get_lang('WrongInvitationCode'), 'error', false); + Display::display_footer(); exit; } $survey_invitation = Database::fetch_assoc($result); // Now we check if the user already filled the survey if ($survey_invitation['answered'] == 1) { - Display :: display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false); - Display :: display_footer(); + echo Display::return_message(get_lang('YouAlreadyFilledThisSurvey'), 'error', false); + Display::display_footer(); exit; } @@ -102,8 +102,8 @@ function check_download_survey($course, $invitation, $doc_url) )"; $result = Database::query($sql); if (Database::num_rows($result) == 0) { - Display :: display_error_message(get_lang('WrongInvitationCode'), false); - Display :: display_footer(); + echo Display::return_message(get_lang('WrongInvitationCode'), 'error', false); + Display::display_footer(); exit; } diff --git a/main/tracking/question_course_report.php b/main/tracking/question_course_report.php index 63113435e8..71bd5c65c7 100755 --- a/main/tracking/question_course_report.php +++ b/main/tracking/question_course_report.php @@ -14,9 +14,9 @@ $this_section = "session_my_space"; $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin; if (!$is_allowedToTrack) { - Display :: display_header(null); + Display::display_header(null); api_not_allowed(); - Display :: display_footer(); + Display::display_footer(); } $export_to_xls = false; @@ -45,13 +45,13 @@ function load_courses() { $session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : null; if (empty($session_id)) { - $temp_course_list = CourseManager :: get_courses_list(); + $temp_course_list = CourseManager::get_courses_list(); } else { $temp_course_list = SessionManager::get_course_list_by_session_id($session_id); } foreach ($temp_course_list as $temp_course_item) { - $course_item = CourseManager ::get_course_information($temp_course_item['code']); + $course_item = api_get_course_info($temp_course_item['code']); $course_select_list[$temp_course_item['code']] = $course_item['title']; } @@ -148,7 +148,7 @@ if (!empty($course_info)) { } if (!$export_to_xls) { - Display :: display_header(get_lang("MySpace")); + Display::display_header(get_lang("MySpace")); echo '
'; if ($global) { echo MySpace::getTopMenu(); @@ -171,7 +171,7 @@ if (!$export_to_xls) { $form->display(); if (empty($course_code)) { - Display::display_warning_message(get_lang('PleaseSelectACourse')); + echo Display::return_message(get_lang('PleaseSelectACourse'), 'warning'); } } @@ -215,7 +215,7 @@ if (!empty($main_question_list) && is_array($main_question_list)) { $html_result .= ''; } else { if (!empty($course_code)) { - Display::display_warning_message(get_lang('NoResults')); + echo Display::return_message(get_lang('NoResults'), 'warning'); } } @@ -223,4 +223,4 @@ if (!$export_to_xls) { echo $html_result; } -Display :: display_footer(); +Display::display_footer(); diff --git a/plugin/search_course/lib/register_course_widget.class.php b/plugin/search_course/lib/register_course_widget.class.php index bd5f11365c..fb47a1ce87 100755 --- a/plugin/search_course/lib/register_course_widget.class.php +++ b/plugin/search_course/lib/register_course_widget.class.php @@ -77,12 +77,12 @@ class RegisterCourseWidget if ($this->subscribe_user($course_code, $registration_code)) { - Display::display_confirmation_message(get_lang('EnrollToCourseSuccessful')); + echo Display::return_message(get_lang('EnrollToCourseSuccessful'), 'confirmation'); return; } if (!empty($registration_code)) { - Display::display_error_message(get_lang('CourseRegistrationCodeIncorrect')); + echo Display::return_message(get_lang('CourseRegistrationCodeIncorrect'), 'error'); } $this->display_form($course_code); return true; @@ -99,7 +99,7 @@ class RegisterCourseWidget */ function subscribe_user($course_code, $registration_code = '', $user_id = null) { - $course = $this->retrieve_course($course_code); + $course = api_get_course_info($course_code); $course_regisration_code = $course['registration_code']; if (!empty($course_regisration_code) && $registration_code != $course_regisration_code) { @@ -125,7 +125,7 @@ class RegisterCourseWidget { global $stok; - $course = $this->retrieve_course($course_code); + $course = api_get_course_info($course_code); $self = $_SERVER['REQUEST_URI']; $course_code = $course['code']; $course_visual_code = $course['visual_code']; @@ -144,19 +144,4 @@ class RegisterCourseWidget EOT; echo $result; } - - /** - * DB functions - DB functions - DB functions - */ - - /** - * - * @param type $course_code - * @return type - */ - function retrieve_course($course_code) - { - return CourseManager::get_course_information($course_code); - } - } From d814dc2439ae840ef35e3956055c8bf4b0f09663 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 26 Apr 2017 10:02:53 -0500 Subject: [PATCH 2/3] Minor - Replace deprecated function calls #scrutinizer --- main/admin/course_import.php | 10 ++++---- main/admin/course_intro_pdf_import.php | 33 +++++++++++++------------- main/admin/extra_field_options.php | 8 +++---- main/admin/extra_fields.php | 9 +++---- main/admin/settings.lib.php | 10 ++++---- main/auth/courses_categories.php | 6 ++--- main/inc/ajax/exercise.ajax.php | 6 ++--- main/inc/ajax/message.ajax.php | 6 ++--- main/inc/lib/blog.lib.php | 6 ++--- main/survey/survey.php | 8 +++---- 10 files changed, 53 insertions(+), 49 deletions(-) diff --git a/main/admin/course_import.php b/main/admin/course_import.php index 7c4b74f475..0ff14f3c94 100755 --- a/main/admin/course_import.php +++ b/main/admin/course_import.php @@ -172,19 +172,19 @@ $tool_name = get_lang('ImportCourses').' CSV'; $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); set_time_limit(0); -Display :: display_header($tool_name); +Display::display_header($tool_name); if (isset($_POST['formSent']) && $_POST['formSent']) { if (empty($_FILES['import_file']['tmp_name'])) { $error_message = get_lang('UplUploadFailed'); - Display :: display_error_message($error_message, false); + echo Display::return_message($error_message, 'error', false); } else { $allowed_file_mimetype = array('csv'); $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'], '.') + 1)); if (!in_array($ext_import_file, $allowed_file_mimetype)) { - Display :: display_error_message(get_lang('YouMustImportAFileAccordingToSelectedOption')); + echo Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'), 'error'); } else { $courses = parse_csv_courses_data($_FILES['import_file']['tmp_name']); @@ -204,7 +204,7 @@ if (isset($errors) && count($errors) != 0) { $error_message .= ''; } $error_message .= ''; - Display :: display_error_message($error_message, false); + echo Display::return_message($error_message, 'error', false); } $form = new FormValidator('import', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data')); @@ -229,4 +229,4 @@ BIO0017;Language;LANG;;;english 'index.php', 'name' => get_lang('PlatformAdmin')); set_time_limit(0); -Display :: display_header($tool_name); +Display::display_header($tool_name); if ($_POST['formSent']) { if (empty($_FILES['import_file']['tmp_name'])) { $error_message = get_lang('UplUploadFailed'); - Display :: display_error_message($error_message, false); + Display::addFlash(Display::return_message($error_message, 'error', false)); } else { $allowed_file_mimetype = array('zip'); $ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'], '.') + 1)); if (!in_array($ext_import_file, $allowed_file_mimetype)) { - Display :: display_error_message(get_lang('YouMustImportAZipFile')); + Display::addFlash(Display::return_message(get_lang('YouMustImportAZipFile'), 'error')); } else { - $errors = import_pdfs($courses, $subDir); + $errors = import_pdfs($subDir); if (count($errors) == 0) { error_log('Course intros imported successfully in '.__FILE__.', line '.__LINE__); } @@ -46,11 +47,11 @@ if (count($errors) != 0) { $error_message .= ''; Display::addFlash(Display::return_message($error_message, 'normal', false)); } elseif ($_POST['formSent']) { - Display :: display_confirmation_message('CourseIntroductionsAllImportesSuccessfully', false); + Display::addFlash(Display::return_message('CourseIntroductionsAllImportesSuccessfully', 'confirmation', false)); } ?> -
- + +

@@ -71,21 +72,21 @@ if (count($errors) != 0) {
 CourseCode_NameOfDocument_CourseName.pdf
 e.g.
-MAT101_Introduction_Mathematics-101.pdf
-MAT102_Introduction_Mathematics-102.pdf
-ENG101_Introduction_English-101.pdf
+MAT101_Introduction_to_Mathematics-101.pdf
+MAT102_Introduction_to_Mathematics-102.pdf
+ENG101_Introduction_to_English-101.pdf
 
set_course_id($course['real_id']); $course_description->set_session_id($session_id); - $course_description->set_title('PresentaciĆ³n de la asignatura'); + $course_description->set_title('Course presentation'); $course_description->set_content($link); $course_description->set_description_type(1); $course_description->insert(); diff --git a/main/admin/extra_field_options.php b/main/admin/extra_field_options.php index da31927e6d..d59f3c46f4 100755 --- a/main/admin/extra_field_options.php +++ b/main/admin/extra_field_options.php @@ -151,7 +151,7 @@ switch ($action) { $values = $form->exportValues(); $res = $obj->save_one_item($values); if ($res) { - Display::display_confirmation_message(get_lang('ItemAdded')); + echo Display::return_message(get_lang('ItemAdded'), 'confirmation'); } } $obj->display(); @@ -171,7 +171,7 @@ switch ($action) { if ($check) { $values = $form->exportValues(); $res = $obj->update($values); - Display::display_confirmation_message(sprintf(get_lang('ItemUpdated'), $values['display_text']), false); + echo Display::return_message(sprintf(get_lang('ItemUpdated'), $values['display_text']), 'confirmation', false); } $obj->display(); } else { @@ -185,7 +185,7 @@ switch ($action) { if ($check) { $res = $obj->delete($_GET['id']); if ($res) { - Display::display_confirmation_message(get_lang('ItemDeleted')); + echo Display::return_message(get_lang('ItemDeleted'), 'confirmation'); } } $obj->display(); @@ -194,4 +194,4 @@ switch ($action) { $obj->display(); break; } -Display :: display_footer(); +Display::display_footer(); diff --git a/main/admin/extra_fields.php b/main/admin/extra_fields.php index cb239eb089..dad4f5c415 100755 --- a/main/admin/extra_fields.php +++ b/main/admin/extra_fields.php @@ -127,7 +127,7 @@ switch ($action) { unset($values['id']); $res = $obj->save($values); if ($res) { - Display::display_confirmation_message(get_lang('ItemAdded')); + echo Display::return_message(get_lang('ItemAdded'), 'confirmation'); } $obj->display(); } else { @@ -149,8 +149,9 @@ switch ($action) { if ($form->validate()) { $values = $form->exportValues(); $res = $obj->update($values); - Display::display_confirmation_message( + echo Display::return_message( sprintf(get_lang('ItemUpdated'), $values['variable']), + 'confirmation', false ); $obj->display(); @@ -168,7 +169,7 @@ switch ($action) { // Action handling: delete $res = $obj->delete($_GET['id']); if ($res) { - Display::display_confirmation_message(get_lang('ItemDeleted')); + echo Display::return_message(get_lang('ItemDeleted'), 'confirmation'); } $obj->display(); break; @@ -176,4 +177,4 @@ switch ($action) { $obj->display(); break; } -Display :: display_footer(); +Display::display_footer(); diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index 4d8bdd58da..b59a80e184 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -458,7 +458,7 @@ function handleStylesheets() '; echo Display::tabs( array(get_lang('Update'),get_lang('UpdateLogo'), get_lang('UploadNewStylesheet')), - array($form_change->return_form(), $logoForm->returnForm(), $form->returnForm()) + array($form_change->returnForm(), $logoForm->returnForm(), $form->returnForm()) ); } else { $form_change->display(); @@ -540,8 +540,9 @@ function uploadStylesheet($values, $picture) $error_string .= '
  • '.$invalid_file.'
  • '; } $error_string .= ''; - Display::display_error_message( + echo Display::return_message( get_lang('ErrorStylesheetFilesExtensionsInsideZip').$error_string, + 'error', false ); } else { @@ -1691,8 +1692,9 @@ function showSearchToolsStatusTable() $table->set_header(2, get_lang('Status'), false); echo $table->display(); } else { - Display::display_warning_message( - get_lang('YouAreUsingChamiloInAWindowsPlatformSadlyYouCantConvertDocumentsInOrderToSearchTheContentUsingThisTool') + echo Display::return_message( + get_lang('YouAreUsingChamiloInAWindowsPlatformSadlyYouCantConvertDocumentsInOrderToSearchTheContentUsingThisTool'), + 'warning' ); } } diff --git a/main/auth/courses_categories.php b/main/auth/courses_categories.php index eef9b888ba..e57c1eb752 100755 --- a/main/auth/courses_categories.php +++ b/main/auth/courses_categories.php @@ -134,10 +134,10 @@ $code = isset($code) ? $code : null;
    '.get_lang('ManageGroups').'

    '; if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) { - echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false); + echo Display::return_message(get_lang($_GET['sendmsg']), 'confirmation', false); } if (in_array($_GET['sendmsg'], array('GroupNeedName'))){ - echo Display::display_warning_message(get_lang($_GET['sendmsg']), false); + echo Display::return_message(get_lang($_GET['sendmsg']), 'warning', false); } echo '
    '.get_lang('Name').''.get_lang('Description').'
    '; echo ''; @@ -285,4 +285,4 @@ if ($is_survey_type_1) { Session::erase('answer_count'); // Footer -Display :: display_footer(); +Display::display_footer(); From 1fdfb08dd3553d748296299a319d3882e5a80d23 Mon Sep 17 00:00:00 2001 From: Alex Aragon Date: Wed, 26 Apr 2017 11:20:55 -0500 Subject: [PATCH 3/3] fix css label subscriber --- app/Resources/public/css/base.css | 7 +++++++ main/auth/courses_categories.php | 17 ++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index 31dfd860ab..2e88fe6170 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -6192,6 +6192,13 @@ ul#toolnavbox-two li a.btn{ display: block; width: 100%; } +.label-subscribed{ + font-size: 12px; + position: absolute; + top: -65px; + right: 0; + width: 100px; +} /* CSS NEW TOP ******************************************************************************/ /* CSS Responsive */ @media (min-width: 1025px) and (max-width: 1200px) { diff --git a/main/auth/courses_categories.php b/main/auth/courses_categories.php index e57c1eb752..0431f7ca0a 100755 --- a/main/auth/courses_categories.php +++ b/main/auth/courses_categories.php @@ -213,7 +213,7 @@ if ($showCourses && $action != 'display_sessions') { // display course title and button bloc $html .= '
    '; - $html .= return_title($course, $userRegisterd); + $html .= return_title($course, $userRegisterdInCourse); $html .= return_teacher($course); // display button line @@ -226,7 +226,6 @@ if ($showCourses && $action != 'display_sessions') { // if user registered as student if ($userRegisterdInCourse) { $html .= return_already_registered_label('student'); - if (!$course_closed) { if ($course_unsubscribe_allowed) { $html .= return_unregister_button($course, $stok, $search_term, $code); @@ -434,9 +433,9 @@ function return_already_registered_label($in_status) } $html = Display::tag( - 'button', - $icon, - array('id' => 'register', 'class' => 'btn btn-default btn-sm', 'title' => $title, 'aria-label' => $title) + 'span', + $icon . ' ' . $title, + array('id' => 'register', 'class' => 'label-subscribed text-success', 'title' => $title, 'aria-label' => $title) ); return $html; @@ -455,7 +454,7 @@ function return_register_button($course, $stok, $code, $search_term) { $title = get_lang('Subscribe'); $html = Display::url( - Display::returnFontAwesomeIcon('sign-in'), + Display::returnFontAwesomeIcon('check') . ' ' . $title, api_get_self() . '?action=subscribe_course&sec_token=' . $stok. '&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code, array('class' => 'btn btn-success btn-sm', 'title' => $title, 'aria-label' => $title) @@ -474,12 +473,12 @@ function return_register_button($course, $stok, $code, $search_term) */ function return_unregister_button($course, $stok, $search_term, $code) { - $title = get_lang('Unsubscribe'); + $title = get_lang('UnsubscriptionAllowed'); $html = Display::url( - Display::returnFontAwesomeIcon('sign-in'), + Display::returnFontAwesomeIcon('sign-in').' '.$title, api_get_self() . '?action=unsubscribe&sec_token='.$stok .'&unsubscribe='.$course['code'].'&search_term='.$search_term.'&category_code='.$code, - array('class' => 'btn btn-success btn-sm', 'title' => $title, 'aria-label' => $title) + array('class' => 'btn btn-danger btn-sm', 'title' => $title, 'aria-label' => $title) ); return $html; }