Internal - Add travis behat, fix course creation, add psalm checks

pull/3464/head
Julio Montoya 5 years ago
parent fa9c35a907
commit 72d23099d7
  1. 3
      .travis.yml
  2. 5
      public/main/admin/course_add.php
  3. 4
      public/main/admin/course_category.php
  4. 16
      public/main/admin/course_edit.php
  5. 12
      public/main/admin/course_list.php
  6. 12
      public/main/admin/course_request_edit.php
  7. 2
      public/main/admin/extra_field_workflow.php
  8. 2
      public/main/admin/gradebook_dependency.php
  9. 4
      public/main/admin/gradebook_list.php
  10. 4
      public/main/admin/index.php
  11. 3
      public/main/admin/legal_list.php
  12. 10
      public/main/admin/questions.php
  13. 2
      public/main/admin/resource_sequence.php
  14. 9
      public/main/admin/skill.php
  15. 9
      public/main/admin/skill_badge_create.php
  16. 11
      public/main/admin/skill_level.php
  17. 18
      public/main/admin/skill_list.php
  18. 10
      public/main/admin/skill_profile.php
  19. 2
      public/main/admin/skill_rel_course.php
  20. 5
      public/main/admin/skill_translate.php
  21. 1
      public/main/admin/system_announcements.php
  22. 2
      public/main/admin/teachers_time_by_session_report.php
  23. 13
      public/main/admin/user_add.php
  24. 6
      public/main/admin/user_export.php
  25. 6
      public/main/admin/user_linking_requests.php
  26. 4
      public/main/admin/user_list_consent.php
  27. 14
      public/main/inc/lib/add_course.lib.inc.php
  28. 2
      public/main/inc/lib/course.lib.php
  29. 1
      public/main/inc/lib/display.lib.php
  30. 4
      public/main/inc/lib/formvalidator/FormValidator.class.php
  31. 10
      src/CoreBundle/Entity/Course.php
  32. 8
      src/CoreBundle/Entity/CourseRelUser.php
  33. 46
      src/CoreBundle/Entity/CourseRequest.php
  34. 18
      src/CoreBundle/Entity/CourseType.php

@ -102,6 +102,7 @@ script:
- sed -i "s/APP_ENV='dev'/APP_ENV='test'/g" .env.local
- cd tests/behat
- ../../vendor/behat/behat/bin/behat features/adminFillUsers.feature -vvv
- ../../vendor/behat/behat/bin/behat features/actionUserLogin.feature -vvv
- ../../vendor/behat/behat/bin/behat features/adminSettings.feature -vvv
- ../../vendor/behat/behat/bin/behat features/career.feature -vvv
- ../../vendor/behat/behat/bin/behat features/class.feature -vvv
@ -114,7 +115,7 @@ script:
# - ../../vendor/behat/behat/bin/behat features/profile.feature -v
# - ../../vendor/behat/behat/bin/behat features/promotion.feature -v
# - ../../vendor/behat/behat/bin/behat features/registration.feature -v
# - ../../vendor/behat/behat/bin/behat features/sessionAccess.feature -v
- ../../vendor/behat/behat/bin/behat features/sessionAccess.feature -v
# - ../../vendor/behat/behat/bin/behat features/sessionManagement.feature -v
# - ../../vendor/behat/behat/bin/behat features/socialGroup.feature -v
# - ../../vendor/behat/behat/bin/behat features/systemAnnouncements.feature -v

@ -2,9 +2,6 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\CourseCategory;
use Chamilo\CoreBundle\Repository\CourseCategoryRepository;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
@ -16,8 +13,6 @@ $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')
$interbreadcrumb[] = ['url' => 'course_list.php', 'name' => get_lang('Course list')];
$em = Database::getManager();
/** @var CourseCategoryRepository $courseCategoriesRepo */
$courseCategoriesRepo = $em->getRepository('ChamiloCoreBundle:CourseCategory');
// Get all possible teachers.
$accessUrlId = api_get_current_access_url_id();

@ -49,10 +49,10 @@ if (!empty($action)) {
$ret = $categoryInfo['id'];
//Delete Picture Category
$deletePicture = isset($_POST['delete_picture']) ? $_POST['delete_picture'] : '';
/*$deletePicture = isset($_POST['delete_picture']) ? $_POST['delete_picture'] : '';
if ($deletePicture) {
CourseCategory::deletePictureCategory($ret);
}
}*/
$errorMsg = Display::return_message(get_lang('Update successful'));
}

