Minor - fix php code

pull/3064/head
Julio 6 years ago
parent e39837419c
commit b1073ed308
  1. 5
      public/main/admin/access_url_add_courses_to_url.php
  2. 5
      public/main/admin/access_url_add_usergroup_to_url.php
  3. 11
      public/main/admin/access_url_add_users_to_url.php
  4. 10
      public/main/admin/access_url_check_user_session.php
  5. 27
      public/main/admin/access_url_edit.php
  6. 16
      public/main/admin/access_url_edit_course_category_to_url.php
  7. 16
      public/main/admin/access_url_edit_courses_to_url.php
  8. 16
      public/main/admin/access_url_edit_usergroup_to_url.php
  9. 22
      public/main/admin/access_url_edit_users_to_url.php
  10. 20
      public/main/admin/access_urls.php
  11. 23
      public/main/admin/add_courses_to_usergroup.php
  12. 9
      public/main/admin/add_drh_to_user.php
  13. 20
      public/main/admin/add_sessions_to_promotion.php
  14. 22
      public/main/admin/add_sessions_to_usergroup.php
  15. 38
      public/main/admin/add_users_to_usergroup.php
  16. 6
      public/main/admin/archive_cleanup.php
  17. 5
      public/main/admin/career_dashboard.php
  18. 11
      public/main/admin/career_diagram.php
  19. 20
      public/main/admin/careers.php
  20. 3
      public/main/admin/configure_extensions.php
  21. 52
      public/main/admin/configure_inscription.php
  22. 5
      public/main/admin/configure_plugin.php
  23. 8
      public/main/admin/course_add.php
  24. 26
      public/main/admin/course_category.php
  25. 13
      public/main/admin/course_edit.php
  26. 12
      public/main/admin/course_export.php
  27. 14
      public/main/admin/course_import.php
  28. 18
      public/main/admin/course_information.php
  29. 61
      public/main/admin/course_list.php
  30. 24
      public/main/admin/course_request_accepted.php
  31. 19
      public/main/admin/course_request_edit.php
  32. 23
      public/main/admin/course_request_rejected.php
  33. 21
      public/main/admin/course_request_review.php
  34. 22
      public/main/admin/course_user_import.php
  35. 26
      public/main/admin/course_user_import_by_email.php
  36. 22
      public/main/admin/dashboard_add_courses_to_user.php
  37. 24
      public/main/admin/dashboard_add_sessions_to_user.php
  38. 52
      public/main/admin/dashboard_add_users_to_user.php

