Multi url disabled (#5678)

* Display: Fix styles for toast

* Internal: Remove api_is_multiple_url_enabled
pull/5682/head
Angel Fernando Quiroz Campos 4 months ago committed by GitHub
parent f534c73420
commit 28463ab582
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .env.dist
  2. 10
      assets/css/scss/atoms/_toast.scss
  3. 5
      public/main/admin/course_edit.php
  4. 10
      public/main/admin/course_information.php
  5. 8
      public/main/admin/course_list.php
  6. 5
      public/main/admin/course_list_admin.php
  7. 15
      public/main/admin/dashboard_add_courses_to_user.php
  8. 11
      public/main/admin/dashboard_add_sessions_to_user.php
  9. 24
      public/main/admin/dashboard_add_users_to_user.php
  10. 2
      public/main/admin/settings.php
  11. 27
      public/main/admin/subscribe_user2course.php
  12. 11
      public/main/admin/user_export.php
  13. 2
      public/main/admin/user_information.php
  14. 5
      public/main/inc/ajax/admin.ajax.php
  15. 61
      public/main/inc/lib/CoursesAndSessionsCatalog.class.php
  16. 37
      public/main/inc/lib/api.lib.php
  17. 23
      public/main/inc/lib/course.lib.php
  18. 11
      public/main/inc/lib/login.lib.php
  19. 28
      public/main/inc/lib/myspace.lib.php
  20. 12
      public/main/inc/lib/online.inc.php
  21. 7
      public/main/inc/lib/redirect.class.php
  22. 138
      public/main/inc/lib/sessionmanager.lib.php
  23. 125
      public/main/inc/lib/statistics.lib.php
  24. 73
      public/main/inc/lib/tracking.lib.php
  25. 31
      public/main/inc/lib/usermanager.lib.php
  26. 21
      public/main/inc/lib/userportal.lib.php
  27. 22
      public/main/inc/lib/webservices/Rest.php
  28. 11
      public/main/inc/lib/zombie/zombie_manager.class.php
  29. 9
      public/main/my_space/session_filter.php
  30. 5
      public/main/my_space/user_edit.php
  31. 47
      public/main/session/add_edit_users_to_session.php
  32. 54
      public/main/session/add_users_to_session_course.php
  33. 8
      public/main/session/resume_session.php
  34. 13
      public/main/session/session_add.php
  35. 9
      public/main/session/session_course_edit.php
  36. 22
      public/main/session/session_export.php
  37. 5
      public/main/session/session_import.php
  38. 128
      public/main/user/add_users_to_session.php
  39. 160
      public/main/user/subscribe_user.php
  40. 28
      public/main/user/user.php
  41. 14
      public/main/user/user_export.php
  42. 4
      public/plugin/customcertificate/src/export_pdf_all_in_one.php
  43. 18
      src/CoreBundle/EventListener/LegacyListener.php
  44. 45
      src/CoreBundle/Repository/Node/UsergroupRepository.php
  45. 13
      src/CoreBundle/ServiceHelper/AccessUrlHelper.php
  46. 5
      tests/scripts/synchronize_user_base_from_ldap.php

@ -33,8 +33,6 @@ APP_LOCALE='en_US'
APP_CUSTOM_VUE_TEMPLATE='0'
APP_MULTIPLE_ACCESS_URL=''
GOOGLE_MAPS_API_KEY=''
#APP_API_PLATFORM_URL='http://localhost/api/' #deprecated

@ -1,5 +1,5 @@
.p-toast {
@apply whitespace-pre-line break-words opacity-90 w-96;
@apply whitespace-pre-line break-words opacity-90 min-w-96;
&.p-toast-top-center, &.p-toast-bottom-center {
@apply -translate-x-1/2;
@ -52,7 +52,7 @@
@apply bg-warning text-gray-90 border-0;
.p-toast-message-icon, .p-toast-icon-close {
@apply bg-gray-90;
@apply text-gray-90;
}
}
@ -65,14 +65,14 @@
}
.p-toast-message-content {
@apply flex items-center p-4 border-0;
@apply flex items-start p-4 border-0;
.p-toast-message-text {
@apply flex-auto m-0 ml-4;
@apply flex-auto m-0 ml-4 self-center;
}
.p-toast-message-icon {
@apply shrink-0 text-body-1;
@apply shrink-0 text-2xl;
&.p-icon {
@apply w-8 h-8;

@ -59,7 +59,6 @@ while ($obj = Database::fetch_object($res)) {
}
// Get all possible teachers without the course teachers
if (api_is_multiple_url_enabled()) {
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT u.id as user_id,lastname,firstname
FROM $table_user as u
@ -68,10 +67,6 @@ if (api_is_multiple_url_enabled()) {
WHERE
url_rel_user.access_url_id = $urlId AND
status = 1".$order_clause;
} else {
$sql = "SELECT id as user_id, lastname, firstname
FROM $table_user WHERE status='1'".$order_clause;
}
$courseInfo['tutor_name'] = null;
$res = Database::query($sql);

@ -138,14 +138,12 @@ echo Display::page_header(get_lang('Users'));
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$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
FROM $table_course_user cu, $table_user u
INNER JOIN ".Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER)." url_rel_user
ON
u.id = url_rel_user.user_id AND
url_rel_user.access_url_id = ".api_get_current_access_url_id();
}
$sql .= " WHERE
url_rel_user.access_url_id = ".api_get_current_access_url_id()."
WHERE
cu.user_id = u.id AND
cu.c_id = '".$courseId."' AND
cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH;

@ -80,9 +80,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
INNER JOIN $tblCourseCategory category ON course_rel_category.course_category_id = category.id ";
}
if ((api_is_platform_admin() || api_is_session_admin()) &&
api_is_multiple_url_enabled() && -1 != api_get_current_access_url_id()
) {
if ((api_is_platform_admin() || api_is_session_admin())) {
$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
ON (course.id = url_rel_course.c_id)";
@ -121,9 +119,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
}
// 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() && -1 != api_get_current_access_url_id()
) {
if ((api_is_platform_admin() || api_is_session_admin())) {
$sql .= ' AND url_rel_course.access_url_id='.api_get_current_access_url_id();
}

@ -73,11 +73,10 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
}
$sql = "$select FROM $table course";
if (api_is_multiple_url_enabled()) {
$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
ON (course.id = url_rel_course.c_id)";
}
$tableCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$sql .= "
@ -119,9 +118,7 @@ function get_course_data($from, $number_of_items, $column, $direction, $dataFunc
}
// Adding the filter to see the user's only of the current access_url.
if (api_is_multiple_url_enabled()) {
$sql .= " AND url_rel_course.access_url_id = ".api_get_current_access_url_id();
}
if ($addTeacherColumn) {
$teachers = isset($_GET['course_teachers']) ? $_GET['course_teachers'] : [];

@ -76,7 +76,6 @@ function search_courses($needle, $type)
$without_assigned_courses = ' AND c.code NOT IN('.implode(',', $assigned_courses_code).')';
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT c.code, c.title
FROM $tbl_course c
LEFT JOIN $tbl_course_rel_access_url a
@ -84,13 +83,6 @@ function search_courses($needle, $type)
WHERE
c.code LIKE '$needle%' $without_assigned_courses AND
access_url_id = ".api_get_current_access_url_id();
} else {
$sql = "SELECT c.code, c.title
FROM $tbl_course c
WHERE
c.code LIKE '$needle%'
$without_assigned_courses ";
}
$rs = Database::query($sql);
@ -205,7 +197,6 @@ if (isset($_POST['firstLetterCourse'])) {
$needle = Database::escape_string($firstLetter.'%');
}
if (api_is_multiple_url_enabled()) {
$sql = " SELECT c.code, c.title
FROM $tbl_course c
LEFT JOIN $tbl_course_rel_access_url a
@ -214,12 +205,6 @@ if (api_is_multiple_url_enabled()) {
c.code LIKE '$needle' $without_assigned_courses AND
access_url_id = ".api_get_current_access_url_id().'
ORDER BY c.title';
} else {
$sql = " SELECT c.code, c.title
FROM $tbl_course c
WHERE c.code LIKE '$needle' $without_assigned_courses
ORDER BY c.title";
}
$result = Database::query($sql);

@ -74,17 +74,12 @@ function search_sessions($needle, $type)
$without_assigned_sessions = ' AND s.id NOT IN('.implode(',', $assigned_sessions_id).')';
}
if (api_is_multiple_url_enabled()) {
$sql = " SELECT s.id, s.title FROM $tbl_session s
LEFT JOIN $tbl_session_rel_access_url a
ON (s.id = a.session_id)
WHERE
s.title LIKE '$needle%' $without_assigned_sessions AND
access_url_id = ".api_get_current_access_url_id();
} else {
$sql = "SELECT s.id, s.title FROM $tbl_session s
WHERE s.title LIKE '$needle%' $without_assigned_sessions ";
}
$rs = Database::query($sql);
$return .= '<select class="form-control" id="origin" name="NoAssignedSessionsList[]" multiple="multiple" size="20">';
while ($session = Database :: fetch_array($rs)) {
@ -204,7 +199,6 @@ if (!empty($firstLetterSession)) {
$needle = Database::escape_string($firstLetterSession.'%');
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT s.id, s.title
FROM $tbl_session s
LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
@ -212,11 +206,6 @@ if (api_is_multiple_url_enabled()) {
s.title LIKE '$needle%' $without_assigned_sessions AND
access_url_id = ".api_get_current_access_url_id().'
ORDER BY s.title';
} else {
$sql = "SELECT s.id, s.title FROM $tbl_session s
WHERE s.title LIKE '$needle%' $without_assigned_sessions
ORDER BY s.title";
}
$result = Database::query($sql);
?>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id; ?>" style="margin:0px;" <?php if ($ajax_search) {

@ -99,7 +99,6 @@ function search_users($needle, $type = 'multiple')
$without_assigned_users = ' AND user.id NOT IN('.implode(',', $assigned_users_id).')';
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT user.id as user_id, username, lastname, firstname
FROM $tbl_user user
LEFT JOIN $tbl_access_url_rel_user au ON (au.user_id = user.id)
@ -111,17 +110,6 @@ function search_users($needle, $type = 'multiple')
access_url_id = ".api_get_current_access_url_id()."
$order_clause
";
} else {
$sql = "SELECT id as user_id, username, lastname, firstname
FROM $tbl_user user
WHERE user.active <> ".USER_SOFT_DELETED." AND
".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
status NOT IN(".DRH.', '.SESSIONADMIN.', '.STUDENT_BOSS.") AND
id NOT IN ($user_anonymous, $current_user_id, $user_id)
$without_assigned_users
$order_clause
";
}
$rs = Database::query($sql);
$xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return));
@ -395,7 +383,6 @@ if (!empty($conditions)) {
}
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT user.id as user_id, username, lastname, firstname
FROM $tbl_user user
LEFT JOIN $tbl_access_url_rel_user au
@ -407,17 +394,6 @@ if (api_is_multiple_url_enabled()) {
access_url_id = ".api_get_current_access_url_id()."
$sqlConditions
ORDER BY firstname";
} else {
$sql = "SELECT id as user_id, username, lastname, firstname
FROM $tbl_user user
WHERE user.active <> -1 AND
$without_assigned_users
id NOT IN ($user_anonymous, $current_user_id, $user_id) AND
status NOT IN(".DRH.', '.SESSIONADMIN.', '.ANONYMOUS.")
$search_user
$sqlConditions
ORDER BY firstname ";
}
$result = Database::query($sql);
?>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?user=<?php echo $user_id; ?>" class="form-horizontal" <?php if ($ajax_search) {

@ -71,7 +71,6 @@ if (!empty($_GET['category']) &&
$mark_all = false;
$un_mark_all = false;
if (api_is_multiple_url_enabled()) {
if (isset($values['buttons_in_action_right']) &&
isset($values['buttons_in_action_right']['mark_all'])
) {
@ -83,7 +82,6 @@ if (!empty($_GET['category']) &&
) {
$un_mark_all = true;
}
}
if ($mark_all || $un_mark_all) {
if (api_is_global_platform_admin()) {

@ -179,21 +179,12 @@ if ($use_extra_fields) {
$final_result = $extra_field_result[0];
}
if (api_is_multiple_url_enabled()) {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " AND u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " AND u.id = -1";
}
} else {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " AND id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " AND id = -1";
}
}
}
$target_name = 'lastname';
@ -205,15 +196,8 @@ if ('true' === $orderListByOfficialCode) {
$orderBy = " official_code, lastname, firstname";
}
$sql = "SELECT id as user_id, lastname, firstname, username, official_code
FROM $tbl_user
WHERE id <>2 AND ".$target_name." LIKE '".$first_letter_user."%' $where_filter
ORDER BY ".(count($users) > 0 ? "(id IN(".implode(',', $users).")) DESC," : "")." ".$orderBy;
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT u.id as user_id,lastname,firstname,username, official_code
FROM $tbl_user u
INNER JOIN $tbl_user_rel_access_url user_rel_url
@ -224,22 +208,13 @@ if (api_is_multiple_url_enabled()) {
(".$target_name." LIKE '".$first_letter_user."%' )
$where_filter
ORDER BY ".(count($users) > 0 ? "(u.id IN(".implode(',', $users).")) DESC," : "")." ".$orderBy;
}
}
$result = Database::query($sql);
$db_users = Database::store_result($result);
unset($result);
$sql = "SELECT code,visual_code,title
FROM $tbl_course
WHERE visual_code LIKE '".$first_letter_course."%'
ORDER BY ".(count($courses) > 0 ? "(code IN('".implode("','", $courses)."')) DESC," : "")." visual_code";
if (api_is_multiple_url_enabled()) {
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT code, visual_code, title
FROM $tbl_course as course
INNER JOIN $tbl_course_rel_access_url course_rel_url
@ -248,8 +223,6 @@ if (api_is_multiple_url_enabled()) {
access_url_id = $access_url_id AND
(visual_code LIKE '".$first_letter_course."%' )
ORDER BY ".(count($courses) > 0 ? "(code IN('".implode("','", $courses)."')) DESC," : "")." visual_code";
}
}
$result = Database::query($sql);
$db_courses = Database::store_result($result);

@ -26,20 +26,15 @@ $coursesSessions = array_merge($coursesSessions, $allCoursesFromSessions);
$courses = [];
$courses[''] = '--';
$sql = "SELECT code,visual_code,title FROM $course_table ORDER BY visual_code";
if (api_is_multiple_url_enabled()) {
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT code,visual_code,title
FROM $course_table as c
INNER JOIN $tbl_course_rel_access_url as course_rel_url
ON (c.id = course_rel_url.c_id)
WHERE access_url_id = $access_url_id
ORDER BY visual_code";
}
}
$result = Database::query($sql);
while ($course = Database::fetch_object($result)) {
$courses[$course->code] = $course->visual_code.' - '.$course->title;
@ -114,19 +109,13 @@ if ($form->validate()) {
ORDER BY lastname,firstname";
$filename = 'export_users_'.$courseSessionCode.'_'.$sessionInfo['name'].'_'.api_get_local_time();
} else {
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql .= " FROM $user_table u
INNER JOIN $tbl_user_rel_access_url as user_rel_url
ON (u.user_id= user_rel_url.user_id)
WHERE access_url_id = $access_url_id
ORDER BY lastname,firstname";
}
} else {
$sql .= " FROM $user_table u ORDER BY lastname,firstname";
}
$filename = 'export_users_'.api_get_local_time();
}
$data = [];

