Merge branch '1.10.x' of https://github.com/chamilo/chamilo-lms into BT9413

Conflicts:
	main/inc/lib/extra_field.lib.php
1.10.x
Angel Fernando Quiroz Campos 10 years ago
commit 119832686c
  1. 100
      main/admin/add_users_to_session.php
  2. 4
      main/inc/lib/api.lib.php
  3. 64
      main/inc/lib/extra_field.lib.php
  4. 12
      main/inc/lib/extra_field_value.lib.php
  5. 108
      main/inc/lib/sessionmanager.lib.php
  6. 8
      main/inc/lib/usermanager.lib.php
  7. 4
      plugin/advanced_subscription/src/AdvancedSubscriptionPlugin.php
  8. 1
      src/Chamilo/CoreBundle/Entity/ExtraField.php

@ -109,14 +109,14 @@ function search_users($needle, $type)
}
}
if (count($user_ids) > 0) {
$cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
$cond_user_id = ' AND user.id NOT IN('.implode(",",$user_ids).')';
}
}
switch ($type) {
case 'single':
// search users where username or firstname or lastname begins likes $needle
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code
$sql = 'SELECT user.id, username, lastname, firstname, official_code
FROM '.$tbl_user.' user
WHERE
(
@ -130,7 +130,7 @@ function search_users($needle, $type)
LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code
$sql = 'SELECT user.id, username, lastname, firstname, official_code
FROM '.$tbl_user.' user
WHERE
'.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND
@ -139,9 +139,9 @@ function search_users($needle, $type)
$order_clause;
break;
case 'any_session':
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code
$sql = 'SELECT DISTINCT user.id, username, lastname, firstname, official_code
FROM '.$tbl_user.' user
LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.user_id = user.user_id)
LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.user_id = user.id)
WHERE
s.user_id IS NULL AND
user.status<>'.DRH.' AND
@ -156,10 +156,10 @@ function search_users($needle, $type)
if ($access_url_id != -1) {
switch ($type) {
case 'single':
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code
$sql = 'SELECT user.id, username, lastname, firstname, official_code
FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user
ON (url_user.user_id = user.user_id)
ON (url_user.user_id = user.id)
WHERE
access_url_id = '.$access_url_id.' AND
(
@ -172,9 +172,9 @@ function search_users($needle, $type)
' LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname, official_code
$sql = 'SELECT user.id, username, lastname, firstname, official_code
FROM '.$tbl_user.' user
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.id)
WHERE
access_url_id = '.$access_url_id.' AND
'.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND
@ -183,17 +183,17 @@ function search_users($needle, $type)
$order_clause;
break;
case 'any_session' :
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code
$sql = 'SELECT DISTINCT user.id, username, lastname, firstname, official_code
FROM '.$tbl_user.' user
LEFT OUTER JOIN '.$tbl_session_rel_user.' s
ON (s.user_id = user.user_id)
ON (s.user_id = user.id)
INNER JOIN '.$tbl_user_rel_access_url.' url_user
ON (url_user.user_id=user.user_id)
ON (url_user.user_id = user.id)
WHERE
access_url_id = '.$access_url_id.' AND
s.user_id IS null AND
user.status<>'.DRH.' AND
user.status<>6 '.$cond_user_id.
user.status <> '.DRH.' AND
user.status <> 6 '.$cond_user_id.
$order_clause;
break;
}
@ -212,7 +212,7 @@ function search_users($needle, $type)
$person_name = $officialCode.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
}
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' '.'\')">'.$person_name.' </a><br />';
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['id'].'\',\''.$person_name.' '.'\')">'.$person_name.' </a><br />';
} else {
$return .= '...<br />';
}
@ -228,7 +228,7 @@ function search_users($needle, $type)
$officialCode = !empty($user['official_code']) ? $user['official_code'].' - ' : '? - ';
$person_name = $officialCode.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
}
$return .= '<option value="'.$user['user_id'].'">'.$person_name.' </option>';
$return .= '<option value="'.$user['id'].'">'.$person_name.' </option>';
}
$return .= '</select>';
$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
@ -330,10 +330,10 @@ if (isset($_configuration['order_user_list_by_official_code']) &&
}
if ($ajax_search) {
$sql = "SELECT u.user_id, lastname, firstname, username, session_id, official_code
$sql = "SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.user_id AND
ON $tbl_session_rel_user.user_id = u.id AND
$tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
AND $tbl_session_rel_user.session_id = ".intval($id_session)."
WHERE u.status<>".DRH." AND u.status<>6
@ -343,13 +343,13 @@ if ($ajax_search) {
$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 ($access_url_id != -1) {
$sql="SELECT u.user_id, lastname, firstname, username, session_id, official_code
$sql="SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.user_id AND
ON $tbl_session_rel_user.user_id = u.id AND
$tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
AND $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)
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.id)
WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
@ -357,7 +357,7 @@ if ($ajax_search) {
$result = Database::query($sql);
$users = Database::store_result($result);
foreach ($users as $user) {
$sessionUsersList[$user['user_id']] = $user ;
$sessionUsersList[$user['id']] = $user ;
}
$sessionUserInfo = SessionManager::getTotalUserCoursesInSession($id_session);
@ -369,12 +369,12 @@ if ($ajax_search) {
continue;
}
if (!array_key_exists($sessionUser['user_id'], $sessionUsersList)) {
if (!array_key_exists($sessionUser['id'], $sessionUsersList)) {
continue;
}
/*if ($sessionUser['count'] != $countSessionCoursesList) {
unset($sessionUsersList[$sessionUser['user_id']]);
unset($sessionUsersList[$sessionUser['id']]);
}*/
}
@ -411,17 +411,17 @@ if ($ajax_search) {
if (api_is_multiple_url_enabled()) {
if (is_array($final_result) && count($final_result)>0) {
$where_filter = " AND u.user_id IN ('".implode("','",$final_result)."') ";
$where_filter = " AND u.id IN ('".implode("','",$final_result)."') ";
} else {
//no results
$where_filter = " AND u.user_id = -1";
$where_filter = " AND u.id = -1";
}
} else {
if (is_array($final_result) && count($final_result)>0) {
$where_filter = " WHERE u.user_id IN ('".implode("','", $final_result)."') ";
$where_filter = " WHERE u.id IN ('".implode("','", $final_result)."') ";
} else {
//no results
$where_filter = " WHERE u.user_id = -1";
$where_filter = " WHERE u.id = -1";
}
}
}
@ -429,20 +429,20 @@ if ($ajax_search) {
$order_clause = " AND u.creator_id = " . api_get_user_id() . $order_clause;
}
if ($use_extra_fields) {
$sql = "SELECT user_id, lastname, firstname, username, session_id, official_code
$sql = "SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.user_id AND
$tbl_session_rel_user.session_id = '$id_session' 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_RELATION_TYPE_RRHH."
$where_filter AND u.status<>".DRH." AND u.status<>6
$order_clause";
} else {
$sql = "SELECT user_id, lastname, firstname, username, session_id, official_code
$sql = "SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.user_id AND
$tbl_session_rel_user.session_id = '$id_session' 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_RELATION_TYPE_RRHH."
WHERE u.status<>".DRH." AND u.status<>6
$order_clause";
@ -451,14 +451,14 @@ if ($ajax_search) {
$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 ($access_url_id != -1) {
$sql = "SELECT u.user_id, lastname, firstname, username, session_id, official_code
$sql = "SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.user_id AND
$tbl_session_rel_user.session_id = '$id_session' 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_RELATION_TYPE_RRHH."
INNER JOIN $tbl_user_rel_access_url url_user
ON (url_user.user_id = u.user_id)
ON (url_user.user_id = u.id)
WHERE access_url_id = $access_url_id $where_filter AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
@ -468,7 +468,7 @@ if ($ajax_search) {
$users = Database::store_result($result,'ASSOC');
foreach ($users as $uid => $user) {
if ($user['id_session'] != $id_session) {
$nosessionUsersList[$user['user_id']] = array(
$nosessionUsersList[$user['id']] = array(
'fn' => $user['firstname'],
'ln' => $user['lastname'],
'un' => $user['username'],
@ -480,11 +480,11 @@ if ($ajax_search) {
unset($users); //clean to free memory
//filling the correct users in list
$sql="SELECT user_id, lastname, firstname, username, session_id, official_code
$sql="SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.user_id AND
$tbl_session_rel_user.session_id = '$id_session' 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_RELATION_TYPE_RRHH."
WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
@ -492,13 +492,13 @@ if ($ajax_search) {
$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 ($access_url_id != -1) {
$sql = "SELECT u.user_id, lastname, firstname, username, session_id, official_code
$sql = "SELECT u.id, lastname, firstname, username, session_id, official_code
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.user_id = u.user_id AND
$tbl_session_rel_user.session_id = '$id_session' 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_RELATION_TYPE_RRHH."
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id = u.id)
WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
@ -508,9 +508,9 @@ if ($ajax_search) {
$users = Database::store_result($result,'ASSOC');
foreach ($users as $uid => $user) {
if ($user['id_session'] == $id_session) {
$sessionUsersList[$user['user_id']] = $user;
if (array_key_exists($user['user_id'],$nosessionUsersList)) {
unset($nosessionUsersList[$user['user_id']]);
$sessionUsersList[$user['id']] = $user;
if (array_key_exists($user['id'],$nosessionUsersList)) {
unset($nosessionUsersList[$user['id']]);
}
}
unset($users[$uid]);
@ -672,7 +672,7 @@ if (!empty($errorMsg)) {
<?php
foreach ($sessionUsersList as $enreg) {
?>
<option value="<?php echo $enreg['user_id']; ?>">
<option value="<?php echo $enreg['id']; ?>">
<?php
$personName = api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].') '.$enreg['official_code'];
if ($showOfficialCode) {

@ -282,6 +282,7 @@ define('WEB_COURSE_PATH', 'WEB_COURSE_PATH');
define('SYS_COURSE_PATH', 'SYS_COURSE_PATH');
define('REL_COURSE_PATH', 'REL_COURSE_PATH');
define('REL_CODE_PATH', 'REL_CODE_PATH');
define('REL_UPLOAD_PATH', 'REL_UPLOAD_PATH');
define('WEB_CODE_PATH', 'WEB_CODE_PATH');
define('SYS_CODE_PATH', 'SYS_CODE_PATH');
define('SYS_LANG_PATH', 'SYS_LANG_PATH');
@ -572,6 +573,7 @@ require_once __DIR__.'/internationalization.lib.php';
* api_get_path(REL_PATH) /chamilo/
* api_get_path(REL_COURSE_PATH) /chamilo/courses/
* api_get_path(REL_CODE_PATH) /chamilo/main/
* api_get_path(REL_UPLOAD_PATH) /chamilo/app/upload/
* api_get_path(SYS_SERVER_ROOT_PATH) /var/www/ - This is the physical folder where the system Chamilo has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT'].
* api_get_path(SYS_PATH) /var/www/chamilo/
* api_get_path(SYS_APP_PATH) /var/www/chamilo/app/
@ -642,6 +644,7 @@ function api_get_path($path_type, $path = null)
WEB_ARCHIVE_PATH => 'app/cache/',
SYS_APP_PATH => 'app/',
SYS_UPLOAD_PATH => 'app/upload/',
REL_UPLOAD_PATH => 'app/upload/',
INCLUDE_PATH => 'inc/',
LIBRARY_PATH => 'inc/lib/',
CONFIGURATION_PATH => 'app/config/',
@ -753,6 +756,7 @@ function api_get_path($path_type, $path = null)
$paths[REL_CODE_PATH] = $root_rel.$code_folder;
$paths[WEB_CODE_PATH] = $root_web.$code_folder;
$paths[SYS_CODE_PATH] = $root_sys.$code_folder;
$paths[REL_UPLOAD_PATH] = $root_rel.$paths[SYS_UPLOAD_PATH];
$paths[WEB_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[WEB_CODE_PATH].'default_course_document/';
$paths[REL_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[REL_PATH].'main/default_course_document/';

@ -95,6 +95,9 @@ class ExtraField extends Model
case 'lp':
$this->extraFieldType = EntityExtraField::LP_FIELD_TYPE;
break;
case 'lp_item':
$this->extraFieldType = EntityExtraField::LP_ITEM_FIELD_TYPE;
break;
}
$this->pageUrl = 'extra_fields.php?type='.$this->type;
@ -121,7 +124,8 @@ class ExtraField extends Model
'session',
'question',
'lp',
'calendar_event'
'calendar_event',
'lp_item'
);
}
@ -2049,44 +2053,34 @@ EOF;
}
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
if ($valueData === false || empty($valueData['value'])) {
break;
}
$cleanImagePath = str_replace(api_get_path(SYS_PATH), '', $valueData['value']);
$webImagePath = api_get_path(WEB_PATH) . $cleanImagePath;
if (file_exists(api_get_path(SYS_PATH) . $cleanImagePath)) {
$image = Display::img(
$webImagePath,
$field['display_text'],
['width' => '300']
);
if ($valueData !== false && !empty($valueData['value'])) {
if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) {
$image = Display::img(
api_get_path(WEB_UPLOAD_PATH) . $valueData['value'],
$field['display_text'],
array('width' => '300')
);
$displayedValue = Display::url(
$image,
$webImagePath,
['target' => '_blank']
);
$displayedValue = Display::url(
$image,
api_get_path(WEB_UPLOAD_PATH) . $valueData['value'],
array('target' => '_blank')
);
}
}
break;
case ExtraField::FIELD_TYPE_FILE:
if ($valueData === false || empty($valueData['value'])) {
break;
}
$cleanFilePath = str_replace(api_get_path(SYS_PATH), '', $valueData['value']);
$webFilePath = api_get_path(WEB_PATH) . $cleanFilePath;
if (file_exists(api_get_path(SYS_PATH) . $cleanFilePath)) {
$displayedValue = Display::url(
get_lang('Download'),
$webFilePath,
array(
'title' => $field['display_text'],
'target' => '_blank'
)
);
if ($valueData !== false && !empty($valueData['value'])) {
if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) {
$displayedValue = Display::url(
get_lang('Download'),
api_get_path(WEB_UPLOAD_PATH) . $valueData['value'],
array(
'title' => $field['display_text'],
'target' => '_blank'
)
);
}
}
break;
default:

@ -165,12 +165,15 @@ class ExtraFieldValue extends Model
switch ($this->type) {
case 'course':
$fileDir = api_get_path(SYS_UPLOAD_PATH)."courses/";
$fileDirStored = "courses/";
break;
case 'session':
$fileDir = api_get_path(SYS_UPLOAD_PATH)."sessions/";
$fileDirStored = "sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($params['item_id'], 'system');
$fileDirStored = UserManager::getUserPathById($params['item_id'], 'last');
break;
}
@ -183,11 +186,10 @@ class ExtraFieldValue extends Model
if ($value['error'] == 0) {
$imageExtraField = new Image($value['tmp_name']);
$imageExtraField->send_image($fileDir . $fileName, -1, 'png');
$newParams = array(
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $fileDir . $fileName,
'value' => $fileDirStored . $fileName,
'comment' => $comment
);
@ -200,18 +202,20 @@ class ExtraFieldValue extends Model
switch ($this->type) {
case 'course':
$fileDir = api_get_path(SYS_UPLOAD_PATH)."courses/";
$fileDirStored = "courses/";
break;
case 'session':
$fileDir = api_get_path(SYS_UPLOAD_PATH)."sessions/";
$fileDirStored = "sessions/";
break;
case 'user':
$fileDir = UserManager::getUserPathById($params['item_id'], 'system');
$fileDirStored = UserManager::getUserPathById($params['item_id'], 'last');
break;
}
$cleanedName = api_replace_dangerous_char($value['name']);
$fileName = ExtraField::FIELD_TYPE_FILE . "_{$params['item_id']}_$cleanedName";
if (!file_exists($fileDir)) {
mkdir($fileDir, $dirPermissions, true);
}
@ -222,7 +226,7 @@ class ExtraFieldValue extends Model
$new_params = array(
'item_id' => $params['item_id'],
'field_id' => $extraFieldInfo['id'],
'value' => $fileDir . $fileName
'value' => $fileDirStored . $fileName
);
if ($this->type !== 'session' && $this->type !== 'course') {

@ -1521,7 +1521,7 @@ class SessionManager
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$id_promotion = intval($id_promotion);
$sql = "UPDATE $tbl_session SET promotion_id=0
WHERE promotion_id='$id_promotion'";
WHERE promotion_id = $id_promotion";
if (Database::query($sql)) {
return true;
} else {
@ -1579,7 +1579,7 @@ class SessionManager
}
$sql = "SELECT user_id FROM $tbl_session_rel_course_rel_user
WHERE session_id = '$id_session' AND status = 0";
WHERE session_id = $id_session AND status = 0";
$result = Database::query($sql);
$existingUsers = array();
while ($row = Database::fetch_array($result)) {
@ -1587,7 +1587,7 @@ class SessionManager
}
$sql = "SELECT c_id FROM $tbl_session_rel_course
WHERE session_id = '$id_session'";
WHERE session_id = $id_session";
$result = Database::query($sql);
$course_list = array();
while ($row = Database::fetch_array($result)) {
@ -1627,8 +1627,8 @@ class SessionManager
$sql = "SELECT DISTINCT user_id
FROM $tbl_session_rel_course_rel_user
WHERE
session_id = '$id_session' AND
c_id = '$courseId' AND
session_id = $id_session AND
c_id = $courseId AND
status = 0
";
$result = Database::query($sql);
@ -1643,9 +1643,9 @@ class SessionManager
if (!in_array($existing_user, $user_list)) {
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE
session_id =' $id_session' AND
c_id = '$courseId' AND
user_id = '$existing_user' AND
session_id = $id_session AND
c_id = $courseId AND
user_id = $existing_user AND
status = 0 ";
$result = Database::query($sql);
if (Database::affected_rows($result)) {
@ -1661,7 +1661,7 @@ class SessionManager
if (!in_array($enreg_user, $existingUsers)) {
$enreg_user = Database::escape_string($enreg_user);
$sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (session_id, c_id, user_id, visibility, status)
VALUES('$id_session', '$courseId', '$enreg_user', '$session_visibility', '0')";
VALUES($id_session, $courseId, $enreg_user, $session_visibility, 0)";
$result = Database::query($sql);
if (Database::affected_rows($result)) {
$nbr_users++;
@ -1672,12 +1672,12 @@ class SessionManager
// Count users in this session-course relation
$sql = "SELECT COUNT(user_id) as nbUsers
FROM $tbl_session_rel_course_rel_user
WHERE session_id = '$id_session' AND c_id = '$courseId' AND status<>2";
WHERE session_id = $id_session AND c_id = $courseId AND status<>2";
$rs = Database::query($sql);
list($nbr_users) = Database::fetch_array($rs);
// update the session-course relation to add the users total
$sql = "UPDATE $tbl_session_rel_course SET nbr_users = $nbr_users
WHERE session_id ='$id_session' AND c_id = '$courseId'";
WHERE session_id = $id_session AND c_id = $courseId";
Database::query($sql);
}
@ -1695,7 +1695,7 @@ class SessionManager
$enreg_user = Database::escape_string($enreg_user);
$nbr_users++;
$sql = "INSERT IGNORE INTO $tbl_session_rel_user (relation_type, session_id, user_id)
VALUES (0, '$id_session', '$enreg_user')";
VALUES (0, $id_session, $enreg_user)";
Database::query($sql);
}
@ -1704,11 +1704,11 @@ class SessionManager
if ($empty_users) {
// update number of users in the session
$sql = "UPDATE $tbl_session SET nbr_users= $nbr_users
WHERE id='$id_session' ";
WHERE id = $id_session ";
Database::query($sql);
} else {
$sql = "UPDATE $tbl_session SET nbr_users = nbr_users + $nbr_users
WHERE id='$id_session'";
WHERE id = $id_session";
Database::query($sql);
}
}
@ -1745,8 +1745,8 @@ class SessionManager
$sql = "SELECT DISTINCT user_id
FROM $table
WHERE
session_id = '$sessionId' AND
c_id = '$courseId'
session_id = $sessionId AND
c_id = $courseId
$statusCondition
";
$result = Database::query($sql);
@ -1795,9 +1795,9 @@ class SessionManager
$userId = intval($userId);
$sql = "DELETE FROM $table
WHERE
session_id='$sessionId' AND
c_id = '$courseId' AND
user_id = '$userId'
session_id = $sessionId AND
c_id = $courseId AND
user_id = $userId
$statusCondition
";
Database::query($sql);
@ -1808,9 +1808,9 @@ class SessionManager
$sql = "SELECT COUNT(user_id) as nbUsers
FROM $table
WHERE
session_id ='$sessionId' AND
c_id = '$courseId' AND
status <>2";
session_id = $sessionId AND
c_id = $courseId AND
status <> 2";
$result = Database::query($sql);
list($userCount) = Database::fetch_array($result);
@ -1818,8 +1818,8 @@ class SessionManager
$sql = "UPDATE $tableSessionCourse
SET nbr_users = $userCount
WHERE
session_id ='$sessionId' AND
c_id = '$courseId'";
session_id = $sessionId AND
c_id = $courseId";
Database::query($sql);
}
}
@ -1886,7 +1886,7 @@ class SessionManager
FROM $tbl_session_rel_course_rel_user
WHERE
session_id = $session_id AND
c_id = '$courseId' and
c_id = $courseId and
user_id = $enreg_user ";
$result = Database::query($sql);
$count = 0;
@ -1898,7 +1898,7 @@ class SessionManager
if ($count == 0) {
$sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user (session_id, c_id, user_id, visibility)
VALUES ('$session_id', '$courseId', '$enreg_user', '$session_visibility')";
VALUES ($session_id, $courseId, $enreg_user, $session_visibility)";
$result = Database::query($sql);
if (Database::affected_rows($result)) {
$nbr_users++;
@ -1920,11 +1920,11 @@ class SessionManager
if (empty($count)) {
// If user is not registered to a session then add it.
$sql = "INSERT IGNORE INTO $tbl_session_rel_user (session_id, user_id)
VALUES ('$session_id', '$enreg_user')";
VALUES ($session_id, $enreg_user)";
Database::query($sql);
$sql = "UPDATE $tbl_session SET nbr_users = nbr_users + 1
WHERE id = '$session_id' ";
WHERE id = $session_id ";
Database::query($sql);
}
}
@ -1932,13 +1932,13 @@ class SessionManager
// count users in this session-course relation
$sql = "SELECT COUNT(user_id) as nbUsers
FROM $tbl_session_rel_course_rel_user
WHERE session_id ='$session_id' AND c_id='$courseId' AND status<>2";
WHERE session_id = $session_id AND c_id = $courseId AND status <> 2";
$rs = Database::query($sql);
list($nbr_users) = Database::fetch_array($rs);
// update the session-course relation to add the users total
$sql = "UPDATE $tbl_session_rel_course
SET nbr_users=$nbr_users
WHERE session_id='$session_id' AND c_id = '$courseId'";
SET nbr_users = $nbr_users
WHERE session_id = $session_id AND c_id = $courseId";
Database::query($sql);
}
@ -1961,8 +1961,8 @@ class SessionManager
$delete_sql = "DELETE FROM $tbl_session_rel_user
WHERE
session_id = '$session_id' AND
user_id ='$user_id' AND
session_id = $session_id AND
user_id = $user_id AND
relation_type <> " . SESSION_RELATION_TYPE_RRHH . "";
$result = Database::query($delete_sql);
$return = Database::affected_rows($result);
@ -1970,7 +1970,7 @@ class SessionManager
// Update number of users
$sql = "UPDATE $tbl_session
SET nbr_users = nbr_users - $return
WHERE id='$session_id' ";
WHERE id = $session_id ";
Database::query($sql);
// Get the list of courses related to this session
@ -1981,12 +1981,12 @@ class SessionManager
$courseId = $course['id'];
// Delete user from course
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE session_id ='$session_id' AND c_id = '$courseId' AND user_id = '$user_id'";
WHERE session_id = $session_id AND c_id = $courseId AND user_id = $user_id";
$result = Database::query($sql);
if (Database::affected_rows($result)) {
// Update number of users in this relation
$sql = "UPDATE $tbl_session_rel_course SET nbr_users = nbr_users - 1
WHERE session_id ='$session_id' AND c_id = '$courseId'";
WHERE session_id = $session_id AND c_id = $courseId";
Database::query($sql);
}
}
@ -2045,11 +2045,11 @@ class SessionManager
$courseInfo = api_get_course_info_by_id($existingCourse['c_id']);
$sql = "DELETE FROM $tbl_session_rel_course
WHERE c_id = '" . $existingCourse['c_id'] . "' AND session_id = $sessionId";
WHERE c_id = " . $existingCourse['c_id'] . " AND session_id = $sessionId";
Database::query($sql);
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE c_id = '" . $existingCourse['c_id'] . "' AND session_id = $sessionId";
WHERE c_id = " . $existingCourse['c_id'] . " AND session_id = $sessionId";
Database::query($sql);
CourseManager::remove_course_ranking(
@ -2134,17 +2134,17 @@ class SessionManager
// Unsubscribe course
$sql = "DELETE FROM $tbl_session_rel_course
WHERE c_id = '$course_id' AND session_id='$session_id'";
WHERE c_id = $course_id AND session_id = $session_id";
$result = Database::query($sql);
$nb_affected = Database::affected_rows($result);
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE c_id = '$course_id' AND session_id='$session_id'";
WHERE c_id = $course_id AND session_id = $session_id";
Database::query($sql);
if ($nb_affected > 0) {
// Update number of courses in the session
$sql = "UPDATE $tbl_session SET nbr_courses= nbr_courses - $nb_affected WHERE id='$session_id' ";
$sql = "UPDATE $tbl_session SET nbr_courses= nbr_courses - $nb_affected WHERE id = $session_id";
Database::query($sql);
return true;
} else {
@ -2202,7 +2202,7 @@ class SessionManager
$sql = "SELECT c_id FROM $tbl_session_course
WHERE
session_id = " . intval($session_id) . " AND
c_id = '" . intval($courseId) . "'";
c_id = " . intval($courseId) . "";
$result = Database::query($sql);
$num = Database::num_rows($result);
if ($num > 0) {
@ -2339,10 +2339,10 @@ class SessionManager
}
if ($date_end <> null) {
$sql = "UPDATE $tbl_session_category SET name = '" . Database::escape_string($name) . "', date_start = '$date_start' " .
", date_end = '$date_end' WHERE id= '" . $id . "' ";
", date_end = '$date_end' WHERE id= $id";
} else {
$sql = "UPDATE $tbl_session_category SET name = '" . Database::escape_string($name) . "', date_start = '$date_start' " .
", date_end = NULL WHERE id= '" . $id . "' ";
", date_end = NULL WHERE id= $id";
}
$result = Database::query($sql);
return ($result ? true : false);
@ -2516,7 +2516,7 @@ class SessionManager
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$id = api_get_current_access_url_id();
$sql = 'SELECT * FROM ' . $tbl_session_category . '
WHERE access_url_id ="' . $id . '"
WHERE access_url_id = ' . $id . '
ORDER BY name ASC';
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
@ -2563,7 +2563,7 @@ class SessionManager
// check if user is a teacher
$sql = "SELECT * FROM $tbl_user
WHERE status='1' AND user_id = '$user_id'";
WHERE status = 1 AND user_id = $user_id";
$rs_check_user = Database::query($sql);
@ -2573,8 +2573,8 @@ class SessionManager
// subscribed to the session in any manner)
$sql = "SELECT user_id FROM $tbl_session_rel_user
WHERE
session_id = '$session_id' AND
user_id = '$user_id' ";
session_id = $session_id AND
user_id = $user_id";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
@ -2584,9 +2584,9 @@ class SessionManager
$sql = "UPDATE $tbl_session_rel_course_rel_user
SET status = 0
WHERE
session_id = '$session_id' AND
c_id = '$courseId' AND
user_id = '$user_id' ";
session_id = $session_id AND
c_id = $courseId AND
user_id = $user_id ";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0)
return true;
@ -5541,11 +5541,11 @@ class SessionManager
{
$tableUser = Database::get_main_table(TABLE_MAIN_USER);
$tableSessionRelCourseRelUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sql = "SELECT COUNT(1) as count, u.user_id, scu.status status_in_session, u.status user_status
$sql = "SELECT COUNT(1) as count, u.id, scu.status status_in_session, u.status user_status
FROM $tableSessionRelCourseRelUser scu
INNER JOIN $tableUser u ON scu.user_id = u.user_id
INNER JOIN $tableUser u ON scu.user_id = u.id
WHERE scu.session_id = " . intval($sessionId) ."
GROUP BY u.user_id";
GROUP BY u.id";
$result = Database::query($sql);

@ -1383,7 +1383,7 @@ class UserManager
* Get user path from user ID (returns an array).
* The return format is a complete path to a folder ending with "/"
* @param integer $id User ID
* @param string $type Type of path to return (can be 'system', 'web')
* @param string $type Type of path to return (can be 'system', 'web', 'rel', 'last')
* @return string User folder path (i.e. /var/www/chamilo/app/upload/users/1/1/)
*/
public static function getUserPathById($id, $type)
@ -1404,6 +1404,12 @@ class UserManager
case 'web': // Base: absolute web path.
$userPath = api_get_path(WEB_UPLOAD_PATH).$userPath;
break;
case 'rel': // Relative to the document root (e.g. app/upload/users/1/13/)
$userPath = api_get_path(REL_UPLOAD_PATH).$userPath;
break;
case 'last': // Only the last part starting with users/
$userPath = $userPath;
break;
}
return $userPath;

@ -960,10 +960,10 @@ class AdvancedSubscriptionPlugin extends Plugin implements HookPluginInterface
$sessionArray['description'] = SessionManager::getDescriptionFromSessionId($sessionId);
if (isset($sessionArray['brochure'])) {
$sessionArray['brochure'] = api_get_path(WEB_CODE_PATH) . $sessionArray['brochure'];
$sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['brochure'];
}
if (isset($sessionArray['banner'])) {
$sessionArray['banner'] = api_get_path(WEB_CODE_PATH) . $sessionArray['banner'];
$sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['banner'];
}
return $sessionArray;

@ -23,6 +23,7 @@ class ExtraField extends BaseAttribute
const QUESTION_FIELD_TYPE = 4;
const CALENDAR_FIELD_TYPE = 5;
const LP_FIELD_TYPE = 6;
const LP_ITEM_FIELD_TYPE = 7;
/**
* @var integer

Loading…
Cancel
Save