@ -5,7 +5,6 @@
* It displays a list of users and a list of courses;
* you can select multiple users and courses and then click on.
*
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
@ -48,8 +47,8 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$url_list = is_array($_POST['url_list']) ? $_POST['url_list'] : [];
$first_letter_course = $_POST['first_letter_course'];
if ($form_sent == 1) {
if (count($courses) == 0 || count($url_list) == 0) {
if (1 == $form_sent) {
if (0 == count($courses) || 0 == count($url_list)) {
echo Display::return_message(get_lang('At least one course and one URL'), 'error');
} else {
UrlManager::add_courses_to_urls($courses, $url_list);

@ -5,7 +5,6 @@
* It displays a list of users and a list of courses;
* you can select multiple users and courses and then click on.
*
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
@ -46,8 +45,8 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$urlList = is_array($_POST['url_list']) ? $_POST['url_list'] : [];
$firstLetterUserGroup = $_POST['first_letter_user_group'];
if ($form_sent == 1) {
if (count($userGroups) == 0 || count($urlList) == 0) {
if (1 == $form_sent) {
if (0 == count($userGroups) || 0 == count($urlList)) {
echo Display::return_message(get_lang('You need to select at least one group and one site'), 'error');
} else {
UrlManager::addUserGroupListToUrl($userGroups, $urlList);

@ -5,7 +5,6 @@
* It displays a list of users and a list of courses;
* you can select multiple users and courses and then click on.
*
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
@ -48,11 +47,11 @@ if ($_POST['form_sent']) {
$url_list = is_array($_POST['url_list']) ? $_POST['url_list'] : [];
$first_letter_user = $_POST['first_letter_user'];
foreach ($users as $key => $value) {
$users[$key] = intval($value);
$users[$key] = (int) $value;
}
if ($form_sent == 1) {
if (count($users) == 0 || count($url_list) == 0) {
if (1 == $form_sent) {
if (0 == count($users) || 0 == count($url_list)) {
echo Display::return_message(
get_lang('You must select at least one user and one URL'),
'error'
@ -82,7 +81,7 @@ $target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
$target_name = 'lastname';
$sql = "SELECT user_id,lastname,firstname,username FROM $tbl_user
WHERE ".$target_name." LIKE '".$first_letter_user_lower."%' OR ".$target_name." LIKE '".$first_letter_user_lower."%'
ORDER BY ".(count($users) > 0 ? "(user_id IN(".implode(',', $users).")) DESC," : "")." ".$target_name;
ORDER BY ".(count($users) > 0 ? '(user_id IN('.implode(',', $users).')) DESC,' : '').' '.$target_name;
$result = Database::query($sql);
$db_users = Database::store_result($result);
unset($result);
@ -100,7 +99,7 @@ unset($result);
<td width="40%" align="center">
<b><?php echo get_lang('User list'); ?></b>
<br/><br/>
<?php echo get_lang('Select').' '; echo $target_name == 'firstname' ? get_lang('First name') : get_lang('Last name'); ?>
<?php echo get_lang('Select').' '; echo 'firstname' == $target_name ? get_lang('First name') : get_lang('Last name'); ?>
<select name="first_letter_user" onchange="javascript:document.formulaire.form_sent.value='2'; document.formulaire.submit();">
<option value="">--</option>
<?php

@ -1,9 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Bart Mollet, Julio Montoya lot of fixes
*
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -39,6 +38,7 @@ switch ($action) {
'confirm'
);
}
break;
}
@ -53,7 +53,7 @@ $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' O
$session_list = SessionManager::get_sessions_list();
$html = '';
$show_users_with_problems = isset($_REQUEST['show_users_with_problems']) && $_REQUEST['show_users_with_problems'] == 1 ? true : false;
$show_users_with_problems = isset($_REQUEST['show_users_with_problems']) && 1 == $_REQUEST['show_users_with_problems'] ? true : false;
if ($show_users_with_problems) {
$html .= '<a href="'.api_get_self().'?show_users_with_problems=0">'.get_lang('Show all users').'</a>';
} else {
@ -65,7 +65,7 @@ foreach ($session_list as $session_item) {
$html .= '<h3>'.$session_item['name'].'</h3>';
$access_where = "(access_url_id = $url_id OR access_url_id is null )";
if ($show_users_with_problems) {
$access_where = "(access_url_id is null)";
$access_where = '(access_url_id is null)';
}
$sql = "SELECT u.user_id, lastname, firstname, username, access_url_id
@ -86,7 +86,7 @@ foreach ($session_list as $session_item) {
foreach ($users as $user) {
$user_link = '';
if (!empty($user['user_id'])) {
$user_link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.intval($user['user_id']).'">'.Security::remove_XSS(api_get_person_name($user['firstname'], $user['lastname'])).' ('.$user['username'].')</a>';
$user_link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.(int) ($user['user_id']).'">'.Security::remove_XSS(api_get_person_name($user['firstname'], $user['lastname'])).' ('.$user['username'].')</a>';
}
$link_to_add_user_in_url = '';

@ -1,9 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true;
@ -31,12 +30,12 @@ if ($form->validate()) {
$url_to_go = 'access_urls.php';
if (!empty($url_id)) {
//we can't change the status of the url with id=1
if ($url_id == 1) {
if (1 == $url_id) {
$active = 1;
}
// Checking url
if (substr($url, strlen($url) - 1, strlen($url)) == '/') {
if ('/' == substr($url, strlen($url) - 1, strlen($url))) {
UrlManager::update($url_id, $url, $description, $active);
} else {
UrlManager::update($url_id, $url.'/', $description, $active);
@ -45,10 +44,10 @@ if ($form->validate()) {
$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
$image_fields = ['url_image_1', 'url_image_2', 'url_image_3'];
foreach ($image_fields as $image_field) {
if ($_FILES[$image_field]['error'] == 0) {
if (0 == $_FILES[$image_field]['error']) {
// Hardcoded: only PNG files allowed
$fileFields = explode('.', $_FILES[$image_field]['name']);
if (end($fileFields) === 'png') {
if ('png' === end($fileFields)) {
if (file_exists($url_images_dir.$url_id.'_'.$image_field.'.png')) {
// if the file exists, we have to remove it before move_uploaded_file
unlink($url_images_dir.$url_id.'_'.$image_field.'.png');
@ -64,9 +63,9 @@ if ($form->validate()) {
$message = get_lang('The URL has been edited');
} else {
$num = UrlManager::url_exist($url);
if ($num == 0) {
if (0 == $num) {
// checking url
if (substr($url, strlen($url) - 1, strlen($url)) == '/') {
if ('/' == substr($url, strlen($url) - 1, strlen($url))) {
UrlManager::add($url, $description, $active);
} else {
//create
@ -79,15 +78,15 @@ if ($form->validate()) {
$message = get_lang('This URL already exists, please select another URL');
}
// URL Images
$url .= (substr($url, strlen($url) - 1, strlen($url)) == '/') ? '' : '/';
$url .= '/' == substr($url, strlen($url) - 1, strlen($url)) ? '' : '/';
$url_id = UrlManager::get_url_id($url);
$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
$image_fields = ["url_image_1", "url_image_2", "url_image_3"];
$image_fields = ['url_image_1', 'url_image_2', 'url_image_3'];
foreach ($image_fields as $image_field) {
if ($_FILES[$image_field]['error'] == 0) {
if (0 == $_FILES[$image_field]['error']) {
// Hardcoded: only PNG files allowed
$fileFields = explode('.', $_FILES[$image_field]['name']);
if (end($fileFields) == 'png') {
if ('png' == end($fileFields)) {
move_uploaded_file(
$_FILES[$image_field]['tmp_name'],
$url_images_dir.$url_id.'_'.$image_field.'.png'
@ -117,7 +116,7 @@ $form->addRule('url', '', 'maxlength', 254);
$form->addElement('textarea', 'description', get_lang('Description'));
//the first url with id = 1 will be always active
if (isset($_GET['url_id']) && $_GET['url_id'] != 1) {
if (isset($_GET['url_id']) && 1 != $_GET['url_id']) {
$form->addElement('checkbox', 'active', null, get_lang('active'));
}
@ -128,7 +127,7 @@ $submit_name = get_lang('Add URL');
if (isset($_GET['url_id'])) {
$url_id = (int) $_GET['url_id'];
$num_url_id = UrlManager::url_id_exist($url_id);
if ($num_url_id != 1) {
if (1 != $num_url_id) {
header('Location: access_urls.php');
exit();
}

@ -2,8 +2,6 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
@ -32,12 +30,12 @@ $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')
$interbreadcrumb[] = ['url' => 'access_urls.php', 'name' => get_lang('Multiple access URL / Branding')];
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
if (isset($_REQUEST['add_type']) && '' != $_REQUEST['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
$access_url_id = 1;
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') {
if (isset($_REQUEST['access_url_id']) && '' != $_REQUEST['access_url_id']) {
$access_url_id = (int) $_REQUEST['access_url_id'];
}
@ -84,8 +82,8 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$list = [];
}
if ($form_sent == 1) {
if ($access_url_id == 0) {
if (1 == $form_sent) {
if (0 == $access_url_id) {
Display::addFlash(Display::return_message(get_lang('Select a URL')));
header('Location: access_url_edit_users_to_url.php?');
} elseif (is_array($list)) {
@ -101,7 +99,7 @@ Display::display_header($tool_name);
api_display_tool_title($tool_name);
$noUserGroupList = $userGroupList = [];
$ajax_search = $add_type == 'unique' ? true : false;
$ajax_search = 'unique' == $add_type ? true : false;
if ($ajax_search) {
$userGroups = UrlManager::getUrlRelCourseCategory($access_url_id);
@ -119,7 +117,7 @@ if ($ajax_search) {
$noUserGroupList = CourseCategory::getCourseCategoryNotInList(array_keys($userGroupList));
}
if ($add_type == 'multiple') {
if ('multiple' == $add_type) {
$link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'.
get_lang('Single registration').'</a>';
$link_add_type_multiple = get_lang('Multiple registration');
@ -156,7 +154,7 @@ $url_list = UrlManager::get_url_data();
$url_selected = $url_obj[1];
}
}
if ($url_obj['active'] == 1) {
if (1 == $url_obj['active']) {
?>
<option <?php echo $checked; ?> value="<?php echo $url_obj[0]; ?>"> <?php echo $url_obj[1]; ?>
</option>

@ -2,8 +2,6 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
// resetting the course id
@ -32,12 +30,12 @@ $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')
$interbreadcrumb[] = ['url' => 'access_urls.php', 'name' => get_lang('Multiple access URL / Branding')];
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
if (isset($_REQUEST['add_type']) && '' != $_REQUEST['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
$access_url_id = 1;
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') {
if (isset($_REQUEST['access_url_id']) && '' != $_REQUEST['access_url_id']) {
$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']);
}
@ -79,8 +77,8 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$course_list = [];
}
if ($form_sent == 1) {
if ($access_url_id == 0) {
if (1 == $form_sent) {
if (0 == $access_url_id) {
Display::addFlash(Display::return_message(get_lang('Select a URL')));
header('Location: access_url_edit_users_to_url.php?');
} elseif (is_array($course_list)) {
@ -104,7 +102,7 @@ echo '</div>';
api_display_tool_title($tool_name);
$no_course_list = $course_list = [];
$ajax_search = $add_type == 'unique' ? true : false;
$ajax_search = 'unique' == $add_type ? true : false;
if ($ajax_search) {
$courses = UrlManager::get_url_rel_course_data($access_url_id);
@ -134,7 +132,7 @@ if ($ajax_search) {
}
}
if ($add_type == 'multiple') {
if ('multiple' == $add_type) {
$link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'.
get_lang('Single registration').'</a>';
$link_add_type_multiple = get_lang('Multiple registration');
@ -165,7 +163,7 @@ $url_list = UrlManager::get_url_data();
$url_selected = $url_obj[1];
}
}
if ($url_obj['active'] == 1) {
if (1 == $url_obj['active']) {
?>
<option <?php echo $checked; ?> value="<?php echo $url_obj[0]; ?>"> <?php echo $url_obj[1]; ?></option>
<?php

@ -2,8 +2,6 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
// resetting the course id
@ -31,12 +29,12 @@ $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')
$interbreadcrumb[] = ['url' => 'access_urls.php', 'name' => get_lang('Multiple access URL / Branding')];
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
if (isset($_REQUEST['add_type']) && '' != $_REQUEST['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
$access_url_id = 1;
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') {
if (isset($_REQUEST['access_url_id']) && '' != $_REQUEST['access_url_id']) {
$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']);
}
@ -80,8 +78,8 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$course_list = [];
}
if ($form_sent == 1) {
if ($access_url_id == 0) {
if (1 == $form_sent) {
if (0 == $access_url_id) {
Display::addFlash(Display::return_message(get_lang('Select a URL')));
header('Location: access_url_edit_users_to_url.php');
} elseif (is_array($course_list)) {
@ -105,7 +103,7 @@ echo '</div>';
api_display_tool_title($tool_name);
$noUserGroupList = $userGroupList = [];
$ajax_search = $add_type === 'unique' ? true : false;
$ajax_search = 'unique' === $add_type ? true : false;
if ($ajax_search) {
$userGroups = UrlManager::get_url_rel_usergroup_data($access_url_id);
@ -126,7 +124,7 @@ if ($ajax_search) {
$link_add_type_unique = ['class' => 'disabled'];
$link_add_type_multiple = [];
if ($add_type === 'multiple') {
if ('multiple' === $add_type) {
$link_add_type_unique = [];
$link_add_type_multiple = ['class' => 'disabled'];
}
@ -185,7 +183,7 @@ $url_list = UrlManager::get_url_data();
$url_selected = $url_obj[1];
}
}
if ($url_obj['active'] == 1) {
if (1 == $url_obj['active']) {
?>
<option <?php echo $checked; ?>
value="<?php echo $url_obj[0]; ?>"> <?php echo $url_obj[1]; ?>

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
*/
// resetting the course id
@ -31,12 +29,12 @@ $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')
$interbreadcrumb[] = ['url' => 'access_urls.php', 'name' => get_lang('Multiple access URL / Branding')];
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
if (isset($_REQUEST['add_type']) && '' != $_REQUEST['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
$access_url_id = 1;
if (isset($_REQUEST['access_url_id']) && $_REQUEST['access_url_id'] != '') {
if (isset($_REQUEST['access_url_id']) && '' != $_REQUEST['access_url_id']) {
$access_url_id = Security::remove_XSS($_REQUEST['access_url_id']);
}
@ -80,8 +78,8 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
if (!is_array($UserList)) {
$UserList = [];
}
if ($form_sent == 1) {
if ($access_url_id == 0) {
if (1 == $form_sent) {
if (0 == $access_url_id) {
Display::addFlash(Display::return_message(get_lang('Select a URL')));
header('Location: access_url_edit_users_to_url.php');
exit;
@ -100,7 +98,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$user_info = api_get_user_info($user);
if (!empty($user_info)) {
$user_added_list[] = $i.'. '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, null, $user_info['username']);
$i++;
++$i;
}
}
if (!empty($user_added_list)) {
@ -116,7 +114,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$user_info = api_get_user_info($user);
if (!empty($user_info)) {
$user_deleted_list[] = $i.'. '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
$i++;
++$i;
}
}
if (!empty($user_deleted_list)) {
@ -143,7 +141,7 @@ echo '</div>';
api_display_tool_title($tool_name);
$nosessionUsersList = $sessionUsersList = [];
$ajax_search = $add_type == 'unique' ? true : false;
$ajax_search = 'unique' == $add_type ? true : false;
if ($ajax_search) {
$Users = UrlManager::get_url_rel_user_data($access_url_id);
@ -161,7 +159,7 @@ if ($ajax_search) {
}
$sql = "SELECT u.user_id, lastname, firstname, username
FROM $tbl_user u WHERE status <> ".ANONYMOUS." ".
FROM $tbl_user u WHERE status <> ".ANONYMOUS.' '.
$order_clause;
$result = Database::query($sql);
$Users = Database::store_result($result);
@ -173,7 +171,7 @@ if ($ajax_search) {
}
}
if ($add_type == 'multiple') {
if ('multiple' == $add_type) {
$link_add_type_unique = '<a href="'.api_get_self().'?add_type=unique&access_url_id='.$access_url_id.'">'.get_lang('Single registration').'</a>';
$link_add_type_multiple = get_lang('Multiple registration');
} else {
@ -203,7 +201,7 @@ $url_list = UrlManager::get_url_data();
$url_selected = $url_obj[1];
}
}
if ($url_obj['active'] == 1) {
if (1 == $url_obj['active']) {
?>
<option <?php echo $checked; ?> value="<?php echo $url_obj[0]; ?>"> <?php echo $url_obj[1]; ?></option>
<?php

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Frontend script for multiple access urls.
*
* @package chamilo.admin
*
* @author Julio Montoya <gugli100@gmail.com>
* @author Yannick Warnier <yannick.warnier@beeznest.com>
@ -41,19 +41,22 @@ if (isset($_GET['action'])) {
} else {
echo Display::return_message(get_lang('Cannot delete this URL.'), 'error');
}
break;
case 'lock':
UrlManager::set_url_status('lock', $url_id);
echo Display::return_message(get_lang('The URL has been disabled'), 'normal');
break;
case 'unlock':
UrlManager::set_url_status('unlock', $url_id);
echo Display::return_message(get_lang('The URL has been enabled'), 'normal');
break;
case 'register':
// we are going to register the admin
if (api_is_platform_admin()) {
if ($current_access_url_id != -1) {
if (-1 != $current_access_url_id) {
$url_str = '';
foreach ($url_list as $my_url) {
if (!in_array($my_url['id'], $my_user_url_list)) {
@ -68,6 +71,7 @@ if (isset($_GET['action'])) {
);
}
}
break;
}
}
@ -91,7 +95,7 @@ if (!empty($url_string)) {
}
// checking the current installation
if ($current_access_url_id == -1) {
if (-1 == $current_access_url_id) {
echo Display::return_message(
get_lang('URL not configured yet, please add this URL :').': '.api_get_path(WEB_PATH),
'warning'
@ -101,7 +105,7 @@ if ($current_access_url_id == -1) {
api_get_user_id(),
$current_access_url_id
);
if ($quant == 0) {
if (0 == $quant) {
echo Display::return_message(
'<a href="'.api_get_self().'?action=register&sec_token='.$parameters['sec_token'].'">'.
get_lang('Click here to register the admin into all sites').'</a>',
@ -153,12 +157,12 @@ foreach ($data as $row) {
$active = $row['active'];
$action = 'unlock';
$image = 'wrong';
if ($active == '1') {
if ('1' == $active) {
$action = 'lock';
$image = 'right';
}
// you cannot lock the default
if ($row['id'] == '1') {
if ('1' == $row['id']) {
$status = Display::return_icon($image.'.gif', get_lang(ucfirst($action)));
} else {
$status = '<a href="access_urls.php?action='.$action.'&amp;url_id='.$row['id'].'">'.
@ -170,8 +174,8 @@ foreach ($data as $row) {
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL),
"access_url_edit.php?url_id=$url_id"
);
if ($url_id != '1') {
$actions .= '<a href="access_urls.php?action=delete_url&amp;url_id='.$url_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("Please confirm your choice"), ENT_QUOTES, $charset))."'".')) return false;">'.
if ('1' != $url_id) {
$actions .= '<a href="access_urls.php?action=delete_url&amp;url_id='.$url_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES, $charset))."'".')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>';
}
$urls[] = [$url, $description, $status, $createdAt, $actions];

@ -1,8 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
// Resetting the course id.
$cidReset = true;
@ -29,7 +26,7 @@ $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')];
$tool_name = get_lang('Subscribe class to courses');
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
if (isset($_REQUEST['add_type']) && '' != $_REQUEST['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
@ -54,7 +51,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
if (!is_array($elements_posted)) {
$elements_posted = [];
}
if ($form_sent == 1) {
if (1 == $form_sent) {
$usergroup->subscribe_courses_to_usergroup($id, $elements_posted);
Display::addFlash(Display::return_message(get_lang('Update successful')));
header('Location: usergroups.php');
@ -120,7 +117,7 @@ $course_list = CourseManager::get_courses_list(
$elements_not_in = $elements_in = [];
foreach ($course_list_in as $course) {
$elements_in[$course['id']] = $course['title']." (".$course['visual_code'].")";
$elements_in[$course['id']] = $course['title'].' ('.$course['visual_code'].')';
}
if (!empty($course_list)) {
@ -128,11 +125,11 @@ if (!empty($course_list)) {
if (isset($elements_in[$item['id']])) {
continue;
}
$elements_not_in[$item['id']] = $item['title']." (".$item['visual_code'].")";
$elements_not_in[$item['id']] = $item['title'].' ('.$item['visual_code'].')';
}
}
$ajax_search = $add_type == 'unique' ? true : false;
$ajax_search = 'unique' == $add_type ? true : false;
// checking for extra field with filter on
function search($needle, $type)
@ -141,7 +138,7 @@ function search($needle, $type)
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
if ($type != 'single') {
if ('single' != $type) {
$list = CourseManager::get_courses_list(
0,
0,
@ -151,7 +148,7 @@ function search($needle, $type)
$needle
);
}
if ($type != 'single') {
if ('single' != $type) {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';
foreach ($list as $row) {
@ -170,7 +167,7 @@ function search($needle, $type)
$xajax->processRequests();
Display::display_header($tool_name);
if ($add_type == 'multiple') {
if ('multiple' == $add_type) {
$link_add_type_unique = '<a href="'.api_get_self().'?add='.$add.'&add_type=unique">'.
Display::return_icon('single.gif').get_lang('Single registration').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('Multiple registration');
@ -212,7 +209,7 @@ if (!empty($errorMsg)) {
<td align="center"><b><?php echo get_lang('Courses in group'); ?> :</b></td>
</tr>
<?php if ($add_type == 'multiple') {
<?php if ('multiple' == $add_type) {
?>
<tr>
<td align="center">
@ -231,7 +228,7 @@ if (!empty($errorMsg)) {
<td align="center">
<div id="content_source">
<?php
if (!($add_type == 'multiple')) {
if (!('multiple' == $add_type)) {
?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
<div id="ajax_list_users_single"></div>

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\UserRelUser;
@ -19,7 +20,7 @@ $userRepository = UserManager::getRepository();
/** @var UserEntity $user */
$user = UserManager::getManager()->find($_REQUEST['u']);
if ($user === null) {
if (null === $user) {
api_not_allowed(true);
}
@ -34,7 +35,7 @@ foreach ($subscribedUsers as $subscribedUser) {
/** @var UserEntity $hrm */
$hrm = UserManager::getManager()->find($subscribedUser->getFriendUserId());
if ($hrm === null) {
if (null === $hrm) {
continue;
}
@ -68,11 +69,11 @@ if ($form->validate()) {
/** @var UserEntity $hrm */
$hrm = UserManager::getManager()->find($hrmId);
if ($hrm === null) {
if (null === $hrm) {
continue;
}
if ($hrm->getStatus() !== DRH) {
if (DRH !== $hrm->getStatus()) {
continue;
}

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
// resetting the course id
$cidReset = true;
@ -25,7 +23,7 @@ $interbreadcrumb[] = ['url' => 'career_dashboard.php', 'name' => get_lang('Caree
// Setting the name of the tool
$tool_name = get_lang('Subscribe sessions to promotions');
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
if (isset($_REQUEST['add_type']) && '' != $_REQUEST['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
@ -68,14 +66,14 @@ $form_sent = 0;
$errorMsg = '';
$users = $sessions = [];
$promotion = new Promotion();
$id = intval($_GET['id']);
$id = (int) ($_GET['id']);
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$session_in_promotion_posted = $_POST['session_in_promotion_name'];
if (!is_array($session_in_promotion_posted)) {
$session_in_promotion_posted = [$session_in_promotion_posted];
}
if ($form_sent == 1) {
if (1 == $form_sent) {
// Added a parameter to send emails when registering a user
SessionManager::subscribe_sessions_to_promotion($id, $session_in_promotion_posted);
header('Location: promotions.php');
@ -101,7 +99,7 @@ if (!empty($session_list)) {
}
}
}
$ajax_search = $add_type == 'unique' ? true : false;
$ajax_search = 'unique' == $add_type ? true : false;
// Checking for extra field with filter on
@ -109,7 +107,7 @@ $xajax->processRequests();
Display::display_header($tool_name);
if ($add_type == 'multiple') {
if ('multiple' == $add_type) {
$link_add_type_unique = '<a href="'.api_get_self().'?id='.$id.'&add_type=unique">'.Display::return_icon('single.gif').get_lang('Single registration').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('Multiple registration');
} else {
@ -129,7 +127,7 @@ echo '</div>';
}?>>
<?php echo '<legend>'.$tool_name.' '.$promotion_data['name'].'</legend>';
if ($add_type == 'multiple') {
if ('multiple' == $add_type) {
$extraField = new \ExtraField('session');
$extra_field_list = $extraField->get_all_extra_field_by_type(ExtraField::FIELD_TYPE_SELECT);
$new_field_list = [];
@ -172,7 +170,7 @@ if (!empty($errorMsg)) {
<td align="center"><b><?php echo get_lang('Sessions in this promotion'); ?> :</b></td>
</tr>
<?php if ($add_type == 'multiple') {
<?php if ('multiple' == $add_type) {
?>
<tr>
<td align="center">
@ -191,7 +189,7 @@ if (!empty($errorMsg)) {
<td align="center">
<div id="content_source">
<?php
if (!($add_type == 'multiple')) {
if (!('multiple' == $add_type)) {
?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
<div id="ajax_list_users_single"></div>

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
// resetting the course id
$cidReset = true;
@ -28,7 +26,7 @@ $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')];
$tool_name = get_lang('Subscribe class to sessions');
$add_type = 'multiple';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type'] != '') {
if (isset($_REQUEST['add_type']) && '' != $_REQUEST['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
@ -80,7 +78,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
if (!is_array($elements_posted)) {
$elements_posted = [];
}
if ($form_sent == 1) {
if (1 == $form_sent) {
//added a parameter to send emails when registering a user
$usergroup->subscribe_sessions_to_usergroup($id, $elements_posted);
header('Location: usergroups.php');
@ -110,7 +108,7 @@ if (!empty($session_list)) {
}
}
$ajax_search = $add_type === 'unique' ? true : false;
$ajax_search = 'unique' === $add_type ? true : false;
// checking for extra field with filter on
function search_usergroup_sessions($needle, $type)
@ -119,16 +117,16 @@ function search_usergroup_sessions($needle, $type)
$xajax_response = new xajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
if ($type == 'searchbox') {
if ('searchbox' == $type) {
$session_list = SessionManager::get_sessions_list(
['s.name' => ['operator' => 'LIKE', 'value' => "%$needle%"]]
);
} elseif ($type != 'single') {
} elseif ('single' != $type) {
$session_list = SessionManager::get_sessions_list(
['s.name' => ['operator' => 'LIKE', 'value' => "$needle%"]]
);
}
if ($type != 'single') {
if ('single' != $type) {
$return .= '<select id="elements_not_in" name="elements_not_in_name[]" multiple="multiple" size="15" style="width:360px;">';
foreach ($session_list as $row) {
if (!in_array($row['id'], array_keys($elements_in))) {
@ -151,7 +149,7 @@ $xajax->processRequests();
Display::display_header($tool_name);
$add = (empty($_GET['add']) ? '' : Security::remove_XSS($_GET['add']));
if ($add_type == 'multiple') {
if ('multiple' == $add_type) {
$link_add_type_unique = '<a href="'.api_get_self().'?add='.$add.'&add_type=unique">'.
Display::return_icon('single.gif').get_lang('Single registration').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('Multiple registration');
@ -193,7 +191,7 @@ if (!empty($errorMsg)) {
<td align="center"><b><?php echo get_lang('Sessions in group'); ?> :</b></td>
</tr>
<?php if ($add_type == 'multiple') {
<?php if ('multiple' == $add_type) {
?>
<tr>
<td align="center">
@ -213,7 +211,7 @@ if (!empty($errorMsg)) {
<td align="center">
<div id="content_source">
<?php
if (!($add_type == 'multiple')) {
if (!('multiple' == $add_type)) {
?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
<div id="ajax_list_users_single"></div>

@ -1,10 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
// resetting the course id
$cidReset = true;
@ -91,7 +87,7 @@ $new_field_list = [];
if (is_array($extra_field_list)) {
foreach ($extra_field_list as $extra_field) {
//if is enabled to filter and is a "<select>" field type
if ($extra_field[8] == 1 && $extra_field[2] == 4) {
if (1 == $extra_field[8] && 4 == $extra_field[2]) {
$new_field_list[] = [
'name' => $extra_field[3],
'variable' => $extra_field[1], 'data' => $extra_field[9],
@ -116,13 +112,13 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
}
// If "social group" you need to select a role
if ($groupInfo['group_type'] == 1 && empty($relation)) {
if (1 == $groupInfo['group_type'] && empty($relation)) {
Display::addFlash(Display::return_message(get_lang('Select role'), 'warning'));
header('Location: '.api_get_self().'?id='.$id);
exit;
}
if ($form_sent == 1) {
if (1 == $form_sent) {
Display::addFlash(Display::return_message(get_lang('Update successful')));
// Added a parameter to send emails when registering a user
$usergroup->subscribe_users_to_usergroup(
@ -136,7 +132,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
}
}
if (isset($_GET['action']) && $_GET['action'] == 'export') {
if (isset($_GET['action']) && 'export' == $_GET['action']) {
$users = $usergroup->getUserListByUserGroup($id);
if (!empty($users)) {
$data = [
@ -158,7 +154,7 @@ if (is_array($extra_field_list)) {
foreach ($new_field_list as $new_field) {
$varname = 'field_'.$new_field['variable'];
if (UserManager::is_extra_field_available($new_field['variable'])) {
if (isset($_POST[$varname]) && $_POST[$varname] != '0') {
if (isset($_POST[$varname]) && '0' != $_POST[$varname]) {
$use_extra_fields = true;
$extra_field_result[] = UserManager::get_extra_user_data_by_value(
$new_field['variable'],
@ -173,7 +169,7 @@ if (is_array($extra_field_list)) {
if ($use_extra_fields) {
$final_result = [];
if (count($extra_field_result) > 1) {
for ($i = 0; $i < count($extra_field_result) - 1; $i++) {
for ($i = 0; $i < count($extra_field_result) - 1; ++$i) {
if (is_array($extra_field_result[$i + 1])) {
$final_result = array_intersect($extra_field_result[$i], $extra_field_result[$i + 1]);
}
@ -217,7 +213,7 @@ if (api_is_western_name_order()) {
}
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
if ('true' === $orderListByOfficialCode) {
$order = ['official_code', 'lastname'];
}
@ -249,7 +245,7 @@ if (!empty($complete_user_list)) {
}
// Avoid anonymous users
if ($item['status'] == 6) {
if (6 == $item['status']) {
continue;
}
@ -261,7 +257,7 @@ if (!empty($complete_user_list)) {
).' ('.$item['username'].') '.$officialCode;
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
if ('true' === $orderListByOfficialCode) {
$officialCode = !empty($item['official_code']) ? $item['official_code'].' - ' : '? - ';
$person_name = $officialCode.api_get_person_name(
$item['firstname'],
@ -297,7 +293,7 @@ if (!empty($user_list)) {
}
// Avoid anonymous users
if ($item['status'] == ANONYMOUS) {
if (ANONYMOUS == $item['status']) {
continue;
}
@ -308,7 +304,7 @@ if (!empty($user_list)) {
).' ('.$item['username'].') '.$officialCode;
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
if ('true' === $orderListByOfficialCode) {
$officialCode = !empty($item['official_code']) ? $item['official_code'].' - ' : '? - ';
$person_name = $officialCode.api_get_person_name(
$item['firstname'],
@ -379,19 +375,19 @@ echo Display::input('hidden', 'add_type', null);
?>
<div class="row">
<div class="col-md-5">
<?php if ($data['group_type'] == UserGroup::SOCIAL_CLASS) {
<?php if (UserGroup::SOCIAL_CLASS == $data['group_type']) {
?>
<select name="relation" id="relation">
<option value=""><?php echo get_lang('Relation type selection'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_ADMIN; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_ADMIN) ? 'selected=selected' : ''; ?> >
<option value="<?php echo GROUP_USER_PERMISSION_ADMIN; ?>" <?php echo isset($relation) && GROUP_USER_PERMISSION_ADMIN == $relation ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Admin'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_READER; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_READER) ? 'selected=selected' : ''; ?> >
<option value="<?php echo GROUP_USER_PERMISSION_READER; ?>" <?php echo isset($relation) && GROUP_USER_PERMISSION_READER == $relation ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Reader'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_PENDING_INVITATION; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_PENDING_INVITATION) ? 'selected=selected' : ''; ?> >
<option value="<?php echo GROUP_USER_PERMISSION_PENDING_INVITATION; ?>" <?php echo isset($relation) && GROUP_USER_PERMISSION_PENDING_INVITATION == $relation ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Pending invitation'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_MODERATOR; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_MODERATOR) ? 'selected=selected' : ''; ?> >
<option value="<?php echo GROUP_USER_PERMISSION_MODERATOR; ?>" <?php echo isset($relation) && GROUP_USER_PERMISSION_MODERATOR == $relation ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Moderator'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_HRM; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_HRM) ? 'selected=selected' : ''; ?> >
<option value="<?php echo GROUP_USER_PERMISSION_HRM; ?>" <?php echo isset($relation) && GROUP_USER_PERMISSION_HRM == $relation ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Human Resources Manager'); ?></option>
</select>
<?php

@ -1,8 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
// resetting the course id
$cidReset = true;
@ -55,6 +54,7 @@ if ($form->validate()) {
} else {
Display::addFlash(Display::return_message(get_lang('The app/cache/ directory cleanup has been executed successfully.')));
}
try {
\Chamilo\CoreBundle\Composer\ScriptHandler::dumpCssFiles();
Display::addFlash(Display::return_message(get_lang('The styles and assets in the web/ folder have been refreshed.')));

@ -1,10 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Careers dashboard.
*
* @package chamilo.admin.career
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -111,7 +110,7 @@ if (!empty($careers)) {
$promotion_array = [];
if (!empty($promotions)) {
foreach ($promotions as $promotion_item) {
if ($promotion_item['status'] == 0) {
if (0 == $promotion_item['status']) {
continue; //avoid status = 0
}

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
/* For licensing terms, see /license.txt */
/*
*
@ -17,7 +14,7 @@ ALTER TABLE extra_field_values modify column value longtext null;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
if (api_get_configuration_value('allow_career_diagram') == false) {
if (false == api_get_configuration_value('allow_career_diagram')) {
api_not_allowed(true);
}
@ -56,10 +53,10 @@ $interbreadcrumb[] = [
$action = isset($_GET['action']) ? $_GET['action'] : '';
if ($action == 'add') {
if ('add' == $action) {
$interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
$toolName = get_lang('Add');
} elseif ($action == 'edit') {
} elseif ('edit' == $action) {
$interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')];
$toolName = get_lang('Edit');

@ -3,9 +3,6 @@
use ChamiloSession as Session;
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -32,10 +29,10 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
$check = Security::check_token('request');
$token = Security::get_token();
if ($action == 'add') {
if ('add' == $action) {
$interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
$tool_name = get_lang('Add');
} elseif ($action == 'edit') {
} elseif ('edit' == $action) {
$interbreadcrumb[] = ['url' => 'careers.php', 'name' => get_lang('Careers')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')];
$tool_name = get_lang('Edit');
@ -88,8 +85,8 @@ if (api_is_platform_admin()) {
$actionLinks = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
$diagramLink.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("Please confirm your choice"), ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("Please confirm your choice"), ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang('Please confirm your choice'), ENT_QUOTES))."\'".')) return false;" href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'.
'\';
}';
} else {
@ -108,7 +105,7 @@ switch ($action) {
case 'add':
api_protect_admin_script();
if (api_get_session_id() != 0 &&
if (0 != api_get_session_id() &&
!api_is_allowed_to_session_edit(false, true)
) {
api_not_allowed();
@ -140,6 +137,7 @@ switch ($action) {
$form->setConstants(['sec_token' => $token]);
$content .= $form->returnForm();
}
break;
case 'edit':
api_protect_admin_script();
@ -197,6 +195,7 @@ switch ($action) {
$form->setConstants(['sec_token' => $token]);
$content .= $form->returnForm();
}
break;
case 'delete':
api_protect_admin_script();
@ -211,10 +210,11 @@ switch ($action) {
}
header('Location: '.$listUrl);
exit;
break;
case 'copy':
api_protect_admin_script();
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
if (0 != api_get_session_id() && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed(true);
}
if ($check) {
@ -228,9 +228,11 @@ switch ($action) {
header('Location: '.$listUrl);
exit;
break;
default:
$content = $career->display();
break;
}

@ -5,8 +5,6 @@ use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
/**
* Edition of extensions configuration.
*
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -66,6 +64,7 @@ if (isset($_POST['activeExtension'])) {
WHERE variable="service_ppt2lp"
AND subkey="size"';
Database::query($sql);
break;
}
}

@ -1,12 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
/**
* This script displays a form for registering new users.
*
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -14,10 +13,10 @@ require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
// Load terms & conditions from the current lang
if (api_get_setting('allow_terms_conditions') === 'true') {
if ('true' === api_get_setting('allow_terms_conditions')) {
$get = array_keys($_GET);
if (isset($get)) {
if (isset($get[0]) && $get[0] == 'legal') {
if (isset($get[0]) && 'legal' == $get[0]) {
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview = LegalManager::get_last_condition($language);
@ -52,6 +51,7 @@ if (!empty($action)) {
switch ($action) {
case 'edit_top':
$tool_name = get_lang('Edit Note');
break;
}
}
@ -156,7 +156,7 @@ if (!empty($action)) {
}*/
$form = new FormValidator('registration');
if (api_get_setting('allow_terms_conditions') === 'true') {
if ('true' === api_get_setting('allow_terms_conditions')) {
$display_all_form = !isset($_SESSION['update_term_and_condition']['user_id']);
} else {
$display_all_form = true;
@ -179,7 +179,7 @@ if ($display_all_form) {
// EMAIL
$form->addElement('text', 'email', get_lang('e-mail'), ['size' => 40, 'disabled' => 'disabled']);
if (api_get_setting('registration', 'email') == 'true') {
if ('true' == api_get_setting('registration', 'email')) {
$form->addRule('email', get_lang('Required field'), 'required');
}
$form->addRule('email', get_lang('e-mailWrong'), 'email');
@ -201,12 +201,12 @@ if ($display_all_form) {
// PHONE
$form->addElement('text', 'phone', get_lang('Phone'), ['size' => 40, 'disabled' => 'disabled']);
if (api_get_setting('registration', 'phone') == 'true') {
if ('true' == api_get_setting('registration', 'phone')) {
$form->addRule('phone', get_lang('Required field'), 'required');
}
// LANGUAGE
if (api_get_setting('registration', 'language') == 'true') {
if ('true' == api_get_setting('registration', 'language')) {
$form->addSelectLanguage(
'language',
get_lang('Language'),
@ -216,47 +216,47 @@ if ($display_all_form) {
}
// STUDENT/TEACHER
if (api_get_setting('allow_registration_as_teacher') != 'false') {
if ('false' != api_get_setting('allow_registration_as_teacher')) {
$form->addElement('radio', 'status', get_lang('Status'), get_lang('Student (follows courses)'), STUDENT, ['disabled' => 'disabled']);
$form->addElement('radio', 'status', null, get_lang('Teacher (creates courses)'), COURSEMANAGER, ['disabled' => 'disabled']);
}
// EXTENDED FIELDS
if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true'
if ('true' == api_get_setting('extended_profile') &&
'true' == api_get_setting('extendedprofile_registration', 'mycomptetences')
) {
$form->addHtmlEditor('competences', get_lang('My competences'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
}
if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true'
if ('true' == api_get_setting('extended_profile') &&
'true' == api_get_setting('extendedprofile_registration', 'mydiplomas')
) {
$form->addHtmlEditor('diplomas', get_lang('My diplomas'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
}
if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'myteach') == 'true'
if ('true' == api_get_setting('extended_profile') &&
'true' == api_get_setting('extendedprofile_registration', 'myteach')
) {
$form->addHtmlEditor('teach', get_lang('What I am able to teach'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
}
if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true'
if ('true' == api_get_setting('extended_profile') &&
'true' == api_get_setting('extendedprofile_registration', 'mypersonalopenarea')
) {
$form->addHtmlEditor('openarea', get_lang('My personal open area'), false, false, ['ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130']);
}
if (api_get_setting('extended_profile') == 'true') {
if (api_get_setting('extendedprofile_registrationrequired', 'mycomptetences') == 'true') {
if ('true' == api_get_setting('extended_profile')) {
if ('true' == api_get_setting('extendedprofile_registrationrequired', 'mycomptetences')) {
$form->addRule('competences', get_lang('Required field'), 'required');
}
if (api_get_setting('extendedprofile_registrationrequired', 'mydiplomas') == 'true') {
if ('true' == api_get_setting('extendedprofile_registrationrequired', 'mydiplomas')) {
$form->addRule('diplomas', get_lang('Required field'), 'required');
}
if (api_get_setting('extendedprofile_registrationrequired', 'myteach') == 'true') {
if ('true' == api_get_setting('extendedprofile_registrationrequired', 'myteach')) {
$form->addRule('teach', get_lang('Required field'), 'required');
}
if (api_get_setting('extendedprofile_registrationrequired', 'mypersonalopenarea') == 'true') {
if ('true' == api_get_setting('extendedprofile_registrationrequired', 'mypersonalopenarea')) {
$form->addRule('openarea', get_lang('Required field'), 'required');
}
}
@ -266,7 +266,7 @@ if ($display_all_form) {
}
// Terms and conditions
if (api_get_setting('allow_terms_conditions') == 'true') {
if ('true' == api_get_setting('allow_terms_conditions')) {
$language = api_get_interface_language();
$language = api_get_language_id($language);
$term_preview = LegalManager::get_last_condition($language);
@ -287,7 +287,7 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
$form->addElement('hidden', 'legal_accept_type', $term_preview['version'].':'.$term_preview['language_id']);
$form->addElement('hidden', 'legal_info', $term_preview['id'].':'.$term_preview['language_id']);
if ($term_preview['type'] == 1) {
if (1 == $term_preview['type']) {
$form->addElement(
'checkbox',
'legal_accept',
@ -307,7 +307,7 @@ $form->addButtonSave(get_lang('Register'));
$defaults['status'] = STUDENT;
if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') {
if (isset($_SESSION['user_language_choice']) && '' != $_SESSION['user_language_choice']) {
$defaults['language'] = $_SESSION['user_language_choice'];
} else {
$defaults['language'] = api_get_setting('platformLanguage');
@ -338,7 +338,7 @@ $content = Display::page_header($tool_name);
//}
//api_display_tool_title($tool_name);
if (api_get_setting('allow_registration') == 'approval') {
if ('approval' == api_get_setting('allow_registration')) {
$content .= Display::return_message(get_lang('Your account has to be approved'), 'normal');
}

@ -1,11 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Julio Montoya <gugli100@gmail.com> BeezNest 2012
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -49,7 +48,7 @@ if (isset($form)) {
$values = $form->getSubmitValues();
// Fix only for bbb
if ($pluginName == 'bbb') {
if ('bbb' == $pluginName) {
if (!isset($values['global_conference_allow_roles'])) {
$values['global_conference_allow_roles'] = [];
}

@ -1,12 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\CourseCategory;
use Chamilo\CoreBundle\Repository\CourseCategoryRepository;
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
@ -133,7 +131,7 @@ $form->applyFilter('department_url', 'html_filter');
// Course language.
$languages = api_get_languages();
if (count($languages) === 1) {
if (1 === count($languages)) {
// If there's only one language available, there's no point in asking
$form->addElement('hidden', 'course_language', $languages[0]);
} else {
@ -145,7 +143,7 @@ if (count($languages) === 1) {
);
}
if (api_get_setting('teacher_can_select_course_template') === 'true') {
if ('true' === api_get_setting('teacher_can_select_course_template')) {
$form->addElement(
'select_ajax',
'course_template',

@ -1,9 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
@ -25,13 +23,13 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
$myCourseListAsCategory = api_get_configuration_value('my_courses_list_as_category');
if (!empty($action)) {
if ($action == 'delete') {
if ('delete' == $action) {
CourseCategory::deleteNode($categoryId);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header('Location: '.api_get_self().'?category='.Security::remove_XSS($category));
exit();
} elseif (($action == 'add' || $action == 'edit') && isset($_POST['formSent']) && $_POST['formSent']) {
if ($action == 'add') {
} elseif (('add' == $action || 'edit' == $action) && isset($_POST['formSent']) && $_POST['formSent']) {
if ('add' == $action) {
$ret = CourseCategory::addNode(
$_POST['code'],
$_POST['name'],
@ -72,7 +70,7 @@ if (!empty($action)) {
Display::addFlash($errorMsg);
header('Location: '.api_get_path(WEB_CODE_PATH).'admin/course_category.php');
exit;
} elseif ($action == 'moveUp') {
} elseif ('moveUp' == $action) {
CourseCategory::moveNodeUp($categoryId, $_GET['tree_pos'], $category);
header('Location: '.api_get_self().'?category='.Security::remove_XSS($category));
Display::addFlash(Display::return_message(get_lang('Update successful')));
@ -89,7 +87,7 @@ $interbreadcrumb[] = [
Display::display_header($tool_name);
$urlId = api_get_current_access_url_id();
if ($action == 'add' || $action == 'edit') {
if ('add' == $action || 'edit' == $action) {
echo '<div class="actions">';
echo Display::url(
Display::return_icon('folder_up.png', get_lang('Back'), '', ICON_SIZE_MEDIUM),
@ -97,7 +95,7 @@ if ($action == 'add' || $action == 'edit') {
);
echo '</div>';
$form_title = ($action == 'add') ? get_lang('Add category') : get_lang('Edit this category');
$form_title = 'add' == $action ? get_lang('Add category') : get_lang('Edit this category');
if (!empty($category)) {
$form_title .= ' '.get_lang('Into').' '.Security::remove_XSS($category);
}
@ -105,7 +103,7 @@ if ($action == 'add' || $action == 'edit') {
$form = new FormValidator('course_category', 'post', $url);
$form->addElement('header', '', $form_title);
$form->addElement('hidden', 'formSent', 1);
$form->addElement('text', 'code', get_lang("Category code"));
$form->addElement('text', 'code', get_lang('Category code'));
if (api_get_configuration_value('save_titles_as_html')) {
$form->addHtmlEditor(
@ -116,7 +114,7 @@ if ($action == 'add' || $action == 'edit') {
['ToolbarSet' => 'TitleAsHtml']
);
} else {
$form->addElement('text', 'name', get_lang("Category name"));
$form->addElement('text', 'name', get_lang('Category name'));
$form->addRule('name', get_lang('Please enter a code and a name for the category'), 'required');
}
@ -149,7 +147,7 @@ if ($action == 'add' || $action == 'edit') {
);
$form->addFile('image', get_lang('Image'), ['id' => 'picture', 'class' => 'picture-form', 'accept' => 'image/*', 'crop_image' => true]);
if ($action == 'edit' && !empty($categoryInfo['image'])) {
if ('edit' == $action && !empty($categoryInfo['image'])) {
$form->addElement('checkbox', 'delete_picture', null, get_lang('Delete picture'));
$form->addHtml('
<div class="form-group row">
@ -178,7 +176,7 @@ if ($action == 'add' || $action == 'edit') {
$form->display();
} else {
// If multiple URLs and not main URL, prevent deletion and inform user
if ($action == 'delete' && api_get_multiple_access_url() && $urlId != 1) {
if ('delete' == $action && api_get_multiple_access_url() && 1 != $urlId) {
echo Display::return_message(get_lang('Course categories are global over multiple portals configurations. Changes are only allowed in the main administrative portal.'), 'warning');
}
echo '<div class="actions">';
@ -193,7 +191,7 @@ if ($action == 'add' || $action == 'edit') {
);
}
if (empty($parentInfo) || $parentInfo['auth_cat_child'] == 'TRUE') {
if (empty($parentInfo) || 'TRUE' == $parentInfo['auth_cat_child']) {
$newCategoryLink = Display::url(
Display::return_icon('new_folder.png', get_lang('Add category'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'admin/course_category.php?action=add&category='.Security::remove_XSS($category)

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\CourseCategory;
@ -35,8 +36,8 @@ if (empty($courseInfo)) {
}
$tool_name = get_lang('Edit course information');
$interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('Administration')];
$interbreadcrumb[] = ["url" => "course_list.php", "name" => get_lang('Course list')];
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
$interbreadcrumb[] = ['url' => 'course_list.php', 'name' => get_lang('Course list')];
// Get all course categories
$table_user = Database::get_main_table(TABLE_MAIN_USER);
@ -95,7 +96,7 @@ while ($obj = Database::fetch_object($res)) {
}
// Case where there is no teacher in the course
if (count($course_teachers) == 0) {
if (0 == count($course_teachers)) {
$sql = 'SELECT tutor_name FROM '.$course_table.' WHERE code="'.$course_code.'"';
$res = Database::query($sql);
$tutor_name = Database::result($res, 0, 0);
@ -206,7 +207,7 @@ if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) {
);
}
$allowEditSessionCoaches = api_get_configuration_value('disabled_edit_session_coaches_course_editing_course') === false;
$allowEditSessionCoaches = false === api_get_configuration_value('disabled_edit_session_coaches_course_editing_course');
$coursesInSession = SessionManager::get_session_by_course($courseInfo['real_id']);
if (!empty($coursesInSession) && $allowEditSessionCoaches) {
foreach ($coursesInSession as $session) {
@ -253,7 +254,7 @@ $form->applyFilter('department_url', 'trim');
$form->addSelectLanguage('course_language', get_lang('Course language'));
$group = [];
$group[] = $form->createElement('radio', 'visibility', get_lang("Course access"), get_lang('Public - access allowed for the whole world'), COURSE_VISIBILITY_OPEN_WORLD);
$group[] = $form->createElement('radio', 'visibility', get_lang('Course access'), get_lang('Public - access allowed for the whole world'), COURSE_VISIBILITY_OPEN_WORLD);
$group[] = $form->createElement('radio', 'visibility', null, get_lang(' Open - access allowed for users registered on the platform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('Private access (access authorized to group members only)'), COURSE_VISIBILITY_REGISTERED);
$group[] = $form->createElement('radio', 'visibility', null, get_lang('Closed - the course is only accessible to the teachers'), COURSE_VISIBILITY_CLOSED);
@ -317,7 +318,7 @@ if ($form->validate()) {
$_configuration[$urlId]['hosting_limit_active_courses'] > 0
) {
// Check if
if ($courseInfo['visibility'] == COURSE_VISIBILITY_HIDDEN &&
if (COURSE_VISIBILITY_HIDDEN == $courseInfo['visibility'] &&
$visibility != $courseInfo['visibility']
) {
$num = CourseManager::countActiveCourses($urlId);

@ -1,10 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This tool allows platform admins to export courses to CSV file.
*
* @package chamilo.admin
*/
$cidReset = true;
@ -24,10 +23,10 @@ $courses = $selected_courses = [];
if (isset($_POST['formSent']) && $_POST['formSent']) {
$formSent = $_POST['formSent'];
$select_type = intval($_POST['select_type']);
$select_type = (int) ($_POST['select_type']);
$file_type = $_POST['file_type'];
if ($select_type == 2) {
if (2 == $select_type) {
// Get selected courses from courses list in form sent
$selected_courses = $_POST['course_code'];
if (is_array($selected_courses)) {
@ -75,7 +74,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
if (is_array($usersInCourse) && !empty($usersInCourse)) {
foreach ($usersInCourse as $user) {
if ($user['status_rel'] == COURSEMANAGER) {
if (COURSEMANAGER == $user['status_rel']) {
$dataToExport['teachers'] .= $user['username'].'|';
} else {
$dataToExport['students'] .= $user['username'].'|';
@ -93,12 +92,15 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
// Remove header
unset($listToExport[0]);
Export::arrayToXml($listToExport, $archiveFile);
break;
case 'csv':
Export::arrayToCsv($listToExport, $archiveFile);
break;
case 'xls':
Export::arrayToXls($listToExport, $archiveFile);
break;
}
} else {

@ -11,7 +11,7 @@
*
* @param array $courses
*
* @return array $errors
* @return array
*/
function validate_courses_data($courses)
{
@ -64,7 +64,7 @@ function validate_courses_data($courses)
if (empty($categoryInfo)) {
CourseCategory::addNode(
$course['CourseCategory'],
$course['CourseCategoryName'] ? $course['CourseCategoryName'] : $course['CourseCategory'],
$course['CourseCategoryName'] ?: $course['CourseCategory'],
'TRUE',
null
);
@ -157,9 +157,7 @@ function save_courses_data($courses)
*/
function parse_csv_courses_data($file)
{
$courses = Import::csv_reader($file);
return $courses;
return Import::csv_reader($file);
}
$cidReset = true;
@ -189,7 +187,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
} else {
$allowed_file_mimetype = ['csv'];
$ext_import_file = substr($_FILES['import_file']['name'], (strrpos($_FILES['import_file']['name'], '.') + 1));
$ext_import_file = substr($_FILES['import_file']['name'], strrpos($_FILES['import_file']['name'], '.') + 1);
if (!in_array($ext_import_file, $allowed_file_mimetype)) {
echo Display::return_message(get_lang('You must import a file corresponding to the selected format'), 'error');
@ -197,14 +195,14 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$courses = parse_csv_courses_data($_FILES['import_file']['tmp_name']);
$errors = validate_courses_data($courses);
if (count($errors) == 0) {
if (0 == count($errors)) {
save_courses_data($courses);
}
}
}
}
if (isset($errors) && count($errors) != 0) {
if (isset($errors) && 0 != count($errors)) {
$error_message = '<ul>';
foreach ($errors as $index => $error_course) {
$error_message .= '<li>'.get_lang('Line').' '.$error_course['line'].': <strong>'.$error_course['error'].'</strong>: ';

@ -4,8 +4,6 @@
* This script gives information about a course.
*
* @author Bart Mollet
*
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -70,8 +68,8 @@ function get_course_usage($course, $session_id = 0)
$usage = [];
$conditionSession = '';
if ($session_id !== '') {
$session_id = intval($session_id);
if ('' !== $session_id) {
$session_id = (int) $session_id;
$conditionSession = " AND session_id = '$session_id' ";
}
@ -92,8 +90,8 @@ function get_course_usage($course, $session_id = 0)
return $usage;
}
$interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('Administration')];
$interbreadcrumb[] = ["url" => 'course_list.php', "name" => get_lang('Courses')];
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
$interbreadcrumb[] = ['url' => 'course_list.php', 'name' => get_lang('Courses')];
$courseId = $courseInfo['real_id'];
$tool_name = $courseInfo['title'].' ('.$courseInfo['visual_code'].')';
Display::display_header($tool_name);
@ -119,7 +117,7 @@ $table->set_header(0, get_lang('tool'), true);
$table->set_header(1, get_lang('number of items'), true);
$table->display();
/**
/*
* Show all users subscribed in this course.
*/
echo Display::page_header(get_lang('Users'));
@ -129,10 +127,10 @@ $table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT *, cu.status as course_status
FROM $table_course_user cu, $table_user u";
if (api_is_multiple_url_enabled()) {
$sql .= " INNER JOIN ".Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER)." url_rel_user
$sql .= ' INNER JOIN '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' url_rel_user
ON
u.user_id = url_rel_user.user_id AND
url_rel_user.access_url_id = ".api_get_current_access_url_id();
url_rel_user.access_url_id = '.api_get_current_access_url_id();
}
$sql .= " WHERE
cu.user_id = u.user_id AND
@ -153,7 +151,7 @@ if (Database::num_rows($res) > 0) {
$user[] = $obj->firstname;
}
$user[] = Display:: encrypted_mailto_link($obj->email, $obj->email);
$user[] = $obj->course_status == 5 ? get_lang('Learner') : get_lang('Trainer');
$user[] = 5 == $obj->course_status ? get_lang('Learner') : get_lang('Trainer');
$user[] = '<a href="user_information.php?user_id='.$obj->user_id.'">'.
Display::return_icon('info2.png', get_lang('user information')).'</a>';
$users[] = $user;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -27,7 +28,7 @@ function get_number_of_courses()
$sql = "SELECT COUNT(c.id) AS total_number_of_items FROM $course_table c";
if ((api_is_platform_admin() || api_is_session_admin()) &&
api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1
api_is_multiple_url_enabled() && -1 != api_get_current_access_url_id()
) {
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql .= " INNER JOIN $access_url_rel_course_table url_rel_course
@ -37,7 +38,7 @@ function get_number_of_courses()
$sql .= " LEFT JOIN $tblCourseCategory ON c.category_id = course_category.id ";
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string("%".$_GET['keyword']."%");
$keyword = Database::escape_string('%'.$_GET['keyword'].'%');
$sql .= " WHERE (
c.title LIKE '".$keyword."' OR
c.code LIKE '".$keyword."' OR
@ -45,13 +46,13 @@ function get_number_of_courses()
)
";
} elseif (isset($_GET['keyword_code'])) {
$keyword_code = Database::escape_string("%".$_GET['keyword_code']."%");
$keyword_title = Database::escape_string("%".$_GET['keyword_title']."%");
$keyword_code = Database::escape_string('%'.$_GET['keyword_code'].'%');
$keyword_title = Database::escape_string('%'.$_GET['keyword_title'].'%');
$keyword_category = isset($_GET['keyword_category'])
? Database::escape_string("%".$_GET['keyword_category']."%")
? Database::escape_string('%'.$_GET['keyword_category'].'%')
: null;
$keyword_language = Database::escape_string("%".$_GET['keyword_language']."%");
$keyword_visibility = Database::escape_string("%".$_GET['keyword_visibility']."%");
$keyword_language = Database::escape_string('%'.$_GET['keyword_language'].'%');
$keyword_visibility = Database::escape_string('%'.$_GET['keyword_visibility'].'%');
$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
$keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
@ -71,9 +72,9 @@ function get_number_of_courses()
// adding the filter to see the user's only of the current access_url
if ((api_is_platform_admin() || api_is_session_admin()) &&
api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1
api_is_multiple_url_enabled() && -1 != api_get_current_access_url_id()
) {
$sql .= " AND url_rel_course.access_url_id = ".api_get_current_access_url_id();
$sql .= ' AND url_rel_course.access_url_id = '.api_get_current_access_url_id();
}
$res = Database::query($sql);
@ -117,7 +118,7 @@ function get_course_data($from, $number_of_items, $column, $direction)
LEFT JOIN $tblCourseCategory category ON course.category_id = category.id ";
if ((api_is_platform_admin() || api_is_session_admin()) &&
api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1
api_is_multiple_url_enabled() && -1 != api_get_current_access_url_id()
) {
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql .= " INNER JOIN $access_url_rel_course_table url_rel_course
@ -125,7 +126,7 @@ function get_course_data($from, $number_of_items, $column, $direction)
}
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string("%".trim($_GET['keyword'])."%");
$keyword = Database::escape_string('%'.trim($_GET['keyword']).'%');
$sql .= " WHERE (
title LIKE '".$keyword."' OR
course.code LIKE '".$keyword."' OR
@ -133,13 +134,13 @@ function get_course_data($from, $number_of_items, $column, $direction)
)
";
} elseif (isset($_GET['keyword_code'])) {
$keyword_code = Database::escape_string("%".$_GET['keyword_code']."%");
$keyword_title = Database::escape_string("%".$_GET['keyword_title']."%");
$keyword_code = Database::escape_string('%'.$_GET['keyword_code'].'%');
$keyword_title = Database::escape_string('%'.$_GET['keyword_title'].'%');
$keyword_category = isset($_GET['keyword_category'])
? Database::escape_string("%".$_GET['keyword_category']."%")
? Database::escape_string('%'.$_GET['keyword_category'].'%')
: null;
$keyword_language = Database::escape_string("%".$_GET['keyword_language']."%");
$keyword_visibility = Database::escape_string("%".$_GET['keyword_visibility']."%");
$keyword_language = Database::escape_string('%'.$_GET['keyword_language'].'%');
$keyword_visibility = Database::escape_string('%'.$_GET['keyword_visibility'].'%');
$keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']);
$keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']);
@ -158,9 +159,9 @@ function get_course_data($from, $number_of_items, $column, $direction)
// Adding the filter to see the user's only of the current access_url.
if ((api_is_platform_admin() || api_is_session_admin()) &&
api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1
api_is_multiple_url_enabled() && -1 != api_get_current_access_url_id()
) {
$sql .= " AND url_rel_course.access_url_id=".api_get_current_access_url_id();
$sql .= ' AND url_rel_course.access_url_id='.api_get_current_access_url_id();
}
$sql .= " ORDER BY col$column $direction ";
@ -179,8 +180,8 @@ function get_course_data($from, $number_of_items, $column, $direction)
$course[1] = get_course_visibility_icon($course[8]).PHP_EOL
.Display::url(Security::remove_XSS($course[1]), $coursePath.$course[9].'/index.php').PHP_EOL
.$show_visual_code;
$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[5] = SUBSCRIBE_ALLOWED == $course[5] ? get_lang('Yes') : get_lang('No');
$course[6] = UNSUBSCRIBE_ALLOWED == $course[6] ? get_lang('Yes') : get_lang('No');
$language = isset($languages[$course[3]]) ? $languages[$course[3]] : $course[3];
$courseCode = $course[0];
@ -272,8 +273,8 @@ function get_course_data_by_session($from, $number_of_items, $column, $direction
";
if (isset($_GET['session_id']) && !empty($_GET['session_id'])) {
$sessionId = intval($_GET['session_id']);
$sql .= " WHERE s.id = ".$sessionId;
$sessionId = (int) ($_GET['session_id']);
$sql .= ' WHERE s.id = '.$sessionId;
}
$sql .= " ORDER BY col$column $direction ";
@ -290,8 +291,8 @@ function get_course_data_by_session($from, $number_of_items, $column, $direction
$course[1].
'</a> '.
$showVisualCode;
$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[5] = SUBSCRIBE_ALLOWED == $course[5] ? get_lang('Yes') : get_lang('No');
$course[6] = UNSUBSCRIBE_ALLOWED == $course[6] ? get_lang('Yes') : get_lang('No');
$row = [
$course[0],
$course[1],
@ -325,6 +326,7 @@ function get_course_visibility_icon($visibility)
get_lang('Closed - the course is only accessible to the teachers'),
['style' => $style]
);
break;
case 1:
return Display::return_icon(
@ -332,6 +334,7 @@ function get_course_visibility_icon($visibility)
get_lang('Private access (access authorized to group members only) access (access authorized to group members only)'),
['style' => $style]
);
break;
case 2:
return Display::return_icon(
@ -339,6 +342,7 @@ function get_course_visibility_icon($visibility)
get_lang(' Open - access allowed for users registered on the platform'),
['style' => $style]
);
break;
case 3:
return Display::return_icon(
@ -346,6 +350,7 @@ function get_course_visibility_icon($visibility)
get_lang('Public - access allowed for the whole world'),
['style' => $style]
);
break;
case 4:
return Display::return_icon(
@ -353,6 +358,7 @@ function get_course_visibility_icon($visibility)
get_lang('Hidden - Completely hidden to all users except the administrators'),
['style' => $style]
);
break;
default:
return '';
@ -373,6 +379,7 @@ if (isset($_POST['action'])) {
Display::addFlash(Display::return_message(get_lang('Deleted')));
}
break;
}
}
@ -380,7 +387,7 @@ $content = '';
$message = '';
$actions = '';
if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
if (isset($_GET['search']) && 'advanced' === $_GET['search']) {
// Get all course categories
$interbreadcrumb[] = [
'url' => 'index.php',
@ -411,7 +418,7 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
$el = $form->addSelectLanguage('keyword_language', get_lang('Course language'));
$el->addOption(get_lang('All'), '%');
$form->addElement('radio', 'keyword_visibility', get_lang("Course access"), get_lang('Public - access allowed for the whole world'), COURSE_VISIBILITY_OPEN_WORLD);
$form->addElement('radio', 'keyword_visibility', get_lang('Course access'), get_lang('Public - access allowed for the whole world'), COURSE_VISIBILITY_OPEN_WORLD);
$form->addElement('radio', 'keyword_visibility', null, get_lang(' Open - access allowed for users registered on the platform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$form->addElement('radio', 'keyword_visibility', null, get_lang('Private access (access authorized to group members only) access (access authorized to group members only)'), COURSE_VISIBILITY_REGISTERED);
$form->addElement('radio', 'keyword_visibility', null, get_lang('Closed - the course is only accessible to the teachers'), COURSE_VISIBILITY_CLOSED);
@ -498,7 +505,7 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
api_get_path(WEB_CODE_PATH).'admin/course_add.php'
);
if (api_get_setting('course_validation') === 'true') {
if ('true' === api_get_setting('course_validation')) {
$actions1 .= Display::url(
Display::return_icon(
'course_request_pending.png',

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* A list containig the accepted course requests.
*
* @package chamilo.admin
*
* @author José Manuel Abuin Mosquera <chema@cesga.es>, 2010
* @author Bruno Rubio Gayo <brubio@cesga.es>, 2010
@ -18,15 +18,15 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
// A check whether the course validation feature is enabled.
$course_validation_feature = api_get_setting('course_validation') == 'true';
$course_validation_feature = 'true' == api_get_setting('course_validation');
// Filltering passed to this page parameters.
$delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['delete_course_request']) : '';
$delete_course_request = isset($_GET['delete_course_request']) ? (int) ($_GET['delete_course_request']) : '';
$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : '';
$is_error_message = !empty($_GET['is_error_message']);
if ($course_validation_feature) {
/**
/*
* Deletion of a course request.
*/
if (!empty($delete_course_request)) {
@ -40,7 +40,7 @@ if ($course_validation_feature) {
$is_error_message = true;
}
} elseif (isset($_POST['action'])) {
/**
/*
* Form actions: delete.
*/
switch ($_POST['action']) {
@ -55,6 +55,7 @@ if ($course_validation_feature) {
$message = $success ? get_lang('The selected course requests have been deleted.') : get_lang('Some of the selected course requests have not been deleted due to internal error.');
$is_error_message = !$success;
}
break;
}
}
@ -84,9 +85,9 @@ function get_request_data($from, $number_of_items, $column, $direction)
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
$tblCourseCategory = Database::get_main_table(TABLE_MAIN_CATEGORY);
$from = intval($from);
$number_of_items = intval($number_of_items);
$column = intval($column);
$from = (int) $from;
$number_of_items = (int) $number_of_items;
$column = (int) $column;
$direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction;
$sql = "SELECT
@ -101,7 +102,7 @@ function get_request_data($from, $number_of_items, $column, $direction)
LEFT JOIN $tblCourseCategory on course.category_id = course_category.id
WHERE status = ".COURSE_REQUEST_ACCEPTED;
if ($keyword != '') {
if ('' != $keyword) {
$sql .= " AND (
title LIKE '%".$keyword."%' OR
code LIKE '%".$keyword."%' OR
@ -127,7 +128,8 @@ function get_request_data($from, $number_of_items, $column, $direction)
function modify_filter($id)
{
$code = CourseRequestManager::get_course_request_code($id);
$result = '<a href="course_request_edit.php?id='.$id.'&caller=1">'.
return '<a href="course_request_edit.php?id='.$id.'&caller=1">'.
Display::return_icon('edit.png', get_lang('Edit'), ['style' => 'vertical-align: middle;']).'</a>'.
'&nbsp;<a href="?delete_course_request='.$id.'">'.
Display::return_icon(
@ -139,8 +141,6 @@ function modify_filter($id)
]
).
'</a>';
return $result;
}
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* A page for detailed preview or edition of a given course request.
*
* @package chamilo.admin
*
* @author Ivan Tcholakov <ivantcholakov@gmail.com>, 2010
*/
@ -16,11 +16,11 @@ $tool_name = get_lang('Edit a course request');
api_protect_admin_script();
// A check whether the course validation feature is enabled.
$course_validation_feature = api_get_setting('course_validation') == 'true';
$course_validation_feature = 'true' == api_get_setting('course_validation');
// Filtering passed to this page parameters.
$id = intval($_GET['id']);
$caller = intval($_GET['caller']);
$id = (int) ($_GET['id']);
$caller = (int) ($_GET['caller']);
if ($course_validation_feature) {
// Retrieve request's data from the corresponding database record.
@ -103,15 +103,15 @@ if ($course_validation_feature) {
// Submit buttons.
$submit_buttons[] = $form->addButtonSave(get_lang('Save'), 'save_button', true);
if ($course_request_info['status'] != COURSE_REQUEST_ACCEPTED) {
if (COURSE_REQUEST_ACCEPTED != $course_request_info['status']) {
$submit_buttons[] = $form->addButtonSave(get_lang('Accept'), 'accept_button', true);
}
if ($course_request_info['status'] != COURSE_REQUEST_ACCEPTED &&
$course_request_info['status'] != COURSE_REQUEST_REJECTED
if (COURSE_REQUEST_ACCEPTED != $course_request_info['status'] &&
COURSE_REQUEST_REJECTED != $course_request_info['status']
) {
$submit_buttons[] = $form->addButtonCancel(get_lang('Reject'), 'reject_button', true);
}
if ($course_request_info['status'] != COURSE_REQUEST_ACCEPTED && intval($course_request_info['info']) <= 0) {
if (COURSE_REQUEST_ACCEPTED != $course_request_info['status'] && (int) ($course_request_info['info']) <= 0) {
$submit_buttons[] = $form->addButtonPreview(get_lang('Ask for additional information'), 'ask_info_button', true);
}
$form->addGroup($submit_buttons);
@ -213,6 +213,7 @@ if ($course_validation_feature) {
false
);
}
break;
case 'reject_button':
if (CourseRequestManager::reject_course_request($id)) {
@ -238,6 +239,7 @@ if ($course_validation_feature) {
false
);
}
break;
case 'ask_info_button':
if (CourseRequestManager::ask_for_additional_info($id)) {
@ -263,6 +265,7 @@ if ($course_validation_feature) {
false
);
}
break;
}
} else {

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* A list containing the rejected course requests.
*
* @package chamilo.admin
*
* @author José Manuel Abuin Mosquera <chema@cesga.es>, 2010
* @author Bruno Rubio Gayo <brubio@cesga.es>, 2010
@ -20,17 +20,17 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
// A check whether the course validation feature is enabled.
$course_validation_feature = api_get_setting('course_validation') == 'true';
$course_validation_feature = 'true' == api_get_setting('course_validation');
// Filltering passed to this page parameters.
$accept_course_request = isset($_GET['accept_course_request']) ? intval($_GET['accept_course_request']) : '';
$delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['delete_course_request']) : '';
$request_info = isset($_GET['request_info']) ? intval($_GET['request_info']) : '';
$accept_course_request = isset($_GET['accept_course_request']) ? (int) ($_GET['accept_course_request']) : '';
$delete_course_request = isset($_GET['delete_course_request']) ? (int) ($_GET['delete_course_request']) : '';
$request_info = isset($_GET['request_info']) ? (int) ($_GET['request_info']) : '';
$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : '';
$is_error_message = !empty($_GET['is_error_message']);
if ($course_validation_feature) {
/**
/*
* Acceptance and creation of the requested course.
*/
if (!empty($accept_course_request)) {
@ -71,7 +71,7 @@ if ($course_validation_feature) {
$is_error_message = true;
}
} elseif (isset($_POST['action'])) {
/**
/*
* Form actions: delete.
*/
switch ($_POST['action']) {
@ -86,6 +86,7 @@ if ($course_validation_feature) {
$message = $success ? get_lang('The selected course requests have been deleted.') : get_lang('Some of the selected course requests have not been deleted due to internal error.');
$is_error_message = !$success;
}
break;
}
}
@ -114,9 +115,9 @@ function get_request_data($from, $number_of_items, $column, $direction)
$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : '';
$course_request_table = Database::get_main_table(TABLE_MAIN_COURSE_REQUEST);
$from = intval($from);
$number_of_items = intval($number_of_items);
$column = intval($column);
$from = (int) $from;
$number_of_items = (int) $number_of_items;
$column = (int) $column;
$direction = !in_array(strtolower(trim($direction)), ['asc', 'desc']) ? 'asc' : $direction;
$sql = "SELECT
@ -130,7 +131,7 @@ function get_request_data($from, $number_of_items, $column, $direction)
FROM $course_request_table
WHERE status = ".COURSE_REQUEST_REJECTED;
if ($keyword != '') {
if ('' != $keyword) {
$sql .= " AND (
title LIKE '%".$keyword."%' OR
code LIKE '%".$keyword."%' OR

@ -1,10 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* A list containing the pending course requests.
*
* @package chamilo.admin
*
* @author José Manuel Abuin Mosquera <chema@cesga.es>, 2010
* Centro de Supercomputacion de Galicia (CESGA)
@ -21,19 +21,19 @@ api_protect_admin_script();
// see DELETE_ACTION_ENABLED constant in main_api.lib.php
// A check whether the course validation feature is enabled.
$course_validation_feature = api_get_setting('course_validation') == 'true';
$course_validation_feature = 'true' == api_get_setting('course_validation');
// Filltering passed to this page parameters.
$accept_course_request = isset($_GET['accept_course_request']) ? intval($_GET['accept_course_request']) : '';
$reject_course_request = isset($_GET['reject_course_request']) ? intval($_GET['reject_course_request']) : '';
$request_info = isset($_GET['request_info']) ? intval($_GET['request_info']) : '';
$delete_course_request = isset($_GET['delete_course_request']) ? intval($_GET['delete_course_request']) : '';
$accept_course_request = isset($_GET['accept_course_request']) ? (int) ($_GET['accept_course_request']) : '';
$reject_course_request = isset($_GET['reject_course_request']) ? (int) ($_GET['reject_course_request']) : '';
$request_info = isset($_GET['request_info']) ? (int) ($_GET['request_info']) : '';
$delete_course_request = isset($_GET['delete_course_request']) ? (int) ($_GET['delete_course_request']) : '';
$message = isset($_GET['message']) ? trim(Security::remove_XSS(stripslashes(urldecode($_GET['message'])))) : '';
$is_error_message = isset($_GET['is_error_message']) ? !empty($_GET['is_error_message']) : '';
$keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : '';
if ($course_validation_feature) {
/**
/*
* Course acceptance and creation.
*/
if (!empty($accept_course_request)) {
@ -87,7 +87,7 @@ if ($course_validation_feature) {
$is_error_message = true;
}
} elseif (DELETE_ACTION_ENABLED && isset($_POST['action'])) {
/**
/*
* Form actions: delete.
*/
switch ($_POST['action']) {
@ -102,6 +102,7 @@ if ($course_validation_feature) {
$message = $success ? get_lang('The selected course requests have been deleted.') : get_lang('Some of the selected course requests have not been deleted due to internal error.');
$is_error_message = !$success;
}
break;
}
}
@ -152,7 +153,7 @@ function get_request_data($from, $number_of_items, $column, $direction)
WHERE status = ".COURSE_REQUEST_PENDING;
}
if ($keyword != '') {
if ('' != $keyword) {
$sql .= " AND (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')";
}
$sql .= " ORDER BY col$column $direction ";
@ -178,7 +179,7 @@ function get_request_data($from, $number_of_items, $column, $direction)
function email_filter($teacher)
{
$teacher = Database::escape_string($teacher);
$sql = "SELECT user_id FROM ".Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
$sql = 'SELECT user_id FROM '.Database::get_main_table(TABLE_MAIN_COURSE_REQUEST)."
WHERE tutor_name LIKE '".$teacher."'";
$res = Database::query($sql);
$info = Database::fetch_array($res);

@ -4,8 +4,6 @@
/**
* This tool allows platform admins to update course-user relations by uploading
* a CSV file.
*
* @package chamilo.admin
*/
/**
@ -20,14 +18,14 @@ function validate_data($users_courses)
// 1. Check whether mandatory fields are set.
$mandatory_fields = ['UserName', 'CourseCode', 'Status'];
foreach ($mandatory_fields as $key => $field) {
if (!isset($user_course[$field]) || strlen($user_course[$field]) == 0) {
if (!isset($user_course[$field]) || 0 == strlen($user_course[$field])) {
$user_course['error'] = get_lang($field.'Mandatory');
$errors[] = $user_course;
}
}
// 2. Check whether coursecode exists.
if (isset($user_course['CourseCode']) && strlen($user_course['CourseCode']) != 0) {
if (isset($user_course['CourseCode']) && 0 != strlen($user_course['CourseCode'])) {
// 2.1 Check whethher code has been allready used by this CVS-file.
if (!isset($coursecodes[$user_course['CourseCode']])) {
// 2.1.1 Check whether course with this code exists in the system.
@ -42,7 +40,7 @@ function validate_data($users_courses)
}
// 3. Check whether username exists.
if (isset($user_course['UserName']) && strlen($user_course['UserName']) != 0) {
if (isset($user_course['UserName']) && 0 != strlen($user_course['UserName'])) {
if (UserManager::is_username_available($user_course['UserName'])) {
$user_course['error'] = get_lang('Unknown user');
$errors[] = $user_course;
@ -50,8 +48,8 @@ function validate_data($users_courses)
}
// 4. Check whether status is valid.
if (isset($user_course['Status']) && strlen($user_course['Status']) != 0) {
if ($user_course['Status'] != COURSEMANAGER && $user_course['Status'] != STUDENT) {
if (isset($user_course['Status']) && 0 != strlen($user_course['Status'])) {
if (COURSEMANAGER != $user_course['Status'] && STUDENT != $user_course['Status']) {
$user_course['error'] = get_lang('Unknown status');
$errors[] = $user_course;
}
@ -92,7 +90,7 @@ function save_data($users_courses)
$user_id = $userInfo['user_id'];
$sql = "SELECT * FROM $course_user_table cu
WHERE cu.user_id = $user_id AND cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH." ";
WHERE cu.user_id = $user_id AND cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH.' ';
$res = Database::query($sql);
$db_subscriptions = [];
while ($obj = Database::fetch_object($res)) {
@ -142,9 +140,7 @@ function save_data($users_courses)
*/
function parse_csv_data($file)
{
$courses = Import::csvToArray($file);
return $courses;
return Import::csvToArray($file);
}
$cidReset = true;
@ -176,7 +172,7 @@ $errors = [];
if ($form->validate()) {
$users_courses = parse_csv_data($_FILES['import_file']['tmp_name']);
$errors = validate_data($users_courses);
if (count($errors) == 0) {
if (0 == count($errors)) {
$inserted_in_course = save_data($users_courses);
// Build the alert message in case there were visual codes subscribed to.
if ($_POST['subscribe']) {
@ -203,7 +199,7 @@ if ($form->validate()) {
// Displaying the header.
Display :: display_header($tool_name);
if (count($errors) != 0) {
if (0 != count($errors)) {
$error_message = '<ul>';
foreach ($errors as $index => $error_course) {
$error_message .= '<li>'.get_lang('Line').' '.$error_course['line'].': <strong>'.$error_course['error'].'</strong>: ';

@ -4,8 +4,6 @@ exit;
/**
* This tool allows platform admins to update course-user relations by uploading
* a CSV file.
*
* @package chamilo.admin
*/
/**
* Validates the imported data.
@ -19,14 +17,14 @@ function validate_data($users_courses)
// 1. Check whether mandatory fields are set.
$mandatory_fields = ['Email', 'CourseCode', 'Status'];
foreach ($mandatory_fields as $key => $field) {
if (!isset($user_course[$field]) || strlen($user_course[$field]) == 0) {
if (!isset($user_course[$field]) || 0 == strlen($user_course[$field])) {
$user_course['error'] = get_lang($field.'Mandatory');
$errors[] = $user_course;
}
}
// 2. Check whether coursecode exists.
if (isset($user_course['CourseCode']) && strlen($user_course['CourseCode']) != 0) {
if (isset($user_course['CourseCode']) && 0 != strlen($user_course['CourseCode'])) {
// 2.1 Check whethher code has been allready used by this CVS-file.
if (!isset($coursecodes[$user_course['CourseCode']])) {
// 2.1.1 Check whether course with this code exists in the system.
@ -34,7 +32,7 @@ function validate_data($users_courses)
$sql = "SELECT * FROM $course_table
WHERE code = '".Database::escape_string($user_course['CourseCode'])."'";
$res = Database::query($sql);
if (Database::num_rows($res) == 0) {
if (0 == Database::num_rows($res)) {
$user_course['error'] = get_lang('This code does not exist');
$errors[] = $user_course;
} else {
@ -44,7 +42,7 @@ function validate_data($users_courses)
}
// 3. Check whether Email exists.
if (isset($user_course['Email']) && strlen($user_course['Email']) != 0) {
if (isset($user_course['Email']) && 0 != strlen($user_course['Email'])) {
$user = api_get_user_info_from_email($user_course['Email']);
if (empty($user)) {
$user_course['error'] = get_lang('Unknown user');
@ -53,8 +51,8 @@ function validate_data($users_courses)
}
// 4. Check whether status is valid.
if (isset($user_course['Status']) && strlen($user_course['Status']) != 0) {
if ($user_course['Status'] != COURSEMANAGER && $user_course['Status'] != STUDENT) {
if (isset($user_course['Status']) && 0 != strlen($user_course['Status'])) {
if (COURSEMANAGER != $user_course['Status'] && STUDENT != $user_course['Status']) {
$user_course['error'] = get_lang('Unknown status');
$errors[] = $user_course;
}
@ -86,7 +84,7 @@ function save_data($users_courses)
$obj = Database::fetch_object($res);
$user_id = $obj->user_id;
$sql = "SELECT * FROM $course_user_table cu
WHERE cu.user_id = $user_id AND cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH." ";
WHERE cu.user_id = $user_id AND cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH.' ';
$res = Database::query($sql);
$db_subscriptions = [];
while ($obj = Database::fetch_object($res)) {
@ -140,9 +138,7 @@ function save_data($users_courses)
*/
function parse_csv_data($file)
{
$courses = Import::csv_reader($file);
return $courses;
return Import::csv_reader($file);
}
$cidReset = true;
@ -174,7 +170,7 @@ $errors = [];
if ($form->validate()) {
$users_courses = parse_csv_data($_FILES['import_file']['tmp_name']);
$errors = validate_data($users_courses);
if (count($errors) == 0) {
if (0 == count($errors)) {
$inserted_in_course = save_data($users_courses);
// Build the alert message in case there were visual codes subscribed to.
if ($_POST['subscribe']) {
@ -184,7 +180,7 @@ if ($form->validate()) {
}
if (!empty($inserted_in_course)) {
$warn = $warn.' '.get_lang('File imported');
$warn .= ' '.get_lang('File imported');
// The users have been inserted in more than one course.
foreach ($inserted_in_course as $code => $info) {
$warn .= ' '.$info.' ('.$code.') ';
@ -204,7 +200,7 @@ if ($form->validate()) {
// Displaying the header.
Display::display_header($tool_name);
if (count($errors) != 0) {
if (0 != count($errors)) {
$error_message = '<ul>';
foreach ($errors as $index => $error_course) {
$error_message .= '<li>'.get_lang('Line').' '.$error_course['line'].': <strong>'.$error_course['error'].'</strong>: ';

@ -3,8 +3,6 @@
/**
* Interface for assigning courses to Human Resources Manager.
*
* @package chamilo.admin
*/
// resetting the course id
$cidReset = true;
@ -30,7 +28,7 @@ $tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
// initializing variables
$user_id = intval($_GET['user']);
$user_id = (int) ($_GET['user']);
$user_info = api_get_user_info($user_id);
$user_anonymous = api_get_anonymous_id();
$current_user_id = api_get_user_id();
@ -38,14 +36,14 @@ $current_user_id = api_get_user_id();
// setting the name of the tool
if (UserManager::is_admin($user_id)) {
$tool_name = get_lang('AssignCoursesToAdministrationistrator');
} elseif ($user_info['status'] == SESSIONADMIN) {
} elseif (SESSIONADMIN == $user_info['status']) {
$tool_name = get_lang('Assign courses to session\'s administrator');
} else {
$tool_name = get_lang('Assign courses to HR manager');
}
$add_type = 'multiple';
if (isset($_GET['add_type']) && $_GET['add_type'] != '') {
if (isset($_GET['add_type']) && '' != $_GET['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
@ -69,7 +67,7 @@ function search_courses($needle, $type)
}
$without_assigned_courses = '';
if (count($assigned_courses_code) > 0) {
$without_assigned_courses = " AND c.code NOT IN(".implode(',', $assigned_courses_code).")";
$without_assigned_courses = ' AND c.code NOT IN('.implode(',', $assigned_courses_code).')';
}
if (api_is_multiple_url_enabled()) {
@ -158,7 +156,7 @@ $errorMsg = $firstLetterCourse = '';
$UserList = [];
$msg = '';
if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
if (isset($_POST['formSent']) && 1 == (int) ($_POST['formSent'])) {
$courses_list = isset($_POST['CoursesList']) ? $_POST['CoursesList'] : [];
$affected_rows = CourseManager::subscribeCoursesToDrhManager($user_id, $courses_list);
if ($affected_rows) {
@ -191,7 +189,7 @@ foreach ($assigned_courses_code as &$value) {
$without_assigned_courses = '';
if (count($assigned_courses_code) > 0) {
$without_assigned_courses = " AND c.code NOT IN(".implode(',', $assigned_courses_code).")";
$without_assigned_courses = ' AND c.code NOT IN('.implode(',', $assigned_courses_code).')';
}
$needle = '%';
@ -208,8 +206,8 @@ if (api_is_multiple_url_enabled()) {
ON (a.c_id = c.id)
WHERE
c.code LIKE '$needle' $without_assigned_courses AND
access_url_id = ".api_get_current_access_url_id()."
ORDER BY c.title";
access_url_id = ".api_get_current_access_url_id().'
ORDER BY c.title';
} else {
$sql = " SELECT c.code, c.title
FROM $tbl_course c
@ -245,7 +243,7 @@ if (!empty($msg)) {
</div>
<div class="col-md-4">
<div class="code-course">
<?php if ($add_type == 'multiple') {
<?php if ('multiple' == $add_type) {
?>
<p><?php echo get_lang('First letter (code)'); ?> :</p>
<select name="firstLetterCourse" class="selectpicker form-control" onchange = "xajax_search_courses(this.value,'multiple')">
@ -275,7 +273,7 @@ if (!empty($msg)) {
<h5><?php
if (UserManager::is_admin($user_id)) {
echo get_lang('AssignedCoursesListToAdministrationistrator');
} elseif ($user_info['status'] == SESSIONADMIN) {
} elseif (SESSIONADMIN == $user_info['status']) {
echo get_lang('Assigned courses list to sessions administrator');
} else {
echo get_lang('Courses assigned to the HR manager');

@ -3,8 +3,6 @@
/**
* Interface for assigning sessions to Human Resources Manager.
*
* @package chamilo.admin
*/
// resetting the course id
$cidReset = true;
@ -31,7 +29,7 @@ $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
// Initializing variables
$user_id = isset($_GET['user']) ? intval($_GET['user']) : null;
$user_id = isset($_GET['user']) ? (int) ($_GET['user']) : null;
$user_info = api_get_user_info($user_id);
$user_anonymous = api_get_anonymous_id();
$current_user_id = api_get_user_id();
@ -40,14 +38,14 @@ $ajax_search = false;
// Setting the name of the tool
if (UserManager::is_admin($user_id)) {
$tool_name = get_lang('AssignSessionsToAdministrationistrator');
} elseif ($user_info['status'] == SESSIONADMIN) {
} elseif (SESSIONADMIN == $user_info['status']) {
$tool_name = get_lang('assign sessions to sessions administrator');
} else {
$tool_name = get_lang('Assign sessions to Human Resources manager');
}
$add_type = 'multiple';
if (isset($_GET['add_type']) && $_GET['add_type'] != '') {
if (isset($_GET['add_type']) && '' != $_GET['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
@ -69,7 +67,7 @@ function search_sessions($needle, $type)
$without_assigned_sessions = '';
if (count($assigned_sessions_id) > 0) {
$without_assigned_sessions = " AND s.id NOT IN(".implode(',', $assigned_sessions_id).")";
$without_assigned_sessions = ' AND s.id NOT IN('.implode(',', $assigned_sessions_id).')';
}
if (api_is_multiple_url_enabled()) {
@ -156,7 +154,7 @@ $firstLetterSession = isset($_POST['firstLetterSession']) ? $_POST['firstLetterS
$errorMsg = '';
$UserList = [];
if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
if (isset($_POST['formSent']) && 1 == (int) ($_POST['formSent'])) {
$sessions_list = $_POST['SessionsList'];
$userInfo = api_get_user_info($user_id);
$affected_rows = SessionManager::subscribeSessionsToDrh(
@ -174,7 +172,7 @@ if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
Display::display_header($tool_name);
// Actions
if ($user_info['status'] != SESSIONADMIN) {
if (SESSIONADMIN != $user_info['status']) {
$actionsLeft = '<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.
Display::return_icon('add-user.png', get_lang('Assign users'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.
@ -194,7 +192,7 @@ $assigned_sessions_id = array_keys($assigned_sessions_to_hrm);
$without_assigned_sessions = '';
if (count($assigned_sessions_id) > 0) {
$without_assigned_sessions = " AND s.id NOT IN (".implode(',', $assigned_sessions_id).") ";
$without_assigned_sessions = ' AND s.id NOT IN ('.implode(',', $assigned_sessions_id).') ';
}
$needle = '%';
@ -208,8 +206,8 @@ if (api_is_multiple_url_enabled()) {
LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
WHERE
s.name LIKE '$needle%' $without_assigned_sessions AND
access_url_id = ".api_get_current_access_url_id()."
ORDER BY s.name";
access_url_id = ".api_get_current_access_url_id().'
ORDER BY s.name';
} else {
$sql = "SELECT s.id, s.name FROM $tbl_session s
WHERE s.name LIKE '$needle%' $without_assigned_sessions
@ -240,7 +238,7 @@ $result = Database::query($sql);
</div>
<div class="col-md-4">
<div class="code-course">
<?php if ($add_type == 'multiple') {
<?php if ('multiple' == $add_type) {
?>
<p><?php echo get_lang('Session title\'s first letter'); ?> :</p>
<select class="selectpicker form-control" name="firstLetterSession" onchange = "xajax_search_sessions(this.value, 'multiple')">
@ -284,7 +282,7 @@ $result = Database::query($sql);
<?php
if (UserManager::is_admin($user_id)) {
echo get_lang('AssignedSessionsListToAdministrationistrator');
} elseif ($user_info['status'] == SESSIONADMIN) {
} elseif (SESSIONADMIN == $user_info['status']) {
echo get_lang('Assigned sessions list to sessions administrator');
} else {
echo get_lang('List of sessions assigned to the Human Resources manager');

@ -3,8 +3,6 @@
/**
* Interface for assigning users to Human Resources Manager.
*
* @package chamilo.admin
*/
// resetting the course id
@ -46,16 +44,16 @@ $isAdmin = UserManager::is_admin($user_id);
if ($isAdmin) {
$userStatus = PLATFORM_ADMIN;
$tool_name = get_lang('AssignUsersToAdministrationistrator');
} elseif ($user_info['status'] == SESSIONADMIN) {
} elseif (SESSIONADMIN == $user_info['status']) {
$tool_name = get_lang('Assign users to sessions administrator');
} elseif ($user_info['status'] == STUDENT_BOSS) {
} elseif (STUDENT_BOSS == $user_info['status']) {
$tool_name = get_lang('Assign users to superior');
} else {
$tool_name = get_lang('Assign users to Human Resources manager');
}
$add_type = 'multiple';
if (isset($_GET['add_type']) && $_GET['add_type'] != '') {
if (isset($_GET['add_type']) && '' != $_GET['add_type']) {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
@ -76,9 +74,11 @@ function search_users($needle, $type = 'multiple')
case DRH:
case PLATFORM_ADMIN:
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
break;
case STUDENT_BOSS:
$assigned_users_to_hrm = UserManager::getUsersFollowedByStudentBoss($user_id);
break;
}
@ -87,13 +87,13 @@ function search_users($needle, $type = 'multiple')
$westernOrder = api_is_western_name_order();
if ($westernOrder) {
$order_clause = " ORDER BY firstname, lastname";
$order_clause = ' ORDER BY firstname, lastname';
} else {
$order_clause = " ORDER BY lastname, firstname";
$order_clause = ' ORDER BY lastname, firstname';
}
if (count($assigned_users_id) > 0) {
$without_assigned_users = " AND user.user_id NOT IN(".implode(',', $assigned_users_id).")";
$without_assigned_users = ' AND user.user_id NOT IN('.implode(',', $assigned_users_id).')';
}
if (api_is_multiple_url_enabled()) {
@ -102,7 +102,7 @@ function search_users($needle, $type = 'multiple')
LEFT JOIN $tbl_access_url_rel_user au ON (au.user_id = user.user_id)
WHERE
".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
status NOT IN(".DRH.", ".SESSIONADMIN.", ".STUDENT_BOSS.") AND
status NOT IN(".DRH.', '.SESSIONADMIN.', '.STUDENT_BOSS.") AND
user.user_id NOT IN ($user_anonymous, $current_user_id, $user_id)
$without_assigned_users AND
access_url_id = ".api_get_current_access_url_id()."
@ -113,7 +113,7 @@ function search_users($needle, $type = 'multiple')
FROM $tbl_user user
WHERE
".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
status NOT IN(".DRH.", ".SESSIONADMIN.", ".STUDENT_BOSS.") AND
status NOT IN(".DRH.', '.SESSIONADMIN.', '.STUDENT_BOSS.") AND
user_id NOT IN ($user_anonymous, $current_user_id, $user_id)
$without_assigned_users
$order_clause
@ -122,7 +122,7 @@ function search_users($needle, $type = 'multiple')
$rs = Database::query($sql);
$xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
if ($type == 'single') {
if ('single' == $type) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
@ -139,10 +139,12 @@ function search_users($needle, $type = 'multiple')
switch ($userStatus) {
case DRH:
$sql .= " user.status <> 6 AND user.status <> ".DRH;
$sql .= ' user.status <> 6 AND user.status <> '.DRH;
break;
case STUDENT_BOSS:
$sql .= " user.status <> 6 AND user.status <> ".STUDENT_BOSS;
$sql .= ' user.status <> 6 AND user.status <> '.STUDENT_BOSS;
break;
}
@ -151,7 +153,7 @@ function search_users($needle, $type = 'multiple')
$rs = Database::query($sql);
$i = 0;
while ($user = Database :: fetch_array($rs)) {
$i++;
++$i;
if ($i <= 10) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_user(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
@ -285,15 +287,17 @@ if (!empty($filters) && !empty($filterData)) {
}
}
if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
if (isset($_POST['formSent']) && 1 == (int) ($_POST['formSent'])) {
$user_list = isset($_POST['UsersList']) ? $_POST['UsersList'] : null;
switch ($userStatus) {
case DRH:
case PLATFORM_ADMIN:
$affected_rows = UserManager::subscribeUsersToHRManager($user_id, $user_list);
break;
case STUDENT_BOSS:
$affected_rows = UserManager::subscribeBossToUsers($user_id, $user_list);
break;
default:
$affected_rows = 0;
@ -312,7 +316,7 @@ Display::display_header($tool_name);
// actions
$actionsLeft = '';
if ($userStatus != STUDENT_BOSS) {
if (STUDENT_BOSS != $userStatus) {
$actionsLeft = Display::url(
Display::return_icon('course-add.png', get_lang('Assign courses'), null, ICON_SIZE_MEDIUM),
"dashboard_add_courses_to_user.php?user=$user_id"
@ -352,23 +356,25 @@ switch ($userStatus) {
case DRH:
case PLATFORM_ADMIN:
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
break;
case STUDENT_BOSS:
$assigned_users_to_hrm = UserManager::getUsersFollowedByStudentBoss($user_id);
break;
}
$assigned_users_id = array_keys($assigned_users_to_hrm);
$without_assigned_users = '';
if (count($assigned_users_id) > 0) {
$without_assigned_users = " user.user_id NOT IN(".implode(',', $assigned_users_id).") AND ";
$without_assigned_users = ' user.user_id NOT IN('.implode(',', $assigned_users_id).') AND ';
}
$search_user = '';
$needle = '';
if (!empty($firstLetterUser)) {
$needle = Database::escape_string($firstLetterUser);
$search_user = "AND ".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'";
$search_user = 'AND '.(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%'";
}
$sqlConditions = null;
@ -395,7 +401,7 @@ if (api_is_multiple_url_enabled()) {
WHERE
$without_assigned_users
user.user_id NOT IN ($user_anonymous, $current_user_id, $user_id) AND
status NOT IN(".DRH.", ".SESSIONADMIN.", ".ANONYMOUS.") $search_user AND
status NOT IN(".DRH.', '.SESSIONADMIN.', '.ANONYMOUS.") $search_user AND
access_url_id = ".api_get_current_access_url_id()."
$sqlConditions
ORDER BY firstname";
@ -405,7 +411,7 @@ if (api_is_multiple_url_enabled()) {
WHERE
$without_assigned_users
user_id NOT IN ($user_anonymous, $current_user_id, $user_id) AND
status NOT IN(".DRH.", ".SESSIONADMIN.", ".ANONYMOUS.")
status NOT IN(".DRH.', '.SESSIONADMIN.', '.ANONYMOUS.")
$search_user
$sqlConditions
ORDER BY firstname ";
@ -438,7 +444,7 @@ $result = Database::query($sql);
</div>
<div class="col-md-4">
<div class="code-course">
<?php if ($add_type == 'multiple') {
<?php if ('multiple' == $add_type) {
?>
<p><?php echo get_lang('First letter (last name)'); ?></p>
<select class="selectpicker show-tick form-control" name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')">
@ -481,10 +487,10 @@ $result = Database::query($sql);
if (UserManager::is_admin($user_id)) {
echo get_lang('AssignedUsersListToAdministrationistrator');
} else {
if ($user_info['status'] == SESSIONADMIN) {
if (SESSIONADMIN == $user_info['status']) {
echo get_lang('Assign a users list to the sessions administrator');
} else {
if ($user_info['status'] == STUDENT_BOSS) {
if (STUDENT_BOSS == $user_info['status']) {
echo get_lang('Users assigned to their superior');
} else {
echo get_lang('List of users assigned to Human Resources manager');

Loading…
Cancel
Save