@ -499,7 +499,6 @@ if (count($courseRelUserList) > 0) {
* Show the URL in which this user is subscribed.
*/
$urlInformation = '';
if (api_is_multiple_url_enabled()) {
$urlList = UrlManager::get_access_url_from_user($userId);
if (count($urlList) > 0) {
$header = [];
@ -525,7 +524,6 @@ if (api_is_multiple_url_enabled()) {
} else {
$urlInformation = '<p>'.get_lang('This user doesn\'t have a related URL.').'</p>';
}
}
if (isset($_GET['action'])) {
switch ($_GET['action']) {

@ -46,18 +46,13 @@ switch ($action) {
/** @var Filesystem $fileSystem */
$fileSystem = Container::$container->get('home_filesystem');
$dir = 'admin/';
if (api_is_multiple_url_enabled()) {
$accessUrlId = api_get_current_access_url_id();
if (-1 != $accessUrlId) {
$urlInfo = api_get_access_url($accessUrlId);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url']));
$cleanUrl = str_replace('/', '-', $url);
$dir = "$cleanUrl/admin/";
}
}
$filePath = $dir.$blockName.'_extra.html';

@ -158,10 +158,7 @@ class CoursesAndSessionsCatalog
public static function getCourseCategoriesTree()
{
$urlId = 1;
if (api_is_multiple_url_enabled()) {
$urlId = api_get_current_access_url_id();
}
$countCourses = self::countAvailableCoursesToShowInCatalog($urlId);
$categories = [];
@ -254,11 +251,6 @@ class CoursesAndSessionsCatalog
if (!empty($randomValue)) {
$randomValue = (int) $randomValue;
$sql = "SELECT COUNT(*) FROM $tbl_course";
$result = Database::query($sql);
list($num_records) = Database::fetch_row($result);
if (api_is_multiple_url_enabled()) {
$urlId = api_get_current_access_url_id();
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -287,16 +279,6 @@ class CoursesAndSessionsCatalog
$visibilityCondition
ORDER BY RAND()
LIMIT 0, $randomValue";
} else {
$sql = "SELECT id, id as real_id
FROM $tbl_course course
WHERE
RAND()*$num_records< $randomValue
$avoidCoursesCondition
$visibilityCondition
ORDER BY RAND()
LIMIT 0, $randomValue";
}
$result = Database::query($sql);
$id_in = null;
@ -330,30 +312,12 @@ class CoursesAndSessionsCatalog
$conditionCode .= " category_code='$categoryCode' ";
}
if (empty($categoryCode) || 'ALL' === $categoryCode) {
$sql = "SELECT *, id as real_id
FROM $tbl_course course
WHERE
1=1
$avoidCoursesCondition
$visibilityCondition
ORDER BY title $limitFilter ";
} else {
$sql = "SELECT *, id as real_id FROM $tbl_course course
WHERE
$conditionCode
$avoidCoursesCondition
$visibilityCondition
ORDER BY title $limitFilter ";
}
// Showing only the courses of the current Chamilo access_url_id
if (api_is_multiple_url_enabled()) {
$urlId = api_get_current_access_url_id();
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$urlCondition = ' access_url_id = '.$urlId.' ';
if ('ALL' !== $categoryCode) {
if (empty($categoryCode) || 'ALL' === $categoryCode) {
$sql = "SELECT *, course.id real_id
FROM $tbl_course as course
INNER JOIN $tbl_url_rel_course as url_rel_course
@ -375,7 +339,6 @@ class CoursesAndSessionsCatalog
ORDER BY title $limitFilter";
}
}
}
$result = Database::query($sql);
$courses = [];
@ -457,27 +420,7 @@ class CoursesAndSessionsCatalog
$categoryFilter = ' AND category_code = "'.$categoryCode.'" ';
}
//$sql = "SELECT DISTINCT course.*, $injectExtraFields
$sql = "SELECT DISTINCT(course.id)
FROM $courseTable course
$sqlInjectJoins
WHERE (
course.code LIKE '%".$keyword."%' OR
course.title LIKE '%".$keyword."%' OR
course.tutor_name LIKE '%".$keyword."%'
)
$where
$categoryFilter
$sqlInjectWhere
$avoidCoursesCondition
$visibilityCondition
ORDER BY title, visual_code ASC
$limitFilter
";
if (api_is_multiple_url_enabled()) {
$urlId = api_get_current_access_url_id();
if (-1 != $urlId) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$urlCondition = ' access_url_id = '.$urlId.' AND';
$allowBaseCategories = ('true' === api_get_setting('course.allow_base_course_category'));
@ -505,8 +448,6 @@ class CoursesAndSessionsCatalog
ORDER BY title, visual_code ASC
$limitFilter
";
}
}
$result = Database::query($sql);
$courses = [];

@ -11,6 +11,7 @@ use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Entity\UserCourseCategory;
use Chamilo\CoreBundle\Exception\NotAllowedException;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper;
use Chamilo\CoreBundle\ServiceHelper\MailHelper;
use Chamilo\CoreBundle\ServiceHelper\PermissionServiceHelper;
use Chamilo\CoreBundle\ServiceHelper\ThemeHelper;
@ -5099,39 +5100,10 @@ function api_request_uri()
* @return int access_url_id of the current Chamilo Installation
*
* @author Julio Montoya <gugli100@gmail.com>
* @throws Exception
*/
function api_get_current_access_url_id(): int
{
if (false === api_get_multiple_access_url()) {
return 1;
}
static $id;
if (!empty($id)) {
return $id;
}
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
$path = Database::escape_string(api_get_path(WEB_PATH));
$sql = "SELECT id FROM $table WHERE url = '".$path."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$id = Database::result($result, 0, 0);
if (false === $id) {
return -1;
}
return (int) $id;
}
$id = 1;
//if the url in WEB_PATH was not found, it can only mean that there is
// either a configuration problem or the first URL has not been defined yet
// (by default it is http://localhost/). Thus the more sensible thing we can
// do is return 1 (the main URL) as the user cannot hack this value anyway
return 1;
return Container::$container->get(AccessUrlHelper::class)->getCurrent()->getId();
}
/**
@ -5987,11 +5959,6 @@ function api_get_multiple_access_url(): bool
return $accessUrlEnabled;
}
function api_is_multiple_url_enabled(): bool
{
return api_get_multiple_access_url();
}
/**
* Returns a md5 unique id.
*

@ -2386,15 +2386,9 @@ class CourseManager
return false;
}
$count = 0;
if (api_is_multiple_url_enabled()) {
$url_id = 1;
if (-1 != api_get_current_access_url_id()) {
$url_id = api_get_current_access_url_id();
}
UrlManager::delete_url_rel_course($courseId, $url_id);
$count = UrlManager::getCountUrlRelCourse($courseId);
}
if (0 === $count) {
// Cleaning group categories
@ -3246,7 +3240,6 @@ class CourseManager
$affected_rows = 0;
//Deleting assigned courses to hrm_id
if (api_is_multiple_url_enabled()) {
$sql = "SELECT s.c_id FROM $tbl_course_rel_user s
INNER JOIN $tbl_course_rel_access_url a
ON (a.c_id = s.c_id)
@ -3254,10 +3247,6 @@ class CourseManager
user_id = $hr_manager_id AND
relation_type = ".COURSE_RELATION_TYPE_RRHH." AND
access_url_id = ".api_get_current_access_url_id();
} else {
$sql = "SELECT c_id FROM $tbl_course_rel_user
WHERE user_id = $hr_manager_id AND relation_type = ".COURSE_RELATION_TYPE_RRHH;
}
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result)) {
@ -5966,19 +5955,9 @@ class CourseManager
return [];
}
$sql = "SELECT DISTINCT(c.id), c.title
FROM $courseTable c
INNER JOIN $courseUserTable cru ON c.id = cru.c_id
WHERE (
cru.user_id IN (".implode(', ', $userIdList).")
AND cru.relation_type = 0
)";
if (api_is_multiple_url_enabled()) {
$courseAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$accessUrlId = api_get_current_access_url_id();
if (-1 != $accessUrlId) {
$sql = "SELECT DISTINCT(c.id), c.title
FROM $courseTable c
INNER JOIN $courseUserTable cru ON c.id = cru.c_id
@ -5988,8 +5967,6 @@ class CourseManager
cru.id_user IN (".implode(', ', $userIdList).") AND
cru.relation_type = 0
)";
}
}
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {

@ -25,15 +25,9 @@ class Login
*/
public static function get_user_account_list($user, $reset = false, $by_username = false)
{
$portal_url = api_get_path(WEB_PATH);
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
if ($reset) {
if ($by_username) {
@ -104,14 +98,9 @@ class Login
$email_to = $user[0]['email'];
}
$portal_url = api_get_path(WEB_PATH);
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
$email_body = get_lang('This is your information to connect to')." ".$portal_url."\n\n$user_account_list";
// SEND MESSAGE

@ -510,21 +510,8 @@ class MySpace
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tblSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$sqlCoachs = "SELECT DISTINCT
scu.user_id as id_coach,
u.id as user_id,
lastname,
firstname,
MAX(login_date) as login_date
FROM $tbl_user u, $tbl_session_course_user scu, $tbl_track_login
WHERE
u.active <> ".USER_SOFT_DELETED." AND scu.user_id = u.id AND scu.status=".SessionEntity::COURSE_COACH." AND login_user_id=u.id
GROUP BY user_id ";
if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sqlCoachs = "SELECT DISTINCT
scu.user_id as id_coach,
u.id as user_id,
@ -542,8 +529,6 @@ class MySpace
access_url_id = $access_url_id AND
session_rel_url.session_id = scu.session_id
GROUP BY u.id";
}
}
if (!empty($order[$tracking_column])) {
$sqlCoachs .= " ORDER BY `".$order[$tracking_column]."` ".$tracking_direction;
}
@ -554,19 +539,8 @@ class MySpace
$global_coaches[$coach['user_id']] = $coach;
}
$sql_session_coach = "SELECT u.id AS user_id, u.lastname, u.firstname, MAX(tel.login_date) AS login_date
FROM $tbl_user u
INNER JOIN $tbl_track_login tel
ON tel.login_user_id = u.id
INNER JOIN $tblSessionRelUser sru
ON (u.id = sru.user_id AND sru.relation_type = ".SessionEntity::GENERAL_COACH.")
GROUP BY u.id
ORDER BY login_date $tracking_direction";
if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql_session_coach = "SELECT u.id AS user_id, u.lastname, u.firstname, MAX(tel.login_date) AS login_date
FROM $tbl_user u
INNER JOIN $tbl_track_login tel
@ -578,8 +552,6 @@ class MySpace
WHERE aurs.access_url_id = $access_url_id
GROUP BY u.id
ORDER BY login_date $tracking_direction";
}
}
$result_sessions_coach = Database::query($sql_session_coach);
//$total_no_coaches += Database::num_rows($result_sessions_coach);

