Minor - Replace deprecated function calls #scrutinizer

pull/2487/head
Yannick Warnier 9 years ago
parent 8752836443
commit d814dc2439
  1. 10
      main/admin/course_import.php
  2. 33
      main/admin/course_intro_pdf_import.php
  3. 8
      main/admin/extra_field_options.php
  4. 9
      main/admin/extra_fields.php
  5. 10
      main/admin/settings.lib.php
  6. 6
      main/auth/courses_categories.php
  7. 6
      main/inc/ajax/exercise.ajax.php
  8. 6
      main/inc/ajax/message.ajax.php
  9. 6
      main/inc/lib/blog.lib.php
  10. 8
      main/survey/survey.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 .= '</li>';
}
$error_message .= '</ul>';
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
</blockquote>
<?php
Display :: display_footer();
Display::display_footer();

@ -13,24 +13,25 @@ api_protect_admin_script();
// Should default to '', and start with a '/' and end without it, if defined
$subDir = '';
$tool_name = get_lang('ImportPDFIntroToCourses');
$errors = [];
$interbreadcrumb[] = array('url' => '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 .= '</ul>';
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));
}
?>
<form method="post" action="<?php echo api_get_self(); ?>" enctype="multipart/form-data" style="margin: 0px;">
<legend><?php echo $tool_name; ?></legend>
<form method="post" action="<?php echo api_get_self(); ?>" enctype="multipart/form-data" style="margin: 0;">
<h3><?php echo $tool_name; ?></h3>
<div class="control-group">
<label><?php echo get_lang('ImportZipFileLocation'); ?></label>
<div class="control">
@ -71,21 +72,21 @@ if (count($errors) != 0) {
<pre>
<strong>CourseCode</strong>_<strong>NameOfDocument</strong>_<strong>CourseName</strong>.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
</pre>
</blockquote>
<?php
Display :: display_footer();
Display::display_footer();
/**
* Import PDFs
* @param string Filename
* @param string The subdirectory in which to put the files in each course
* @param string $subDir The subdirectory in which to put the files in each course
* @return array List of possible errors found
*/
function import_pdfs($file, $subDir = '/')
function import_pdfs($subDir = '/')
{
$baseDir = api_get_path(SYS_ARCHIVE_PATH);
$uploadPath = 'pdfimport/';
@ -120,7 +121,7 @@ function import_pdfs($file, $subDir = '/')
error_log('Destination '.api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir.' is NOT writeable in '.__FILE__);
}
// Place each file in its folder in each course
$move = rename($baseDir.$uploadPath.$file, api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir.'/'.$file);
rename($baseDir.$uploadPath.$file, api_get_path(SYS_COURSE_PATH).$course['path'].'/document'.$subDir.'/'.$file);
api_item_property_update($course, TOOL_DOCUMENT, $docId, 'DocumentAdded', api_get_user_id());
// Redo visibility
api_set_default_visibility($docId, TOOL_DOCUMENT);
@ -134,7 +135,7 @@ function import_pdfs($file, $subDir = '/')
$session_id = api_get_session_id();
$course_description->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();

@ -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();

@ -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();

@ -458,7 +458,7 @@ function handleStylesheets()
</script>';
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 .= '<li>'.$invalid_file.'</li>';
}
$error_string .= '</ul>';
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'
);
}
}

@ -134,10 +134,10 @@ $code = isset($code) ? $code : null;
<?php
if ($showCourses && $action != 'display_sessions') {
if (!empty($message)) {
Display::display_confirmation_message($message, false);
echo Display::return_message($message, 'confirmation', false);
}
if (!empty($error)) {
Display::display_error_message($error, false);
echo Display::return_message($error, 'error', false);
}
if (!empty($content)) {
@ -263,7 +263,7 @@ if ($showCourses && $action != 'display_sessions') {
if (!isset($_REQUEST['subscribe_user_with_password']) &&
!isset($_REQUEST['subscribe_course'])
) {
Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory'));
echo Display::return_message(get_lang('ThereAreNoCoursesInThisCategory'), 'warning');
}
}
}

@ -186,7 +186,7 @@ switch ($action) {
);
$counter++;
}
Display::display_confirmation_message(get_lang('Saved'));
echo Display::return_message(get_lang('Saved'), 'confirmation');
}
break;
case 'update_question_order':
@ -195,7 +195,7 @@ switch ($action) {
$exercise_id = isset($_REQUEST['exercise_id']) ? $_REQUEST['exercise_id'] : null;
if (empty($exercise_id)) {
return Display::display_error_message(get_lang('Error'));
return Display::return_message(get_lang('Error'), 'error');
}
if (api_is_allowed_to_edit(null, true)) {
$new_question_list = $_POST['question_id_list'];
@ -209,7 +209,7 @@ switch ($action) {
;
$counter++;
}
Display::display_confirmation_message(get_lang('Saved'));
echo Display::return_message(get_lang('Saved'), 'confirmation');
}
break;
case 'add_question_to_reminder':

@ -51,15 +51,15 @@ switch ($action) {
$messageContent = isset($_REQUEST['content']) ? trim($_REQUEST['content']) : null;
if (empty($subject) || empty($messageContent)) {
echo Display::display_error_message(get_lang('ErrorSendingMessage'));
echo Display::return_message(get_lang('ErrorSendingMessage'), 'error');
exit;
}
$result = MessageManager::send_message($_REQUEST['user_id'], $subject, $messageContent);
if ($result) {
echo Display::display_confirmation_message(get_lang('MessageHasBeenSent'));
echo Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation');
} else {
echo Display::display_error_message(get_lang('ErrorSendingMessage'));
echo Display::return_message(get_lang('ErrorSendingMessage'), 'confirmation');
}
break;
case 'send_invitation':

@ -379,7 +379,7 @@ class Blog
$file_name = $_FILES['user_upload']['name'];
if (!filter_extension($new_file_name)) {
Display::display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
echo Display::return_message(get_lang('UplUnableToSaveFileFilteredExtension'), 'error');
} else {
$new_file_name = uniqid('');
$new_path = $updir.'/'.$new_file_name;
@ -404,7 +404,7 @@ class Blog
return $last_post_id;
} else {
Display::display_error_message(get_lang('UplNoFileUploaded'));
echo Display::return_message(get_lang('UplNoFileUploaded'), 'error');
}
}
@ -540,7 +540,7 @@ class Blog
$file_name = Database::escape_string($_FILES['user_upload']['name']);
if (!filter_extension($new_file_name)) {
Display:: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
echo Display::return_message(get_lang('UplUnableToSaveFileFilteredExtension'), 'error');
} else {
$new_file_name = uniqid('');
$new_path = $updir . '/' . $new_file_name;

@ -108,7 +108,7 @@ $message_information = isset($_GET['message']) ? Security::remove_XSS($_GET['mes
if (isset($action)) {
if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) {
SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey);
Display::display_confirmation_message(get_lang('SurveyQuestionMoved'));
echo Display::return_message(get_lang('SurveyQuestionMoved'), 'confirmation');
}
if ($action == 'delete' AND is_numeric($_GET['question_id'])) {
SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']);
@ -238,11 +238,11 @@ if ($is_survey_type_1) {
echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />';
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 '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>';
echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">';
@ -285,4 +285,4 @@ if ($is_survey_type_1) {
Session::erase('answer_count');
// Footer
Display :: display_footer();
Display::display_footer();

Loading…
Cancel
Save