Internal - Fix travis, fix legacy code

pull/3464/head
Julio Montoya 5 years ago
parent efefcc708b
commit f617a6cc36
  1. 24
      public/main/course_info/infocours.php
  2. 30
      public/main/inc/lib/link.lib.php
  3. 15
      src/CoreBundle/Framework/Container.php
  4. 4
      tests/behat/features/actionUserLogin.feature
  5. 3
      tests/behat/features/adminSettings.feature
  6. 1
      tests/behat/features/career.feature
  7. 7
      tests/behat/features/course.feature
  8. 4
      tests/behat/features/sessionAccess.feature
  9. 1
      tests/behat/features/sessionManagement.feature

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Framework\Container;
@ -21,6 +22,8 @@ $this_section = SECTION_COURSES;
$nameTools = get_lang('Settings'); $nameTools = get_lang('Settings');
api_protect_course_script(true); api_protect_course_script(true);
api_block_anonymous_users(); api_block_anonymous_users();
$urlId = api_get_current_access_url_id();
$_course = api_get_course_info(); $_course = api_get_course_info();
$courseEntity = api_get_course_entity(); $courseEntity = api_get_course_entity();
$isAllowToEdit = api_is_course_admin() || api_is_platform_admin(); $isAllowToEdit = api_is_course_admin() || api_is_platform_admin();
@ -47,7 +50,7 @@ if ('true' == api_get_setting('pdf_export_watermark_by_course')) {
} }
} }
$categories = CourseCategory::getCategoriesCanBeAddedInCourse($_course['categoryCode']); $categories = $courseCategoryRepo->getCategoriesByCourseIdAndAccessUrlId($courseId, $urlId);
$formOptionsArray = []; $formOptionsArray = [];
@ -97,13 +100,13 @@ $form->addText('title', get_lang('Title'), true);
$form->applyFilter('title', 'html_filter'); $form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim'); $form->applyFilter('title', 'trim');
$form->addElement( /*$form->addElement(
'select', 'select',
'category_id', 'category_id',
get_lang('Category'), get_lang('Category'),
$categories, $categories,
['style' => 'width:350px', 'id' => 'category_id'] ['style' => 'width:350px', 'id' => 'category_id']
); );*/
$form->addSelectLanguage( $form->addSelectLanguage(
'course_language', 'course_language',
[get_lang('Language'), get_lang('This language will be valid for every visitor of your courses portal')] [get_lang('Language'), get_lang('This language will be valid for every visitor of your courses portal')]
@ -910,7 +913,7 @@ $form->addHtml('</div>');
// Set the default values of the form // Set the default values of the form
$values = []; $values = [];
$values['title'] = $_course['name']; $values['title'] = $_course['name'];
$values['category_id'] = $_course['category_id']; //$values['category_id'] = $_course['category_id'];
$values['course_language'] = $_course['language']; $values['course_language'] = $_course['language'];
$values['department_name'] = $_course['extLink']['name']; $values['department_name'] = $_course['extLink']['name'];
$values['department_url'] = $_course['extLink']['url']; $values['department_url'] = $_course['extLink']['url'];
@ -961,7 +964,6 @@ if ($form->validate() && $isEditable) {
} }
global $_configuration; global $_configuration;
$urlId = api_get_current_access_url_id();
if (isset($_configuration[$urlId]) && if (isset($_configuration[$urlId]) &&
isset($_configuration[$urlId]['hosting_limit_active_courses']) && isset($_configuration[$urlId]['hosting_limit_active_courses']) &&
$_configuration[$urlId]['hosting_limit_active_courses'] > 0 $_configuration[$urlId]['hosting_limit_active_courses'] > 0
@ -977,7 +979,11 @@ if ($form->validate() && $isEditable) {
api_warn_hosting_contact('hosting_limit_active_courses'); api_warn_hosting_contact('hosting_limit_active_courses');
Display::addFlash( 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.'
)
)
); );
$url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.api_get_cidreq(); $url = api_get_path(WEB_CODE_PATH).'course_info/infocours.php?'.api_get_cidreq();
@ -1002,15 +1008,15 @@ if ($form->validate() && $isEditable) {
$activeLegal = isset($updateValues['activate_legal']) ? $updateValues['activate_legal'] : 0; $activeLegal = isset($updateValues['activate_legal']) ? $updateValues['activate_legal'] : 0;
$category = null; /*$category = null;
if (!empty($updateValues['category_id'])) { if (!empty($updateValues['category_id'])) {
$category = $courseCategoryRepo->find($updateValues['category_id']); $category = $courseCategoryRepo->find($updateValues['category_id']);
} }*/
$courseEntity $courseEntity
->setTitle($updateValues['title']) ->setTitle($updateValues['title'])
->setCourseLanguage($updateValues['course_language']) ->setCourseLanguage($updateValues['course_language'])
->setCategory($category) //->setCategory($category)
->setDepartmentName($updateValues['department_name']) ->setDepartmentName($updateValues['department_name'])
->setDepartmentUrl($updateValues['department_url']) ->setDepartmentUrl($updateValues['department_url'])
->setVisibility($updateValues['visibility']) ->setVisibility($updateValues['visibility'])

@ -1636,9 +1636,9 @@ Do you really want to delete this category and its links ?')."')) return false;\
); );
if ('addlink' === $action) { if ('addlink' === $action) {
$form->addHeader(get_lang('LinksAdd')); $form->addHeader(get_lang('Add a link'));
} else { } else {
$form->addHeader(get_lang('LinksMod')); $form->addHeader(get_lang('Edit link'));
} }
$target_link = '_blank'; $target_link = '_blank';
@ -1661,8 +1661,14 @@ Do you really want to delete this category and its links ?')."')) return false;\
$form->addHidden('id', $linkId); $form->addHidden('id', $linkId);
$form->addText('url', 'URL'); $form->addText('url', 'URL');
$form->addRule('url', get_lang('Please give the link URL, it should be valid.'), 'url'); $form->addRule('url', get_lang('Please give the link URL, it should be valid.'), 'url');
$form->addText('title', get_lang('LinksName')); $form->addText('title', get_lang('Link name'));
$form->addHtmlEditor('description', get_lang('Description'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']); $form->addHtmlEditor(
'description',
get_lang('Description'),
false,
false,
['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']
);
$resultcategories = self::getLinkCategories($courseId, $sessionId); $resultcategories = self::getLinkCategories($courseId, $sessionId);
$options = ['0' => '--']; $options = ['0' => '--'];
@ -1676,17 +1682,17 @@ Do you really want to delete this category and its links ?')."')) return false;\
$form->addCheckBox('on_homepage', null, get_lang('Show link on course homepage')); $form->addCheckBox('on_homepage', null, get_lang('Show link on course homepage'));
$targets = [ $targets = [
'_self' => get_lang('LinksOpenSelf'), '_self' => get_lang('Open self'),
'_blank' => get_lang('LinksOpenBlank'), '_blank' => get_lang('Open blank'),
'_parent' => get_lang('LinksOpenParent'), '_parent' => get_lang('Open parent'),
'_top' => get_lang('LinksOpenTop'), '_top' => get_lang('Open top'),
]; ];
$form->addSelect( $form->addSelect(
'target', 'target',
[ [
get_lang('LinksTarget'), get_lang('Link\'s target'),
get_lang('AddTargetOfLinksShow link on course homepage'), get_lang('Select the target which shows the link on the homepage of the course'),
], ],
$targets $targets
); );
@ -1700,14 +1706,14 @@ Do you really want to delete this category and its links ?')."')) return false;\
'target' => $target_link, 'target' => $target_link,
]; ];
if ('true' == api_get_setting('search_enabled')) { if ('true' === api_get_setting('search_enabled')) {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list(); $specific_fields = get_specific_field_list();
$form->addCheckBox('index_document', get_lang('Index link title and description?s'), get_lang('Yes')); $form->addCheckBox('index_document', get_lang('Index link title and description?s'), get_lang('Yes'));
foreach ($specific_fields as $specific_field) { foreach ($specific_fields as $specific_field) {
$default_values = ''; $default_values = '';
if ('editlink' == $action) { if ('editlink' === $action) {
$filter = [ $filter = [
'field_id' => $specific_field['id'], 'field_id' => $specific_field['id'],
'ref_id' => intval($_GET['id']), 'ref_id' => intval($_GET['id']),

@ -339,26 +339,17 @@ class Container
return self::$container->get(SessionRepository::class); return self::$container->get(SessionRepository::class);
} }
/** public static function getCourseCategoryRepository(): CourseCategoryRepository
* @return CourseCategoryRepository|object|null
*/
public static function getCourseCategoryRepository()
{ {
return self::$container->get(CourseCategoryRepository::class); return self::$container->get(CourseCategoryRepository::class);
} }
/** public static function getCalendarEventRepository(): CCalendarEventRepository
* @return CCalendarEventRepository
*/
public static function getCalendarEventRepository()
{ {
return self::$container->get(CCalendarEventRepository::class); return self::$container->get(CCalendarEventRepository::class);
} }
/** public static function getCalendarEventAttachmentRepository(): CCalendarEventAttachmentRepository
* @return CCalendarEventAttachmentRepository
*/
public static function getCalendarEventAttachmentRepository()
{ {
return self::$container->get(CCalendarEventAttachmentRepository::class); return self::$container->get(CCalendarEventAttachmentRepository::class);
} }

@ -7,10 +7,10 @@ Feature: Login user
And I fill in "admin" for "password" And I fill in "admin" for "password"
Then I press "Login" Then I press "Login"
Then wait for the page to be loaded Then wait for the page to be loaded
Then I should see "My courses" Then I should not see "Login"
Then I should not see an error Then I should not see an error
Scenario: Login as admin Scenario: Login as admin
Given I am a platform administrator Given I am a platform administrator
Then I should not see an error Then I should not see an error
Then I should see "My courses" Then I should not see "Login"

@ -11,6 +11,7 @@ Feature: Settings update
And I additionally select "Official code" from "form_changeable_options" And I additionally select "Official code" from "form_changeable_options"
And I additionally select "Login" from "form_changeable_options" And I additionally select "Login" from "form_changeable_options"
And I press "Save" And I press "Save"
And wait for the page to be loaded
Then I should see "Settings have been successfully updated" Then I should see "Settings have been successfully updated"
Scenario: Update 'allow_registration' setting Scenario: Update 'allow_registration' setting
@ -18,6 +19,7 @@ Feature: Settings update
And I am on "/admin/settings/search_settings?keyword=allow_registration" And I am on "/admin/settings/search_settings?keyword=allow_registration"
And I select "Yes" from "form_allow_registration" And I select "Yes" from "form_allow_registration"
And I press "Save" And I press "Save"
And wait for the page to be loaded
Then I should see "Settings have been successfully updated" Then I should see "Settings have been successfully updated"
Scenario: Update 'allow_group_categories' setting Scenario: Update 'allow_group_categories' setting
@ -25,4 +27,5 @@ Feature: Settings update
And I am on "/admin/settings/search_settings?keyword=allow_group_categories" And I am on "/admin/settings/search_settings?keyword=allow_group_categories"
And I select "Yes" from "form_allow_group_categories" And I select "Yes" from "form_allow_group_categories"
And I press "Save" And I press "Save"
And wait for the page to be loaded
Then I should see "Settings have been successfully updated" Then I should see "Settings have been successfully updated"

@ -10,4 +10,5 @@ Feature: Career
| name | Developer | | name | Developer |
And I fill in ckeditor field "description" with "Description" And I fill in ckeditor field "description" with "Description"
And I press "submit" And I press "submit"
And wait for the page to be loaded
Then I should see "Item added" Then I should see "Item added"

@ -32,10 +32,11 @@ Feature: Course tools basic testing
And I press "submit" And I press "submit"
Then wait for the page to be loaded Then wait for the page to be loaded
Then I should see "Course list" Then I should see "Course list"
And I should see "TEMP"
Scenario: Make sure the course exists # Scenario: Make sure the course exists
Given course "TEMP" exists # Given course "TEMP" exists
Then I should not see an error # Then I should not see an error
# Scenario: Make sure the course description tool is available # Scenario: Make sure the course description tool is available
# Given I am on course "TEMP" homepage # Given I am on course "TEMP" homepage

@ -20,6 +20,7 @@ Feature: Session access
Then I select "Warnier Yannick (ywarnier)" from "nosessionUsersList[]" Then I select "Warnier Yannick (ywarnier)" from "nosessionUsersList[]"
And I press "add_user" And I press "add_user"
And I press "next" And I press "next"
And wait for the page to be loaded
Then I should see "Session1" Then I should see "Session1"
Then I should see "TEMPPRIVATE" Then I should see "TEMPPRIVATE"
Then I should see "ywarnier" Then I should see "ywarnier"
@ -42,6 +43,7 @@ Feature: Session access
Then I select "Mosquera Guardamino Michela (mmosquera)" from "nosessionUsersList[]" Then I select "Mosquera Guardamino Michela (mmosquera)" from "nosessionUsersList[]"
And I press "add_user" And I press "add_user"
And I press "next" And I press "next"
And wait for the page to be loaded
Then I should see "Session2" Then I should see "Session2"
Then I should see "TEMPPRIVATE" Then I should see "TEMPPRIVATE"
Then I should see "mmosquera" Then I should see "mmosquera"
@ -77,6 +79,7 @@ Feature: Session access
And wait for the page to be loaded And wait for the page to be loaded
And I follow "Delete" And I follow "Delete"
And I confirm the popup And I confirm the popup
And wait for the page to be loaded
Then I should see "Deleted" Then I should see "Deleted"
Scenario: Delete session "Session1" Scenario: Delete session "Session1"
@ -85,4 +88,5 @@ Feature: Session access
And wait for the page to be loaded And wait for the page to be loaded
And I follow "Delete" And I follow "Delete"
And I confirm the popup And I confirm the popup
And wait for the page to be loaded
Then I should see "Deleted" Then I should see "Deleted"

@ -24,6 +24,7 @@ Feature: Session management tool
Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]" Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]"
And I press "add_course" And I press "add_course"
And I press "next" And I press "next"
And wait for the page to be loaded
Then I should see "Update successful" Then I should see "Update successful"
@javascript @javascript

Loading…
Cancel
Save