@ -474,14 +474,10 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit
$from = (int) $from;
$number_of_items = (int) $number_of_items;
$urlCondition = '';
$urlJoin = '';
if (api_is_multiple_url_enabled()) {
$accessUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$urlJoin = " INNER JOIN $accessUrlUser a ON (a.user_id = u.id) ";
$urlCondition = " AND a.access_url_id = $urlId ";
}
$query = "SELECT o.login_user_id, o.login_date
FROM $track_online_table o
@ -532,14 +528,10 @@ function who_is_online_in_this_course_count(
return false;
}
$urlCondition = '';
$urlJoin = '';
if (api_is_multiple_url_enabled()) {
$accessUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$urlJoin = " INNER JOIN $accessUrlUser a ON (a.user_id = u.id) ";
$urlCondition = " AND a.access_url_id = $urlId ";
}
$query = "SELECT count(login_user_id) as count
FROM $track_online_table o
@ -582,14 +574,10 @@ function whoIsOnlineInThisSessionCount($timeLimit, $sessionId)
$online_time = time() - $timeLimit * 60;
$current_date = api_get_utc_datetime($online_time);
$urlCondition = '';
$urlJoin = '';
if (api_is_multiple_url_enabled()) {
$accessUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$urlJoin = " INNER JOIN $accessUrlUser a ON (a.user_id = u.id) ";
$urlCondition = " AND a.access_url_id = $urlId ";
}
$query = "SELECT count(login_user_id) as count
FROM $tblTrackOnline o

@ -116,19 +116,12 @@ class Redirect
$redirect = api_get_setting('redirect_admin_to_courses_list');
if ('true' !== $redirect) {
// If the user is a platform admin, redirect to the main admin page
if (api_is_multiple_url_enabled()) {
// if multiple URLs are enabled, make sure he's admin of the
// current URL before redirecting
$url = api_get_current_access_url_id();
if (api_is_platform_admin_by_id($userId, $url)) {
self::navigate(api_get_path(WEB_CODE_PATH).'admin/index.php');
}
} else {
// if no multiple URL, then it's enough to be platform admin
if (api_is_platform_admin_by_id($userId)) {
self::navigate(api_get_path(WEB_CODE_PATH).'admin/index.php');
}
}
}
$page_after_login = api_get_setting('page_after_login');
if (!empty($page_after_login)) {

@ -163,13 +163,10 @@ class SessionManager
global $_configuration;
// Check portal limits
$accessUrlId = api_is_multiple_url_enabled()
? (empty($accessUrlId) ? api_get_current_access_url_id() : (int) $accessUrlId)
: 1;
$accessUrlId = empty($accessUrlId) ? api_get_current_access_url_id() : (int) $accessUrlId;
if (isset($_configuration[$accessUrlId]) &&
if (isset($_configuration[$accessUrlId]['hosting_limit_sessions']) &&
is_array($_configuration[$accessUrlId]) &&
isset($_configuration[$accessUrlId]['hosting_limit_sessions']) &&
$_configuration[$accessUrlId]['hosting_limit_sessions'] > 0
) {
$num = self::count_sessions();
@ -395,27 +392,7 @@ class SessionManager
";
}
$sql = "SELECT COUNT(id) as total_rows FROM (
SELECT DISTINCT
IF (
(s.access_start_date <= '$today' AND '$today' <= s.access_end_date) OR
(s.access_start_date IS NULL AND s.access_end_date IS NULL ) OR
(s.access_start_date <= '$today' AND s.access_end_date IS NULL) OR
('$today' <= s.access_end_date AND s.access_start_date IS NULL)
, 1, 0) as session_active,
s.id
FROM $tbl_session s
LEFT JOIN $tbl_session_category sc
ON s.session_category_id = sc.id
INNER JOIN $tbl_user u
ON s.id_coach = u.id
$courseCondition
$extraJoin
$where $where_condition ) as session_table";
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$where .= " AND ar.access_url_id = $access_url_id ";
$sql = "SELECT count(id) as total_rows FROM (
@ -437,8 +414,6 @@ class SessionManager
$courseCondition
$extraJoin
$where $where_condition) as session_table";
}
}
$sql .= !str_contains($sql, 'WHERE') ? ' WHERE u.active <> '.USER_SOFT_DELETED : ' AND u.active <> '.USER_SOFT_DELETED;
@ -604,20 +579,14 @@ class SessionManager
$injectExtraFields = rtrim(trim($injectExtraFields), ',');
$query .= ", $injectExtraFields";
}
$query .= " FROM $tblSession s $sqlInjectJoins $where $sqlInjectWhere";
if (api_is_multiple_url_enabled()) {
$tblAccessUrlRelSession = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$accessUrlId = api_get_current_access_url_id();
if (-1 != $accessUrlId) {
$where .= " AND ar.access_url_id = $accessUrlId ";
$query = "$select
FROM $tblSession s $sqlInjectJoins
$query .= " FROM $tblSession s $sqlInjectJoins
INNER JOIN $tblAccessUrlRelSession ar
ON (ar.session_id = s.id) $where";
}
}
ON (ar.session_id = s.id) $where $sqlInjectWhere ";
$date = api_get_utc_datetime();
@ -3688,7 +3657,6 @@ class SessionManager
$affected_rows = 0;
// Deleting assigned sessions to hrm_id.
if ($removeSessionsFromUser) {
if (api_is_multiple_url_enabled()) {
$sql = "SELECT s.session_id
FROM $tbl_session_rel_user s
INNER JOIN $tbl_session_rel_access_url a
@ -3697,11 +3665,6 @@ class SessionManager
s.user_id = $userId AND
relation_type = ".Session::DRH." AND
access_url_id = ".api_get_current_access_url_id();
} else {
$sql = "SELECT s.session_id
FROM $tbl_session_rel_user s
WHERE user_id = $userId AND relation_type=".Session::DRH;
}
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -3769,9 +3732,7 @@ class SessionManager
$userId = (int) $userId;
$sessionId = (int) $sessionId;
$select = " SELECT * ";
if (api_is_multiple_url_enabled()) {
$sql = " $select FROM $tbl_session s
$sql = " SELECT * FROM $tbl_session s
INNER JOIN $tbl_session_rel_user sru ON (sru.session_id = s.id)
LEFT JOIN $tbl_session_rel_access_url a ON (s.id = a.session_id)
WHERE
@ -3780,16 +3741,6 @@ class SessionManager
sru.relation_type = '".Session::DRH."' AND
access_url_id = ".api_get_current_access_url_id()."
";
} else {
$sql = "$select FROM $tbl_session s
INNER JOIN $tbl_session_rel_user sru
ON
sru.session_id = s.id AND
sru.user_id = '$userId' AND
sru.session_id = '$sessionId' AND
sru.relation_type = '".Session::DRH."'
";
}
$result = Database::query($sql);
if (Database::num_rows($result)) {
@ -4399,16 +4350,12 @@ class SessionManager
$whereConditions = "sru.user_id = $user_id AND sru.relation_type = ".Session::GENERAL_COACH;
}
if (api_is_multiple_url_enabled()) {
$tblSessionRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$innerJoin .= " INNER JOIN $tblSessionRelAccessUrl session_rel_url
ON (s.id = access_url_rel_session.session_id)";
$whereConditions .= " AND access_url_rel_session.access_url_id = $access_url_id";
}
}
$sql = "SELECT s.* FROM $sessionTable AS s $innerJoin ";
if (!empty($whereConditions)) {
$sql .= "WHERE $whereConditions ";
@ -7810,20 +7757,9 @@ class SessionManager
return [];
}
$sql = "SELECT DISTINCT s.*
FROM $sessionTable s
INNER JOIN $sessionUserTable sru
ON s.id = sru.id_session
WHERE
(sru.id_user IN (".implode(', ', $userIdList).")
AND sru.relation_type = ".Session::STUDENT."
)";
if (api_is_multiple_url_enabled()) {
$sessionAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$accessUrlId = api_get_current_access_url_id();
if (-1 != $accessUrlId) {
$sql = "SELECT DISTINCT s.*
FROM $sessionTable s
INNER JOIN $sessionUserTable sru ON s.id = sru.id_session
@ -7834,8 +7770,6 @@ class SessionManager
sru.id_user IN (".implode(', ', $userIdList).")
AND sru.relation_type = ".Session::STUDENT."
)";
}
}
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {
@ -7943,15 +7877,8 @@ class SessionManager
$orderClause = 'ORDER BY ';
$orderClause .= api_sort_by_first_name() ? 'firstname, lastname, username' : 'lastname, firstname, username';
$sql = "SELECT id as user_id, lastname, firstname, username
FROM $tbl_user
WHERE active <> -1 AND status = '1' ".
$orderClause;
if (api_is_multiple_url_enabled()) {
$userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$accessUrlId = api_get_current_access_url_id();
if (-1 != $accessUrlId) {
$sql = "SELECT user.id as user_id, username, lastname, firstname
FROM $tbl_user user
INNER JOIN $userRelAccessUrlTable url_user
@ -7961,8 +7888,6 @@ class SessionManager
access_url_id = $accessUrlId AND
status = 1 "
.$orderClause;
}
}
$result = Database::query($sql);
$coachesList = Database::store_result($result);
@ -8350,6 +8275,10 @@ class SessionManager
}
$today = api_get_utc_datetime();
$table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
$where .= " AND ar.access_url_id = $access_url_id ";
$query_rows = "SELECT count(*) as total_rows, c.title as course_title, s.title,
IF (
(s.access_start_date <= '$today' AND '$today' < s.access_end_date) OR
@ -8369,24 +8298,8 @@ class SessionManager
ON s.id = scu.session_id
INNER JOIN $courseTable c
ON c.id = scu.c_id
$where ";
if (api_is_multiple_url_enabled()) {
$table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$where .= " AND ar.access_url_id = $access_url_id ";
$query_rows = "SELECT count(*) as total_rows
FROM $tbl_session s
LEFT JOIN $tbl_session_category sc
ON s.session_category_id = sc.id
INNER JOIN $tblSessionRelUser sru ON s.id = sru.session_id
INNER JOIN $tbl_user u
ON sru.user_id = u.id
INNER JOIN $table_access_url_rel_session ar
ON ar.session_id = s.id $where ";
}
}
$result = Database::query($query_rows);
$num = 0;
@ -9051,30 +8964,8 @@ class SessionManager
$limit = ' LIMIT '.$options['limit'];
}
$query = "$select FROM $tbl_session s
LEFT JOIN $tbl_session_field_values fv
ON (fv.item_id = s.id)
LEFT JOIN $extraFieldTable f
ON f.id = fv.field_id
LEFT JOIN $tbl_session_field_options fvo
ON (fv.field_id = fvo.field_id)
LEFT JOIN $tbl_session_rel_course src
ON (src.session_id = s.id)
LEFT JOIN $tbl_course c
ON (src.c_id = c.id)
LEFT JOIN $tbl_session_category sc
ON (s.session_category_id = sc.id)
INNER JOIN $tblSessionRelUser sru ON s.id = sru.session_id
INNER JOIN $tbl_user u
ON sru.user_id = u.id
$where
$limit
";
if (api_is_multiple_url_enabled()) {
$table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$query = "$select
FROM $tbl_session s
LEFT JOIN $tbl_session_field_values fv
@ -9095,8 +8986,6 @@ class SessionManager
$where
$limit
";
}
}
$query .= ') AS s';
@ -9788,7 +9677,6 @@ class SessionManager
$tblSession = Database::get_main_table(TABLE_MAIN_SESSION);
$tblSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
if (api_is_multiple_url_enabled()) {
$tblSessionRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$sql = "SELECT s.id FROM $tblSession s
@ -9799,14 +9687,6 @@ class SessionManager
sru.session_id = '$sessionId' AND
sru.relation_type = '".Session::DRH."' AND
access_url_id = ".api_get_current_access_url_id();
} else {
$sql = "SELECT s.id FROM $tblSession s
INNER JOIN $tblSessionRelUser sru ON sru.session_id = s.id
WHERE
sru.user_id = '$userId' AND
sru.session_id = '$sessionId' AND
sru.relation_type = '".Session::DRH."'";
}
$result = Database::query($sql);

