Minor - flint fixes

pull/3924/head
Julio Montoya 4 years ago
parent 028435b3e1
commit f68d481383
  1. 2
      ecs.php
  2. 4
      public/main/admin/access_url_edit.php
  3. 1
      public/main/admin/access_url_edit_users_to_url.php
  4. 1
      public/main/admin/add_sessions_to_usergroup.php
  5. 1
      public/main/admin/course_list.php
  6. 2
      public/main/admin/course_user_import_by_email.php
  7. 1
      public/main/admin/skills_wheel.php
  8. 1
      public/main/admin/user_information.php
  9. 1
      public/main/admin/user_update_import.php
  10. 1
      public/main/blog/blog.php
  11. 2
      public/main/course_info/infocours.php
  12. 1
      public/main/cron/add_gradebook_certificates.php
  13. 8
      public/main/cron/check_lp_total_time.php
  14. 2
      public/main/exercise/answer.class.php
  15. 6
      public/main/exercise/exercise.class.php
  16. 1
      public/main/exercise/export/aiken/aiken_import.inc.php
  17. 16
      public/main/exercise/hotspot_actionscript.as.php
  18. 7
      public/main/exercise/question.class.php
  19. 1
      public/main/exercise/question_admin.inc.php
  20. 16
      public/main/forum/forumfunction.inc.php
  21. 1
      public/main/forum/viewforum.php
  22. 2
      public/main/forum/viewthread.php
  23. 2
      public/main/glossary/glossary_ajax_request.php
  24. 8
      public/main/gradebook/lib/be/category.class.php
  25. 4
      public/main/inc/ajax/course.ajax.php
  26. 7
      public/main/inc/ajax/exercise.ajax.php
  27. 2
      public/main/inc/ajax/lp.ajax.php
  28. 8
      public/main/inc/ajax/model.ajax.php
  29. 1
      public/main/inc/ajax/work.ajax.php
  30. 2
      public/main/inc/global.inc.php
  31. 9
      public/main/inc/lib/SkillModel.php
  32. 1
      public/main/inc/lib/TicketManager.php
  33. 2
      public/main/inc/lib/add_course.lib.inc.php
  34. 58
      public/main/inc/lib/agenda.lib.php
  35. 10
      public/main/inc/lib/api.lib.php
  36. 114
      public/main/inc/lib/course.lib.php
  37. 12
      public/main/inc/lib/course_category.lib.php
  38. 6
      public/main/inc/lib/database.lib.php
  39. 7
      public/main/inc/lib/display.lib.php
  40. 7
      public/main/inc/lib/document.lib.php
  41. 15
      public/main/inc/lib/events.lib.php
  42. 25
      public/main/inc/lib/exercise.lib.php
  43. 2
      public/main/inc/lib/formvalidator/Element/HtmlEditor.php
  44. 8
      public/main/inc/lib/formvalidator/FormValidator.class.php
  45. 2
      public/main/inc/lib/grade_model.lib.php
  46. 13
      public/main/inc/lib/groupmanager.lib.php
  47. 95
      public/main/inc/lib/internationalization.lib.php
  48. 2
      public/main/inc/lib/myspace.lib.php
  49. 12
      public/main/inc/lib/system_announcements.lib.php
  50. 40
      public/main/inc/lib/tracking.lib.php
  51. 1
      public/main/inc/lib/urlmanager.lib.php
  52. 15
      public/main/inc/lib/usermanager.lib.php
  53. 4
      public/main/inc/lib/webservices/Rest.php
  54. 9
      public/main/install/install.lib.php
  55. 1
      public/main/lp/lp_add_audio.php
  56. 1
      public/main/lp/lp_add_item.php
  57. 3
      public/main/lp/lp_ajax_initialize.php
  58. 1
      public/main/lp/lp_ajax_switch_item.php
  59. 2
      public/main/lp/lp_ajax_switch_item_toc.php
  60. 2
      public/main/lp/lp_controller.php
  61. 2
      public/main/lp/lp_edit_item.php
  62. 1
      public/main/lp/lp_edit_item_prereq.php
  63. 1
      public/main/lp/lp_upload.php
  64. 2
      public/main/lp/lp_view_item.php
  65. 1
      public/main/lp/openoffice_presentation.class.php
  66. 2
      public/main/lp/scorm.class.php
  67. 1
      public/main/messages/view_message.php
  68. 2
      public/main/mySpace/index.php
  69. 3
      public/main/mySpace/myStudents.php
  70. 8
      public/main/session/add_users_to_session_course.php
  71. 4
      public/main/session/session_category_list.php
  72. 1
      public/main/session/session_course_edit.php
  73. 2
      public/main/session/session_import.php
  74. 1
      public/main/social/group_add.php
  75. 1
      public/main/survey/fillsurvey.php
  76. 2
      public/main/survey/link.php
  77. 1
      public/main/survey/question.php
  78. 2
      public/main/survey/survey.lib.php
  79. 26
      public/main/survey/surveyUtil.class.php
  80. 126
      public/main/ticket/ticket_details.php
  81. 2
      public/main/ticket/tickets.php
  82. 28
      public/main/tracking/exams.php
  83. 2
      public/main/user/career_diagram.php
  84. 2
      public/main/user/user.php
  85. 1
      public/main/work/edit.php
  86. 63
      public/main/work/work.lib.php
  87. 1
      public/main/work/work_list.php
  88. 2
      public/plugin/azure_active_directory/lang/dutch.php
  89. 2
      public/plugin/azure_active_directory/lang/english.php
  90. 2
      public/plugin/azure_active_directory/lang/french.php
  91. 2
      public/plugin/azure_active_directory/lang/spanish.php
  92. 2
      public/plugin/azure_active_directory/src/AzureActiveDirectory.php
  93. 4
      public/plugin/azure_active_directory/src/callback.php
  94. 2
      public/plugin/buycourses/src/buycourses.ajax.php
  95. 1
      public/plugin/buycourses/src/service_process.php
  96. 1
      public/plugin/customcertificate/src/index.php
  97. 31
      public/plugin/whispeakauth/Controller/AuthenticationController.php
  98. 5
      public/plugin/whispeakauth/Controller/BaseController.php
  99. 29
      public/plugin/whispeakauth/Controller/EnrollmentController.php
  100. 13
      public/plugin/whispeakauth/Request/ApiRequest.php
  101. Some files were not shown because too many files have changed in this diff Show More

@ -118,7 +118,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
\PhpCsFixer\Fixer\FunctionNotation\FopenFlagsFixer::class, \PhpCsFixer\Fixer\FunctionNotation\FopenFlagsFixer::class,
\Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer::class, \Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer::class,
\Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer::class, \Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer::class,
\Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer::class \Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer::class,
//UnusedVariableSniff::class . '.ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach' => true, //UnusedVariableSniff::class . '.ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach' => true,
//UnusedVariableSniff::class => 'ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach', //UnusedVariableSniff::class => 'ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach',
] ]

@ -21,10 +21,10 @@ $form = new FormValidator('add_url');
$form->addUrl('url', 'URL'); $form->addUrl('url', 'URL');
$form->addRule('url', get_lang('Required field'), 'required'); $form->addRule('url', get_lang('Required field'), 'required');
$form->addRule('url', '', 'maxlength', 254); $form->addRule('url', '', 'maxlength', 254);
$form->addTextarea( 'description', get_lang('Description')); $form->addTextarea('description', get_lang('Description'));
// URL Images // URL Images
$form->addFile( 'url_image_1', get_lang('Image')); $form->addFile('url_image_1', get_lang('Image'));
//$form->addElement('file', 'url_image_2', 'URL Image 2 (PNG)'); //$form->addElement('file', 'url_image_2', 'URL Image 2 (PNG)');
//$form->addElement('file', 'url_image_3', 'URL Image 3 (PNG)'); //$form->addElement('file', 'url_image_3', 'URL Image 3 (PNG)');

@ -5,7 +5,6 @@
/** /**
* @author Julio Montoya <gugli100@gmail.com> * @author Julio Montoya <gugli100@gmail.com>
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';

@ -159,7 +159,6 @@ if ('multiple' === $add_type) {
Display::return_icon('multiple.gif').get_lang('Multiple registration').'</a>'; Display::return_icon('multiple.gif').get_lang('Multiple registration').'</a>';
} }
$actions = '<a href="usergroups.php">'. $actions = '<a href="usergroups.php">'.
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';

@ -6,7 +6,6 @@
* This script shows a list of courses and allows searching for courses codes * This script shows a list of courses and allows searching for courses codes
* and names. * and names.
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -227,6 +227,4 @@ example2@example.org;course01;'.STUDENT.'
echo Display::prose($content); echo Display::prose($content);
Display::display_footer(); Display::display_footer();

@ -26,7 +26,6 @@ $skill_condition = '';
$skillId = isset($_REQUEST['skill_id']) ? (int) $_REQUEST['skill_id'] : 0; $skillId = isset($_REQUEST['skill_id']) ? (int) $_REQUEST['skill_id'] : 0;
if (!empty($skillId)) { if (!empty($skillId)) {
$skill_condition = '&skill_id='.$skillId; $skill_condition = '&skill_id='.$skillId;
} }
$tpl->assign('skill_id_to_load', $skillId); $tpl->assign('skill_id_to_load', $skillId);

@ -9,7 +9,6 @@ use Chamilo\CoreBundle\Framework\Container;
* *
* @author Bart Mollet * @author Bart Mollet
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -387,7 +387,6 @@ if ($count_fields > 0) {
} }
} }
$content = '<p>'.get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').') :</p> $content = '<p>'.get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').') :</p>
<blockquote> <blockquote>
<pre> <pre>

@ -30,7 +30,6 @@ $MonthsLong = api_get_months_long();
$action = isset($_GET['action']) ? $_GET['action'] : null; $action = isset($_GET['action']) ? $_GET['action'] : null;
$safe_post_file_comment = isset($_POST['post_file_comment']) ? Security::remove_XSS($_POST['post_file_comment']) : null; $safe_post_file_comment = isset($_POST['post_file_comment']) ? Security::remove_XSS($_POST['post_file_comment']) : null;
$safe_comment_text = isset($_POST['comment_text']) ? Security::remove_XSS($_POST['comment_text']) : null; $safe_comment_text = isset($_POST['comment_text']) ? Security::remove_XSS($_POST['comment_text']) : null;
$safe_comment_title = isset($_POST['comment_title']) ? Security::remove_XSS($_POST['comment_title']) : null; $safe_comment_title = isset($_POST['comment_title']) ? Security::remove_XSS($_POST['comment_title']) : null;

@ -187,10 +187,8 @@ if (!empty($scoreModels)) {
} }
*/ */
$form->addButtonSave(get_lang('Save settings'), 'submit_save'); $form->addButtonSave(get_lang('Save settings'), 'submit_save');
CourseManager::addVisibilityOptions($form); CourseManager::addVisibilityOptions($form);
$url = api_get_path(WEB_CODE_PATH)."auth/inscription.php?c=$course_code&e=1"; $url = api_get_path(WEB_CODE_PATH)."auth/inscription.php?c=$course_code&e=1";