@ -2,10 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\CourseCategory;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\CourseCategoryRepository;
use Chamilo\CoreBundle\Repository\CourseRepository;
use Chamilo\CoreBundle\Framework\Container;
$cidReset = true;
@ -164,7 +161,7 @@ $form->addSelectAjax(
$courseCategoryNames,
[
'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category',
'multiple' => 'multiple'
'multiple' => 'multiple',
]
);
$courseInfo['course_categories'] = $courseCategoryIds;
@ -297,7 +294,8 @@ if ($form->validate()) {
$course = $form->getSubmitValues();
$visibility = $course['visibility'];
global $_configuration;
// @todo should be check in the CourseListener
/*global $_configuration;
if (isset($_configuration[$urlId]) &&
isset($_configuration[$urlId]['hosting_limit_active_courses']) &&
@ -312,14 +310,18 @@ if ($form->validate()) {
api_warn_hosting_contact('hosting_limit_active_courses');
Display::addFlash(
Display::return_message(get_lang('Sorry, this installation has an active courses limit, which has now been reached. You can still create new courses, but only if you hide/disable at least one existing active course. To do this, edit a course from the administration courses list, and change the visibility to \'hidden\', then try creating this course again. To increase the maximum number of active courses allowed on this Chamilo installation, please contact your hosting provider or, if available, upgrade to a superior hosting plan.'))
Display::return_message(
get_lang(
'Sorry, this installation has an active courses limit, which has now been reached. You can still create new courses, but only if you hide/disable at least one existing active course. To do this, edit a course from the administration courses list, and change the visibility to \'hidden\', then try creating this course again. To increase the maximum number of active courses allowed on this Chamilo installation, please contact your hosting provider or, if available, upgrade to a superior hosting plan.'
)
)
);
header('Location: course_list.php');
exit;
}
}
}
}*/
$visual_code = $course['visual_code'];
$visual_code = CourseManager::generate_course_code($visual_code);

@ -151,7 +151,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
// Place colour icons in front of courses.
$show_visual_code = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
$course[1] = get_course_visibility_icon($course[8]).PHP_EOL
$course[1] = get_course_visibility_icon($courseInfo['visibility']).PHP_EOL
.Display::url(Security::remove_XSS($course[1]), $courseInfo['course_public_url']).PHP_EOL
.$show_visual_code;
$course[5] = SUBSCRIBE_ALLOWED == $course[5] ? get_lang('Yes') : get_lang('No');
@ -260,7 +260,7 @@ function get_course_data_by_session($from, $number_of_items, $column, $direction
while ($course = Database::fetch_array($res)) {
// Place colour icons in front of courses.
$showVisualCode = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
$course[1] = get_course_visibility_icon($course[8]).
$course[1] = get_course_visibility_icon($course['col8']).
'<a href="'.$courseUrl.$course[9].'/index.php">'.
$course[1].
'</a> '.
@ -286,12 +286,14 @@ function get_course_data_by_session($from, $number_of_items, $column, $direction
/**
* Return an icon representing the visibility of the course.
*
* @param string $visibility
* @param int $visibility
*
* @return string
*/
function get_course_visibility_icon($visibility)
{
$visibility = (int) $visibility;
$style = 'margin-bottom:0;margin-right:5px;';
switch ($visibility) {
case 0:
@ -453,8 +455,7 @@ if (isset($_GET['search']) && 'advanced' === $_GET['search']) {
FormValidator::LAYOUT_INLINE
);
$url = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_session';
$sessionSelect = $sessionFilter->addElement(
'select_ajax',
$sessionSelect = $sessionFilter->addSelectAjax(
'session_name',
get_lang('Search course by session'),
null,
@ -504,7 +505,6 @@ if (isset($_GET['search']) && 'advanced' === $_GET['search']) {
if (!sessionId) {
return;
}
window.location = "'.$courseListUrl.'?session_id="+sessionId;
});
});

@ -15,7 +15,7 @@ $tool_name = get_lang('Edit a course request');
api_protect_admin_script();
// A check whether the course validation feature is enabled.
$course_validation_feature = 'true' == api_get_setting('course_validation');
$course_validation_feature = 'true' === api_get_setting('course_validation');
// Filtering passed to this page parameters.
$id = (int) ($_GET['id']);
@ -55,8 +55,7 @@ if ($course_validation_feature) {
// Course category.
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category';
$courseSelect = $form->addElement(
'select_ajax',
$courseSelect = $form->addSelectAjax(
'category_code',
get_lang('Category'),
null,
@ -69,7 +68,12 @@ if ($course_validation_feature) {
}
// Course code.
$form->addText('wanted_code', get_lang('Course code'), false, ['size' => '$maxlength', 'maxlength' => $maxlength]);
$form->addText(
'wanted_code',
get_lang('Course code'),
false,
['size' => '$maxlength', 'maxlength' => $maxlength]
);
$form->applyFilter('wanted_code', 'html_filter');
$form->addRule('wanted_code', get_lang('max. 20 characters, e.g. <i>INNOV21</i>'), 'maxlength', $maxlength);
$form->addRule('wanted_code', get_lang('Required field'), 'required');

@ -147,7 +147,7 @@ ksort($options);
$form->addElement('select', 'status', get_lang('Select role'), $options);
$em = Database::getManager();
$repo = $em->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption');
$repo = $em->getRepository(ExtraFieldOptionRelFieldOption::class);
$checks = $repo->findBy(
['fieldId' => $field_id, 'roleId' => $roleId]

@ -15,7 +15,7 @@ if (false == $allow) {
$categoryId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 1;
$em = Database::getManager();
$repo = $em->getRepository('ChamiloCoreBundle:GradebookCategory');
$repo = $em->getRepository(GradebookCategory::class);
/** @var GradebookCategory $category */
$category = $repo->find($categoryId);
if (!$category) {

@ -16,7 +16,7 @@ if (false == $allow) {
}
$em = Database::getManager();
$repo = $em->getRepository('ChamiloCoreBundle:GradebookCategory');
$repo = $em->getRepository(GradebookCategory::class);
$maxItems = 20;
@ -178,7 +178,7 @@ switch ($action) {
);
$form->addText('name', get_lang('Name'));
$form->addText('weight', get_lang('Weight'));
$form->addLabel(get_lang('Course'), $category->getCourseCode());
$form->addLabel(get_lang('Course'), $category->getCourse()->getCode());
$sql = "SELECT
depends,

@ -434,7 +434,7 @@ if (api_is_platform_admin()) {
'label' => get_lang('Tickets'),
];
if (true == api_get_configuration_value('db_manager_enabled') &&
/*if (true == api_get_configuration_value('db_manager_enabled') &&
api_is_global_platform_admin()
) {
$host = $_configuration['db_host'];
@ -445,7 +445,7 @@ if (api_is_platform_admin()) {
'url' => "db.php?username=$username&db=$databaseName&server=$host",
'label' => get_lang('Database manager'),
];
}
}*/
$blocks['settings']['items'] = $items;
$blocks['settings']['extra'] = null;

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Legal;
use Chamilo\CoreBundle\Repository\LegalRepository;
/**
@ -29,7 +30,7 @@ echo '</div>';
$em = Database::getManager();
/** @var LegalRepository $legalTermsRepo */
$legalTermsRepo = $em->getRepository('ChamiloCoreBundle:Legal');
$legalTermsRepo = $em->getRepository(Legal::class);
$legalCount = $legalTermsRepo->countAllActiveLegalTerms();
$languages = api_get_languages();
$available_languages = count($languages['folder']);

@ -105,12 +105,12 @@ if ($formSent) {
$question->courseCode = $courseCode;
// Creating empty exercise
$exercise = new Exercise($courseId);
$questionObject = Question::read($question->getId(), $courseInfo);
$questionObject = Question::read($question->getIid(), $courseInfo);
ob_start();
ExerciseLib::showQuestion(
$exercise,
$question->getId(),
$question->getIid(),
false,
null,
null,
@ -139,7 +139,7 @@ if ($formSent) {
'id_session' => $exercise->sessionId,
'exerciseId' => $exerciseId,
'type' => $question->getType(),
'editQuestion' => $question->getId(),
'editQuestion' => $question->getIid(),
])
);
}
@ -153,7 +153,7 @@ if ($formSent) {
'id_session' => $exercise->sessionId,
'exerciseId' => $exerciseId,
'type' => $question->getType(),
'editQuestion' => $question->getId(),
'editQuestion' => $question->getIid(),
])
);
@ -161,7 +161,7 @@ if ($formSent) {
Display::return_icon('delete.png', get_lang('Delete')),
$url.'&'.http_build_query([
'courseId' => $question->getCId(),
'questionId' => $question->getId(),
'questionId' => $question->getIid(),
'action' => 'delete',
])
).'<br />';

@ -21,7 +21,7 @@ $type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : SequenceResource::S
$tpl = new Template(get_lang('ResourcesSequencing'));
$em = Database::getManager();
$sequenceRepository = $em->getRepository('ChamiloCoreBundle:Sequence');
$sequenceRepository = $em->getRepository(Sequence::class);
$currentUrl = api_get_self().'?type='.$type;

@ -2,6 +2,7 @@
/* For license terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Skill;
use Chamilo\CoreBundle\Entity\Profile;
/**
* This script manages the skills, levels and profiles assignments.
@ -10,8 +11,8 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
$em = Database::getManager();
$profiles = $em->getRepository('ChamiloCoreBundle:Profile')->findAll();
$list = $em->getRepository('ChamiloCoreBundle:Skill')->findAll();
$profiles = $em->getRepository(Profile::class)->findAll();
$list = $em->getRepository(Skill::class)->findAll();
$listAction = api_get_self();
$toolbarAction = '';
@ -26,7 +27,7 @@ $id = isset($_GET['id']) ? $_GET['id'] : '';
$item = null;
if (!empty($id)) {
/** @var Skill $item */
$item = $em->getRepository('ChamiloCoreBundle:Skill')->find($id);
$item = $em->getRepository(Skill::class)->find($id);
if (!$item) {
api_not_allowed();
}
@ -62,7 +63,7 @@ switch ($action) {
if ($form->validate()) {
$values = $form->exportValues();
$profile = $em->getRepository('ChamiloCoreBundle:Profile')->find($values['profile_id']);
$profile = $em->getRepository(Profile::class)->find($values['profile_id']);
if ($profile) {
$item->setProfile($profile);
$em->persist($item);

@ -44,7 +44,7 @@ if ('POST' === $_SERVER['REQUEST_METHOD']) {
$existsBadgesDirectory = is_dir($badgePath);
if (!$existsBadgesDirectory) {
$existsBadgesDirectory = api_create_protected_dir('badges', api_get_path(SYS_UPLOAD_PATH));
//$existsBadgesDirectory = api_create_protected_dir('badges', api_get_path(SYS_UPLOAD_PATH));
}
if ($existsBadgesDirectory) {
@ -77,7 +77,12 @@ if ('POST' === $_SERVER['REQUEST_METHOD']) {
$params['icon'] = sprintf("%s.png", $fileName);
} else {
Display::addFlash(Display::return_message(get_lang('The uploaded file could not be saved (perhaps a permission problem?)')), 'warning');
Display::addFlash(
Display::return_message(
get_lang('The uploaded file could not be saved (perhaps a permission problem?)')
),
'warning'
);
}
}

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Level;
use Chamilo\CoreBundle\Entity\Profile;
/**
* Add a skill Level.
@ -13,8 +14,8 @@ require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
$em = Database::getManager();
$profiles = $em->getRepository('ChamiloCoreBundle:Profile')->findAll();
$list = $em->getRepository('ChamiloCoreBundle:Level')->findAll();
$profiles = $em->getRepository(Profile::class)->findAll();
$list = $em->getRepository(Level::class)->findAll();
$listAction = api_get_self();
@ -28,7 +29,7 @@ $id = isset($_GET['id']) ? $_GET['id'] : '';
$item = null;
if (!empty($id)) {
/** @var Level $item */
$item = $em->getRepository('ChamiloCoreBundle:Level')->find($id);
$item = $em->getRepository(Level::class)->find($id);
if (!$item) {
api_not_allowed();
}
@ -62,7 +63,7 @@ switch ($action) {
if ($form->validate()) {
$values = $form->exportValues();
if (isset($values['profile_id']) && !empty($values['profile_id'])) {
$profile = $em->getRepository('ChamiloCoreBundle:Profile')->find($values['profile_id']);
$profile = $em->getRepository(Profile::class)->find($values['profile_id']);
if ($profile) {
$item = new Level();
$item->setName($values['name']);
@ -109,7 +110,7 @@ switch ($action) {
$item->setName($values['name']);
$item->setShortName($values['short_name']);
$profile = $em->getRepository('ChamiloCoreBundle:Profile')->find($values['profile_id']);
$profile = $em->getRepository(Profile::class)->find($values['profile_id']);
if ($profile) {
$item->setProfile($profile);
}

@ -1,6 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Skill;
use Skill as SkillManager;
/**
* Skill list for management.
*
@ -14,7 +18,7 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Skill::isAllowed();
SkillManager::isAllowed();
$action = isset($_GET['action']) ? $_GET['action'] : 'list';
$skillId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
@ -23,7 +27,7 @@ $entityManager = Database::getManager();
switch ($action) {
case 'enable':
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $skillId);
$skill = $entityManager->find(Skill::class, $skillId);
if (is_null($skill)) {
Display::addFlash(
@ -56,8 +60,8 @@ switch ($action) {
exit;
break;
case 'disable':
/** @var \Chamilo\CoreBundle\Entity\Skill $skill */
$skill = $entityManager->find('ChamiloCoreBundle:Skill', $skillId);
/** @var Skill $skill */
$skill = $entityManager->find(Skill::class, $skillId);
if (is_null($skill)) {
Display::addFlash(
@ -77,12 +81,12 @@ switch ($action) {
$entityManager->persist($skill);
$skillObj = new Skill();
$skillObj = new SkillManager();
$children = $skillObj->getChildren($skill->getId());
foreach ($children as $child) {
$skill = $entityManager->find(
'ChamiloCoreBundle:Skill',
Skill::class,
$child['id']
);
@ -156,7 +160,7 @@ switch ($action) {
}
/* View */
$skill = new Skill();
$skill = new SkillManager();
$skillList = $skill->get_all();
$extraFieldSearchTagId = isset($_REQUEST['tag_id']) ? $_REQUEST['tag_id'] : 0;

@ -1,8 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Level;
use Chamilo\CoreBundle\Entity\Profile;
use Chamilo\CoreBundle\Entity\Skill;
/**
* Add a skill Profile.
@ -12,7 +14,7 @@ require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
$em = Database::getManager();
$list = $em->getRepository('ChamiloCoreBundle:Profile')->findAll();
$list = $em->getRepository(Profile::class)->findAll();
$listAction = api_get_self();
@ -25,7 +27,7 @@ $id = isset($_GET['id']) ? $_GET['id'] : '';
$item = null;
if (!empty($id)) {
$item = $em->getRepository('ChamiloCoreBundle:Profile')->find($id);
$item = $em->getRepository(Profile::class)->find($id);
if (!$item) {
api_not_allowed();
}
@ -52,7 +54,7 @@ $tpl = new Template($action);
switch ($action) {
case 'move_up':
/** @var Level $item */
$item = $em->getRepository('ChamiloCoreBundle:Level')->find($_GET['level_id']);
$item = $em->getRepository(Level::class)->find($_GET['level_id']);
if ($item) {
$position = $item->getPosition();
if (!empty($position)) {
@ -68,7 +70,7 @@ switch ($action) {
break;
case 'move_down':
/** @var Level $item */
$item = $em->getRepository('ChamiloCoreBundle:Level')->find($_GET['level_id']);
$item = $em->getRepository(Level::class)->find($_GET['level_id']);
if ($item) {
$position = $item->getPosition();
$item->setPosition($position + 1);

@ -36,7 +36,7 @@ $form->addHeader(get_lang('Add skills').$sessionName);
$skillList = [];
$em = Database::getManager();
$items = $em->getRepository('ChamiloCoreBundle:SkillRelCourse')->findBy(
$items = $em->getRepository(SkillRelCourse::class)->findBy(
['course' => $courseId, 'session' => $sessionId]
);
/** @var SkillRelCourse $skillRelCourse */

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
@ -21,7 +22,7 @@ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'name';
if (isset($_GET['skill'])) {
/** @var Skill $skill */
$skill = $em->find('ChamiloCoreBundle:Skill', intval($_GET['skill']));
$skill = $em->find(Skill::class, $_GET['skill']);
if ('name' === $action) {
$variableLanguage = ChamiloApi::getLanguageVar(
@ -53,7 +54,7 @@ if (empty($originalName)) {
$languageId = isset($_GET['sub_language']) ? intval($_GET['sub_language']) : 0;
$languages = $em
->getRepository('ChamiloCoreBundle:Language')
->getRepository(Language::class)
->findAllPlatformSubLanguages();
$languagesOptions = [0 => get_lang('none')];

@ -274,7 +274,6 @@ if ($action_todo) {
$form->addElement('checkbox', 'delete_picture', null, get_lang('Delete picture'));
}
} catch (Exception $e) {
} catch (HTML_QuickForm_Error $e) {
error_log($e);
}

@ -103,7 +103,7 @@ if ($session) {
}
}
if (isset($_GET['export']) && $session && ($coursesInfo && $usersInfo)) {
if (isset($_GET['export']) && $session && $coursesInfo && $usersInfo) {
$fileName = get_lang('Teachers time report').' '.api_get_local_time();
$dataToExport = [];

@ -245,19 +245,6 @@ $form->addElement(
//drh list (display only if student)
$display = (isset($_POST['status']) && STUDENT == $_POST['status']) || !isset($_POST['status']) ? 'block' : 'none';
//@todo remove the drh list here. This code is unused
$form->addElement('html', '<div id="drh_list" style="display:'.$display.';">');
if (isset($drh_list) && is_array($drh_list)) {
foreach ($drh_list as $drh) {
$drh_select->addOption(
api_get_person_name($drh['firstname'], $drh['lastname']),
$drh['user_id']
);
}
}
$form->addElement('html', '</div>');
if (api_is_platform_admin()) {
// Platform admin
$group = [];

@ -27,8 +27,6 @@ $courses = [];
$courses[''] = '--';
$sql = "SELECT code,visual_code,title FROM $course_table ORDER BY visual_code";
global $_configuration;
if (api_is_multiple_url_enabled()) {
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$access_url_id = api_get_current_access_url_id();
@ -83,7 +81,7 @@ if ($form->validate()) {
u.firstname AS FirstName,
u.email AS Email,
u.username AS UserName,
".(('none' != $_configuration['password_encryption']) ? " " : "u.password AS Password, ")."
".(('none' != api_get_configuration_value('password_encryption')) ? " " : "u.password AS Password, ")."
u.auth_source AS AuthSource,
u.status AS Status,
u.official_code AS OfficialCode,
@ -126,7 +124,7 @@ if ($form->validate()) {
if (!empty($export['addcsvheader'])) {
if ('1' == $export['addcsvheader'] && ('csv' == $export['file_type'] || 'xls' == $export['file_type'])) {
if ('none' != $_configuration['password_encryption']) {
if ('none' != api_get_configuration_value('password_encryption')) {
$data[] = [
'UserId',
'LastName',

@ -21,7 +21,7 @@ if (!empty($action) && $hrm && $assignedId) {
switch ($action) {
case 'accept':
/** @var UserRelUser $request */
$request = $em->getRepository('ChamiloCoreBundle:UserRelUser')
$request = $em->getRepository(UserRelUser::class)
->findOneBy([
'userId' => $assignedId,
'friendUserId' => $hrm->getId(),
@ -43,7 +43,7 @@ if (!empty($action) && $hrm && $assignedId) {
exit;
case 'reject':
/** @var UserRelUser $request */
$request = $em->getRepository('ChamiloCoreBundle:UserRelUser')
$request = $em->getRepository(UserRelUser::class)
->findOneBy([
'userId' => $assignedId,
'friendUserId' => $hrm->getId(),
@ -63,7 +63,7 @@ if (!empty($action) && $hrm && $assignedId) {
exit;
case 'remove':
/** @var UserRelUser $request */
$request = $em->getRepository('ChamiloCoreBundle:UserRelUser')
$request = $em->getRepository(UserRelUser::class)
->findOneBy([
'userId' => $assignedId,
'friendUserId' => $hrm->getId(),

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
@ -19,6 +20,7 @@ $this_section = SECTION_PLATFORM_ADMIN;
$extraFields = UserManager::createDataPrivacyExtraFields();
Session::write('data_privacy_extra_fields', $extraFields);
$userInfo = api_get_user_info();
/**
* Prepares the shared SQL query for the user table.
@ -482,7 +484,7 @@ if (!empty($action)) {
$number_of_affected_users = 0;
if (is_array($_POST['id'])) {
foreach ($_POST['id'] as $index => $user_id) {
if ($user_id != $_user['user_id']) {
if ($user_id != $userInfo['user_id']) {
if (UserManager::delete_user($user_id)) {
$number_of_affected_users++;
}

@ -657,7 +657,6 @@ class AddCourse
$course_language = isset($params['course_language']) && !empty($params['course_language']) ? $params['course_language'] : api_get_setting(
'platformLanguage'
);
$user_id = empty($params['user_id']) ? api_get_user_id() : intval($params['user_id']);
$department_name = isset($params['department_name']) ? $params['department_name'] : null;
$department_url = isset($params['department_url']) ? $params['department_url'] : null;
$disk_quota = isset($params['disk_quota']) ? $params['disk_quota'] : null;
@ -680,9 +679,6 @@ class AddCourse
$expiration_date = isset($params['expiration_date']) ? $params['expiration_date'] : null;
$teachers = isset($params['teachers']) ? $params['teachers'] : null;
$categories = isset($params['course_categories']) ? $params['course_categories'] : null;
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLECOURSERELCATEGORY = Database::get_main_table(TABLE_MAIN_COURSE_REL_CATEGORY);
$ok_to_register_course = true;
// Check whether all the needed parameters are present.
@ -838,13 +834,12 @@ class AddCourse
//UrlManager::add_course_to_url($course_id, $accessUrlId);
// Add event to the system log.
$user_id = api_get_user_id();
Event::addEvent(
LOG_COURSE_CREATE,
LOG_COURSE_CODE,
$code,
api_get_utc_datetime(),
$user_id,
$userId,
$course_id
);
@ -873,18 +868,15 @@ class AddCourse
foreach ($course->getCategories() as $category) {
$message .= get_lang('Category').': '.$category->getCode()."\n";
}
}
$message .= get_lang('Coach').' '.$tutor_name."\n";
$message .= get_lang('Language').' '.$course_language;
$userInfo = api_get_user_info($user_id);
$additionalParameters = [
'smsType' => SmsPlugin::NEW_COURSE_BEEN_CREATED,
'userId' => $user_id,
'userId' => $userId,
'courseName' => $title,
'creatorUsername' => $userInfo['username'],
'creatorUsername' => $user->getUsername(),
];
api_mail_html(

@ -3211,8 +3211,6 @@ class CourseManager
/**
* Get course code(s) from visual code.
*
* @deprecated
*
* @param string Visual code
*
* @return array List of codes for the given visual code

@ -1778,7 +1778,6 @@ class Display
];
}
return $session;
}

@ -280,7 +280,7 @@ EOT;
*
* @throws Exception
*
* @return HTML_QuickForm_element
* @return SelectAjax
*/
public function addSelectAjax($name, $label, $options = [], $attributes = [])
{
@ -302,7 +302,7 @@ EOT;
* @param string $label
* @param array $attributes
*
* @return mixed
* @return DatePicker
*/
public function addDatePicker($name, $label, $attributes = [])
{

@ -789,12 +789,8 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
/**
* Set visibility.
*
* @param int $visibility
*
* @return Course
*/
public function setVisibility($visibility)
public function setVisibility(int $visibility): Course
{
$this->visibility = $visibility;
@ -803,10 +799,8 @@ class Course extends AbstractResource implements ResourceInterface, ResourceWith
/**
* Get visibility.
*
* @return int
*/
public function getVisibility()
public function getVisibility(): int
{
return (int) $this->visibility;
}

@ -125,14 +125,6 @@ class CourseRelUser
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return $this
*/

@ -9,20 +9,11 @@ use Doctrine\ORM\Mapping as ORM;
/**
* CourseRequest.
*
* @todo fix objetives variable
*
* @ORM\Table(name="course_request", uniqueConstraints={@ORM\UniqueConstraint(name="code", columns={"code"})})
* @ORM\Entity
*/
class CourseRequest
{
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", cascade={"persist"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* @var int
*
@ -32,6 +23,14 @@ class CourseRequest
*/
protected $id;
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", cascade={"persist"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* @var string
*
@ -145,11 +144,6 @@ class CourseRequest
$this->requestDate = new \DateTime();
}
/**
* Set user.
*
* @return UsergroupRelUser
*/
public function setUser(User $user)
{
$this->user = $user;
@ -191,30 +185,6 @@ class CourseRequest
return $this->code;
}
/**
* Set userId.
*
* @param int $userId
*
* @return CourseRequest
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId.
*
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set directory.
*

@ -14,6 +14,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class CourseType
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var string
*
@ -42,15 +51,6 @@ class CourseType
*/
protected $props;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* Set name.
*

Loading…
Cancel
Save