Minor - update from 1.11.x

pull/4101/head
Julio Montoya 6 years ago
parent 29ef206e8c
commit 9ecb2aee2e
  1. 2
      main/admin/course_edit.php
  2. 1
      main/admin/statistics/index.php
  3. 1
      main/attendance/attendance_list.php
  4. 1
      main/badge/assign.php
  5. 3
      main/badge/issued.php
  6. 4
      main/badge/issued_all.php
  7. 1
      main/calendar/agenda_js.php
  8. 8
      main/calendar/download.php
  9. 160
      main/cron/import_csv.php
  10. 41
      main/extra/userInfoLib.php
  11. 10
      main/inc/ajax/course.ajax.php
  12. 3
      main/inc/ajax/exercise.ajax.php
  13. 28
      main/inc/ajax/message.ajax.php
  14. 4
      main/inc/ajax/user_manager.ajax.php
  15. 12
      main/inc/lib/career.lib.php
  16. 32
      main/inc/lib/display.lib.php
  17. 8
      main/inc/lib/glossary.lib.php
  18. 46
      main/inc/lib/groupmanager.lib.php
  19. 126
      main/inc/lib/usermanager.lib.php
  20. 4
      main/upload/form.scorm.php
  21. 9
      main/user/class.php

@ -508,7 +508,6 @@ function mysort(a, b) {
function valide() {
// Checking all multiple
$('select').filter(function() {
if ($(this).attr('multiple')) {
$(this).find('option').each(function() {
@ -516,7 +515,6 @@ function valide() {
});
}
});
//document.update_course.submit();
}
</script>";

@ -507,7 +507,6 @@ switch ($report) {
}
$row++;
}
$content .= $table->toHtml();
}
echo $form->returnForm();