@ -10,7 +10,6 @@ use Chamilo\CoreBundle\Framework\Container;
* *
* @author Imanol Losada <imanol.losada@beeznest.com> * @author Imanol Losada <imanol.losada@beeznest.com>
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
/** /**

@ -10,7 +10,6 @@ use Chamilo\CoreBundle\Entity\Course;
*/ */
exit; exit;
require_once __DIR__.'/../../main/inc/global.inc.php'; require_once __DIR__.'/../../main/inc/global.inc.php';
api_protect_admin_script(); api_protect_admin_script();
@ -53,7 +52,7 @@ foreach ($sessions as $session) {
foreach ($users as $user) { foreach ($users as $user) {
$result = compareLpTimeAndCourseTime($user, $course, $sessionId); $result = compareLpTimeAndCourseTime($user, $course, $sessionId);
if ($result) { if ($result) {
++$counter; $counter++;
} }
if ($counter > $max) { if ($counter > $max) {
@ -76,9 +75,8 @@ foreach($courses as $courseInfo) {
}*/ }*/
/** /**
* @param array $user * @param array $user
* @param Course $course * @param int $sessionId
* @param int $sessionId
* *
* @return bool * @return bool
*/ */

@ -469,7 +469,9 @@ class Answer
* Returns the question type. * Returns the question type.
* *
* @author Yannick Warnier <ywarnier@beeznest.org> * @author Yannick Warnier <ywarnier@beeznest.org>
*
* @todo remove this function use CQuizQuestion * @todo remove this function use CQuizQuestion
*
* @return int The type of the question this answer is bound to * @return int The type of the question this answer is bound to
*/ */
public function getQuestionType() public function getQuestionType()

@ -216,7 +216,7 @@ class Exercise
//$this->pageResultConfiguration = $object->page_result_configuration; //$this->pageResultConfiguration = $object->page_result_configuration;
} }
$this->hideQuestionNumber = $object->hide_question_number == 1; $this->hideQuestionNumber = 1 == $object->hide_question_number;
if (isset($object->show_previous_button)) { if (isset($object->show_previous_button)) {
$this->showPreviousButton = 1 == $object->show_previous_button ? true : false; $this->showPreviousButton = 1 == $object->show_previous_button ? true : false;
@ -3369,7 +3369,7 @@ class Exercise
/** /**
* So the time control will work. * So the time control will work.
* *
* @param int $timeLeft * @param int $timeLeft
* @param string $redirectToUrl * @param string $redirectToUrl
* *
* @return string * @return string
@ -3389,6 +3389,7 @@ class Exercise
if (!empty($redirectToUrl)) { if (!empty($redirectToUrl)) {
$exerciseSubmitRedirect = "window.location = '$redirectToUrl'"; $exerciseSubmitRedirect = "window.location = '$redirectToUrl'";
} }
return "<script> return "<script>
function openClockWarning() { function openClockWarning() {
$('#clock_warning').dialog({ $('#clock_warning').dialog({
@ -10402,7 +10403,6 @@ class Exercise
"; ";
} }
/** /**
* Returns true if the exercise is locked by percentage. an exercise attempt must be passed. * Returns true if the exercise is locked by percentage. an exercise attempt must be passed.
*/ */

@ -121,7 +121,6 @@ function aiken_import_exercise($file)
mkdir($baseWorkDir.$uploadPath, api_get_permissions_for_new_directories(), true); mkdir($baseWorkDir.$uploadPath, api_get_permissions_for_new_directories(), true);
} }
// set some default values for the new exercise // set some default values for the new exercise
$exercise_info = []; $exercise_info = [];
$exercise_info['name'] = preg_replace('/.(zip|txt)$/i', '', $file); $exercise_info['name'] = preg_replace('/.(zip|txt)$/i', '', $file);

@ -46,17 +46,17 @@ $answers = $objQuestion->getAnswers();
// Query db for answers // Query db for answers
/*if (HOT_SPOT_DELINEATION == $answer_type) { /*if (HOT_SPOT_DELINEATION == $answer_type) {
$sql = "SELECT iid, answer, hotspot_coordinates, hotspot_type, ponderation $sql = "SELECT iid, answer, hotspot_coordinates, hotspot_type, ponderation
FROM $TBL_ANSWERS FROM $TBL_ANSWERS
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
question_id = $questionId AND question_id = $questionId AND
hotspot_type = 'delineation' hotspot_type = 'delineation'
ORDER BY iid"; ORDER BY iid";
} else { } else {
$sql = "SELECT iid, answer, hotspot_coordinates, hotspot_type, ponderation $sql = "SELECT iid, answer, hotspot_coordinates, hotspot_type, ponderation
FROM $TBL_ANSWERS FROM $TBL_ANSWERS
WHERE c_id = $course_id AND question_id = $questionId WHERE c_id = $course_id AND question_id = $questionId
ORDER BY position"; ORDER BY position";
} }
$result = Database::query($sql);*/ $result = Database::query($sql);*/

@ -1546,11 +1546,10 @@ abstract class Question
} }
/** /**
* @param CQuizQuestion $question * @param string $name
* @param string $name * @param int $position
* @param int $position
* *
* @return null|CQuizQuestion * @return CQuizQuestion|null
*/ */
public static function saveQuestionOption(CQuizQuestion $question, $name, $position = 0) public static function saveQuestionOption(CQuizQuestion $question, $name, $position = 0)
{ {

@ -8,7 +8,6 @@
* *
* @author Olivier Brouckaert * @author Olivier Brouckaert
*/ */
$type = isset($_REQUEST['answerType']) ? (int) $_REQUEST['answerType'] : 0; $type = isset($_REQUEST['answerType']) ? (int) $_REQUEST['answerType'] : 0;
if (isset($_GET['editQuestion'])) { if (isset($_GET['editQuestion'])) {

@ -6,9 +6,9 @@ use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\GradebookLink; use Chamilo\CoreBundle\Entity\GradebookLink;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CForum;
use Chamilo\CourseBundle\Entity\CForumAttachment; use Chamilo\CourseBundle\Entity\CForumAttachment;
use Chamilo\CourseBundle\Entity\CForumCategory; use Chamilo\CourseBundle\Entity\CForumCategory;
use Chamilo\CourseBundle\Entity\CForum;
use Chamilo\CourseBundle\Entity\CForumNotification; use Chamilo\CourseBundle\Entity\CForumNotification;
use Chamilo\CourseBundle\Entity\CForumPost; use Chamilo\CourseBundle\Entity\CForumPost;
use Chamilo\CourseBundle\Entity\CForumThread; use Chamilo\CourseBundle\Entity\CForumThread;
@ -286,7 +286,7 @@ function forumForm(CForum $forum = null, $lp_id)
// We have a hidden field if we are editing. // We have a hidden field if we are editing.
if ($forum) { if ($forum) {
$form->addHidden( 'forum_id', $id); $form->addHidden('forum_id', $id);
} }
$lp_id = (int) $lp_id; $lp_id = (int) $lp_id;
@ -3496,7 +3496,7 @@ function store_reply(CForum $forum, CForumThread $thread, $values, $courseId = 0
* *
* @param CForumPost $post contains all the information about the current post * @param CForumPost $post contains all the information about the current post
* @param CForumThread $thread contains all the information about the current thread * @param CForumThread $thread contains all the information about the current thread
* @param CForum $forum contains all info about the current forum (to check if attachments are allowed) * @param CForum $forum contains all info about the current forum (to check if attachments are allowed)
* @param array $form_values contains the default values to fill the form * @param array $form_values contains the default values to fill the form
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
@ -3834,7 +3834,9 @@ function updateThreadInfo($threadId, $lastPostId, $post_date)
* This function is used to find all the information about what's new in the forum tool. * This function is used to find all the information about what's new in the forum tool.
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @deprecated * @deprecated
*
* @version february 2006, dokeos 1.8 * @version february 2006, dokeos 1.8
*/ */
function get_whats_new() function get_whats_new()
@ -6175,8 +6177,8 @@ function getPostStatus(CForum $forum, array $row, bool $addWrapper = true): stri
/** /**
* @param CForum $forum * @param CForum $forum
* @param int $threadId * @param int $threadId
* @param int $status * @param int $status
*/ */
function getCountPostsWithStatus($status, $forum, $threadId = null) function getCountPostsWithStatus($status, $forum, $threadId = null)
{ {
@ -6200,8 +6202,8 @@ function getCountPostsWithStatus($status, $forum, $threadId = null)
} }
/** /**
* @param CForum $forum * @param CForum $forum
* @param CForumPost $post * @param CForumPost $post
* *
* @return bool * @return bool
*/ */

@ -541,4 +541,3 @@ $tpl->assign('is_allowed_to_edit', $isTeacher);
$layout = $tpl->get_template('forum/forum.tpl'); $layout = $tpl->get_template('forum/forum.tpl');
$tpl->display($layout); $tpl->display($layout);

@ -3,8 +3,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CForumAttachment;
use Chamilo\CourseBundle\Entity\CForum; use Chamilo\CourseBundle\Entity\CForum;
use Chamilo\CourseBundle\Entity\CForumAttachment;
use Chamilo\CourseBundle\Entity\CForumPost; use Chamilo\CourseBundle\Entity\CForumPost;
use Chamilo\CourseBundle\Entity\CForumThread; use Chamilo\CourseBundle\Entity\CForumThread;

@ -24,7 +24,7 @@ $description = get_lang('No results found');
if (!empty($glossaryId)) { if (!empty($glossaryId)) {
$description = GlossaryManager::get_glossary_term_by_glossary_id($glossaryId); $description = GlossaryManager::get_glossary_term_by_glossary_id($glossaryId);
//$description = str_replace($path_image_search, $path_image, $description); //$description = str_replace($path_image_search, $path_image, $description);
} elseif (isset($_REQUEST['glossary_data']) && 'true' === $_REQUEST['glossary_data']) { } elseif (isset($_REQUEST['glossary_data']) && 'true' === $_REQUEST['glossary_data']) {
// get_glossary_terms // get_glossary_terms
$glossary_data = GlossaryManager::get_glossary_terms(); $glossary_data = GlossaryManager::get_glossary_terms();

@ -2,8 +2,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\GradebookCategory;
use ChamiloSession as Session; use ChamiloSession as Session;
/** /**
@ -2263,9 +2263,8 @@ class Category implements GradebookItem
/** /**
* Get the current score (as percentage) on a gradebook category for a user. * Get the current score (as percentage) on a gradebook category for a user.
* *
* @param int $userId The user id * @param int $userId The user id
* @param GradebookCategory $category * @param bool $recalculate
* @param bool $recalculate
* *
* @return float The score * @return float The score
*/ */
@ -2681,6 +2680,7 @@ class Category implements GradebookItem
/** /**
* Calculate the current score on a gradebook category for a user. * Calculate the current score on a gradebook category for a user.
*
* @return float The score * @return float The score
*/ */
private static function calculateCurrentScore(int $userId, GradebookCategory $category) private static function calculateCurrentScore(int $userId, GradebookCategory $category)

@ -2,10 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CQuiz;
/** /**
* Responses to AJAX calls. * Responses to AJAX calls.
*/ */

@ -138,7 +138,6 @@ switch ($action) {
->setExeDate($nowObject); ->setExeDate($nowObject);
$em->persist($attempt); $em->persist($attempt);
$em->flush(); $em->flush();
} }
} else { } else {
if ($debug) { if ($debug) {
@ -479,7 +478,7 @@ switch ($action) {
} }
if (WhispeakAuthPlugin::questionRequireAuthentify($question_id)) { if (WhispeakAuthPlugin::questionRequireAuthentify($question_id)) {
if ($objExercise->type == ONE_PER_PAGE) { if (ONE_PER_PAGE == $objExercise->type) {
echo json_encode(['type' => 'one_per_page']); echo json_encode(['type' => 'one_per_page']);
break; break;
} }
@ -565,7 +564,7 @@ switch ($action) {
} }
if (!$atLeastOneAnswer) { if (!$atLeastOneAnswer) {
// Check if time is over. // Check if time is over.
if ($objExercise->expired_time != 0) { if (0 != $objExercise->expired_time) {
$clockExpiredTime = ExerciseLib::get_session_time_control_key( $clockExpiredTime = ExerciseLib::get_session_time_control_key(
$objExercise->id, $objExercise->id,
$learnpath_id, $learnpath_id,
@ -840,7 +839,7 @@ switch ($action) {
); );
} }
if ($type === 'all') { if ('all' === $type) {
if ($debug) { if ($debug) {
error_log("result: ok - all"); error_log("result: ok - all");
error_log(" ------ end ajax call ------- "); error_log(" ------ end ajax call ------- ");

@ -5,7 +5,6 @@
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CDocument; use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CourseBundle\Entity\CLp; use Chamilo\CourseBundle\Entity\CLp;
use Chamilo\CourseBundle\Entity\CLpItem;
use ChamiloSession as Session; use ChamiloSession as Session;
require_once __DIR__.'/../global.inc.php'; require_once __DIR__.'/../global.inc.php';
@ -295,7 +294,6 @@ switch ($action) {
exit; exit;
$lp = Session::read('oLP'); $lp = Session::read('oLP');
break; break;
case 'check_item_position': case 'check_item_position':
// loaded in lp_nav.php // loaded in lp_nav.php

@ -115,13 +115,13 @@ function getWhereClause($col, $oper, $val)
return ''; return '';
} }
if ($oper == 'bw' || $oper == 'bn') { if ('bw' == $oper || 'bn' == $oper) {
$val .= '%'; $val .= '%';
} }
if ($oper == 'ew' || $oper == 'en') { if ('ew' == $oper || 'en' == $oper) {
$val = '%'.$val; $val = '%'.$val;
} }
if ($oper == 'cn' || $oper == 'nc' || $oper == 'in' || $oper == 'ni') { if ('cn' == $oper || 'nc' == $oper || 'in' == $oper || 'ni' == $oper) {
$val = '%'.$val.'%'; $val = '%'.$val.'%';
} }
$val = Database::escape_string($val); $val = Database::escape_string($val);
@ -1594,7 +1594,7 @@ switch ($action) {
'actions', 'actions',
]; ];
$officialCodeInList = api_get_setting('show_official_code_exercise_result_list'); $officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
if ($officialCodeInList === 'true') { if ('true' === $officialCodeInList) {
$columns = array_merge(['official_code'], $columns); $columns = array_merge(['official_code'], $columns);
} }

@ -7,7 +7,6 @@ use Chamilo\CoreBundle\Framework\Container;
/** /**
* Responses to AJAX calls. * Responses to AJAX calls.
*/ */
require_once __DIR__.'/../global.inc.php'; require_once __DIR__.'/../global.inc.php';
$action = $_REQUEST['a'] ?? null; $action = $_REQUEST['a'] ?? null;

@ -3,7 +3,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Controller\ExceptionController; use Chamilo\CoreBundle\Controller\ExceptionController;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\ErrorHandler\Debug;
@ -14,7 +13,6 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
/** /**
* All legacy Chamilo scripts should include this important file. * All legacy Chamilo scripts should include this important file.
*/ */
require_once __DIR__.'/../../../vendor/autoload.php'; require_once __DIR__.'/../../../vendor/autoload.php';
// Get settings from .env.local file created. // Get settings from .env.local file created.

@ -511,10 +511,9 @@ class SkillModel extends Model
} }
/** /**
* @param int $userId * @param int $userId
* @param GradebookCategory $category * @param int $courseId
* @param int $courseId * @param int $sessionId
* @param int $sessionId
* *
* @return bool * @return bool
*/ */
@ -2309,7 +2308,6 @@ class SkillModel extends Model
public static function getWebIconPath(Skill $skill, $getSmall = false) public static function getWebIconPath(Skill $skill, $getSmall = false)
{ {
throw new Exception('fix WEB_UPLOAD_PATH'); throw new Exception('fix WEB_UPLOAD_PATH');
if ($getSmall) { if ($getSmall) {
if (empty($skill->getIcon())) { if (empty($skill->getIcon())) {
return \Display::return_icon('badges-default.png', null, null, ICON_SIZE_BIG, null, true); return \Display::return_icon('badges-default.png', null, null, ICON_SIZE_BIG, null, true);
@ -2333,7 +2331,6 @@ class SkillModel extends Model
* @param int $authorId * @param int $authorId
* *
* @return \Chamilo\CoreBundle\Entity\SkillRelUser|bool * @return \Chamilo\CoreBundle\Entity\SkillRelUser|bool
*
*/ */
public function addSkillToUserBadge($user, $skill, $levelId, $argumentation, $authorId) public function addSkillToUserBadge($user, $skill, $levelId, $argumentation, $authorId)
{ {

@ -742,7 +742,6 @@ class TicketManager
); );
} else { } else {
throw new Exception('@todo file upload ticket_attachment'); throw new Exception('@todo file upload ticket_attachment');
//$result = api_upload_file('ticket_attachment', $file_attach, $ticketId); //$result = api_upload_file('ticket_attachment', $file_attach, $ticketId);
if ($result) { if ($result) {
$safe_file_name = Database::escape_string($new_file_name); $safe_file_name = Database::escape_string($new_file_name);

@ -637,8 +637,6 @@ class AddCourse
* @param array $params Course details (see code for details). * @param array $params Course details (see code for details).
* @param int $accessUrlId Optional. * @param int $accessUrlId Optional.
* *
* @return Course|null
*
* @todo use an array called $params instead of lots of params * @todo use an array called $params instead of lots of params
* @assert (null) === false * @assert (null) === false
*/ */

@ -2,13 +2,13 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\PersonalAgenda; use Chamilo\CoreBundle\Entity\PersonalAgenda;
use Chamilo\CoreBundle\Entity\SysCalendar; use Chamilo\CoreBundle\Entity\SysCalendar;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CCalendarEvent; use Chamilo\CourseBundle\Entity\CCalendarEvent;
use Chamilo\CourseBundle\Entity\CCalendarEventAttachment; use Chamilo\CourseBundle\Entity\CCalendarEventAttachment;
use Chamilo\CourseBundle\Entity\CGroup; use Chamilo\CourseBundle\Entity\CGroup;
use Chamilo\CoreBundle\Entity\Course;
use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\File\UploadedFile;
/** /**
@ -1413,7 +1413,6 @@ class Agenda
/** /**
* @param int $start * @param int $start
* @param int $end * @param int $end
* @param Course $course
* @param int $groupId * @param int $groupId
* @param int $sessionId * @param int $sessionId
* @param int $user_id * @param int $user_id
@ -2845,7 +2844,6 @@ class Agenda
$items = []; $items = [];
$my_list = []; $my_list = [];
throw new Exception('@todo get_myagendaitems'); throw new Exception('@todo get_myagendaitems');
/* /*
// get agenda-items for every course // get agenda-items for every course
foreach ($courses_dbs as $key => $array_course_info) { foreach ($courses_dbs as $key => $array_course_info) {
@ -2867,15 +2865,15 @@ class Agenda
if ('1' == $course_user_status) { if ('1' == $course_user_status) {
//echo "course admin"; //echo "course admin";
$sqlquery = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref $sqlquery = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." ip ".$TABLE_ITEMPROPERTY." ip
WHERE agenda.id = ip.ref WHERE agenda.id = ip.ref
AND MONTH(agenda.start_date)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(agenda.start_date)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND ip.tool='".TOOL_CALENDAR_EVENT."' AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ip.visibility='1' AND ip.visibility='1'
GROUP BY agenda.id GROUP BY agenda.id
ORDER BY start_date "; ORDER BY start_date ";
} else { } else {
// if the user is not an administrator of that course // if the user is not an administrator of that course
if (is_array($group_memberships) && count( if (is_array($group_memberships) && count(
@ -2883,29 +2881,29 @@ class Agenda
) > 0 ) > 0
) { ) {
$sqlquery = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref $sqlquery = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." ip ".$TABLE_ITEMPROPERTY." ip
WHERE agenda.id = ip.ref WHERE agenda.id = ip.ref
AND MONTH(agenda.start_date)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(agenda.start_date)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND ip.tool='".TOOL_CALENDAR_EVENT."' AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ( ip.to_user_id='".$user_id."' OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode( AND ( ip.to_user_id='".$user_id."' OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(
", ", ", ",
$group_memberships $group_memberships
).")) ) ).")) )
AND ip.visibility='1' AND ip.visibility='1'
ORDER BY start_date "; ORDER BY start_date ";
} else { } else {
$sqlquery = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref $sqlquery = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$TABLEAGENDA." agenda, FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." ip ".$TABLE_ITEMPROPERTY." ip
WHERE agenda.id = ip.ref WHERE agenda.id = ip.ref
AND MONTH(agenda.start_date)='".$month."' AND MONTH(agenda.start_date)='".$month."'
AND YEAR(agenda.start_date)='".$year."' AND YEAR(agenda.start_date)='".$year."'
AND ip.tool='".TOOL_CALENDAR_EVENT."' AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ( ip.to_user_id='".$user_id."' OR ip.to_group_id='0' OR ip.to_group_id IS NULL) AND ( ip.to_user_id='".$user_id."' OR ip.to_group_id='0' OR ip.to_group_id IS NULL)
AND ip.visibility='1' AND ip.visibility='1'
ORDER BY start_date "; ORDER BY start_date ";
} }
} }
$result = Database::query($sqlquery); $result = Database::query($sqlquery);

@ -6399,9 +6399,9 @@ function api_get_jquery_libraries_js($libraries)
* *
* This function relies on api_get_course_info() * This function relies on api_get_course_info()
* *
* @param int $courseId The course code - optional (takes it from context if not given) * @param int $courseId The course code - optional (takes it from context if not given)
* @param int $sessionId The session ID - optional (takes it from context if not given) * @param int $sessionId The session ID - optional (takes it from context if not given)
* @param int $groupId The group ID - optional (takes it from context if not given) * @param int $groupId The group ID - optional (takes it from context if not given)
* *
* @return string The URL to a course, a session, or empty string if nothing works * @return string The URL to a course, a session, or empty string if nothing works
* e.g. https://localhost/courses/ABC/index.php?session_id=3&gidReq=1 * e.g. https://localhost/courses/ABC/index.php?session_id=3&gidReq=1
@ -6796,7 +6796,7 @@ function api_get_roles()
{ {
$hierarchy = Container::$container->getParameter('security.role_hierarchy.roles'); $hierarchy = Container::$container->getParameter('security.role_hierarchy.roles');
$roles = []; $roles = [];
array_walk_recursive($hierarchy, function($role) use (&$roles) { array_walk_recursive($hierarchy, function ($role) use (&$roles) {
$roles[$role] = $role; $roles[$role] = $role;
}); });
//echo '<pre>'; var_dump($roles); //echo '<pre>'; var_dump($roles);
@ -7704,7 +7704,7 @@ function api_mail_html(
} }
/** /**
* @param int $tool Possible values: GroupManager::GROUP_TOOL_* * @param int $tool Possible values: GroupManager::GROUP_TOOL_*
* @param bool $showHeader * @param bool $showHeader
*/ */
function api_protect_course_group($tool, $showHeader = true) function api_protect_course_group($tool, $showHeader = true)

@ -170,7 +170,6 @@ class CourseManager
$sql .= " INNER JOIN $table url ON (url.c_id = course.id) "; $sql .= " INNER JOIN $table url ON (url.c_id = course.id) ";
} }
$visibility = (int) $visibility; $visibility = (int) $visibility;
if (!empty($startwith)) { if (!empty($startwith)) {
@ -241,7 +240,7 @@ class CourseManager
if (!in_array($orderdirection, ['ASC', 'DESC'])) { if (!in_array($orderdirection, ['ASC', 'DESC'])) {
$sql .= 'ASC'; $sql .= 'ASC';
} else { } else {
$sql .= $orderdirection === 'ASC' ? 'ASC' : 'DESC'; $sql .= 'ASC' === $orderdirection ? 'ASC' : 'DESC';
} }
$howmany = (int) $howmany; $howmany = (int) $howmany;
@ -710,12 +709,12 @@ class CourseManager
* Subscribe a user to a course. No checks are performed here to see if * Subscribe a user to a course. No checks are performed here to see if
* course subscription is allowed. * course subscription is allowed.
* *
* @param int $userId * @param int $userId
* @param int $courseId * @param int $courseId
* @param int $status (STUDENT, COURSEMANAGER, COURSE_ADMIN, NORMAL_COURSE_MEMBER) * @param int $status (STUDENT, COURSEMANAGER, COURSE_ADMIN, NORMAL_COURSE_MEMBER)
* @param int $sessionId * @param int $sessionId
* @param int $userCourseCategoryId * @param int $userCourseCategoryId
* @param bool $checkTeacherPermission * @param bool $checkTeacherPermission
* *
* @return bool True on success, false on failure * @return bool True on success, false on failure
* *
@ -5893,7 +5892,7 @@ class CourseManager
$result[$content['value']] = $content['content']; $result[$content['value']] = $content['content'];
} }
return $form->addMultiSelect( 'users', get_lang('Users'), $result); return $form->addMultiSelect('users', get_lang('Users'), $result);
} }
/** /**
@ -6634,14 +6633,8 @@ class CourseManager
} }
/** /**
* @param User $user
* @param Course $course
* @param array $relationInfo
*
* @throws \Doctrine\ORM\ORMException * @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException * @throws \Doctrine\ORM\OptimisticLockException
*
* @return int|null
*/ */
public static function insertUserInCourse(User $user, Course $course, array $relationInfo = []): ?int public static function insertUserInCourse(User $user, Course $course, array $relationInfo = []): ?int
{ {
@ -6669,6 +6662,51 @@ class CourseManager
return $insertId; return $insertId;
} }
public static function addVisibilityOptions(FormValidator $form): void
{
$group = [];
$group[] = $form->createElement(
'radio',
'visibility',
get_lang('Course access'),
get_lang('Public - access allowed for the whole world'),
Course::OPEN_WORLD
);
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang(' Open - access allowed for users registered on the platform'),
Course::OPEN_PLATFORM
);
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang('Private access (access authorized to group members only)'),
Course::REGISTERED
);
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang('Closed - the course is only accessible to the teachers'),
Course::CLOSED
);
// The "hidden" visibility is only available to portal admins
if (api_is_platform_admin()) {
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang('Hidden - Completely hidden to all users except the administrators'),
Course::HIDDEN
);
}
$form->addGroup($group, '', get_lang('Course access'));
}
/** /**
* Check if a specific access-url-related setting is a problem or not. * Check if a specific access-url-related setting is a problem or not.
* *
@ -6709,7 +6747,7 @@ class CourseManager
/** /**
* Fill course with all necessary items. * Fill course with all necessary items.
* *
* @param array $params Parameters from the course creation form * @param array $params Parameters from the course creation form
* @param int $authorId * @param int $authorId
*/ */
private static function fillCourse(Course $course, $params, $authorId = 0) private static function fillCourse(Course $course, $params, $authorId = 0)
@ -6743,48 +6781,4 @@ class CourseManager
$courseFieldValue = new ExtraFieldValue('course'); $courseFieldValue = new ExtraFieldValue('course');
//$courseFieldValue->saveFieldValues($params); //$courseFieldValue->saveFieldValues($params);
} }
public static function addVisibilityOptions(FormValidator $form): void
{
$group = [];
$group[] = $form->createElement(
'radio',
'visibility',
get_lang('Course access'),
get_lang('Public - access allowed for the whole world'),
Course::OPEN_WORLD
);
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang(' Open - access allowed for users registered on the platform'),
Course::OPEN_PLATFORM
);
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang('Private access (access authorized to group members only)'),
Course::REGISTERED
);
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang('Closed - the course is only accessible to the teachers'),
Course::CLOSED
);
// The "hidden" visibility is only available to portal admins
if (api_is_platform_admin()) {
$group[] = $form->createElement(
'radio',
'visibility',
null,
get_lang('Hidden - Completely hidden to all users except the administrators'),
Course::HIDDEN
);
}
$form->addGroup($group, '', get_lang('Course access'));
}
} }

@ -3,9 +3,9 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Asset; use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Entity\CourseCategory as CourseCategoryEntity;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Entity\CourseCategory as CourseCategoryEntity;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
class CourseCategory class CourseCategory
@ -125,10 +125,10 @@ class CourseCategory
} }
/** /**
* @param string $code * @param string $code
* @param string $name * @param string $name
* @param string $canHaveCourses * @param string $canHaveCourses
* @param null|int $parentId * @param int|null $parentId
*/ */
public static function add($code, $name, $canHaveCourses, $description = '', $parentId = null): ?CourseCategoryEntity public static function add($code, $name, $canHaveCourses, $description = '', $parentId = null): ?CourseCategoryEntity
{ {
@ -471,7 +471,7 @@ class CourseCategory
$actions[] = Display::url( $actions[] = Display::url(
$deleteIcon, $deleteIcon,
$deleteUrl, $deleteUrl,
['onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('Please confirm your choice')), ENT_QUOTES)).'\')) return false;',] ['onclick' => 'javascript: if (!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('Please confirm your choice')), ENT_QUOTES)).'\')) return false;']
); );
} }

@ -519,7 +519,7 @@ class Database
$option = 'ASSOC', $option = 'ASSOC',
$debug = false $debug = false
) { ) {
if ($type_result === 'count') { if ('count' === $type_result) {
$conditions['LIMIT'] = null; $conditions['LIMIT'] = null;
$conditions['limit'] = null; $conditions['limit'] = null;
} }
@ -536,7 +536,7 @@ class Database
} }
} }
if ($type_result === 'count') { if ('count' === $type_result) {
$clean_columns = ' count(*) count '; $clean_columns = ' count(*) count ';
} }
$sql = "SELECT $clean_columns FROM $table_name $conditions"; $sql = "SELECT $clean_columns FROM $table_name $conditions";
@ -544,7 +544,7 @@ class Database
var_dump($sql); var_dump($sql);
} }
$result = self::query($sql); $result = self::query($sql);
if ($type_result === 'count') { if ('count' === $type_result) {
$row = self::fetch_array($result, $option); $row = self::fetch_array($result, $option);
if ($row) { if ($row) {
return (int) $row['count']; return (int) $row['count'];

@ -27,6 +27,7 @@ class Display
public static $global_template; public static $global_template;
public static $preview_style = null; public static $preview_style = null;
public static $legacyTemplate; public static $legacyTemplate;
public function __construct() public function __construct()
{ {
} }
@ -1984,8 +1985,8 @@ class Display
tabindex="-1" tabindex="-1"
> >
<div class="py-1" role="none">'; <div class="py-1" role="none">';
foreach ($elements as $item) { foreach ($elements as $item) {
$html .= self::url( $html .= self::url(
$item['title'], $item['title'],
$item['href'], $item['href'],
[ [
@ -1995,7 +1996,7 @@ class Display
'data-action' => $item['data-action'] ?? '', 'data-action' => $item['data-action'] ?? '',
] ]
); );
} }
$html .= ' $html .= '
</div> </div>
</div> </div>

@ -2,15 +2,12 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\ResourceFile;
use Chamilo\CoreBundle\Entity\ResourceLink; use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CoreBundle\Entity\ResourceNode; use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CDocument; use Chamilo\CourseBundle\Entity\CDocument;
use Chamilo\CourseBundle\Entity\CGroup;
use ChamiloSession as Session; use ChamiloSession as Session;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/** /**
* Class DocumentManager * Class DocumentManager
@ -2906,8 +2903,8 @@ class DocumentManager
'rootOpen' => '<ul id="doc_list" class="list-group lp_resource">', 'rootOpen' => '<ul id="doc_list" class="list-group lp_resource">',
'rootClose' => '</ul>', 'rootClose' => '</ul>',
//'childOpen' => '<li class="doc_resource lp_resource_element ">', //'childOpen' => '<li class="doc_resource lp_resource_element ">',
'childOpen' => function($child) { 'childOpen' => function ($child) {
$id = $child['id']; $id = $child['id'];
$disableDrag = ''; $disableDrag = '';
if (!$child['resourceFile']) { if (!$child['resourceFile']) {
$disableDrag = ' disable_drag '; $disableDrag = ' disable_drag ';

@ -680,13 +680,12 @@ class Event
/** /**
* Record an hotspot spot for this attempt at answering an hotspot question. * Record an hotspot spot for this attempt at answering an hotspot question.
* *
* @param Exercise $exercise * @param int $exeId
* @param int $exeId * @param int $questionId Question ID
* @param int $questionId Question ID * @param int $answerId Answer ID
* @param int $answerId Answer ID * @param int $correct
* @param int $correct * @param string $coords Coordinates of this point (e.g. 123;324)
* @param string $coords Coordinates of this point (e.g. 123;324) * @param bool $updateResults
* @param bool $updateResults
* *
* @return bool Result of the insert query * @return bool Result of the insert query
* *
@ -706,7 +705,7 @@ class Event
) { ) {
$debug = false; $debug = false;
if ($updateResults == false) { if (false == $updateResults) {
// Validation in case of fraud with activated control time // Validation in case of fraud with activated control time
if (!ExerciseLib::exercise_time_control_is_valid($exercise, $lpId, $lpItemId)) { if (!ExerciseLib::exercise_time_control_is_valid($exercise, $lpId, $lpItemId)) {
if ($debug) { if ($debug) {

@ -1751,9 +1751,8 @@ HOTSPOT;
/** /**
* Validates the time control key. * Validates the time control key.
* *
* @param Exercise $exercise * @param int $lp_id
* @param int $lp_id * @param int $lp_item_id
* @param int $lp_item_id
* *
* @return bool * @return bool
*/ */
@ -1865,10 +1864,10 @@ HOTSPOT;
/** /**
* Gets count of exam results. * Gets count of exam results.
* *
* @param int $exerciseId * @param int $exerciseId
* @param array $conditions * @param array $conditions
* @param int $courseId * @param int $courseId
* @param bool $showSession * @param bool $showSession
* *
* @return array * @return array
*/ */
@ -2154,7 +2153,7 @@ HOTSPOT;
$column = !empty($column) ? Database::escape_string($column) : null; $column = !empty($column) ? Database::escape_string($column) : null;
$from = (int) $from; $from = (int) $from;
$number_of_items = (int) $number_of_items; $number_of_items = (int) $number_of_items;
$direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction; $direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction;
if (!empty($column)) { if (!empty($column)) {
$sql .= " ORDER BY `$column` $direction "; $sql .= " ORDER BY `$column` $direction ";
@ -5366,11 +5365,11 @@ EOT;
* Generate a certificate linked to current quiz and. * Generate a certificate linked to current quiz and.
* Return the HTML block with links to download and view the certificate. * Return the HTML block with links to download and view the certificate.
* *
* @param float $totalScore * @param float $totalScore
* @param float $totalWeight * @param float $totalWeight
* @param int $studentId * @param int $studentId
* @param int $courseId * @param int $courseId
* @param int $sessionId * @param int $sessionId
* *
* @return string * @return string
*/ */

@ -2,8 +2,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Component\Editor\Editor; use Chamilo\CoreBundle\Component\Editor\Editor;
use Chamilo\CoreBundle\Framework\Container;
/** /**
* A html editor field to use with QuickForm. * A html editor field to use with QuickForm.

@ -24,7 +24,6 @@ class FormValidator extends HTML_QuickForm
* @param string $action (optional) Action (default is $PHP_SELF) * @param string $action (optional) Action (default is $PHP_SELF)
* @param string|null $target (optional) Form's target defaults to '_self' * @param string|null $target (optional) Form's target defaults to '_self'
* @param mixed $attributes (optional) Extra attributes for <form> tag * @param mixed $attributes (optional) Extra attributes for <form> tag
* @param string $layout
* @param bool $trackSubmit Whether to track if the form was submitted by adding a special hidden field * @param bool $trackSubmit Whether to track if the form was submitted by adding a special hidden field
*/ */
public function __construct( public function __construct(
@ -885,10 +884,7 @@ EOT;
} }
/** /**
* @param string $name
* @param string|array $label * @param string|array $label
* @param array $options
* @param array $attributes
* *
* @return HTML_QuickForm_select * @return HTML_QuickForm_select
*/ */
@ -970,9 +966,9 @@ EOT;
} }
/** /**
* @param string $name * @param string $name
* @param string|array $label * @param string|array $label
* @param array $attributes * @param array $attributes
* *
* @throws Exception if the file doesn't have an id * @throws Exception if the file doesn't have an id
* *

@ -282,7 +282,7 @@ class GradeModel extends Model
$grade_model_options[$item['id']] = $item['name']; $grade_model_options[$item['id']] = $item['name'];
} }
} }
$form->addSelect( $name, get_lang('Grading model'), $grade_model_options); $form->addSelect($name, get_lang('Grading model'), $grade_model_options);
$default_platform_setting = api_get_setting('gradebook_default_grade_model_id'); $default_platform_setting = api_get_setting('gradebook_default_grade_model_id');
$default = -1; $default = -1;

@ -95,13 +95,13 @@ class GroupManager
/** /**
* Get list of groups for current course. * Get list of groups for current course.
* *
* @param int $categoryId The id of the category from which the groups are * @param int $categoryId The id of the category from which the groups are
* requested * requested
* @param Course $course Default is current course * @param Course $course Default is current course
* @param int $status group status * @param int $status group status
* @param int $sessionId * @param int $sessionId
* @param bool $getCount * @param bool $getCount
* @param bool $notInGroup Get groups not in a category * @param bool $notInGroup Get groups not in a category
* @param bool $returnEntityList * @param bool $returnEntityList
* *
* @return array|CGroup[] an array with all information about the groups * @return array|CGroup[] an array with all information about the groups
@ -1634,7 +1634,7 @@ class GroupManager
public static function get_subscribed_users(CGroup $group) public static function get_subscribed_users(CGroup $group)
{ {
//$order = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname'; //$order = api_sort_by_first_name() ? ' ORDER BY u.firstname, u.lastname' : ' ORDER BY u.lastname, u.firstname';
$order = ['lastname'=> Criteria::DESC, 'firstname'=> Criteria::ASC]; $order = ['lastname' => Criteria::DESC, 'firstname' => Criteria::ASC];
if (api_sort_by_first_name()) { if (api_sort_by_first_name()) {
$order = ['firstname' => Criteria::ASC, 'lastname' => Criteria::ASC]; $order = ['firstname' => Criteria::ASC, 'lastname' => Criteria::ASC];
} }
@ -2816,7 +2816,6 @@ class GroupManager
} }
/** /**
* @param Course $course
* @param string $keyword * @param string $keyword
* *
* @return string * @return string

@ -356,7 +356,7 @@ function api_strtotime($time, $timezone = null)
* The given date should be in the timezone chosen by the administrator * The given date should be in the timezone chosen by the administrator
* and/or user. Use api_get_local_time to get it. * and/or user. Use api_get_local_time to get it.
* *
* @param mixed $time Timestamp or datetime string * @param mixed $time Timestamp or datetime string
* @param string|int Date format (see date formats in the Chamilo system: * @param string|int Date format (see date formats in the Chamilo system:
* TIME_NO_SEC_FORMAT, * TIME_NO_SEC_FORMAT,
* DATE_FORMAT_SHORT, * DATE_FORMAT_SHORT,
@ -401,49 +401,41 @@ function api_format_date($time, $format = null, $language = null)
if (is_int($format)) { if (is_int($format)) {
switch ($format) { switch ($format) {
case DATE_FORMAT_ONLY_DAYNAME: case DATE_FORMAT_ONLY_DAYNAME:
$datetype = IntlDateFormatter::SHORT; $datetype = IntlDateFormatter::SHORT;
$timetype = IntlDateFormatter::NONE; $timetype = IntlDateFormatter::NONE;
break; break;
case DATE_FORMAT_NUMBER_NO_YEAR: case DATE_FORMAT_NUMBER_NO_YEAR:
$datetype = IntlDateFormatter::SHORT; $datetype = IntlDateFormatter::SHORT;
$timetype = IntlDateFormatter::NONE; $timetype = IntlDateFormatter::NONE;
break; break;
case DATE_FORMAT_NUMBER: case DATE_FORMAT_NUMBER:
$datetype = IntlDateFormatter::SHORT; $datetype = IntlDateFormatter::SHORT;
$timetype = IntlDateFormatter::NONE; $timetype = IntlDateFormatter::NONE;
break; break;
case TIME_NO_SEC_FORMAT: case TIME_NO_SEC_FORMAT:
$datetype = IntlDateFormatter::NONE; $datetype = IntlDateFormatter::NONE;
$timetype = IntlDateFormatter::SHORT; $timetype = IntlDateFormatter::SHORT;
break; break;
case DATE_FORMAT_SHORT: case DATE_FORMAT_SHORT:
$datetype = IntlDateFormatter::LONG; $datetype = IntlDateFormatter::LONG;
$timetype = IntlDateFormatter::NONE; $timetype = IntlDateFormatter::NONE;
break; break;
case DATE_FORMAT_LONG: case DATE_FORMAT_LONG:
$datetype = IntlDateFormatter::FULL; $datetype = IntlDateFormatter::FULL;
$timetype = IntlDateFormatter::NONE; $timetype = IntlDateFormatter::NONE;
break; break;
case DATE_TIME_FORMAT_LONG: case DATE_TIME_FORMAT_LONG:
$datetype = IntlDateFormatter::FULL; $datetype = IntlDateFormatter::FULL;
$timetype = IntlDateFormatter::SHORT; $timetype = IntlDateFormatter::SHORT;
break; break;
case DATE_FORMAT_LONG_NO_DAY: case DATE_FORMAT_LONG_NO_DAY:
$datetype = IntlDateFormatter::FULL; $datetype = IntlDateFormatter::FULL;
$timetype = IntlDateFormatter::SHORT; $timetype = IntlDateFormatter::SHORT;
@ -454,7 +446,6 @@ function api_format_date($time, $format = null, $language = null)
break; break;
case DATE_TIME_FORMAT_SHORT_TIME_FIRST: case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
$datetype = IntlDateFormatter::FULL; $datetype = IntlDateFormatter::FULL;
$timetype = IntlDateFormatter::SHORT; $timetype = IntlDateFormatter::SHORT;
@ -488,7 +479,7 @@ function api_format_date($time, $format = null, $language = null)
* You can use it like this: * You can use it like this:
* Display::dateToStringAgoAndLongDate($dateInUtc);. * Display::dateToStringAgoAndLongDate($dateInUtc);.
* *
* @param string|DateTime $date Result of a date function in this format -> date('Y-m-d H:i:s', time()); * @param string|DateTime $date Result of a date function in this format -> date('Y-m-d H:i:s', time());
* @param string $timeZone * @param string $timeZone
* @param bool $returnDateDifference * @param bool $returnDateDifference
* *
@ -1426,21 +1417,21 @@ function api_ucwords($string, $encoding = null)
/** /**
* Performs a regular expression match, UTF-8 aware when it is applicable. * Performs a regular expression match, UTF-8 aware when it is applicable.
* *
* @param string $pattern the pattern to search for, as a string * @param string $pattern the pattern to search for, as a string
* @param string $subject the input string * @param string $subject the input string
* @param array &$matches (optional) If matches is provided, * @param array &$matches (optional) If matches is provided,
* then it is filled with the results of search (as an array). * then it is filled with the results of search (as an array).
* $matches[0] will contain the text that matched the full pattern, $matches[1] will have the * $matches[0] will contain the text that matched the full pattern, $matches[1] will have the
* text that matched the first captured parenthesized subpattern, and so on. * text that matched the first captured parenthesized subpattern, and so on.
* @param int $flags (optional) Could be PREG_OFFSET_CAPTURE. If this flag is passed, for every occurring match * @param int $flags (optional) Could be PREG_OFFSET_CAPTURE. If this flag is passed, for every occurring match
* the appendant string offset will also be returned. Note that this changes the return value * the appendant string offset will also be returned. Note that this changes the return value
* in an array where every element is an array consisting of the matched string at index 0 and * in an array where every element is an array consisting of the matched string at index 0 and
* its string offset into subject at index 1. * its string offset into subject at index 1.
* @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The * @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The
* optional parameter offset can be used to specify the alternate place from which to start * optional parameter offset can be used to specify the alternate place from which to start
* the search. * the search.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted,
* the platform character set will be used by default. * the platform character set will be used by default.
* *
* @return int|bool returns the number of times pattern matches or FALSE if an error occurred * @return int|bool returns the number of times pattern matches or FALSE if an error occurred
* *
@ -1464,24 +1455,24 @@ function api_preg_match(
/** /**
* Performs a global regular expression match, UTF-8 aware when it is applicable. * Performs a global regular expression match, UTF-8 aware when it is applicable.
* *
* @param string $pattern the pattern to search for, as a string * @param string $pattern the pattern to search for, as a string
* @param string $subject the input string * @param string $subject the input string
* @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags * @param array &$matches (optional) Array of all matches in multi-dimensional array ordered according to $flags
* @param int $flags (optional) Can be a combination of the following flags (note that it doesn't * @param int $flags (optional) Can be a combination of the following flags (note that it doesn't
* make sense to use PREG_PATTERN_ORDER together with PREG_SET_ORDER): PREG_PATTERN_ORDER - * make sense to use PREG_PATTERN_ORDER together with PREG_SET_ORDER): PREG_PATTERN_ORDER -
* orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an * orders results so that $matches[0] is an array of full pattern matches, $matches[1] is an
* array of strings matched by the first parenthesized subpattern, and so on; PREG_SET_ORDER - * array of strings matched by the first parenthesized subpattern, and so on; PREG_SET_ORDER -
* orders results so that $matches[0] is an array of first set of matches, $matches[1] is an * orders results so that $matches[0] is an array of first set of matches, $matches[1] is an
* array of second set of matches, and so on; PREG_OFFSET_CAPTURE - If this flag is passed, * array of second set of matches, and so on; PREG_OFFSET_CAPTURE - If this flag is passed,
* for every occurring match the appendant string offset will also be returned. Note that this * for every occurring match the appendant string offset will also be returned. Note that this
* changes the value of matches in an array where every element is an array consisting of the * changes the value of matches in an array where every element is an array consisting of the
* matched string at offset 0 and its string offset into subject at offset 1. If no order flag * matched string at offset 0 and its string offset into subject at offset 1. If no order flag
* is given, PREG_PATTERN_ORDER is assumed. * is given, PREG_PATTERN_ORDER is assumed.
* @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The * @param int $offset (optional) Normally, the search starts from the beginning of the subject string. The
* optional parameter offset can be used to specify the alternate place from which to start * optional parameter offset can be used to specify the alternate place from which to start
* the search. * the search.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, * @param string $encoding (optional) The used internally by this function character encoding. If it is omitted,
* the platform character set will be used by default. * the platform character set will be used by default.
* *
* @return int|bool returns the number of full pattern matches (which might be zero), or FALSE if an error occurred * @return int|bool returns the number of full pattern matches (which might be zero), or FALSE if an error occurred
* *
@ -1502,14 +1493,14 @@ function api_preg_match_all($pattern, $subject, &$matches, $flags = PREG_PATTERN
/** /**
* Performs a regular expression search and replace, UTF-8 aware when it is applicable. * Performs a regular expression search and replace, UTF-8 aware when it is applicable.
* *
* @param string|array $pattern The pattern to search for. It can be either a string or an array with strings. * @param string|array $pattern The pattern to search for. It can be either a string or an array with strings.
* @param string|array $replacement the string or an array with strings to replace * @param string|array $replacement the string or an array with strings to replace
* @param string|array $subject the string or an array with strings to search and replace * @param string|array $subject the string or an array with strings to search and replace
* @param int $limit The maximum possible replacements for each pattern in each subject string. * @param int $limit The maximum possible replacements for each pattern in each subject string.
* Defaults to -1 (no limit). * Defaults to -1 (no limit).
* @param int &$count If specified, this variable will be filled with the number of replacements done * @param int &$count If specified, this variable will be filled with the number of replacements done
* @param string $encoding (optional) The used internally by this function character encoding. * @param string $encoding (optional) The used internally by this function character encoding.
* If it is omitted, the platform character set will be used by default. * If it is omitted, the platform character set will be used by default.
* *
* @return array|string|null returns an array if the subject parameter is an array, or a string otherwise. * @return array|string|null returns an array if the subject parameter is an array, or a string otherwise.
* If matches are found, the new subject will be returned, otherwise subject will be returned * If matches are found, the new subject will be returned, otherwise subject will be returned

@ -1544,7 +1544,6 @@ class MySpace
$tpl = new Template('', false, false, false, false, false, false); $tpl = new Template('', false, false, false, false, false, false);
$data = null; $data = null;
$time_spent = 0; $time_spent = 0;
$progress = 0; $progress = 0;
$nb_progress_lp = 0; $nb_progress_lp = 0;
@ -1732,7 +1731,6 @@ class MySpace
$csv_row = []; $csv_row = [];
$csv_row[] = $course_title; $csv_row[] = $course_title;
$time_spent = 0; $time_spent = 0;
$progress = 0; $progress = 0;
$nb_progress_lp = 0; $nb_progress_lp = 0;

@ -247,7 +247,7 @@ class SystemAnnouncementManager
* Makes the announcement id visible only for groups in groups_array. * Makes the announcement id visible only for groups in groups_array.
* *
* @param int $announcement_id * @param int $announcement_id
* @param array $group_array array of group id * @param array $group_array array of group id
* *
* @return bool * @return bool
*/ */
@ -308,11 +308,11 @@ class SystemAnnouncementManager
/** /**
* Updates an announcement to the database. * Updates an announcement to the database.
* *
* @param int $id of the announcement * @param int $id of the announcement
* @param string $title title of the announcement * @param string $title title of the announcement
* @param string $content content of the announcement * @param string $content content of the announcement
* @param array $date_start start date (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) * @param array $date_start start date (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
* @param array $date_end end date of (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) * @param array $date_end end date of (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute)
* @param array $visibility * @param array $visibility
* @param array $lang * @param array $lang
* @param int $send_mail * @param int $send_mail

@ -2275,8 +2275,8 @@ class Tracking
* @param string code * @param string code
* @param int id (optional), filtered by exercise * @param int id (optional), filtered by exercise
* @param int id (optional), if param $sessionId is null * @param int id (optional), if param $sessionId is null
* it'll return results including sessions, 0 = session is not * it'll return results including sessions, 0 = session is not
* filtered * filtered
* *
* @return string value (number %) Which represents a round integer about the score average * @return string value (number %) Which represents a round integer about the score average
*/ */
@ -2582,7 +2582,6 @@ class Tracking
* course, it will take into account the progress that were not started. * course, it will take into account the progress that were not started.
* *
* @param int|array $studentId * @param int|array $studentId
* @param Course $course
* @param array $lpIdList Limit average to listed lp ids * @param array $lpIdList Limit average to listed lp ids
* @param SessionEntity $session Session id (optional), * @param SessionEntity $session Session id (optional),
* if parameter $sessionId is null(default) it'll return results including * if parameter $sessionId is null(default) it'll return results including
@ -2752,7 +2751,6 @@ class Tracking
* 3. And finally it will return the average between 1. and 2. * 3. And finally it will return the average between 1. and 2.
* *
* @param mixed $student_id Array of user ids or an user id * @param mixed $student_id Array of user ids or an user id
* @param Course $course
* @param array $lp_ids List of LP ids * @param array $lp_ids List of LP ids
* @param SessionEntity $session * @param SessionEntity $session
* if param $sessionId is null(default) it'll return results * if param $sessionId is null(default) it'll return results
@ -2763,9 +2761,9 @@ class Tracking
* @param bool $getOnlyBestAttempt * @param bool $getOnlyBestAttempt
* *
* @return string value (number %) Which represents a round integer explain in got in 3 * @return string value (number %) Which represents a round integer explain in got in 3
*
* @todo improve performance, when loading 1500 users with 20 lps the script dies * @todo improve performance, when loading 1500 users with 20 lps the script dies
* This function does not take the results of a Test out of a LP * This function does not take the results of a Test out of a LP
*
*/ */
public static function get_avg_student_score( public static function get_avg_student_score(
$student_id, $student_id,
@ -3146,7 +3144,7 @@ class Tracking
* @param int|array $student_id Array of user ids or an user id * @param int|array $student_id Array of user ids or an user id
* @param string $course_code Course code * @param string $course_code Course code
* @param array $lp_ids List of LP ids * @param array $lp_ids List of LP ids
* @param int $sessionId Session id (optional), if param $sessionId is 0(default) * @param int $sessionId Session id (optional), if param $sessionId is 0(default)
* it'll return results including sessions, 0 = session is not filtered * it'll return results including sessions, 0 = session is not filtered
* *
* @return string value (number %) Which represents a round integer explain in got in 3 * @return string value (number %) Which represents a round integer explain in got in 3
@ -3222,11 +3220,11 @@ class Tracking
/** /**
* This function gets time spent in learning path for a student inside a course. * This function gets time spent in learning path for a student inside a course.
* *
* @param int|array $student_id Student id(s) * @param int|array $student_id Student id(s)
* @param Course $course Course code * @param Course $course Course code
* @param array $lp_ids Limit average to listed lp ids * @param array $lp_ids Limit average to listed lp ids
* @param int $sessionId Session id (optional), if param $sessionId is null(default) * @param int $sessionId Session id (optional), if param $sessionId is null(default)
* it'll return results including sessions, 0 = session is not filtered * it'll return results including sessions, 0 = session is not filtered
* *
* @return int Total time in seconds * @return int Total time in seconds
*/ */
@ -4006,7 +4004,7 @@ class Tracking
* This function counts the number of post by course. * This function counts the number of post by course.
* *
* @param string $course_code * @param string $course_code
* @param int $sessionId (optional), if is null(default) it'll return results including sessions, * @param int $sessionId (optional), if is null(default) it'll return results including sessions,
* 0 = session is not filtered * 0 = session is not filtered
* @param int $groupId * @param int $groupId
* *
@ -4333,7 +4331,7 @@ class Tracking
/** /**
* Get course list inside a session from a student. * Get course list inside a session from a student.
* *
* @param int $user_id Student id * @param int $user_id Student id
* @param int $sessionId Session id (optional) * @param int $sessionId Session id (optional)
* *
* @return array Courses list * @return array Courses list
@ -5419,10 +5417,10 @@ class Tracking
/** /**
* Shows the user detail progress (when clicking in the details link). * Shows the user detail progress (when clicking in the details link).
* *
* @param int $userId * @param int $userId
* @param int $courseId * @param int $courseId
* @param int $sessionId * @param int $sessionId
* @param bool $showDiagram * @param bool $showDiagram
* *
* @return string html code * @return string html code
*/ */
@ -7703,13 +7701,13 @@ class Tracking
['cidReq' => $courseInfo['code'], 'id_session' => $sessionId, 'exerciseId' => $exercices['id']] ['cidReq' => $courseInfo['code'], 'id_session' => $sessionId, 'exerciseId' => $exercices['id']]
); );
if ($visibleReturn['value'] == true) { if (true == $visibleReturn['value']) {
$exercices['title'] = Display::url( $exercices['title'] = Display::url(
$exercices['title'], $exercices['title'],
$url, $url,
['target' => SESSION_LINK_TARGET] ['target' => SESSION_LINK_TARGET]
); );
} elseif ($exercices['active'] == -1) { } elseif (-1 == $exercices['active']) {
$exercices['title'] = sprintf(get_lang('XParenthesisDeleted'), $exercices['title']); $exercices['title'] = sprintf(get_lang('XParenthesisDeleted'), $exercices['title']);
} }
@ -7785,7 +7783,7 @@ class Tracking
$latestAttemptUrl $latestAttemptUrl
); );
$myScore = !empty($weighting) && intval($weighting) != 0 ? $score / $weighting : 0; $myScore = !empty($weighting) && 0 != intval($weighting) ? $score / $weighting : 0;
//@todo this function slows the page //@todo this function slows the page
if (is_int($userList)) { if (is_int($userList)) {
@ -7837,7 +7835,7 @@ class Tracking
$columnHeaders, $columnHeaders,
function ($columHeader, $key) use ($trackingColumns) { function ($columHeader, $key) use ($trackingColumns) {
if (!isset($trackingColumns['my_progress_lp'][$key]) if (!isset($trackingColumns['my_progress_lp'][$key])
|| $trackingColumns['my_progress_lp'][$key] == false || false == $trackingColumns['my_progress_lp'][$key]
) { ) {
return false; return false;
} }
@ -7901,7 +7899,7 @@ class Tracking
); );
if (in_array('lp', $columnHeadersKeys)) { if (in_array('lp', $columnHeadersKeys)) {
if ($learnpath['lp_visibility'] == 0) { if (0 == $learnpath['lp_visibility']) {
$learningpathData[] = $learnpath['lp_name']; $learningpathData[] = $learnpath['lp_name'];
} else { } else {
$learningpathData[] = Display::url( $learningpathData[] = Display::url(

@ -123,6 +123,7 @@ class UrlManager
$sql = "SELECT id FROM $table $sql = "SELECT id FROM $table
WHERE url = '".Database::escape_string($url)."' "; WHERE url = '".Database::escape_string($url)."' ";
$res = Database::query($sql); $res = Database::query($sql);
return (int) Database::num_rows($res); return (int) Database::num_rows($res);
} }

@ -3,7 +3,6 @@
use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField; use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
use Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch; use Chamilo\CoreBundle\Entity\ExtraFieldSavedSearch;
use Chamilo\CoreBundle\Entity\ResourceNode;
use Chamilo\CoreBundle\Entity\SkillRelUser; use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment; use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
@ -147,6 +146,7 @@ class UserManager
Display::addFlash( Display::addFlash(
Display::return_message(get_lang('A user creator is needed')) Display::return_message(get_lang('A user creator is needed'))
); );
return false; return false;
} }
@ -249,7 +249,7 @@ class UserManager
if (empty($expirationDate) || '0000-00-00 00:00:00' === $expirationDate) { if (empty($expirationDate) || '0000-00-00 00:00:00' === $expirationDate) {
$expirationDate = null; $expirationDate = null;
// Default expiration date // Default expiration date
// if there is a default duration of a valid account then // if there is a default duration of a valid account then
// we have to change the expiration_date accordingly // we have to change the expiration_date accordingly
// Accept 0000-00-00 00:00:00 as a null value to avoid issues with // Accept 0000-00-00 00:00:00 as a null value to avoid issues with
@ -2105,7 +2105,7 @@ class UserManager
$sqlf .= " AND filter = $field_filter "; $sqlf .= " AND filter = $field_filter ";
} }
$sqlf .= " ORDER BY `".$columns[$column]."` $sort_direction "; $sqlf .= " ORDER BY `".$columns[$column]."` $sort_direction ";
if ($number_of_items != 0) { if (0 != $number_of_items) {
$sqlf .= " LIMIT ".intval($from).','.intval($number_of_items); $sqlf .= " LIMIT ".intval($from).','.intval($number_of_items);
} }
$resf = Database::query($sqlf); $resf = Database::query($sqlf);
@ -4383,7 +4383,7 @@ class UserManager
* Get users followed by human resource manager. * Get users followed by human resource manager.
* *
* @param int $userId * @param int $userId
* @param int $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc) * @param int $userStatus Filter users by status (STUDENT, COURSEMANAGER, etc)
* @param bool $getOnlyUserId * @param bool $getOnlyUserId
* @param bool $getSql * @param bool $getSql
* @param bool $getCount * @param bool $getCount
@ -4393,7 +4393,7 @@ class UserManager
* @param string $direction * @param string $direction
* @param int $active * @param int $active
* @param string $lastConnectionDate * @param string $lastConnectionDate
* @param int $status the function is called by who? COURSEMANAGER, DRH? * @param int $status the function is called by who? COURSEMANAGER, DRH?
* @param string $keyword * @param string $keyword
* @param bool $checkSessionVisibility * @param bool $checkSessionVisibility
* *
@ -5065,8 +5065,8 @@ class UserManager
/** /**
* Subscribe boss to students. * Subscribe boss to students.
* *
* @param int $bossId The boss id * @param int $bossId The boss id
* @param array $usersId The users array * @param array $usersId The users array
* @param bool $deleteOtherAssignedUsers * @param bool $deleteOtherAssignedUsers
* *
* @return int Affected rows * @return int Affected rows
@ -5358,6 +5358,7 @@ class UserManager
if ($userId > 0) { if ($userId > 0) {
$userRelTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER); $userRelTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
return Database::select( return Database::select(
'DISTINCT friend_user_id AS boss_id', 'DISTINCT friend_user_id AS boss_id',
$userRelTable, $userRelTable,

@ -1046,6 +1046,7 @@ class Rest extends WebService
return $userList; return $userList;
} }
/** /**
* @param string $subject * @param string $subject
* @param string $text * @param string $text
@ -1174,7 +1175,6 @@ class Rest extends WebService
$idCampus, //$urlId $idCampus, //$urlId
true //AlsoSearchCode true //AlsoSearchCode
); );
} }
/** /**
@ -1260,7 +1260,7 @@ class Rest extends WebService
$params['course_language'] = $language; $params['course_language'] = $language;
foreach ($courseParam as $key => $value) { foreach ($courseParam as $key => $value) {
if (substr($key, 0, 6) === 'extra_') { //an extra field if ('extra_' === substr($key, 0, 6)) { //an extra field
$params[$key] = $value; $params[$key] = $value;
} }
} }

@ -4,16 +4,10 @@
use Chamilo\CoreBundle\DataFixtures\LanguageFixtures; use Chamilo\CoreBundle\DataFixtures\LanguageFixtures;
use Chamilo\CoreBundle\Entity\AccessUrl; use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Entity\BranchSync;
use Chamilo\CoreBundle\Entity\Group;
use Chamilo\CoreBundle\Entity\TicketCategory;
use Chamilo\CoreBundle\Entity\TicketPriority;
use Chamilo\CoreBundle\Entity\TicketProject;
use Chamilo\CoreBundle\Entity\User; use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\GroupRepository; use Chamilo\CoreBundle\Repository\GroupRepository;
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository; use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\ToolChain; use Chamilo\CoreBundle\ToolChain;
use Doctrine\Migrations\Configuration\Connection\ExistingConnection; use Doctrine\Migrations\Configuration\Connection\ExistingConnection;
use Doctrine\Migrations\Configuration\Migration\PhpFile; use Doctrine\Migrations\Configuration\Migration\PhpFile;
@ -21,7 +15,6 @@ use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Query\Query; use Doctrine\Migrations\Query\Query;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\Container as SymfonyContainer; use Symfony\Component\DependencyInjection\Container as SymfonyContainer;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
/* /*
* Chamilo LMS * Chamilo LMS
@ -423,7 +416,7 @@ function display_language_selection_box($name = 'language_list', $default_langua
// Displaying the box. // Displaying the box.
return Display::select( return Display::select(
'language_list', 'language_list',
array_column(LanguageFixtures::getLanguages(),'english_name', 'isocode'), array_column(LanguageFixtures::getLanguages(), 'english_name', 'isocode'),
$default_language, $default_language,
['class' => 'form-control'], ['class' => 'form-control'],
false false

@ -3,7 +3,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLp;
use ChamiloSession as Session; use ChamiloSession as Session;
/** /**

@ -173,4 +173,3 @@ switch ($type) {
case 'step': case 'step':
break; break;
}*/ }*/

@ -2,9 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLp;
/** /**
* This script contains the server part of the xajax interaction process. * This script contains the server part of the xajax interaction process.
* This script, in particular, enables the process of SCO's initialization. It * This script, in particular, enables the process of SCO's initialization. It

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* This script contains the server part of the xajax interaction process. The client part is located * This script contains the server part of the xajax interaction process. The client part is located
* in lp_api.php or other api's. * in lp_api.php or other api's.

@ -1,8 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLp;
use ChamiloSession as Session; use ChamiloSession as Session;
/** /**

@ -695,7 +695,7 @@ switch ($action) {
if (!$lp_found) { if (!$lp_found) {
require 'lp_list.php'; require 'lp_list.php';
} else { } else {
$result = ScormExport::exportToPdf($lpId, api_get_course_info());; $result = ScormExport::exportToPdf($lpId, api_get_course_info());
if (!$result) { if (!$result) {
require 'lp_list.php'; require 'lp_list.php';
} }

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use ChamiloSession as Session; use ChamiloSession as Session;
/** /**
@ -97,7 +96,6 @@ if (isset($is_success) && true === $is_success) {
Session::erase('finalItem'); Session::erase('finalItem');
} }
$tpl = new Template(); $tpl = new Template();
$tpl->assign('actions', $learnPath->build_action_menu(true)); $tpl->assign('actions', $learnPath->build_action_menu(true));
$tpl->assign('left', $learnPath->showBuildSideBar()); $tpl->assign('left', $learnPath->showBuildSideBar());

@ -69,4 +69,3 @@ $tpl->assign('actions', $lp->build_action_menu(true));
$tpl->assign('left', $lp->showBuildSideBar()); $tpl->assign('left', $lp->showBuildSideBar());
$tpl->assign('right', $right); $tpl->assign('right', $right);
$tpl->displayTwoColTemplate(); $tpl->displayTwoColTemplate();

@ -4,7 +4,6 @@
use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver; use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer; use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
use Chamilo\CourseBundle\Entity\CLp;
/** /**
* Script managing the learnpath upload. To best treat the uploaded file, make sure we can identify it. * Script managing the learnpath upload. To best treat the uploaded file, make sure we can identify it.

@ -120,7 +120,7 @@ if (is_object($lp)) {
echo $lp->build_action_menu(); echo $lp->build_action_menu();
echo '<div class="row">'; echo '<div class="row">';
echo '<div class="col-md-3">'; echo '<div class="col-md-3">';
echo $lp->return_new_tree();exit; echo $lp->return_new_tree(); exit;
echo '</div>'; echo '</div>';
echo '<div class="col-md-9">'; echo '<div class="col-md-9">';
echo $lp->display_item($lpItem); echo $lp->display_item($lpItem);

@ -9,7 +9,6 @@
* @author Eric Marguin <eric.marguin@dokeos.com> * @author Eric Marguin <eric.marguin@dokeos.com>
* @license GNU/GPL * @license GNU/GPL
*/ */
class OpenofficePresentation extends OpenofficeDocument class OpenofficePresentation extends OpenofficeDocument
{ {
public $take_slide_name; public $take_slide_name;

@ -1001,6 +1001,4 @@ class scorm extends learnpath
return api_detect_encoding($test_string); return api_detect_encoding($test_string);
} }
} }

@ -28,7 +28,6 @@ if ($allowSocial) {
} }
$interbreadcrumb[] = ['url' => 'inbox.php', 'name' => get_lang('Messages')]; $interbreadcrumb[] = ['url' => 'inbox.php', 'name' => get_lang('Messages')];
$actions = ''; $actions = '';
if ($allowMessage) { if ($allowMessage) {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.

@ -1,8 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
/** /**
* Homepage for the MySpace directory. * Homepage for the MySpace directory.
*/ */

@ -2,10 +2,10 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Usergroup;
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CLpCategory; use Chamilo\CourseBundle\Entity\CLpCategory;
use Chamilo\CourseBundle\Entity\CQuiz; use Chamilo\CourseBundle\Entity\CQuiz;
use Chamilo\CoreBundle\Entity\Usergroup;
use Chamilo\CourseBundle\Entity\CStudentPublication; use Chamilo\CourseBundle\Entity\CStudentPublication;
use ChamiloSession as Session; use ChamiloSession as Session;
@ -2132,7 +2132,6 @@ if (empty($details)) {
echo '<td class="text-center">'. echo '<td class="text-center">'.
api_convert_and_format_date($result->getSentDate()).' </td>'; api_convert_and_format_date($result->getSentDate()).' </td>';
echo '<td class="text-center">'; echo '<td class="text-center">';
if ($assignment && !empty($assignment->getExpiresOn())) { if ($assignment && !empty($assignment->getExpiresOn())) {
echo api_convert_and_format_date($assignment->getExpiresOn()); echo api_convert_and_format_date($assignment->getExpiresOn());

@ -650,10 +650,10 @@ echo Display::page_header($tool_name.' ('.$session_info['name'].') - '.$courseIn
?> ?>
<form name="formulaire" method="post" <form name="formulaire" method="post"
action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&course_id=<?php echo $courseId; ?>&id_session=<?php echo $id_session; ?><?php if (!empty($addProcess)) { action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&course_id=<?php echo $courseId; ?>&id_session=<?php echo $id_session; ?><?php if (!empty($addProcess)) {
echo '&add=true'; echo '&add=true';
} ?>" <?php if ($ajax_search) { } ?>" <?php if ($ajax_search) {
echo ' onsubmit="valide();"'; echo ' onsubmit="valide();"';
} ?>> } ?>>
<?php <?php
if ('multiple' === $add_type) { if ('multiple' === $add_type) {
if (is_array($extra_field_list)) { if (is_array($extra_field_list)) {

@ -115,9 +115,7 @@ if (isset($_GET['search']) && 'advanced' === $_GET['search']) {
</div> </div>
</form>'; </form>';
echo Display::toolbarAction('category', [$actionsLeft, $actionsRight]); echo Display::toolbarAction('category', [$actionsLeft, $actionsRight]); ?>
?>
<form method="post" action="<?php echo api_get_self(); ?>?action=delete&sort=<?php echo $sort; ?>" <form method="post" action="<?php echo api_get_self(); ?>?action=delete&sort=<?php echo $sort; ?>"
onsubmit="if(!confirm('<?php echo get_lang('Please confirm your choice'); ?>')) return false;"> onsubmit="if(!confirm('<?php echo get_lang('Please confirm your choice'); ?>')) return false;">
<?php <?php

@ -166,4 +166,3 @@ $form->setDefaults(['id_coach' => $selected]);
$form->display(); $form->display();
Display::display_footer(); Display::display_footer();

@ -457,7 +457,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
} }
Display::display_header($tool_name); Display::display_header($tool_name);
$actions = '<a href="../session/session_list.php">'. $actions = '<a href="../session/session_list.php">'.
Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Administration'), '', ICON_SIZE_MEDIUM). Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Administration'), '', ICON_SIZE_MEDIUM).
'</a>'; '</a>';
echo Display::toolbarAction('session_import', [$actions]); echo Display::toolbarAction('session_import', [$actions]);

@ -7,7 +7,6 @@ use Chamilo\CoreBundle\Entity\Usergroup;
/** /**
* @author Julio Montoya <gugli100@gmail.com> * @author Julio Montoya <gugli100@gmail.com>
*/ */
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';

@ -1256,7 +1256,6 @@ if (isset($questions) && is_array($questions)) {
} }
foreach ($questions as $key => &$question) { foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type']; $ch_type = 'ch_'.$question['type'];
$questionNumber = $questionCounter; $questionNumber = $questionCounter;
$display = new $ch_type(); $display = new $ch_type();

@ -41,7 +41,7 @@ if ($hashIsValid && $course) {
api_get_session_entity() api_get_session_entity()
); );
if ($invitation) { if ($invitation) {
$link = SurveyUtil::generateFillSurveyLink($survey,$invitationCode, $course, $sessionId); $link = SurveyUtil::generateFillSurveyLink($survey, $invitationCode, $course, $sessionId);
header('Location: '.$link); header('Location: '.$link);
exit; exit;
} }

@ -9,7 +9,6 @@ use Chamilo\CoreBundle\Framework\Container;
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup,
* refactoring and rewriting large parts of the code * refactoring and rewriting large parts of the code
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$htmlHeadXtra[] = '<script>'.api_get_language_translate_html().'</script>'; $htmlHeadXtra[] = '<script>'.api_get_language_translate_html().'</script>';

@ -1215,7 +1215,7 @@ class SurveyManager
$survey_id = (int) $survey_id; $survey_id = (int) $survey_id;
/*$sql = "DELETE FROM $table_survey_question /*$sql = "DELETE FROM $table_survey_question
WHERE $course_condition survey_id = '".$survey_id."'"; WHERE $course_condition survey_id = '".$survey_id."'";
// Deleting the survey questions // Deleting the survey questions
Database::query($sql);*/ Database::query($sql);*/

@ -2,9 +2,9 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session as SessionEntity; use Chamilo\CoreBundle\Entity\Session as SessionEntity;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CourseBundle\Entity\CGroup; use Chamilo\CourseBundle\Entity\CGroup;
use Chamilo\CourseBundle\Entity\CSurvey; use Chamilo\CourseBundle\Entity\CSurvey;
use Chamilo\CourseBundle\Entity\CSurveyAnswer; use Chamilo\CourseBundle\Entity\CSurveyAnswer;
@ -595,7 +595,7 @@ class SurveyUtil
// Getting the question information // Getting the question information
/*$sql = "SELECT * FROM $table_survey_question /*$sql = "SELECT * FROM $table_survey_question
WHERE WHERE
survey_id = $surveyId AND survey_id = $surveyId AND
survey_question NOT LIKE '%{{%' AND survey_question NOT LIKE '%{{%' AND
type <>'pagebreak' type <>'pagebreak'
@ -928,10 +928,10 @@ class SurveyUtil
/** /**
* This functions displays the complete reporting. * This functions displays the complete reporting.
* *
* @param int $userId * @param int $userId
* @param bool $addActionBar * @param bool $addActionBar
* @param bool $addFilters * @param bool $addFilters
* @param bool $addExtraFields * @param bool $addExtraFields
* *
* @return string * @return string
*/ */
@ -2508,10 +2508,10 @@ class SurveyUtil
} }
/** /**
* @param int $courseId * @param int $courseId
* @param int $sessionId * @param int $sessionId
* @param int $groupId * @param int $groupId
* @param int $surveyId * @param int $surveyId
* *
* @return int * @return int
*/ */
@ -2736,6 +2736,7 @@ class SurveyUtil
* @param int $surveyId * @param int $surveyId
* *
* @return array Database rows matching the survey code * @return array Database rows matching the survey code
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* *
* @version September 2007 * @version September 2007
@ -3219,7 +3220,7 @@ class SurveyUtil
$search_restriction = "WHERE c_id = $course_id"; $search_restriction = "WHERE c_id = $course_id";
} }
$sql = "SELECT count(iid) AS total_number_of_items $sql = "SELECT count(iid) AS total_number_of_items
FROM $table_survey $search_restriction"; FROM $table_survey $search_restriction";
$res = Database::query($sql); $res = Database::query($sql);
$obj = Database::fetch_object($res); $obj = Database::fetch_object($res);
@ -4019,8 +4020,7 @@ class SurveyUtil
} }
/** /**
* @param string $code invitation code * @param string $code invitation code
* @param Course $course
* @param int $sessionId * @param int $sessionId
* *
* @return string * @return string

@ -127,7 +127,7 @@ $ticket_id = (int) $_REQUEST['ticket_id'];
$ticket = TicketManager::get_ticket_detail_by_id($ticket_id); $ticket = TicketManager::get_ticket_detail_by_id($ticket_id);
if (empty($ticket)) { if (empty($ticket)) {
api_not_allowed(true); api_not_allowed(true);
} }
$projectId = $ticket['ticket']['project_id']; $projectId = $ticket['ticket']['project_id'];
$userIsAllowInProject = TicketManager::userIsAllowInProject($userInfo, $projectId); $userIsAllowInProject = TicketManager::userIsAllowInProject($userInfo, $projectId);
$allowEdition = $ticket['ticket']['assigned_last_user'] == $user_id || $allowEdition = $ticket['ticket']['assigned_last_user'] == $user_id ||
@ -202,49 +202,49 @@ foreach ($messages as $message) {
$subject = get_lang('Re:').': '.Security::remove_XSS($ticket['ticket']['subject']); $subject = get_lang('Re:').': '.Security::remove_XSS($ticket['ticket']['subject']);
if ($allowEdition && if ($allowEdition &&
$ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED && TicketManager::STATUS_FORWARDED != $ticket['ticket']['status_id'] &&
$ticket['ticket']['status_id'] != TicketManager::STATUS_CLOSE TicketManager::STATUS_CLOSE != $ticket['ticket']['status_id']
) { ) {
$form = getForm($ticket['ticket']); $form = getForm($ticket['ticket']);
$formToShow = $form->returnForm(); $formToShow = $form->returnForm();
if ($form->validate()) { if ($form->validate()) {
$ticket_id = (int) $_POST['ticket_id']; $ticket_id = (int) $_POST['ticket_id'];
$messageToSend = ''; $messageToSend = '';
$message = isset($_POST['confirmation']) ? true : false; $message = isset($_POST['confirmation']) ? true : false;
$file_attachments = $_FILES; $file_attachments = $_FILES;
if ($isAdmin) { if ($isAdmin) {
$oldUserId = $ticket['ticket']['assigned_last_user']; $oldUserId = $ticket['ticket']['assigned_last_user'];
if (isset($_POST['assigned_last_user']) && !empty($_POST['assigned_last_user']) && if (isset($_POST['assigned_last_user']) && !empty($_POST['assigned_last_user']) &&
$_POST['assigned_last_user'] != $oldUserId $_POST['assigned_last_user'] != $oldUserId
) { ) {
TicketManager::assignTicketToUser( TicketManager::assignTicketToUser(
$ticket_id, $ticket_id,
$_POST['assigned_last_user'] $_POST['assigned_last_user']
); );
$oldUserName = '-'; $oldUserName = '-';
if (!empty($oldUserId)) { if (!empty($oldUserId)) {
$oldUserInfo = api_get_user_info($oldUserId); $oldUserInfo = api_get_user_info($oldUserId);
$oldUserName = $oldUserInfo['complete_name_with_message_link']; $oldUserName = $oldUserInfo['complete_name_with_message_link'];
} }
$userCompleteName = '-'; $userCompleteName = '-';
if (!empty($_POST['assigned_last_user'])) { if (!empty($_POST['assigned_last_user'])) {
$userInfo = api_get_user_info( $userInfo = api_get_user_info(
$_POST['assigned_last_user'] $_POST['assigned_last_user']
); );
$userCompleteName = $userInfo['complete_name_with_message_link']; $userCompleteName = $userInfo['complete_name_with_message_link'];
} }
$messageToSend .= sprintf( $messageToSend .= sprintf(
get_lang('Assignee changed from %s to %s'), get_lang('Assignee changed from %s to %s'),
$oldUserName, $oldUserName,
$userCompleteName $userCompleteName
).'<br />'; ).'<br />';
} }
TicketManager::updateTicket( TicketManager::updateTicket(
[ [
'priority_id' => (int) $_POST['priority_id'], 'priority_id' => (int) $_POST['priority_id'],
'status_id' => (int) $_POST['status_id'], 'status_id' => (int) $_POST['status_id'],
@ -253,55 +253,55 @@ if ($allowEdition &&
api_get_user_id() api_get_user_id()
); );
if ($_POST['priority_id'] != $ticket['ticket']['priority_id']) { if ($_POST['priority_id'] != $ticket['ticket']['priority_id']) {
$newPriority = TicketManager::getPriority( $newPriority = TicketManager::getPriority(
$_POST['priority_id'] $_POST['priority_id']
); );
$newPriorityTitle = '-'; $newPriorityTitle = '-';
if ($newPriority) { if ($newPriority) {
$newPriorityTitle = $newPriority->getName(); $newPriorityTitle = $newPriority->getName();
} }
$oldPriority = TicketManager::getPriority( $oldPriority = TicketManager::getPriority(
$ticket['ticket']['priority_id'] $ticket['ticket']['priority_id']
); );
$oldPriorityTitle = '-'; $oldPriorityTitle = '-';
if ($oldPriority) { if ($oldPriority) {
$oldPriorityTitle = $oldPriority->getName(); $oldPriorityTitle = $oldPriority->getName();
} }
$messageToSend .= sprintf( $messageToSend .= sprintf(
get_lang('Priority changed from %s to %s'), get_lang('Priority changed from %s to %s'),
$oldPriorityTitle, $oldPriorityTitle,
$newPriorityTitle $newPriorityTitle
).'<br />'; ).'<br />';
} }
if ($_POST['status_id'] != $ticket['ticket']['status_id']) { if ($_POST['status_id'] != $ticket['ticket']['status_id']) {
$newStatus = TicketManager::getStatus( $newStatus = TicketManager::getStatus(
$_POST['status_id'] $_POST['status_id']
); );
$newTitle = '-'; $newTitle = '-';
if ($newStatus) { if ($newStatus) {
$newTitle = $newStatus->getName(); $newTitle = $newStatus->getName();
} }
$oldStatus = TicketManager::getStatus( $oldStatus = TicketManager::getStatus(
$ticket['ticket']['status_id'] $ticket['ticket']['status_id']
); );
$oldStatusTitle = '-'; $oldStatusTitle = '-';
if ($oldStatus) { if ($oldStatus) {
$oldStatusTitle = $oldStatus->getName(); $oldStatusTitle = $oldStatus->getName();
} }
$messageToSend .= sprintf( $messageToSend .= sprintf(
get_lang('Status changed from %s to %s'), get_lang('Status changed from %s to %s'),
$oldStatusTitle, $oldStatusTitle,
$newTitle $newTitle
).'<br />'; ).'<br />';
}
} }
}
$messageToSend .= $_POST['content']; $messageToSend .= $_POST['content'];
TicketManager::insertMessage( TicketManager::insertMessage(
$ticket_id, $ticket_id,
$_POST['subject'], $_POST['subject'],
$messageToSend, $messageToSend,
@ -311,17 +311,17 @@ if ($allowEdition &&
$message $message
); );
TicketManager::sendNotification( TicketManager::sendNotification(
$ticket_id, $ticket_id,
get_lang('TicketUpdate successful'), get_lang('TicketUpdate successful'),
$messageToSend $messageToSend
); );
Display::addFlash(Display::return_message(get_lang('Saved.'))); Display::addFlash(Display::return_message(get_lang('Saved.')));
header('Location:'.api_get_self().'?ticket_id='.$ticket_id); header('Location:'.api_get_self().'?ticket_id='.$ticket_id);
exit; exit;
}
} }
}
Display::display_header(); Display::display_header();
echo '<div class="actions">'; echo '<div class="actions">';

@ -309,7 +309,7 @@ if (!empty($projectId)) {
); );
if ($isAllow) { if ($isAllow) {
echo Display::toolbarAction('toolbar-options', [$options,]); echo Display::toolbarAction('toolbar-options', [$options]);
} }
$advancedSearchForm = new FormValidator( $advancedSearchForm = new FormValidator(

@ -234,25 +234,25 @@ if (!empty($courseList)) {
if ($global) { if ($global) {
$qb = $quizRepo->getResourcesByCourse($course); $qb = $quizRepo->getResourcesByCourse($course);
$exercises = $qb->getQuery()->getResult(); $exercises = $qb->getQuery()->getResult();
/*$sql = "SELECT quiz.title, iid, session_id /*$sql = "SELECT quiz.title, iid, session_id
FROM $quizTable AS quiz FROM $quizTable AS quiz
WHERE c_id = $courseId AND active = 1 WHERE c_id = $courseId AND active = 1
ORDER BY session_id, quiz.title ASC";*/ ORDER BY session_id, quiz.title ASC";*/
} else { } else {
//$sessionCondition = api_get_session_condition($sessionId, true, false); //$sessionCondition = api_get_session_condition($sessionId, true, false);
if (!empty($exerciseId)) { if (!empty($exerciseId)) {
$exercises = []; $exercises = [];
$exercises[] = $quizRepo->find($exerciseId); $exercises[] = $quizRepo->find($exerciseId);
/* /*
$sql = "SELECT quiz.title, iid, session_id $sql = "SELECT quiz.title, iid, session_id
FROM $quizTable AS quiz FROM $quizTable AS quiz
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
active = 1 AND active = 1 AND
id = $exerciseId id = $exerciseId
$sessionCondition $sessionCondition
ORDER BY session_id, quiz.title ASC"; ORDER BY session_id, quiz.title ASC";
*/ */
} else { } else {
$qb = $quizRepo->getResourcesByCourse($course, api_get_session_entity()); $qb = $quizRepo->getResourcesByCourse($course, api_get_session_entity());
$exercises = $qb->getQuery()->getResult(); $exercises = $qb->getQuery()->getResult();

@ -34,7 +34,7 @@ if (empty($careerInfo)) {
} }
$allow = UserManager::userHasCareer($userId, $careerId) || api_is_platform_admin() || api_is_drh(); $allow = UserManager::userHasCareer($userId, $careerId) || api_is_platform_admin() || api_is_drh();
if ($allow === false) { if (false === $allow) {
api_not_allowed(true); api_not_allowed(true);
} }

@ -13,7 +13,6 @@ use Chamilo\CoreBundle\Framework\Container;
* @author Roan Embrechts * @author Roan Embrechts
* @author Julio Montoya, Several fixes * @author Julio Montoya, Several fixes
*/ */
$use_anonymous = true; $use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_USER; $current_course_tool = TOOL_USER;
@ -627,7 +626,6 @@ if ($canRead) {
Display::return_icon('pdf.png', get_lang('Export to PDF'), [], ICON_SIZE_MEDIUM).'</a> '; Display::return_icon('pdf.png', get_lang('Export to PDF'), [], ICON_SIZE_MEDIUM).'</a> ';
} }
// Build search-form // Build search-form
$form = new FormValidator( $form = new FormValidator(
'search_user', 'search_user',

@ -110,7 +110,6 @@ if (!empty($my_folder_data)) {
} }
} }
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('Assignments'), 'name' => get_lang('Assignments'),

