Minor - Add psalm checks, fix code from 1.11.x

pull/3432/head
Julio Montoya 4 years ago
parent 4bbff2572e
commit 158b7e9ef1
  1. 17
      psalm.xml
  2. 8
      public/main/forum/forumfunction.inc.php
  3. 48
      public/main/inc/ajax/admin.ajax.php
  4. 9
      public/main/inc/ajax/announcement.ajax.php
  5. 2
      public/main/inc/ajax/exercise.ajax.php
  6. 12
      public/main/inc/ajax/extra_field.ajax.php
  7. 5
      public/main/inc/ajax/forum.ajax.php
  8. 5
      public/main/inc/ajax/install.ajax.php
  9. 4
      public/main/inc/ajax/sequence.ajax.php
  10. 2
      public/main/inc/ajax/session.ajax.php
  11. 13
      public/main/inc/ajax/skill.ajax.php
  12. 4
      public/main/inc/ajax/social.ajax.php
  13. 21
      public/main/inc/ajax/statistics.ajax.php
  14. 6
      public/main/inc/lib/course_description.lib.php
  15. 117
      public/main/inc/lib/webservices/Rest.php
  16. 1
      public/main/lp/lp_edit.php
  17. 13
      src/CoreBundle/Controller/CourseHomeController.php
  18. 23
      src/CoreBundle/Entity/ExtraFieldSavedSearch.php

@ -40,6 +40,8 @@
<!-- <directory name="public/main/gamification"/>-->
<directory name="public/main/glossary"/>
<directory name="public/main/group"/>
<!-- <directory name="public/main/inc/ajax" />-->
<directory name="public/main/link" />
<!-- <directory name="public/main/lp"/>-->
<directory name="public/main/messages" />
@ -48,7 +50,6 @@
<directory name="public/main/session" />
<directory name="public/main/social" />
<!-- <directory name="public/main/survey" />-->
<!-- <directory name="public/main/inc/ajax" />-->
<!-- <directory name="public/main/ticket" />-->
<!-- <directory name="public/main/tracking" />-->
<!-- <directory name="public/main/upload" />-->
@ -157,6 +158,20 @@
<directory name="src/GraphQlBundle"/>
<directory name="src/LtiBundle"/>
<directory name="public/main/inc/lib/elfinder" />
<directory name="public/main/inc/lib/javascript" />
<directory name="public/main/inc/lib/kses-0.2.2" />
<directory name="public/main/inc/lib/mimetex" />
<directory name="public/main/inc/lib/nusoap" />
<directory name="public/main/inc/lib/opengraph" />
<directory name="public/main/inc/lib/pear" />
<directory name="public/main/inc/lib/ppt2png" />
<directory name="public/main/inc/lib/search" />
<directory name="public/main/inc/lib/svg-edit" />
<directory name="public/main/inc/lib/zombie" />
<file name="public/main/lp/openoffice_presentation.class.php"/>
<file name="public/main/lp/openoffice_document.class.php"/>
<file name="public/main/lp/openoffice_text.class.php"/>

