Fix legacy PHP code, add more files to psalm.xml

pull/3924/head
Julio Montoya 4 years ago
parent 38641a14c5
commit 95aea79d62
  1. 7
      psalm.xml
  2. 3
      public/main/admin/user_add.php
  3. 3
      public/main/admin/user_edit.php
  4. 3
      public/main/admin/user_list_consent.php
  5. 3
      public/main/course_progress/index.php
  6. 6
      public/main/coursecopy/import_backup.php
  7. 3
      public/main/exercise/TestCategory.php
  8. 4
      public/main/exercise/category.php
  9. 10
      public/main/exercise/exercise.class.php
  10. 2
      public/main/exercise/export/exercise_import.inc.php
  11. 10
      public/main/exercise/fill_blanks.class.php
  12. 3
      public/main/exercise/question_create.php
  13. 2
      public/main/exercise/tests_category.php
  14. 3
      public/main/inc/lib/agenda.lib.php
  15. 12
      public/main/inc/lib/api.lib.php
  16. 34
      public/main/inc/lib/course_description.lib.php
  17. 10
      public/main/inc/lib/display.lib.php
  18. 2
      public/main/inc/lib/events.lib.php
  19. 3
      public/main/inc/lib/exercise.lib.php
  20. 14
      public/main/inc/lib/export.lib.inc.php
  21. 7
      public/main/inc/lib/extra_field.lib.php
  22. 2
      public/main/inc/lib/formvalidator/FormValidator.class.php
  23. 3
      public/main/inc/lib/gradebook.lib.php
  24. 2
      public/main/inc/lib/pear/HTML/QuickForm/button.php
  25. 6
      public/main/inc/lib/tracking.lib.php
  26. 2
      public/main/lp/learnpath.class.php
  27. 2
      public/main/lp/lp_add_audio.php
  28. 2
      public/main/lp/lp_edit_item_prereq.php
  29. 2
      public/main/lp/lp_final_item.php
  30. 4
      public/main/lp/lp_list_search.php
  31. 4
      public/main/lp/lp_view.php
  32. 3
      public/main/mySpace/access_details.php
  33. 3
      public/main/mySpace/users.php
  34. 4
      public/main/survey/survey.php
  35. 9
      public/main/ticket/new_ticket.php
  36. 3
      public/main/tracking/lp_results_by_user.php
  37. 6
      public/main/tracking/question_course_report.php
  38. 3
      public/plugin/buycourses/src/buycourses.ajax.php
  39. 6
      public/plugin/customcertificate/src/index.php

@ -63,7 +63,7 @@
<file name="public/main/inc/lib/agenda.lib.php"/> <file name="public/main/inc/lib/agenda.lib.php"/>
<file name="public/main/inc/lib/AnnouncementEmail.php"/> <file name="public/main/inc/lib/AnnouncementEmail.php"/>
<file name="public/main/inc/lib/AnnouncementManager.php"/> <file name="public/main/inc/lib/AnnouncementManager.php"/>
<!-- <file name="public/main/inc/lib/api.lib.php"/>--> <file name="public/main/inc/lib/api.lib.php"/>
<file name="public/main/inc/lib/array.lib.php"/> <file name="public/main/inc/lib/array.lib.php"/>
<file name="public/main/inc/lib/attendance.lib.php"/> <file name="public/main/inc/lib/attendance.lib.php"/>
<file name="public/main/inc/lib/auth.lib.php"/> <file name="public/main/inc/lib/auth.lib.php"/>
@ -86,7 +86,7 @@
<!-- <file name="public/main/inc/lib/exercise.lib.php"/>--> <!-- <file name="public/main/inc/lib/exercise.lib.php"/>-->
<file name="public/main/inc/lib/exercise_show_functions.lib.php"/> <file name="public/main/inc/lib/exercise_show_functions.lib.php"/>
<file name="public/main/inc/lib/ExerciseCategoryManager.php"/> <file name="public/main/inc/lib/ExerciseCategoryManager.php"/>
<!-- <file name="public/main/inc/lib/export.lib.inc.php"/>--> <file name="public/main/inc/lib/export.lib.inc.php"/>
<file name="public/main/inc/lib/extra_field.lib.php"/> <file name="public/main/inc/lib/extra_field.lib.php"/>
<file name="public/main/inc/lib/extra_field_option.lib.php"/> <file name="public/main/inc/lib/extra_field_option.lib.php"/>
@ -165,6 +165,8 @@
<directory name="public/main/inc/lib/search" /> <directory name="public/main/inc/lib/search" />
<directory name="public/main/inc/lib/svg-edit" /> <directory name="public/main/inc/lib/svg-edit" />
<directory name="public/main/inc/lib/zombie" /> <directory name="public/main/inc/lib/zombie" />
<directory name="public/main/exercise/export/qti2" />
<file name="public/main/lp/openoffice_presentation.class.php"/> <file name="public/main/lp/openoffice_presentation.class.php"/>
<file name="public/main/lp/openoffice_document.class.php"/> <file name="public/main/lp/openoffice_document.class.php"/>
@ -187,6 +189,7 @@
<file name="public/main/admin/ldap_*"/> <file name="public/main/admin/ldap_*"/>
<file name="public/main/admin/special_exports.php"/> <file name="public/main/admin/special_exports.php"/>
<file name="public/main/exercise/admin.php"/>
<file name="src/CoreBundle/Controller/EditorController.php"/> <file name="src/CoreBundle/Controller/EditorController.php"/>
<file name="src/CoreBundle/Controller/ResourceController.php"/> <file name="src/CoreBundle/Controller/ResourceController.php"/>

