Skip to content

Commit 72d2309

Browse files
committed
Internal - Add travis behat, fix course creation, add psalm checks
1 parent fa9c35a commit 72d2309

35 files changed

+127
-179
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ script:
102102
- sed -i "s/APP_ENV='dev'/APP_ENV='test'/g" .env.local
103103
- cd tests/behat
104104
- ../../vendor/behat/behat/bin/behat features/adminFillUsers.feature -vvv
105+
- ../../vendor/behat/behat/bin/behat features/actionUserLogin.feature -vvv
105106
- ../../vendor/behat/behat/bin/behat features/adminSettings.feature -vvv
106107
- ../../vendor/behat/behat/bin/behat features/career.feature -vvv
107108
- ../../vendor/behat/behat/bin/behat features/class.feature -vvv
@@ -114,7 +115,7 @@ script:
114115
# - ../../vendor/behat/behat/bin/behat features/profile.feature -v
115116
# - ../../vendor/behat/behat/bin/behat features/promotion.feature -v
116117
# - ../../vendor/behat/behat/bin/behat features/registration.feature -v
117-
# - ../../vendor/behat/behat/bin/behat features/sessionAccess.feature -v
118+
- ../../vendor/behat/behat/bin/behat features/sessionAccess.feature -v
118119
# - ../../vendor/behat/behat/bin/behat features/sessionManagement.feature -v
119120
# - ../../vendor/behat/behat/bin/behat features/socialGroup.feature -v
120121
# - ../../vendor/behat/behat/bin/behat features/systemAnnouncements.feature -v

public/main/admin/course_add.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
/* For licensing terms, see /license.txt */
44

5-
use Chamilo\CoreBundle\Entity\CourseCategory;
6-
use Chamilo\CoreBundle\Repository\CourseCategoryRepository;
7-
85
$cidReset = true;
96
require_once __DIR__.'/../inc/global.inc.php';
107
$this_section = SECTION_PLATFORM_ADMIN;
@@ -16,8 +13,6 @@
1613
$interbreadcrumb[] = ['url' => 'course_list.php', 'name' => get_lang('Course list')];
1714

1815
$em = Database::getManager();
19-
/** @var CourseCategoryRepository $courseCategoriesRepo */
20-
$courseCategoriesRepo = $em->getRepository('ChamiloCoreBundle:CourseCategory');
2116
// Get all possible teachers.
2217
$accessUrlId = api_get_current_access_url_id();
2318

public/main/admin/course_category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
$ret = $categoryInfo['id'];
5050

5151
//Delete Picture Category
52-
$deletePicture = isset($_POST['delete_picture']) ? $_POST['delete_picture'] : '';
52+
/*$deletePicture = isset($_POST['delete_picture']) ? $_POST['delete_picture'] : '';
5353
if ($deletePicture) {
5454
CourseCategory::deletePictureCategory($ret);
55-
}
55+
}*/
5656

5757
$errorMsg = Display::return_message(get_lang('Update successful'));
5858
}

public/main/admin/course_edit.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
/* For licensing terms, see /license.txt */
44

5-
use Chamilo\CoreBundle\Entity\CourseCategory;
65
use Chamilo\CoreBundle\Entity\User;
7-
use Chamilo\CoreBundle\Repository\CourseCategoryRepository;
8-
use Chamilo\CoreBundle\Repository\CourseRepository;
96
use Chamilo\CoreBundle\Framework\Container;
107

118
$cidReset = true;
@@ -164,7 +161,7 @@
164161
$courseCategoryNames,
165162
[
166163
'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category',
167-
'multiple' => 'multiple'
164+
'multiple' => 'multiple',
168165
]
169166
);
170167
$courseInfo['course_categories'] = $courseCategoryIds;
@@ -297,7 +294,8 @@
297294
$course = $form->getSubmitValues();
298295
$visibility = $course['visibility'];
299296