@ -6118,13 +6118,7 @@ function getForumCategoryByTitle($title, $courseId, $sessionId = 0)
return $resultData;*/
}
/**
* @param array $row
* @param bool $addWrapper
*
* @return string
*/
function getPostStatus(CForumForum $forum, $row, $addWrapper = true)
function getPostStatus(CForumForum $forum, array $row, bool $addWrapper = true): string
{
$statusIcon = '';
if ($forum->isModerated()) {

@ -1,15 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\BranchSync;
use Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository;
use Chamilo\CoreBundle\Repository\BranchSyncRepository;
use Chamilo\CoreBundle\Framework\Container;
use GuzzleHttp\Client;
use League\Flysystem\Filesystem;
/**
* Responses to AJAX calls.
*/
require_once __DIR__.'/../global.inc.php';
api_protect_admin_script();
@ -106,9 +104,19 @@ function version_check()
$return = '';
if ('false' == $row['selected_value']) {
$return .= get_lang('In order to enable the automatic version checking you have to register your portal on chamilo.org. The information obtained by clicking this button is only for internal use and only aggregated data will be publicly available (total number of portals, total number of chamilo course, total number of chamilo users, ...) (see <a href="http://www.chamilo.org/stats/">http://www.chamilo.org/stats/</a>. When registering you will also appear on the worldwide list (<a href="http://www.chamilo.org/community.php">http://www.chamilo.org/community.php</a>. If you do not want to appear in this list you have to check the checkbox below. The registration is as easy as it can be: you only have to click this button: <br />');
$return .= '<form class="version-checking" action="'.api_get_path(WEB_CODE_PATH).'admin/index.php" id="VersionCheck" name="VersionCheck" method="post">';
$return .= '<label class="checkbox"><input type="checkbox" name="donotlistcampus" value="1" id="checkbox" />'.get_lang('Hide campus from public platforms list');
$return .= '</label><button type="submit" class="btn btn-primary btn-block" name="Register" value="'.get_lang('Enable version check').'" id="register" >'.get_lang('Enable version check').'</button>';
$return .= '<form
class="version-checking"
action="'.api_get_path(WEB_CODE_PATH).'admin/index.php"
id="VersionCheck" name="VersionCheck" method="post">';
$return .= '<label class="checkbox">
<input type="checkbox" name="donotlistcampus" value="1" id="checkbox" />'.
get_lang('Hide campus from public platforms list');
$return .= '</label>
<button type="submit"
class="btn btn-primary btn-block"
name="Register"
value="'.get_lang('Enable version check').'"
id="register" >'.get_lang('Enable version check').'</button>';
$return .= '</form>';
check_system_version();
} else {
@ -132,7 +140,8 @@ function check_system_version()
{
// Check if curl is available.
if (!in_array('curl', get_loaded_extensions())) {
return '<span style="color:red">'.get_lang('Impossible to contact the version server right now. Please try again later.').'</span>';
return '<span style="color:red">'.
get_lang('Impossible to contact the version server right now. Please try again later.').'</span>';
}
$url = 'https://version.chamilo.org';
@ -177,10 +186,10 @@ function check_system_version()
$uniqueId = '';
$entityManager = Database::getManager();
/** @var BranchSyncRepository $branch */
$repository = $entityManager->getRepository('ChamiloCoreBundle:BranchSync');
$repository = $entityManager->getRepository(BranchSync::class);
/** @var BranchSync $branch */
$branch = $repository->getTopBranch();
if (is_a($branch, '\Chamilo\CoreBundle\Entity\BranchSync')) {
if (is_a($branch, BranchSync::class)) {
$uniqueId = $branch->getUniqueId();
}
@ -223,17 +232,26 @@ function check_system_version()
}
if (version_compare($system_version, $version, '<')) {
$output = '<span style="color:red">'.get_lang('Your version is not up-to-date').'<br />
'.get_lang('The latest version is').' <b>Chamilo '.$version.'</b>. <br />
'.get_lang('Your version is').' <b>Chamilo '.$system_version.'</b>. <br />'.str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('Please visit our website: http://www.chamilo.org')).'</span>';
$output = '<span style="color:red">'.
get_lang('Your version is not up-to-date').'<br />'.
get_lang('The latest version is').' <b>Chamilo '.$version.'</b>. <br />'.
get_lang('Your version is').' <b>Chamilo '.$system_version.'</b>. <br />'.
str_replace(
'http://www.chamilo.org',
'<a href="http://www.chamilo.org">http://www.chamilo.org</a>',
get_lang('Please visit our website: http://www.chamilo.org')
).
'</span>';
} else {
$output = '<span style="color:green">'.get_lang('Your version is up-to-date').': Chamilo '.$version.'</span>';
$output = '<span style="color:green">'.
get_lang('Your version is up-to-date').': Chamilo '.$version.'</span>';
}
return $output;
}
return '<span style="color:red">'.get_lang('Impossible to contact the version server right now. Please try again later.').'</span>';
return '<span style="color:red">'.
get_lang('Impossible to contact the version server right now. Please try again later.').'</span>';
}
/**

@ -11,15 +11,14 @@ $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$isAllowedToEdit = api_is_allowed_to_edit();
$courseInfo = api_get_course_info();
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
$groupId = api_get_group_id();
$sessionId = api_get_session_id();
$isTutor = false;
if (!empty($groupId)) {
$groupInfo = GroupManager::get_group_properties($groupId);
$groupRepo = \Chamilo\CoreBundle\Framework\Container::getGroupRepository();
/** @var \Chamilo\CourseBundle\Entity\CGroup $groupEntity */
$groupEntity = $groupRepo->find($groupId);
$groupEntity = api_get_group_entity($groupId);
$isTutor = GroupManager::isTutorOfGroup(api_get_user_id(), $groupEntity);
if ($isTutor) {
$isAllowedToEdit = true;
@ -39,9 +38,7 @@ switch ($action) {
}
if (false === $allowToEdit && !empty($groupId)) {
$groupRepo = \Chamilo\CoreBundle\Framework\Container::getGroupRepository();
/** @var \Chamilo\CourseBundle\Entity\CGroup $groupEntity */
$groupEntity = $groupRepo->find($groupId);
$groupEntity = api_get_group_entity($groupId);
// Check if user is tutor group
$isTutor = GroupManager::isTutorOfGroup(api_get_user_id(), $groupEntity);
if ($isTutor) {

@ -938,7 +938,7 @@ switch ($action) {
$confirmed = !empty($_POST['quiz_confirm_saved_answers_check']);
$em = Database::getManager();
$repo = $em->getRepository('ChamiloCoreBundle:TrackEExerciseConfirmation');
$repo = $em->getRepository(TrackEExerciseConfirmation::class);
try {
if (!$trackConfirmationId) {

@ -1,7 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Tag;
use Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch;
require_once __DIR__.'/../global.inc.php';
@ -46,7 +48,7 @@ switch ($action) {
$extraFieldOption = new ExtraFieldOption($type);
$tags = Database::getManager()
->getRepository('ChamiloCoreBundle:Tag')
->getRepository(Tag::class)
->createQueryBuilder('t')
->where("t.tag LIKE :tag")
->andWhere('t.fieldId = :field')
@ -117,10 +119,10 @@ switch ($action) {
'field' => $extraFieldInfo['id'],
];
$extraFieldSavedSearch = $em->getRepository('ChamiloCoreBundle:ExtraFieldSavedSearch')->findOneBy($search);
$extraFieldSavedSearch = $em->getRepository(ExtraFieldSavedSearch::class)->findOneBy($search);
if ($save) {
$extraField = new \Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch('session');
$extraField = new ExtraFieldSavedSearch('session');
if ($extraFieldSavedSearch) {
$extraFieldSavedSearch->setValue($values);
$em->persist($extraFieldSavedSearch);
@ -129,8 +131,8 @@ switch ($action) {
}
if ($extraFieldInfo) {
/** @var \Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch $options */
$extraFieldSavedSearch = $em->getRepository('ChamiloCoreBundle:ExtraFieldSavedSearch')->findOneBy($search);
/** @var ExtraFieldSavedSearch $extraFieldSavedSearch */
$extraFieldSavedSearch = $em->getRepository(ExtraFieldSavedSearch::class)->findOneBy($search);
$values = $extraFieldSavedSearch->getValue();
$url = api_get_self().'?a=order&save=1&field_variable='.$variable;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CForumPost;
@ -162,9 +163,9 @@ if (!empty($action)) {
$postId = str_replace('status_post_', '', $postId);
$em = Database::getManager();
/** @var CForumPost $post */
$post = $em->find('ChamiloCourseBundle:CForumPost', $postId);
$post = $em->find(CForumPost::class, $postId);
if ($post) {
$forum = get_forums($post->getForumId(), api_get_course_id());
$forum = $post->getForum();
$status = $post->getStatus();
if (empty($status)) {
$status = CForumPost::STATUS_WAITING_MODERATION;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use GuzzleHttp\Client;
@ -6,7 +7,7 @@ use GuzzleHttp\Client;
/**
* Responses to AJAX calls for install.
*/
require_once __DIR__.'/../../../vendor/autoload.php';
require_once __DIR__.'/../../../../vendor/autoload.php';
$action = $_GET['a'];
@ -49,7 +50,7 @@ switch ($action) {
$urlValidated = false;
try {
$client = new GuzzleHttp\Client();
$client = new Client();
$res = $client->request('GET', $url, $options);
if ('200' == $res->getStatusCode() || '301' == $res->getStatusCode()) {
$urlValidated = true;

@ -23,9 +23,9 @@ $sequenceId = isset($_REQUEST['sequence_id']) ? $_REQUEST['sequence_id'] : 0;
$em = Database::getManager();
/** @var SequenceRepository $sequenceRepository */
$sequenceRepository = $em->getRepository('ChamiloCoreBundle:Sequence');
$sequenceRepository = $em->getRepository(Sequence::class);
/** @var SequenceResourceRepository $sequenceResourceRepository */
$sequenceResourceRepository = $em->getRepository('ChamiloCoreBundle:SequenceResource');
$sequenceResourceRepository = $em->getRepository(SequenceResource::class);
switch ($action) {
case 'graph':

@ -282,7 +282,7 @@ switch ($action) {
1
);
$id = (int) $newFolderData['iid'];
$id = $newFolderData->getIid();
} else {
$id = DocumentManager::get_document_id($courseInfo, $folderName, $session->getId());
}

@ -4,6 +4,7 @@
use Chamilo\CoreBundle\Entity\SkillRelCourse;
use Chamilo\CoreBundle\Entity\SkillRelItem;
use Chamilo\CoreBundle\Entity\SkillRelItemRelUser;
/**
* Responses to AJAX calls.
@ -415,7 +416,7 @@ switch ($action) {
if (!empty($typeId) && !empty($itemId) && !empty($skillId) && !empty($userId) && !empty($courseId)) {
$em = Database::getManager();
$user = api_get_user_entity($userId);
$skill = $em->getRepository('ChamiloCoreBundle:Skill')->find($skillId);
$skill = $em->getRepository(\Chamilo\CoreBundle\Entity\Skill::class)->find($skillId);
if (empty($user) || empty($skill)) {
exit;
}
@ -435,13 +436,13 @@ switch ($action) {
'user' => $userId,
'skillRelItem' => $skillRelItem,
];
$skillRelItemRelUser = $em->getRepository('ChamiloCoreBundle:SkillRelItemRelUser')->findOneBy($criteria);
$skillRelItemRelUser = $em->getRepository(SkillRelItemRelUser::class)->findOneBy($criteria);
if ($skillRelItemRelUser) {
$em->remove($skillRelItemRelUser);
$em->flush();
$skillRelItemRelUser = null;
} else {
$skillRelItemRelUser = new Chamilo\CoreBundle\Entity\SkillRelItemRelUser();
$skillRelItemRelUser = new SkillRelItemRelUser();
$skillRelItemRelUser
->setUser($user)
->setSkillRelItem($skillRelItem)
@ -476,7 +477,7 @@ switch ($action) {
}
$em = Database::getManager();
$skillRepo = $em->getRepository('ChamiloCoreBundle:Skill');
$skillRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\Skill::class);
$skill = $skillRepo->find($skillId);
$user = api_get_user_entity($userId);
@ -484,7 +485,7 @@ switch ($action) {
exit;
}
$skillUserRepo = $em->getRepository('ChamiloCoreBundle:SkillRelUser');
$skillUserRepo = $em->getRepository(\Chamilo\CoreBundle\Entity\SkillRelUser::class);
$criteria = [
'user' => $user,
'skill' => $skill,
@ -502,7 +503,7 @@ switch ($action) {
$course = api_get_course_entity($courseId);
$skillUser->setCourse($course);
if (!empty($sessionId)) {
$session = $em->getRepository('ChamiloCoreBundle:Session')->find($sessionId);
$session = api_get_session_entity($sessionId);
$skillUser->setSession($session);
}

@ -349,8 +349,8 @@ switch ($action) {
}
$em = Database::getManager();
$messageRepo = $em->getRepository('ChamiloCoreBundle:Message');
$messageLikesRepo = $em->getRepository('ChamiloCoreBundle:MessageFeedback');
$messageRepo = $em->getRepository(Message::class);
$messageLikesRepo = $em->getRepository(MessageFeedback::class);
/** @var Message $message */
$message = $messageRepo->find($messageId);

@ -430,16 +430,17 @@ switch ($action) {
if (!empty($row['value'])) {
$date1 = new DateTime($row['value']);
$interval = $now->diff($date1);
$years = (int) $interval->y;
if ($years >= 16 && $years <= 17) {
$all['16-17']++;
}
if ($years >= 18 && $years <= 25) {
$all['18-25']++;
}
if ($years >= 26 && $years <= 30) {
$all['26-30']++;
if ($interval) {
$years = $interval->y;
if ($years >= 16 && $years <= 17) {
$all['16-17']++;
}
if ($years >= 18 && $years <= 25) {
$all['18-25']++;
}
if ($years >= 26 && $years <= 30) {
$all['26-30']++;
}
}
}
}

@ -107,9 +107,9 @@ class CourseDescription
* Get all data by description and session id,
* first you must set session_id property with the object CourseDescription.
*
* @param int $description_type Description type
* @param int $courseId Course code (optional)
* @param int $session_id Session id (optional)
* @param int $description_type Description type
* @param int $courseId Course code (optional)
* @param int $session_id Session id (optional)
*
* @return array List of fields from the descriptions found of the given type
*/

@ -9,67 +9,67 @@ use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLpCategory;
use Chamilo\CourseBundle\Entity\CNotebook;
use Chamilo\CourseBundle\Entity\Repository\CNotebookRepository;
use Chamilo\UserBundle\Entity\User;
use Chamilo\CourseBundle\Repository\CNotebookRepository;
use Chamilo\CoreBundle\Entity\User;
/**
* Class RestApi.
*/
class Rest extends WebService
{
const SERVICE_NAME = 'MsgREST';
const EXTRA_FIELD_GCM_REGISTRATION = 'gcm_registration_id';
const GET_AUTH = 'authenticate';
const GET_USER_MESSAGES = 'user_messages';
const POST_USER_MESSAGE_READ = 'user_message_read';
const POST_USER_MESSAGE_UNREAD = 'user_message_unread';
const SAVE_GCM_ID = 'gcm_id';
const GET_USER_COURSES = 'user_courses';
const GET_PROFILE = 'user_profile';
const GET_COURSE_INFO = 'course_info';
const GET_COURSE_DESCRIPTIONS = 'course_descriptions';
const GET_COURSE_DOCUMENTS = 'course_documents';
const GET_COURSE_ANNOUNCEMENTS = 'course_announcements';
const GET_COURSE_ANNOUNCEMENT = 'course_announcement';
const GET_COURSE_AGENDA = 'course_agenda';
const GET_COURSE_NOTEBOOKS = 'course_notebooks';
const GET_COURSE_FORUM_CATEGORIES = 'course_forumcategories';
const GET_COURSE_FORUM = 'course_forum';
const GET_COURSE_FORUM_THREAD = 'course_forumthread';
const GET_COURSE_LEARNPATHS = 'course_learnpaths';
const GET_COURSE_LEARNPATH = 'course_learnpath';
const GET_COURSE_LP_PROGRESS = 'course_lp_progress';
const SAVE_FORUM_POST = 'save_forum_post';
const GET_USER_SESSIONS = 'user_sessions';
const SAVE_USER_MESSAGE = 'save_user_message';
const GET_MESSAGE_USERS = 'message_users';
const SAVE_COURSE_NOTEBOOK = 'save_course_notebook';
const SAVE_FORUM_THREAD = 'save_forum_thread';
const SAVE_COURSE = 'save_course';
const SAVE_USER = 'save_user';
const SAVE_USER_JSON = 'save_user_json';
const SUBSCRIBE_USER_TO_COURSE = 'subscribe_user_to_course';
const EXTRAFIELD_GCM_ID = 'gcm_registration_id';
const GET_USER_MESSAGES_RECEIVED = 'user_messages_received';
const GET_USER_MESSAGES_SENT = 'user_messages_sent';
const DELETE_USER_MESSAGE = 'delete_user_message';
const SET_MESSAGE_READ = 'set_message_read';
const CREATE_CAMPUS = 'add_campus';
const EDIT_CAMPUS = 'edit_campus';
const DELETE_CAMPUS = 'delete_campus';
const SAVE_SESSION = 'save_session';
const GET_USERS = 'get_users';
const GET_COURSES = 'get_courses';
const ADD_COURSES_SESSION = 'add_courses_session';
const ADD_USERS_SESSION = 'add_users_session';
const CREATE_SESSION_FROM_MODEL = 'create_session_from_model';
const SUBSCRIBE_USER_TO_SESSION_FROM_USERNAME = 'subscribe_user_to_session_from_username';
const GET_SESSION_FROM_EXTRA_FIELD = 'get_session_from_extra_field';
const UPDATE_USER_FROM_USERNAME = 'update_user_from_username';
const USERNAME_EXIST = 'username_exist';
const GET_COURSE_QUIZ_MDL_COMPAT = 'get_course_quiz_mdl_compat';
const UPDATE_USER_PAUSE_TRAINING = 'update_user_pause_training';
public const SERVICE_NAME = 'MsgREST';
public const EXTRA_FIELD_GCM_REGISTRATION = 'gcm_registration_id';
public const GET_AUTH = 'authenticate';
public const GET_USER_MESSAGES = 'user_messages';
public const POST_USER_MESSAGE_READ = 'user_message_read';
public const POST_USER_MESSAGE_UNREAD = 'user_message_unread';
public const SAVE_GCM_ID = 'gcm_id';
public const GET_USER_COURSES = 'user_courses';
public const GET_PROFILE = 'user_profile';
public const GET_COURSE_INFO = 'course_info';
public const GET_COURSE_DESCRIPTIONS = 'course_descriptions';
public const GET_COURSE_DOCUMENTS = 'course_documents';
public const GET_COURSE_ANNOUNCEMENTS = 'course_announcements';
public const GET_COURSE_ANNOUNCEMENT = 'course_announcement';
public const GET_COURSE_AGENDA = 'course_agenda';
public const GET_COURSE_NOTEBOOKS = 'course_notebooks';
public const GET_COURSE_FORUM_CATEGORIES = 'course_forumcategories';
public const GET_COURSE_FORUM = 'course_forum';
public const GET_COURSE_FORUM_THREAD = 'course_forumthread';
public const GET_COURSE_LEARNPATHS = 'course_learnpaths';
public const GET_COURSE_LEARNPATH = 'course_learnpath';
public const GET_COURSE_LP_PROGRESS = 'course_lp_progress';
public const SAVE_FORUM_POST = 'save_forum_post';
public const GET_USER_SESSIONS = 'user_sessions';
public const SAVE_USER_MESSAGE = 'save_user_message';
public const GET_MESSAGE_USERS = 'message_users';
public const SAVE_COURSE_NOTEBOOK = 'save_course_notebook';
public const SAVE_FORUM_THREAD = 'save_forum_thread';
public const SAVE_COURSE = 'save_course';
public const SAVE_USER = 'save_user';
public const SAVE_USER_JSON = 'save_user_json';
public const SUBSCRIBE_USER_TO_COURSE = 'subscribe_user_to_course';
public const EXTRAFIELD_GCM_ID = 'gcm_registration_id';
public const GET_USER_MESSAGES_RECEIVED = 'user_messages_received';
public const GET_USER_MESSAGES_SENT = 'user_messages_sent';
public const DELETE_USER_MESSAGE = 'delete_user_message';
public const SET_MESSAGE_READ = 'set_message_read';
public const CREATE_CAMPUS = 'add_campus';
public const EDIT_CAMPUS = 'edit_campus';
public const DELETE_CAMPUS = 'delete_campus';
public const SAVE_SESSION = 'save_session';
public const GET_USERS = 'get_users';
public const GET_COURSES = 'get_courses';
public const ADD_COURSES_SESSION = 'add_courses_session';
public const ADD_USERS_SESSION = 'add_users_session';
public const CREATE_SESSION_FROM_MODEL = 'create_session_from_model';
public const SUBSCRIBE_USER_TO_SESSION_FROM_USERNAME = 'subscribe_user_to_session_from_username';
public const GET_SESSION_FROM_EXTRA_FIELD = 'get_session_from_extra_field';
public const UPDATE_USER_FROM_USERNAME = 'update_user_from_username';
public const USERNAME_EXIST = 'username_exist';
public const GET_COURSE_QUIZ_MDL_COMPAT = 'get_course_quiz_mdl_compat';
public const UPDATE_USER_PAUSE_TRAINING = 'update_user_pause_training';
/**
* @var Session
@ -1773,8 +1773,7 @@ class Rest extends WebService
if (is_null($userId)) {
throw new Exception(get_lang('NoData'));
}
/** @var User $user */
$user = UserManager::getRepository()->find($userId);
$user = api_get_user_entity($userId);
if (empty($user)) {
throw new Exception(get_lang('CouldNotLoadUser'));
}
@ -1999,12 +1998,12 @@ class Rest extends WebService
'indent' => 0,
'onclick' => '',
'afterlink' => null,
'customdata' => "",
'customdata' => '',
'noviewlink' => false,
'completion' => (int) ($exercise[1] > 0),
];
},
Exercise::exerciseGrid(0, '', $userId, $courseId, $sessionId, true)
Exercise::exerciseGridResource(0, '', $userId, $courseId, $sessionId, true)
);
return [$json];

@ -11,7 +11,6 @@ use ChamiloSession as Session;
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
api_protect_course_script();
/** @var learnpath $learnPath */

@ -173,10 +173,7 @@ class CourseHomeController extends ToolBaseController
if (!empty($item) && isset($item['value']) && !empty($item['value'])) {
/** @var Graph $graph */
$graph = UnserializeApi::unserialize(
'career',
$item['value']
);
$graph = UnserializeApi::unserialize('career', $item['value']);
$diagram = Career::renderDiagram($careerInfo, $graph);
}
}
@ -192,8 +189,12 @@ class CourseHomeController extends ToolBaseController
api_remove_in_gradebook();
\Exercise::cleanSessionVariables();
$shortcutQuery = $shortcutRepository->getResources($this->getUser(), $course->getResourceNode(), $course);
$shortcuts = $shortcutQuery->getQuery()->getResult();
$shortcuts = [];
if ($user) {
$shortcutQuery = $shortcutRepository->getResources($user, $course->getResourceNode(), $course);
$shortcuts = $shortcutQuery->getQuery()->getResult();
}
return $this->render(
'@ChamiloCore/Course/home.html.twig',

@ -41,7 +41,7 @@ class ExtraFieldSavedSearch
protected User $user;
/**
* @var string
* @var array
*
* @ORM\Column(name="value", type="array", nullable=true, unique=false)
*/
@ -57,20 +57,12 @@ class ExtraFieldSavedSearch
return $this->id;
}
/**
* @return ExtraField
*/
public function getField()
public function getField(): ExtraField
{
return $this->field;
}
/**
* @param ExtraField $field
*
* @return ExtraFieldSavedSearch
*/
public function setField($field)
public function setField(ExtraField $field): self
{
$this->field = $field;
@ -78,19 +70,14 @@ class ExtraFieldSavedSearch
}
/**
* @return string
* @return array
*/
public function getValue()
{
return $this->value;
}
/**
* @param string $value
*
* @return ExtraFieldSavedSearch
*/
public function setValue($value)
public function setValue(array $value): self
{
$this->value = $value;

Loading…
Cancel
Save