@ -282,17 +282,17 @@ function getWorkList($id, $my_folder_data, $add_in_where_query = null, $course_i
if ($is_allowed_to_edit) { if ($is_allowed_to_edit) {
$qb->andWhere($qb->expr()->in('resource.active', [1, 0])); $qb->andWhere($qb->expr()->in('resource.active', [1, 0]));
$qb->andWhere($qb->expr()->isNull('resource.publicationParent')); $qb->andWhere($qb->expr()->isNull('resource.publicationParent'));
/*$active_condition = ' active IN (0, 1)'; /*$active_condition = ' active IN (0, 1)';
$sql = "SELECT * FROM $work_table $sql = "SELECT * FROM $work_table
WHERE WHERE
c_id = $course_id c_id = $course_id
$add_in_where_query $add_in_where_query
$condition_session AND $condition_session AND
$active_condition AND $active_condition AND
(parent_id = 0) (parent_id = 0)
$contains_file_query AND $contains_file_query AND
post_group_id = $groupIid post_group_id = $groupIid
ORDER BY sent_date DESC";*/ ORDER BY sent_date DESC";*/
} else { } else {
if (!empty($group_id)) { if (!empty($group_id)) {
// set to select only messages posted by the user's group // set to select only messages posted by the user's group
@ -1236,7 +1236,6 @@ function getWorkListStudent(
->setMaxResults($limit) ->setMaxResults($limit)
; ;
/*$sql = "$select /*$sql = "$select
FROM $workTable w FROM $workTable w
LEFT JOIN $workTableAssignment a LEFT JOIN $workTableAssignment a
@ -2266,7 +2265,7 @@ function get_work_user_list(
} }
$feedback = ''; $feedback = '';
$count = count($studentPublication->getComments());// getWorkCommentCount($item_id, $course_info); $count = count($studentPublication->getComments()); // getWorkCommentCount($item_id, $course_info);
if (null !== $count && !empty($count)) { if (null !== $count && !empty($count)) {
if ($qualification_exists) { if ($qualification_exists) {
$feedback .= ' '; $feedback .= ' ';
@ -3787,8 +3786,8 @@ function getWorkDescriptionToolbar()
function getWorkComments(CStudentPublication $work) function getWorkComments(CStudentPublication $work)
{ {
$comments = $work->getComments(); $comments = $work->getComments();
$commentList = []; $commentList = [];
if (!empty($comments)) { if (!empty($comments)) {
foreach ($comments as $comment) { foreach ($comments as $comment) {
//$userInfo = api_get_user_info($comment['user_id']); //$userInfo = api_get_user_info($comment['user_id']);
@ -5190,23 +5189,23 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
; ;
$em->persist($publication); $em->persist($publication);
/*$sql = "INSERT INTO $table SET /*$sql = "INSERT INTO $table SET
c_id = $course_id , c_id = $course_id ,
$expiryDateCondition $expiryDateCondition
$endOnCondition $endOnCondition
add_to_calendar = $agendaId, add_to_calendar = $agendaId,
enable_qualification = '$qualification', enable_qualification = '$qualification',
publication_id = '$workId'"; publication_id = '$workId'";
Database::query($sql); Database::query($sql);
$my_last_id = Database::insert_id(); $my_last_id = Database::insert_id();
if ($my_last_id) { if ($my_last_id) {
$sql = "UPDATE $workTable SET $sql = "UPDATE $workTable SET
has_properties = $my_last_id, has_properties = $my_last_id,
view_properties = 1 view_properties = 1
WHERE iid = $workId"; WHERE iid = $workId";
Database::query($sql); Database::query($sql);
}*/ }*/
} else { } else {
$assignment = $em->getRepository(CStudentPublicationAssignment::class)->find($data['iid']); $assignment = $em->getRepository(CStudentPublicationAssignment::class)->find($data['iid']);
/*$sql = "UPDATE $table SET /*$sql = "UPDATE $table SET
@ -5306,7 +5305,7 @@ function deleteAllWorkPerUser(User $user, Course $course)
/** /**
* @param int $item_id * @param int $item_id
* @param Course $course course info * @param Course $course course info
* *
* @return bool * @return bool
*/ */

@ -18,7 +18,6 @@ if (empty($workId) || empty($courseInfo)) {
} }
$course = api_get_course_entity(); $course = api_get_course_entity();
// Student publications are saved with the iid in a LP // Student publications are saved with the iid in a LP
$origin = api_get_origin(); $origin = api_get_origin();
if ('learnpath' === $origin) { if ('learnpath' === $origin) {

@ -4,8 +4,6 @@
* Strings to Dutch L10n. * Strings to Dutch L10n.
* *
* @author Yannick Warnier <yannick.warnier@beeznest.com> * @author Yannick Warnier <yannick.warnier@beeznest.com>
*
* @package chamilo.plugin.azure_active_directory
*/ */
$strings['plugin_title'] = 'Azure Active Directory'; $strings['plugin_title'] = 'Azure Active Directory';
$strings['plugin_comment'] = 'Sta authenticatie met Microsoft\'s Azure Active Directory toe'; $strings['plugin_comment'] = 'Sta authenticatie met Microsoft\'s Azure Active Directory toe';

@ -4,8 +4,6 @@
* Strings to English L10n. * Strings to English L10n.
* *
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*
* @package chamilo.plugin.azure_active_directory
*/ */
$strings['plugin_title'] = 'Azure Active Directory'; $strings['plugin_title'] = 'Azure Active Directory';
$strings['plugin_comment'] = 'Allow authentication with Microsoft\'s Azure Active Directory'; $strings['plugin_comment'] = 'Allow authentication with Microsoft\'s Azure Active Directory';

@ -4,8 +4,6 @@
* Strings to French L10n. * Strings to French L10n.
* *
* @author Yannick Warnier <yannick.warnier@beeznest.com> * @author Yannick Warnier <yannick.warnier@beeznest.com>
*
* @package chamilo.plugin.azure_active_directory
*/ */
$strings['plugin_title'] = 'Azure Active Directory'; $strings['plugin_title'] = 'Azure Active Directory';
$strings['plugin_comment'] = 'Permet l\'authentification des utilisateurs via Azure Active Directory de Microsoft'; $strings['plugin_comment'] = 'Permet l\'authentification des utilisateurs via Azure Active Directory de Microsoft';

@ -4,8 +4,6 @@
* Strings to Spanish L10n. * Strings to Spanish L10n.
* *
* @author Yannick Warnier <yannick.warnier@beeznest.com> * @author Yannick Warnier <yannick.warnier@beeznest.com>
*
* @package chamilo.plugin.azure_active_directory
*/ */
$strings['plugin_title'] = 'Azure Active Directory'; $strings['plugin_title'] = 'Azure Active Directory';
$strings['plugin_comment'] = 'Permite la autenticación de usuarios por Azure Active Directory de Microsoft'; $strings['plugin_comment'] = 'Permite la autenticación de usuarios por Azure Active Directory de Microsoft';

@ -7,8 +7,6 @@ use TheNetworg\OAuth2\Client\Provider\Azure;
* AzureActiveDirectory plugin class. * AzureActiveDirectory plugin class.
* *
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*
* @package chamilo.plugin.azure_active_directory
*/ */
class AzureActiveDirectory extends Plugin class AzureActiveDirectory extends Plugin
{ {

@ -76,7 +76,7 @@ try {
if (empty($userId)) { if (empty($userId)) {
// If we didn't find the user // If we didn't find the user
if ($plugin->get(AzureActiveDirectory::SETTING_PROVISION_USERS) === 'true') { if ('true' === $plugin->get(AzureActiveDirectory::SETTING_PROVISION_USERS)) {
// If the option is set to create users, create it // If the option is set to create users, create it
$userId = UserManager::create_user( $userId = UserManager::create_user(
$me['givenName'], $me['givenName'],
@ -112,7 +112,7 @@ try {
throw new Exception('User '.$userId.' not found.'); throw new Exception('User '.$userId.' not found.');
} }
if ($userInfo['active'] != '1') { if ('1' != $userInfo['active']) {
throw new Exception(get_lang('AccountInactive')); throw new Exception(get_lang('AccountInactive'));
} }
} catch (Exception $exception) { } catch (Exception $exception) {

@ -2,9 +2,7 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CourseBundle\Entity\CLp; use Chamilo\CourseBundle\Entity\CLp;
use Chamilo\UserBundle\Entity\User;
/** /**
* Responses to AJAX calls. * Responses to AJAX calls.

@ -2,7 +2,6 @@
/* For license terms, see /license.txt */ /* For license terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\CourseBundle\Entity\CLp; use Chamilo\CourseBundle\Entity\CLp;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;

@ -173,7 +173,6 @@ if ($form->validate()) {
} }
throw new Exception('@todo custom certificate upload'); throw new Exception('@todo custom certificate upload');
if ($_FILES[$field]['size']) { if ($_FILES[$field]['size']) {
$newPicture = api_upload_file( $newPicture = api_upload_file(
'certificates', 'certificates',

@ -8,7 +8,12 @@ use Chamilo\PluginBundle\WhispeakAuth\Request\ApiRequest;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
use ChamiloSession; use ChamiloSession;
use Display; use Display;
use Exception;
use Exercise;
use learnpath;
use Login; use Login;
use Template;
use UserManager;
use WhispeakAuthPlugin; use WhispeakAuthPlugin;
/** /**
@ -17,12 +22,12 @@ use WhispeakAuthPlugin;
class AuthenticationController extends BaseController class AuthenticationController extends BaseController
{ {
/** /**
* @throws \Exception * @throws Exception
*/ */
public function index() public function index()
{ {
if (!$this->plugin->toolIsEnabled()) { if (!$this->plugin->toolIsEnabled()) {
throw new \Exception(get_lang('NotAllowed')); throw new Exception(get_lang('NotAllowed'));
} }
/** @var array $lpQuestionInfo */ /** @var array $lpQuestionInfo */
@ -46,9 +51,9 @@ class AuthenticationController extends BaseController
/** @var array $lpItemInfo */ /** @var array $lpItemInfo */
$lpItemInfo = ChamiloSession::read(WhispeakAuthPlugin::SESSION_LP_ITEM, []); $lpItemInfo = ChamiloSession::read(WhispeakAuthPlugin::SESSION_LP_ITEM, []);
/** @var \learnpath $oLp */ /** @var learnpath $oLp */
$oLp = ChamiloSession::read('oLP', null); $oLp = ChamiloSession::read('oLP', null);
/** @var \Exercise $objExercise */ /** @var Exercise $objExercise */
$objExercise = ChamiloSession::read('objExercise', null); $objExercise = ChamiloSession::read('objExercise', null);
$isAuthOnLp = !empty($lpItemInfo) && !empty($oLp); $isAuthOnLp = !empty($lpItemInfo) && !empty($oLp);
@ -93,7 +98,7 @@ class AuthenticationController extends BaseController
ChamiloSession::write(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT, $response['token']); ChamiloSession::write(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT, $response['token']);
if (!empty($lpQuestionInfo) && empty($lpItemInfo)) { if (!empty($lpQuestionInfo) && empty($lpItemInfo)) {
$template = new \Template('', $showFullPage, $showFullPage, false, true, false); $template = new Template('', $showFullPage, $showFullPage, false, true, false);
$template->assign('show_form', $showForm); $template->assign('show_form', $showForm);
$template->assign('sample_text', $response['text']); $template->assign('sample_text', $response['text']);
@ -111,7 +116,7 @@ class AuthenticationController extends BaseController
} }
/** /**
* @throws \Exception * @throws Exception
*/ */
public function ajax() public function ajax()
{ {
@ -125,7 +130,7 @@ class AuthenticationController extends BaseController
} }
if (!$isAllowed || !$this->plugin->toolIsEnabled()) { if (!$isAllowed || !$this->plugin->toolIsEnabled()) {
throw new \Exception(get_lang('NotAllowed')); throw new Exception(get_lang('NotAllowed'));
} }
if (!empty($user2fa)) { if (!empty($user2fa)) {
@ -134,11 +139,11 @@ class AuthenticationController extends BaseController
$user = api_get_user_entity($userId); $user = api_get_user_entity($userId);
} else { } else {
/** @var User|null $user */ /** @var User|null $user */
$user = \UserManager::getRepository()->findOneBy(['username' => $_POST['username']]); $user = UserManager::getRepository()->findOneBy(['username' => $_POST['username']]);
} }
if (!$user) { if (!$user) {
throw new \Exception(get_lang('NotFound')); throw new Exception(get_lang('NotFound'));
} }
$audioFilePath = $this->uploadAudioFile($user); $audioFilePath = $this->uploadAudioFile($user);
@ -147,15 +152,15 @@ class AuthenticationController extends BaseController
$maxAttempts = $this->plugin->getMaxAttempts(); $maxAttempts = $this->plugin->getMaxAttempts();
if ($maxAttempts && $failedLogins >= $maxAttempts) { if ($maxAttempts && $failedLogins >= $maxAttempts) {
throw new \Exception($this->plugin->get_lang('MaxAttemptsReached')); throw new Exception($this->plugin->get_lang('MaxAttemptsReached'));
} }
$token = \ChamiloSession::read(\WhispeakAuthPlugin::SESSION_SENTENCE_TEXT); $token = ChamiloSession::read(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT);
$request = new ApiRequest(); $request = new ApiRequest();
$success = $request->performAuthentication($token, $user, $audioFilePath); $success = $request->performAuthentication($token, $user, $audioFilePath);
\ChamiloSession::erase(\WhispeakAuthPlugin::SESSION_SENTENCE_TEXT); ChamiloSession::erase(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT);
/** @var array $lpItemInfo */ /** @var array $lpItemInfo */
$lpItemInfo = ChamiloSession::read(WhispeakAuthPlugin::SESSION_LP_ITEM, []); $lpItemInfo = ChamiloSession::read(WhispeakAuthPlugin::SESSION_LP_ITEM, []);
@ -322,7 +327,7 @@ class AuthenticationController extends BaseController
$pageTitle = $this->plugin->get_title(); $pageTitle = $this->plugin->get_title();
$template = new \Template($pageTitle, $isFullPage, $isFullPage); $template = new Template($pageTitle, $isFullPage, $isFullPage);
foreach ($variables as $key => $value) { foreach ($variables as $key => $value) {
$template->assign($key, $value); $template->assign($key, $value);

@ -6,6 +6,7 @@ namespace Chamilo\PluginBundle\WhispeakAuth\Controller;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
use FFMpeg\FFMpeg; use FFMpeg\FFMpeg;
use FFMpeg\Format\Audio\Wav; use FFMpeg\Format\Audio\Wav;
use WhispeakAuthPlugin;
/** /**
* Class BaseController. * Class BaseController.
@ -13,7 +14,7 @@ use FFMpeg\Format\Audio\Wav;
abstract class BaseController abstract class BaseController
{ {
/** /**
* @var \WhispeakAuthPlugin * @var WhispeakAuthPlugin
*/ */
protected $plugin; protected $plugin;
@ -22,7 +23,7 @@ abstract class BaseController
*/ */
public function __construct() public function __construct()
{ {
$this->plugin = \WhispeakAuthPlugin::create(); $this->plugin = WhispeakAuthPlugin::create();
} }
/** /**

@ -4,6 +4,11 @@
namespace Chamilo\PluginBundle\WhispeakAuth\Controller; namespace Chamilo\PluginBundle\WhispeakAuth\Controller;
use Chamilo\PluginBundle\WhispeakAuth\Request\ApiRequest; use Chamilo\PluginBundle\WhispeakAuth\Request\ApiRequest;
use ChamiloSession;
use Display;
use Exception;
use Template;
use WhispeakAuthPlugin;
/** /**
* Class EnrollmentController. * Class EnrollmentController.
@ -11,26 +16,26 @@ use Chamilo\PluginBundle\WhispeakAuth\Request\ApiRequest;
class EnrollmentController extends BaseController class EnrollmentController extends BaseController
{ {
/** /**
* @throws \Exception * @throws Exception
*/ */
public function index() public function index()
{ {
if (!$this->plugin->toolIsEnabled()) { if (!$this->plugin->toolIsEnabled()) {
throw new \Exception(get_lang('NotAllowed')); throw new Exception(get_lang('NotAllowed'));
} }
$user = api_get_user_entity(api_get_user_id()); $user = api_get_user_entity(api_get_user_id());
$userIsEnrolled = \WhispeakAuthPlugin::checkUserIsEnrolled($user->getId()); $userIsEnrolled = WhispeakAuthPlugin::checkUserIsEnrolled($user->getId());
if ($userIsEnrolled) { if ($userIsEnrolled) {
throw new \Exception($this->plugin->get_lang('SpeechAuthAlreadyEnrolled')); throw new Exception($this->plugin->get_lang('SpeechAuthAlreadyEnrolled'));
} }
$request = new ApiRequest(); $request = new ApiRequest();
$response = $request->createEnrollmentSessionToken($user); $response = $request->createEnrollmentSessionToken($user);
\ChamiloSession::write(\WhispeakAuthPlugin::SESSION_SENTENCE_TEXT, $response['token']); ChamiloSession::write(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT, $response['token']);
$this->displayPage( $this->displayPage(
true, true,
@ -42,32 +47,32 @@ class EnrollmentController extends BaseController
} }
/** /**
* @throws \Exception * @throws Exception
*/ */
public function ajax() public function ajax()
{ {
if (!$this->plugin->toolIsEnabled() || empty($_FILES['audio'])) { if (!$this->plugin->toolIsEnabled() || empty($_FILES['audio'])) {
throw new \Exception(get_lang('NotAllowed')); throw new Exception(get_lang('NotAllowed'));
} }
$user = api_get_user_entity(api_get_user_id()); $user = api_get_user_entity(api_get_user_id());
$audioFilePath = $this->uploadAudioFile($user); $audioFilePath = $this->uploadAudioFile($user);
$token = \ChamiloSession::read(\WhispeakAuthPlugin::SESSION_SENTENCE_TEXT); $token = ChamiloSession::read(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT);
if (empty($token)) { if (empty($token)) {
throw new \Exception($this->plugin->get_lang('EnrollmentFailed')); throw new Exception($this->plugin->get_lang('EnrollmentFailed'));
} }
$request = new ApiRequest(); $request = new ApiRequest();
$response = $request->createEnrollment($token, $audioFilePath, $user); $response = $request->createEnrollment($token, $audioFilePath, $user);
\ChamiloSession::erase(\WhispeakAuthPlugin::SESSION_SENTENCE_TEXT); ChamiloSession::erase(WhispeakAuthPlugin::SESSION_SENTENCE_TEXT);
$this->plugin->saveEnrollment($user, $response['speaker']); $this->plugin->saveEnrollment($user, $response['speaker']);
echo \Display::return_message($this->plugin->get_lang('EnrollmentSuccess'), 'success'); echo Display::return_message($this->plugin->get_lang('EnrollmentSuccess'), 'success');
} }
/** /**
@ -82,7 +87,7 @@ class EnrollmentController extends BaseController
$pageTitle = $this->plugin->get_lang('EnrollmentTitle'); $pageTitle = $this->plugin->get_lang('EnrollmentTitle');
$template = new \Template($pageTitle); $template = new Template($pageTitle);
foreach ($variables as $key => $value) { foreach ($variables as $key => $value) {
$template->assign($key, $value); $template->assign($key, $value);

@ -6,6 +6,7 @@ namespace Chamilo\PluginBundle\WhispeakAuth\Request;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use WhispeakAuthPlugin;
/** /**
* Class ApiRequest. * Class ApiRequest.
@ -13,7 +14,7 @@ use GuzzleHttp\Exception\RequestException;
class ApiRequest class ApiRequest
{ {
/** /**
* @var \WhispeakAuthPlugin * @var WhispeakAuthPlugin
*/ */
protected $plugin; protected $plugin;
/** /**
@ -26,8 +27,8 @@ class ApiRequest
*/ */
public function __construct() public function __construct()
{ {
$this->plugin = \WhispeakAuthPlugin::create(); $this->plugin = WhispeakAuthPlugin::create();
$this->apiKey = $this->plugin->get(\WhispeakAuthPlugin::SETTING_TOKEN); $this->apiKey = $this->plugin->get(WhispeakAuthPlugin::SETTING_TOKEN);
} }
/** /**
@ -39,7 +40,7 @@ class ApiRequest
*/ */
public function createEnrollmentSessionToken(User $user) public function createEnrollmentSessionToken(User $user)
{ {
$apiKey = $this->plugin->get(\WhispeakAuthPlugin::SETTING_TOKEN); $apiKey = $this->plugin->get(WhispeakAuthPlugin::SETTING_TOKEN);
$langIso = api_get_language_isocode($user->getLanguage()); $langIso = api_get_language_isocode($user->getLanguage());
return $this->sendRequest( return $this->sendRequest(
@ -84,7 +85,7 @@ class ApiRequest
*/ */
public function createAuthenticationSessionToken(User $user = null) public function createAuthenticationSessionToken(User $user = null)
{ {
$apiKey = $this->plugin->get(\WhispeakAuthPlugin::SETTING_TOKEN); $apiKey = $this->plugin->get(WhispeakAuthPlugin::SETTING_TOKEN);
$langIso = api_get_language_isocode($user ? $user->getLanguage() : null); $langIso = api_get_language_isocode($user ? $user->getLanguage() : null);
@ -106,7 +107,7 @@ class ApiRequest
*/ */
public function performAuthentication($token, User $user, $audioFilePath) public function performAuthentication($token, User $user, $audioFilePath)
{ {
$wsid = \WhispeakAuthPlugin::getAuthUidValue($user->getId()); $wsid = WhispeakAuthPlugin::getAuthUidValue($user->getId());
if (empty($wsid)) { if (empty($wsid)) {
throw new \Exception($this->plugin->get_lang('SpeechAuthNotEnrolled')); throw new \Exception($this->plugin->get_lang('SpeechAuthNotEnrolled'));

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save