@ -56,7 +56,6 @@ class Statistics
//$categoryCondition = " course_category.code = '".Database::escape_string($categoryCode)."' ";
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT COUNT(*) AS number
FROM ".$course_table." as c, $access_url_rel_course_table as u
$categoryJoin
@ -64,13 +63,6 @@ class Statistics
if (isset($categoryCode)) {
$sql .= " AND $categoryCondition";
}
} else {
$sql = "SELECT COUNT(*) AS number
FROM $course_table $categoryJoin";
if (isset($categoryCode)) {
$sql .= " WHERE $categoryCondition";
}
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
@ -93,19 +85,12 @@ class Statistics
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$urlId = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
$sql = "SELECT COUNT(*) AS number
FROM $course_table as c, $access_url_rel_course_table as u
WHERE u.c_id = c.id AND access_url_id='".$urlId."'";
if (isset($visibility)) {
$sql .= " AND visibility = ".intval($visibility);
}
} else {
$sql = "SELECT COUNT(*) AS number FROM $course_table ";
if (isset($visibility)) {
$sql .= " WHERE visibility = ".intval($visibility);
}
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
@ -139,7 +124,6 @@ class Statistics
$active_filter = $onlyActive ? ' AND active = 1' : '';
$status_filter = isset($status) ? ' AND status = '.intval($status) : '';
if (api_is_multiple_url_enabled()) {
$sql = "SELECT COUNT(DISTINCT(u.id)) AS number
FROM $user_table as u, $access_url_rel_user_table as url
WHERE
@ -160,25 +144,6 @@ class Statistics
access_url_id = $urlId
$status_filter $active_filter";
}
} else {
$sql = "SELECT COUNT(DISTINCT(id)) AS number
FROM $user_table
WHERE 1 = 1 AND active <> ".USER_SOFT_DELETED." $status_filter $active_filter";
if (isset($categoryCode)) {
$categoryCode = Database::escape_string($categoryCode);
$status_filter = isset($status) ? ' AND status = '.intval($status) : '';
$sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number
FROM $course_user_table cu, $course_table c, $tblCourseRelCategory crc, $tblCourseCategory cc
WHERE
c.id = cu.c_id AND
cc.code = '$categoryCode' AND
crc.course_category_id = cc.id AND
crc.course_id = c.id AND
$status_filter
$active_filter
";
}
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
@ -201,17 +166,12 @@ class Statistics
$urlId = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
$sql = "SELECT DISTINCT(t.c_id) FROM $table t , $access_url_rel_course_table a
WHERE
t.c_id = a.c_id AND
access_url_id='".$urlId."' AND
access_date BETWEEN '$startDate' AND '$endDate'
";
} else {
$sql = "SELECT DISTINCT(t.c_id) FROM $table t
access_date BETWEEN '$startDate' AND '$endDate' ";
}
$result = Database::query($sql);
@ -230,18 +190,12 @@ class Statistics
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
$sql = "SELECT count(default_id) AS total_number_of_items
FROM $track_e_default, $table_user user, $access_url_rel_user_table url
WHERE user.active <> ".USER_SOFT_DELETED." AND
default_user_id = user.id AND
user.id=url.user_id AND
access_url_id = '".$urlId."'";
} else {
$sql = "SELECT count(default_id) AS total_number_of_items
FROM $track_e_default, $table_user user
WHERE user.active <> ".USER_SOFT_DELETED." AND default_user_id = user.id ";
}
if (!empty($courseId)) {
$courseId = (int) $courseId;
@ -296,7 +250,6 @@ class Statistics
$direction = 'DESC';
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT
default_event_type as col0,
default_value_type as col1,
@ -314,19 +267,6 @@ class Statistics
track_default.default_user_id = user.id AND
url.user_id = user.id AND
access_url_id= $urlId ";
} else {
$sql = "SELECT
default_event_type as col0,
default_value_type as col1,
default_value as col2,
c_id as col3,
session_id as col4,
user.username as col5,
user.id as col6,
default_date as col7
FROM $track_e_default track_default, $table_user user
WHERE user.active <> ".USER_SOFT_DELETED." AND track_default.default_user_id = user.id ";
}
if (!empty($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
@ -516,15 +456,10 @@ class Statistics
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$table_url = null;
$where_url = null;
$now = api_get_utc_datetime();
$where_url_last = ' WHERE login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)';
if (api_is_multiple_url_enabled()) {
$table_url = ", $access_url_rel_user_table";
$where_url = " WHERE login_user_id=user_id AND access_url_id='".$urlId."'";
$where_url_last = ' AND login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)';
}
$period = get_lang('Month');
$periodCollection = api_get_months_long();
@ -618,12 +553,8 @@ class Statistics
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$table_url = '';
$where_url = '';
if (api_is_multiple_url_enabled()) {
$table_url = ", $access_url_rel_user_table";
$where_url = " AND login_user_id=user_id AND access_url_id='".$urlId."'";
}
$now = api_get_utc_datetime();
$field = 'login_id';
@ -708,12 +639,8 @@ class Statistics
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$table_url = '';
$where_url = '';
if (api_is_multiple_url_enabled()) {
$table_url = ", $access_url_rel_user_table";
$where_url = " AND login_user_id=user_id AND access_url_id='".$urlId."'";
}
$now = api_get_utc_datetime();
$date = new DateTime($now);
@ -776,7 +703,6 @@ class Statistics
foreach ($tools as $tool) {
$tool_names[$tool] = get_lang(ucfirst($tool), '');
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT access_tool, count( access_id ) AS number_of_logins
FROM $table t , $access_url_rel_course_table a
WHERE
@ -785,12 +711,6 @@ class Statistics
access_url_id='".$urlId."'
GROUP BY access_tool
";
} else {
$sql = "SELECT access_tool, count( access_id ) AS number_of_logins
FROM $table
WHERE access_tool IN ('".implode("','", $tools)."')
GROUP BY access_tool ";
}
$res = Database::query($sql);
$result = [];
@ -825,17 +745,11 @@ class Statistics
$table = Database::get_main_table(TABLE_MAIN_COURSE);
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$urlId = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
$sql = "SELECT course_language, count( c.code ) AS number_of_courses
FROM $table as c, $access_url_rel_course_table as u
WHERE u.c_id = c.id AND access_url_id='".$urlId."'
GROUP BY course_language
ORDER BY number_of_courses DESC";
} else {
$sql = "SELECT course_language, count( code ) AS number_of_courses
FROM $table GROUP BY course_language
ORDER BY number_of_courses DESC";
}
$res = Database::query($sql);
$result = [];
while ($obj = Database::fetch_object($res)) {
@ -853,14 +767,9 @@ class Statistics
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$url_condition = null;
$url_condition2 = null;
$table = null;
if (api_is_multiple_url_enabled()) {
$url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.id AND access_url_id='".$urlId."'";
$url_condition2 = " AND url.user_id=u.id AND access_url_id='".$urlId."'";
$table = ", $access_url_rel_user_table as url ";
}
$sql = "SELECT COUNT(*) AS n FROM $user_table as u ".$url_condition;
$res = Database::query($sql);
$count1 = Database::fetch_object($res);
@ -969,7 +878,6 @@ class Statistics
$values = $form->exportValues();
$date_diff = $values['date_diff'];
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
if (api_is_multiple_url_enabled()) {
$sql = "SELECT * FROM $table t , $access_url_rel_course_table a
WHERE
t.c_id = a.c_id AND
@ -977,12 +885,6 @@ class Statistics
GROUP BY t.c_id
HAVING t.c_id <> ''
AND DATEDIFF( '".api_get_utc_datetime()."' , access_date ) <= ".$date_diff;
} else {
$sql = "SELECT * FROM $table t
GROUP BY t.c_id
HAVING t.c_id <> ''
AND DATEDIFF( '".api_get_utc_datetime()."' , access_date ) <= ".$date_diff;
}
$sql .= ' ORDER BY `'.$columns[$column].'` '.$sql_order[$direction];
$from = ($page_nr - 1) * $per_page;
$sql .= ' LIMIT '.$from.','.$per_page;
@ -1045,19 +947,12 @@ class Statistics
break;
}
if (api_is_multiple_url_enabled()) {
$sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
FROM $access_url_rel_user_table as url, $message_table m
LEFT JOIN $user_table u ON m.$field = u.id AND u.active <> ".USER_SOFT_DELETED."
WHERE url.user_id = m.$field AND access_url_id='".$urlId."'
GROUP BY m.$field
ORDER BY count_message DESC ";
} else {
$sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
FROM $message_table m
LEFT JOIN $user_table u ON m.$field = u.id AND u.active <> ".USER_SOFT_DELETED."
GROUP BY m.$field ORDER BY count_message DESC ";
}
$res = Database::query($sql);
$messages_sent = [];
while ($messages = Database::fetch_array($res)) {
@ -1084,7 +979,6 @@ class Statistics
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
FROM $access_url_rel_user_table as url, $user_friend_table uf
LEFT JOIN $user_table u
@ -1095,15 +989,6 @@ class Statistics
access_url_id = '".$urlId."'
GROUP BY uf.user_id
ORDER BY count_friend DESC ";
} else {
$sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
FROM $user_friend_table uf
LEFT JOIN $user_table u
ON (uf.user_id = u.id) AND u.active <> ".USER_SOFT_DELETED."
WHERE uf.relation_type <> '".UserRelUser::USER_RELATION_TYPE_RRHH."'
GROUP BY uf.user_id
ORDER BY count_friend DESC ";
}
$res = Database::query($sql);
$list_friends = [];
while ($friends = Database::fetch_array($res)) {
@ -1124,13 +1009,8 @@ class Statistics
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$total = self::countUsers();
if (api_is_multiple_url_enabled()) {
$table_url = ", $access_url_rel_user_table";
$where_url = " AND login_user_id=user_id AND access_url_id='".$urlId."'";
} else {
$table_url = '';
$where_url = '';
}
$now = api_get_utc_datetime();
$sql[get_lang('This day')] =
"SELECT count(distinct(login_user_id)) AS number ".
@ -1453,15 +1333,10 @@ class Statistics
$tblUser = Database::get_main_table(TABLE_MAIN_USER);
$tblLogin = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$urlJoin = '';
$urlWhere = '';
if (api_is_multiple_url_enabled()) {
$tblUrlUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlJoin = "INNER JOIN $tblUrlUser au ON u.id = au.user_id";
$urlWhere = 'AND au.access_url_id = '.api_get_current_access_url_id();
}
$sql = "SELECT u.id,
u.firstname,

@ -1742,14 +1742,10 @@ class Tracking
$userCondition = " login_user_id = $userId ";
}
$url_condition = null;
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$url_table = null;
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
$url_table = ", $tbl_url_rel_user as url_users";
$url_condition = " AND u.login_user_id = url_users.user_id AND access_url_id='$access_url_id'";
}
if (empty($timeFilter)) {
$timeFilter = 'last_week';
@ -1825,13 +1821,9 @@ class Tracking
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$url_table = null;
$url_condition = null;
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
$url_table = ", ".$tbl_url_rel_user." as url_users";
$url_condition = " AND u.login_user_id = url_users.user_id AND access_url_id='$access_url_id'";
}
if (!empty($startDate) && !empty($endDate)) {
$startDate = Database::escape_string($startDate);
@ -3613,16 +3605,10 @@ class Tracking
$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$accessUrlEnabled = api_is_multiple_url_enabled();
$access_url_id = $accessUrlEnabled ? api_get_current_access_url_id() : -1;
$access_url_id = api_get_current_access_url_id();
$students = [];
// At first, courses where $coach_id is coach of the course //
$sql = 'SELECT session_id, c_id
FROM '.$tbl_session_course_user.'
WHERE user_id='.$coach_id.' AND status = '.SessionEntity::COURSE_COACH;
if (-1 != $access_url_id) {
$sql = 'SELECT scu.session_id, scu.c_id
FROM '.$tbl_session_course_user.' scu
INNER JOIN '.$tbl_session_rel_access_url.' sru
@ -3631,7 +3617,6 @@ class Tracking
scu.user_id='.$coach_id.' AND
scu.status = '.SessionEntity::COURSE_COACH.' AND
sru.access_url_id = '.$access_url_id;
}
$result = Database::query($sql);
@ -3768,9 +3753,7 @@ class Tracking
ON (c.id = sc.c_id)
WHERE sc.user_id = '.$coach_id.' AND sc.status = '.SessionEntity::COURSE_COACH;
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = 'SELECT DISTINCT c.code
FROM '.$tbl_session_course_user.' scu
INNER JOIN '.$tbl_course.' c
@ -3781,8 +3764,6 @@ class Tracking
scu.user_id='.$coach_id.' AND
scu.status = '.SessionEntity::COURSE_COACH.' AND
cru.access_url_id = '.$access_url_id;
}
}
if (!empty($sessionId)) {
$sql .= ' AND session_id='.$sessionId;
@ -3795,21 +3776,8 @@ class Tracking
}
// Then, courses where $coach_id is coach of the session
$sql = "SELECT DISTINCT course.code
FROM $tbl_session_course as session_course
INNER JOIN $tbl_session as session
ON (session.id = session_course.session_id)
INNER JOIN $tblSessionRelUser session_user
ON (session.id = session_user.session_id
AND session_user.user_id = $coach_id
AND session_user.relation_type = ".SessionEntity::GENERAL_COACH.")
INNER JOIN $tbl_course as course
ON course.id = session_course.c_id";
if (api_is_multiple_url_enabled()) {
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT DISTINCT c.code
FROM $tbl_session_course as session_course
INNER JOIN $tbl_course c
@ -3824,19 +3792,13 @@ class Tracking
ON course.id = session_course.c_id
INNER JOIN $tbl_course_rel_access_url course_rel_url
ON (course_rel_url.c_id = c.id)";
}
}
if (!empty($sessionId)) {
$sql .= ' WHERE session_course.session_id='.$sessionId;
if (api_is_multiple_url_enabled()) {
$sql .= ' AND access_url_id = '.$access_url_id;
}
} else {
if (api_is_multiple_url_enabled()) {
$sql .= ' WHERE access_url_id = '.$access_url_id;
}
}
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
@ -4610,7 +4572,6 @@ class Tracking
$session_id = (int) $session_id;
$urlId = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
$sql = "SELECT c.id, c.code, title
FROM $tbl_course_user cu
INNER JOIN $tbl_course c
@ -4622,16 +4583,6 @@ class Tracking
relation_type<> ".COURSE_RELATION_TYPE_RRHH." AND
access_url_id = $urlId
ORDER BY title";
} else {
$sql = "SELECT c.id, c.code, title
FROM $tbl_course_user cu
INNER JOIN $tbl_course c
ON (cu.c_id = c.id)
WHERE
cu.user_id = $user_id AND
relation_type <> ".COURSE_RELATION_TYPE_RRHH."
ORDER BY title";
}
$rs = Database::query($sql);
$courses = $course_in_session = $temp_course_in_session = [];
@ -4657,7 +4608,6 @@ class Tracking
}
// Get the list of sessions where the user is subscribed as student
if (api_is_multiple_url_enabled()) {
$sql = "SELECT DISTINCT c.code, s.id as session_id, s.title
FROM $tbl_session_course_user cu
INNER JOIN $tbl_access_rel_session a
@ -4672,19 +4622,6 @@ class Tracking
access_url_id = ".$urlId."
$sessionCondition
$orderBy ";
} else {
$sql = "SELECT DISTINCT c.code, s.id as session_id, s.title
FROM $tbl_session_course_user cu
INNER JOIN $tbl_session s
ON (s.id = cu.session_id)
INNER JOIN $tbl_course c
ON (c.id = cu.c_id)
$extraInnerJoin
WHERE
cu.user_id = $user_id
$sessionCondition
$orderBy ";
}
$rs = Database::query($sql);
$simple_session_array = [];
@ -8650,12 +8587,8 @@ class TrackingCourseLog
) ";
}
$url_table = '';
$url_condition = '';
if (api_is_multiple_url_enabled()) {
$url_table = " INNER JOIN $tbl_url_rel_user as url_users ON (user.id = url_users.user_id)";
$url_condition = " AND access_url_id = '$access_url_id'";
}
$invitedUsersCondition = '';
if (!$includeInvitedUsers) {
@ -9054,12 +8987,8 @@ class TrackingCourseLog
$condition_user = " WHERE user.user_id = $user_ids ";
}
$url_table = null;
$url_condition = null;
if (api_is_multiple_url_enabled()) {
$url_table = ", ".$tbl_url_rel_user." as url_users";
$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
}
$invitedUsersCondition = '';
if (!$includeInvitedUsers) {

@ -387,15 +387,11 @@ class UserManager
$email_admin = api_get_setting('emailAdministrator');
$url = api_get_path(WEB_PATH);
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$urlInfo = api_get_access_url($access_url_id);
if ($urlInfo) {
$url = $urlInfo['url'];
}
}
}
// variables for the default template
$params = [
@ -966,14 +962,9 @@ class UserManager
PERSON_NAME_EMAIL_ADDRESS
);
$email_admin = api_get_setting('emailAdministrator');
$url = api_get_path(WEB_PATH);
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$url = api_get_access_url($access_url_id);
$url = $url['url'];
}
}
$tplContent = new Template(
null,
@ -1381,7 +1372,6 @@ class UserManager
$return_array = [];
$sql = "SELECT user.*, user.id as user_id FROM $user_table user ";
if (api_is_multiple_url_enabled()) {
if ($idCampus) {
$urlId = $idCampus;
} else {
@ -1390,9 +1380,6 @@ class UserManager
$sql .= " INNER JOIN $userUrlTable url_user
ON (user.id = url_user.user_id)
WHERE url_user.access_url_id = $urlId";
} else {
$sql .= " WHERE 1=1 ";
}
if (count($conditions) > 0) {
foreach ($conditions as $field => $value) {
@ -1438,7 +1425,6 @@ class UserManager
$sql = "SELECT count(user.id) count FROM $user_table user ";
}
if (api_is_multiple_url_enabled()) {
if ($idCampus) {
$urlId = $idCampus;
} else {
@ -1447,9 +1433,6 @@ class UserManager
$sql .= " INNER JOIN $userUrlTable url_user
ON (user.user_id = url_user.user_id)
WHERE url_user.access_url_id = $urlId";
} else {
$sql .= " WHERE 1=1 ";
}
$sql .= " AND status <> ".ANONYMOUS." ";
@ -1514,11 +1497,7 @@ class UserManager
$tblAccessUrlRelUser = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$return_array = [];
$sql_query = "SELECT user.id FROM $user_table user ";
if (api_is_multiple_url_enabled()) {
$sql_query .= " INNER JOIN $tblAccessUrlRelUser auru ON auru.user_id = user.id ";
}
$sql_query .= ' WHERE 1 = 1 ';
if (count($conditions) > 0) {
$temp_conditions = [];
@ -1535,14 +1514,10 @@ class UserManager
$sql_query .= ' AND '.implode(' '.$condition.' ', $temp_conditions);
}
if (api_is_multiple_url_enabled()) {
$sql_query .= ' AND auru.access_url_id = '.api_get_current_access_url_id();
}
} else {
if (api_is_multiple_url_enabled()) {
$sql_query .= ' AND auru.access_url_id = '.api_get_current_access_url_id();
}
}
if (!empty($onlyThisUserList)) {
$onlyThisUserListToString = implode("','", $onlyThisUserList);
@ -3379,18 +3354,12 @@ class UserManager
$t_u = Database::get_main_table(TABLE_MAIN_USER);
$t_a = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
if (api_is_multiple_url_enabled()) {
$sql = "SELECT count(u.id)
FROM $t_u u
INNER JOIN $t_a url_user
ON (u.id = url_user.user_id)
WHERE url_user.access_url_id = $access_url_id
";
} else {
$sql = "SELECT count(u.id)
FROM $t_u u
WHERE 1 = 1 ";
}
$status = (int) $status;
if (!empty($status) && $status > 0) {

@ -283,9 +283,7 @@ class IndexManager
}
// Showing only the courses of the current access_url_id.
if (api_is_multiple_url_enabled()) {
$url_access_id = api_get_current_access_url_id();
if (-1 != $url_access_id) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql = "SELECT * FROM $main_course_table as course
INNER JOIN $tbl_url_rel_course as url_rel_course
@ -305,8 +303,6 @@ class IndexManager
course_category.code = '$category'
ORDER BY course.title, UPPER(visual_code)";
}
}
}
// Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
$queryResult = Database::query($sql);
@ -329,27 +325,12 @@ class IndexManager
$platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )";
}
}
$sqlGetSubCatList = "
SELECT t1.name,
t1.code,
t1.parent_id,
t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
FROM $main_category_table t1
LEFT JOIN $main_category_table t2
ON t1.code=t2.parent_id
LEFT JOIN $main_course_table t3
ON (t3.category_id = t1.id $platform_visible_courses)
WHERE t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")."
GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count
ORDER BY t1.tree_pos, t1.name";
// Showing only the category of courses of the current access_url_id
if (api_is_multiple_url_enabled()) {
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
$courseCategoryCondition = " INNER JOIN $table a ON (t1.id = a.course_category_id)";
$url_access_id = api_get_current_access_url_id();
if (-1 != $url_access_id) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sqlGetSubCatList = "
SELECT t1.name,
@ -368,8 +349,6 @@ class IndexManager
t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")."
GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count
ORDER BY t1.tree_pos, t1.name";
}
}
$resCats = Database::query($sqlGetSubCatList);
$thereIsSubCat = false;

