Internal - Fix legacy code, add psalm checks

pull/3543/head
Julio Montoya 5 years ago
parent 41516e4e1a
commit c87549682f
  1. 47
      psalm.xml
  2. 9
      public/main/auth/courses.php
  3. 151
      public/main/auth/inscription.php
  4. 8
      public/main/auth/profile.php
  5. 35
      public/main/calendar/ical_export.php
  6. 4
      public/main/inc/lib/CoursesAndSessionsCatalog.class.php
  7. 27
      public/main/inc/lib/MailTemplateManager.php
  8. 3
      public/main/inc/lib/api.lib.php
  9. 15
      public/main/inc/lib/exercise.lib.php
  10. 45
      public/main/inc/lib/extra_field.lib.php
  11. 10
      public/main/inc/lib/extra_field_option.lib.php
  12. 14
      public/main/inc/lib/extra_field_value.lib.php
  13. 8
      public/main/inc/lib/import.lib.php
  14. 11
      public/main/inc/lib/message.lib.php
  15. 4
      public/main/session/index.php
  16. 2
      public/main/session/session_category_edit.php
  17. 11
      src/CoreBundle/Entity/User.php

@ -11,9 +11,10 @@
<directory name="public/main/admin" /> <directory name="public/main/admin" />
<directory name="public/main/announcements"/> <directory name="public/main/announcements"/>
<directory name="public/main/attendance"/> <directory name="public/main/attendance"/>
<directory name="public/main/auth"/>
<!-- <directory name="public/main/badge"/>--> <!-- <directory name="public/main/badge"/>-->
<directory name="public/main/blog"/> <directory name="public/main/blog"/>
<!-- <directory name="public/main/calendar"/>--> <directory name="public/main/calendar"/>
<!-- <directory name="public/main/chat"/>--> <!-- <directory name="public/main/chat"/>-->
<!-- <directory name="public/main/course_description"/>--> <!-- <directory name="public/main/course_description"/>-->
<!-- <directory name="public/main/course_info"/>--> <!-- <directory name="public/main/course_info"/>-->
@ -29,8 +30,10 @@
<directory name="public/main/link" /> <directory name="public/main/link" />
<!-- <directory name="public/main/lp"/>--> <!-- <directory name="public/main/lp"/>-->
<!-- <directory name="public/main/session" /> --> <!-- <directory name="public/main/session" />-->
<!-- <directory name="public/main/inc/ajax" />-->
<!-- <directory name="public/main/inc/ajax" />-->
<directory name="public/main/work" /> <directory name="public/main/work" />
@ -39,24 +42,51 @@
<file name="public/main/inc/lib/access_url_edit_users_to_url_functions.lib.php"/> <file name="public/main/inc/lib/access_url_edit_users_to_url_functions.lib.php"/>
<file name="public/main/inc/lib/add_course.lib.inc.php"/> <file name="public/main/inc/lib/add_course.lib.inc.php"/>
<file name="public/main/inc/lib/add_courses_to_session_functions.lib.php"/> <file name="public/main/inc/lib/add_courses_to_session_functions.lib.php"/>
<!-- <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/blog.lib.php"/>-->
<file name="public/main/inc/lib/career.lib.php"/> <file name="public/main/inc/lib/career.lib.php"/>
<!-- <file name="public/main/inc/lib/certificate.lib.php"/>-->
<file name="public/main/inc/lib/course.lib.php"/> <file name="public/main/inc/lib/course.lib.php"/>
<file name="public/main/inc/lib/course_category.lib.php"/> <file name="public/main/inc/lib/course_category.lib.php"/>
<!-- <file name="public/main/inc/lib/course_description.lib.php"/>--> <!-- <file name="public/main/inc/lib/course_description.lib.php"/>-->
<!-- <file name="public/main/inc/lib/course_home.lib.php"/>--> <!-- <file name="public/main/inc/lib/course_home.lib.php"/>-->
<file name="public/main/inc/lib/course_request.lib.php"/> <file name="public/main/inc/lib/course_request.lib.php"/>
<file name="public/main/inc/lib/display.lib.php"/> <file name="public/main/inc/lib/display.lib.php"/>
<!-- <file name="public/main/inc/lib/CoursesAndSessionsCatalog.class.php"/>-->
<file name="public/main/inc/lib/dashboard.lib.php"/>
<!-- <file name="public/main/inc/lib/database.lib.php"/>-->
<!-- <file name="public/main/inc/lib/diagnoser.lib.php"/>-->
<!-- <file name="public/main/inc/lib/events.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/ExerciseCategoryManager.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_option.lib.php"/>
<!-- <file name="public/main/inc/lib/extra_field_value.lib.php"/>-->
<!-- <file name="public/main/inc/lib/glossary.lib.php"/>-->
<file name="public/main/inc/lib/grade_model.lib.php"/>
<file name="public/main/inc/lib/gradebook.lib.php"/>
<file name="public/main/inc/lib/groupmanager.lib.php"/> <file name="public/main/inc/lib/groupmanager.lib.php"/>
<!-- <file name="public/main/inc/lib/image.lib.php"/>-->
<file name="public/main/inc/lib/import.lib.php"/>
<file name="public/main/inc/lib/legal.lib.php"/>
<file name="public/main/inc/lib/link.lib.php"/>
<!-- <file name="public/main/inc/lib/message.lib.php"/>-->
<file name="public/main/inc/lib/model.lib.php"/>
<!-- <file name="public/main/inc/lib/myspace.lib.php"/>-->
<file name="public/main/inc/lib/sessionmanager.lib.php"/> <file name="public/main/inc/lib/sessionmanager.lib.php"/>
<!-- <file name="public/main/inc/lib/skill.lib.php"/>--> <!-- <file name="public/main/inc/lib/skill.lib.php"/>-->
<file name="public/main/inc/lib/link.lib.php"/> <file name="public/main/inc/lib/link.lib.php"/>
@ -82,7 +112,6 @@
<file name="public/main/inc/lib/timeline.lib.php"/> <file name="public/main/inc/lib/timeline.lib.php"/>
<file name="public/main/inc/lib/UnserializeApi.php"/> <file name="public/main/inc/lib/UnserializeApi.php"/>
<!-- <file name="public/main/inc/lib/tracking.lib.php"/>--> <!-- <file name="public/main/inc/lib/tracking.lib.php"/>-->
<file name="public/main/inc/lib/urlmanager.lib.php"/> <file name="public/main/inc/lib/urlmanager.lib.php"/>
<file name="public/main/inc/lib/usergroup.lib.php"/> <file name="public/main/inc/lib/usergroup.lib.php"/>
<!-- <file name="public/main/inc/lib/usermanager.lib.php"/>--> <!-- <file name="public/main/inc/lib/usermanager.lib.php"/>-->
@ -100,11 +129,8 @@
<file name="public/main/admin/index.php"/> <file name="public/main/admin/index.php"/>
<file name="public/main/admin/db.php"/> <file name="public/main/admin/db.php"/>
<file name="public/main/admin/settings.php"/> <file name="public/main/admin/settings.php"/>
<file name="public/main/admin/periodic_export.php"/> <file name="public/main/admin/periodic_export.php"/>
<file name="public/main/admin/user_move_stats.php"/> <file name="public/main/admin/user_move_stats.php"/>
<file name="public/main/admin/settings.lib.php"/> <file name="public/main/admin/settings.lib.php"/>
<file name="public/main/admin/user_update_import.php"/> <file name="public/main/admin/user_update_import.php"/>
<file name="public/main/admin/teachers_time_by_session_report.php"/> <file name="public/main/admin/teachers_time_by_session_report.php"/>
@ -112,7 +138,6 @@
<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="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"/>
</ignoreFiles> </ignoreFiles>