300-
global $_configuration;
297+
// @todo should be check in the CourseListener
298+
/*global $_configuration;
301299
302300
if (isset($_configuration[$urlId]) &&
303301
isset($_configuration[$urlId]['hosting_limit_active_courses']) &&
@@ -312,14 +310,18 @@
312310
api_warn_hosting_contact('hosting_limit_active_courses');
313311
314312
Display::addFlash(
315-
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.'))
313+
Display::return_message(
314+
get_lang(
315+
'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.'
316+
)
317+
)
316318
);
317319
318320
header('Location: course_list.php');
319321
exit;
320322
}
321323
}
322-
}
324+
}*/
323325

324326
$visual_code = $course['visual_code'];
325327
$visual_code = CourseManager::generate_course_code($visual_code);

public/main/admin/course_list.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
103103
unsubscribe LIKE '".$keyword_unsubscribe."'";
104104

105105
if (!empty($keyword_category)) {
106-
$sql .= " AND category.id = ".$keyword_category . " ";
106+
$sql .= " AND category.id = ".$keyword_category." ";
107107
}
108108
}
109109

@@ -141,7 +141,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
141141
// get categories
142142
$sqlCategoriesByCourseId = "SELECT category.name FROM $tblCourseCategory category
143143
INNER JOIN $tblCourseRelCategory course_rel_category ON category.id = course_rel_category.course_category_id
144-
WHERE course_rel_category.course_id = " . $course['id'];
144+
WHERE course_rel_category.course_id = ".$course['id'];
145145
$resultCategories = Database::query($sqlCategoriesByCourseId);
146146
$categories = [];
147147

@@ -151,7 +151,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
151151