@ -1339,19 +1339,10 @@ class Rest extends WebService
throw new Exception(get_lang('UserNotRegistered'));
}
if (api_is_multiple_url_enabled()) {
if (-1 != api_get_current_access_url_id()) {
UrlManager::add_user_to_url(
$userId,
api_get_current_access_url_id()
);
} else {
UrlManager::add_user_to_url($userId, 1);
}
} else {
// We add by default the access_url_user table with access_url_id = 1
UrlManager::add_user_to_url($userId, 1);
}
// Save new field label into user_field table.
UserManager::create_extra_field(
@ -1625,12 +1616,7 @@ class Rest extends WebService
$modelSession = SessionManager::fetch($modelSessionId);
$generalCoachesId = SessionManager::getGeneralCoachesIdForSession($modelSessionId);
$modelSession['accessUrlId'] = 1;
if (api_is_multiple_url_enabled()) {
if (-1 != api_get_current_access_url_id()) {
$modelSession['accessUrlId'] = api_get_current_access_url_id();
}
}
$newSessionId = SessionManager::create_session(
$sessionName,
@ -1690,18 +1676,10 @@ class Rest extends WebService
throw new Exception(get_lang('CoursesNotAddedToSession'));
}
if (api_is_multiple_url_enabled()) {
if (-1 != api_get_current_access_url_id()) {
UrlManager::add_session_to_url(
$newSessionId,
api_get_current_access_url_id()
);
} else {
UrlManager::add_session_to_url($newSessionId, 1);
}
} else {
UrlManager::add_session_to_url($newSessionId, 1);
}
return $newSessionId;
}