@ -107,7 +107,8 @@ switch ($action) {
break; break;
case 'subscribe_course': case 'subscribe_course':
if (api_is_anonymous()) { 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; exit;
} }
$courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : ''; $courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : '';
@ -408,8 +409,8 @@ switch ($action) {
if ($allowExtraFields) { if ($allowExtraFields) {
$extraFieldValues = new ExtraFieldValue('course'); $extraFieldValues = new ExtraFieldValue('course');
$em = Database::getManager(); $em = Database::getManager();
$fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField'); $fieldsRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraField::class);
$fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); $fieldTagsRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraFieldRelTag::class);
} }
$courseUrl = api_get_path(WEB_COURSE_PATH); $courseUrl = api_get_path(WEB_COURSE_PATH);
@ -613,7 +614,7 @@ switch ($action) {
$registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription'); $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription');
if ('true' === $registrationAllowed) { if ('true' === $registrationAllowed) {
$entityManager = Database::getManager(); $entityManager = Database::getManager();
$repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); $repository = $entityManager->getRepository(SequenceResource::class);
$sequences = $repository->getRequirements( $sequences = $repository->getRequirements(
$sessionId, $sessionId,
SequenceResource::SESSION_TYPE SequenceResource::SESSION_TYPE

@ -431,47 +431,50 @@ $content = null;
$tool_name = get_lang('Registration'); $tool_name = get_lang('Registration');
if (!CustomPages::enabled()) { // Load terms & conditions from the current lang
// Load terms & conditions from the current lang if ('true' === api_get_setting('allow_terms_conditions')) {
if ('true' === api_get_setting('allow_terms_conditions')) { $get = array_keys($_GET);
$get = array_keys($_GET); if (isset($get)) {
if (isset($get)) { if (isset($get[0]) && 'legal' == $get[0]) {
if (isset($get[0]) && 'legal' == $get[0]) { $language = api_get_interface_language();
$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); $language = api_get_language_id($language);
$term_preview = LegalManager::get_last_condition($language); $term_preview = LegalManager::get_last_condition($language);
if (!$term_preview) { }
//look for the default language Display::display_header(get_lang('Terms and Conditions'));
$language = api_get_setting('platformLanguage'); if (!empty($term_preview['content'])) {
$language = api_get_language_id($language); echo $term_preview['content'];
$term_preview = LegalManager::get_last_condition($language);
} $termExtraFields = new ExtraFieldValue('terms_and_condition');
Display::display_header(get_lang('Terms and Conditions')); $values = $termExtraFields->getAllValuesByItem($term_preview['id']);
if (!empty($term_preview['content'])) { foreach ($values as $value) {
echo $term_preview['content']; echo '<h3>'.$value['display_text'].'</h3><br />'.$value['value'].'<br />';
$termExtraFields = new ExtraFieldValue('terms_and_condition');
$values = $termExtraFields->getAllValuesByItem($term_preview['id']);
foreach ($values as $value) {
echo '<h3>'.$value['display_text'].'</h3><br />'.$value['value'].'<br />';
}
} else {
echo get_lang('Coming soon...');
} }
Display::display_footer(); } else {
exit; echo get_lang('Coming soon...');
} }
Display::display_footer();
exit;
} }
} }
}
if ('true' === api_get_setting('allow_terms_conditions') && $user_already_registered_show_terms) { if ('true' === api_get_setting('allow_terms_conditions') && $user_already_registered_show_terms) {
$tool_name = get_lang('Terms and Conditions'); $tool_name = get_lang('Terms and Conditions');
}
} }
// Forbidden to self-register // Forbidden to self-register
if ($isNotAllowedHere) { 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')) { if ('approval' === api_get_setting('allow_registration')) {
@ -655,13 +658,13 @@ if ($form->validate()) {
//an extra field //an extra field
$extras[substr($key, 6)] = $value; $extras[substr($key, 6)] = $value;
} elseif (false !== strpos($key, 'remove_extra_')) { } 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 // To remove from user_field_value and folder
UserManager::update_extra_field_value( UserManager::update_extra_field_value(
$user_id, $user_id,
substr($key, 13), substr($key, 13),
$extra_value $extra_value
); );*/
} }
} }
@ -1061,60 +1064,46 @@ if ($form->validate()) {
Session::erase('session_redirect'); Session::erase('session_redirect');
Session::erase('only_one_course_session_redirect'); Session::erase('only_one_course_session_redirect');
if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION_FEEDBACK)) { $tpl = new Template($tool_name);
CustomPages::display( $tpl->assign('inscription_content', $content);
CustomPages::REGISTRATION_FEEDBACK, $tpl->assign('text_after_registration', $text_after_registration);
['info' => $text_after_registration] $tpl->assign('hide_header', $hideHeaders);
); $inscription = $tpl->get_template('auth/inscription.tpl');
} else { $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 { } else {
// Custom pages if (!api_is_anonymous()) {
if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION)) { // Saving user to course if it was set.
CustomPages::display( if (!empty($course_code_redirect)) {
CustomPages::REGISTRATION, $course_info = api_get_course_info($course_code_redirect);
['form' => $form, 'content' => $content] if (!empty($course_info)) {
); if (in_array(
} else { $course_info['visibility'],
if (!api_is_anonymous()) { [
// Saving user to course if it was set. COURSE_VISIBILITY_OPEN_PLATFORM,
if (!empty($course_code_redirect)) { COURSE_VISIBILITY_OPEN_WORLD,
$course_info = api_get_course_info($course_code_redirect); ]
if (!empty($course_info)) { )
if (in_array( ) {
$course_info['visibility'], CourseManager::subscribeUser(
[ api_get_user_id(),
COURSE_VISIBILITY_OPEN_PLATFORM, $course_info['code']
COURSE_VISIBILITY_OPEN_WORLD, );
]
)
) {
CourseManager::subscribeUser(
$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_header', Display::page_header($tool_name));
$tpl->assign('inscription_content', $content); $tpl->assign('inscription_content', $content);
$tpl->assign('form', $form->returnForm()); $tpl->assign('form', $form->returnForm());
$tpl->assign('hide_header', $hideHeaders); $tpl->assign('hide_header', $hideHeaders);
$page = Container::getPage('inscription'); //$page = Container::getPage('inscription');
$tpl->assign('page', $page); //$tpl->assign('page', $page);
$inscription = $tpl->get_template('auth/inscription.tpl');
$tpl->display($inscription);
$inscription = $tpl->get_template('auth/inscription.tpl');
$tpl->display($inscription);
}
} }

@ -481,7 +481,7 @@ if ($form->validate()) {
} }
// upload production if a new one is provided // 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()); $res = upload_user_production(api_get_user_id());
if (!$res) { if (!$res) {
//it's a bit excessive to assume the extension is the reason why //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 // remove values that shouldn't go in the database
unset( unset(
@ -640,12 +640,12 @@ if ($form->validate()) {
); );
Session::write('_user', $userInfo); Session::write('_user', $userInfo);
if ($hook) { /*if ($hook) {
Database::getManager()->clear(User::class); // Avoid cache issue (user entity is used before) 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 $user = api_get_user_entity(api_get_user_id()); // Get updated user info for hook event
$hook->setEventData(['user' => $user]); $hook->setEventData(['user' => $user]);
$hook->notifyUpdateUser(HOOK_EVENT_TYPE_POST); $hook->notifyUpdateUser(HOOK_EVENT_TYPE_POST);
} }*/
Session::erase('system_timezone'); Session::erase('system_timezone');

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Kigkonsult\Icalcreator\Vcalendar; use Kigkonsult\Icalcreator\Vcalendar;
@ -44,13 +45,14 @@ if (isset($_GET['course_id'])) {
} }
$event = $agenda->get_event($id); $event = $agenda->get_event($id);
$charset = api_get_system_encoding();
if (!empty($event)) { if (!empty($event)) {
define('ICAL_LANG', api_get_language_isocode()); define('ICAL_LANG', api_get_language_isocode());
$ical = new Vcalendar(); $ical = new Vcalendar();
$ical->setConfig('unique_id', api_get_path(WEB_PATH)); $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)); $ical->setConfig('url', api_get_path(WEB_PATH));
$vevent = new Vevent(); $vevent = new Vevent();
@ -75,15 +77,13 @@ if (!empty($event)) {
switch ($type) { switch ($type) {
case 'personal': case 'personal':
case 'platform': 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'])) { if (empty($event['start_date'])) {
header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER'])); header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));
exit;
} }
list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']); list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']);
$vevent->setProperty( $vevent->setDtstart(new DateTime($event['start_date']));
'dtstart',
['year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s]
);
if (empty($event['end_date'])) { if (empty($event['end_date'])) {
$y2 = $y; $y2 = $y;
$m2 = $m; $m2 = $m;
@ -98,12 +98,10 @@ if (!empty($event)) {
} else { } else {
list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']); list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']);
} }
$vevent->setProperty(
'dtend', $vevent->setDtend(new DateTime("$y2-$m2-$d2 $h2:$M2:$s2"));
['year' => $y2, 'month' => $m2, 'day' => $d2, 'hour' => $h2, 'min' => $M2, 'sec' => $s2]
);
//$vevent->setProperty( 'LOCATION', get_lang('Unknown') ); // property name - case independent //$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' ); //$vevent->setProperty( 'comment', 'This is a comment' );
//$user = api_get_user_info($event['user']); //$user = api_get_user_info($event['user']);
//$vevent->setProperty('organizer',$user['mail']); //$vevent->setProperty('organizer',$user['mail']);
@ -114,13 +112,12 @@ if (!empty($event)) {
$ical->returnCalendar(); $ical->returnCalendar();
break; break;
case 'course': 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'])) { if (empty($event['start_date'])) {
header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER'])); header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));
} }
list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']); list($y, $m, $d, $h, $M, $s) = preg_split('/[\s:-]/', $event['start_date']);
$vevent->setProperty( $vevent->setDtstart(
'dtstart',
['year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s] ['year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s]
); );
if (empty($event['end_date'])) { if (empty($event['end_date'])) {
@ -137,17 +134,15 @@ if (!empty($event)) {
} else { } else {
list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']); list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\s:-]/', $event['end_date']);
} }
$vevent->setProperty(
'dtend', $vevent->setDtend(new DateTime("$y2-$m2-$d2 $h2:$M2:$s2"));
['year' => $y2, 'month' => $m2, 'day' => $d2, 'hour' => $h2, 'min' => $M2, 'sec' => $s2] $vevent->setDescription(api_convert_encoding($event['description'], 'UTF-8', $charset));
);
$vevent->setProperty('description', api_convert_encoding($event['description'], 'UTF-8', $charset));
//$vevent->setProperty( 'comment', 'This is a comment' ); //$vevent->setProperty( 'comment', 'This is a comment' );
//$user = api_get_user_info($event['user']); //$user = api_get_user_info($event['user']);
//$vevent->setProperty('organizer',$user['mail']); //$vevent->setProperty('organizer',$user['mail']);
//$vevent->setProperty('attendee',$user['mail']); //$vevent->setProperty('attendee',$user['mail']);
//$course = api_get_course_info(); //$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']) { /*if($ai['repeat']) {
$trans = array('daily'=>'DAILY','weekly'=>'WEEKLY','monthlyByDate'=>'MONTHLY','yearly'=>'YEARLY'); $trans = array('daily'=>'DAILY','weekly'=>'WEEKLY','monthlyByDate'=>'MONTHLY','yearly'=>'YEARLY');
$freq = $trans[$ai['repeat_type']]; $freq = $trans[$ai['repeat_type']];

@ -1017,7 +1017,7 @@ class CoursesAndSessionsCatalog
*/ */
public static function returnThumbnail($course) 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')) { if (file_exists($course_path.'/course-pic.png')) {
// redimensioned image 85x85 // redimensioned image 85x85
@ -1034,7 +1034,7 @@ class CoursesAndSessionsCatalog
); );
} }
return $courseMediumImage; return $courseMediumImage;*/
} }
/** /**

@ -173,7 +173,7 @@ class MailTemplateManager extends Model
} }
$type = $template['type']; $type = $template['type'];
$urlId = api_get_current_access_url_id(); $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"; WHERE type = '$type' AND url_id = $urlId";
Database::query($sql); Database::query($sql);
@ -209,4 +209,29 @@ class MailTemplateManager extends Model
return false; 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'];
}
} }

@ -8393,12 +8393,13 @@ function api_is_student_view_active()
* @param int $itemId * @param int $itemId
* @param string $cropParameters * @param string $cropParameters
* *
* @deprecated use Resources
* *
* @return array|bool * @return array|bool
*/ */
function api_upload_file($type, $file, $itemId, $cropParameters = '') function api_upload_file($type, $file, $itemId, $cropParameters = '')
{ {
throw new Exception('api_upload_file not implemented');
$upload = process_uploaded_file($file); $upload = process_uploaded_file($file);
if ($upload) { if ($upload) {
$name = api_replace_dangerous_char($file['name']); $name = api_replace_dangerous_char($file['name']);

@ -472,6 +472,7 @@ class ExerciseLib
$hidingClass = ''; $hidingClass = '';
if (READING_COMPREHENSION == $answerType) { if (READING_COMPREHENSION == $answerType) {
/** @var ReadingComprehension */
$objQuestionTmp->setExerciseType($exercise->selectType()); $objQuestionTmp->setExerciseType($exercise->selectType());
$objQuestionTmp->processText($objQuestionTmp->selectDescription()); $objQuestionTmp->processText($objQuestionTmp->selectDescription());
$hidingClass = 'hide-reading-answers'; $hidingClass = 'hide-reading-answers';
@ -4542,7 +4543,7 @@ EOT;
} else { } else {
$pluginEvaluation = QuestionOptionsEvaluationPlugin::create(); $pluginEvaluation = QuestionOptionsEvaluationPlugin::create();
if ('true' === $pluginEvaluation->get(QuestionOptionsEvaluationPlugin::SETTING_ENABLE)) { if ('true' === $pluginEvaluation->get(QuestionOptionsEvaluationPlugin::SETTING_ENABLE)) {
$formula = $pluginEvaluation->getFormulaForExercise($objExercise->selectId()); $formula = $pluginEvaluation->getFormulaForExercise($objExercise->getId());
if (!empty($formula)) { if (!empty($formula)) {
$total_score = $pluginEvaluation->getResultWithFormula($exeId, $formula); $total_score = $pluginEvaluation->getResultWithFormula($exeId, $formula);
@ -4625,7 +4626,7 @@ EOT;
if (api_is_allowed_to_session_edit()) { if (api_is_allowed_to_session_edit()) {
Event::updateEventExercise( Event::updateEventExercise(
$exercise_stat_info['exe_id'], $exercise_stat_info['exe_id'],
$objExercise->selectId(), $objExercise->getId(),
$total_score, $total_score,
$total_weight, $total_weight,
$sessionId, $sessionId,
@ -4639,7 +4640,7 @@ EOT;
$allowStats = api_get_configuration_value('allow_gradebook_stats'); $allowStats = api_get_configuration_value('allow_gradebook_stats');
if ($allowStats) { if ($allowStats) {
$objExercise->generateStats( $objExercise->generateStats(
$objExercise->selectId(), $objExercise->getId(),
api_get_course_info(), api_get_course_info(),
$sessionId $sessionId
); );
@ -5235,7 +5236,7 @@ EOT;
$link = LinkFactory::load( $link = LinkFactory::load(
null, null,
null, null,
$objExercise->selectId(), $objExercise->getId(),
null, null,
$courseCode, $courseCode,
$categoryId $categoryId
@ -5280,7 +5281,7 @@ EOT;
$em = Database::getManager(); $em = Database::getManager();
/** @var TrackEExercises $trackedExercise */ /** @var TrackEExercises $trackedExercise */
$trackedExercise = $em->getRepository('ChamiloCoreBundle:TrackEExercises')->find($exeId); $trackedExercise = $em->getRepository(TrackEExercises::class)->find($exeId);
if (empty($trackedExercise)) { if (empty($trackedExercise)) {
return null; return null;
@ -5351,8 +5352,8 @@ EOT;
} }
$trackedExercise $trackedExercise
->setExeResult($totalScore) ->setScore($totalScore)
->setExeWeighting($totalWeight); ->setMaxScore($totalWeight);
$em->persist($trackedExercise); $em->persist($trackedExercise);
$em->flush(); $em->flush();

@ -552,7 +552,7 @@ class ExtraField extends Model
public function get_count() public function get_count()
{ {
$em = Database::getManager(); $em = Database::getManager();
$query = $em->getRepository('ChamiloCoreBundle:ExtraField')->createQueryBuilder('e'); $query = $em->getRepository(EntityExtraField::class)->createQueryBuilder('e');
$query->select('count(e.id)'); $query->select('count(e.id)');
$query->where('e.extraFieldType = :type'); $query->where('e.extraFieldType = :type');
$query->setParameter('type', $this->getExtraFieldType()); $query->setParameter('type', $this->getExtraFieldType());
@ -602,7 +602,7 @@ class ExtraField extends Model
break; break;
} }
$em = Database::getManager(); $em = Database::getManager();
$query = $em->getRepository('ChamiloCoreBundle:ExtraField')->createQueryBuilder('e'); $query = $em->getRepository(EntityExtraField::class)->createQueryBuilder('e');
$query->select('e') $query->select('e')
->where('e.extraFieldType = :type') ->where('e.extraFieldType = :type')
->setParameter('type', $this->getExtraFieldType()) ->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 * Get an array of all the values from the extra_field and extra_field_options tables
* based on the current object's type. * based on the current object's type.
* *
* @param array $conditions * @param array $options
* @param null $order_field_options_by * @param null $order_field_options_by
* *
* @return array * @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)) { if (empty($options)) {
$conditions .= ' WHERE extra_field_type = '.$this->extraFieldType; $options .= ' WHERE extra_field_type = '.$this->extraFieldType;
} else { } else {
$conditions .= ' AND extra_field_type = '.$this->extraFieldType; $options .= ' AND extra_field_type = '.$this->extraFieldType;
} }
$sql = "SELECT * FROM $this->table $sql = "SELECT * FROM $this->table
$conditions $options
ORDER BY field_order ASC ORDER BY field_order ASC
"; ";
@ -1246,7 +1246,7 @@ class ExtraField extends Model
if ($separateValue > 0) { if ($separateValue > 0) {
$em = Database::getManager(); $em = Database::getManager();
$fieldTags = $em $fieldTags = $em
->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') ->getRepository(ExtraFieldRelTag::class)
->findBy( ->findBy(
[ [
'fieldId' => $field_id, 'fieldId' => $field_id,
@ -1256,8 +1256,7 @@ class ExtraField extends Model
// ofaj // ofaj
for ($i = 0; $i < $separateValue; $i++) { for ($i = 0; $i < $separateValue; $i++) {
$tagsSelect = $form->addElement( $tagsSelect = $form->addSelect(
'select',
'extra_'.$field_details['variable'].'['.$i.']', 'extra_'.$field_details['variable'].'['.$i.']',
$customLabelsExtraMultipleSelect[$field_details['variable']][$i], //$field_details['display_text'], $customLabelsExtraMultipleSelect[$field_details['variable']][$i], //$field_details['display_text'],
null, null,
@ -1272,7 +1271,7 @@ class ExtraField extends Model
} }
foreach ($fieldTags as $fieldTag) { foreach ($fieldTags as $fieldTag) {
$tag = $em->find('ChamiloCoreBundle:Tag', $fieldTag->getTagId()); $tag = $em->find(Tag::class, $fieldTag->getTagId());
if (empty($tag)) { if (empty($tag)) {
continue; continue;
@ -1330,7 +1329,7 @@ class ExtraField extends Model
} else { } else {
$em = Database::getManager(); $em = Database::getManager();
$fieldTags = $em->getRepository( $fieldTags = $em->getRepository(
'ChamiloCoreBundle:ExtraFieldRelTag' ExtraFieldRelTag::class
) )
->findBy( ->findBy(
[ [
@ -1342,7 +1341,7 @@ class ExtraField extends Model
/** @var ExtraFieldRelTag $fieldTag */ /** @var ExtraFieldRelTag $fieldTag */
foreach ($fieldTags as $fieldTag) { foreach ($fieldTags as $fieldTag) {
/** @var Tag $tag */ /** @var Tag $tag */
$tag = $em->find('ChamiloCoreBundle:Tag', $fieldTag->getTagId()); $tag = $em->find(Tag::class, $fieldTag->getTagId());
if (empty($tag)) { if (empty($tag)) {
continue; continue;
@ -1367,7 +1366,7 @@ class ExtraField extends Model
} }
if ($useTagAsSelect) { if ($useTagAsSelect) {
$fieldTags = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') $fieldTags = $em->getRepository(ExtraFieldRelTag::class)
->findBy( ->findBy(
[ [
'fieldId' => $field_id, 'fieldId' => $field_id,
@ -1375,7 +1374,7 @@ class ExtraField extends Model
); );
$tagsAdded = []; $tagsAdded = [];
foreach ($fieldTags as $fieldTag) { foreach ($fieldTags as $fieldTag) {
$tag = $em->find('ChamiloCoreBundle:Tag', $fieldTag->getTagId()); $tag = $em->find(Tag::class, $fieldTag->getTagId());
if (empty($tag)) { if (empty($tag)) {
continue; continue;
@ -1464,7 +1463,7 @@ class ExtraField extends Model
'extra_'.$field_details['variable'], 'extra_'.$field_details['variable'],
$field_details['display_text'], $field_details['display_text'],
[ [
'size' => 60, //'size' => 60,
'size' => implode( 'size' => implode(
'; ', '; ',
[ [
@ -2007,7 +2006,7 @@ class ExtraField extends Model
public function delete($id) public function delete($id)
{ {
$em = Database::getManager(); $em = Database::getManager();
$items = $em->getRepository('ChamiloCoreBundle:ExtraFieldSavedSearch')->findBy(['field' => $id]); $items = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch::class)->findBy(['field' => $id]);
if ($items) { if ($items) {
foreach ($items as $item) { foreach ($items as $item) {
$em->remove($item); $em->remove($item);
@ -2894,7 +2893,7 @@ JAVASCRIPT;
$fields = $this->get_all(); $fields = $this->get_all();
$em = Database::getManager(); $em = Database::getManager();
$repoTag = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); $repoTag = $em->getRepository(ExtraFieldRelTag::class);
foreach ($fields as $field) { foreach ($fields as $field) {
if ('1' != $field['visible_to_self']) { if ('1' != $field['visible_to_self']) {
@ -2923,7 +2922,7 @@ JAVASCRIPT;
$data = []; $data = [];
foreach ($tags as $extraFieldTag) { foreach ($tags as $extraFieldTag) {
/** @var \Chamilo\CoreBundle\Entity\Tag $tag */ /** @var \Chamilo\CoreBundle\Entity\Tag $tag */
$tag = $em->find('ChamiloCoreBundle:Tag', $extraFieldTag->getTagId()); $tag = $em->find(Tag::class, $extraFieldTag->getTagId());
$data[] = $tag->getTag(); $data[] = $tag->getTag();
} }
$valueData = implode(',', $data); $valueData = implode(',', $data);
@ -3481,7 +3480,7 @@ JAVASCRIPT;
$level3 = $this->getOptionsFromTripleSelect($options['level3'], $secondId); $level3 = $this->getOptionsFromTripleSelect($options['level3'], $secondId);
/** @var \HTML_QuickForm_select $slctFirst */ /** @var \HTML_QuickForm_select $slctFirst */
$slctFirst = $form->createElement('select', "extra_$variable", null, $values1, ['id' => $slctFirstId]); $slctFirst = $form->createElement('select', "extra_$variable", null, $values1, ['id' => $slctFirstId]);
/** @var \HTML_QuickForm_select $slctFirst */ /** @var \HTML_QuickForm_select $slctSecond */
$slctSecond = $form->createElement( $slctSecond = $form->createElement(
'select', 'select',
"extra_{$variable}_second", "extra_{$variable}_second",
@ -3489,7 +3488,7 @@ JAVASCRIPT;
$values2, $values2,
['id' => $slctSecondId] ['id' => $slctSecondId]
); );
/** @var \HTML_QuickForm_select $slctFirst */ /** @var \HTML_QuickForm_select $slctThird */
$slctThird = $form->createElement('select', "extra_{$variable}_third", null, $values3, ['id' => $slctThirdId]); $slctThird = $form->createElement('select', "extra_{$variable}_third", null, $values3, ['id' => $slctThirdId]);
foreach ($level1 as $item1) { foreach ($level1 as $item1) {

@ -66,7 +66,7 @@ class ExtraFieldOption extends Model
$fieldId = (int) $fieldId; $fieldId = (int) $fieldId;
$sql = "SELECT count(*) as count $sql = "SELECT count(*) as count
FROM $this->table o FROM $this->table o
INNER JOIN $this->tableExtraField e INNER JOIN $this->tableExtraField e
ON o.field_id = e.id ON o.field_id = e.id
WHERE WHERE
@ -535,7 +535,7 @@ class ExtraFieldOption extends Model
} }
$result = Database::getManager() $result = Database::getManager()
->getRepository('ChamiloCoreBundle:ExtraFieldOptions') ->getRepository(ExtraFieldOptions::class)
->findBy(['field' => $field_id], $orderBy); ->findBy(['field' => $field_id], $orderBy);
if (!$result) { 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) public function get_second_select_field_options_by_field($option_value_id, $to_json = false)
{ {
$em = Database::getManager(); $em = Database::getManager();
$option = $em->find('ChamiloCoreBundle:ExtraFieldOptions', $option_value_id); $option = $em->find(ExtraFieldOptions::class, $option_value_id);
if (!$option) { if (!$option) {
return !$to_json ? [] : '{}'; return !$to_json ? [] : '{}';
} }
$subOptions = $em $subOptions = $em->getRepository(ExtraFieldOptions::class)->findSecondaryOptions($option);
->getRepository('ChamiloCoreBundle:ExtraFieldOptions')
->findSecondaryOptions($option);
$optionsInfo = []; $optionsInfo = [];
/** @var ExtraFieldOptions $subOption */ /** @var ExtraFieldOptions $subOption */

@ -64,7 +64,7 @@ class ExtraFieldValue extends Model
public function get_count() public function get_count()
{ {
$em = Database::getManager(); $em = Database::getManager();
$query = $em->getRepository('ChamiloCoreBundle:ExtraFieldValues')->createQueryBuilder('e'); $query = $em->getRepository(ExtraFieldValues::class)->createQueryBuilder('e');
$query->select('count(e.id)'); $query->select('count(e.id)');
$query->where('e.extraFieldType = :type'); $query->where('e.extraFieldType = :type');
$query->setParameter('type', $this->getExtraField()->getExtraFieldType()); $query->setParameter('type', $this->getExtraField()->getExtraFieldType());
@ -198,7 +198,7 @@ class ExtraFieldValue extends Model
$em = Database::getManager(); $em = Database::getManager();
$currentTags = $em $currentTags = $em
->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') ->getRepository(ExtraFieldRelTag::class)
->findBy([ ->findBy([
'fieldId' => $extraFieldInfo['id'], 'fieldId' => $extraFieldInfo['id'],
'itemId' => $params['item_id'], 'itemId' => $params['item_id'],
@ -216,7 +216,7 @@ class ExtraFieldValue extends Model
continue; continue;
} }
$tagsResult = $em->getRepository('ChamiloCoreBundle:Tag') $tagsResult = $em->getRepository(Tag::class)
->findBy([ ->findBy([
'tag' => $tagValue, 'tag' => $tagValue,
'fieldId' => $extraFieldInfo['id'], 'fieldId' => $extraFieldInfo['id'],
@ -235,7 +235,7 @@ class ExtraFieldValue extends Model
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tagUses = $em $tagUses = $em
->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') ->getRepository(ExtraFieldRelTag::class)
->findBy([ ->findBy([
'tagId' => $tag->getId(), 'tagId' => $tag->getId(),
]); ]);
@ -908,7 +908,7 @@ class ExtraFieldValue extends Model
} else { } else {
if (ExtraField::FIELD_TYPE_TAG == $field['field_type']) { if (ExtraField::FIELD_TYPE_TAG == $field['field_type']) {
$tagResult = []; $tagResult = [];
$tags = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag') $tags = $em->getRepository(ExtraFieldRelTag::class)
->findBy( ->findBy(
[ [
'fieldId' => $field['id'], 'fieldId' => $field['id'],
@ -919,7 +919,7 @@ class ExtraFieldValue extends Model
/** @var ExtraFieldRelTag $extraFieldTag */ /** @var ExtraFieldRelTag $extraFieldTag */
foreach ($tags as $extraFieldTag) { foreach ($tags as $extraFieldTag) {
/** @var \Chamilo\CoreBundle\Entity\Tag $tag */ /** @var \Chamilo\CoreBundle\Entity\Tag $tag */
$tag = $em->find('ChamiloCoreBundle:Tag', $extraFieldTag->getTagId()); $tag = $em->find(Tag::class, $extraFieldTag->getTagId());
$tagResult[] = [ $tagResult[] = [
'id' => $extraFieldTag->getTagId(), 'id' => $extraFieldTag->getTagId(),
'value' => $tag->getTag(), 'value' => $tag->getTag(),
@ -1085,7 +1085,7 @@ class ExtraFieldValue extends Model
->getQuery() ->getQuery()
->getResult(); ->getResult();
$fieldOptionsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldOptions'); $fieldOptionsRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\ExtraFieldOptions::class);
$valueList = []; $valueList = [];
/** @var ExtraFieldValues $fieldValue */ /** @var ExtraFieldValues $fieldValue */

@ -1,7 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Ddeboer\DataImport\Reader\ExcelReader;
use League\Csv\Reader; use League\Csv\Reader;
/** /**
@ -78,9 +77,10 @@ class Import
return []; return [];
} }
$file = new \SplFileObject($filename); $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$reader = new ExcelReader($file, 0); $spreadsheet = $reader->load($filename);
$sheet = $spreadsheet->getActiveSheet();
return $reader; return $sheet->toArray();
} }
} }

@ -3,6 +3,7 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Message; use Chamilo\CoreBundle\Entity\Message;
use Chamilo\CoreBundle\Entity\MessageFeedback;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use ChamiloSession as Session; use ChamiloSession as Session;
@ -350,7 +351,7 @@ class MessageManager
'; ';
$result = Database::query($sql); $result = Database::query($sql);
$messages = []; $messages = [];
$repo = Database::getManager()->getRepository('ChamiloCoreBundle:Message'); $repo = Database::getManager()->getRepository(Message::class);
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$message = $repo->find($row['id']); $message = $repo->find($row['id']);
$messages[] = $message; $messages[] = $message;
@ -387,7 +388,7 @@ class MessageManager
false, false,
false false
); );
$senderId = $message->getUserSenderId(); $senderId = $message->getUserSender()->getId();
$senderInfo = api_get_user_info($senderId); $senderInfo = api_get_user_info($senderId);
$html .= Display::panelCollapse( $html .= Display::panelCollapse(
$localTime.' '.$senderInfo['complete_name'].' '.$message->getTitle(), $localTime.' '.$senderInfo['complete_name'].' '.$message->getTitle(),
@ -1343,10 +1344,6 @@ class MessageManager
$table = Database::get_main_table(TABLE_MESSAGE); $table = Database::get_main_table(TABLE_MESSAGE);
if (empty($type)) {
return '';
}
switch ($type) { switch ($type) {
case self::MESSAGE_TYPE_OUTBOX: case self::MESSAGE_TYPE_OUTBOX:
$status = MESSAGE_STATUS_OUTBOX; $status = MESSAGE_STATUS_OUTBOX;
@ -3047,7 +3044,7 @@ class MessageManager
} }
$userLike = $em $userLike = $em
->getRepository('ChamiloCoreBundle:MessageFeedback') ->getRepository(MessageFeedback::class)
->findOneBy(['message' => $messageId, 'user' => $userId]); ->findOneBy(['message' => $messageId, 'user' => $userId]);
return [ return [

@ -264,8 +264,10 @@ if (!empty($courseList)) {
$start_date = $exerciseInfo['start_time']; $start_date = $exerciseInfo['start_time'];
} }
$exerciseId = $exerciseInfo['id'];
$best_score_data = ExerciseLib::get_best_attempt_in_course( $best_score_data = ExerciseLib::get_best_attempt_in_course(
$exerciseInfo['id'], $exerciseId,
$courseInfo['real_id'], $courseInfo['real_id'],
$session_id $session_id
); );

@ -8,6 +8,8 @@ require_once __DIR__.'/../inc/global.inc.php';
// setting the section (for the tabs) // setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(true); api_protect_admin_script(true);
$_user = api_get_user_info();
$id = (int) $_GET['id']; $id = (int) $_GET['id'];
$formSent = 0; $formSent = 0;
$errorMsg = ''; $errorMsg = '';

@ -1536,11 +1536,11 @@ class User implements UserInterface, EquatableInterface
return $this->passwordRequestedAt; return $this->passwordRequestedAt;
} }
/*public function isPasswordRequestNonExpired($ttl) public function isPasswordRequestNonExpired($ttl)
{ {
return $this->getPasswordRequestedAt() instanceof \DateTime && return $this->getPasswordRequestedAt() instanceof \DateTime &&
$this->getPasswordRequestedAt()->getTimestamp() + $ttl > time(); $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time();
}*/ }
public function getUsername(): string public function getUsername(): string
{ {
@ -1791,6 +1791,13 @@ class User implements UserInterface, EquatableInterface
return $this; return $this;
} }
public function setPasswordRequestedAt(\DateTime $date = null)
{
$this->passwordRequestedAt = $date;
return $this;
}
public function setRoles(array $roles): self public function setRoles(array $roles): self
{ {
$this->roles = []; $this->roles = [];

Loading…
Cancel
Save