Minor - Replace deprecated function calls #scrutinizer

pull/2487/head
Yannick Warnier 8 years ago
parent 665a9c8305
commit 9ab6470b75
  1. 14
      main/admin/careers.php
  2. 14
      main/admin/system_announcements.php
  3. 16
      main/admin/usergroups.php
  4. 10
      main/blog/blog_admin.php
  5. 8
      main/course_progress/thematic.php
  6. 19
      main/coursecopy/copy_course_session_selected.php
  7. 15
      main/exercise/exercise_submit.php
  8. 10
      main/gradebook/gradebook_display_certificate.php
  9. 14
      main/inc/lib/search/xapian/XapianIndexer.class.php
  10. 8
      main/inc/lib/tracking.lib.php
  11. 12
      main/survey/survey_list.php

@ -117,7 +117,7 @@ switch ($action) {
$values = $form->exportValues();
$res = $career->save($values);
if ($res) {
Display::display_confirmation_message(get_lang('ItemAdded'));
echo Display::return_message(get_lang('ItemAdded'), 'confirmation');
}
}
$career->display();
@ -144,15 +144,17 @@ switch ($action) {
$old_status = $career->get_status($values['id']);
$res = $career->update($values);
if ($res) {
Display::display_confirmation_message(get_lang('CareerUpdated'));
echo Display::return_message(get_lang('CareerUpdated'), 'confirmation');
if ($values['status'] && !$old_status) {
Display::display_confirmation_message(
echo Display::return_message(
sprintf(get_lang('CareerXUnarchived'), $values['name']),
'confirmation',
false
);
} elseif (!$values['status'] && $old_status) {
Display::display_confirmation_message(
echo Display::return_message(
sprintf(get_lang('CareerXArchived'), $values['name']),
'confirmation',
false
);
}
@ -173,7 +175,7 @@ switch ($action) {
if ($check) {
$res = $career->delete($_GET['id']);
if ($res) {
Display::display_confirmation_message(get_lang('ItemDeleted'));
echo Display::return_message(get_lang('ItemDeleted'), 'confirmation');
}
}
$career->display();
@ -185,7 +187,7 @@ switch ($action) {
if ($check) {
$res = $career->copy($_GET['id'], true); //copy career and promotions inside
if ($res) {
Display::display_confirmation_message(get_lang('ItemCopied'));
echo Display::return_message(get_lang('ItemCopied'), 'confirmation');
}
}
$career->display();

@ -87,13 +87,13 @@ switch ($action) {
case 'delete':
// Delete an announcement.
SystemAnnouncementManager :: delete_announcement($_GET['id']);
Display :: display_confirmation_message(get_lang('AnnouncementDeleted'));
echo Display::return_message(get_lang('AnnouncementDeleted'), 'confirmation');
break;
case 'delete_selected':
foreach ($_POST['id'] as $index => $id) {
SystemAnnouncementManager :: delete_announcement($id);
}
Display :: display_confirmation_message(get_lang('AnnouncementDeleted'));
echo Display::return_message(get_lang('AnnouncementDeleted'), 'confirmation');
$action_todo = false;
break;
case 'add':
@ -264,8 +264,9 @@ if ($action_todo) {
$announcement_id,
array($values['group'])
);
Display:: display_confirmation_message(
get_lang('AnnouncementAdded')
echo Display::return_message(
get_lang('AnnouncementAdded'),
'confirmation'
);
}
} else {
@ -295,8 +296,9 @@ if ($action_todo) {
$values['id'],
array($values['group'])
);
Display:: display_confirmation_message(
get_lang('AnnouncementUpdated')
echo Display::return_message(
get_lang('AnnouncementUpdated'),
'confirmation'
);
}
} else {

@ -123,11 +123,12 @@ if ($action == 'add') {
$values = $form->exportValues();
$res = $usergroup->save($values);
if ($res) {
Display::display_confirmation_message(get_lang('ItemAdded'));
echo Display::return_message(get_lang('ItemAdded'), 'confirmation');
} else {
Display::display_warning_message(
echo Display::return_message(
Security::remove_XSS($values['name']).': '.
get_lang('AlreadyExists')
get_lang('AlreadyExists'),
'warning'
);
}
@ -163,11 +164,12 @@ if ($action == 'add') {
$values = $form->getSubmitValues();
$res = $usergroup->update($values);
if ($res) {
Display::display_confirmation_message(get_lang('Updated'));
echo Display::return_message(get_lang('Updated'), 'confirmation');
} else {
Display::display_warning_message(
echo Display::return_message(
Security::remove_XSS($values['name']).': '.
get_lang('AlreadyExists')
get_lang('AlreadyExists'),
'warning'
);
}
@ -186,7 +188,7 @@ if ($action == 'add') {
} elseif ($action == 'delete' && is_numeric($_GET['id'])) {
$res = $usergroup->delete($_GET['id']);
if ($res) {
Display::display_confirmation_message(get_lang('Deleted'));
echo Display::return_message(get_lang('Deleted'), 'confirmation');
}
$usergroup->display();
} else {

@ -52,22 +52,22 @@ if (api_is_allowed_to_edit()) {
if (!empty($_POST['new_blog_submit']) && !empty($_POST['blog_name'])) {
if (isset($_POST['blog_name'])) {
Blog::addBlog($_POST['blog_name'], $_POST['blog_subtitle']);
Display::display_confirmation_message(get_lang('BlogStored'));
echo Display::return_message(get_lang('BlogStored'), 'confirmation');
}
}
if (!empty($_POST['edit_blog_submit']) && !empty($_POST['blog_name'])) {
if (strlen(trim($_POST['blog_name']))>0) {
Blog::editBlog($_POST['blog_id'], $_POST['blog_name'], $_POST['blog_subtitle']);
Display::display_confirmation_message(get_lang('BlogEdited'));
echo Display::return_message(get_lang('BlogEdited'), 'confirmation');
}
}
if (isset($_GET['action']) && $_GET['action'] == 'visibility') {
Blog::changeBlogVisibility(intval($_GET['blog_id']));
Display::display_confirmation_message(get_lang('VisibilityChanged'));
echo Display::return_message(get_lang('VisibilityChanged'), 'confirmation');
}
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
Blog::deleteBlog(intval($_GET['blog_id']));
Display::display_confirmation_message(get_lang('BlogDeleted'));
echo Display::return_message(get_lang('BlogDeleted'), 'confirmation');
}
if (isset($_GET['action']) && $_GET['action'] == 'add') {
@ -86,7 +86,7 @@ if (api_is_allowed_to_edit()) {
if (!$_POST || (!empty($_POST) && (empty($_POST['edit_blog_submit']) || empty($_POST['blog_name']) ))) {
// if there is post data there is certainly an error in the form
if ($_POST) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error');
}
Blog::displayBlogEditForm(intval($_GET['blog_id']));
}

@ -200,7 +200,7 @@ if ($action == 'thematic_list') {
if (api_get_session_id()) {
if ($thematic_data['session_id'] != api_get_session_id()) {
$show_form = false;
Display::display_error_message(get_lang('NotAllowedClickBack'), false);
echo Display::return_message(get_lang('NotAllowedClickBack'), 'error', false);
}
}
// set default values
@ -211,10 +211,10 @@ if ($action == 'thematic_list') {
// error messages
if (isset($error)) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false);
}
if ($show_form) {
$html = $form->return_form();
$html = $form->returnForm();
}
} elseif ($action == 'thematic_import_select') {
@ -224,7 +224,7 @@ if ($action == 'thematic_list') {
$form->addElement('file', 'file');
$form->addElement('checkbox', 'replace', null, get_lang('DeleteAllThematic'));
$form->addButtonImport(get_lang('Import'), 'SubmitImport');
$html = $form->return_form();
$html = $form->returnForm();
}
$tpl->assign('actions', $toolbar);
if (!empty($html)) {

@ -298,7 +298,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
$cr = new CourseRestorer($course);
$cr->restore($destinationCourse, $destinationSession);
Display::display_confirmation_message(get_lang('CopyFinished'));
echo Display::return_message(get_lang('CopyFinished'), 'confirmation');
displayForm();
} else {
@ -324,8 +324,9 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
if ((is_array($arrCourseOrigin) && count($arrCourseOrigin) > 0) && !empty($destinationSession)) {
//We need only one value
if (count($arrCourseOrigin) > 1 || count($arrCourseDestination) > 1) {
Display::display_error_message(
get_lang('YouMustSelectACourseFromOriginalSession')
echo Display::return_message(
get_lang('YouMustSelectACourseFromOriginalSession'),
'error'
);
} else {
$courseDestination = $arrCourseDestination[0];
@ -337,13 +338,14 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
$cr = new CourseRestorer($course);
$cr->restore($courseDestination, $destinationSession);
Display::display_confirmation_message(get_lang('CopyFinished'));
echo Display::return_message(get_lang('CopyFinished'), 'confirmation');
}
displayForm();
} else {
Display::display_error_message(
get_lang('YouMustSelectACourseFromOriginalSession')
echo Display::return_message(
get_lang('YouMustSelectACourseFromOriginalSession'),
'error'
);
displayForm();
}
@ -392,8 +394,9 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
).
get_lang('Back').'</a></div>';
} else {
Display::display_error_message(
get_lang('You must select a course from original session and select a destination session')
echo Display::return_message(
get_lang('You must select a course from original session and select a destination session'),
'error'
);
displayForm();
}

@ -619,8 +619,9 @@ if ($formSent && isset($_POST)) {
$learnpath_item_view_id
);
if ($attempt_count >= $objExercise->selectAttempts()) {
Display :: display_warning_message(
echo Display :: return_message(
sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()),
'warning',
false
);
if ($origin != 'learnpath') {
@ -682,8 +683,9 @@ if ($question_count != 0) {
$learnpath_item_view_id
);
if ($attempt_count >= $objExercise->selectAttempts()) {
Display :: display_warning_message(
Display::return_message(
sprintf(get_lang('ReachedMaxAttempts'), $exercise_title, $objExercise->selectAttempts()),
'warning',
false
);
if ($origin != 'learnpath') {
@ -800,14 +802,14 @@ if ($limit_time_exists) {
if (!$permission_to_start || $exercise_timeover) {
if (!api_is_allowed_to_edit(null, true)) {
$message_warning = $permission_to_start ? get_lang('ReachedTimeLimit') : get_lang('ExerciseNoStartedYet');
Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
echo Display::return_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()), 'warning');
if ($origin != 'learnpath') {
Display :: display_footer();
}
exit;
} else {
$message_warning = $permission_to_start ? get_lang('ReachedTimeLimitAdmin') : get_lang('ExerciseNoStartedAdmin');
Display :: display_warning_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()));
echo Display::return_message(sprintf($message_warning, $exercise_title, $objExercise->selectAttempts()), 'warning');
}
}
}
@ -818,12 +820,13 @@ if (isset($_custom['exercises_hidden_when_no_start_date']) &&
$_custom['exercises_hidden_when_no_start_date']
) {
if (empty($objExercise->start_time)) {
Display:: display_warning_message(
echo Display:: return_message(
sprintf(
get_lang('ExerciseNoStartedYet'),
$exercise_title,
$objExercise->selectAttempts()
)
),
'warning'
);
if ($origin != 'learnpath') {
Display :: display_footer();

@ -88,9 +88,9 @@ if (isset($_GET['action']) && $_GET['action'] == 'delete') {
$result = $certificate->delete(true);
Security::clear_token();
if ($result == true) {
Display::display_confirmation_message(get_lang('CertificateRemoved'));
echo Display::return_message(get_lang('CertificateRemoved'), 'confirmation');
} else {
Display::display_error_message(get_lang('CertificateNotRemoved'));
echo Display::return_message(get_lang('CertificateNotRemoved'), 'error');
}
}
}
@ -142,7 +142,7 @@ if (!empty($cats)) {
}
if ($total_resource_weight != $total_weight) {
Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight'));
echo Display::return_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight'), 'warning');
}
}
@ -161,7 +161,7 @@ if ($filter === 'true') {
);
$form->addElement('select', 'filter', get_lang('OfficialCode'), $options);
$form->addButton('submit', get_lang('Submit'));
$filterForm = '<br />'.$form->return_form();
$filterForm = '<br />'.$form->returnForm();
if ($form->validate()) {
$officialCode = $form->getSubmitValue('filter');
@ -200,7 +200,7 @@ echo '</div>';
echo $filterForm;
if (count($certificate_list) == 0) {
echo Display::display_warning_message(get_lang('NoResultsAvailable'));
echo Display::return_message(get_lang('NoResultsAvailable'), 'warning');
} else {
echo '<br /><br /><table class="data_table">';
foreach ($certificate_list as $index => $value) {

@ -90,7 +90,7 @@ abstract class XapianIndexer
return $this->db;
} catch (Exception $e) {
Display::display_error_message($e->getMessage());
echo Display::return_message($e->getMessage(), 'error');
return 1;
}
@ -150,7 +150,7 @@ abstract class XapianIndexer
}
}
} catch (Exception $e) {
Display::display_error_message($e->getMessage());
echo Display::return_message($e->getMessage(), 'error');
exit(1);
}
}
@ -169,7 +169,7 @@ abstract class XapianIndexer
try {
$docid = $this->db->get_document($did);
} catch (Exception $e) {
//Display::display_error_message($e->getMessage());
//echo Display::return_message($e->getMessage(), 'error');
return false;
}
return $docid;
@ -193,7 +193,7 @@ abstract class XapianIndexer
$doc_data = $doc->get_data();
return $doc_data;
} catch (Exception $e) {
//Display::display_error_message($e->getMessage());
//echo Display::return_message($e->getMessage(), 'error');
return false;
}
}
@ -257,7 +257,7 @@ abstract class XapianIndexer
try {
$doc->add_term($term);
} catch (Exception $e) {
Display::display_error_message($e->getMessage());
echo Display::return_message($e->getMessage(), 'error');
return 1;
}
}
@ -277,7 +277,7 @@ abstract class XapianIndexer
try {
$doc->remove_term($term);
} catch (Exception $e) {
Display::display_error_message($e->getMessage());
echo Display::return_message($e->getMessage(), 'error');
return 1;
}
}
@ -300,7 +300,7 @@ abstract class XapianIndexer
$this->getDb()->replace_document((int) $did, $doc);
$this->getDb()->flush();
} catch (Exception $e) {
Display::display_error_message($e->getMessage());
echo Display::return_message($e->getMessage(), 'error');
return 1;
}
}

@ -3003,7 +3003,7 @@ class Tracking
$lp_id,
$session_id = 0
) {
$course = CourseManager::get_course_information($course_code);
$course = api_get_course_info($course_code);
$student_id = intval($student_id);
$lp_id = intval($lp_id);
$last_time = 0;
@ -3496,7 +3496,7 @@ class Tracking
public static function count_student_uploaded_documents($student_id, $course_code, $session_id = null)
{
// get the information of the course
$a_course = CourseManager::get_course_information($course_code);
$a_course = api_get_course_info($course_code);
if (!empty($a_course)) {
// table definition
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
@ -4490,7 +4490,7 @@ class Tracking
$rs = Database::query($sql);
$simple_session_array = array();
while ($row = Database::fetch_array($rs)) {
$course_info = CourseManager::get_course_information($row['code']);
$course_info = api_get_course_info($row['code']);
$temp_course_in_session[$row['session_id']]['course_list'][$course_info['real_id']] = $course_info;
$temp_course_in_session[$row['session_id']]['name'] = $row['name'];
$simple_session_array[$row['session_id']] = $row['name'];
@ -5081,7 +5081,7 @@ class Tracking
$user_id = intval($user_id);
$session_id = intval($session_id);
$course = Database::escape_string($course_code);
$course_info = CourseManager::get_course_information($course);
$course_info = api_get_course_info($course);
$html .= '<a name="course_session_data"></a>';
$html .= Display::page_subheader($course_info['title']);

@ -109,9 +109,9 @@ if ($action === 'delete' && isset($_GET['survey_id'])) {
$return = SurveyManager::delete_survey($_GET['survey_id']);
if ($return) {
Display::display_confirmation_message(get_lang('SurveyDeleted'), false);
echo Display::return_message(get_lang('SurveyDeleted'), 'confirmation', false);
} else {
Display::display_error_message(get_lang('ErrorOccurred'), false);
echo Display::return_message(get_lang('ErrorOccurred'), 'error', false);
}
}
@ -132,9 +132,9 @@ if ($action == 'empty') {
}
$return = SurveyManager::empty_survey(intval($_GET['survey_id']));
if ($return) {
Display :: display_confirmation_message(get_lang('SurveyEmptied'), false);
echo Display::return_message(get_lang('SurveyEmptied'), 'confirmation', false);
} else {
Display :: display_error_message(get_lang('ErrorOccurred'), false);
echo Display::return_message(get_lang('ErrorOccurred'), 'error', false);
}
}
@ -151,9 +151,9 @@ if (isset($_POST['action']) && $_POST['action']) {
// delete the actual survey
SurveyManager::delete_survey($value);
}
Display :: display_confirmation_message(get_lang('SurveysDeleted'), false);
echo Display::return_message(get_lang('SurveysDeleted'), 'confirmation', false);
} else {
Display :: display_error_message(get_lang('NoSurveysSelected'), false);
echo Display::return_message(get_lang('NoSurveysSelected'), 'error', false);
}
}

Loading…
Cancel
Save