152152
// Place colour icons in front of courses.
153153
$show_visual_code = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
154-
$course[1] = get_course_visibility_icon($course[8]).PHP_EOL
154+
$course[1] = get_course_visibility_icon($courseInfo['visibility']).PHP_EOL
155155
.Display::url(Security::remove_XSS($course[1]), $courseInfo['course_public_url']).PHP_EOL
156156
.$show_visual_code;
157157
$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
260260
while ($course = Database::fetch_array($res)) {
261261
// Place colour icons in front of courses.
262262
$showVisualCode = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
263-
$course[1] = get_course_visibility_icon($course[8]).
263+
$course[1] = get_course_visibility_icon($course['col8']).
264264
'<a href="'.$courseUrl.$course[9].'/index.php">'.
265265
$course[1].
266266
'</a> '.
@@ -286,12 +286,14 @@ function get_course_data_by_session($from, $number_of_items, $column, $direction
286286
/**
287287
* Return an icon representing the visibility of the course.
288288
*
289-
* @param string $visibility
289+
* @param int $visibility
290290
*
291291
* @return string
292292
*/
293293
function get_course_visibility_icon($visibility)
294294
{
295+
$visibility = (int) $visibility;
296+
295297
$style = 'margin-bottom:0;margin-right:5px;';
296298
switch ($visibility) {
297299
case 0:
@@ -453,8 +455,7 @@ function get_course_visibility_icon($visibility)
453455
FormValidator::LAYOUT_INLINE
454456
);
455457
$url = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=search_session';
456-
$sessionSelect = $sessionFilter->addElement(
457-
'select_ajax',
458+
$sessionSelect = $sessionFilter->addSelectAjax(
458459
'session_name',
459460
get_lang('Search course by session'),
460461
null,
@@ -504,7 +505,6 @@ function get_course_visibility_icon($visibility)
504505
if (!sessionId) {
505506
return;
506507
}
507-
508508
window.location = "'.$courseListUrl.'?session_id="+sessionId;
509509
});
510510
});

public/main/admin/course_request_edit.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
api_protect_admin_script();
1616

1717
// A check whether the course validation feature is enabled.
18-
$course_validation_feature = 'true' == api_get_setting('course_validation');
18+
$course_validation_feature = 'true' === api_get_setting('course_validation');
1919

2020
// Filtering passed to this page parameters.
2121
$id = (int) ($_GET['id']);
@@ -55,8 +55,7 @@
5555
// Course category.
5656
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category';
5757

58-
$courseSelect = $form->addElement(
59-
'select_ajax',
58+
$courseSelect = $form->addSelectAjax(
6059
'category_code',
6160
get_lang('Category'),
6261
null,
@@ -69,7 +68,12 @@
6968
}
7069

7170
// Course code.
72-
$form->addText('wanted_code', get_lang('Course code'), false, ['size' => '$maxlength', 'maxlength' => $maxlength]);
71+
$form->addText(
72+
'wanted_code',
73+
get_lang('Course code'),
74+
false,
75+
['size' => '$maxlength', 'maxlength' => $maxlength]
76+
);
7377
$form->applyFilter('wanted_code', 'html_filter');
7478
$form->addRule('wanted_code', get_lang('max. 20 characters, e.g. <i>INNOV21</i>'), 'maxlength', $maxlength);
7579
$form->addRule('wanted_code', get_lang('Required field'), 'required');

public/main/admin/extra_field_workflow.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ function setHidden(obj) {
9393
}
9494
}
9595
96-
$(function() {
96+
$(function() {
9797
$("#workflow_status").on("change", function() {
98-
var roleId = $(this).find(":selected").val();
98+
var roleId = $(this).find(":selected").val();
9999
if (roleId != 0) {
100100
window.location.replace("'.api_get_self().'?'.$paramsNoRole.'&roleId="+roleId);
101101
}
102102
});
103-
103+
104104
$("[name=select_all]").on("click", function() {
105105
$("#workflow :checkbox").prop("checked", 1);
106106
$("#workflow :hidden").prop("value", 1);
107107
return false;
108108
});
109-
109+
110110
$("[name=unselect_all]").on("click", function() {
111111
$("#workflow :checkbox").prop("checked", 0);
112112
$("#workflow :hidden").prop("value", 0);
@@ -147,7 +147,7 @@ function setHidden(obj) {
147147
$form->addElement('select', 'status', get_lang('Select role'), $options);
148148

149149
$em = Database::getManager();
150-
$repo = $em->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption');
150+
$repo = $em->getRepository(ExtraFieldOptionRelFieldOption::class);
151151

152152
$checks = $repo->findBy(
153153
['fieldId' => $field_id, 'roleId' => $roleId]

public/main/admin/gradebook_dependency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$categoryId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 1;
1616

1717
$em = Database::getManager();
18-
$repo = $em->getRepository('ChamiloCoreBundle:GradebookCategory');
18+
$repo = $em->getRepository(GradebookCategory::class);
1919
/** @var GradebookCategory $category */
2020
$category = $repo->find($categoryId);
2121
if (!$category) {

public/main/admin/gradebook_list.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717

1818
$em = Database::getManager();
19-
$repo = $em->getRepository('ChamiloCoreBundle:GradebookCategory');
19+
$repo = $em->getRepository(GradebookCategory::class);
2020

2121
$maxItems = 20;
2222

@@ -178,7 +178,7 @@
178178
);
179179
$form->addText('name', get_lang('Name'));
180180
$form->addText('weight', get_lang('Weight'));
181-
$form->addLabel(get_lang('Course'), $category->getCourseCode());
181+
$form->addLabel(get_lang('Course'), $category->getCourse()->getCode());
182182

183183
$sql = "SELECT
184184
depends,

public/main/admin/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@
434434
'label' => get_lang('Tickets'),
435435
];
436436

437-
if (true == api_get_configuration_value('db_manager_enabled') &&
437+
/*if (true == api_get_configuration_value('db_manager_enabled') &&
438438
api_is_global_platform_admin()
439439
) {
440440
$host = $_configuration['db_host'];
@@ -445,7 +445,7 @@
445445
'url' => "db.php?username=$username&db=$databaseName&server=$host",
446446
'label' => get_lang('Database manager'),
447447
];
448-
}
448+
}*/
449449

450450
$blocks['settings']['items'] = $items;
451451
$blocks['settings']['extra'] = null;

0 commit comments

Comments
 (0)