@ -58,7 +58,6 @@ class ZombieManager
user.active,
access.login_date';
if (api_is_multiple_url_enabled()) {
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
@ -71,16 +70,6 @@ class ZombieManager
access.login_date <= '$ceiling' AND
user.user_id = access.login_user_id AND
url.user_id = user.user_id AND url.access_url_id=$current_url_id";
} else {
$sql .= " FROM $user_table as user, $login_table as access
WHERE
access.login_date = (SELECT MAX(a.login_date)
FROM $login_table as a
WHERE a.login_user_id = user.user_id
) AND
access.login_date <= '$ceiling' AND
user.user_id = access.login_user_id";
}
if ($active_only) {
$sql .= ' AND user.active = 1';

@ -43,15 +43,8 @@ if (api_is_drh()) {
}
// Select of sessions.
$sql = "SELECT s.id, name FROM $tblSession s
$innerJoinSessionRelUser
$whereCondictionDRH
ORDER BY name";
if (api_is_multiple_url_enabled()) {
$tblSessionRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$accessUrlId = api_get_current_access_url_id();
if (-1 != $accessUrlId) {
$sql = "SELECT s.id, name FROM $tblSession s
INNER JOIN $tblSessionRelAccessUrl as session_rel_url
ON (s.id = session_rel_url.session_id)
@ -59,8 +52,6 @@ if (api_is_multiple_url_enabled()) {
WHERE access_url_id = $accessUrlId
$whereCondictionMultiUrl
ORDER BY name";
}
}
$result = Database::query($sql);
$Sessions = Database::store_result($result);
$options = [];

@ -131,14 +131,9 @@ if ($form->validate()) {
if (!empty($email) && $send_mail) {
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('Your registration on').' '.api_get_setting('siteName');
$portal_url = api_get_path(WEB_PATH);
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
$emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($userInfo['firstname'], $userInfo['lastname'])).",\n\n".
get_lang('You are registered to')." ".api_get_setting('siteName')." ".get_lang('with the following settings:')."\n\n".

@ -172,10 +172,8 @@ function search_users($needle, $type)
break;
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
switch ($type) {
case 'single':
$sql = "
@ -225,8 +223,6 @@ function search_users($needle, $type)
";
break;
}
}
}
$rs = Database::query($sql);
$i = 0;
@ -367,22 +363,8 @@ if ('true' === $orderListByOfficialCode) {
}
if ($ajax_search) {
$sql = "
SELECT u.id, u.lastname, u.firstname, u.username, session_id, u.official_code
FROM $tblUser u
INNER JOIN $tblSessionRelUser su
ON su.user_id = u.id
AND su.relation_type = ".Session::STUDENT."
AND su.session_id = ".intval($sessionId)."
WHERE u.status<>".DRH."
AND u.status <> 6
$order_clause
";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "
SELECT u.id, u.lastname, u.firstname, u.username, session_id, u.official_code
FROM $tblUser u
@ -396,8 +378,6 @@ if ($ajax_search) {
AND u.status <> 6
$order_clause
";
}
}
$result = Database::query($sql);
$users = Database::store_result($result);
foreach ($users as $user) {
@ -464,21 +444,12 @@ if ($ajax_search) {
$final_result = $extra_field_result[0];
}
if (api_is_multiple_url_enabled()) {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " AND u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " AND u.id = -1";
}
} else {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " WHERE u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " WHERE u.id = -1";
}
}
}
if (api_is_session_admin() && 'true' === api_get_setting('prevent_session_admins_to_manage_all_users')) {
$order_clause = " AND u.creator_id = ".api_get_user_id().$order_clause;
@ -508,10 +479,8 @@ if ($ajax_search) {
$order_clause
";
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "
SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tblUser u
@ -526,8 +495,6 @@ if ($ajax_search) {
AND u.status<>6
$order_clause
";
}
}
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');
@ -545,20 +512,8 @@ if ($ajax_search) {
unset($users); //clean to free memory
// filling the correct users in list
$sql = "
SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tblUser u
LEFT JOIN $tblSessionRelUser
ON $tblSessionRelUser.user_id = u.id
AND $tblSessionRelUser.session_id = $sessionId
AND $tblSessionRelUser.relation_type = ".Session::STUDENT."
WHERE u.status <> ".DRH." AND u.status <> 6 $order_clause
";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "
SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tblUser u
@ -572,8 +527,6 @@ if ($ajax_search) {
AND u.status <> 6
$order_clause
";
}
}
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');

@ -186,7 +186,6 @@ function search_users($needle, $type)
break;
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
@ -240,7 +239,6 @@ function search_users($needle, $type)
break;
}
}
}
$rs = Database::query($sql);
$i = 0;
@ -387,26 +385,8 @@ if ('true' === $orderListByOfficialCode) {
}
if ($ajax_search) {
$sql = "
SELECT u.id, u.lastname, u.firstname, u.username, su.session_id, u.official_code
FROM $tbl_session_rel_user su
INNER JOIN $tableRelSessionCourseUser sc
ON (sc.session_id = su.session_id AND su.user_id = sc.user_id)
INNER JOIN $tbl_user u
ON su.user_id = u.id
WHERE
su.session_id = ".intval($id_session)." AND
su.relation_type = ".Session::STUDENT." AND
sc.c_id = $courseId AND
u.status<>".DRH." AND
u.status <> 6
$order_clause
";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "
SELECT u.id, u.lastname, u.firstname, u.username, su.session_id, u.official_code
FROM $tbl_user u
@ -426,8 +406,6 @@ if ($ajax_search) {
u.status <> 6
$order_clause
";
}
}
$result = Database::query($sql);
$users = Database::store_result($result);
foreach ($users as $user) {
@ -493,21 +471,12 @@ if ($ajax_search) {
$final_result = $extra_field_result[0];
}
if (api_is_multiple_url_enabled()) {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " AND u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " AND u.id = -1";
}
} else {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " WHERE u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " WHERE u.id = -1";
}
}
}
if (api_is_session_admin() && 'true' === api_get_setting('prevent_session_admins_to_manage_all_users')) {
$order_clause = " AND u.creator_id = ".api_get_user_id().$order_clause;
@ -542,10 +511,8 @@ if ($ajax_search) {
$order_clause
";
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
FROM $tbl_user u
@ -563,8 +530,6 @@ if ($ajax_search) {
AND u.status<>6
$order_clause
";
}
}
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');
@ -582,25 +547,8 @@ if ($ajax_search) {
unset($users); //clean to free memory
// filling the correct users in list
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user su
ON su.user_id = u.id
AND su.session_id = $id_session
AND su.relation_type = ".Session::STUDENT."
INNER JOIN $tableRelSessionCourseUser sc
ON (sc.session_id = su.session_id AND su.user_id = sc.user_id)
WHERE
sc.c_id = $courseId AND
u.status <> ".DRH." AND u.status <> 6
$order_clause
";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
FROM $tbl_user u
@ -619,8 +567,6 @@ if ($ajax_search) {
u.status <> 6
$order_clause
";
}
}
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');

@ -126,11 +126,7 @@ $sessionTitle = Display::page_subheader(get_lang('General properties').$url);
$sessionField = new ExtraField('session');
$extraFieldData = $sessionField->getDataAndFormattedValues($sessionId);
$urlList = [];
$isMultipleUrl = api_is_multiple_url_enabled();
if ($isMultipleUrl) {
$urlList = $session->getUrls();
}
$url = Display::url(
Display::getMdiIcon(ActionIcon::ADD, 'ch-tool-icon-gradient', null, 32, get_lang('Add')),
@ -330,13 +326,11 @@ if (!empty($sessionRelUsers)) {
);
$addUserToUrlLink = '';
/*if ($isMultipleUrl) {
if ($user['access_url_id'] != $url_id) {
/*if ($user['access_url_id'] != $url_id) {
$userLink .= ' '.Display::getMdiIcon(StateIcon::WARNING, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Users not added to the URL'));
$add = Display::getMdiIcon(ActionIcon::ADD, 'ch-tool-icon', null, ICON_SIZE_SMALL, get_lang('Add a userToURL'));
$addUserToUrlLink = '<a href="resume_session.php?action=add_user_to_url&id_session='.$sessionId
.'&user_id='.$user['user_id'].'">'.$add.'</a>';
}
}*/
$editUrl = null;

@ -39,19 +39,8 @@ function search_coachs($needle)
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
// search users where username or firstname or lastname begins likes $needle
$sql = 'SELECT username, lastname, firstname
FROM '.$tbl_user.' user
WHERE (username LIKE "'.$needle.'%"
OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%")
AND status=1'.
$order_clause.
' LIMIT 10';
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = 'SELECT username, lastname, firstname
FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user
@ -66,8 +55,6 @@ function search_coachs($needle)
AND status=1'.
$order_clause.'
LIMIT 10';
}
}
$rs = Database::query($sql);
while ($user = Database :: fetch_array($rs)) {

@ -113,7 +113,6 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
if (api_is_multiple_url_enabled()) {
$tbl_access_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
$sql = "SELECT u.id as user_id,lastname,firstname,username
@ -125,14 +124,6 @@ if (api_is_multiple_url_enabled()) {
active = 1 AND
access_url_id = $access_url_id ".
$order_clause;
} else {
$sql = "SELECT id as user_id,lastname,firstname,username
FROM $tblUser
WHERE
status = '1' AND
active = 1 ".
$order_clause;
}
$result = Database::query($sql);
$coaches = Database::store_result($result);

@ -39,6 +39,8 @@ if (isset($_POST['formSent'])) {
$file_type = isset($_POST['file_type']) ? $_POST['file_type'] : 'csv';
$session_id = $_POST['session_id'];
if (empty($session_id)) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
$sql = "SELECT
s.id,
s.title,
@ -48,18 +50,6 @@ if (isset($_POST['formSent'])) {
s.visibility,
s.session_category_id
FROM $tblSession s
INNER JOIN $tblSessionRelUser sru
ON (s.id = sru.session_id AND sru.relation_type = ".Session::GENERAL_COACH.")
INNER JOIN $tblUser u
ON u.id = sru.user_id
ORDER BY s.id";
if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT s.id, s.title, u.username,s.access_start_date,s.access_end_date,s.visibility,s.session_category_id
FROM $tblSession s
INNER JOIN $tbl_session_rel_access_url as session_rel_url
ON (s.id= session_rel_url.session_id)
INNER JOIN $tblSessionRelUser sru
@ -67,8 +57,6 @@ if (isset($_POST['formSent'])) {
INNER JOIN $tblUser u ON (u.id = sru.user_id)
WHERE session_rel_url.access_url_id = $access_url_id
ORDER BY s.id";
}
}
$result = Database::query($sql);
} else {
@ -278,19 +266,13 @@ if (isset($_POST['formSent'])) {
Display::display_header($tool_name);
//select of sessions
$sql = "SELECT id, title FROM $tblSession ORDER BY title";
if (api_is_multiple_url_enabled()) {
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT s.id, title FROM $tblSession s
INNER JOIN $tbl_session_rel_access_url as session_rel_url
ON (s.id = session_rel_url.session_id)
WHERE access_url_id = $access_url_id
ORDER BY title";
}
}
$result = Database::query($sql);
$sessions = Database::store_result($result);

@ -376,13 +376,8 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
}
// Associate the session with access_url.
if (api_is_multiple_url_enabled()) {
$accessUrlId = api_get_current_access_url_id();
UrlManager::add_session_to_url($sessionId, $accessUrlId);
} else {
// We fill by default the access_url_rel_session table.
UrlManager::add_session_to_url($sessionId, 1);
}
// Adding users to the new session.
foreach ($nodeSession->User as $nodeUser) {

@ -112,20 +112,28 @@ if ('true' === $allowTutors) {
}
}
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
switch ($type) {
case 'single':
// search users where username or firstname or lastname begins likes $needle
$sql = 'SELECT user.user_id, username, lastname, firstname
FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user
ON (url_user.user_id=user.user_id)
WHERE user.active <> '.USER_SOFT_DELETED.' AND (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.''.
OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.'
AND access_url_id = '.$access_url_id.
$order_clause.
' LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname
FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user
ON (url_user.user_id=user.user_id)
WHERE user.active <> '.USER_SOFT_DELETED.' AND '.(api_sort_by_first_name() ? 'firstname' : 'lastname').'
AND access_url_id = '.$access_url_id.' AND
LIKE "'.$needle.'%" AND
user.status<>'.DRH.' AND
user.status<>6 '.$cond_user_id.
@ -135,50 +143,7 @@ if ('true' === $allowTutors) {
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname
FROM '.$tbl_user.' user
LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.user_id = user.user_id)
WHERE
user.active <> '.USER_SOFT_DELETED.' AND
s.user_id IS NULL AND
user.status <>'.DRH.' AND
user.status <> 6 '.$cond_user_id.
$order_clause;
break;
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
switch ($type) {
case 'single':
$sql = 'SELECT user.user_id, username, lastname, firstname
FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user
ON (url_user.user_id=user.user_id)
WHERE
user.active <> '.USER_SOFT_DELETED.' AND
access_url_id = '.$access_url_id.' AND
(username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%" OR lastname LIKE "'.$needle.'%") AND
user.status<>6 AND
user.status<>'.DRH.' '.
$order_clause.
' LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname
FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user
ON (url_user.user_id=user.user_id)
WHERE user.active <> '.USER_SOFT_DELETED.' AND access_url_id = '.$access_url_id.' AND
'.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id.
$order_clause;
break;
case 'any_session':
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname
FROM '.$tbl_user.' user
LEFT OUTER JOIN '.$tbl_session_rel_user.' s
ON (s.user_id = user.user_id)
INNER JOIN '.$tbl_user_rel_access_url.' url_user
ON (url_user.user_id=user.user_id)
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE
user.active <> '.USER_SOFT_DELETED.' AND
access_url_id = '.$access_url_id.' AND
@ -188,8 +153,6 @@ if ('true' === $allowTutors) {
$order_clause;
break;
}
}
}
$rs = Database::query($sql);
$i = 0;
@ -292,19 +255,8 @@ if ('true' === $allowTutors) {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
if ($ajax_search) {
$sql = "SELECT u.id as user_id, lastname, firstname, username, session_id
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user
ON
$tbl_session_rel_user.user_id = u.id AND
$tbl_session_rel_user.relation_type = ".Session::STUDENT." AND
$tbl_session_rel_user.session_id = ".intval($id_session)."
WHERE u.active <> ".USER_SOFT_DELETED." AND u.status <> ".DRH." AND u.status<>6 $order_clause";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT u.id as user_id, lastname, firstname, username, session_id
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user
@ -314,10 +266,7 @@ if ('true' === $allowTutors) {
$tbl_session_rel_user.session_id = ".intval($id_session)."
INNER JOIN $tbl_user_rel_access_url url_user
ON (url_user.user_id=u.user_id)
WHERE u.active <> ".USER_SOFT_DELETED." AND access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
}
WHERE u.active <> ".USER_SOFT_DELETED." AND u.status<>".DRH." AND u.status<>6 AND access_url_id = $access_url_id $order_clause";
$result = Database::query($sql);
$users = Database::store_result($result);
foreach ($users as $user) {
@ -345,6 +294,8 @@ if ('true' === $allowTutors) {
}
}
$where_filter = '';
if ($use_extra_fields) {
$final_result = [];
if (count($extra_field_result) > 1) {
@ -360,60 +311,25 @@ if ('true' === $allowTutors) {
$final_result = $extra_field_result[0];
}
$where_filter = '';
if (api_is_multiple_url_enabled()) {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " AND u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " AND u.id = -1";
}
} else {
if (is_array($final_result) && count($final_result) > 0) {
$where_filter = " WHERE u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " WHERE u.id = -1";
}
}
}
if ($use_extra_fields) {
$sql = "SELECT u.id as user_id, lastname, firstname, username, session_id
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.id AND
$tbl_session_rel_user.session_id = '$id_session' AND
$tbl_session_rel_user.relation_type = ".Session::STUDENT."
$where_filter AND u.status<>".DRH." AND u.status<>6 AND u.active <> ".USER_SOFT_DELETED."
$order_clause";
} else {
$sql = "SELECT u.id as user_id, lastname, firstname, username, session_id
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.id AND
$tbl_session_rel_user.session_id = '$id_session' AND
$tbl_session_rel_user.relation_type = ".Session::STUDENT."
WHERE u.status <> ".DRH." AND u.status<>6 AND u.active <> ".USER_SOFT_DELETED."
$order_clause";
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT u.id as user_id, lastname, firstname, username, session_id
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON
$tbl_session_rel_user.user_id = u.id AND
ON $tbl_session_rel_user.user_id = u.id AND
$tbl_session_rel_user.session_id = '$id_session' AND
$tbl_session_rel_user.relation_type = ".Session::STUDENT."
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE access_url_id = $access_url_id $where_filter AND u.status<>".DRH." AND u.status<>6 AND u.active <> ".USER_SOFT_DELETED."
$order_clause";
}
}
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');
@ -431,19 +347,8 @@ if ('true' === $allowTutors) {
unset($users); //clean to free memory
//filling the correct users in list
$sql = "SELECT user_id, lastname, firstname, username, session_id
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON
$tbl_session_rel_user.user_id = u.id AND
$tbl_session_rel_user.session_id = '$id_session' AND
$tbl_session_rel_user.relation_type = ".Session::STUDENT."
WHERE u.active <> ".USER_SOFT_DELETED." AND u.status <> ".DRH." AND u.status<>6 $order_clause";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql = "SELECT u.id as user_id, lastname, firstname, username, session_id
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
@ -452,10 +357,7 @@ if ('true' === $allowTutors) {
$tbl_session_rel_user.session_id = '$id_session' AND
$tbl_session_rel_user.relation_type = ".Session::STUDENT."
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE u.active <> ".USER_SOFT_DELETED." AND access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
}
WHERE u.active <> ".USER_SOFT_DELETED." AND access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 $order_clause";
$result = Database::query($sql);
$users = Database::store_result($result, 'ASSOC');
foreach ($users as $uid => $user) {

@ -230,10 +230,12 @@ function get_number_of_users()
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$courseId = api_get_course_int_id();
$url_access_id = api_get_current_access_url_id();
$studentRoleFilter = " AND (
u.roles LIKE '%ROLE_STUDENT%'
@ -254,26 +256,9 @@ function get_number_of_users()
LEFT JOIN $tbl_session_rel_course_user cu
ON
u.id = cu.user_id AND
c_id = $courseId AND
session_id = $sessionId
WHERE
u.active <> ".USER_SOFT_DELETED." AND
cu.user_id IS NULL
$teacherRoleFilter AND
(u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
if (api_is_multiple_url_enabled()) {
$url_access_id = api_get_current_access_url_id();
if (-1 != $url_access_id) {
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT COUNT(u.id)
FROM $user_table u
LEFT JOIN $tbl_session_rel_course_user cu
ON
u.id = cu.user_id AND cu.c_id = $courseId AND
cu.c_id = $courseId AND
session_id = $sessionId
INNER JOIN $tbl_url_rel_user as url_rel_user
ON (url_rel_user.user_id = u.id)
INNER JOIN $tbl_url_rel_user as url_rel_user ON (url_rel_user.user_id = u.id)
WHERE
u.active <> ".USER_SOFT_DELETED." AND
cu.user_id IS NULL AND
@ -281,23 +266,7 @@ function get_number_of_users()
$teacherRoleFilter AND
(u.official_code <> 'ADMIN' OR u.official_code IS NULL)
";
}
}
} else {
$sql = "SELECT COUNT(u.id)
FROM $user_table u
LEFT JOIN $course_user_table cu
ON u.id = cu.user_id and c_id = $courseId
WHERE
u.active <> ".USER_SOFT_DELETED." AND
cu.user_id IS NULL
$teacherRoleFilter ";
if (api_is_multiple_url_enabled()) {
$url_access_id = api_get_current_access_url_id();
if (-1 != $url_access_id) {
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT COUNT(u.id)
FROM $user_table u
LEFT JOIN $course_user_table cu
@ -310,28 +279,9 @@ function get_number_of_users()
$teacherRoleFilter AND
access_url_id = $url_access_id ";
}
}
}
} else {
// students
if (0 != $sessionId) {
$sql = "SELECT COUNT(u.id)
FROM $user_table u
LEFT JOIN $tbl_session_rel_course_user cu
ON
u.id = cu.user_id AND
c_id = $courseId AND
session_id = $sessionId
WHERE
u.active <> ".USER_SOFT_DELETED." AND
cu.user_id IS NULL
$studentRoleFilter AND
(u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
if (api_is_multiple_url_enabled()) {
$url_access_id = api_get_current_access_url_id();
if (-1 != $url_access_id) {
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT COUNT(u.id)
FROM $user_table u
LEFT JOIN $tbl_session_rel_course_user cu
@ -347,17 +297,16 @@ function get_number_of_users()
$studentRoleFilter AND
access_url_id = $url_access_id AND
(u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
}
}
} else {
$sql = "SELECT COUNT(u.id)
FROM $user_table u
LEFT JOIN $course_user_table cu
ON u.id = cu.user_id AND c_id = $courseId";
ON u.id = cu.user_id AND c_id = $courseId
INNER JOIN $tbl_url_rel_user as url_rel_user ON (url_rel_user.user_id = u.id)";
// we change the SQL when we have a filter
if (isset($_GET['subscribe_user_filter_value']) &&
!empty($_GET['subscribe_user_filter_value']) &&
if (!empty($_GET['subscribe_user_filter_value']) &&
'true' === api_get_setting('profiling_filter_adding_users')
) {
$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
@ -374,23 +323,7 @@ function get_number_of_users()
$sql .= " WHERE cu.user_id IS NULL $studentRoleFilter ";
}
if (api_is_multiple_url_enabled()) {
$url_access_id = api_get_current_access_url_id();
if (-1 != $url_access_id) {
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT COUNT(u.id)
FROM $user_table u
LEFT JOIN $course_user_table cu
ON u.id = cu.user_id AND c_id = $courseId
INNER JOIN $tbl_url_rel_user as url_rel_user
ON (url_rel_user.user_id = u.id)
WHERE
cu.user_id IS NULL AND
access_url_id = $url_access_id
$studentRoleFilter ";
}
}
$sql .= " AND access_url_id = $url_access_id";
}
}
@ -529,32 +462,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
}
$sql .= " AND access_url_id = $url_access_id";
} else {
// adding a teacher NOT through a session
$sql = "SELECT $select_fields
FROM $user_table u
LEFT JOIN $course_user_table cu
ON u.id = cu.user_id AND c_id = $courseId";
// applying the filter of the additional user profile fields
if (isset($_GET['subscribe_user_filter_value']) &&
!empty($_GET['subscribe_user_filter_value']) &&
'true' === api_get_setting('profiling_filter_adding_users')
) {
$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
$sql .= "
LEFT JOIN $table_user_field_values field_values
ON field_values.item_id = u.id
WHERE
cu.user_id IS NULL
$studentRoleFilter AND
field_values.field_id = '".intval($field_identification[0])."' AND
field_values.value = '".Database::escape_string($field_identification[1])."'";
} else {
$sql .= " WHERE cu.user_id IS NULL $teacherRoleFilter";
}
// adding a teacher NOT through a session on a portal with multiple URLs
if (api_is_multiple_url_enabled()) {
if (-1 != $url_access_id) {
$sql = "SELECT $select_fields
FROM $user_table u
LEFT JOIN $course_user_table cu
@ -563,8 +471,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
ON (url_rel_user.user_id = u.id) ";
// applying the filter of the additional user profile fields
if (isset($_GET['subscribe_user_filter_value']) &&
!empty($_GET['subscribe_user_filter_value']) &&
if (!empty($_GET['subscribe_user_filter_value']) &&
'true' === api_get_setting('profiling_filter_adding_users')
) {
$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
@ -582,8 +489,8 @@ function get_user_data($from, $number_of_items, $column, $direction)
$teacherRoleFilter AND
access_url_id = $url_access_id ";
}
}
}
$sql .= " AND access_url_id = $url_access_id ";
}
} else {
// adding a student
@ -594,12 +501,9 @@ function get_user_data($from, $number_of_items, $column, $direction)
ON
u.id = cu.user_id AND
c_id = $courseId AND
session_id = $sessionId ";
if (api_is_multiple_url_enabled()) {
$sql .= " INNER JOIN $tbl_url_rel_user as url_rel_user
session_id = $sessionId
INNER JOIN $tbl_url_rel_user as url_rel_user
ON (url_rel_user.user_id = u.id) ";
}
// applying the filter of the additional user profile fields
if (isset($_GET['subscribe_user_filter_value']) &&
@ -621,35 +525,9 @@ function get_user_data($from, $number_of_items, $column, $direction)
$studentRoleFilter AND
(u.official_code <> 'ADMIN' OR u.official_code IS NULL) ";
}
if (api_is_multiple_url_enabled()) {
$sql .= " AND access_url_id = $url_access_id";
}
} else {
$sql = "SELECT $select_fields
FROM $user_table u
LEFT JOIN $course_user_table cu
ON
u.id = cu.user_id AND
c_id = $courseId ";
// applying the filter of the additional user profile fields
if (isset($_GET['subscribe_user_filter_value']) && !empty($_GET['subscribe_user_filter_value'])) {
$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
$sql .= "
LEFT JOIN $table_user_field_values field_values
ON field_values.item_id = u.id
WHERE
cu.user_id IS NULL
$studentRoleFilter AND
field_values.field_id = '".intval($field_identification[0])."' AND
field_values.value = '".Database::escape_string($field_identification[1])."'";
} else {
$sql .= " WHERE cu.user_id IS NULL $studentRoleFilter ";
}
//showing only the courses of the current Chamilo access_url_id
if (api_is_multiple_url_enabled()) {
if (-1 != $url_access_id) {
$sql = "SELECT $select_fields
FROM $user_table u
LEFT JOIN $course_user_table cu
@ -658,8 +536,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
ON (url_rel_user.user_id = u.id) ";
// applying the filter of the additional user profile fields
if (isset($_GET['subscribe_user_filter_value']) &&
!empty($_GET['subscribe_user_filter_value']) &&
if (!empty($_GET['subscribe_user_filter_value']) &&
'true' === api_get_setting('profiling_filter_adding_users')
) {
$field_identification = explode('*', $_GET['subscribe_user_filter_value']);
@ -674,12 +551,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
access_url_id = $url_access_id
";
} else {
$sql .= " WHERE
cu.user_id IS NULL
$studentRoleFilter AND
access_url_id = $url_access_id ";
}
}
$sql .= " WHERE cu.user_id IS NULL $studentRoleFilter AND access_url_id = $url_access_id ";
}
}
}

@ -228,19 +228,12 @@ if (isset($_GET['action'])) {
active
$legal
FROM $table_session_course_user as session_course_user,
$table_users as user ";
if (api_is_multiple_url_enabled()) {
$sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au ';
}
$sql .= "
$table_users as user, "
.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER)." au
WHERE user.active <> ".USER_SOFT_DELETED." AND c_id = $courseId
AND session_course_user.user_id = user.id
AND session_id = $sessionId
";
if (api_is_multiple_url_enabled()) {
$sql .= " AND user.id = au.user_id AND access_url_id = $current_access_url_id ";
}
AND user.id = au.user_id AND access_url_id = $current_access_url_id ";
// only users no coaches/teachers
if (COURSEMANAGER == $type) {
@ -316,19 +309,14 @@ if (isset($_GET['action'])) {
phone,
user.official_code,
active $legal
FROM $table_course_user as course_user, $table_users as user ";
if (api_is_multiple_url_enabled()) {
$sql .= ' , '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au ';
}
$sql .= " WHERE
FROM $table_course_user as course_user, $table_users as user,
".Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER)." au
WHERE
user.active <> ".USER_SOFT_DELETED." AND
c_id = '$courseId' AND
course_user.relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND
course_user.user_id = user.id ";
if (api_is_multiple_url_enabled()) {
$sql .= " AND user.id = au.user_id AND access_url_id = $current_access_url_id ";
}
course_user.user_id = user.id
AND user.id = au.user_id AND access_url_id = $current_access_url_id ";
// only users no teachers/coaches
if (COURSEMANAGER == $type) {

@ -47,17 +47,11 @@ if (is_array($courseSessionValue) && isset($courseSessionValue[1])) {
$sessionInfo = api_get_session_info($sessionId);
}
$extraUrlJoin = '';
$extraUrlCondition = '';
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$extraUrlJoin .= " INNER JOIN $tbl_user_rel_access_url as user_rel_url
$extraUrlJoin = " INNER JOIN $tbl_user_rel_access_url as user_rel_url
ON (u.id = user_rel_url.user_id) ";
$extraUrlCondition = " AND access_url_id = $access_url_id";
}
}
$sql = "SELECT
u.id AS UserId,
@ -107,19 +101,13 @@ if (strlen($course_code) > 0) {
ORDER BY lastname,firstname";
$filename = 'export_users_'.$sessionInfo['name'].'_'.api_get_local_time();
} else {
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql .= " FROM $userTable u
INNER JOIN $tbl_user_rel_access_url as user_rel_url
ON (u.id = user_rel_url.user_id)
WHERE u.active <> ".USER_SOFT_DELETED." AND access_url_id = $access_url_id
ORDER BY lastname,firstname";
}
} else {
$sql .= " FROM $userTable u WHERE u.active <> ".USER_SOFT_DELETED." ORDER BY lastname,firstname";
}
$filename = 'export_users_'.api_get_local_time();
}
$data = [];

@ -31,8 +31,6 @@ $sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : null;
$dateBegin = isset($_GET['date_begin']) ? strtotime($_GET['date_begin']) : null;
$dateEnd = isset($_GET['date_end']) ? strtotime($_GET['date_end'].' 23:59:59') : null;
if (api_is_multiple_url_enabled()) {
if (-1 != $accessUrlId) {
$result = Database::select(
'*',
"$tblSessionRelAccessUrl",
@ -46,8 +44,6 @@ if (api_is_multiple_url_enabled()) {
if (empty($result)) {
api_not_allowed();
}
}
}
$exportAllInOne = isset($_GET['export_pdf']) ? (int) $_GET['export_pdf'] : false;
$exportZip = isset($_GET['export_zip']) ? (int) $_GET['export_zip'] : false;

@ -9,12 +9,12 @@ namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Exception;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@ -37,6 +37,7 @@ class LegacyListener
private readonly ParameterBagInterface $parameterBag,
private readonly SettingsManager $settingsManager,
private readonly ContainerInterface $container,
private readonly AccessUrlHelper $accessUrlHelper,
) {}
public function __invoke(RequestEvent $event): void
@ -147,16 +148,9 @@ class LegacyListener
$session->set('cid_reset', false);
}
$urlId = $this->accessUrlRepository->getFirstId();
if (1 === (int) $this->parameterBag->get('multiple_access_url')) {
$url = $this->router->generate('index', [], UrlGeneratorInterface::ABSOLUTE_URL);
$accessUrl = $this->accessUrlRepository->findOneBy(['url' => $url]);
if (null !== $accessUrl) {
$urlId = $accessUrl->getId();
}
}
$session->set('access_url_id', $urlId);
$session->set(
'access_url_id',
$this->accessUrlHelper->getCurrent()->getId()
);
}
}

@ -49,14 +49,10 @@ class UsergroupRepository extends ResourceRepository
}
}
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.urls', 'u')
->andWhere('u.accessUrl = :urlId')
->setParameter('urlId', $accessUrl->getId())
->setParameter('urlId', $this->accessUrlHelper->getCurrent()->getId())
;
}
$qb->orderBy('g.createdAt', 'DESC');
$query = $qb->getQuery();
@ -81,22 +77,16 @@ class UsergroupRepository extends ResourceRepository
$qb = $this->createQueryBuilder('g')
->select('g, COUNT(gu) AS HIDDEN memberCount')
->innerJoin('g.users', 'gu')
->innerJoin('g.urls', 'u')
->where('g.groupType = :socialClass')
->andWhere('u.accessUrl = :urlId')
->setParameter('socialClass', Usergroup::SOCIAL_CLASS)
->setParameter('urlId', $this->accessUrlHelper->getCurrent()->getId())
->groupBy('g')
->orderBy('g.createdAt', 'DESC')
->setMaxResults($limit)
;
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.urls', 'u')
->andWhere('u.accessUrl = :urlId')
->setParameter('urlId', $accessUrl->getId())
;
}
if (!empty($query)) {
$qb->andWhere('g.title LIKE :query OR g.description LIKE :query')
->setParameter('query', '%'.$query.'%')
@ -111,7 +101,9 @@ class UsergroupRepository extends ResourceRepository
$qb = $this->createQueryBuilder('g')
->select('g, COUNT(gu) as HIDDEN memberCount')
->innerJoin('g.users', 'gu')
->innerJoin('g.urls', 'u')
->where('g.groupType = :socialClass')
->andWhere('u.accessUrl = :urlId')
->setParameter('socialClass', Usergroup::SOCIAL_CLASS)
->andWhere('gu.relationType IN (:relationTypes)')
->setParameter('relationTypes', [
@ -119,20 +111,12 @@ class UsergroupRepository extends ResourceRepository
Usergroup::GROUP_USER_PERMISSION_READER,
Usergroup::GROUP_USER_PERMISSION_HRM,
])
->setParameter('urlId', $this->accessUrlHelper->getCurrent()->getId())
->groupBy('g')
->orderBy('memberCount', 'DESC')
->setMaxResults($limit)
;
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.urls', 'u')
->andWhere('u.accessUrl = :urlId')
->setParameter('urlId', $accessUrl->getId())
;
}
return $qb->getQuery()->getResult();
}
@ -311,22 +295,17 @@ class UsergroupRepository extends ResourceRepository
$qb->select('g.id, g.title, g.description, g.url, g.picture');
}
if ($this->accessUrlHelper->isMultipleEnabled()) {
$accessUrl = $this->accessUrlHelper->getCurrent();
$qb->innerJoin('g.accessUrls', 'a', 'WITH', 'g.id = a.usergroup')
->andWhere('a.accessUrl = :urlId')
->setParameter('urlId', $accessUrl->getId())
;
}
$qb->where(
$qb
->innerJoin('g.accessUrls', 'a', 'WITH', 'g.id = a.usergroup')
->where(
$qb->expr()->orX(
$qb->expr()->like('g.title', ':tag'),
$qb->expr()->like('g.description', ':tag'),
$qb->expr()->like('g.url', ':tag')
)
)
->andWhere('a.accessUrl = :urlId')
->setParameter('urlId', $this->accessUrlHelper->getCurrent()->getId())
->setParameter('tag', '%'.$tag.'%')
;

@ -8,7 +8,6 @@ namespace Chamilo\CoreBundle\ServiceHelper;
use Chamilo\CoreBundle\Entity\AccessUrl;
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
@ -16,15 +15,9 @@ class AccessUrlHelper
{
public function __construct(
private readonly AccessUrlRepository $accessUrlRepository,
private readonly ParameterBagInterface $parameterBag,
private readonly RouterInterface $router,
) {}
public function isMultipleEnabled(): bool
{
return 1 === (int) $this->parameterBag->get('multiple_access_url');
}
public function getFirstAccessUrl(): AccessUrl
{
$urlId = $this->accessUrlRepository->getFirstId();
@ -40,13 +33,13 @@ class AccessUrlHelper
return $accessUrl;
}
$accessUrl = $this->getFirstAccessUrl();
if ($this->isMultipleEnabled()) {
$url = $this->router->generate('index', [], UrlGeneratorInterface::ABSOLUTE_URL);
/** @var AccessUrl $accessUrl */
$accessUrl = $this->accessUrlRepository->findOneBy(['url' => $url]);
if (!$accessUrl) {
$accessUrl = $this->getFirstAccessUrl();
}
return $accessUrl;

@ -96,13 +96,11 @@ if ($debug) {
echo count($dbUsers) . " users with id > 1 found in internal database\n";
}
if (api_is_multiple_url_enabled()) {
$accessUrls = api_get_access_urls(0,100000,'id');
$multipleUrlLDAPConfig = true;
if (!empty($extldap_config) && array_key_exists('host', $extldap_config) && !empty($extldap_config['host'])) {
$multipleUrlLDAPConfig = false;
}
}
if (!$multipleUrlLDAPConfig) {
$accessUrls[0]['id'] = 0;
@ -339,9 +337,6 @@ foreach ($accessUrls as $accessUrl) {
}
if ($multipleUrlLDAPConfig) {
UrlManager::add_user_to_url($user->getId(), $accessUrlId);
} elseif (!api_is_multiple_url_enabled()) {
//we are adding by default the access_url_user table with access_url_id = 1
UrlManager::add_user_to_url($user->getId(), 1);
}
}
}

Loading…
Cancel
Save