diff --git a/psalm.xml b/psalm.xml index e2415c8dcf..9a87e2cc83 100644 --- a/psalm.xml +++ b/psalm.xml @@ -11,9 +11,10 @@ + - + @@ -29,8 +30,10 @@ - - + + + + @@ -39,24 +42,51 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -82,7 +112,6 @@ - @@ -100,11 +129,8 @@ - - - @@ -112,7 +138,6 @@ - diff --git a/public/main/auth/courses.php b/public/main/auth/courses.php index b0b979940f..305417e067 100644 --- a/public/main/auth/courses.php +++ b/public/main/auth/courses.php @@ -107,7 +107,8 @@ switch ($action) { break; case 'subscribe_course': if (api_is_anonymous()) { - header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php?c='.$courseCodeToSubscribe); + //header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php?c='.$courseCodeToSubscribe); + header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php'); exit; } $courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : ''; @@ -408,8 +409,8 @@ switch ($action) { if ($allowExtraFields) { $extraFieldValues = new ExtraFieldValue('course'); $em = Database::getManager(); - $fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField'); - $fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); + $fieldsRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraField::class); + $fieldTagsRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraFieldRelTag::class); } $courseUrl = api_get_path(WEB_COURSE_PATH); @@ -613,7 +614,7 @@ switch ($action) { $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription'); if ('true' === $registrationAllowed) { $entityManager = Database::getManager(); - $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); + $repository = $entityManager->getRepository(SequenceResource::class); $sequences = $repository->getRequirements( $sessionId, SequenceResource::SESSION_TYPE diff --git a/public/main/auth/inscription.php b/public/main/auth/inscription.php index cbe80af326..c7bd4f7e5e 100644 --- a/public/main/auth/inscription.php +++ b/public/main/auth/inscription.php @@ -431,47 +431,50 @@ $content = null; $tool_name = get_lang('Registration'); -if (!CustomPages::enabled()) { - // Load terms & conditions from the current lang - if ('true' === api_get_setting('allow_terms_conditions')) { - $get = array_keys($_GET); - if (isset($get)) { - if (isset($get[0]) && 'legal' == $get[0]) { - $language = api_get_interface_language(); +// Load terms & conditions from the current lang +if ('true' === api_get_setting('allow_terms_conditions')) { + $get = array_keys($_GET); + if (isset($get)) { + 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); + if (!$term_preview) { + //look for the default language + $language = api_get_setting('platformLanguage'); $language = api_get_language_id($language); $term_preview = LegalManager::get_last_condition($language); - if (!$term_preview) { - //look for the default language - $language = api_get_setting('platformLanguage'); - $language = api_get_language_id($language); - $term_preview = LegalManager::get_last_condition($language); - } - Display::display_header(get_lang('Terms and Conditions')); - if (!empty($term_preview['content'])) { - echo $term_preview['content']; - - $termExtraFields = new ExtraFieldValue('terms_and_condition'); - $values = $termExtraFields->getAllValuesByItem($term_preview['id']); - foreach ($values as $value) { - echo '

'.$value['display_text'].'


'.$value['value'].'
'; - } - } else { - echo get_lang('Coming soon...'); + } + Display::display_header(get_lang('Terms and Conditions')); + if (!empty($term_preview['content'])) { + echo $term_preview['content']; + + $termExtraFields = new ExtraFieldValue('terms_and_condition'); + $values = $termExtraFields->getAllValuesByItem($term_preview['id']); + foreach ($values as $value) { + echo '

'.$value['display_text'].'


'.$value['value'].'
'; } - Display::display_footer(); - exit; + } else { + echo get_lang('Coming soon...'); } + Display::display_footer(); + exit; } } +} - if ('true' === api_get_setting('allow_terms_conditions') && $user_already_registered_show_terms) { - $tool_name = get_lang('Terms and Conditions'); - } +if ('true' === api_get_setting('allow_terms_conditions') && $user_already_registered_show_terms) { + $tool_name = get_lang('Terms and Conditions'); } // Forbidden to self-register 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.')); + 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 ('approval' === api_get_setting('allow_registration')) { @@ -655,13 +658,13 @@ if ($form->validate()) { //an extra field $extras[substr($key, 6)] = $value; } elseif (false !== strpos($key, 'remove_extra_')) { - $extra_value = Security::filter_filename(urldecode(key($value))); + /*$extra_value = Security::filter_filename(urldecode(key($value))); // To remove from user_field_value and folder UserManager::update_extra_field_value( $user_id, substr($key, 13), $extra_value - ); + );*/ } } @@ -1061,60 +1064,46 @@ if ($form->validate()) { Session::erase('session_redirect'); Session::erase('only_one_course_session_redirect'); - if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION_FEEDBACK)) { - CustomPages::display( - CustomPages::REGISTRATION_FEEDBACK, - ['info' => $text_after_registration] - ); - } else { - $tpl = new Template($tool_name); - $tpl->assign('inscription_content', $content); - $tpl->assign('text_after_registration', $text_after_registration); - $tpl->assign('hide_header', $hideHeaders); - $inscription = $tpl->get_template('auth/inscription.tpl'); - $tpl->display($inscription); - } + $tpl = new Template($tool_name); + $tpl->assign('inscription_content', $content); + $tpl->assign('text_after_registration', $text_after_registration); + $tpl->assign('hide_header', $hideHeaders); + $inscription = $tpl->get_template('auth/inscription.tpl'); + $tpl->display($inscription); } else { - // Custom pages - if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION)) { - CustomPages::display( - CustomPages::REGISTRATION, - ['form' => $form, 'content' => $content] - ); - } else { - if (!api_is_anonymous()) { - // Saving user to course if it was set. - if (!empty($course_code_redirect)) { - $course_info = api_get_course_info($course_code_redirect); - if (!empty($course_info)) { - if (in_array( - $course_info['visibility'], - [ - COURSE_VISIBILITY_OPEN_PLATFORM, - COURSE_VISIBILITY_OPEN_WORLD, - ] - ) - ) { - CourseManager::subscribeUser( - $user_id, - $course_info['code'] - ); - } + if (!api_is_anonymous()) { + // Saving user to course if it was set. + if (!empty($course_code_redirect)) { + $course_info = api_get_course_info($course_code_redirect); + if (!empty($course_info)) { + if (in_array( + $course_info['visibility'], + [ + COURSE_VISIBILITY_OPEN_PLATFORM, + COURSE_VISIBILITY_OPEN_WORLD, + ] + ) + ) { + CourseManager::subscribeUser( + api_get_user_id(), + $course_info['code'] + ); } } - CourseManager::redirectToCourse([]); } + CourseManager::redirectToCourse([]); + } - $tpl = new Template($tool_name); + $tpl = new Template($tool_name); - $tpl->assign('inscription_header', Display::page_header($tool_name)); - $tpl->assign('inscription_content', $content); - $tpl->assign('form', $form->returnForm()); - $tpl->assign('hide_header', $hideHeaders); - $page = Container::getPage('inscription'); - $tpl->assign('page', $page); + $tpl->assign('inscription_header', Display::page_header($tool_name)); + $tpl->assign('inscription_content', $content); + $tpl->assign('form', $form->returnForm()); + $tpl->assign('hide_header', $hideHeaders); + //$page = Container::getPage('inscription'); + //$tpl->assign('page', $page); + + $inscription = $tpl->get_template('auth/inscription.tpl'); + $tpl->display($inscription); - $inscription = $tpl->get_template('auth/inscription.tpl'); - $tpl->display($inscription); - } } diff --git a/public/main/auth/profile.php b/public/main/auth/profile.php index d8fbfbf744..2c9cb57a67 100644 --- a/public/main/auth/profile.php +++ b/public/main/auth/profile.php @@ -481,7 +481,7 @@ if ($form->validate()) { } // upload production if a new one is provided - if (isset($_FILES['production']) && $_FILES['production']['size']) { + /*if (isset($_FILES['production']) && $_FILES['production']['size']) { $res = upload_user_production(api_get_user_id()); if (!$res) { //it's a bit excessive to assume the extension is the reason why @@ -496,7 +496,7 @@ if ($form->validate()) { ) ); } - } + }*/ // remove values that shouldn't go in the database unset( @@ -640,12 +640,12 @@ if ($form->validate()) { ); Session::write('_user', $userInfo); - if ($hook) { + /*if ($hook) { Database::getManager()->clear(User::class); // Avoid cache issue (user entity is used before) $user = api_get_user_entity(api_get_user_id()); // Get updated user info for hook event $hook->setEventData(['user' => $user]); $hook->notifyUpdateUser(HOOK_EVENT_TYPE_POST); - } + }*/ Session::erase('system_timezone'); diff --git a/public/main/calendar/ical_export.php b/public/main/calendar/ical_export.php index f167c23dd1..0ee6c29d51 100644 --- a/public/main/calendar/ical_export.php +++ b/public/main/calendar/ical_export.php @@ -1,4 +1,5 @@ get_event($id); +$charset = api_get_system_encoding(); if (!empty($event)) { define('ICAL_LANG', api_get_language_isocode()); $ical = new Vcalendar(); $ical->setConfig('unique_id', api_get_path(WEB_PATH)); - $ical->setProperty('method', 'PUBLISH'); + $ical->setMethod(Vcalendar::PUBLISH); $ical->setConfig('url', api_get_path(WEB_PATH)); $vevent = new Vevent(); @@ -75,15 +77,13 @@ if (!empty($event)) { switch ($type) { case 'personal': case 'platform': - $vevent->setProperty('summary', api_convert_encoding($event['title'], 'UTF-8', $charset)); + $vevent->setSummary(api_convert_encoding($event['title'], 'UTF-8', $charset)); if (empty($event['start_date'])) { header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER'])); + exit; } list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']); - $vevent->setProperty( - 'dtstart', - ['year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s] - ); + $vevent->setDtstart(new DateTime($event['start_date'])); if (empty($event['end_date'])) { $y2 = $y; $m2 = $m; @@ -98,12 +98,10 @@ if (!empty($event)) { } else { list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']); } - $vevent->setProperty( - 'dtend', - ['year' => $y2, 'month' => $m2, 'day' => $d2, 'hour' => $h2, 'min' => $M2, 'sec' => $s2] - ); + + $vevent->setDtend(new DateTime("$y2-$m2-$d2 $h2:$M2:$s2")); //$vevent->setProperty( 'LOCATION', get_lang('Unknown') ); // property name - case independent - $vevent->setProperty('description', api_convert_encoding($event['description'], 'UTF-8', $charset)); + $vevent->setDescription(api_convert_encoding($event['description'], 'UTF-8', $charset)); //$vevent->setProperty( 'comment', 'This is a comment' ); //$user = api_get_user_info($event['user']); //$vevent->setProperty('organizer',$user['mail']); @@ -114,13 +112,12 @@ if (!empty($event)) { $ical->returnCalendar(); break; case 'course': - $vevent->setProperty('summary', api_convert_encoding($event['title'], 'UTF-8', $charset)); + $vevent->setSummary(api_convert_encoding($event['title'], 'UTF-8', $charset)); if (empty($event['start_date'])) { header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER'])); } list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']); - $vevent->setProperty( - 'dtstart', + $vevent->setDtstart( ['year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s] ); if (empty($event['end_date'])) { @@ -137,17 +134,15 @@ if (!empty($event)) { } else { list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']); } - $vevent->setProperty( - 'dtend', - ['year' => $y2, 'month' => $m2, 'day' => $d2, 'hour' => $h2, 'min' => $M2, 'sec' => $s2] - ); - $vevent->setProperty('description', api_convert_encoding($event['description'], 'UTF-8', $charset)); + + $vevent->setDtend(new DateTime("$y2-$m2-$d2 $h2:$M2:$s2")); + $vevent->setDescription(api_convert_encoding($event['description'], 'UTF-8', $charset)); //$vevent->setProperty( 'comment', 'This is a comment' ); //$user = api_get_user_info($event['user']); //$vevent->setProperty('organizer',$user['mail']); //$vevent->setProperty('attendee',$user['mail']); //$course = api_get_course_info(); - $vevent->setProperty('location', $course_info['name']); // property name - case independent + $vevent->setLocation($course_info['name']); // property name - case independent /*if($ai['repeat']) { $trans = array('daily'=>'DAILY','weekly'=>'WEEKLY','monthlyByDate'=>'MONTHLY','yearly'=>'YEARLY'); $freq = $trans[$ai['repeat_type']]; diff --git a/public/main/inc/lib/CoursesAndSessionsCatalog.class.php b/public/main/inc/lib/CoursesAndSessionsCatalog.class.php index c5c5541702..766eec64c3 100644 --- a/public/main/inc/lib/CoursesAndSessionsCatalog.class.php +++ b/public/main/inc/lib/CoursesAndSessionsCatalog.class.php @@ -1017,7 +1017,7 @@ class CoursesAndSessionsCatalog */ public static function returnThumbnail($course) { - $course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; + /*$course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; if (file_exists($course_path.'/course-pic.png')) { // redimensioned image 85x85 @@ -1034,7 +1034,7 @@ class CoursesAndSessionsCatalog ); } - return $courseMediumImage; + return $courseMediumImage;*/ } /** diff --git a/public/main/inc/lib/MailTemplateManager.php b/public/main/inc/lib/MailTemplateManager.php index 7b44882ed2..1ee682a280 100644 --- a/public/main/inc/lib/MailTemplateManager.php +++ b/public/main/inc/lib/MailTemplateManager.php @@ -173,7 +173,7 @@ class MailTemplateManager extends Model } $type = $template['type']; $urlId = api_get_current_access_url_id(); - $sql = "UPDATE {$this->table} SET default_template = 0 + $sql = "UPDATE {$this->table} SET default_template = 0 WHERE type = '$type' AND url_id = $urlId"; Database::query($sql); @@ -209,4 +209,29 @@ class MailTemplateManager extends Model return false; } + + /** + * Gets a custom mail template by the name of the template it replaces. + * + * @param string $templateType Name of the template file it replaces + * + * @return string + */ + public function getTemplateByType($templateType) + { + if (empty($templateType)) { + return ''; + } + $result = Database::select( + 'template', + $this->table, + ['where' => ['type = ? ' => $templateType, ' AND url_id = ? ' => api_get_current_access_url_id()]], + 'first' + ); + if (empty($result)) { + return ''; + } + + return $result['template']; + } } diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php index 2d3b015cbd..170e683ac8 100644 --- a/public/main/inc/lib/api.lib.php +++ b/public/main/inc/lib/api.lib.php @@ -8393,12 +8393,13 @@ function api_is_student_view_active() * @param int $itemId * @param string $cropParameters * - * @deprecated use Resources * * @return array|bool */ function api_upload_file($type, $file, $itemId, $cropParameters = '') { + throw new Exception('api_upload_file not implemented'); + $upload = process_uploaded_file($file); if ($upload) { $name = api_replace_dangerous_char($file['name']); diff --git a/public/main/inc/lib/exercise.lib.php b/public/main/inc/lib/exercise.lib.php index 52bb238d49..83d486b701 100644 --- a/public/main/inc/lib/exercise.lib.php +++ b/public/main/inc/lib/exercise.lib.php @@ -472,6 +472,7 @@ class ExerciseLib $hidingClass = ''; if (READING_COMPREHENSION == $answerType) { + /** @var ReadingComprehension */ $objQuestionTmp->setExerciseType($exercise->selectType()); $objQuestionTmp->processText($objQuestionTmp->selectDescription()); $hidingClass = 'hide-reading-answers'; @@ -4542,7 +4543,7 @@ EOT; } else { $pluginEvaluation = QuestionOptionsEvaluationPlugin::create(); if ('true' === $pluginEvaluation->get(QuestionOptionsEvaluationPlugin::SETTING_ENABLE)) { - $formula = $pluginEvaluation->getFormulaForExercise($objExercise->selectId()); + $formula = $pluginEvaluation->getFormulaForExercise($objExercise->getId()); if (!empty($formula)) { $total_score = $pluginEvaluation->getResultWithFormula($exeId, $formula); @@ -4625,7 +4626,7 @@ EOT; if (api_is_allowed_to_session_edit()) { Event::updateEventExercise( $exercise_stat_info['exe_id'], - $objExercise->selectId(), + $objExercise->getId(), $total_score, $total_weight, $sessionId, @@ -4639,7 +4640,7 @@ EOT; $allowStats = api_get_configuration_value('allow_gradebook_stats'); if ($allowStats) { $objExercise->generateStats( - $objExercise->selectId(), + $objExercise->getId(), api_get_course_info(), $sessionId ); @@ -5235,7 +5236,7 @@ EOT; $link = LinkFactory::load( null, null, - $objExercise->selectId(), + $objExercise->getId(), null, $courseCode, $categoryId @@ -5280,7 +5281,7 @@ EOT; $em = Database::getManager(); /** @var TrackEExercises $trackedExercise */ - $trackedExercise = $em->getRepository('ChamiloCoreBundle:TrackEExercises')->find($exeId); + $trackedExercise = $em->getRepository(TrackEExercises::class)->find($exeId); if (empty($trackedExercise)) { return null; @@ -5351,8 +5352,8 @@ EOT; } $trackedExercise - ->setExeResult($totalScore) - ->setExeWeighting($totalWeight); + ->setScore($totalScore) + ->setMaxScore($totalWeight); $em->persist($trackedExercise); $em->flush(); diff --git a/public/main/inc/lib/extra_field.lib.php b/public/main/inc/lib/extra_field.lib.php index 84f3f839e7..4bd88b6386 100644 --- a/public/main/inc/lib/extra_field.lib.php +++ b/public/main/inc/lib/extra_field.lib.php @@ -552,7 +552,7 @@ class ExtraField extends Model public function get_count() { $em = Database::getManager(); - $query = $em->getRepository('ChamiloCoreBundle:ExtraField')->createQueryBuilder('e'); + $query = $em->getRepository(EntityExtraField::class)->createQueryBuilder('e'); $query->select('count(e.id)'); $query->where('e.extraFieldType = :type'); $query->setParameter('type', $this->getExtraFieldType()); @@ -602,7 +602,7 @@ class ExtraField extends Model break; } $em = Database::getManager(); - $query = $em->getRepository('ChamiloCoreBundle:ExtraField')->createQueryBuilder('e'); + $query = $em->getRepository(EntityExtraField::class)->createQueryBuilder('e'); $query->select('e') ->where('e.extraFieldType = :type') ->setParameter('type', $this->getExtraFieldType()) @@ -895,23 +895,23 @@ class ExtraField extends Model * Get an array of all the values from the extra_field and extra_field_options tables * based on the current object's type. * - * @param array $conditions + * @param array $options * @param null $order_field_options_by * * @return array */ - public function get_all($conditions = [], $order_field_options_by = null) + public function get_all($options = [], $order_field_options_by = null) { - $conditions = Database::parse_conditions(['where' => $conditions]); + $options = Database::parse_conditions(['where' => $options]); - if (empty($conditions)) { - $conditions .= ' WHERE extra_field_type = '.$this->extraFieldType; + if (empty($options)) { + $options .= ' WHERE extra_field_type = '.$this->extraFieldType; } else { - $conditions .= ' AND extra_field_type = '.$this->extraFieldType; + $options .= ' AND extra_field_type = '.$this->extraFieldType; } $sql = "SELECT * FROM $this->table - $conditions + $options ORDER BY field_order ASC "; @@ -1246,7 +1246,7 @@ class ExtraField extends Model if ($separateValue > 0) { $em = Database::getManager(); $fieldTags = $em - ->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') + ->getRepository(ExtraFieldRelTag::class) ->findBy( [ 'fieldId' => $field_id, @@ -1256,8 +1256,7 @@ class ExtraField extends Model // ofaj for ($i = 0; $i < $separateValue; $i++) { - $tagsSelect = $form->addElement( - 'select', + $tagsSelect = $form->addSelect( 'extra_'.$field_details['variable'].'['.$i.']', $customLabelsExtraMultipleSelect[$field_details['variable']][$i], //$field_details['display_text'], null, @@ -1272,7 +1271,7 @@ class ExtraField extends Model } foreach ($fieldTags as $fieldTag) { - $tag = $em->find('ChamiloCoreBundle:Tag', $fieldTag->getTagId()); + $tag = $em->find(Tag::class, $fieldTag->getTagId()); if (empty($tag)) { continue; @@ -1330,7 +1329,7 @@ class ExtraField extends Model } else { $em = Database::getManager(); $fieldTags = $em->getRepository( - 'ChamiloCoreBundle:ExtraFieldRelTag' + ExtraFieldRelTag::class ) ->findBy( [ @@ -1342,7 +1341,7 @@ class ExtraField extends Model /** @var ExtraFieldRelTag $fieldTag */ foreach ($fieldTags as $fieldTag) { /** @var Tag $tag */ - $tag = $em->find('ChamiloCoreBundle:Tag', $fieldTag->getTagId()); + $tag = $em->find(Tag::class, $fieldTag->getTagId()); if (empty($tag)) { continue; @@ -1367,7 +1366,7 @@ class ExtraField extends Model } if ($useTagAsSelect) { - $fieldTags = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') + $fieldTags = $em->getRepository(ExtraFieldRelTag::class) ->findBy( [ 'fieldId' => $field_id, @@ -1375,7 +1374,7 @@ class ExtraField extends Model ); $tagsAdded = []; foreach ($fieldTags as $fieldTag) { - $tag = $em->find('ChamiloCoreBundle:Tag', $fieldTag->getTagId()); + $tag = $em->find(Tag::class, $fieldTag->getTagId()); if (empty($tag)) { continue; @@ -1464,7 +1463,7 @@ class ExtraField extends Model 'extra_'.$field_details['variable'], $field_details['display_text'], [ - 'size' => 60, + //'size' => 60, 'size' => implode( '; ', [ @@ -2007,7 +2006,7 @@ class ExtraField extends Model public function delete($id) { $em = Database::getManager(); - $items = $em->getRepository('ChamiloCoreBundle:ExtraFieldSavedSearch')->findBy(['field' => $id]); + $items = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch::class)->findBy(['field' => $id]); if ($items) { foreach ($items as $item) { $em->remove($item); @@ -2894,7 +2893,7 @@ JAVASCRIPT; $fields = $this->get_all(); $em = Database::getManager(); - $repoTag = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); + $repoTag = $em->getRepository(ExtraFieldRelTag::class); foreach ($fields as $field) { if ('1' != $field['visible_to_self']) { @@ -2923,7 +2922,7 @@ JAVASCRIPT; $data = []; foreach ($tags as $extraFieldTag) { /** @var \Chamilo\CoreBundle\Entity\Tag $tag */ - $tag = $em->find('ChamiloCoreBundle:Tag', $extraFieldTag->getTagId()); + $tag = $em->find(Tag::class, $extraFieldTag->getTagId()); $data[] = $tag->getTag(); } $valueData = implode(',', $data); @@ -3481,7 +3480,7 @@ JAVASCRIPT; $level3 = $this->getOptionsFromTripleSelect($options['level3'], $secondId); /** @var \HTML_QuickForm_select $slctFirst */ $slctFirst = $form->createElement('select', "extra_$variable", null, $values1, ['id' => $slctFirstId]); - /** @var \HTML_QuickForm_select $slctFirst */ + /** @var \HTML_QuickForm_select $slctSecond */ $slctSecond = $form->createElement( 'select', "extra_{$variable}_second", @@ -3489,7 +3488,7 @@ JAVASCRIPT; $values2, ['id' => $slctSecondId] ); - /** @var \HTML_QuickForm_select $slctFirst */ + /** @var \HTML_QuickForm_select $slctThird */ $slctThird = $form->createElement('select', "extra_{$variable}_third", null, $values3, ['id' => $slctThirdId]); foreach ($level1 as $item1) { diff --git a/public/main/inc/lib/extra_field_option.lib.php b/public/main/inc/lib/extra_field_option.lib.php index d4729d959a..efcc087515 100644 --- a/public/main/inc/lib/extra_field_option.lib.php +++ b/public/main/inc/lib/extra_field_option.lib.php @@ -66,7 +66,7 @@ class ExtraFieldOption extends Model $fieldId = (int) $fieldId; $sql = "SELECT count(*) as count - FROM $this->table o + FROM $this->table o INNER JOIN $this->tableExtraField e ON o.field_id = e.id WHERE @@ -535,7 +535,7 @@ class ExtraFieldOption extends Model } $result = Database::getManager() - ->getRepository('ChamiloCoreBundle:ExtraFieldOptions') + ->getRepository(ExtraFieldOptions::class) ->findBy(['field' => $field_id], $orderBy); if (!$result) { @@ -576,15 +576,13 @@ class ExtraFieldOption extends Model public function get_second_select_field_options_by_field($option_value_id, $to_json = false) { $em = Database::getManager(); - $option = $em->find('ChamiloCoreBundle:ExtraFieldOptions', $option_value_id); + $option = $em->find(ExtraFieldOptions::class, $option_value_id); if (!$option) { return !$to_json ? [] : '{}'; } - $subOptions = $em - ->getRepository('ChamiloCoreBundle:ExtraFieldOptions') - ->findSecondaryOptions($option); + $subOptions = $em->getRepository(ExtraFieldOptions::class)->findSecondaryOptions($option); $optionsInfo = []; /** @var ExtraFieldOptions $subOption */ diff --git a/public/main/inc/lib/extra_field_value.lib.php b/public/main/inc/lib/extra_field_value.lib.php index 09f541e322..1b34912e7b 100644 --- a/public/main/inc/lib/extra_field_value.lib.php +++ b/public/main/inc/lib/extra_field_value.lib.php @@ -64,7 +64,7 @@ class ExtraFieldValue extends Model public function get_count() { $em = Database::getManager(); - $query = $em->getRepository('ChamiloCoreBundle:ExtraFieldValues')->createQueryBuilder('e'); + $query = $em->getRepository(ExtraFieldValues::class)->createQueryBuilder('e'); $query->select('count(e.id)'); $query->where('e.extraFieldType = :type'); $query->setParameter('type', $this->getExtraField()->getExtraFieldType()); @@ -198,7 +198,7 @@ class ExtraFieldValue extends Model $em = Database::getManager(); $currentTags = $em - ->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') + ->getRepository(ExtraFieldRelTag::class) ->findBy([ 'fieldId' => $extraFieldInfo['id'], 'itemId' => $params['item_id'], @@ -216,7 +216,7 @@ class ExtraFieldValue extends Model continue; } - $tagsResult = $em->getRepository('ChamiloCoreBundle:Tag') + $tagsResult = $em->getRepository(Tag::class) ->findBy([ 'tag' => $tagValue, 'fieldId' => $extraFieldInfo['id'], @@ -235,7 +235,7 @@ class ExtraFieldValue extends Model foreach ($tags as $tag) { $tagUses = $em - ->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') + ->getRepository(ExtraFieldRelTag::class) ->findBy([ 'tagId' => $tag->getId(), ]); @@ -908,7 +908,7 @@ class ExtraFieldValue extends Model } else { if (ExtraField::FIELD_TYPE_TAG == $field['field_type']) { $tagResult = []; - $tags = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') + $tags = $em->getRepository(ExtraFieldRelTag::class) ->findBy( [ 'fieldId' => $field['id'], @@ -919,7 +919,7 @@ class ExtraFieldValue extends Model /** @var ExtraFieldRelTag $extraFieldTag */ foreach ($tags as $extraFieldTag) { /** @var \Chamilo\CoreBundle\Entity\Tag $tag */ - $tag = $em->find('ChamiloCoreBundle:Tag', $extraFieldTag->getTagId()); + $tag = $em->find(Tag::class, $extraFieldTag->getTagId()); $tagResult[] = [ 'id' => $extraFieldTag->getTagId(), 'value' => $tag->getTag(), @@ -1085,7 +1085,7 @@ class ExtraFieldValue extends Model ->getQuery() ->getResult(); - $fieldOptionsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldOptions'); + $fieldOptionsRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraFieldOptions::class); $valueList = []; /** @var ExtraFieldValues $fieldValue */ diff --git a/public/main/inc/lib/import.lib.php b/public/main/inc/lib/import.lib.php index adf9b57b9c..b9af2639b7 100644 --- a/public/main/inc/lib/import.lib.php +++ b/public/main/inc/lib/import.lib.php @@ -1,7 +1,6 @@ load($filename); + $sheet = $spreadsheet->getActiveSheet(); - return $reader; + return $sheet->toArray(); } } diff --git a/public/main/inc/lib/message.lib.php b/public/main/inc/lib/message.lib.php index d8fce16cd0..6068331cd3 100644 --- a/public/main/inc/lib/message.lib.php +++ b/public/main/inc/lib/message.lib.php @@ -3,6 +3,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Message; +use Chamilo\CoreBundle\Entity\MessageFeedback; use Chamilo\CoreBundle\Entity\User; use ChamiloSession as Session; @@ -350,7 +351,7 @@ class MessageManager '; $result = Database::query($sql); $messages = []; - $repo = Database::getManager()->getRepository('ChamiloCoreBundle:Message'); + $repo = Database::getManager()->getRepository(Message::class); while ($row = Database::fetch_array($result)) { $message = $repo->find($row['id']); $messages[] = $message; @@ -387,7 +388,7 @@ class MessageManager false, false ); - $senderId = $message->getUserSenderId(); + $senderId = $message->getUserSender()->getId(); $senderInfo = api_get_user_info($senderId); $html .= Display::panelCollapse( $localTime.' '.$senderInfo['complete_name'].' '.$message->getTitle(), @@ -1343,10 +1344,6 @@ class MessageManager $table = Database::get_main_table(TABLE_MESSAGE); - if (empty($type)) { - return ''; - } - switch ($type) { case self::MESSAGE_TYPE_OUTBOX: $status = MESSAGE_STATUS_OUTBOX; @@ -3047,7 +3044,7 @@ class MessageManager } $userLike = $em - ->getRepository('ChamiloCoreBundle:MessageFeedback') + ->getRepository(MessageFeedback::class) ->findOneBy(['message' => $messageId, 'user' => $userId]); return [ diff --git a/public/main/session/index.php b/public/main/session/index.php index cbcabacd15..a22a523b55 100644 --- a/public/main/session/index.php +++ b/public/main/session/index.php @@ -264,8 +264,10 @@ if (!empty($courseList)) { $start_date = $exerciseInfo['start_time']; } + $exerciseId = $exerciseInfo['id']; + $best_score_data = ExerciseLib::get_best_attempt_in_course( - $exerciseInfo['id'], + $exerciseId, $courseInfo['real_id'], $session_id ); diff --git a/public/main/session/session_category_edit.php b/public/main/session/session_category_edit.php index aefcb0ce53..35de45ae95 100644 --- a/public/main/session/session_category_edit.php +++ b/public/main/session/session_category_edit.php @@ -8,6 +8,8 @@ require_once __DIR__.'/../inc/global.inc.php'; // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; api_protect_admin_script(true); + +$_user = api_get_user_info(); $id = (int) $_GET['id']; $formSent = 0; $errorMsg = ''; diff --git a/src/CoreBundle/Entity/User.php b/src/CoreBundle/Entity/User.php index 518440631b..6c84d2a7bd 100644 --- a/src/CoreBundle/Entity/User.php +++ b/src/CoreBundle/Entity/User.php @@ -1536,11 +1536,11 @@ class User implements UserInterface, EquatableInterface return $this->passwordRequestedAt; } - /*public function isPasswordRequestNonExpired($ttl) + public function isPasswordRequestNonExpired($ttl) { return $this->getPasswordRequestedAt() instanceof \DateTime && $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); - }*/ + } public function getUsername(): string { @@ -1791,6 +1791,13 @@ class User implements UserInterface, EquatableInterface return $this; } + public function setPasswordRequestedAt(\DateTime $date = null) + { + $this->passwordRequestedAt = $date; + + return $this; + } + public function setRoles(array $roles): self { $this->roles = [];