@ -51,7 +51,6 @@ if (api_is_allowed_to_edit(null, true)) {
}
$table->set_form_actions($actions);
}
if ($table->get_total_number_of_items() > 0) {
$table->display();
}

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Skill;
use Chamilo\UserBundle\Entity\User;
use Skill as SkillManager;
/**

@ -235,6 +235,9 @@ if ($allowExport) {
if (strcmp($backpack, $configBackpack) !== 0) {
$backpack = $configBackpack;
if (substr($backpack, -1) !== '/') {
$backpack .= '/';
}
}
$htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';

@ -3,7 +3,6 @@
use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\UserBundle\Entity\User;
use SkillRelUser as SkillRelUserManager;
/**
@ -223,6 +222,9 @@ foreach ($userSkills as $index => $skillIssue) {
if (strcmp($backpack, $configBackpack) !== 0) {
$backpack = $configBackpack;
if (substr($backpack, -1) !== '/') {
$backpack .= '/';
}
}
$htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';

@ -270,6 +270,7 @@ $form->addHtmlEditor(
[
'ToolbarSet' => 'TestProposedAnswer',
'Height' => '120',
'id' => 'content',
]
);

@ -19,18 +19,14 @@ header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Cache-Control: public');
header('Pragma: no-cache');
$course_id = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : 0;
$course_id = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : api_get_course_int_id();
$user_id = api_get_user_id();
$course_info = api_get_course_info_by_id($course_id);
$doc_url = $_REQUEST['file'];
if (empty($course_id)) {
$course_id = api_get_course_int_id();
}
if (empty($course_id) || empty($doc_url)) {
api_not_allowed();
}
$doc_url = $_REQUEST['file'];
$session_id = api_get_session_id();
$is_user_is_subscribed = CourseManager::is_user_subscribed_in_course(

@ -156,6 +156,10 @@ class ImportCsv
$method = 'importCareersDiagram';
}
if ($method == 'importCareersresults') {
$method = 'importCareersResults';
}
if ($method == 'importOpensessions') {
$method = 'importOpenSessions';
}
@ -209,6 +213,7 @@ class ImportCsv
'care',
'careers',
'careersdiagram',
'careersresults',
];
foreach ($sections as $section) {
@ -1429,28 +1434,45 @@ class ImportCsv
$courseTitle = $courseInfo['title'];
// Get the value of the "careerid" extra field of this
// session
$sessionExtraFieldValue = new ExtraFieldValue('session');
$values = $sessionExtraFieldValue->get_values_by_handler_and_field_variable(
$externalCareerIdList = $sessionExtraFieldValue->get_values_by_handler_and_field_variable(
$event['session_id'],
$this->extraFieldIdNameList['session_career']
'careerid'
);
$externalCareerIdList = $externalCareerIdList['value'];
if (substr($externalCareerIdList, 0, 1) === '[') {
$externalCareerIdList = substr($externalCareerIdList, 1, -1);
$externalCareerIds = preg_split('/,/', $externalCareerIdList);
} else {
$externalCareerIds = [$externalCareerIdList];
}
$careerExtraFieldValue = new ExtraFieldValue('career');
$career = new Career();
$careerName = '';
if (!empty($values)) {
foreach ($values as $value) {
if (isset($value['value'])) {
$careerName = $value['value'];
}
}
// Concat the names of each career linked to this session
foreach ($externalCareerIds as $externalCareerId) {
// Using the external_career_id field (from above),
// find the career ID
$careerValue = $careerExtraFieldValue->get_item_id_from_field_variable_and_field_value(
'external_career_id',
$externalCareerId
);
$career = $career->find($careerValue['item_id']);
$careerName .= $career['name'].', ';
}
// Remove trailing comma
$careerName = substr($careerName, 0, -2);
$subject = sprintf(
get_lang('WelcomeToPortalXInCourseSessionX'),
api_get_setting('siteName'),
api_get_setting('Institution'),
$courseInfo['title']
);
$tpl->assign('site_name', api_get_setting('siteName'));
$tpl->assign('course_title', $courseTitle);
$tpl->assign('career_name', $careerName);
$tpl->assign('first_lesson', $date);
@ -2542,17 +2564,17 @@ class ImportCsv
$data = Import::csv_reader($file);
if (!empty($data)) {
$this->logger->addInfo(count($data)." records found.");
$this->logger->addInfo(count($data).' records found.');
$extraFieldValue = new ExtraFieldValue('career');
$extraFieldName = $this->extraFieldIdNameList['career'];
$externalEventId = null;
$extraField = new ExtraField('career');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
$extraFieldName
);
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
if (empty($extraFieldInfo)) {
$this->logger->addInfo("Extra field doesn't exists: $extraFieldName");
return false;
}
@ -2626,6 +2648,105 @@ class ImportCsv
}
}
/**
* @param $file
* @param bool $moveFile
* @param array $teacherBackup
* @param array $groupBackup
*/
private function importCareersResults(
$file,
$moveFile = false,
&$teacherBackup = [],
&$groupBackup = []
) {
$data = Import::csv_reader($file);
if (!empty($data)) {
$this->logger->addInfo(count($data).' records found.');
$extraFieldValue = new ExtraFieldValue('career');
$extraFieldName = $this->extraFieldIdNameList['career'];
foreach ($data as $row) {
if (empty($row)) {
continue;
}
foreach ($row as $key => $value) {
$key = (string) trim($key);
// Remove utf8 bom
$key = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $key);
$row[$key] = $value;
}
$studentId = $row['StudentId'];
$studentId = UserManager::get_user_id_from_original_id(
$studentId,
$this->extraFieldIdNameList['user']
);
$studentInfo = api_get_user_info($studentId);
if (empty($studentInfo)) {
$this->logger->addInfo("Student id not found: $studentId");
continue;
}
$careerId = $row['CareerId'];
$item = $extraFieldValue->get_item_id_from_field_variable_and_field_value(
$extraFieldName,
$careerId
);
$careerChamiloId = null;
if (empty($item)) {
$this->logger->addInfo("Career not found: $careerId");
continue;
} else {
if (isset($item['item_id'])) {
$careerChamiloId = $item['item_id'];
} else {
continue;
}
}
if (UserManager::userHasCareer($studentId, $careerChamiloId) === false) {
$this->logger->addInfo(
"User $studentId (".$row['StudentId'].") has no career #$careerChamiloId (ext #$careerId)"
);
continue;
}
$userCareerData = UserManager::getUserCareer($studentId, $careerChamiloId);
$extraData = isset($userCareerData['extra_data']) && !empty($userCareerData['extra_data']) ? unserialize($userCareerData['extra_data']) : [];
$teacherInfo = api_get_user_info_from_username($row['TeacherUsername']);
$teacherName = $row['TeacherUsername'];
if ($teacherInfo) {
$teacherName = $teacherInfo['complete_name'];
}
$extraData[$row['CourseId']][$row['ResultId']] = [
'Description' => $row['Description'],
'Period' => $row['Period'],
'TeacherText' => $row['TeacherText'],
'TeacherUsername' => $teacherName,
'ScoreText' => $row['ScoreText'],
'ScoreValue' => $row['ScoreValue'],
'Info' => $row['Info'],
'BgColor' => $row['BgColor'],
'Color' => $row['Color'],
'BorderColor' => $row['BorderColor'],
'Icon' => $row['Icon'],
'IconColor' => $row['IconColor'],
];
$serializedValue = serialize($extraData);
UserManager::updateUserCareer($userCareerData['id'], $serializedValue);
}
}
}
/**
* @param $file
* @param bool $moveFile
@ -2645,9 +2766,7 @@ class ImportCsv
$externalEventId = null;
$extraField = new ExtraField('career');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
$extraFieldName
);
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
$careerDiagramExtraFieldName = $this->extraFieldIdNameList['career_diagram'];
$extraFieldDiagramInfo = $extraField->get_handler_field_info_by_field_variable(
@ -2659,7 +2778,7 @@ class ImportCsv
}
if (!empty($data)) {
$this->logger->addInfo(count($data)." records found.");
$this->logger->addInfo(count($data).' records found.');
$values = [];
foreach ($data as $row) {
if (empty($row)) {
@ -2690,7 +2809,6 @@ class ImportCsv
false
);
$chamiloCareerName = '';
if (empty($item)) {
$this->logger->addInfo("Career not found: $careerId");
continue;
@ -2720,7 +2838,7 @@ class ImportCsv
$careerList[$careerId] = $graph;
}
$currentCourseId = (int) $row['CourseId'];
$currentCourseId = $row['CourseId'];
$name = $row['CourseName'];
$notes = $row['Notes'];
$groupValue = $row['Group'];
@ -2764,7 +2882,7 @@ class ImportCsv
continue;
}
$currentCourseId = (int) $row['CourseId'];
$currentCourseId = $row['CourseId'];
if ($graph->hasVertex($currentCourseId)) {
$current = $graph->getVertex($currentCourseId);
} else {

@ -459,47 +459,6 @@ function get_course_user_info($user_id)
return false;
}
/**
* get the main user information.
*
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param int $user_id user id as stored in the Dokeos main db
*
* @return array containing user info as 'lastName', 'firstName', 'email', 'role'
*/
function get_main_user_info($user_id, $courseCode)
{
$user_id = (int) $user_id;
$courseCode = Database::escape_string($courseCode);
$courseId = api_get_course_int_id($courseCode);
if (0 == $user_id) {
return false;
}
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT u.*, u.lastname lastName, u.firstname firstName,
u.email, u.picture_uri picture,
cu.status status, cu.is_tutor as tutor_id
FROM $table_user u, $table_course_user cu
WHERE u.user_id = cu.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND u.user_id = $user_id
AND cu.c_id = $courseId";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$userInfo = Database::fetch_array($result, 'ASSOC');
$userInfo['password'] = '';
return $userInfo;
}
return false;
}
/**
* get the user content of a categories plus the categories definition.
*

@ -34,7 +34,15 @@ switch ($action) {
$courseInfo = api_get_course_info_by_id($courseId);
$image = isset($_REQUEST['image']) && in_array($_REQUEST['image'], ['course_image_large_source', 'course_image_source']) ? $_REQUEST['image'] : '';
if ($courseInfo && $image) {
DocumentManager::file_send_for_download($courseInfo[$image]);
// Arbitrarily set a cache of 10' for the course image to
// avoid hammering the server with otherwise unfrequently
// changed images that can have some weight
$now = time() + 600; //time must be in GMT anyway
$headers = [
'Expires' => gmdate('D, d M Y H:i:s ', $now) . 'GMT',
'Cache-Control' => 'max-age=600',
];
DocumentManager::file_send_for_download($courseInfo[$image], null, null, null, $headers);
}
break;
case 'get_user_courses':

@ -560,8 +560,7 @@ switch ($action) {
false,
true,
false,
$objExercise->selectPropagateNeg(),
[]
$objExercise->selectPropagateNeg()
);
// Removing old score.
$total_score = $total_score - $old_result['score'];

@ -13,11 +13,31 @@ require_once __DIR__.'/../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'get_count_notifications':
if (api_get_configuration_value('notification_event')) {
$notificationManager = new NotificationEvent();
$notifications = $notificationManager->getNotificationsByUser(api_get_user_id());
echo count($notifications);
}
break;
case 'get_notifications':
if (api_get_configuration_value('notification_event')) {
$notificationManager = new NotificationEvent();
$notifications = $notificationManager->getNotificationsByUser(api_get_user_id());
echo json_encode($notifications);
}
break;
case 'mark_notification_as_read':
if (api_get_configuration_value('notification_event')) {
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
$notificationManager = new NotificationEvent();
$notificationManager->markAsRead($id);
echo 1;
}
break;
case 'get_count_message':
$userId = api_get_user_id();
$invitations = [];
$group_pending_invitations = 0;
// Setting notifications
$count_unread_message = 0;
if (api_get_setting('allow_message_tool') === 'true') {
@ -50,6 +70,8 @@ switch ($action) {
echo json_encode($invitations);
break;
case 'send_message':
api_block_anonymous_users(false);
$subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : null;
$messageContent = isset($_REQUEST['content']) ? trim($_REQUEST['content']) : null;
@ -89,6 +111,8 @@ switch ($action) {
}
break;
case 'send_invitation':
api_block_anonymous_users(false);
$subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : null;
$invitationContent = isset($_REQUEST['content']) ? trim($_REQUEST['content']) : null;

@ -171,8 +171,8 @@ switch ($action) {
if (!empty($user_id)) {
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $user_table
SET active = '".$status."'
$sql = "UPDATE $user_table
SET active = '".$status."'
WHERE user_id = '".$user_id."'";
$result = Database::query($sql);

@ -128,7 +128,7 @@ class Career extends Model
$header = get_lang('Modify');
}
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$id = isset($_GET['id']) ? (int) $_GET['id'] : '';
$form->addHeader($header);
$form->addHidden('id', $id);
$form->addElement('text', 'name', get_lang('Name'), ['size' => '70']);
@ -145,14 +145,16 @@ class Career extends Model
);
$status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list);
if ($action == 'edit') {
$extraField = new ExtraField('career');
$extraField->addElements($form, $id);
$form->addElement('text', 'created_at', get_lang('CreatedAt'));
$form->freeze('created_at');
}
if ($action == 'edit') {
$form->addButtonSave(get_lang('Modify'), 'submit');
$form->addButtonSave(get_lang('Modify'));
} else {
$form->addButtonCreate(get_lang('Add'), 'submit');
$form->addButtonCreate(get_lang('Add'));
}
// Setting the defaults

@ -1635,7 +1635,7 @@ class Display
c_id = $course_id AND
access_user_id = '$user_id' AND
access_session_id ='".$sessionId."'
ORDER BY access_date DESC
ORDER BY access_date DESC
LIMIT 1
";
$result = Database::query($sql);
@ -1656,10 +1656,10 @@ class Display
$hideTools = [TOOL_NOTEBOOK, TOOL_CHAT];
// Get current tools in course
$sql = "SELECT name, link, image
FROM $course_tool_table
WHERE
c_id = $course_id AND
$sql = "SELECT name, link, image
FROM $course_tool_table
WHERE
c_id = $course_id AND
visibility = '1' AND
name NOT IN ('".implode("','", $hideTools)."')
";
@ -1681,7 +1681,7 @@ class Display
$toolName = addslashes($toolName);
$sql = "SELECT * FROM $tool_edit_table
$sql = "SELECT * FROM $tool_edit_table
WHERE
c_id = $course_id AND
$toolCondition
@ -2831,9 +2831,9 @@ HTML;
$toolbar = '<div class="btn-group pull-right">'.$toolbar.'</div>';
}
return '<div id="user_card_'.$userInfo['id'].'" class="col-md-12">
return '<div id="user_card_'.$userInfo['id'].'" class="col-md-12">
<div class="row">
<div class="col-md-2">
<div class="col-md-2">
<img src="'.$userInfo['avatar'].'" class="img-responsive img-circle">
</div>
<div class="col-md-10">
@ -2842,7 +2842,7 @@ HTML;
<div class="col-md-2">
'.$status.'
</div>
<div class="col-md-10">
<div class="col-md-10">
'.$toolbar.'
</div>
</div>
@ -2949,7 +2949,7 @@ HTML;
$.frameReady(function() {
$(function () {
$("video:not(.skip), audio:not(.skip)").mediaelementplayer({
pluginPath: "'.$webPublicPath.'assets/mediaelement/plugins/",
pluginPath: "'.$webPublicPath.'assets/mediaelement/plugins/",
features: [\''.$videoFeatures.'\'],
success: function(mediaElement, originalNode, instance) {
'.ChamiloApi::getQuizMarkersRollsJS().'
@ -2957,28 +2957,28 @@ HTML;
vrPath: "'.$webPublicPath.'assets/vrview/build/vrview.js"
});
});
},
},
"'.$frameName.'",
[
{type:"script", src:"'.api_get_jquery_web_path().'", deps: [
{type:"script", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
{type:"script", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"},
{type:"script", src:"'.$webPublicPath.'assets/jquery-ui/jquery-ui.min.js"},
{type:"script", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelement-and-player.min.js",
{type:"script", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelement-and-player.min.js",
deps: [
{type:"script", src: "'.$webPublicPath.'assets/mediaelement/plugins/vrview/vrview.js"},
{type:"script", src: "'.$webPublicPath.'assets/mediaelement/plugins/markersrolls/markersrolls.js"},
'.$videoPluginFiles.'
]},
]},
'.$translateHtml.'
]},
'.$videoPluginCssFiles.'
{type:"script", src:"'.$webPublicPath.'assets/MathJax/MathJax.js?config=AM_HTMLorMML"},
{type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/jquery-ui.min.css"},
{type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/theme.css"},
{type:"stylesheet", src:"'.$webPublicPath.'assets/jquery-ui/themes/smoothness/theme.css"},
{type:"stylesheet", src:"'.$webPublicPath.'css/dialog.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/plugins/vrview/vrview.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/build/mediaelementplayer.min.css"},
{type:"stylesheet", src: "'.$webPublicPath.'assets/mediaelement/plugins/vrview/vrview.css"},
'.$fileCustomCssMedia.',
]);';

@ -359,7 +359,11 @@ class GlossaryManager
if ($showMessage) {
Display::addFlash(
Display::return_message(get_lang('TermDeleted').': '.$glossaryInfo['name'])
Display::return_message(
get_lang('TermDeleted').': '.Security::remove_XSS($glossaryInfo['name']),
'normal',
false
)
);
}
@ -637,7 +641,7 @@ class GlossaryManager
$return = '<a href="'.api_get_self().'?action=edit_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.
Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>';
$glossary_data = self::get_glossary_information($glossary_id);
$glossary_term = $glossary_data['name'];
$glossary_term = Security::remove_XSS(strip_tags($glossary_data['name']));
if (api_is_allowed_to_edit(null, true)) {
if ($glossary_data['session_id'] == api_get_session_id()) {
$return .= '<a href="'.api_get_self().'?action=delete_glossary&glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.

@ -15,10 +15,6 @@ use Chamilo\CourseBundle\Entity\CGroupRelUser;
*/
class GroupManager
{
/* VIRTUAL_COURSE_CATEGORY:
in this category groups are created based on the virtual course of a course*/
const VIRTUAL_COURSE_CATEGORY = 1;
/* DEFAULT_GROUP_CATEGORY:
When group categories aren't available (platform-setting),
all groups are created in this 'dummy'-category*/
@ -1966,8 +1962,8 @@ class GroupManager
return false;
}
$user_id = intval($user_id);
$group_id = intval($groupInfo['id']);
$user_id = (int) $user_id;
$group_id = (int) $groupInfo['id'];
$table = Database::get_course_table(TABLE_GROUP_TUTOR);
@ -1979,9 +1975,9 @@ class GroupManager
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
return true;
} else {
return false;
}
return false;
}
/**
@ -2002,12 +1998,16 @@ class GroupManager
public static function is_user_in_group($user_id, $groupInfo)
{
$member = self::is_subscribed($user_id, $groupInfo);
if ($member) {
return true;
}
$tutor = self::is_tutor_of_group($user_id, $groupInfo);
if ($member || $tutor) {
if ($tutor) {
return true;
} else {
return false;
}
return false;
}
/**
@ -2073,7 +2073,7 @@ class GroupManager
}
// Course admin also have access to everything
if (api_is_allowed_to_edit()) {
if (api_is_allowed_to_edit(false, true, true)) {
return true;
}
@ -2118,10 +2118,6 @@ class GroupManager
return false;
}
if (api_is_allowed_to_edit(false, true)) {
return true;
}
$status = $groupInfo[$key];
switch ($status) {
@ -2166,14 +2162,24 @@ class GroupManager
return true;
}
if (api_is_allowed_to_edit(false, true)) {
if (api_is_allowed_to_edit(false, true, true)) {
return true;
}
$groupId = $groupInfo['iid'];
$tutors = self::get_subscribed_tutors($groupInfo, true);
if (!empty($sessionId)) {
if (api_is_coach($sessionId, api_get_course_int_id())) {
return true;
}
if (in_array($userId, $tutors)) {
if (api_is_drh()) {
if (SessionManager::isUserSubscribedAsHRM($sessionId, $userId)) {
return true;
}
}
}
$groupId = $groupInfo['iid'];
if (self::is_tutor_of_group($userId, $groupInfo)) {
return true;
}

@ -3185,6 +3185,9 @@ class UserManager
$order = ' ORDER BY _isFieldNull asc, s.accessEndDate asc';
}
break;
case 'name':
$order = " ORDER BY s.name $orderSetting ";
break;
}
}
@ -3733,6 +3736,13 @@ class UserManager
if (!empty($myCourseList)) {
ksort($myCourseList);
$checkPosition = array_filter(array_column($myCourseList, 'position'));
if (empty($checkPosition)) {
// The session course list doesn't have any position,
// then order the course list by course code
$list = array_column($myCourseList, 'course_code');
array_multisort($myCourseList, SORT_ASC, $list);
}
}
return $myCourseList;
@ -4028,12 +4038,13 @@ class UserManager
/**
* Get the total count of users.
*
* @param int Status of users to be counted
* @param int Access URL ID (optional)
* @param int $status Status of users to be counted
* @param int $access_url_id Access URL ID (optional)
* @param int $active
*
* @return mixed Number of users or false on error
*/
public static function get_number_of_users($status = 0, $access_url_id = 1)
public static function get_number_of_users($status = 0, $access_url_id = 1, $active = null)
{
$t_u = Database::get_main_table(TABLE_MAIN_USER);
$t_a = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@ -4050,9 +4061,17 @@ class UserManager
FROM $t_u u
WHERE 1 = 1 ";
}
if (is_int($status) && $status > 0) {
$status = (int) $status;
$sql .= " AND u.status = $status ";
}
if ($active !== null) {
$active = (int) $active;
$sql .= " AND u.active = $active ";
}
$res = Database::query($sql);
if (Database::num_rows($res) === 1) {
return (int) Database::result($res, 0, 0);
@ -6799,6 +6818,107 @@ SQL;
return $fullName;
}
/**
* @param int $userId
*
* @return array
*/
public static function getUserCareers($userId)
{
$table = Database::get_main_table(TABLE_MAIN_USER_CAREER);
$tableCareer = Database::get_main_table(TABLE_CAREER);
$userId = (int) $userId;
$sql = "SELECT c.id, c.name
FROM $table uc
INNER JOIN $tableCareer c
ON uc.career_id = c.id
WHERE user_id = $userId
ORDER BY uc.created_at
";
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
/**
* @param int $userId
* @param int $careerId
*/
public static function addUserCareer($userId, $careerId)
{
if (!api_get_configuration_value('allow_career_users')) {
return false;
}
if (self::userHasCareer($userId, $careerId) === false) {
$params = ['user_id' => $userId, 'career_id' => $careerId, 'created_at' => api_get_utc_datetime(), 'updated_at' => api_get_utc_datetime()];
$table = Database::get_main_table(TABLE_MAIN_USER_CAREER);
Database::insert($table, $params);
}
return true;
}
/**
* @param int $userCareerId
* @param array $data
*
* @return bool
*/
public static function updateUserCareer($userCareerId, $data)
{
if (!api_get_configuration_value('allow_career_users')) {
return false;
}
$params = ['extra_data' => $data, 'updated_at' => api_get_utc_datetime()];
$table = Database::get_main_table(TABLE_MAIN_USER_CAREER);
Database::update(
$table,
$params,
['id = ?' => (int) $userCareerId]
);
return true;
}
/**
* @param int $userId
* @param int $careerId
*
* @return array
*/
public static function getUserCareer($userId, $careerId)
{
$userId = (int) $userId;
$careerId = (int) $careerId;
$table = Database::get_main_table(TABLE_MAIN_USER_CAREER);
$sql = "SELECT * FROM $table WHERE user_id = $userId AND career_id = $careerId";
$result = Database::query($sql);
return Database::fetch_array($result, 'ASSOC');
}
/**
* @param int $userId
* @param int $careerId
*
* @return bool
*/
public static function userHasCareer($userId, $careerId)
{
$userId = (int) $userId;
$careerId = (int) $careerId;
$table = Database::get_main_table(TABLE_MAIN_USER_CAREER);
$sql = "SELECT id FROM $table WHERE user_id = $userId AND career_id = $careerId";
$result = Database::query($sql);
return Database::num_rows($result) > 0;
}
/**
* @return EncoderFactory
*/

@ -84,9 +84,7 @@ if (api_get_setting('search_enabled') == 'true') {
}
}
if (api_is_platform_admin()) {
$form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
}
$form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
if (api_get_configuration_value('allow_htaccess_import_from_scorm')) {
$form->addElement('checkbox', 'allow_htaccess', null, get_lang('AllowHtaccessScormImport'));

@ -7,7 +7,7 @@
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
api_protect_course_script(true);
api_protect_course_script(true, false, 'user');
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'false') {
if (!api_is_platform_admin()) {
@ -21,12 +21,13 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
// Extra entries in breadcrumb
$interbreadcrumb[] = [
"url" => "user.php?".api_get_cidreq(),
"name" => get_lang('ToolUser'),
'url' => 'user.php?'.api_get_cidreq(),
'name' => get_lang('ToolUser'),
];
$type = isset($_GET['type']) ? Security::remove_XSS($_GET['type']) : 'registered';
$groupFilter = isset($_GET['group_filter']) ? intval($_GET['group_filter']) : 0;
$groupFilter = isset($_GET['group_filter']) ? (int) $_GET['group_filter'] : 0;
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : '';
$htmlHeadXtra[] = '
<script>

Loading…
Cancel
Save