@ -235,8 +235,7 @@ $status[SESSIONADMIN] = get_lang('Sessions administrator');
$status[STUDENT_BOSS] = get_lang('Student\'s superior'); $status[STUDENT_BOSS] = get_lang('Student\'s superior');
$status[INVITEE] = get_lang('Invitee'); $status[INVITEE] = get_lang('Invitee');
$form->addElement( $form->addSelect(
'select',
'status', 'status',
get_lang('Profile'), get_lang('Profile'),
$status, $status,

@ -241,8 +241,7 @@ $status[SESSIONADMIN] = get_lang('Sessions administrator');
$status[STUDENT_BOSS] = get_lang('Student\'s superior'); $status[STUDENT_BOSS] = get_lang('Student\'s superior');
$status[INVITEE] = get_lang('Invitee'); $status[INVITEE] = get_lang('Invitee');
$form->addElement( $form->addSelect(
'select',
'status', 'status',
get_lang('Profile'), get_lang('Profile'),
$status, $status,

@ -574,8 +574,7 @@ $status_options[DRH] = get_lang('Human Resources Manager');
$status_options[SESSIONADMIN] = get_lang('Sessions administrator'); $status_options[SESSIONADMIN] = get_lang('Sessions administrator');
$status_options[PLATFORM_ADMIN] = get_lang('Administrator'); $status_options[PLATFORM_ADMIN] = get_lang('Administrator');
$form->addElement( $form->addSelect(
'select',
'keyword_status', 'keyword_status',
get_lang('Profile'), get_lang('Profile'),
$status_options $status_options

@ -1071,8 +1071,7 @@ switch ($action) {
} }
if (count($attendance_select) > 1) { if (count($attendance_select) > 1) {
$form->addElement( $form->addSelect(
'select',
'attendance_select', 'attendance_select',
get_lang('Attendances'), get_lang('Attendances'),
$attendance_select, $attendance_select,

@ -180,12 +180,10 @@ if (Security::check_token('post') && ('course_select_form' === $action || 'full_
foreach ($backups as $index => $backup) { foreach ($backups as $index => $backup) {
$options[$backup['file']] = $backup['course_code'].' ('.$backup['date'].')'; $options[$backup['file']] = $backup['course_code'].' ('.$backup['date'].')';
} }
$form->addElement( $form->addSelect(
'select',
'backup_server', 'backup_server',
'', '',
$options, $options
'style="margin-left: 50px;"'
); );
$form->addElement( $form->addElement(
'html', 'html',

@ -923,8 +923,7 @@ class TestCategory
'1' => get_lang('Visible'), '1' => get_lang('Visible'),
'0' => get_lang('Hidden'), '0' => get_lang('Hidden'),
]; ];
$form->addElement( $form->addSelect(
'select',
'visibility', 'visibility',
get_lang('Visibility'), get_lang('Visibility'),
$options $options

@ -99,7 +99,7 @@ switch ($action) {
} else { } else {
$actions = '<a href="'.$url.'">'. $actions = '<a href="'.$url.'">'.
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
$content .= Display::toolbarAction('toolbar', [$actions]); $content = Display::toolbarAction('toolbar', [$actions]);
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
$form->setConstants(['sec_token' => $token]); $form->setConstants(['sec_token' => $token]);
$content .= $form->returnForm(); $content .= $form->returnForm();
@ -123,7 +123,7 @@ switch ($action) {
} else { } else {
$actions = '<a href="'.$url.'">'. $actions = '<a href="'.$url.'">'.
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
$content .= Display::toolbarAction('toolbar', [$actions]); $content = Display::toolbarAction('toolbar', [$actions]);
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
$form->setConstants(['sec_token' => $token]); $form->setConstants(['sec_token' => $token]);
$content .= $form->returnForm(); $content .= $form->returnForm();

@ -2036,8 +2036,7 @@ class Exercise
//EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_RANDOM => get_lang('OrderedCategoriesByParentWithQuestionsRandom'), //EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_RANDOM => get_lang('OrderedCategoriesByParentWithQuestionsRandom'),
]; ];
$form->addElement( $form->addSelect(
'select',
'question_selection_type', 'question_selection_type',
[get_lang('Question selection type')], [get_lang('Question selection type')],
$option, $option,
@ -2107,8 +2106,7 @@ class Exercise
$option = range(0, $max); $option = range(0, $max);
$option[0] = get_lang('No'); $option[0] = get_lang('No');
$option[-1] = get_lang('All'); $option[-1] = get_lang('All');
$form->addElement( $form->addSelect(
'select',
'randomQuestions', 'randomQuestions',
[ [
get_lang('Random questions'), get_lang('Random questions'),
@ -3911,7 +3909,7 @@ class Exercise
} }
} }
} else { } else {
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null; $studentChoice = $choice[$answerAutoId] ?? null;
if (1 == $answerCorrect) { if (1 == $answerCorrect) {
$real_answers[$answerId] = false; $real_answers[$answerId] = false;
if ($studentChoice) { if ($studentChoice) {
@ -5729,7 +5727,7 @@ class Exercise
// Save the score attempts // Save the score attempts
if (1) { if (1) {
//getting the answer 1 or 0 comes from exercise_submit_modal.php //getting the answer 1 or 0 comes from exercise_submit_modal.php
$final_answer = isset($hotspot_delineation_result[1]) ? $hotspot_delineation_result[1] : ''; $final_answer = $hotspot_delineation_result[1] ?? '';
if (0 == $final_answer) { if (0 == $final_answer) {
$questionScore = 0; $questionScore = 0;
} }

@ -536,7 +536,7 @@ function parseQti2($xmlData)
} }
if ('inlineChoiceInteraction' === $childNode->nodeName) { if ('inlineChoiceInteraction' === $childNode->nodeName) {
$currentQuestionItemBody .= '**claroline_start**'.$childNode->attr('responseIdentifier') $currentQuestionItemBody .= '**claroline_start**'.$childNode->getAttribute('responseIdentifier')
.'**claroline_end**'; .'**claroline_end**';
continue; continue;

@ -339,12 +339,16 @@ class FillBlanks extends Question
//added multiple answers //added multiple answers
$form->addCheckBox('multiple_answer', '', get_lang('Allow answers order switches')); $form->addCheckBox('multiple_answer', '', get_lang('Allow answers order switches'));
$form->addElement( $form->addSelect(
'select',
'select_separator', 'select_separator',
get_lang('Select a blanks marker'), get_lang('Select a blanks marker'),
self::getAllowedSeparatorForSelect(), self::getAllowedSeparatorForSelect(),
' id="select_separator" style="width:150px" class="form-control" onchange="changeBlankSeparator()" ' [
'id' => 'select_separator',
'style' => 'width:150px',
'class' => 'form-control',
'onchange' => 'changeBlankSeparator()',
]
); );
$form->addLabel( $form->addLabel(
null, null,

@ -32,8 +32,7 @@ $question_list_options = [];
foreach ($question_list as $key => $value) { foreach ($question_list as $key => $value) {
$question_list_options[$key] = addslashes(get_lang($value[1])); $question_list_options[$key] = addslashes(get_lang($value[1]));
} }
$form->addElement( $form->addSelect(
'select',
'question_type_hidden', 'question_type_hidden',
get_lang('Question type'), get_lang('Question type'),
$question_list_options, $question_list_options,

@ -64,7 +64,7 @@ switch ($action) {
if (!empty($categories)) { if (!empty($categories)) {
foreach ($categories as $category) { foreach ($categories as $category) {
$export[] = [$category['title'], $category['description']]; $export[] = [$category->getTitle(), $category->getDescription()];
} }
} }

@ -2134,8 +2134,7 @@ class Agenda
'html', 'html',
'<div id="options2" style="display:none">' '<div id="options2" style="display:none">'
); );
$form->addElement( $form->addSelect(
'select',
'repeat_type', 'repeat_type',
get_lang('Repeat type'), get_lang('Repeat type'),
self::getRepeatTypes() self::getRepeatTypes()

@ -853,7 +853,7 @@ function api_get_path($path = '', $configuration = [])
global $virtualChamilo; global $virtualChamilo;
if (!empty($virtualChamilo)) { if (!empty($virtualChamilo)) {
$paths[SYS_ARCHIVE_PATH] = api_add_trailing_slash($virtualChamilo[SYS_ARCHIVE_PATH]); $paths[SYS_ARCHIVE_PATH] = api_add_trailing_slash($virtualChamilo[SYS_ARCHIVE_PATH]);
$paths[SYS_UPLOAD_PATH] = api_add_trailing_slash($virtualChamilo[SYS_UPLOAD_PATH]); //$paths[SYS_UPLOAD_PATH] = api_add_trailing_slash($virtualChamilo[SYS_UPLOAD_PATH]);
//$paths[$root_web][WEB_UPLOAD_PATH] = api_add_trailing_slash($virtualChamilo[WEB_UPLOAD_PATH]); //$paths[$root_web][WEB_UPLOAD_PATH] = api_add_trailing_slash($virtualChamilo[WEB_UPLOAD_PATH]);
$paths[WEB_ARCHIVE_PATH] = api_add_trailing_slash($virtualChamilo[WEB_ARCHIVE_PATH]); $paths[WEB_ARCHIVE_PATH] = api_add_trailing_slash($virtualChamilo[WEB_ARCHIVE_PATH]);
//$paths[$root_web][WEB_COURSE_PATH] = api_add_trailing_slash($virtualChamilo[WEB_COURSE_PATH]); //$paths[$root_web][WEB_COURSE_PATH] = api_add_trailing_slash($virtualChamilo[WEB_COURSE_PATH]);
@ -3767,14 +3767,14 @@ function api_is_allowed($tool, $action, $task_id = 0)
// Getting the permissions of this user. // Getting the permissions of this user.
if (0 == $task_id) { if (0 == $task_id) {
$user_permissions = get_permissions('user', $_user['user_id']); //$user_permissions = get_permissions('user', $_user['user_id']);
$_SESSION['total_permissions'][$_course['code']] = $user_permissions; //$_SESSION['total_permissions'][$_course['code']] = $user_permissions;
} }
// Getting the permissions of the task. // Getting the permissions of the task.
if (0 != $task_id) { if (0 != $task_id) {
$task_permissions = get_permissions('task', $task_id); //$task_permissions = get_permissions('task', $task_id);
/* !!! */ $_SESSION['total_permissions'][$_course['code']] = $task_permissions; //$_SESSION['total_permissions'][$_course['code']] = $task_permissions;
} }
} }
@ -7965,7 +7965,7 @@ function api_unserialize_content($type, $serialized, $ignoreErrors = false)
scormOrganization::class, scormOrganization::class,
scormResource::class, scormResource::class,
Link::class, Link::class,
LpItem::class, //LpItem::class,
]; ];
break; break;
case 'course': case 'course':

@ -79,28 +79,6 @@ class CourseDescription
$qb = $repo->getResourcesByCourse($course, $session); $qb = $repo->getResourcesByCourse($course, $session);
return $qb->getQuery()->getResult(); return $qb->getQuery()->getResult();
/*$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$condition_session = api_get_session_condition(
$this->session_id,
true,
true
);
if (empty($course_id)) {
return [];
}
$sql = "SELECT * FROM $table
ORDER BY iid ";
$rs = Database::query($sql);
$data = [];
while ($description = Database::fetch_array($rs)) {
$data['descriptions'][$description['iid']] = $description;
}
return $data;*/
} }
/** /**
@ -192,7 +170,6 @@ class CourseDescription
public function get_max_description_type() public function get_max_description_type()
{ {
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION); $table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_id = api_get_course_int_id();
$sql = "SELECT MAX(description_type) as MAX $sql = "SELECT MAX(description_type) as MAX
FROM $table FROM $table
@ -274,17 +251,6 @@ class CourseDescription
] ]
); );
if ($this->id > 0) {
// Insert into item_property
api_item_property_update(
api_get_course_info(),
TOOL_COURSE_DESCRIPTION,
$this->id,
'CourseDescriptionUpdated',
api_get_user_id()
);
}
return 1; return 1;
} }

@ -251,13 +251,13 @@ class Display
$tableName = 'tablename', $tableName = 'tablename',
$tableId = '' $tableId = ''
) { ) {
$column = isset($sorting_options['column']) ? $sorting_options['column'] : 0; $column = $sorting_options['column'] ?? 0;
$default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20; $default_items_per_page = $paging_options['per_page'] ?? 20;
$table = new SortableTableFromArray($content, $column, $default_items_per_page, $tableName, null, $tableId); $table = new SortableTableFromArray($content, $column, $default_items_per_page, $tableName, null, $tableId);
if (is_array($query_vars)) { if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars); $table->set_additional_parameters($query_vars);
} }
if ('table' == $style) { if ('table' === $style) {
if (is_array($header) && count($header) > 0) { if (is_array($header) && count($header) > 0) {
foreach ($header as $index => $header_item) { foreach ($header as $index => $header_item) {
$table->set_header( $table->set_header(
@ -389,9 +389,9 @@ class Display
$elementCount = 0 $elementCount = 0
) { ) {
$column = 0; $column = 0;
$default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20; $default_items_per_page = $paging_options['per_page'] ?? 20;
$table = new SortableTableFromArray($content, $column, $default_items_per_page, $name); $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
$table->total_number_of_items = intval($elementCount); $table->total_number_of_items = (int) $elementCount;
if (is_array($query_vars)) { if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars); $table->set_additional_parameters($query_vars);
} }

@ -1,4 +1,5 @@
<?php <?php
/* See license terms in /license.txt */ /* See license terms in /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi; use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
@ -2343,7 +2344,6 @@ class Event
} }
if (Tracking::minimumTimeAvailable($sessionId, $courseId)) { if (Tracking::minimumTimeAvailable($sessionId, $courseId)) {
$workId = (int) $workId;
$sql = "SELECT id FROM track_e_access_complete $sql = "SELECT id FROM track_e_access_complete
WHERE WHERE
tool = '".TOOL_STUDENTPUBLICATION."' AND tool = '".TOOL_STUDENTPUBLICATION."' AND

@ -1651,6 +1651,8 @@ HOTSPOT;
public static function showTestsWhereQuestionIsUsed(int $questionId, int $excludeTestId = 0) public static function showTestsWhereQuestionIsUsed(int $questionId, int $excludeTestId = 0)
{ {
$questionId = (int) $questionId; $questionId = (int) $questionId;
$excludeTestId = (int) $excludeTestId;
$sql = "SELECT qz.title quiz_title, $sql = "SELECT qz.title quiz_title,
c.title course_title, c.title course_title,
s.name session_name, s.name session_name,
@ -1665,7 +1667,6 @@ HOTSPOT;
(qz.session_id = s.id OR qz.session_id = 0) AND (qz.session_id = s.id OR qz.session_id = 0) AND
qq.quiz_id = qz.iid AND "; qq.quiz_id = qz.iid AND ";
if (!empty($excludeTestId)) { if (!empty($excludeTestId)) {
$excludeTestId = (int) $excludeTestId;
$sql .= " qz.iid != $excludeTestId AND "; $sql .= " qz.iid != $excludeTestId AND ";
} }
$sql .= " qq.question_id = $questionId $sql .= " qq.question_id = $questionId

@ -1,9 +1,10 @@
<?php <?php
/* See license terms in /license.txt */ /* See license terms in /license.txt */
use Chamilo\CoreBundle\Component\Editor\Connector; //use Chamilo\CoreBundle\Component\Editor\Connector;
use MediaAlchemyst\Alchemyst; //use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\DriversContainer; //use MediaAlchemyst\DriversContainer;
use Neutron\TemporaryFilesystem\Manager; use Neutron\TemporaryFilesystem\Manager;
use Neutron\TemporaryFilesystem\TemporaryFilesystem; use Neutron\TemporaryFilesystem\TemporaryFilesystem;
use Sonata\Exporter\Handler; use Sonata\Exporter\Handler;
@ -213,9 +214,8 @@ class Export
$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true); $table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
$row++; $row++;
} }
$table_tp_html = $table->toHtml();
return $table_tp_html; return $table->toHtml();
} }
/** /**
@ -236,7 +236,7 @@ class Export
} }
if (!empty($html)) { if (!empty($html)) {
$fs = new Filesystem(); /*$fs = new Filesystem();
$paths = [ $paths = [
'root_sys' => api_get_path(SYS_PATH), 'root_sys' => api_get_path(SYS_PATH),
'path.temp' => api_get_path(SYS_ARCHIVE_PATH), 'path.temp' => api_get_path(SYS_ARCHIVE_PATH),
@ -279,7 +279,7 @@ class Export
} catch (Exception $e) { } catch (Exception $e) {
// error_log($e->getMessage()); // error_log($e->getMessage());
} }
} }*/
} }
} }
} }

@ -1193,8 +1193,7 @@ class ExtraField extends Model
$options[$optionDetails['option_value']] = $optionDetails['display_text']; $options[$optionDetails['option_value']] = $optionDetails['display_text'];
} }
} }
$form->addElement( $form->addSelect(
'select',
'extra_'.$variable, 'extra_'.$variable,
$field_details['display_text'], $field_details['display_text'],
$options, $options,
@ -1436,12 +1435,10 @@ class ExtraField extends Model
break; break;
case self::FIELD_TYPE_TIMEZONE: case self::FIELD_TYPE_TIMEZONE:
$form->addElement( $form->addSelect(
'select',
'extra_'.$variable, 'extra_'.$variable,
$field_details['display_text'], $field_details['display_text'],
api_get_timezones(), api_get_timezones(),
''
); );
if ($freezeElement) { if ($freezeElement) {
$form->freeze('extra_'.$variable); $form->freeze('extra_'.$variable);

@ -892,7 +892,7 @@ EOT;
* *
* @return HTML_QuickForm_select * @return HTML_QuickForm_select
*/ */
public function addSelect($name, $label, $options = [], $attributes = []) public function addSelect(string $name, $label, array $options = [], array $attributes = [])
{ {
return $this->addElement('select', $name, $label, $options, $attributes); return $this->addElement('select', $name, $label, $options, $attributes);
} }

@ -178,8 +178,7 @@ class Gradebook extends Model
foreach ($skills as $skill) { foreach ($skills as $skill) {
$clean_skill_list[$skill['id']] = $skill['name']; $clean_skill_list[$skill['id']] = $skill['name'];
} }
$form->addElement( $form->addSelect(
'select',
'skill', 'skill',
get_lang('Skills'), get_lang('Skills'),
$clean_skill_list, $clean_skill_list,

@ -91,7 +91,7 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
$icon = $this->getIcon(); $icon = $this->getIcon();
if (!empty($icon)) { if (!empty($icon)) {
$icon = '<em class="mr-1 ' . $this->getIcon() . '"></em> '; $icon = '<em class="'.$this->getIcon().'"></em> ';
} }
$class = $this->getClass().' '.$this->getStyle().' '.$this->getSize(); $class = $this->getClass().' '.$this->getStyle().' '.$this->getSize();

@ -6272,15 +6272,13 @@ class Tracking
public static function setUserSearchForm($form) public static function setUserSearchForm($form)
{ {
$form->addElement('text', 'keyword', get_lang('Keyword')); $form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addElement( $form->addSelect(
'select',
'active', 'active',
get_lang('Status'), get_lang('Status'),
[1 => get_lang('active'), 0 => get_lang('inactive')] [1 => get_lang('active'), 0 => get_lang('inactive')]
); );
$form->addElement( $form->addSelect(
'select',
'sleeping_days', 'sleeping_days',
get_lang('Inactive days'), get_lang('Inactive days'),
[ [

@ -8496,7 +8496,7 @@ class learnpath
if (!empty($itemList['thread'])) { if (!empty($itemList['thread'])) {
$threadList = []; $threadList = [];
$em = Database::getManager(); $em = Database::getManager();
$repo = $em->getRepository('ChamiloCourseBundle:CForumThread'); $repo = Container::getForumThreadRepository();
foreach ($itemList['thread'] as $threadId) { foreach ($itemList['thread'] as $threadId) {
/** @var CForumThread $thread */ /** @var CForumThread $thread */
$thread = $repo->find($threadId); $thread = $repo->find($threadId);

@ -136,7 +136,7 @@ $tpl->assign('filename', $lp_item->get_title().'_nano.wav');
$tpl->assign('enable_record_audio', 'true' === api_get_setting('enable_record_audio')); $tpl->assign('enable_record_audio', 'true' === api_get_setting('enable_record_audio'));
$tpl->assign('cur_dir_path', '/audio'); $tpl->assign('cur_dir_path', '/audio');
$tpl->assign('lp_item_id', $lp_item_id); $tpl->assign('lp_item_id', $lp_item_id);
$tpl->assign('lp_dir', api_remove_trailing_slash($lpPathInfo['dir'])); //$tpl->assign('lp_dir', api_remove_trailing_slash($lpPathInfo['dir']));
$recordVoiceForm .= $tpl->fetch('@ChamiloCore/LearnPath/record_voice.html.twig'); $recordVoiceForm .= $tpl->fetch('@ChamiloCore/LearnPath/record_voice.html.twig');
$form->addElement('header', '<small class="text-muted">'.get_lang('Or').'</small> '.get_lang('AudioFile')); $form->addElement('header', '<small class="text-muted">'.get_lang('Or').'</small> '.get_lang('AudioFile'));

@ -21,7 +21,7 @@ $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null; $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null;
$learnpath_id = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : null; $learnpath_id = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : null;
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null; $submit = $_POST['submit_button'] ?? null;
/* MAIN CODE */ /* MAIN CODE */
if (!$is_allowed_to_edit || $isStudentView) { if (!$is_allowed_to_edit || $isStudentView) {

@ -230,7 +230,7 @@ function generateLPFinalItemTemplate(
function generateLPFinalItemTemplateBadgeLinks($userId, $courseId, $sessionId = 0) function generateLPFinalItemTemplateBadgeLinks($userId, $courseId, $sessionId = 0)
{ {
$em = Database::getManager(); $em = Database::getManager();
$skillRelUser = new SkillRelUser(); $skillRelUser = new SkillRelUserModel();
$userSkills = $skillRelUser->getUserSkills($userId, $courseId, $sessionId); $userSkills = $skillRelUser->getUserSkills($userId, $courseId, $sessionId);
$skillList = ''; $skillList = '';
$badgeLink = ''; $badgeLink = '';

@ -111,8 +111,8 @@ if (count($term_array)) {
} }
if ($query) { if ($query) {
list($count, $results) = chamilo_query_query( [$count, $results] = chamilo_query_query(
api_convert_encoding($query, 'UTF-8', $charset), $query,
0, 0,
1000, 1000,
$fixed_queries $fixed_queries

@ -333,7 +333,7 @@ $lp_theme_css = $lp->getTheme();
// Setting up the CSS theme if exists. // Setting up the CSS theme if exists.
if (!empty($lp_theme_css) && !empty($mycourselptheme) && -1 != $mycourselptheme && 1 == $mycourselptheme) { if (!empty($lp_theme_css) && !empty($mycourselptheme) && -1 != $mycourselptheme && 1 == $mycourselptheme) {
global $lp_theme_css; //global $lp_theme_css;
} else { } else {
$lp_theme_css = $my_style; $lp_theme_css = $my_style;
} }
@ -364,7 +364,7 @@ if (Database::num_rows($res_media) > 0) {
$is_allowed_to_edit = api_is_allowed_to_edit(false, true, true, false); $is_allowed_to_edit = api_is_allowed_to_edit(false, true, true, false);
global $interbreadcrumb; //global $interbreadcrumb;
if ($is_allowed_to_edit) { if ($is_allowed_to_edit) {
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_self().'?action=list&isStudentView=false&'.api_get_cidreq(true, true, 'course'), 'url' => api_get_self().'?action=list&isStudentView=false&'.api_get_cidreq(true, true, 'course'),

@ -46,8 +46,7 @@ $form = new FormValidator(
); );
$form->addElement('text', 'from', get_lang('From'), ['id' => 'date_from']); $form->addElement('text', 'from', get_lang('From'), ['id' => 'date_from']);
$form->addElement('text', 'to', get_lang('Until'), ['id' => 'date_to']); $form->addElement('text', 'to', get_lang('Until'), ['id' => 'date_to']);
$form->addElement( $form->addSelect(
'select',
'type', 'type',
get_lang('Type'), get_lang('Type'),
['day' => get_lang('Day'), 'month' => get_lang('Month')], ['day' => get_lang('Day'), 'month' => get_lang('Month')],

@ -334,8 +334,7 @@ $form = new FormValidator(
'get', 'get',
$webCodePath.'mySpace/users.php' $webCodePath.'mySpace/users.php'
); );
$form->addElement( $form->addSelect(
'select',
'status', 'status',
get_lang('Status'), get_lang('Status'),
[ [

@ -370,10 +370,10 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
echo ' </td>'; echo ' </td>';
$question_counter++; $question_counter++;
if ($is_survey_type_1) { /*if ($is_survey_type_1) {
echo '<td>'.((0 == $row['survey_group_pri']) ? get_lang('Secondary') : get_lang('Primary')).'</td>'; echo '<td>'.((0 == $row['survey_group_pri']) ? get_lang('Secondary') : get_lang('Primary')).'</td>';
echo '<td>'.((0 == $row['survey_group_pri']) ? $groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']] : $groups[$row['survey_group_pri']]).'</td>'; echo '<td>'.((0 == $row['survey_group_pri']) ? $groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']] : $groups[$row['survey_group_pri']]).'</td>';
} }*/
echo '</tr>'; echo '</tr>';
} }

@ -317,16 +317,14 @@ $form->addLabel(
) )
); );
$form->addElement( $form->addSelect(
'select',
'status_id', 'status_id',
get_lang('Status'), get_lang('Status'),
$statusList, $statusList,
$statusAttributes $statusAttributes
); );
$form->addElement( $form->addSelect(
'select',
'priority_id', 'priority_id',
get_lang('Priority'), get_lang('Priority'),
$priorityList, $priorityList,
@ -336,8 +334,7 @@ $form->addElement(
] ]
); );
$form->addElement( $form->addSelect(
'select',
'source_id', 'source_id',
get_lang('Source'), get_lang('Source'),
$sourceList, $sourceList,

@ -47,8 +47,7 @@ foreach ($course_list as $data) {
} }
$form = new FormValidator('search_simple', 'POST', '', '', null, false); $form = new FormValidator('search_simple', 'POST', '', '', null, false);
$form->addElement( $form->addSelect(
'select',
'course_code', 'course_code',
get_lang('Course'), get_lang('Course'),
$new_course_select $new_course_select

@ -59,15 +59,13 @@ foreach ($session_list as $sesion_item) {
} }
$form = new FormValidator('search_simple', 'POST', '', '', null, false); $form = new FormValidator('search_simple', 'POST', '', '', null, false);
$form->addElement( $form->addSelect(
'select',
'session_id', 'session_id',
get_lang('Course sessions'), get_lang('Course sessions'),
$my_session_list, $my_session_list,
['id' => 'session_id', 'onchange' => 'load_courses();'] ['id' => 'session_id', 'onchange' => 'load_courses();']
); );
$form->addElement( $form->addSelect(
'select',
'course_code', 'course_code',
get_lang('Courses'), get_lang('Courses'),
$course_select_list $course_select_list

@ -472,8 +472,7 @@ switch ($action) {
} else { } else {
if (BuyCoursesPlugin::SERVICE_TYPE_SESSION == $nodeType) { if (BuyCoursesPlugin::SERVICE_TYPE_SESSION == $nodeType) {
$nodeType = get_lang('Session'); $nodeType = get_lang('Session');
/** @var Session $session */ $session = api_get_session_entity($serviceSale['node_id']);
$session = $em->find('ChamiloCoreBundle:Session', $serviceSale['node_id']);
$nodeName = $session ? $session->getName() : null; $nodeName = $session ? $session->getName() : null;
} else { } else {
if (BuyCoursesPlugin::SERVICE_TYPE_LP_FINAL_ITEM == $nodeType) { if (BuyCoursesPlugin::SERVICE_TYPE_LP_FINAL_ITEM == $nodeType) {

@ -897,15 +897,13 @@ while ($i < 298) {
$marginOptions[$i] = $i.' mm'; $marginOptions[$i] = $i.' mm';
$i++; $i++;
} }
$form->addElement( $form->addSelect(
'select',
'margin_left', 'margin_left',
get_lang('MarginLeft'), get_lang('MarginLeft'),
$marginOptions, $marginOptions,
['cols-size' => [4, 8, 0]] ['cols-size' => [4, 8, 0]]
); );
$form->addElement( $form->addSelect(
'select',
'margin_right', 'margin_right',
get_lang('MarginRight'), get_lang('MarginRight'),
$marginOptions, $marginOptions,

Loading…
Cancel
Save