Minor - Partial merge from 1.11.x

pull/3016/head
Julio 6 years ago
parent f41061624a
commit 0bcd181f7d
  1. 9
      main/document/document.php
  2. 15
      main/exercise/exercise.class.php
  3. 24
      main/exercise/exercise.php
  4. 19
      main/exercise/overview.php
  5. 8
      main/exercise/question.class.php
  6. 8
      main/gradebook/lib/fe/displaygradebook.php
  7. 2
      main/group/group.php
  8. 2
      main/group/group_category.php
  9. 2
      main/group/member_settings.php
  10. 2
      main/group/tutor_settings.php
  11. 2
      main/inc/ajax/lang.ajax.php
  12. 4
      main/inc/ajax/model.ajax.php
  13. 191
      main/inc/ajax/session.ajax.php
  14. 16
      main/inc/ajax/social.ajax.php
  15. 2
      main/inc/lib/add_course.lib.inc.php
  16. 40
      main/inc/lib/agenda.lib.php
  17. 4
      main/inc/lib/api.lib.php
  18. 32
      main/inc/lib/display.lib.php
  19. 170
      main/inc/lib/document.lib.php
  20. 11
      main/inc/lib/elfinder/connectorAction.php
  21. 89
      main/inc/lib/events.lib.php
  22. 44
      main/inc/lib/exercise.lib.php
  23. 179
      main/inc/lib/exercise_show_functions.lib.php
  24. 2
      main/inc/lib/extra_field.lib.php
  25. 4
      main/inc/lib/fileUpload.lib.php
  26. 2
      main/inc/lib/fixlinks.js
  27. 2
      main/inc/lib/formvalidator/Element/Color.php
  28. 23
      main/inc/lib/formvalidator/Element/DatePicker.php
  29. 23
      main/inc/lib/formvalidator/Element/DateTimePicker.php
  30. 24
      main/inc/lib/formvalidator/Element/DateTimeRangePicker.php
  31. 9
      main/inc/lib/formvalidator/FormValidator.class.php
  32. 9
      main/inc/lib/internationalization.lib.php
  33. 40
      main/inc/lib/message.lib.php
  34. 99
      main/inc/lib/myspace.lib.php
  35. 3
      main/inc/lib/nusoap/class.soap_server.php
  36. 15
      main/inc/lib/pdf.lib.php
  37. 2
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  38. 17
      main/inc/lib/pear/HTML/QuickForm/button.php
  39. 17
      main/inc/lib/pear/HTML/QuickForm/checkbox.php
  40. 50
      main/inc/lib/pear/HTML/QuickForm/element.php
  41. 21
      main/inc/lib/pear/HTML/QuickForm/file.php
  42. 17
      main/inc/lib/pear/HTML/QuickForm/group.php
  43. 2
      main/inc/lib/pear/HTML/QuickForm/radio.php
  44. 18
      main/inc/lib/pear/HTML/QuickForm/select.php
  45. 42
      main/inc/lib/pear/HTML/QuickForm/text.php
  46. 542
      main/inc/lib/sessionmanager.lib.php
  47. 36
      main/inc/lib/skill.lib.php
  48. 1682
      main/inc/lib/social.lib.php
  49. 12
      main/inc/lib/sortable_table.class.php
  50. 4
      main/inc/lib/statistics.lib.php
  51. 57
      main/inc/lib/tracking.lib.php
  52. 13
      main/inc/lib/usergroup.lib.php
  53. 234
      main/inc/lib/usermanager.lib.php
  54. 2
      main/link/link.php
  55. 66
      main/lp/aicc.class.php
  56. 3
      main/lp/aicc_api.php
  57. 6
      main/lp/aicc_hacp.php
  58. 90
      main/lp/learnpath.class.php
  59. 2
      main/lp/learnpathItem.class.php
  60. 2
      main/lp/lp_add_item.php
  61. 7
      main/lp/lp_ajax_switch_item.php
  62. 7
      main/lp/lp_controller.php
  63. 17
      main/lp/lp_edit.php
  64. 4
      main/lp/lp_edit_item.php
  65. 5
      main/lp/lp_list.php
  66. 6
      main/lp/lp_update_scorm.php
  67. 7
      main/lp/lp_view.php
  68. 2
      main/lp/lp_view_item.php
  69. 200
      main/lp/scorm.class.php
  70. 25
      main/lp/scorm_api.php
  71. 82
      main/messages/inbox.php
  72. 86
      main/messages/new_message.php
  73. 83
      main/messages/outbox.php
  74. 56
      main/messages/view_message.php
  75. 4
      main/mySpace/exercise_category_report.php
  76. 2
      main/mySpace/index.php
  77. 4
      main/mySpace/myStudents.php
  78. 5
      main/mySpace/my_career.php
  79. 10
      main/mySpace/session.php
  80. 4
      main/mySpace/slider.js
  81. 28
      main/mySpace/user_import.php
  82. 5
      main/notebook/index.php
  83. 138
      main/session/add_edit_users_to_session.php
  84. 63
      main/session/add_users_to_session_course.php
  85. 101
      main/session/resume_session.php
  86. 2
      main/session/session_add.php
  87. 16
      main/session/session_course_user_list.php
  88. 4
      main/session/session_edit.php
  89. 4
      main/session/session_import.php
  90. 12
      main/session/session_list.php

@ -222,6 +222,7 @@ switch ($action) {
case 'delete_item':
if ($isAllowedToEdit ||
$groupMemberWithUploadRights ||
DocumentManager::isBasicCourseFolder($curdirpath, $sessionId) ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $moveTo, $sessionId)
) {
@ -787,7 +788,7 @@ function confirmation (name) {
}
}
$(document).ready(function() {
$(function() {
$(".convertAction").click(function() {
var id = $(this).attr("data-documentId");
var format = $(this).attr("data-formatType");
@ -953,7 +954,7 @@ if (!empty($documentAndFolders)) {
$htmlHeadXtra[] = '
<script>
$(document).ready( function() {
$(function() {
//Experimental changes to preview mp3, ogg files'
.$jquery.'
});
@ -1799,7 +1800,6 @@ if ($isAllowedToEdit ||
);
}
}
require 'document_slideshow.inc.php';
if (!isset($_GET['keyword']) && !$is_certificate_mode) {
$actionsLeft .= Display::url(
Display::return_icon('slideshow.png', get_lang('ViewSlideshow'), '', ICON_SIZE_MEDIUM),
@ -1861,7 +1861,6 @@ if (!empty($documentAndFolders)) {
false,
$userIsSubscribed
);
$invisibility_span_open = ($is_visible == 0) ? '<span class="muted">' : '';
$invisibility_span_close = ($is_visible == 0) ? '</span>' : '';
$size = 1;
@ -2192,7 +2191,7 @@ $ajaxURL = api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=get_document_quota&'
if (count($documentAndFolders) > 1) {
echo '<script>
$(document).ready(function() {
$(function() {
$.ajax({
url:"'.$ajaxURL.'",
success:function(data){

@ -6273,19 +6273,6 @@ class Exercise
);
$isVisible = false;
}
} else {
$isLimitReached = ExerciseLib::isQuestionsLimitPerDayReached(
api_get_user_id(),
$this->selectNbrQuestions(),
api_get_course_int_id(),
api_get_session_id()
);
if ($isLimitReached) {
$maxQuestionsAnswered = (int) api_get_course_setting('quiz_question_limit_per_day');
$message = sprintf(get_lang('QuizQuestionsLimitPerDayXReached'), $maxQuestionsAnswered);
$isVisible = false;
}
}
}
@ -7824,7 +7811,7 @@ class Exercise
/**
* @param string $class
* @param string $scoreLabel
* @param array $result
* @param string $result
* @param array
*
* @return string

@ -66,7 +66,6 @@ $exercisePath = substr($exercisePath, 0, strpos($exercisePath, $exfile));
$exercisePath = $exercisePath.'exercise.php';
// Clear the exercise session
Session::erase('objExercise');
Session::erase('objQuestion');
Session::erase('objAnswer');
@ -664,7 +663,6 @@ if (!empty($exerciseList)) {
$mylpid = (empty($learnpath_id) ? '' : '&learnpath_id='.$learnpath_id);
$mylpitemid = (empty($learnpath_item_id) ? '' : '&learnpath_item_id='.$learnpath_item_id);
$i = 1;
foreach ($exerciseList as $row) {
$my_exercise_id = $row['id'];
@ -1259,7 +1257,6 @@ if (!empty($exerciseList)) {
$listExercise['description'] = cut($row['description'], 150, false);
$listExercise['score'] = $score;
$listExercise['number_questions'] = $rowi;
//$item .= Display::tag('td', $attempt_text);
}
if ($is_allowedToEdit) {
@ -1269,10 +1266,8 @@ if (!empty($exerciseList)) {
$actions .= $additionalActions.PHP_EOL;
}
$listExercise['actions'] = $actions;
//$item .= Display::tag('td', $actions, ['class' => 'td_actions']);
} else {
if ($isDrhOfCourse) {
$actions = '<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
$listExercise['actions'] = $actions;
@ -1281,25 +1276,13 @@ if (!empty($exerciseList)) {
}
}
/*$tableRows[] = Display::tag(
'tr',
$item,
[
'id' => 'exercise_list_'.$my_exercise_id,
]
);*/
$list[] = $listExercise;
}
}
}
// END EXERCISE LIST
// HOTPOTATOES
// end exercise list
// Hotpotatoes results
$hotpotatoes_exist = false;
if ($is_allowedToEdit) {
@ -1336,10 +1319,7 @@ $listHotpotatoes = [];
if (isset($attribute['path']) && is_array($attribute['path'])) {
$hotpotatoes_exist = true;
foreach ($attribute['path'] as $key => $path) {
//$item = '';
$title = GetQuizName($path, $documentPath);
if ($title == '') {
$title = basename($path);
}

@ -395,7 +395,14 @@ if ($disable && empty($exercise_stat_info)) {
$exercise_url_button = Display::return_message(get_lang('NewExerciseAttemptDisabled'));
}
if (!empty($exercise_url_button)) {
$isLimitReached = ExerciseLib::isQuestionsLimitPerDayReached(
api_get_user_id(),
count($objExercise->get_validated_question_list()),
api_get_course_int_id(),
api_get_session_id()
);
if (!empty($exercise_url_button) && !$isLimitReached) {
$html .= Display::div(
Display::div(
$exercise_url_button,
@ -405,6 +412,16 @@ if (!empty($exercise_url_button)) {
);
}
if ($isLimitReached) {
$maxQuestionsAnswered = (int) api_get_course_setting('quiz_question_limit_per_day');
$html .= Display::return_message(
sprintf(get_lang('QuizQuestionsLimitPerDayXReached'), $maxQuestionsAnswered),
'warning',
false
);
}
$html .= Display::tag(
'div',
$table_content,

@ -1152,7 +1152,10 @@ abstract class Question
$se_doc = $di->get_document((int) $se_ref['search_did']);
if ($se_doc !== false) {
if (($se_doc_data = $di->get_document_data($se_doc)) !== false) {
$se_doc_data = unserialize($se_doc_data);
$se_doc_data = UnserializeApi::unserialize(
'not_allowed_classes',
$se_doc_data
);
if (isset($se_doc_data[SE_DATA]['type']) &&
$se_doc_data[SE_DATA]['type'] == SE_DOCTYPE_EXERCISE_QUESTION
) {
@ -1268,7 +1271,8 @@ abstract class Question
// checks if the exercise ID is not in the list
if (!in_array($exerciseId, $this->exerciseList)) {
$this->exerciseList[] = $exerciseId;
$newExercise = new Exercise();
$courseId = isset($this->course['real_id']) ? $this->course['real_id'] : 0;
$newExercise = new Exercise($courseId);
$newExercise->read($exerciseId, false);
$count = $newExercise->getQuestionCount();
$count++;

@ -402,12 +402,8 @@ class DisplayGradebook
}
if ($show_add_link && !$message_resource) {
$actionsLeft .= '<a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'" >'.
Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= Display::url(
Display::return_icon('new_evaluation.png', get_lang('New evaluation for external tool'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_PUBLIC_PATH)
.'courses/'.$catobj->get_course_code().'/lti/grade/'.$catobj->get_id()
);
Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '',
ICON_SIZE_MEDIUM).'</a>';
$cats = Category::load($selectcat);
if ($cats[0]->get_course_code() != null && !$message_resource) {

@ -30,7 +30,7 @@ $sessionId = api_get_session_id();
api_protect_course_script(true);
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$(function() {
var i;
for (i=0; i<$(".actions").length; i++) {
if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {

@ -84,7 +84,7 @@ if (isset($_GET['id'])) {
}
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$(function() {
$("#max_member").on("focus", function() {
$("#max_member_selected").attr("checked", true);
});

@ -115,7 +115,7 @@ function check_group_members($value)
}
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$(function() {
$("#max_member").on("focus", function() {
$("#max_member_selected").attr("checked", true);
});

@ -99,7 +99,7 @@ function sort_users($user_a, $user_b)
}
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$(function() {
$("#max_member").on("focus", function() {
$("#max_member_selected").attr("checked", true);
});

@ -33,7 +33,7 @@ switch ($action) {
$languageInfo = api_get_language_info($languageId);
echo '
$(document).ready(function() {
$(function() {
'.$hideAll.'
var defaultLanguageFromUser = "'.$languageInfo['isocode'].'";
$("span:lang('.$languageInfo['isocode'].')").filter(

@ -673,7 +673,7 @@ switch ($action) {
case 'get_sessions':
$list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple';
if ($list_type === 'simple') {
$count = SessionManager::get_sessions_admin(
$count = SessionManager::formatSessionsAdminForGrid(
['where' => $whereCondition, 'extra' => $extra_fields],
true
);
@ -1556,7 +1556,7 @@ switch ($action) {
$columns = $session_columns['simple_column_name'];
if ($list_type == 'simple') {
$result = SessionManager::get_sessions_admin(
$result = SessionManager::formatSessionsAdminForGrid(
[
'where' => $whereCondition,
'order' => "$sidx $sord, s.name",

@ -243,6 +243,197 @@ switch ($action) {
echo json_encode($courseListToSelect);
break;
case 'get_basic_course_documents_list':
case 'get_basic_course_documents_form':
$courseId = isset($_GET['course']) ? (int) $_GET['course'] : 0;
$sessionId = isset($_GET['session']) ? (int) $_GET['session'] : 0;
$currentUserId = api_get_user_id();
$em = Database::getManager();
$course = $em->find('ChamiloCoreBundle:Course', $courseId);
$session = $em->find('ChamiloCoreBundle:Session', $sessionId);
if (!$course || !$session) {
break;
}
if (!api_is_platform_admin(true) || $session->getSessionAdminId() != $currentUserId) {
break;
}
$folderName = '/basic-course-documents__'.$session->getId().'__0';
if ('get_basic_course_documents_list' === $action) {
$courseInfo = api_get_course_info_by_id($course->getId());
$exists = DocumentManager::folderExists('/basic-course-documents', $courseInfo, $session->getId(), 0);
if (!$exists) {
$courseDir = $courseInfo['directory'].'/document';
$sysCoursePath = api_get_path(SYS_COURSE_PATH);
$baseWorkDir = $sysCoursePath.$courseDir;
$newFolderData = create_unexisting_directory(
$courseInfo,
$currentUserId,
$session->getId(),
0,
0,
$baseWorkDir,
'/basic-course-documents',
get_lang('BasicCourseDocuments'),
1
);
$id = (int) $newFolderData['iid'];
} else {
$id = DocumentManager::get_document_id($courseInfo, $folderName, $session->getId());
}
$http_www = api_get_path(WEB_COURSE_PATH).$courseInfo['directory'].'/document';
$documentAndFolders = DocumentManager::getAllDocumentData(
$courseInfo,
$folderName,
0,
0,
false,
false,
$session->getId()
);
$documentAndFolders = array_filter(
$documentAndFolders,
function (array $documentData) {
return $documentData['filetype'] != 'folder';
}
);
$documentAndFolders = array_map(
function (array $documentData) use ($course, $session, $courseInfo, $currentUserId, $http_www, $folderName, $id) {
$downloadUrl = api_get_path(WEB_CODE_PATH).'document/document.php?'
.api_get_cidreq_params($course->getCode(), $session->getId()).'&'
.http_build_query(['action' => 'download', 'id' => $documentData['id']]);
$deleteUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?'
.http_build_query(
[
'a' => 'delete_basic_course_documents',
'deleteid' => $documentData['id'],
'curdirpath' => $folderName,
'course' => $course->getId(),
'session' => $session->getId(),
]
);
$row = [];
$row[] = DocumentManager::build_document_icon_tag($documentData['filetype'], $documentData['path']);
$row[] = Display::url($documentData['title'], $downloadUrl);
$row[] = format_file_size($documentData['size']);
$row[] = date_to_str_ago($documentData['lastedit_date']).PHP_EOL
.'<div class="muted"><small>'
.api_get_local_time($documentData['lastedit_date'])
."</small></div>";
$row[] = Display::url(
Display::return_icon('save.png', get_lang('Download')),
$downloadUrl
)
.PHP_EOL
.Display::url(
Display::return_icon('delete.png', get_lang('Delete')),
$deleteUrl,
[
'class' => 'delete_document',
'data-course' => $course->getId(),
'data-session' => $session->getId(),
]
);
return $row;
},
$documentAndFolders
);
$table = new SortableTableFromArray($documentAndFolders, 1, count($documentAndFolders));
$table->set_header(0, get_lang('Type'), false, [], ['class' => 'text-center', 'width' => '60px']);
$table->set_header(1, get_lang('Name'), false);
$table->set_header(2, get_lang('Size'), false, [], ['class' => 'text-right', 'style' => 'width: 80px;']);
$table->set_header(3, get_lang('Date'), false, [], ['class' => 'text-center', 'style' => 'width: 200px;']);
$table->set_header(4, get_lang('Actions'), false, [], ['class' => 'text-center']);
$table->display();
}
if ('get_basic_course_documents_form' === $action) {
$form = new FormValidator('get_basic_course_documents_form_'.$session->getId());
$form->addMultipleUpload(
api_get_path(WEB_AJAX_PATH).'document.ajax.php?'
.api_get_cidreq_params($course->getCode(), $session->getId())
.'&a=upload_file&curdirpath='.$folderName,
''
);
$form->display();
}
break;
case 'delete_basic_course_documents':
$curdirpath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
$docId = isset($_GET['deleteid']) ? (int) $_GET['deleteid'] : 0;
$courseId = isset($_GET['course']) ? (int) $_GET['course'] : 0;
$sessionId = isset($_GET['session']) ? (int) $_GET['session'] : 0;
if (empty($curdirpath) || empty($docId) || empty($courseId) || empty($sessionId)) {
break;
}
$em = Database::getManager();
$courseInfo = api_get_course_info_by_id($courseId);
$session = $em->find('ChamiloCoreBundle:Session', $sessionId);
$currentUserId = api_get_user_id();
if (empty($courseInfo) || !$session) {
break;
}
if (!api_is_platform_admin(true) || $session->getSessionAdminId() != $currentUserId) {
break;
}
$sysCoursePath = api_get_path(SYS_COURSE_PATH);
$courseDir = $courseInfo['directory'].'/document';
$baseWorkDir = $sysCoursePath.$courseDir;
$documentInfo = DocumentManager::get_document_data_by_id(
$docId,
$courseInfo['code'],
false,
$session->getId()
);
if (empty($documentInfo)) {
break;
}
if ($documentInfo['filetype'] != 'link') {
$deletedDocument = DocumentManager::delete_document(
$courseInfo,
null,
$baseWorkDir,
$session->getId(),
$docId
);
} else {
$deletedDocument = DocumentManager::deleteCloudLink(
$courseInfo,
$docId
);
}
if (!$deletedDocument) {
break;
}
echo true;
break;
default:
echo '';
}

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Message;
use Chamilo\CoreBundle\Entity\MessageLikes;
use Chamilo\CoreBundle\Entity\MessageFeedback;
use ChamiloSession as Session;
/**
@ -275,13 +275,13 @@ switch ($action) {
$userId = isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : api_get_user_id();
$html = '';
if ($userId == api_get_user_id()) {
$threadList = SocialManager::getThreadList();
$threadList = SocialManager::getThreadList($userId);
$threadIdList = [];
if (!empty($threadList)) {
$threadIdList = array_column($threadList, 'id');
}
$html = SocialManager::getMyWallMessages($userId, $start, $length, $threadIdList);
$html = SocialManager::getMyWallMessages($userId, $start, SocialManager::DEFAULT_SCROLL_NEW_POST, $threadIdList);
$html = $html['posts'];
} else {
$messages = SocialManager::getWallMessages(
@ -291,7 +291,7 @@ switch ($action) {
0,
'',
$start,
$length
SocialManager::DEFAULT_SCROLL_NEW_POST
);
$messages = SocialManager::formatWallMessages($messages);
@ -310,7 +310,7 @@ switch ($action) {
Display::url(
get_lang('SeeMore'),
api_get_self().'?u='.$userId.'&a=list_wall_message&start='.
($start + $length + 1).'&length='.$length,
($start + SocialManager::DEFAULT_SCROLL_NEW_POST).'&length='.SocialManager::DEFAULT_SCROLL_NEW_POST,
[
'class' => 'nextPage',
]
@ -339,7 +339,7 @@ switch ($action) {
if (
api_is_anonymous() ||
!api_get_configuration_value('social_enable_likes_messages')
!api_get_configuration_value('social_enable_messages_feedback')
) {
echo json_encode(false);
exit;
@ -356,7 +356,7 @@ switch ($action) {
$em = Database::getManager();
$messageRepo = $em->getRepository('ChamiloCoreBundle:Message');
$messageLikesRepo = $em->getRepository('ChamiloCoreBundle:MessageLikes');
$messageLikesRepo = $em->getRepository('ChamiloCoreBundle:MessageFeedback');
/** @var Message $message */
$message = $messageRepo->find($messageId);
@ -393,7 +393,7 @@ switch ($action) {
$userLike = $messageLikesRepo->findOneBy(['message' => $message, 'user' => $user]);
if (empty($userLike)) {
$userLike = new MessageLikes();
$userLike = new MessageFeedback();
$userLike
->setMessage($message)
->setUser($user);

@ -433,7 +433,7 @@ class AddCourse
'id' => 2,
'title' => get_lang('DefaultGroupCategory'),
'description' => '',
'max_student' => 8,
'max_student' => 0,
'self_reg_allowed' => 0,
'self_unreg_allowed' => 0,
'groups_per_user' => 0,

@ -113,7 +113,7 @@ class Agenda
$agendaColors = array_merge(
[
'platform' => 'red', //red
'course' => '#43D29E', //green
'course' => '#458B00', //green
'group' => '#A0522D', //siena
'session' => '#00496D', // kind of green
'other_session' => '#999', // kind of green
@ -2705,10 +2705,14 @@ class Agenda
*/
public function getAttachment($attachmentId, $eventId, $courseInfo)
{
if (empty($courseInfo) || empty($attachmentId) || empty($eventId)) {
return [];
}
$tableAttachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
$courseId = intval($courseInfo['real_id']);
$eventId = intval($eventId);
$attachmentId = intval($attachmentId);
$courseId = (int) $courseInfo['real_id'];
$eventId = (int) $eventId;
$attachmentId = (int) $attachmentId;
$row = [];
$sql = "SELECT id, path, filename, comment
@ -2743,7 +2747,7 @@ class Agenda
$courseInfo
) {
$agenda_table_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT);
$eventId = intval($eventId);
$eventId = (int) $eventId;
// Storing the attachments
$upload_ok = false;
@ -2880,6 +2884,8 @@ class Agenda
public function getAllRepeatEvents($eventId)
{
$events = [];
$eventId = (int) $eventId;
switch ($this->type) {
case 'personal':
break;
@ -4057,30 +4063,6 @@ class Agenda
return $items;
}
/**
* This function retrieves one personal agenda item returns it.
*
* @param int $id The agenda item ID
*
* @return array The results of the database query, or null if not found
*/
public static function get_personal_agenda_item($id)
{
$table = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$id = intval($id);
// make sure events of the personal agenda can only be seen by the user himself
$user = api_get_user_id();
$sql = " SELECT * FROM ".$table." WHERE id=".$id." AND user = ".$user;
$result = Database::query($sql);
if (Database::num_rows($result) == 1) {
$item = Database::fetch_array($result);
} else {
$item = null;
}
return $item;
}
/**
* This function calculates the startdate of the week (monday)
* and the enddate of the week (sunday)

@ -8056,13 +8056,13 @@ function api_get_password_checker_js($usernameInputId, $passwordInputId)
];
$js = api_get_asset('pwstrength-bootstrap/dist/pwstrength-bootstrap.min.js');
$js .= "<script>
$js .= "<script>
var errorMessages = {
password_to_short : \"".get_lang('PasswordIsTooShort')."\",
same_as_username : \"".get_lang('YourPasswordCannotBeTheSameAsYourUsername')."\"
};
$(document).ready(function() {
$(function() {
var lang = ".json_encode($translations).";
var options = {
onLoad : function () {

@ -1353,9 +1353,23 @@ class Display
$obj->viewrecords = 'true';
$all_value = 10000000;
// Sets how many records we want to view in the grid
$obj->rowNum = 20;
// Default row quantity
if (!isset($extra_params['rowList'])) {
$extra_params['rowList'] = [20, 50, 100, 500, 1000, $all_value];
$rowList = api_get_configuration_value('table_row_list');
if (!empty($rowList) && isset($rowList['options'])) {
$rowList = $rowList['options'];
$rowList[] = $all_value;
}
$extra_params['rowList'] = $rowList;
}
$defaultRow = api_get_configuration_value('table_default_row');
if (!empty($defaultRow)) {
$obj->rowNum = (int) $defaultRow;
}
$json = '';
@ -1381,8 +1395,6 @@ class Display
$obj->rowList = $extra_params['rowList'];
}
// Sets how many records we want to view in the grid
$obj->rowNum = 20;
if (!empty($extra_params['rowNum'])) {
$obj->rowNum = $extra_params['rowNum'];
} else {
@ -1753,9 +1765,13 @@ class Display
} else {
$dates = SessionManager::parseSessionDates($session_info, true);
$session['dates'] = $dates['access'];
if (api_get_setting('show_session_coach') === 'true' && isset($coachInfo['complete_name'])) {
$session['coach'] = $coachInfo['complete_name'];
}
$active = $date_start <= $now && $date_end >= $now;
}
$session['active'] = $active;
$session['session_category_id'] = $session_info['session_category_id'];
$session['visibility'] = $session_info['visibility'];
$session['num_users'] = $session_info['nbr_users'];
$session['num_courses'] = $session_info['nbr_courses'];
@ -1933,15 +1949,15 @@ class Display
}
/**
* @param $percentage
* @param bool $show_percentage
* @param null $extra_info
* @param int $percentage
* @param bool $show_percentage
* @param string $extra_info
*
* @return string
*/
public static function bar_progress($percentage, $show_percentage = true, $extra_info = null)
public static function bar_progress($percentage, $show_percentage = true, $extra_info = '')
{
$percentage = intval($percentage);
$percentage = (int) $percentage;
$div = '<div class="progress">
<div
class="progress-bar progress-bar-striped"
@ -1958,7 +1974,7 @@ class Display
$div .= $extra_info;
}
}
$div .= '</div>';
$div .= '</div></div>';
return $div;
}

@ -3170,19 +3170,21 @@ class DocumentManager
*
* @return string
*/
public static function generateVideoPreview($file, $extension)
public static function generateMediaPreview($file, $extension)
{
$type = '';
/*if ($extension != 'flv') {
}*/
//$type = "video/$extension";
//$fileInfo = parse_url($file);
//$type = self::file_get_mime_type(basename($fileInfo['path']));
$html = '<video id="myvideo" controls>';
$html .= '<source src="'.$file.'" >';
$html .= '</video>';
$id = api_get_unique_id();
switch ($extension) {
case 'mp3':
$document_data['file_extension'] = $extension;
$html = '<div style="margin: 0; position: absolute; top: 50%; left: 35%;">';
$html .= '<audio id="'.$id.'" controls="controls" src="'.$file.'" type="audio/mp3" ></audio></div>';
break;
default:
$html = '<video id="'.$id.'" controls>';
$html .= '<source src="'.$file.'" >';
$html .= '</video>';
break;
}
return $html;
}
@ -3221,12 +3223,7 @@ class DocumentManager
$user_id = api_get_user_id();
$userInfo = api_get_user_info();
$user_in_course = false;
if (api_is_platform_admin()) {
$user_in_course = true;
}
$user_in_course = api_is_platform_admin();
if (!$user_in_course) {
if (CourseManager::is_course_teacher($user_id, $course_info['code'])) {
$user_in_course = true;
@ -3270,17 +3267,11 @@ class DocumentManager
// If we are in LP display hidden folder https://support.chamilo.org/issues/6679
$lp_visibility_condition = null;
if ($lp_id) {
// $lp_visibility_condition = " OR filetype='folder'";
if ($showInvisibleFiles) {
$lp_visibility_condition .= ' OR l.visibility = 0';
}
}
$showOnlyFoldersCondition = null;
if ($showOnlyFolders) {
//$showOnlyFoldersCondition = " AND docs.filetype = 'folder' ";
}
$folderCondition = " AND docs.path LIKE '/%' ";
if (!api_is_allowed_to_edit()) {
$protectedFolders = self::getProtectedFolderFromStudent();
@ -3343,25 +3334,17 @@ class DocumentManager
$resources = Database::store_result($res_doc, 'ASSOC');
$return = '';
if ($lp_id) {
if ($lp_id == false && $addCloseButton) {
if ($folderId === false) {
/*$return .= '<div class="lp_resource_element">';
$return .= Display::return_icon('new_doc.gif', '', [], ICON_SIZE_SMALL);
$return .= Display::url(
get_lang('CreateTheDocument'),
api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&lp_id='.$_SESSION['oLP']->lp_id
$return .= Display::div(
Display::url(
Display::return_icon('close.png', get_lang('Close'), [], ICON_SIZE_SMALL),
' javascript:void(0);',
['id' => 'close_div_'.$course_info['real_id'].'_'.$session_id, 'class' => 'close_div']
),
['style' => 'position:absolute;right:10px']
);
$return .= '</div>';*/
}
} else {
$return .= Display::div(
Display::url(
Display::return_icon('close.png', get_lang('Close'), [], ICON_SIZE_SMALL),
' javascript:void(0);',
['id' => 'close_div_'.$course_info['real_id'].'_'.$session_id, 'class' => 'close_div']
),
['style' => 'position:absolute;right:10px']
);
}
// If you want to debug it, I advise you to do "echo" on the eval statements.
@ -3402,7 +3385,7 @@ class DocumentManager
}
}
$write_result = self::write_resources_tree(
$writeResult = self::write_resources_tree(
$userInfo,
$course_info,
$session_id,
@ -3414,43 +3397,35 @@ class DocumentManager
$folderId
);
$return .= $write_result;
$return .= $writeResult;
$lpAjaxUrl = api_get_path(WEB_AJAX_PATH).'lp.ajax.php';
if ($lp_id === false) {
$url = api_get_path(WEB_AJAX_PATH).
'lp.ajax.php?a=get_documents&url='.$overwrite_url.'&lp_id='.$lp_id.'&cidReq='.$course_info['code'];
$url = $lpAjaxUrl.'?a=get_documents&lp_id=&cidReq='.$course_info['code'];
$return .= "<script>
$('.doc_folder').click(function() {
var realId = this.id;
var my_id = this.id.split('_')[2];
var tempId = 'temp_'+my_id;
$('#res_'+my_id).show();
var tempDiv = $('#'+realId).find('#'+tempId);
if (tempDiv.length == 0) {
$.ajax({
async: false,
type: 'GET',
url: '".$url."',
data: 'folder_id='+my_id,
success: function(data) {
$('#'+realId).append('<div id='+tempId+'>'+data+'</div>');
}
});
}
});
$('.close_div').click(function() {
var course_id = this.id.split('_')[2];
var session_id = this.id.split('_')[3];
$('#document_result_'+course_id+'_'+session_id).hide();
$('.lp_resource').remove();
$('.document_preview_container').html('');
$(function() {
$('.close_div').click(function() {
var course_id = this.id.split('_')[2];
var session_id = this.id.split('_')[3];
$('#document_result_'+course_id+'_'+session_id).hide();
$('.lp_resource').remove();
$('.document_preview_container').html('');
});
});
</script>";
} else {
//For LPs
$url = api_get_path(WEB_AJAX_PATH).'lp.ajax.php?a=get_documents&lp_id='.$lp_id.'&'.api_get_cidreq();
$return .= "<script>
// For LPs
$url = $lpAjaxUrl.'?a=get_documents&lp_id='.$lp_id.'&'.api_get_cidreq();
}
if (!empty($overwrite_url)) {
$url .= '&url='.Security::remove_XSS($overwrite_url);
}
if ($add_move_button) {
$url .= '&add_move_button=1';
}
$return .= "<script>
function testResources(id, img) {
var numericId = id.split('_')[1];
var parentId = 'doc_id_'+numericId;
@ -3482,7 +3457,6 @@ class DocumentManager
}
}
</script>";
}
if (!$user_in_course) {
$return = '';
@ -4976,6 +4950,9 @@ class DocumentManager
$path = $document_data['path'];
$url_path = urlencode($document_data['path']);
$basePageUrl = api_get_path(WEB_CODE_PATH).'document/';
$pageUrl = $basePageUrl.'document.php';
// Add class="invisible" on invisible files
$visibility_class = $visibility == false ? ' class="muted"' : '';
$forcedownload_link = '';
@ -4985,7 +4962,9 @@ class DocumentManager
if (!$show_as_icon) {
// Build download link (icon)
$forcedownload_link = $filetype == 'folder' ? api_get_self().'?'.$courseParams.'&action=downloadfolder&id='.$document_data['id'] : api_get_self().'?'.$courseParams.'&amp;action=download&amp;id='.$document_data['id'];
$forcedownload_link = $filetype == 'folder'
? $pageUrl.'?'.$courseParams.'&action=downloadfolder&id='.$document_data['id']
: $pageUrl.'?'.$courseParams.'&amp;action=download&amp;id='.$document_data['id'];
// Folder download or file download?
$forcedownload_icon = $filetype == 'folder' ? 'save_pack.png' : 'save.png';
// Prevent multiple clicks on zipped folder download
@ -5004,9 +4983,9 @@ class DocumentManager
$is_browser_viewable_file = self::isBrowserViewable($ext);
if ($is_browser_viewable_file) {
if ($ext == 'pdf' || in_array($ext, $webODFList)) {
$url = api_get_self().'?'.$courseParams.'&amp;action=download&amp;id='.$document_data['id'];
$url = $pageUrl.'?'.$courseParams.'&amp;action=download&amp;id='.$document_data['id'];
} else {
$url = 'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
$url = $basePageUrl.'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
}
} else {
// url-encode for problematic characters (we may not call them dangerous characters...)
@ -5014,7 +4993,7 @@ class DocumentManager
$url = $www.str_replace('%2F', '/', $url_path).'?'.$courseParams;
}
} else {
$url = api_get_self().'?'.$courseParams.'&id='.$document_data['id'];
$url = $pageUrl.'?'.$courseParams.'&id='.$document_data['id'];
}
if ($isCertificateMode) {
@ -5092,7 +5071,7 @@ class DocumentManager
if (api_get_setting('allow_my_files') === 'true' &&
api_get_setting('users_copy_files') === 'true' && api_is_anonymous() === false
) {
$copy_myfiles_link = $filetype == 'file' ? api_get_self().'?'.$courseParams.'&action=copytomyfiles&id='.$document_data['id'] : api_get_self().'?'.$courseParams;
$copy_myfiles_link = $filetype == 'file' ? $pageUrl.'?'.$courseParams.'&action=copytomyfiles&id='.$document_data['id'] : api_get_self().'?'.$courseParams;
if ($filetype == 'file') {
/*$copyToMyFiles = '<a href="'.$copy_myfiles_link.'" style="float:right"'.$prevent_multiple_click.'>'.
Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), [], ICON_SIZE_SMALL).'&nbsp;&nbsp;</a>';
@ -5109,7 +5088,7 @@ class DocumentManager
$filetype == 'file' &&
in_array($extension, ['html', 'htm'])
) {
$pdf_icon = ' <a style="float:right".'.$prevent_multiple_click.' href="'.api_get_self().'?'.$courseParams.'&action=export_to_pdf&id='.$document_data['id'].'&curdirpath='.$curdirpath.'">'.
$pdf_icon = ' <a style="float:right".'.$prevent_multiple_click.' href="'.$pageUrl.'?'.$courseParams.'&action=export_to_pdf&id='.$document_data['id'].'&curdirpath='.$curdirpath.'">'.
Display::return_icon('pdf.png', get_lang('Export2PDF'), [], ICON_SIZE_SMALL).'</a> ';
}
@ -5160,7 +5139,7 @@ class DocumentManager
// For a "PDF Download" of the file.
$pdfPreview = null;
if ($ext != 'pdf' && !in_array($ext, $webODFList)) {
$url = 'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
$url = $basePageUrl.'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
} else {
$pdfPreview = Display::url(
Display::return_icon('preview.png', get_lang('Preview'), null, ICON_SIZE_SMALL),
@ -5201,7 +5180,7 @@ class DocumentManager
preg_match('/bmp$/i', urldecode($checkExtension)) ||
preg_match('/svg$/i', urldecode($checkExtension))
) {
$url = 'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
$url = $basePageUrl.'showinframes.php?'.$courseParams.'&id='.$document_data['id'];
return '<a href="'.$url.'" title="'.$tooltip_title_alt.'" '.$visibility_class.' style="float:left">'.
self::build_document_icon_tag($filetype, $path, $isAllowedToEdit).
@ -5240,7 +5219,7 @@ class DocumentManager
preg_match('/bmp$/i', urldecode($checkExtension)) ||
preg_match('/svg$/i', urldecode($checkExtension))
) {
$url = 'showinframes.php?'.$courseParams.'&id='.$document_data['id']; //without preview
$url = $basePageUrl.'showinframes.php?'.$courseParams.'&id='.$document_data['id']; //without preview
return '<a href="'.$url.'" title="'.$tooltip_title_alt.'" '.$visibility_class.' style="float:left">'.
self::build_document_icon_tag($filetype, $path, $isAllowedToEdit).
'</a>';
@ -5583,7 +5562,7 @@ class DocumentManager
// Cannot copy dir into his own subdir
$path_displayed = self::get_titles_of_path($folder);
$display_folder = substr($path_displayed, strlen($group_dir));
$display_folder = ($display_folder == '') ? get_lang('Documents') : $display_folder;
$display_folder = $display_folder == '' ? get_lang('Documents') : $display_folder;
$options[$folder] = $display_folder;
}
}
@ -5802,6 +5781,14 @@ class DocumentManager
}
}
public static function isBasicCourseFolder($path, $sessionId)
{
$cleanPath = Security::remove_XSS($path);
$basicCourseFolder = '/basic-course-documents__'.$sessionId.'__0';
return $cleanPath == $basicCourseFolder;
}
/**
* Check if the file name or folder searched exist.
*
@ -6772,15 +6759,14 @@ class DocumentManager
if ($lp_id) {
// LP URL
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&file='.$documentId.'&lp_id='.$lp_id;
if (!empty($overwrite_url)) {
$url = $overwrite_url.'&cidReq='.$course_info['code'].'&id_session='.$session_id.'&document_id='.$documentId.'';
}
} else {
// Direct document URL
$url = $web_code_path.'document/document.php?cidReq='.$course_info['code'].'&id_session='.$session_id.'&id='.$documentId;
if (!empty($overwrite_url)) {
$url = $overwrite_url.'&cidReq='.$course_info['code'].'&id_session='.$session_id.'&document_id='.$documentId;
}
}
if (!empty($overwrite_url)) {
$overwrite_url = Security::remove_XSS($overwrite_url);
$url = $overwrite_url.'&cidReq='.$course_info['code'].'&id_session='.$session_id.'&document_id='.$documentId;
}
$img = Display::returnIconPath($icon);
@ -6861,15 +6847,15 @@ class DocumentManager
return null;
}
$onclick = '';
//$onclick = '';
// if in LP, hidden folder are displayed in grey
$folder_class_hidden = '';
if ($lp_id) {
if (isset($resource['visible']) && $resource['visible'] == 0) {
$folder_class_hidden = "doc_folder_hidden"; // in base.css
$folder_class_hidden = ' doc_folder_hidden'; // in base.css
}
$onclick = 'onclick="javascript: testResources(\'res_'.$resource['id'].'\',\'img_'.$resource['id'].'\')"';
}
$onclick = 'onclick="javascript: testResources(\'res_'.$resource['id'].'\',\'img_'.$resource['id'].'\')"';
$return = null;
if (empty($path)) {

@ -20,6 +20,17 @@ if (empty($driverList)) {
//'CourseUserDriver',
//'HomeDriver'
];
$block = api_get_configuration_value('block_editor_file_manager_for_students');
$newDriverList = [];
if ($block && !api_is_allowed_to_edit()) {
foreach ($driverList as $driver) {
if ($driver === 'CourseDriver') {
continue;
}
$newDriverList[] = $driver;
}
$driverList = $newDriverList;
}
}
$connector->setDriverList($driverList);

@ -2021,7 +2021,6 @@ class Event
* @param int $sessionId The session in which to add the time (if any)
* @param string $virtualTime The amount of time to be added,
* in a hh:mm:ss format. If int, we consider it is expressed in hours.
* @param string $ip IP address to go on record for this time record
*
* @return true on successful insertion, false otherwise
*/
@ -2029,80 +2028,32 @@ class Event
$courseId,
$userId,
$sessionId,
$virtualTime = '',
$ip = ''
$virtualTime = ''
) {
$courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$time = $loginDate = $logoutDate = api_get_utc_datetime();
$courseId = (int) $courseId;
$userId = (int) $userId;
$sessionId = (int) $sessionId;
$ip = Database::escape_string($ip);
// Get the current latest course connection register. We need that
// record to re-use the data and create a new record.
$sql = "SELECT *
FROM $courseTrackingTable
WHERE
user_id = $userId AND
c_id = $courseId AND
session_id = $sessionId AND
login_course_date > '$time' - INTERVAL 3600 SECOND
ORDER BY login_course_date DESC
LIMIT 0,1";
$result = Database::query($sql);
// Ignore if we didn't find any course connection record in the last
// hour. In this case it wouldn't be right to add a "fake" time record.
if (Database::num_rows($result) > 0) {
// Found the latest connection
$row = Database::fetch_array($result);
$courseAccessId = $row['course_access_id'];
$courseAccessLoginDate = $row['login_course_date'];
$counter = $row['counter'];
$counter = $counter ? $counter : 0;
// Insert a new record, copy of the current one (except the logout
// date that we update to the current time)
$sql = "INSERT INTO $courseTrackingTable(
c_id,
user_ip,
user_id,
login_course_date,
logout_course_date,
counter,
session_id
) VALUES(
$courseId,
'$ip',
$userId,
'$courseAccessLoginDate',
'$logoutDate',
$counter,
$sessionId
)";
Database::query($sql);
$loginDate = ChamiloApi::addOrSubTimeToDateTime(
$virtualTime,
$courseAccessLoginDate,
false
);
// We update the course tracking table
$sql = "UPDATE $courseTrackingTable
SET
login_course_date = '$loginDate',
logout_course_date = '$courseAccessLoginDate',
counter = 0
WHERE
course_access_id = ".intval($courseAccessId)." AND
session_id = ".$sessionId;
Database::query($sql);
$logoutDate = api_get_utc_datetime();
$loginDate = ChamiloApi::addOrSubTimeToDateTime(
$virtualTime,
$logoutDate,
false
);
return true;
}
$params = [
'login_course_date' => $loginDate,
'logout_course_date' => $logoutDate,
'session_id' => $sessionId,
'user_id' => $userId,
'counter' => 0,
'c_id' => $courseId,
'user_ip' => api_get_real_ip(),
];
$courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
Database::insert($courseTrackingTable, $params);
return false;
return true;
}
/**
@ -2134,8 +2085,6 @@ class Event
return false;
}
$courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$time = $loginDate = $logoutDate = api_get_utc_datetime();
$courseId = (int) $courseId;
$userId = (int) $userId;
$sessionId = (int) $sessionId;

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\TrackEExercises;
use Chamilo\CoreBundle\Framework\Container;
use ChamiloSession as Session;
@ -210,7 +211,7 @@ class ExerciseLib
$form->addHtml('<div id="'.'hide_description_'.$questionId.'_options" style="display: none;">');
$form->addHtmlEditor(
"choice[".$questionId."]",
"choice[$questionId]",
null,
false,
false,
@ -295,7 +296,7 @@ class ExerciseLib
RadioValidator(question_id, answer_id);
}
$(document).ready(function() {
$(function() {
var ShowAlert = '';
var typeRadioB = '';
var question_id = $('input[name=question_id]').val();
@ -1259,7 +1260,7 @@ HTML;
if (!$freeze) {
$s .= "
<script>
$(document).on('ready', function() {
$(function() {
jsPlumb.ready(function() {
jsPlumb.connect({
source: 'window_$windowId',
@ -3043,7 +3044,7 @@ HOTSPOT;
spanTag.addClass(optionClass);
}
$(document).ready( function() {
$(function() {
// Loading values
$('.exercise_mark_select').on('loaded.bs.select', function() {
updateSelect($(this));
@ -4740,6 +4741,17 @@ EOT;
true
);
} else {
$pluginEvaluation = QuestionOptionsEvaluationPlugin::create();
if ('true' === $pluginEvaluation->get(QuestionOptionsEvaluationPlugin::SETTING_ENABLE)) {
$formula = $pluginEvaluation->getFormulaForExercise($objExercise->selectId());
if (!empty($formula)) {
$total_score = $pluginEvaluation->getResultWithFormula($exeId, $formula);
$total_weight = $pluginEvaluation->getMaxScore();
}
}
$totalScoreText .= self::getTotalScoreRibbon(
$objExercise,
$total_score,
@ -4815,10 +4827,17 @@ EOT;
$learnpath_item_id,
$learnpath_item_view_id,
$exercise_stat_info['exe_duration'],
$question_list,
'',
[]
$question_list
);
$allowStats = api_get_configuration_value('allow_gradebook_stats');
if ($allowStats) {
$objExercise->generateStats(
$objExercise->selectId(),
api_get_course_info(),
api_get_session_id()
);
}
}
}
@ -5060,8 +5079,7 @@ EOT;
$ribbon .= '<div class="total">';
}
$ribbon .= '<h3>'.get_lang('YourTotalScore').":&nbsp;";
$score = self::show_score($score, $weight, false, true);
$ribbon .= $score['html'];
$ribbon .= self::show_score($score, $weight, false, true);
$ribbon .= '</h3>';
$ribbon .= '</div>';
if ($checkPassPercentage) {
@ -5284,12 +5302,11 @@ EOT;
SELECT COUNT(ea) FROM ChamiloCoreBundle:TrackEAttempt ea
WHERE ea.userId = :user AND ea.cId = :course AND ea.sessionId = :session
AND ea.tms > :time
GROUP BY ea.questionId
')
->setParameters(['user' => $userId, 'course' => $courseId, 'session' => $sessionId, 'time' => $time])
->getResult();
->getSingleScalarResult();
return count($result);
return $result;
}
/**
@ -5298,8 +5315,9 @@ EOT;
* @param int $courseId
* @param int $sessionId
*
* @return bool
* @throws \Doctrine\ORM\Query\QueryException
*
* @return bool
*/
public static function isQuestionsLimitPerDayReached($userId, $numberOfQuestions, $courseId, $sessionId)
{

@ -45,10 +45,7 @@ class ExerciseShowFunctions
$resultsDisabled,
$showTotalScoreAndUserChoices
);
// ofaj
/*if (strpos($originalStudentAnswer, 'font color') !== false) {
$answerHTML = $originalStudentAnswer;
}*/
if (empty($id)) {
echo '<tr><td>';
echo Security::remove_XSS($answerHTML, COURSEMANAGERLOWSECURITY);
@ -190,12 +187,6 @@ class ExerciseShowFunctions
echo Security::remove_XSS($answer);
}
echo '</td>';
if (!api_is_allowed_to_edit(null, true) && $feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td>';
$comm = Event::get_comments($id, $questionId);
echo '</td>';
}
echo '</tr>';
}
}
@ -336,14 +327,24 @@ class ExerciseShowFunctions
$studentChoiceInt = (int) $studentChoice;
$answerCorrectChoice = (int) $answerCorrect;
$hideStudentChoice = false;
$hide_expected_answer = false;
$status = '';
if ($exercise->showExpectedChoice()) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if ($studentChoiceInt === $answerCorrectChoice) {
$status = Display::label(get_lang('Correct'), 'success');
}
}
$showComment = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
if ($studentChoiceInt !== $answerCorrectChoice) {
return '';
}
$hideStudentChoice = true;
$hide_expected_answer = true;
$status = Display::label(get_lang('Correct'), 'success');
$showComment = true;
if (!$answerCorrect) {
return '';
}
@ -370,55 +371,53 @@ class ExerciseShowFunctions
$iconAnswer .= '.png';
echo '<tr>';
echo '<td width="5%">';
echo Display::return_icon($icon, null, null, ICON_SIZE_TINY);
echo '</td><td width="5%">';
if ($hideStudentChoice === false) {
echo '<td width="5%">';
echo Display::return_icon($icon, null, null, ICON_SIZE_TINY);
echo '</td>';
}
if (!$hide_expected_answer) {
echo '<td width="5%">';
echo Display::return_icon($iconAnswer, null, null, ICON_SIZE_TINY);
} else {
echo '-';
echo '</td>';
}
echo '</td><td width="40%">';
echo '<td width="40%">';
echo $answer;
echo '</td>';
if ($exercise->showExpectedChoice()) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if ($studentChoiceInt === $answerCorrectChoice) {
$status = Display::label(get_lang('Correct'), 'success');
}
echo '<td width="20%">';
echo $status;
echo '</td>';
}
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td width="20%">';
if ($studentChoice) {
$color = 'black';
if ($answerCorrect) {
$color = 'green';
}
if ($hide_expected_answer) {
$color = '';
}
$comment = '<span style="font-weight: bold; color: '.$color.';">'.
Security::remove_XSS($answerComment).
'</span>';
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM && $studentChoice) {
$showComment = true;
if (!$answerCorrect && $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$showComment = false;
}
}
if (!$answerCorrect && $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$comment = '';
}
echo $comment;
if ($showComment) {
echo '<td width="20%">';
$color = 'black';
if ($answerCorrect) {
$color = 'green';
}
echo '</td>';
if ($ans == 1) {
$comm = Event::get_comments($id, $questionId);
if ($hide_expected_answer) {
$color = '';
}
$comment = '<span style="font-weight: bold; color: '.$color.';">'.
Security::remove_XSS($answerComment).
'</span>';
echo $comment;
echo '</td>';
} else {
echo '<td>&nbsp;</td>';
}
echo '</tr>';
}
@ -450,7 +449,12 @@ class ExerciseShowFunctions
$showTotalScoreAndUserChoices
) {
$hide_expected_answer = false;
$hideStudentChoice = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
$hideStudentChoice = true;
$hide_expected_answer = true;
break;
case RESULT_DISABLE_SHOW_SCORE_ONLY:
if ($feedbackType == 0) {
$hide_expected_answer = true;
@ -465,29 +469,36 @@ class ExerciseShowFunctions
break;
}
$content = '<tr><td width="5%">';
$course_id = api_get_course_int_id();
$new_options = Question::readQuestionOption($questionId, $course_id);
// Your choice
if (isset($new_options[$studentChoice])) {
$content .= get_lang($new_options[$studentChoice]['name']);
} else {
$content .= '-';
$content = '<tr>';
if ($hideStudentChoice === false) {
$content .= '<td width="5%">';
$course_id = api_get_course_int_id();
$new_options = Question::readQuestionOption($questionId, $course_id);
// Your choice
if (isset($new_options[$studentChoice])) {
$content .= get_lang($new_options[$studentChoice]['name']);
} else {
$content .= '-';
}
$content .= '</td>';
}
echo '</td><td width="5%">';
// Expected choice
if (!$hide_expected_answer) {
$content .= '<td width="5%">';
if (isset($new_options[$answerCorrect])) {
$content .= get_lang($new_options[$answerCorrect]['name']);
} else {
$content .= '-';
}
} else {
$content .= '-';
$content .= '</td>';
}
$content .= '</td><td width="40%">';
$content .= '<td width="40%">';
$content .= $answer;
$content .= '</td>';
if ($exercise->showExpectedChoice()) {
$status = Display::label(get_lang('Incorrect'), 'danger');
if (isset($new_options[$studentChoice])) {
@ -499,15 +510,11 @@ class ExerciseShowFunctions
$content .= $status;
$content .= '</td>';
}
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
if ($resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
if ($studentChoice != $answerCorrect) {
return '';
}
}
$content .= '<td width="20%">';
$color = 'black';
if (isset($new_options[$studentChoice])) {
if (isset($new_options[$studentChoice]) || $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
if ($studentChoice == $answerCorrect) {
$color = 'green';
}
@ -518,8 +525,6 @@ class ExerciseShowFunctions
$content .= '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
}
$content .= '</td>';
} else {
$content .= '<td>&nbsp;</td>';
}
$content .= '</tr>';
@ -641,7 +646,12 @@ class ExerciseShowFunctions
$showTotalScoreAndUserChoices
) {
$hide_expected_answer = false;
$hideStudentChoice = false;
switch ($resultsDisabled) {
case RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER:
$hideStudentChoice = true;
$hide_expected_answer = true;
break;
case RESULT_DISABLE_SHOW_SCORE_ONLY:
if ($feedbackType == 0) {
$hide_expected_answer = true;
@ -656,28 +666,32 @@ class ExerciseShowFunctions
break;
}
echo '<tr><td width="5%">';
// Your choice
$question = new MultipleAnswerCombinationTrueFalse();
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
echo $question->options[2];
echo '<tr>';
if ($hideStudentChoice === false) {
echo '<td width="5%">';
// Your choice
$question = new MultipleAnswerCombinationTrueFalse();
if (isset($question->options[$studentChoice])) {
echo $question->options[$studentChoice];
} else {
echo $question->options[2];
}
echo '</td>';
}
echo '</td><td width="5%">';
// Expected choice
if (!$hide_expected_answer) {
echo '<td width="5%">';
if (isset($question->options[$answerCorrect])) {
echo $question->options[$answerCorrect];
} else {
echo $question->options[2];
}
} else {
echo '-';
echo '</td>';
}
echo '</td>';
echo '<td width="40%">';
// my answer
echo $answer;
echo '</td>';
@ -697,10 +711,10 @@ class ExerciseShowFunctions
if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) {
echo '<td width="20%">';
//@todo replace this harcoded value
if ($studentChoice) {
$color = "black";
if ($studentChoice || $resultsDisabled == RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER) {
$color = 'black';
if ($studentChoice == $answerCorrect) {
$color = "green";
$color = 'green';
}
if ($hide_expected_answer) {
$color = '';
@ -708,9 +722,6 @@ class ExerciseShowFunctions
echo '<span style="font-weight: bold; color: '.$color.';">'.nl2br($answerComment).'</span>';
}
echo '</td>';
if ($ans == 1) {
$comm = Event::get_comments($id, $questionId);
}
} else {
echo '<td>&nbsp;</td>';
}

@ -1658,7 +1658,7 @@ class ExtraField extends Model
$deleteId = $field_details['variable'].'_delete';
$form->addHtml("
<script>
$(document).ready(function() {
$(function() {
$('#".$deleteId."').on('click', function() {
$.ajax({
type: 'GET',

@ -71,6 +71,10 @@ function get_document_title($name)
$name = disable_dangerous_file($name);
$ext = substr(strrchr($name, '.'), 0);
if (empty($ext)) {
return substr($name, 0, strlen($name));
}
return substr($name, 0, strlen($name) - strlen(strstr($name, $ext)));
}

@ -1,4 +1,4 @@
$(document).ready(function() {
$(function() {
var objects = $(document).find('object');
var pathname = location.pathname;
var coursePath = pathname.substr(0, pathname.indexOf('/courses/'));

@ -36,7 +36,7 @@ class Color extends HTML_QuickForm_text
{
return parent::toHtml().<<<JS
<script>
$(document).on('ready', function () {
$(function() {
var txtColor = $('#{$this->getAttribute('id')}'),
lblColor = txtColor.parent().next();

@ -80,28 +80,7 @@ class DatePicker extends HTML_QuickForm_text
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = [2, $sizeTemp, 2];
} else {
if (is_array($size)) {
if (count($size) != 3) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = [2, $sizeTemp, 2];
}
// else just keep the $size array as received
} else {
$size = [2, (int) $size, 2];
}
}
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:

@ -79,28 +79,7 @@ class DateTimePicker extends HTML_QuickForm_text
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = [2, $sizeTemp, 2];
} else {
if (is_array($size)) {
if (count($size) != 3) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = [2, $sizeTemp, 2];
}
// else just keep the $size array as received
} else {
$size = [2, (int) $size, 2];
}
}
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:

@ -53,29 +53,7 @@ class DateTimeRangePicker extends DateRangePicker
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = [2, $sizeTemp, 2];
} else {
if (is_array($size)) {
if (count($size) != 3) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = [2, $sizeTemp, 2];
}
// else just keep the $size array as received
} else {
$size = [2, (int) $size, 2];
}
}
$size = $this->calculateSize();
$id = $this->getAttribute('id');
switch ($layout) {

@ -915,8 +915,9 @@ EOT;
* @param string $label
* @param array $attributes
*
* @throws Exception if the file doesn't have an id
* @throws HTML_QuickForm_Error
* @throws Exception if the file doesn't have an id
*
* @return HTML_QuickForm_file
*/
public function addFile($name, $label, $attributes = [])
{
@ -948,6 +949,8 @@ EOT;
} catch (HTML_Quick | Form_Error $e) {
var_dump($e->getMessage());
}
return $element;
}
/**
@ -1629,7 +1632,7 @@ EOT;
$this->addHtml('</div>');
$this->addHtml("<script>
$(document).on('ready', function() {
$(function() {
var defaultValue = '$defaultId';
$('#$typeNoDots').val(defaultValue);
$('#$typeNoDots').selectpicker('render');

@ -582,14 +582,15 @@ function api_format_date($time, $format = null, $language = null)
* You can use it like this:
* Display::dateToStringAgoAndLongDate($dateInUtc);.
*
* @param string $date Result of a date function in this format -> date('Y-m-d H:i:s', time());
* @param string $date Result of a date function in this format -> date('Y-m-d H:i:s', time());
* @param string $timeZone
* @param bool $returnDateDifference
*
* @return string
*
* @author Julio Montoya
*/
function date_to_str_ago($date, $timeZone = 'UTC')
function date_to_str_ago($date, $timeZone = 'UTC', $returnDateDifference = false)
{
if ($date === '0000-00-00 00:00:00') {
return '';
@ -609,6 +610,10 @@ function date_to_str_ago($date, $timeZone = 'UTC')
date_default_timezone_set($getOldTimezone);
if ($returnDateDifference) {
$value = $timeAgo->dateDifference($date);
}
return $value;
}

@ -2762,13 +2762,11 @@ class MessageManager
* @param int $messageId
* @param int $userId
*
* @throws \Doctrine\ORM\Query\QueryException
*
* @return array
*/
public static function countLikesAndDislikes($messageId, $userId)
{
if (!api_get_configuration_value('social_enable_likes_messages')) {
if (!api_get_configuration_value('social_enable_messages_feedback')) {
return [];
}
@ -2776,26 +2774,26 @@ class MessageManager
$userId = (int) $userId;
$em = Database::getManager();
$query = $em
->createQuery('
SELECT SUM(l.liked) AS likes, SUM(l.disliked) AS dislikes FROM ChamiloCoreBundle:MessageFeedback l
WHERE l.message = :message
')
->setParameters(['message' => $messageId]);
$likesCount = $em
->createQuery('SELECT COUNT(l) FROM ChamiloCoreBundle:MessageLikes l
WHERE l.liked = true AND l.message = :message')
->setParameters(['message' => $messageId])
->getSingleScalarResult();
$dislikesCount = $em
->createQuery('SELECT COUNT(l) FROM ChamiloCoreBundle:MessageLikes l
WHERE l.liked = false AND l.message = :message')
->setParameters(['message' => $messageId])
->getSingleScalarResult();
try {
$counts = $query->getSingleResult();
} catch (Exception $e) {
$counts = ['likes' => 0, 'dislikes' => 0];
}
$userLike = $em
->getRepository('ChamiloCoreBundle:MessageLikes')
->getRepository('ChamiloCoreBundle:MessageFeedback')
->findOneBy(['message' => $messageId, 'user' => $userId]);
return [
'likes' => $likesCount,
'dislikes' => $dislikesCount,
'likes' => (int) $counts['likes'],
'dislikes' => (int) $counts['dislikes'],
'user_liked' => $userLike ? $userLike->isLiked() : false,
'user_disliked' => $userLike ? $userLike->isDisliked() : false,
];
@ -2806,13 +2804,11 @@ class MessageManager
* @param int $userId
* @param int $groupId Optional.
*
* @throws \Doctrine\ORM\Query\QueryException
*
* @return string
*/
public static function getLikesButton($messageId, $userId, $groupId = 0)
{
if (!api_get_configuration_value('social_enable_likes_messages')) {
if (!api_get_configuration_value('social_enable_messages_feedback')) {
return '';
}
@ -2823,7 +2819,7 @@ class MessageManager
Display::returnFontAwesomeIcon('thumbs-up', '', true)
.PHP_EOL.'<span>'.$countLikes['likes'].'</span>',
[
'title' => get_lang('Like'),
'title' => get_lang('VoteLike'),
'class' => 'btn btn-default social-like '.($countLikes['user_liked'] ? 'disabled' : ''),
'data-status' => 'like',
'data-message' => $messageId,
@ -2835,7 +2831,7 @@ class MessageManager
Display::returnFontAwesomeIcon('thumbs-down', '', true)
.PHP_EOL.'<span>'.$countLikes['dislikes'].'</span>',
[
'title' => get_lang('Dislike'),
'title' => get_lang('VoteDislike'),
'class' => 'btn btn-default social-like '.($countLikes['user_disliked'] ? 'disabled' : ''),
'data-status' => 'dislike',
'data-message' => $messageId,

@ -1481,7 +1481,7 @@ class MySpace
'order' => " $columnName $direction",
'limit' => " $from,$numberItems",
];
$sessions = SessionManager::get_sessions_admin($options);
$sessions = SessionManager::formatSessionsAdminForGrid($options);
$list = [];
foreach ($sessions as $session) {
$list[] = [
@ -2359,7 +2359,7 @@ class MySpace
*
* @author Julio Montoya Armas
*/
public function check_all_usernames($users, $course_list, $id_session)
public static function check_all_usernames($users, $course_list, $id_session)
{
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$usernames = [];
@ -2409,7 +2409,7 @@ class MySpace
*
* @author Julio Montoya Armas
*/
public function get_user_creator($users)
public static function get_user_creator($users)
{
$errors = [];
foreach ($users as $index => $user) {
@ -2437,7 +2437,7 @@ class MySpace
*
* @param array $users list of users
*/
public function validate_data($users, $id_session = null)
public static function validate_data($users, $id_session = null)
{
$errors = [];
$new_users = [];
@ -2475,7 +2475,7 @@ class MySpace
/**
* Adds missing user-information (which isn't required, like password, etc).
*/
public function complete_missing_data($user)
public static function complete_missing_data($user)
{
// 1. Generate a password if it is necessary.
if (!isset($user['Password']) || strlen($user['Password']) == 0) {
@ -2488,14 +2488,14 @@ class MySpace
/**
* Saves imported data.
*/
public function save_data($users, $course_list, $id_session)
public static function save_data($users, $course_list, $id_session)
{
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$id_session = intval($id_session);
$id_session = (int) $id_session;
$sendMail = $_POST['sendMail'] ? 1 : 0;
// Adding users to the platform.
@ -2612,7 +2612,7 @@ class MySpace
$addedto = get_lang('UserNotAdded');
}
$registered_users .= UserManager::getUserProfileLink($userInfo)." - ".$addedto.'<br />';
$registered_users .= UserManager::getUserProfileLink($userInfo).' - '.$addedto.'<br />';
}
} else {
$i = 0;
@ -2632,10 +2632,10 @@ class MySpace
$addedto = get_lang('UserNotAdded');
}
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".
api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
Security::remove_XSS($userInfo['complete_user_name'])."</a> - ".$addedto.'<br />';
}
}
Display::addFlash(Display::return_message($registered_users));
Display::addFlash(Display::return_message($registered_users, 'normal', false));
header('Location: course.php?id_session='.$id_session);
exit;
}
@ -2660,55 +2660,6 @@ class MySpace
return $users;
}
/**
* XML-parser: the handler at the beginning of element.
*/
public function element_start($parser, $data)
{
$data = api_utf8_decode($data);
global $user;
global $current_tag;
switch ($data) {
case 'Contact':
$user = [];
break;
default:
$current_tag = $data;
}
}
/**
* XML-parser: the handler at the end of element.
*/
public function element_end($parser, $data)
{
$data = api_utf8_decode($data);
global $user;
global $users;
global $current_value;
global $purification_option_for_usernames;
$user[$data] = $current_value;
switch ($data) {
case 'Contact':
$user['UserName'] = UserManager::purify_username($user['UserName'], $purification_option_for_usernames);
$users[] = $user;
break;
default:
$user[$data] = $current_value;
break;
}
}
/**
* XML-parser: the handler for character data.
*/
public function character_data($parser, $data)
{
$data = trim(api_utf8_decode($data));
global $current_value;
$current_value = $data;
}
/**
* Reads XML-file.
*
@ -2716,21 +2667,25 @@ class MySpace
*
* @return array All userinformation read from the file
*/
public function parse_xml_data($file)
public static function parse_xml_data($file)
{
global $current_tag;
global $current_value;
global $user;
global $users;
$users = [];
$parser = xml_parser_create('UTF-8');
xml_set_element_handler($parser, ['MySpace', 'element_start'], ['MySpace', 'element_end']);
xml_set_character_data_handler($parser, "character_data");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
xml_parser_free($parser);
$crawler = new \Symfony\Component\DomCrawler\Crawler();
$crawler->addXmlContent(file_get_contents($file));
$crawler = $crawler->filter('Contacts > Contact ');
$array = [];
foreach ($crawler as $domElement) {
$row = [];
foreach ($domElement->childNodes as $node) {
if ($node->nodeName != '#text') {
$row[$node->nodeName] = $node->nodeValue;
}
}
if (!empty($row)) {
$array[] = $row;
}
}
return $users;
return $array;
}
/**

@ -1124,5 +1124,6 @@ class nusoap_server extends nusoap_base
/**
* Backward compatibility
*/
class soap_server extends nusoap_server {
class soap_server extends nusoap_server
{
}

@ -123,8 +123,6 @@ class PDF
// Assignments
$tpl->assign('pdf_content', $content);
$teacher_list = [];
// Showing only the current teacher/admin instead the all teacher list name see BT#4080
if (isset($this->params['show_real_course_teachers']) &&
$this->params['show_real_course_teachers']
@ -165,12 +163,17 @@ class PDF
$html = $tpl->fetch($tableTemplate);
$html = api_utf8_encode($html);
if ($returnHtml) {
return $html;
}
$css_file = api_get_path(SYS_CSS_PATH).'themes/'.$tpl->theme.'/print.css';
if (!file_exists($css_file)) {
$css_file = api_get_path(SYS_CSS_PATH).'print.css';
}
$css = file_get_contents($css_file);
$html = self::content_to_pdf(
self::content_to_pdf(
$html,
$css,
$this->params['filename'],
@ -181,10 +184,6 @@ class PDF
$returnHtml,
$addDefaultCss
);
if ($returnHtml) {
return $html;
}
}
/**
@ -392,7 +391,7 @@ class PDF
return false;
}
//clean styles and javascript document
// clean styles and javascript document
$clean_search = [
'@<script[^>]*?>.*?</script>@si',
'@<style[^>]*?>.*?</style>@siU',

@ -920,7 +920,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
'<input type="text" name="q" class="form-control mb-3" placeholder="'.addslashes(get_lang('Search')).'" />';
$js .= '<script>
$(document).ready(function() {
$(function() {
$(\'#'.$name.'\').multiselect({
search: {
left: \''.$search.'\',

@ -210,24 +210,9 @@ class HTML_QuickForm_button extends HTML_QuickForm_input
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
$size = $this->calculateSize();
$attributes = $this->getAttributes();
if (empty($size)) {
$size = array(2, 8, 2);
} else {
if (is_array($size)) {
if (count($size) == 1) {
$size = array(2, intval($size[0]), 2);
} elseif (count($size) != 3) {
$size = array(2, 8, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
return '

@ -163,22 +163,7 @@ class HTML_QuickForm_checkbox extends HTML_QuickForm_input
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$size = array(2, 8, 2);
} else {
if (is_array($size)) {
if (count($size) == 1) {
$size = array(2, intval($size[0]), 2);
} elseif (count($size) != 3) {
$size = array(2, 8, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:

@ -40,6 +40,7 @@ class HTML_QuickForm_element extends HTML_Common
private $template;
private $button;
private $customFrozenTemplate = '';
protected $inputSize;
/**
* Label of the field
@ -602,4 +603,53 @@ class HTML_QuickForm_element extends HTML_Common
return $this;
}
/**
* @return null
*/
public function getInputSize()
{
return $this->inputSize;
}
/**
* @param null $inputSize
*/
public function setInputSize($inputSize)
{
$this->inputSize = $inputSize;
}
/**
* @return array|null
*/
public function calculateSize()
{
$size = $this->getColumnsSize();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
} else {
if (is_array($size)) {
if (count($size) != 3) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
}
} else {
// else just keep the $size array as received
$size = array(2, (int) $size, 2);
}
}
return $size;
}
}

@ -263,7 +263,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
}
return '<script>
$(document).ready(function() {
$(function() {
var $inputFile = $(\'#'.$id.'\'),
$image = $(\'#'.$id.'_preview_image\'),
$input = $(\'[name="'.$id.'_crop_result"]\'),
@ -348,15 +348,12 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
$(".img-box").show();
$(".img-preview").hide();
$image.attr(\'src\', dataUrl).cropper(\'destroy\').off(\'load\', imageCropper);
image.attr(\'src\', dataUrl).cropper(\'destroy\').off(\'load\', imageCropper);
$imageSmall.attr(\'src\', dataUrl).cropper(\'destroy\').off(\'load\', imageCropper);
$imageLarge.attr(\'src\', dataUrl).cropper(\'destroy\').off(\'load\', imageCropper);
$(\'[name="' . $id . '_crop_image_base_64"]\').val(dataUrl);
$(\'[name="'.$id.'_crop_image_base_64"]\').val(dataUrl);
$cropButton.hide();
});
});
</script>';
}
@ -401,6 +398,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
{
$name = $this->getName();
$attributes = $this->getAttributes();
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
@ -414,7 +412,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
</div>';
break;
case FormValidator::LAYOUT_HORIZONTAL:
if (isset($attributes['custom']) && $attributes['custom'] == true) {
if (isset($attributes['custom']) && $attributes['custom']) {
$template = '
<div class="input-file-container">
{element}
@ -449,12 +447,13 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
';
} else {
$template = '
<div id="file_' . $name . '" class="form-group {error_class}">
<label {label-for} class="col-sm-3 control-label" >
<div id="file_'.$name.'" class="form-group {error_class}">
<label {label-for} class="col-sm-'.$size[0].' control-label" >
<!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
{label}
</label>
<div class="col-sm-7">
<div class="col-sm-'.$size[1].'">
{icon}
{element}
<!-- BEGIN label_2 -->
@ -464,7 +463,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
<span class="help-inline help-block">{error}</span>
<!-- END error -->
</div>
<div class="col-sm-2">
<div class="col-sm-'.$size[2].'">
<!-- BEGIN label_3 -->
{label_3}
<!-- END label_3 -->

@ -536,22 +536,7 @@ class HTML_QuickForm_group extends HTML_QuickForm_element
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$size = array(2, 8, 2);
} else {
if (is_array($size)) {
if (count($size) == 1) {
$size = array(2, intval($size[0]), 2);
} elseif (count($size) != 3) {
$size = array(2, 8, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:

@ -141,7 +141,7 @@ class HTML_QuickForm_radio extends HTML_QuickForm_input
HTML_QuickForm_input::toHtml().
''.
$this->_text .
'</label>&nbsp;&nbsp;
'</label>
</div>';
return $label;
}

@ -1,5 +1,4 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Class to dynamically create an HTML SELECT
@ -618,22 +617,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$size = array(2, 8, 2);
} else {
if (is_array($size)) {
if (count($size) == 1) {
$size = array(2, intval($size[0]), 2);
} elseif (count($size) != 3) {
$size = array(2, 8, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
$size = $this->calculateSize();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:

@ -33,8 +33,6 @@
*/
class HTML_QuickForm_text extends HTML_QuickForm_input
{
private $inputSize;
/**
* Class constructor
*
@ -109,28 +107,8 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
*/
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
} else {
if (is_array($size)) {
if (count($size) != 3) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
}
}
$size = $this->calculateSize();
$attributes = $this->getAttributes();
switch ($layout) {
case FormValidator::LAYOUT_INLINE:
@ -193,22 +171,6 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
}
}
/**
* @return null
*/
public function getInputSize()
{
return $this->inputSize;
}
/**
* @param null $inputSize
*/
public function setInputSize($inputSize)
{
$this->inputSize = $inputSize;
}
/**
* Sets size of text field
*

@ -174,8 +174,8 @@ class SessionManager
global $_configuration;
// Check portal limits
$accessUrlId = empty($accessUrlId) && api_get_multiple_access_url()
? api_get_current_access_url_id()
$accessUrlId = api_is_multiple_url_enabled()
? (empty($accessUrlId) ? api_get_current_access_url_id() : (int) $accessUrlId)
: 1;
if (is_array($_configuration[$accessUrlId]) &&
@ -466,33 +466,33 @@ class SessionManager
}
/**
* Gets the admin session list callback of the session/session_list.php page.
* Get session list for a session admin or platform admin.
*
* @param array $options order and limit keys
* @param bool $get_count Whether to get all the results or only the count
* @param array $columns
* @param array $extraFieldsToLoad
* @param int $userId User Id for the session admin.
* @param array $options Optional. Order and limit keys.
* @param bool $getCount Optional. Whether to get all the results or only the count.
* @param array $columns Optional. Columns from jqGrid.
*
* @return mixed Integer for number of rows, or array of results
* @assert ([],true) !== false
* @return array
*/
public static function get_sessions_admin(
public static function getSessionsForAdmin(
$userId,
$options = [],
$get_count = false,
$columns = [],
$extraFieldsToLoad = []
$getCount = false,
$columns = []
) {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tblSession = Database::get_main_table(TABLE_MAIN_SESSION);
$sessionCategoryTable = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$where = 'WHERE 1 = 1 ';
$user_id = api_get_user_id();
$userId = (int) $userId;
if (!api_is_platform_admin()) {
if (api_is_session_admin() &&
api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
) {
$where .= " AND s.session_admin_id = $user_id ";
$where .= " AND s.session_admin_id = $userId ";
}
}
@ -500,13 +500,14 @@ class SessionManager
api_is_teacher() &&
api_get_setting('allow_teachers_to_create_sessions') == 'true'
) {
$where .= " AND s.id_coach = $user_id ";
$where .= " AND s.id_coach = $userId ";
}
$extra_field = new ExtraFieldModel('session');
$conditions = $extra_field->parseConditions($options);
$inject_joins = $conditions['inject_joins'];
$extraFieldModel = new ExtraFieldModel('session');
$conditions = $extraFieldModel->parseConditions($options);
$sqlInjectJoins = $conditions['inject_joins'];
$where .= $conditions['where'];
$inject_where = $conditions['inject_where'];
$sqlInjectWhere = $conditions['inject_where'];
$inject_extra_fields = $conditions['inject_extra_fields'];
$order = $conditions['order'];
$limit = $conditions['limit'];
@ -514,7 +515,7 @@ class SessionManager
$isMakingOrder = false;
$showCountUsers = false;
if ($get_count == true) {
if ($getCount == true) {
$select = " SELECT count(DISTINCT s.id) as total_rows";
} else {
if (!empty($columns['column_model'])) {
@ -550,7 +551,7 @@ class SessionManager
$isFilteringSessionCategoryWithName = strpos($where, 'sc.name') !== false;
if ($isMakingOrder || $isFilteringSessionCategory || $isFilteringSessionCategoryWithName) {
$inject_joins .= " LEFT JOIN $sessionCategoryTable sc ON s.session_category_id = sc.id ";
$sqlInjectJoins .= " LEFT JOIN $sessionCategoryTable sc ON s.session_category_id = sc.id ";
if ($isFilteringSessionCategory) {
$where = str_replace('category_name', 'sc.name', $where);
@ -562,28 +563,31 @@ class SessionManager
}
if ($showCountUsers) {
$table = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$inject_joins .= " LEFT JOIN $table su ON (su.session_id = s.id)";
$tblSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$sqlInjectJoins .= " LEFT JOIN $tblSessionRelUser su ON (su.session_id = s.id)";
}
$query = "$select FROM $tbl_session s $inject_joins $where $inject_where";
$query = "$select FROM $tblSession s $sqlInjectJoins $where $sqlInjectWhere";
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 ($access_url_id != -1) {
$where .= " AND ar.access_url_id = $access_url_id ";
$tblAccessUrlRelSession = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$accessUrlId = api_get_current_access_url_id();
if ($accessUrlId != -1) {
$where .= " AND ar.access_url_id = $accessUrlId ";
$query = "$select
FROM $tbl_session s $inject_joins
INNER JOIN $table_access_url_rel_session ar
ON (ar.session_id = s.id) $where";
FROM $tblSession s $sqlInjectJoins
INNER JOIN $tblAccessUrlRelSession ar
ON (ar.session_id = s.id) $where";
}
}
if ($showCountUsers) {
$query .= ' GROUP by s.id';
}
$allowOrder = api_get_configuration_value('session_list_order');
if ($allowOrder) {
$order = ' ORDER BY position ASC';
}
@ -592,6 +596,52 @@ class SessionManager
$query .= $limit;
$result = Database::query($query);
$sessions = Database::store_result($result, 'ASSOC');
if ($getCount) {
return $sessions[0]['total_rows'];
}
return $sessions;
}
/**
* Gets the admin session list callback of the session/session_list.php page.
*
* @param array $options order and limit keys
* @param bool $getCount Whether to get all the results or only the count
* @param array $columns
* @param array $extraFieldsToLoad
*
* @return mixed Integer for number of rows, or array of results
* @assert ([],true) !== false
*/
public static function formatSessionsAdminForGrid(
$options = [],
$getCount = false,
$columns = [],
$extraFieldsToLoad = []
) {
$showCountUsers = false;
if (!$getCount && !empty($columns['column_model'])) {
foreach ($columns['column_model'] as $column) {
if ($column['name'] == 'users') {
$showCountUsers = true;
}
}
}
$userId = api_get_user_id();
$sessions = self::getSessionsForAdmin($userId, $options, $getCount, $columns);
if ($getCount) {
return (int) $sessions;
}
$formattedSessions = [];
$categories = self::get_all_session_category();
$orderedCategories = [];
if (!empty($categories)) {
@ -599,119 +649,91 @@ class SessionManager
$orderedCategories[$category['id']] = $category['name'];
}
}
$formatted_sessions = [];
if (Database::num_rows($result)) {
$sessions = Database::store_result($result, 'ASSOC');
if ($get_count) {
return $sessions[0]['total_rows'];
$activeIcon = Display::return_icon('accept.png', get_lang('Active'));
$inactiveIcon = Display::return_icon('error.png', get_lang('Inactive'));
foreach ($sessions as $session) {
if ($showCountUsers) {
$session['users'] = self::get_users_by_session($session['id'], 0, true);
}
$url = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session['id'];
if (api_is_drh() || $extraFieldsToLoad) {
$url = api_get_path(WEB_PATH).'session/'.$session['id'].'/about/';
}
$activeIcon = Display::return_icon(
'accept.png',
get_lang('Active'),
[],
ICON_SIZE_SMALL
);
$inactiveIcon = Display::return_icon(
'error.png',
get_lang('Inactive'),
[],
ICON_SIZE_SMALL
);
$session['name'] = Display::url($session['name'], $url);
foreach ($sessions as $session) {
$session_id = $session['id'];
if ($showCountUsers) {
$session['users'] = self::get_users_by_session(
if (!empty($extraFieldsToLoad)) {
foreach ($extraFieldsToLoad as $field) {
$extraFieldValue = new ExtraFieldValue('session');
$fieldData = $extraFieldValue->getAllValuesByItemAndField(
$session['id'],
0,
true
$field['id']
);
}
$url = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session['id'];
if (api_is_drh()) {
$url = api_get_path(WEB_CODE_PATH).'session/about.php?session_id='.$session['id'];
}
if (api_is_platform_admin()) {
$url = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session['id'];
}
if ($extraFieldsToLoad) {
$url = api_get_path(WEB_CODE_PATH).'session/about.php?session_id='.$session['id'];
}
$session['name'] = Display::url($session['name'], $url);
if (!empty($extraFieldsToLoad)) {
foreach ($extraFieldsToLoad as $field) {
$extraFieldValue = new ExtraFieldValue('session');
$fieldData = $extraFieldValue->getAllValuesByItemAndField(
$session['id'],
$field['id']
);
$fieldDataArray = [];
$fieldDataToString = '';
if (!empty($fieldData)) {
foreach ($fieldData as $data) {
$fieldDataArray[] = $data['value'];
}
$fieldDataToString = implode(', ', $fieldDataArray);
$fieldDataArray = [];
$fieldDataToString = '';
if (!empty($fieldData)) {
foreach ($fieldData as $data) {
$fieldDataArray[] = $data['value'];
}
$session[$field['variable']] = $fieldDataToString;
$fieldDataToString = implode(', ', $fieldDataArray);
}
$session[$field['variable']] = $fieldDataToString;
}
}
if (isset($session['session_active']) && $session['session_active'] == 1) {
$session['session_active'] = $activeIcon;
} else {
$session['session_active'] = $inactiveIcon;
}
if (isset($session['session_active']) && $session['session_active'] == 1) {
$session['session_active'] = $activeIcon;
} else {
$session['session_active'] = $inactiveIcon;
}
$session = self::convert_dates_to_local($session, true);
$session = self::convert_dates_to_local($session, true);
switch ($session['visibility']) {
case SESSION_VISIBLE_READ_ONLY: //1
$session['visibility'] = get_lang('ReadOnly');
break;
case SESSION_VISIBLE: //2
case SESSION_AVAILABLE: //4
$session['visibility'] = get_lang('Visible');
break;
case SESSION_INVISIBLE: //3
$session['visibility'] = api_ucfirst(get_lang('Invisible'));
break;
switch ($session['visibility']) {
case SESSION_VISIBLE_READ_ONLY: //1
$session['visibility'] = get_lang('ReadOnly');
break;
case SESSION_VISIBLE: //2
case SESSION_AVAILABLE: //4
$session['visibility'] = get_lang('Visible');
break;
case SESSION_INVISIBLE: //3
$session['visibility'] = api_ucfirst(get_lang('Invisible'));
break;
}
// Cleaning double selects.
foreach ($session as $key => &$value) {
if (isset($optionsByDouble[$key]) || isset($optionsByDouble[$key.'_second'])) {
$options = explode('::', $value);
}
$original_key = $key;
if (strpos($key, '_second') !== false) {
$key = str_replace('_second', '', $key);
}
// Cleaning double selects.
foreach ($session as $key => &$value) {
if (isset($options_by_double[$key]) || isset($options_by_double[$key.'_second'])) {
$options = explode('::', $value);
}
$original_key = $key;
if (strpos($key, '_second') === false) {
if (isset($optionsByDouble[$key]) &&
isset($options[0]) &&
isset($optionsByDouble[$key][$options[0]])
) {
if (strpos($original_key, '_second') === false) {
$value = $optionsByDouble[$key][$options[0]]['option_display_text'];
} else {
$key = str_replace('_second', '', $key);
}
if (isset($options_by_double[$key])) {
if (isset($options[0])) {
if (isset($options_by_double[$key][$options[0]])) {
if (strpos($original_key, '_second') === false) {
$value = $options_by_double[$key][$options[0]]['option_display_text'];
} else {
$value = $options_by_double[$key][$options[1]]['option_display_text'];
}
}
}
$value = $optionsByDouble[$key][$options[1]]['option_display_text'];
}
}
$categoryName = isset($orderedCategories[$session['session_category_id']]) ? $orderedCategories[$session['session_category_id']] : '';
$session['category_name'] = $categoryName;
$formatted_sessions[] = $session;
}
$categoryName = isset($orderedCategories[$session['session_category_id']])
? $orderedCategories[$session['session_category_id']]
: '';
$session['category_name'] = $categoryName;
$formattedSessions[] = $session;
}
return $formatted_sessions;
return $formattedSessions;
}
/**
@ -1964,10 +1986,7 @@ class SessionManager
false
);
// Variables for default template
$tplContent->assign(
'complete_name',
stripslashes($user_info['complete_name'])
);
$tplContent->assign('complete_name', stripslashes($user_info['complete_name']));
$tplContent->assign('session_name', $session->getName());
$tplContent->assign(
'session_coach',
@ -2015,27 +2034,7 @@ class SessionManager
if ($empty_users) {
foreach ($existingUsers as $existing_user) {
if (!in_array($existing_user, $userList)) {
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE
session_id = $sessionId AND
c_id = $courseId AND
user_id = $existing_user AND
status = 0 ";
$result = Database::query($sql);
Event::addEvent(
LOG_SESSION_DELETE_USER_COURSE,
LOG_USER_ID,
$existing_user,
api_get_utc_datetime(),
api_get_user_id(),
$courseId,
$sessionId
);
if (Database::affected_rows($result)) {
$nbr_users--;
}
self::unSubscribeUserFromCourseSession($existing_user, $courseId, $sessionId);
}
}
}
@ -2265,12 +2264,12 @@ class SessionManager
$statusCondition = null;
if (isset($status) && !is_null($status)) {
$status = intval($status);
$status = (int) $status;
$statusCondition = " AND status = $status";
}
foreach ($userList as $userId) {
$userId = intval($userId);
$userId = (int) $userId;
$sql = "DELETE FROM $table
WHERE
session_id = $sessionId AND
@ -2279,6 +2278,16 @@ class SessionManager
$statusCondition
";
Database::query($sql);
Event::addEvent(
LOG_SESSION_DELETE_USER_COURSE,
LOG_USER_ID,
$userId,
api_get_utc_datetime(),
api_get_user_id(),
$courseId,
$sessionId
);
}
if ($updateTotal) {
@ -2441,7 +2450,7 @@ class SessionManager
WHERE
session_id = $session_id AND
user_id = $user_id AND
relation_type <> ".SESSION_RELATION_TYPE_RRHH."";
relation_type <> ".SESSION_RELATION_TYPE_RRHH;
$result = Database::query($sql);
$return = Database::affected_rows($result);
@ -2451,39 +2460,65 @@ class SessionManager
WHERE id = $session_id ";
Database::query($sql);
Event::addEvent(
LOG_SESSION_DELETE_USER,
LOG_USER_ID,
$user_id,
api_get_utc_datetime(),
api_get_user_id(),
null,
$session_id
);
// Get the list of courses related to this session
$course_list = self::get_course_list_by_session_id($session_id);
if (!empty($course_list)) {
foreach ($course_list as $course) {
$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";
$result = Database::query($sql);
Event::addEvent(
LOG_SESSION_DELETE_USER_COURSE,
LOG_USER_ID,
$user_id,
api_get_utc_datetime(),
api_get_user_id(),
$courseId,
$session_id
);
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";
Database::query($sql);
}
self::unSubscribeUserFromCourseSession($user_id, $course['id'], $session_id);
}
}
return true;
}
/**
* @param int $user_id
* @param int $courseId
* @param int $session_id
*/
public static function unSubscribeUserFromCourseSession($user_id, $courseId, $session_id)
{
$user_id = (int) $user_id;
$courseId = (int) $courseId;
$session_id = (int) $session_id;
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
// 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";
$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";
Database::query($sql);
}
Event::addEvent(
LOG_SESSION_DELETE_USER_COURSE,
LOG_USER_ID,
$user_id,
api_get_utc_datetime(),
api_get_user_id(),
$courseId,
$session_id
);
}
/**
* Subscribes courses to the given session and optionally (default)
* unsubscribe previous users.
@ -7882,7 +7917,7 @@ SQL;
$form->addElement('html', '<div id="advanced_params_options" style="display:none">');
if (empty($sessionId)) {
$sessions = SessionManager::get_sessions_admin();
$sessions = SessionManager::formatSessionsAdminForGrid();
$sessionList = [];
$sessionList[] = '';
foreach ($sessions as $session) {
@ -9136,6 +9171,103 @@ SQL;
return $courseIds;
}
/**
* @param int $userId
* @param int $sessionId
* @param ExtraFieldValue $extraFieldValue
* @param string $collapsableLink
*
* @return array
*/
public static function getCollapsableData($userId, $sessionId, $extraFieldValue, $collapsableLink)
{
$collapsed = 0;
// Get default collapsed value in extra field
$value = $extraFieldValue->get_values_by_handler_and_field_variable($sessionId, 'collapsed');
if (!empty($value) && isset($value['value'])) {
$collapsed = $value['value'];
}
$userRelSession = Sessionmanager::getUserSession($userId, $sessionId);
if ($userRelSession) {
if (isset($userRelSession['collapsed']) && $userRelSession['collapsed'] != '') {
$collapsed = $userRelSession['collapsed'];
}
} else {
return ['collapsed' => $collapsed, 'collapsable_link' => '&nbsp;'];
}
$link = $collapsableLink.'&session_id='.$sessionId.'&value=1';
$image = '<i class="fa fa-folder-open"></i>';
if ($collapsed == 1) {
$link = $collapsableLink.'&session_id='.$sessionId.'&value=0';
$image = '<i class="fa fa-folder"></i>';
}
$link = Display::url(
$image,
$link
);
return ['collapsed' => $collapsed, 'collapsable_link' => $link];
}
/**
* Converts "start date" and "end date" to "From start date to end date" string.
*
* @param string $startDate
* @param string $endDate
* @param bool $showTime
* @param bool $dateHuman
*
* @return string
*/
public static function convertSessionDateToString($startDate, $endDate, $showTime, $dateHuman)
{
// api_get_local_time returns empty if date is invalid like 0000-00-00 00:00:00
$startDateToLocal = api_get_local_time(
$startDate,
null,
null,
true,
$showTime,
$dateHuman
);
$endDateToLocal = api_get_local_time(
$endDate,
null,
null,
true,
$showTime,
$dateHuman
);
$format = $showTime ? DATE_TIME_FORMAT_LONG_24H : DATE_FORMAT_LONG_NO_DAY;
$result = '';
if (!empty($startDateToLocal) && !empty($endDateToLocal)) {
$result = sprintf(
get_lang('FromDateXToDateY'),
api_format_date($startDateToLocal, $format),
api_format_date($endDateToLocal, $format)
);
} else {
if (!empty($startDateToLocal)) {
$result = get_lang('From').' '.api_format_date($startDateToLocal, $format);
}
if (!empty($endDateToLocal)) {
$result = get_lang('Until').' '.api_format_date($endDateToLocal, $format);
}
}
if (empty($result)) {
$result = get_lang('NoTimeLimits');
}
return $result;
}
/**
* @param int $id
*
@ -9227,58 +9359,6 @@ SQL;
}
}
/**
* Converts "start date" and "end date" to "From start date to end date" string.
*
* @param string $startDate
* @param string $endDate
* @param bool $showTime
* @param bool $dateHuman
*
* @return string
*/
private static function convertSessionDateToString($startDate, $endDate, $showTime, $dateHuman)
{
// api_get_local_time returns empty if date is invalid like 0000-00-00 00:00:00
$startDateToLocal = api_get_local_time(
$startDate,
null,
null,
true,
$showTime,
$dateHuman
);
$endDateToLocal = api_get_local_time(
$endDate,
null,
null,
true,
$showTime,
$dateHuman
);
$result = '';
if (!empty($startDateToLocal) && !empty($endDateToLocal)) {
$result = sprintf(
get_lang('FromDateXToDateY'),
api_format_date($startDateToLocal, DATE_TIME_FORMAT_LONG_24H),
api_format_date($endDateToLocal, DATE_TIME_FORMAT_LONG_24H)
);
} else {
if (!empty($startDateToLocal)) {
$result = get_lang('From').' '.api_format_date($startDateToLocal, DATE_TIME_FORMAT_LONG_24H);
}
if (!empty($endDateToLocal)) {
$result = get_lang('Until').' '.api_format_date($endDateToLocal, DATE_TIME_FORMAT_LONG_24H);
}
}
if (empty($result)) {
$result = get_lang('NoTimeLimits');
}
return $result;
}
/**
* @param array $listA
* @param array $listB

@ -597,25 +597,29 @@ class SkillRelUser extends Model
*
* @param int $userId The user id
* @param int $skillId The skill id
* @param int $courseId The course id
* @param int $courseId Optional. The course id
* @param int $sessionId Optional. The session id
*
* @return array The relation data. Otherwise return false
*/
public function getByUserAndSkill($userId, $skillId, $courseId, $sessionId = 0)
public function getByUserAndSkill($userId, $skillId, $courseId = 0, $sessionId = 0)
{
$where = [
'user_id = ? AND skill_id = ? AND course_id = ? AND session_id = ?' => [
intval($userId),
intval($skillId),
intval($courseId),
$sessionId ? intval($sessionId) : null,
],
];
$sql = "SELECT * FROM {$this->table} WHERE user_id = %d AND skill_id = %d ";
if ($courseId > 0) {
$sql .= "AND course_id = %d ".api_get_session_condition($sessionId, true);
}
return Database::select('*', $this->table, [
'where' => $where,
], 'first');
$sql = sprintf(
$sql,
$userId,
$skillId,
$courseId
);
$result = Database::query($sql);
return Database::fetch_assoc($result);
}
/**
@ -835,10 +839,10 @@ class Skill extends Model
$item = '';
if ($showBadge) {
$item = $skill[$imageSize];
$item = '<div class="item">'.$skill[$imageSize].'</div>';
}
$name = $skill['name'];
$name = '<div class="caption">'.$skill['name'].'</div>';
if (!empty($skill['short_code'])) {
$name = $skill['short_code'];
}
@ -1384,7 +1388,6 @@ class Skill extends Model
public function getUserSkillsTable($userId, $courseId = 0, $sessionId = 0, $addTitle = true)
{
$skills = $this->getUserSkills($userId, true, $courseId, $sessionId);
$courseTempList = [];
$tableRows = [];
$skillParents = [];
@ -1414,6 +1417,7 @@ class Skill extends Model
'skill_badge' => $resultData['img_mini'],
'skill_name' => self::translateName($resultData['name']),
'short_code' => $resultData['short_code'],
'skill_url' => $resultData['url'],
'achieved_at' => api_get_local_time($resultData['acquired_skill_at']),
'course_image' => '',
'course_name' => '',

File diff suppressed because it is too large Load Diff

@ -142,6 +142,11 @@ class SortableTable extends HTML_Table
$this->column = Session::read($this->param_prefix.'column', $default_column);
$this->column = isset($_GET[$this->param_prefix.'column']) ? (int) $_GET[$this->param_prefix.'column'] : $this->column;
$defaultRow = api_get_configuration_value('table_default_row');
if (!empty($defaultRow)) {
$default_items_per_page = $defaultRow;
}
// Default direction.
if (in_array(strtoupper($default_order_direction), ['ASC', 'DESC'])) {
$this->direction = $default_order_direction;
@ -688,6 +693,12 @@ class SortableTable extends HTML_Table
}
$result[] = '<select class="custom-select" name="'.$this->param_prefix.'per_page" onchange="javascript: this.form.submit();">';
$list = [10, 20, 50, 100, 500, 1000];
$rowList = api_get_configuration_value('table_row_list');
if (!empty($rowList) && isset($rowList['options'])) {
$list = $rowList['options'];
}
foreach ($list as $nr) {
if ($total_number_of_items <= $nr) {
break;
@ -1160,6 +1171,7 @@ class SortableTableFromArrayConfig extends SortableTable
$this->column_show = $column_show;
$this->column_order = $column_order;
$this->doc_filter = $doc_filter;
parent::__construct(
$tablename,
null,

@ -305,7 +305,7 @@ class Statistics
} else {
if (!empty($row[2])) {
$originalData = str_replace('\\', '', $row[2]);
$row[2] = unserialize($originalData);
$row[2] = UnserializeApi::unserialize('not_allowed_classes', $originalData);
if (is_array($row[2]) && !empty($row[2])) {
$row[2] = implode_with_key(', ', $row[2]);
} else {
@ -1130,7 +1130,7 @@ class Statistics
{
$chartCode = '
<script>
$(document).ready(function() {
$(function() {
$.ajax({
url: "'.$url.'",
type: "POST",

@ -436,7 +436,7 @@ class Tracking
$score = $row['myscore'];
$time_for_total = $row['mytime'];
if (api_get_configuration_value('lp_minimum_time')) {
if (self::minimunTimeAvailable($session_id, $course_id)) {
$timeCourse = self::getCalculateTime($user_id, $course_id, $session_id);
Session::write('trackTimeCourse', $timeCourse);
$lp_time = $timeCourse[TOOL_LEARNPATH];
@ -1667,7 +1667,7 @@ class Tracking
return 0;
}
if (api_get_configuration_value('lp_minimum_time')) {
if (self::minimunTimeAvailable($session_id, $courseId)) {
$courseTime = self::getCalculateTime($user_id, $courseId, $session_id);
$time = isset($courseTime['total_time']) ? $courseTime['total_time'] : 0;
@ -1845,7 +1845,7 @@ class Tracking
$courseId = (int) $courseId;
$session_id = (int) $session_id;
if (api_get_configuration_value('lp_minimum_time')) {
if (self::minimunTimeAvailable($session_id, $courseId)) {
$tbl_track_e_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$sql = 'SELECT access_date
FROM '.$tbl_track_e_access.'
@ -1917,7 +1917,7 @@ class Tracking
$session_id = (int) $session_id;
$courseId = $courseInfo['real_id'];
if (api_get_configuration_value('lp_minimum_time')) {
if (self::minimunTimeAvailable($session_id, $courseId)) {
// Show the last date on which the user acceed the session when it was active
$where_condition = '';
$userInfo = api_get_user_info($student_id);
@ -2877,10 +2877,6 @@ class Tracking
$condition_user1 AND
session_id = $session_id
GROUP BY lp_id, user_id";
if ($debug) {
echo 'get LP results';
var_dump($sql);
}
$rs_last_lp_view_id = Database::query($sql);
$global_result = 0;
@ -3533,7 +3529,7 @@ class Tracking
}
}
// Then, courses where $coach_id is coach of the session //
// Then, courses where $coach_id is coach of the session
$sql = 'SELECT session_course_user.user_id
FROM '.$tbl_session_course_user.' as session_course_user
INNER JOIN '.$tbl_session_user.' sru
@ -3590,7 +3586,7 @@ class Tracking
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$students = [];
// At first, courses where $coach_id is coach of the course //
// At first, courses where $coach_id is coach of the course
$sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
WHERE session_id="'.$id_session.'" AND user_id='.$coach_id.' AND status=2';
$result = Database::query($sql);
@ -3644,7 +3640,7 @@ class Tracking
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
// At first, courses where $coach_id is coach of the course //
// At first, courses where $coach_id is coach of the course
$sql = 'SELECT 1 FROM '.$tbl_session_course_user.'
WHERE user_id='.$coach_id.' AND status=2';
$result = Database::query($sql);
@ -3772,7 +3768,7 @@ class Tracking
/**
* Get sessions coached by user.
*
* @param $coach_id
* @param $coach_id
* @param int $start
* @param int $limit
* @param bool $getCount
@ -3876,7 +3872,7 @@ class Tracking
$sessions = [];
while ($row = Database::fetch_array($rs)) {
if ($row['access_start_date'] == '0000-00-00 00:00:00') {
if ($row['access_start_date'] === '0000-00-00 00:00:00') {
$row['access_start_date'] = null;
}
@ -4101,7 +4097,6 @@ class Tracking
return $row['count'];
}
require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php';
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$courseInfo = api_get_course_info($courseCode);
@ -5592,7 +5587,7 @@ class Tracking
$html .= '<div class="table-responsive">';
$html .= '<table class="table table-striped table-hover">';
//Course details
// Course details
$html .= '
<thead>
<tr>
@ -5968,8 +5963,7 @@ class Tracking
*/
public static function generate_session_exercise_graph($names, $my_results, $average)
{
$cdnChartJs = 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js';
$html .= Display::tag('script', '', ['src' => $cdnChartJs]);
$html = api_get_js('chartjs/Chart.js');
$canvas = Display::tag('canvas', '', ['id' => 'session_graph_chart']);
$html .= Display::tag('div', $canvas, ['style' => 'width:100%']);
$jsStr = " var data = {
@ -6046,7 +6040,7 @@ class Tracking
}
}
//Getting best result
// Getting best result
rsort($my_exercise_result_array);
$my_exercise_result = 0;
if (isset($my_exercise_result_array[0])) {
@ -6087,7 +6081,7 @@ class Tracking
}
}
//Fix to remove the data of the user with my data
// Fix to remove the data of the user with my data
for ($i = 0; $i <= count($my_final_array); $i++) {
if (!empty($my_final_array[$i])) {
$my_final_array[$i] = $final_array[$i] + 1; //Add my result
@ -6772,7 +6766,8 @@ class Tracking
user_id = $userId AND
c_id = $courseId AND
session_id = $sessionId AND
login_as = 0";
login_as = 0 AND current_id <> 0";
$res = Database::query($sql);
$reg = [];
while ($row = Database::fetch_assoc($res)) {
@ -6836,23 +6831,13 @@ class Tracking
break;
case TOOL_LEARNPATH:
if ($item['tool_id'] != $beforeItem['tool_id']) {
continue;
break;
}
if (!isset($lpTime[$item['tool_id']])) {
$lpTime[$item['tool_id']] = 0;
}
$lpTime[$item['tool_id']] += $partialTime;
if ($item['tool_id'] == 51) {
//$counter++;
//var_dump($beforeItem, $item);
/*var_dump(
api_get_utc_datetime($item['date_reg']),
api_get_utc_datetime($beforeItem['date_reg'])
);*/
/*var_dump(
$counter.'-'.$beforeItem['id'].'-'.$item['id'].'-'.$partialTime.'-'.api_time_to_hms($lpTime[$item['tool_id']])
);*/
}
break;
case TOOL_QUIZ:
if (!isset($lpTime[$item['action_details']])) {
@ -7673,7 +7658,7 @@ class TrackingCourseLog
$user_ids = array_map('intval', $user_ids);
$condition_user = " WHERE user.user_id IN (".implode(',', $user_ids).") ";
} else {
$user_ids = intval($user_ids);
$user_ids = (int) $user_ids;
$condition_user = " WHERE user.user_id = $user_ids ";
}
@ -7711,9 +7696,9 @@ class TrackingCourseLog
$direction = 'ASC';
}
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
$column = (int) $column;
$from = (int) $from;
$number_of_items = (int) $number_of_items;
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";

@ -2072,11 +2072,17 @@ class UserGroup extends Model
$tbl_group = $this->table;
$user_id = (int) $user_id;
if ($relation_type == 0) {
if ($relationType == 0) {
$relationCondition = '';
} else {
$relation_type = (int) $relation_type;
$relationCondition = " AND gu.relation_type = $relation_type ";
if (is_array($relationType)) {
$relationType = array_map('intval', $relationType);
$relationType = implode("','", $relationType);
$relationCondition = " AND ( gu.relation_type IN ('$relationType')) ";
} else {
$relationType = (int) $relationType;
$relationCondition = " AND gu.relation_type = $relationType ";
}
}
$sql = "SELECT
@ -2094,6 +2100,7 @@ class UserGroup extends Model
$relationCondition
ORDER BY created_at DESC ";
$result = Database::query($sql);
$array = [];
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {

@ -2630,14 +2630,12 @@ class UserManager
$splitMultiple = false,
$fieldFilter = null
) {
// A sanity check.
$user_id = (int) $user_id;
if (empty($user_id)) {
$user_id = 0;
} else {
if ($user_id != strval(intval($user_id))) {
return [];
}
return [];
}
$extra_data = [];
$t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
$t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
@ -2662,7 +2660,7 @@ class UserManager
}
}
$sql .= " ORDER BY f.field_order";
$sql .= ' ORDER BY f.field_order';
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
@ -2968,7 +2966,8 @@ class UserManager
$user_id,
$is_time_over = true,
$ignore_visibility_for_admins = false,
$ignoreTimeLimit = false
$ignoreTimeLimit = false,
$getCount = false
) {
if ($user_id != strval(intval($user_id))) {
return [];
@ -2986,22 +2985,27 @@ class UserManager
// LEFT JOIN is used for session_rel_course_rel_user because an inner
// join would not catch session-courses where the user is general
// session coach but which do not have students nor coaches registered
$dqlSelect = " COUNT(DISTINCT s.id) ";
if (!$getCount) {
$dqlSelect = " DISTINCT
s.id,
s.name,
s.accessStartDate AS access_start_date,
s.accessEndDate AS access_end_date,
s.duration,
sc.id AS session_category_id,
sc.name AS session_category_name,
sc.dateStart AS session_category_date_start,
sc.dateEnd AS session_category_date_end,
s.coachAccessStartDate AS coach_access_start_date,
s.coachAccessEndDate AS coach_access_end_date,
CASE WHEN s.accessEndDate IS NULL THEN 1 ELSE 0 END HIDDEN _isFieldNull
$position
";
}
// master changes
$dql = "SELECT DISTINCT
s.id,
s.name,
s.accessStartDate AS access_start_date,
s.accessEndDate AS access_end_date,
s.duration,
sc.id AS session_category_id,
sc.name AS session_category_name,
sc.dateStart AS session_category_date_start,
sc.dateEnd AS session_category_date_end,
s.coachAccessStartDate AS coach_access_start_date,
s.coachAccessEndDate AS coach_access_end_date,
CASE WHEN s.accessEndDate IS NULL THEN 1 ELSE 0 END HIDDEN _isFieldNull
$position
$dql = "SELECT $dqlSelect
FROM ChamiloCoreBundle:Session AS s
LEFT JOIN ChamiloCoreBundle:SessionRelCourseRelUser AS scu WITH scu.session = s
INNER JOIN ChamiloCoreBundle:AccessUrlRelSession AS url WITH url.session = s.id
@ -3066,6 +3070,10 @@ class UserManager
)
;
if ($getCount) {
return $dqlStudent->getSingleScalarResult() + $dqlCoach->getSingleScalarResult();
}
$sessionDataStudent = $dqlStudent->getResult();
$sessionDataCoach = $dqlCoach->getResult();
@ -3216,6 +3224,7 @@ class UserManager
'courses' => $courseList,
'collapsed' => $collapsed,
'collapsable_link' => $collapsedAction,
'duration' => $row['duration'],
];
}
@ -6434,6 +6443,185 @@ SQL;
return (int) $row['count'];
}
/**
* @param array $userInfo
* @param int $searchYear
*
* @throws Exception
*
* @return array
*/
public static function getSubscribedSessionsByYear(array $userInfo, $searchYear)
{
$timezone = new DateTimeZone(api_get_timezone());
$sessions = [];
if (DRH == $userInfo['status']) {
$sessions = SessionManager::get_sessions_followed_by_drh($userInfo['id']);
} elseif (api_is_platform_admin(true)) {
$sessions = SessionManager::getSessionsForAdmin($userInfo['id']);
} else {
$sessionsByCategory = self::get_sessions_by_category($userInfo['id'], false, true, true);
$sessionsByCategory = array_column($sessionsByCategory, 'sessions');
foreach ($sessionsByCategory as $sessionsInCategory) {
$sessions = array_merge($sessions, $sessionsInCategory);
}
}
$sessions = array_map(
function ($sessionInfo) {
if (!isset($sessionInfo['session_id'])) {
$sessionInfo['session_id'] = $sessionInfo['id'];
}
if (!isset($sessionInfo['session_name'])) {
$sessionInfo['session_name'] = $sessionInfo['name'];
}
return $sessionInfo;
},
$sessions
);
$calendarSessions = [];
foreach ($sessions as $sessionInfo) {
if (!empty($sessionInfo['duration'])) {
$courseAccess = CourseManager::getFirstCourseAccessPerSessionAndUser(
$sessionInfo['session_id'],
$userInfo['id']
);
if (empty($courseAccess)) {
continue;
}
$firstAcessDate = new DateTime(api_get_local_time($courseAccess['login_course_date']), $timezone);
$lastAccessDate = clone $firstAcessDate;
$lastAccessDate->modify("+{$sessionInfo['duration']} days");
$firstAccessYear = (int) $firstAcessDate->format('Y');
$lastAccessYear = (int) $lastAccessDate->format('Y');
if ($firstAccessYear <= $searchYear && $lastAccessYear >= $searchYear) {
$calendarSessions[$sessionInfo['session_id']] = [
'name' => $sessionInfo['session_name'],
'access_start_date' => $firstAcessDate->format('Y-m-d h:i:s'),
'access_end_date' => $lastAccessDate->format('Y-m-d h:i:s'),
];
}
continue;
}
$accessStartDate = !empty($sessionInfo['access_start_date'])
? new DateTime(api_get_local_time($sessionInfo['access_start_date']), $timezone)
: null;
$accessEndDate = !empty($sessionInfo['access_end_date'])
? new DateTime(api_get_local_time($sessionInfo['access_end_date']), $timezone)
: null;
$accessStartYear = $accessStartDate ? (int) $accessStartDate->format('Y') : 0;
$accessEndYear = $accessEndDate ? (int) $accessEndDate->format('Y') : 0;
$isValid = false;
if ($accessStartYear && $accessEndYear) {
if ($accessStartYear <= $searchYear && $accessEndYear >= $searchYear) {
$isValid = true;
}
}
if ($accessStartYear && !$accessEndYear) {
if ($accessStartYear == $searchYear) {
$isValid = true;
}
}
if (!$accessStartYear && $accessEndYear) {
if ($accessEndYear == $searchYear) {
$isValid = true;
}
}
if ($isValid) {
$calendarSessions[$sessionInfo['session_id']] = [
'name' => $sessionInfo['session_name'],
'access_start_date' => $accessStartDate ? $accessStartDate->format('Y-m-d h:i:s') : null,
'access_end_date' => $accessEndDate ? $accessEndDate->format('Y-m-d h:i:s') : null,
];
}
}
return $calendarSessions;
}
/**
* Get sessions info for planification calendar.
*
* @param array $sessionsList Session list from UserManager::getSubscribedSessionsByYear
* @param int $searchYear
*
* @throws Exception
*
* @return array
*/
public static function getSessionsCalendarByYear(array $sessionsList, $searchYear)
{
$timezone = new DateTimeZone(api_get_timezone());
$calendar = [];
foreach ($sessionsList as $sessionId => $sessionInfo) {
$startDate = $sessionInfo['access_start_date']
? new DateTime(api_get_local_time($sessionInfo['access_start_date']), $timezone)
: null;
$endDate = $sessionInfo['access_end_date']
? new DateTime(api_get_local_time($sessionInfo['access_end_date']), $timezone)
: null;
$startYear = $startDate ? (int) $startDate->format('Y') : 0;
$startWeekYear = $startDate ? (int) $startDate->format('o') : 0;
$startWeek = $startDate ? (int) $startDate->format('W') : 0;
$endYear = $endDate ? (int) $endDate->format('Y') : 0;
$endWeekYear = $endDate ? (int) $endDate->format('o') : 0;
$endWeek = $endDate ? (int) $endDate->format('W') : 0;
$start = $startWeekYear < $searchYear ? 0 : $startWeek - 1;
$duration = $endWeekYear > $searchYear ? 52 - $start : $endWeek - $start;
$calendar[] = [
'id' => $sessionId,
'name' => $sessionInfo['name'],
'human_date' => SessionManager::convertSessionDateToString($startDate, $endDate, false, true),
'start_in_last_year' => $startYear < $searchYear,
'end_in_next_year' => $endYear > $searchYear,
'no_start' => !$startWeek,
'no_end' => !$endWeek,
'start' => $start,
'duration' => $duration > 0 ? $duration : 1,
];
}
usort(
$calendar,
function ($sA, $sB) {
if ($sA['start'] == $sB['start']) {
return 0;
}
if ($sA['start'] < $sB['start']) {
return -1;
}
return 1;
}
);
return $calendar;
}
/**
* Return the user's full name. Optionally with the username.
*

@ -25,7 +25,7 @@ $this_section = SECTION_COURSES;
api_protect_course_script(true);
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$(function() {
for (i=0;i<$(".actions").length;i++) {
if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {
$(".actions:eq("+i+")").hide();

@ -439,6 +439,7 @@ class aicc extends learnpath
$files_found = [];
$subdir_isset = false;
// The following loop should be stopped as soon as we found the right config files (.crs, .au, .des and .cst).
$realFileSize = 0;
foreach ($zipContentArray as $thisContent) {
if (preg_match('~.(php.*|phtml)$~i', $thisContent['filename'])) {
// If a php file is found, do not authorize (security risk).
@ -576,68 +577,11 @@ class aicc extends learnpath
if ($this->debug >= 1) {
error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir, 0);
}
$saved_dir = getcwd();
chdir($course_sys_dir.$new_dir);
$unzippingState = $zipFile->extract();
for ($j = 0; $j < count($unzippingState); $j++) {
$state = $unzippingState[$j];
// TODO: Fix relative links in html files (?)
$extension = strrchr($state["stored_filename"], '.');
//if ($this->debug > 1) { error_log('New LP - found extension '.$extension.' in '.$state['stored_filename'], 0); }
}
if (!empty($new_dir)) {
$new_dir = $new_dir.'/';
}
// Rename files, for example with \\ in it.
if ($dir = @opendir($course_sys_dir.$new_dir)) {
if ($this->debug == 1) {
error_log('New LP - Opened dir '.$course_sys_dir.$new_dir, 0);
}
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$filetype = 'file';
if (is_dir($course_sys_dir.$new_dir.$file)) {
$filetype = 'folder';
}
// TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible!
//$safe_file = api_replace_dangerous_char($file, 'strict');
$find_str = ['\\', '.php', '.phtml'];
$repl_str = ['/', '.txt', '.txt'];
$safe_file = str_replace($find_str, $repl_str, $file);
if ($safe_file != $file) {
//@rename($course_sys_dir.$new_dir, $course_sys_dir.'/'.$safe_file);
$mydir = dirname($course_sys_dir.$new_dir.$safe_file);
if (!is_dir($mydir)) {
$mysubdirs = split('/', $mydir);
$mybasedir = '/';
foreach ($mysubdirs as $mysubdir) {
if (!empty($mysubdir)) {
$mybasedir = $mybasedir.$mysubdir.'/';
if (!is_dir($mybasedir)) {
@mkdir($mybasedir, api_get_permissions_for_new_directories());
if ($this->debug == 1) {
error_log('New LP - Dir '.$mybasedir.' doesnt exist. Creating.');
}
}
}
}
}
@rename($course_sys_dir.$new_dir.$file, $course_sys_dir.$new_dir.$safe_file);
if ($this->debug == 1) {
error_log('New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file);
}
}
}
}
closedir($dir);
chdir($saved_dir);
}
$zipFile->extract(
PCLZIP_CB_PRE_EXTRACT,
'clean_up_files_in_zip'
);
} else {
return '';
}

@ -35,7 +35,8 @@ require_once __DIR__.'/../inc/global.inc.php';
// Is this needed? This is probabaly done in the header file.
$file = Session::read('file');
$oLP = unserialize(Session::read('lpobject'));
/** @var learnpath $oLP */
$oLP = UnserializeApi::unserialize('lp', Session::read('lpobject'));
$oItem = $oLP->items[$oLP->current];
if (!is_object($oItem)) {
error_log('New LP - scorm_api - Could not load oItem item', 0);

@ -63,7 +63,11 @@ if ($debug > 2) {
// Is this needed? This is probabaly done in the header file.
$file = Session::read('file');
$oLP = unserialize(Session::read('lpobject'));
/** @var learnpath $oLP */
$oLP = UnserializeApi::unserialize(
'not_allowed_classes',
Session::read('lpobject')
);
$oItem = &$oLP->items[$oLP->current];
if (!is_object($oItem)) {
error_log('New LP - aicc_hacp - Could not load oItem item', 0);

@ -2266,7 +2266,6 @@ class learnpath
switch ($row['item_type']) {
case 'quiz':
$type_quiz = false;
foreach ($list as $toc) {
if ($toc['id'] == $_SESSION['oLP']->current) {
$type_quiz = true;
@ -2363,7 +2362,7 @@ class learnpath
$isBlocked = true;
}
if (api_get_configuration_value('lp_minimum_time')) {
if (Tracking::minimunTimeAvailable($sessionId, $courseId)) {
// Block if it does not exceed minimum time
// Minimum time (in minutes) to pass the learning path
$accumulateWorkTime = self::getAccumulateWorkTimePrerequisite($prerequisite, $courseId);
@ -2495,44 +2494,46 @@ class learnpath
}
}
$subscriptionSettings = self::getSubscriptionSettings();
if ($is_visible) {
$subscriptionSettings = self::getSubscriptionSettings();
// Check if the subscription users/group to a LP is ON
if (isset($row['subscribe_users']) && $row['subscribe_users'] == 1 &&
$subscriptionSettings['allow_add_users_to_lp'] === true
) {
// Try group
$is_visible = false;
// Checking only the user visibility
$userVisibility = api_get_item_visibility(
$courseInfo,
'learnpath',
$row['id'],
$sessionId,
$student_id,
'LearnpathSubscription'
);
// Check if the subscription users/group to a LP is ON
if (isset($row['subscribe_users']) && $row['subscribe_users'] == 1 &&
$subscriptionSettings['allow_add_users_to_lp'] === true
) {
// Try group
$is_visible = false;
// Checking only the user visibility
$userVisibility = api_get_item_visibility(
$courseInfo,
'learnpath',
$row['id'],
$sessionId,
$student_id,
'LearnpathSubscription'
);
if ($userVisibility == 1) {
$is_visible = true;
} else {
$userGroups = GroupManager::getAllGroupPerUserSubscription($student_id);
if (!empty($userGroups)) {
foreach ($userGroups as $groupInfo) {
$groupId = $groupInfo['iid'];
$userVisibility = api_get_item_visibility(
$courseInfo,
'learnpath',
$row['id'],
$sessionId,
null,
'LearnpathSubscription',
$groupId
);
if ($userVisibility == 1) {
$is_visible = true;
} else {
$userGroups = GroupManager::getAllGroupPerUserSubscription($student_id);
if (!empty($userGroups)) {
foreach ($userGroups as $groupInfo) {
$groupId = $groupInfo['iid'];
$userVisibility = api_get_item_visibility(
$courseInfo,
'learnpath',
$row['id'],
$sessionId,
null,
'LearnpathSubscription',
$groupId
);
if ($userVisibility == 1) {
$is_visible = true;
break;
if ($userVisibility == 1) {
$is_visible = true;
break;
}
}
}
}
@ -7370,8 +7371,8 @@ class learnpath
case TOOL_DOCUMENT:
case TOOL_READOUT_TEXT:
$tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
$sql_doc = "SELECT path FROM ".$tbl_doc."
WHERE c_id = ".$course_id." AND iid = ".intval($row['path']);
$sql_doc = "SELECT path FROM $tbl_doc
WHERE c_id = $course_id AND iid = ".intval($row['path']);
$result = Database::query($sql_doc);
$path_file = Database::result($result, 0, 0);
$path_parts = pathinfo($path_file);
@ -9099,7 +9100,7 @@ class learnpath
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('&nbsp;{label}{element}', 'content_lp');
$form->addElement('html', '<div class="editor-lp">');
$form->addHtmlEditor('content_lp', null, null, true, $editor_config);
$form->addHtmlEditor('content_lp', null, null, true, $editor_config, true);
$form->addElement('html', '</div>');
$defaults['content_lp'] = $content;
}
@ -10893,7 +10894,6 @@ class learnpath
public function get_forums()
{
require_once '../forum/forumfunction.inc.php';
require_once '../forum/forumconfig.inc.php';
$forumCategories = get_forum_categories();
$forumsInNoCategory = get_forums_in_category(0);
@ -12614,7 +12614,7 @@ EOD;
$learnPath = null;
$lpObject = Session::read('lpobject');
if ($lpObject !== null) {
$learnPath = unserialize($lpObject);
$learnPath = UnserializeApi::unserialize('lp', $lpObject);
if ($debug) {
error_log('getLpFromSession: unserialize');
error_log('------getLpFromSession------');
@ -13420,9 +13420,9 @@ EOD;
}
$documentPathInfo = pathinfo($document->getPath());
$jplayerSupportedFiles = ['mp4', 'ogv', 'flv', 'm4v'];
$mediaSupportedFiles = ['mp3', 'mp4', 'ogv', 'flv', 'm4v'];
$extension = isset($documentPathInfo['extension']) ? $documentPathInfo['extension'] : '';
$showDirectUrl = !in_array($extension, $jplayerSupportedFiles);
$showDirectUrl = !in_array($extension, $mediaSupportedFiles);
$openmethod = 2;
$officedoc = false;
@ -13464,7 +13464,7 @@ EOD;
}
return $main_dir_path.'work/work.php?'.api_get_cidreq().'&id='.$rowItem->getPath().'&'.$extraParams;
} //end switch
}
return $link;
}

@ -1889,7 +1889,7 @@ class learnpathItem
$sessionLifetime = 3600;
}
if (!api_get_configuration_value('lp_minimum_time')) {
if (!Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$fixedAddedMinute = 5 * 60; // Add only 5 minutes
if ($time > $sessionLifetime) {
error_log("fixAbusiveTime: Total time is too big: $time replaced with: $fixedAddedMinute");

@ -159,7 +159,7 @@ function confirmation(name) {
}
}
$(document).ready(function() {
$(function() {
jQuery('.scrollbar-inner').scrollbar();
$('#subtab ').on('click', 'a:first', function() {

@ -218,7 +218,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
"olms.asset_timer = 0;";
$updateMinTime = '';
if (api_get_configuration_value('lp_minimum_time')) {
if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$timeLp = $mylp->getAccumulateWorkTime();
$timeTotalCourse = $mylp->getAccumulateWorkTimeTotalCourse();
// Minimum connection percentage
@ -237,7 +237,10 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
}
// Percentage of the learning paths
$pl = $timeLp / $timeTotalCourse;
$pl = 0;
if (!empty($timeTotalCourse)) {
$pl = $timeLp / $timeTotalCourse;
}
// Minimum time for each learning path
$time_total = intval($pl * $tc * $perc / 100) * 60;

@ -62,7 +62,7 @@ $htmlHeadXtra[] = '
// uncomment for some debug display utility
/*
$(document).ready(function() {
$(function() {
buildLPtree_debug($("#lp_item_list"), 0, 0);
alert(lp_id_list+"\n\n"+lptree_debug);
});
@ -214,7 +214,8 @@ if (!empty($lpObject)) {
if ($debug) {
error_log(' SESSION[lpobject] is defined');
}
$oLP = unserialize($lpObject);
/** @var learnpath $oLP */
$oLP = UnserializeApi::unserialize('lp', $lpObject);
if (isset($oLP) && is_object($oLP)) {
if ($debug) {
error_log(' oLP is object');
@ -260,7 +261,7 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
if ($debug > 0) {
error_log(' lp_id is defined');
}
// Select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
// Select the lp in the database and check which type it is (scorm/chamilo/aicc) to generate the
// right object.
if (!empty($_REQUEST['lp_id'])) {
$lp_id = $_REQUEST['lp_id'];

@ -158,9 +158,8 @@ $form->addElement('html', '<div class="help-block">'.get_lang('LpPrerequisiteDes
$form->addElement('html', '</div>');
$form->addElement('html', '<div class="col-md-2"></div>');
$form->addElement('html', '</div>');
//Start date
// Time Control
if (api_get_configuration_value('lp_minimum_time')) {
if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$accumulateTime = $_SESSION['oLP']->getAccumulateWorkTime();
$form->addText('accumulate_work_time', [get_lang('LpMinTime'), get_lang('LpMinTimeDescription')]);
$defaults['accumulate_work_time'] = $accumulateTime;
@ -284,13 +283,13 @@ echo Display::return_icon('course_setting_layout.png');
echo '</div>';
echo '</div>';
echo "
<script>
$(document).on('ready', function () {
$('[name=\'hide_toc_frame\']').on('change', function() {
$('#pnl-frm').toggleClass('col-md-8').toggleClass('col-sm-12');
$('#pnl-toc').toggleClass('col-md-4').toggleClass('hide');
});
<script>
$(function() {
$('[name=\'hide_toc_frame\']').on('change', function() {
$('#pnl-frm').toggleClass('col-md-8').toggleClass('col-sm-12');
$('#pnl-toc').toggleClass('col-md-4').toggleClass('hide');
});
</script>
});
</script>
";
Display::display_footer();

@ -22,7 +22,7 @@ $learnPath = Session::read('oLP');
/* Header and action code */
$htmlHeadXtra[] = '<script>'.$learnPath->get_js_dropdown_array().'
$(document).on("ready", function() {
$(function() {
CKEDITOR.on("instanceReady", function (e) {
showTemplates("content_lp");
});
@ -96,7 +96,7 @@ function confirmation(name) {
}
}
$(document).ready(function() {
$(function() {
jQuery('.scrollbar-inner').scrollbar();
expandColumnToogle('#hide_bar_template', {
selector: '#lp_sidebar'

@ -155,7 +155,7 @@ if ($filteredCategoryId) {
$test_mode = api_get_setting('server_type');
$showBlockedPrerequisite = api_get_configuration_value('show_prerequisite_as_blocked');
$allowLpChamiloExport = api_get_configuration_value('allow_lp_chamilo_export');
$allowMinTime = api_get_configuration_value('lp_minimum_time');
$allowMinTime = Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id());
$user = api_get_user_entity($userId);
$ending = true;
@ -405,7 +405,6 @@ foreach ($categories as $item) {
$dsp_time = '';
$linkMinTime = '';
if ($allowMinTime) {
// Time info
// Minimum time (in minutes) to pass the learning path
$accumulateWorkTime = learnpath::getAccumulateWorkTimePrerequisite($id, api_get_course_int_id());
if ($accumulateWorkTime > 0) {
@ -469,7 +468,7 @@ foreach ($categories as $item) {
$actionUpdateScormFile = '';
$actionExportToCourseBuild = '';
// Only for "Chamilo" packages
$allowExportCourseFormat = $allowLpChamiloExport && $details['lp_maker'] == 'Chamilo';
$allowExportCourseFormat = $allowLpChamiloExport && $details['lp_maker'] === 'Chamilo';
if ($is_allowed_to_edit) {
// EDIT LP

@ -14,7 +14,7 @@ require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
$allow = api_is_allowed_to_edit(null, true);
$lpId = !empty($_GET['lp_id']) ? intval($_GET['lp_id']) : 0;
$lpId = !empty($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0;
if (!$allow || empty($lpId)) {
api_not_allowed(true);
@ -44,8 +44,8 @@ $form = new FormValidator(
api_get_self().'?'.api_get_cidreq().'&lp_id='.$lpId,
'',
[
'id' => "upload_form",
'enctype' => "multipart/form-data",
'id' => 'upload_form',
'enctype' => 'multipart/form-data',
]
);
$form->addHeader(get_lang('UpdateFile'));

@ -126,7 +126,7 @@ var jQueryFrameReadyConfigPath = \''.api_get_jquery_web_path().'\';
//$htmlHeadXtra[] = api_get_asset('qtip2/jquery.qtip.min.js');
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
$(function() {
$("div#log_content_cleaner").bind("click", function() {
$("div#log_content").empty();
});
@ -137,7 +137,7 @@ var chamilo_xajax_handler = window.oxajax;
$allowLpItemTip = api_get_configuration_value('hide_accessibility_label_on_lp_item') === false;
if ($allowLpItemTip) {
$htmlHeadXtra[] = '<script>
$(document).ready(function() {
$(function() {
$(".scorm_item_normal").qtip({
content: {
text: function(event, api) {
@ -544,7 +544,7 @@ if ($gamificationMode == 1) {
$template->assign('lp_author', $lp->get_author());
$lpMinTime = '';
if (api_get_configuration_value('lp_minimum_time')) {
if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
// Calulate minimum and accumulated time
$timeLp = $_SESSION['oLP']->getAccumulateWorkTime();
$timeTotalCourse = $_SESSION['oLP']->getAccumulateWorkTimeTotalCourse();
@ -583,7 +583,6 @@ if (api_get_configuration_value('lp_minimum_time')) {
$template->assign('hour', $hour);
$template->assign('minute', date('i', $lpTime));
$template->assign('second', date('s', $lpTime));
$template->assign('hour_min', api_time_to_hms($timeLp * 60, '</div><div class="divider">:</div><div>'));
}

@ -24,7 +24,7 @@ $lp = Session::read('oLP');
if (isset($_GET['lp_item_id'])) {
// Get parameter only came from lp_view.php.
$lp_item_id = intval($_GET['lp_item_id']);
$lp_item_id = (int) $_GET['lp_item_id'];
if (is_object($lp)) {
$src = $lp->get_link('http', $lp_item_id);
}

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Symfony\Component\DomCrawler\Crawler;
/**
* Defines the scorm class, which is meant to contain the scorm items (nuclear elements).
*
@ -94,9 +96,13 @@ class scorm extends learnpath
// UTF-8 is supported by DOMDocument class, this is for sure.
$xml = api_utf8_encode_xml($xml, $this->manifest_encoding);
$doc = new DOMDocument();
$res = @$doc->loadXML($xml);
if ($res === false) {
$crawler = new Crawler();
$crawler->addXmlContent($xml);
$xmlErrors = libxml_get_errors();
if (!empty($xmlErrors)) {
if ($this->debug > 0) {
error_log('New LP - In scorm::parse_manifest() - Exception thrown when loading '.$file.' in DOMDocument');
}
@ -105,10 +111,11 @@ class scorm extends learnpath
}
if ($this->debug > 1) {
error_log('New LP - Called (encoding:'.$doc->xmlEncoding.' - saved: '.$this->manifest_encoding.')', 0);
error_log('New LP - Called (encoding:'.$this->manifest_encoding.' - saved: '.$this->manifest_encoding.')', 0);
}
$root = $doc->documentElement;
$root = $crawler->getNode(0);
if ($root->hasAttributes()) {
$attributes = $root->attributes;
if ($attributes->length !== 0) {
@ -220,8 +227,7 @@ class scorm extends learnpath
}
}
}
unset($doc);
// End parsing using PHP5 DOMXML methods.
// End parsing using PHP5 DOMXML methods.
} else {
if ($this->debug > 1) {
error_log('New LP - Could not open/read file '.$file);
@ -586,8 +592,8 @@ class scorm extends learnpath
/**
* Imports a zip file into the Chamilo structure.
*
* @param string $zip_file_info Zip file info as given by $_FILES['userFile']
* @param string $current_dir
* @param string $zipFileInfo Zip file info as given by $_FILES['userFile']
* @param string $currentDir
* @param array $courseInfo
* @param bool $updateDirContents
* @param learnpath $lpToCheck
@ -595,55 +601,58 @@ class scorm extends learnpath
* @return string $current_dir Absolute path to the imsmanifest.xml file or empty string on error
*/
public function import_package(
$zip_file_info,
$current_dir = '',
$zipFileInfo,
$currentDir = '',
$courseInfo = [],
$updateDirContents = false,
$lpToCheck = null
) {
if ($this->debug > 0) {
error_log(
'In scorm::import_package('.print_r($zip_file_info, true).',"'.$current_dir.'") method'
'In scorm::import_package('.print_r($zipFileInfo, true).',"'.$currentDir.'") method'
);
}
$courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$maxFilledSpace = DocumentManager::get_course_quota($courseInfo['code']);
$zip_file_path = $zip_file_info['tmp_name'];
$zip_file_name = $zip_file_info['name'];
$zipFilePath = $zipFileInfo['tmp_name'];
$zipFileName = $zipFileInfo['name'];
if ($this->debug > 1) {
error_log('New LP - import_package() - zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0);
error_log(
'New LP - import_package() - zip file path = '.$zipFilePath.', zip file name = '.$zipFileName,
0
);
}
$course_rel_dir = api_get_course_path($courseInfo['code']).'/scorm'; // scorm dir web path starting from /courses
$course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // Absolute system path for this course.
$current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/
$courseRelDir = api_get_course_path($courseInfo['code']).'/scorm'; // scorm dir web path starting from /courses
$courseSysDir = api_get_path(SYS_COURSE_PATH).$courseRelDir; // Absolute system path for this course.
$currentDir = api_replace_dangerous_char(trim($currentDir)); // Current dir we are in, inside scorm/
if ($this->debug > 1) {
error_log('New LP - import_package() - current_dir = '.$current_dir, 0);
error_log('New LP - import_package() - current_dir = '.$currentDir, 0);
}
// Get name of the zip file without the extension.
$file_info = pathinfo($zip_file_name);
$filename = $file_info['basename'];
$extension = $file_info['extension'];
$file_base_name = str_replace('.'.$extension, '', $filename); // Filename without its extension.
$this->zipname = $file_base_name; // Save for later in case we don't have a title.
$new_dir = api_replace_dangerous_char(trim($file_base_name));
$this->subdir = $new_dir;
$fileInfo = pathinfo($zipFileName);
$filename = $fileInfo['basename'];
$extension = $fileInfo['extension'];
$fileBaseName = str_replace('.'.$extension, '', $filename); // Filename without its extension.
$this->zipname = $fileBaseName; // Save for later in case we don't have a title.
$newDir = api_replace_dangerous_char(trim($fileBaseName));
$this->subdir = $newDir;
if ($this->debug > 1) {
error_log('New LP - Received zip file name: '.$zip_file_path);
error_log('New LP - Received zip file name: '.$zipFilePath);
error_log("New LP - subdir is first set to : ".$this->subdir);
error_log("New LP - base file name is : ".$file_base_name);
error_log("New LP - base file name is : ".$fileBaseName);
}
$zipFile = new PclZip($zip_file_path);
$zipFile = new PclZip($zipFilePath);
// Check the zip content (real size and file extension).
$zipContentArray = $zipFile->listContent();
$package_type = '';
$manifest_list = [];
$packageType = '';
$manifestList = [];
// The following loop should be stopped as soon as we found the right imsmanifest.xml (how to recognize it?).
$realFileSize = 0;
foreach ($zipContentArray as $thisContent) {
@ -657,29 +666,29 @@ class scorm extends learnpath
error_log("New LP - subdir is now ".$this->subdir);
}
}
$package_type = 'scorm';
$manifest_list[] = $thisContent['filename'];
$packageType = 'scorm';
$manifestList[] = $thisContent['filename'];
}
$realFileSize += $thisContent['size'];
}
// Now get the shortest path (basically, the imsmanifest that is the closest to the root).
$shortest_path = $manifest_list[0];
$slash_count = substr_count($shortest_path, '/');
foreach ($manifest_list as $manifest_path) {
$tmp_slash_count = substr_count($manifest_path, '/');
if ($tmp_slash_count < $slash_count) {
$shortest_path = $manifest_path;
$slash_count = $tmp_slash_count;
$shortestPath = $manifestList[0];
$slashCount = substr_count($shortestPath, '/');
foreach ($manifestList as $manifestPath) {
$tmpSlashCount = substr_count($manifestPath, '/');
if ($tmpSlashCount < $slashCount) {
$shortestPath = $manifestPath;
$slashCount = $tmpSlashCount;
}
}
$this->subdir .= '/'.dirname($shortest_path); // Do not concatenate because already done above.
$manifest = $shortest_path;
$this->subdir .= '/'.dirname($shortestPath); // Do not concatenate because already done above.
$manifest = $shortestPath;
if ($this->debug) {
error_log("New LP - Package type is now: '$package_type'");
error_log("New LP - Package type is now: '$packageType'");
}
if ($package_type == '') {
if ($packageType == '') {
Display::addFlash(
Display::return_message(get_lang('NotScormContent'))
);
@ -687,7 +696,7 @@ class scorm extends learnpath
return false;
}
if (!enough_size($realFileSize, $course_sys_dir, $maxFilledSpace)) {
if (!enough_size($realFileSize, $courseSysDir, $maxFilledSpace)) {
if ($this->debug > 1) {
error_log('New LP - Not enough space to store package');
}
@ -700,20 +709,20 @@ class scorm extends learnpath
if ($updateDirContents && $lpToCheck) {
$originalPath = str_replace('/.', '', $lpToCheck->path);
if ($originalPath != $new_dir) {
if ($originalPath != $newDir) {
Display::addFlash(Display::return_message(get_lang('FileError')));
return false;
}
}
// It happens on Linux that $new_dir sometimes doesn't start with '/'
if ($new_dir[0] != '/') {
$new_dir = '/'.$new_dir;
// It happens on Linux that $newDir sometimes doesn't start with '/'
if ($newDir[0] != '/') {
$newDir = '/'.$newDir;
}
if ($new_dir[strlen($new_dir) - 1] == '/') {
$new_dir = substr($new_dir, 0, -1);
if ($newDir[strlen($newDir) - 1] == '/') {
$newDir = substr($newDir, 0, -1);
}
/* Uncompressing phase */
@ -723,92 +732,33 @@ class scorm extends learnpath
- parse & change relative html links
- make sure the filenames are secure (filter funny characters or php extensions)
*/
if (is_dir($course_sys_dir.$new_dir) ||
@mkdir($course_sys_dir.$new_dir, api_get_permissions_for_new_directories())
if (is_dir($courseSysDir.$newDir) ||
@mkdir(
$courseSysDir.$newDir,
api_get_permissions_for_new_directories()
)
) {
// PHP method - slower...
if ($this->debug >= 1) {
error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir);
}
$saved_dir = getcwd();
chdir($course_sys_dir.$new_dir);
$unzippingState = $zipFile->extract();
for ($j = 0; $j < count($unzippingState); $j++) {
$state = $unzippingState[$j];
// TODO: Fix relative links in html files (?)
$extension = strrchr($state['stored_filename'], '.');
if ($this->debug >= 1) {
error_log('New LP - found extension '.$extension.' in '.$state['stored_filename']);
}
error_log('New LP - Changing dir to '.$courseSysDir.$newDir);
}
if (!empty($new_dir)) {
$new_dir = $new_dir.'/';
}
chdir($courseSysDir.$newDir);
// Rename files, for example with \\ in it.
if ($this->debug >= 1) {
error_log('New LP - try to open: '.$course_sys_dir.$new_dir);
}
if ($dir = @opendir($course_sys_dir.$new_dir)) {
if ($this->debug >= 1) {
error_log('New LP - Opened dir '.$course_sys_dir.$new_dir);
}
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
// TODO: RENAMING FILES CAN BE VERY DANGEROUS SCORM-WISE, avoid that as much as possible!
//$safe_file = api_replace_dangerous_char($file, 'strict');
$find_str = ['\\', '.php', '.phtml'];
$repl_str = ['/', '.txt', '.txt'];
$safe_file = str_replace($find_str, $repl_str, $file);
if ($this->debug >= 1) {
error_log('Comparing: '.$safe_file);
error_log('and: '.$file);
}
if ($safe_file != $file) {
$mydir = dirname($course_sys_dir.$new_dir.$safe_file);
if (!is_dir($mydir)) {
$mysubdirs = explode('/', $mydir);
$mybasedir = '/';
foreach ($mysubdirs as $mysubdir) {
if (!empty($mysubdir)) {
$mybasedir = $mybasedir.$mysubdir.'/';
if (!is_dir($mybasedir)) {
@mkdir($mybasedir, api_get_permissions_for_new_directories());
if ($this->debug >= 1) {
error_log('New LP - Dir '.$mybasedir.' doesnt exist. Creating.');
}
}
}
}
}
@rename($course_sys_dir.$new_dir.$file, $course_sys_dir.$new_dir.$safe_file);
if ($this->debug >= 1) {
error_log(
'New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file
);
}
}
}
}
closedir($dir);
chdir($saved_dir);
$zipFile->extract(
PCLZIP_CB_PRE_EXTRACT,
'clean_up_files_in_zip'
);
api_chmod_R($course_sys_dir.$new_dir, api_get_permissions_for_new_directories());
if ($this->debug > 1) {
error_log('New LP - changed back to init dir: '.$course_sys_dir.$new_dir);
}
if (!empty($newDir)) {
$newDir = $newDir.'/';
}
api_chmod_R($courseSysDir.$newDir, api_get_permissions_for_new_directories());
} else {
return false;
}
return $course_sys_dir.$new_dir.$manifest;
return $courseSysDir.$newDir.$manifest;
}
/**

@ -31,7 +31,10 @@ require_once __DIR__.'/../inc/global.inc.php';
$file = Session::read('file');
/** @var learnpath $oLP */
$oLP = unserialize(Session::read('lpobject'));
$oLP = UnserializeApi::unserialize(
'lp',
Session::read('lpobject')
);
/** @var learnpathItem $oItem */
$oItem = isset($oLP->items[$oLP->current]) ? $oLP->items[$oLP->current] : null;
@ -220,7 +223,7 @@ var courseUrl = '?cidReq='+olms.lms_course_code+'&id_session='+olms.lms_session_
addEvent(window, 'load', addListeners, false);
// Initialize stuff when the page is loaded
$(document).ready(function() {
$(function() {
logit_lms('document.ready event starts');
logit_lms('These logs are generated by the main/lp/scorm_api.php JS '
+ 'library when the admin has clicked on the debug icon in the '
@ -235,6 +238,7 @@ $(document).ready(function() {
olms.info_lms_item[0] = '<?php echo $oItem->get_id(); ?>';
olms.info_lms_item[1] = '<?php echo $oItem->get_id(); ?>';
$("#content_id").load(function() {
logit_lms('#content_id load event starts');
olms.info_lms_item[0] = olms.info_lms_item[1];
@ -333,7 +337,12 @@ function LMSInitialize() {
logit_scorm('LMSInitialize() with params: '+log);
if (olms.lms_lp_type == 1 || olms.lms_item_type == 'asset' || olms.lms_item_type == 'document') {
if(olms.lms_item_type == 'sco'){
$("#tab-iframe").removeClass();
$("#tab-iframe").addClass("tab-content iframe_"+olms.lms_item_type);
}
if (olms.lms_lp_type == 1 || olms.lms_item_type == 'asset' || olms.lms_item_type == 'document') {
xajax_start_timer();
}
@ -1749,11 +1758,15 @@ var loadForumThread = function(lpId, lpItemId) {
var tabForumLink = $('.lp-view-tabs a[href="#lp-view-forum"]'),
tabForum = tabForumLink.parent();
$("#navTabs").show();
$("#tab-iframe").removeClass("tab-none-forum");
$("#btn-menu-float").removeClass("none-forum");
if (forumThreadData.error) {
tabForumLink.removeAttr('data-toggle');
tabForum.addClass('disabled');
$("#navTabs").hide();
$("#tab-iframe").addClass("tab-none-forum");
$("#btn-menu-float").addClass("none-forum");
$('#lp-view-forum').html('');
return;
@ -1924,7 +1937,9 @@ function xajax_save_item_scorm(
} else if (my_scorm_values[k]=='cmi.completion_status') {
} else if (my_scorm_values[k]=='cmi.score.scaled') {
} else if (my_scorm_values[k]=='cmi.suspend_data') {
params += '&suspend='+olms.suspend_data;
// params += '&suspend='+olms.suspend_data;
// Fixes error when scorm sends text with "+" sign
params += '&suspend='+encodeURIComponent(olms.suspend_data);
} else if (my_scorm_values[k]=='cmi.completion_status') {
} else if (my_scorm_values[k]=='cmi.core.exit') {
params += '&core_exit='+olms.lms_item_core_exit;
@ -2258,7 +2273,7 @@ function attach_glossary_into_scorm(type) {
}
if (type == 'fix_links') {
$(document).ready(function() {
$(function() {
var objects = $("iframe").contents().find('object');
var pathname = location.pathname;

@ -20,8 +20,6 @@ $logInfo = [
'tool_id_detail' => 0,
'action' => isset($_GET['action']) ? $_GET['action'] : 'inbox',
'action_details' => '',
'current_id' => isset($_GET['id']) ? (int) $_GET['id'] : 0,
'info' => '',
];
Event::registerLog($logInfo);
@ -117,47 +115,47 @@ $interbreadcrumb[] = [
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Inbox')];
$actions = '';
$keyword = '';
// Comes from normal profile
if ($allowMessage) {
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).'</a>';
$form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/inbox.php');
try {
if ($form->validate()) {
$values = $form->getSubmitValues();
$keyword = $values['keyword'];
}
} catch (HTML_QuickForm_Error $e) {
echo $e->getMessage();
}
$actionsRight = $form->returnForm();
$actions = Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]);
if ($allowSocial == false && $allowMessage) {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
}
// SOCIAL MENU
/*$social_menu_block = '';
// LEFT CONTENT
$social_menu_block = '';
if ($allowSocial) {
// Block Social Menu
$social_menu_block = SocialManager::show_social_menu('messages');
}*/
}
// Right content
$message_content = '';
$social_right_content = '';
$keyword = '';
if (api_get_setting('allow_social_tool') === 'true') {
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'), [], 32).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox'), [], 32).'</a>';
$form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/inbox.php');
if ($form->validate()) {
$values = $form->getSubmitValues();
$keyword = $values['keyword'];
}
$actionsRight = $form->returnForm();
$social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]);
}
//MAIN CONTENT
if (!isset($_GET['del_msg'])) {
$message_content .= MessageManager::inbox_display($keyword);
$social_right_content .= MessageManager::inbox_display($keyword);
} else {
$num_msg = (int) $_POST['total'];
$num_msg = intval($_POST['total']);
for ($i = 0; $i < $num_msg; $i++) {
if ($_POST[$i]) {
//the user_id was necessary to delete a message??
@ -167,20 +165,24 @@ if (!isset($_GET['del_msg'])) {
);
}
}
$message_content .= MessageManager::inbox_display();
$social_right_content .= MessageManager::inbox_display();
}
$tpl = new Template($nameTools);
$tpl = new Template(null);
if ($actions) {
$tpl->assign('actions', $actions);
$tpl->assign('actions', Display::toolbarAction('toolbar', [$actions]));
}
// Block Social Avatar
// SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
$tpl->assign('content_inbox', $message_content);
$social_layout = $tpl->get_template('message/inbox.html.twig');
$content = $tpl->fetch($social_layout);
$tpl->assign('message', $show_message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
if (api_get_setting('allow_social_tool') == 'true') {
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);
} else {
$content = $social_right_content;
$tpl->assign('message', $show_message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}

@ -28,8 +28,6 @@ $logInfo = [
'tool_id_detail' => 0,
'action' => 'new_message',
'action_details' => isset($_GET['re_id']) ? 're_id' : '',
'current_id' => isset($_GET['re_id']) ? (int) $_GET['re_id'] : 0,
'info' => '',
];
Event::registerLog($logInfo);
@ -349,24 +347,45 @@ $interbreadcrumb[] = [
];
$group_id = isset($_REQUEST['group_id']) ? (int) $_REQUEST['group_id'] : 0;
$message_content = null;
$actions = null;
$social_right_content = null;
if ($group_id != 0) {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'.
Display::return_icon('back.png', api_xml_http_response_encode(get_lang('ComposeMessage')), null, ICON_SIZE_MEDIUM).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
Display::return_icon('message_new.png', api_xml_http_response_encode(get_lang('ComposeMessage')), null, ICON_SIZE_MEDIUM).'</a>';
$social_right_content .= '<div class=actions>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/group_view.php?id='.$group_id.'">'.
Display::return_icon('back.png', api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?group_id='.$group_id.'">'.
Display::return_icon('message_new.png', api_xml_http_response_encode(get_lang('ComposeMessage'))).'</a>';
$social_right_content .= '</div>';
} else {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('back.png', get_lang('Back'), null, ICON_SIZE_MEDIUM).'</a>';
if (api_get_setting('allow_message_tool') === 'true') {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).'</a>';
if ($allowSocial) {
} else {
$social_right_content .= '<div class=actions>';
if (api_get_setting('allow_message_tool') === 'true') {
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
}
$social_right_content .= '</div>';
}
}
$show_message = null;
// LEFT COLUMN
$social_left_content = '';
if ($allowSocial) {
// Block Social Menu
$social_menu_block = SocialManager::show_social_menu('messages');
$social_right_content .= '<div class="row">';
$social_right_content .= '<div class="col-md-12">';
$social_right_content .= '<div class="actions">';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('back.png', get_lang('Back'), [], 32).'</a>';
$social_right_content .= '</div>';
$social_right_content .= '</div>';
$social_right_content .= '<div class="col-md-12">';
}
// MAIN CONTENT
if (!isset($_POST['compose'])) {
if (isset($_GET['re_id'])) {
@ -395,7 +414,7 @@ if (!isset($_POST['compose'])) {
// comes from a reply button
if (isset($_GET['re_id']) || isset($_GET['forward_id'])) {
$message_content .= manageForm($default, null, null, $tpl);
$social_right_content .= manageForm($default, null, null, $tpl);
} else {
// post
if ($restrict) {
@ -407,24 +426,29 @@ if (!isset($_POST['compose'])) {
if (isset($_POST['hidden_user'])) {
$default['users'] = [$_POST['hidden_user']];
}
$message_content .= manageForm($default, null, null, $tpl);
$social_right_content .= manageForm($default, null, null, $tpl);
} else {
$show_message = Display::return_message(get_lang('ErrorSendingMessage'), 'error');
$social_right_content .= Display::return_message(get_lang('ErrorSendingMessage'), 'error');
}
}
}
MessageManager::cleanAudioMessage();
if ($allowSocial) {
$social_right_content .= '</div>';
$social_right_content .= '</div>';
}
if ($actions) {
$tpl->assign(
'actions',
Display::toolbarAction('toolbar', [$actions])
);
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
MessageManager::cleanAudioMessage();
if ($allowSocial) {
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);
} else {
$content = $social_right_content;
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}
$tpl->assign('message', $show_message);
$tpl->assign('content_inbox', $message_content);
$social_layout = $tpl->get_template('message/inbox.html.twig');
$content = $tpl->fetch($social_layout);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -19,14 +19,11 @@ $logInfo = [
'tool_id_detail' => 0,
'action' => isset($_GET['action']) ? $_GET['action'] : 'outbox',
'action_details' => '',
'current_id' => isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0,
'info' => '',
];
Event::registerLog($logInfo);
$allowSocial = api_get_setting('allow_social_tool') == 'true';
$allowMessage = api_get_setting('allow_message_tool') == 'true';
$show_message = null;
if (isset($_GET['messages_page_nr'])) {
if ($allowSocial && $allowMessage) {
@ -51,39 +48,40 @@ $interbreadcrumb[] = [
'name' => get_lang('Messages'),
];
$actions = null;
$actions = '';
if ($allowMessage) {
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('back.png', get_lang('Back'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).'</a>';
$form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php');
if ($form->validate()) {
$values = $form->getSubmitValues();
$keyword = $values['keyword'];
}
$actionsRight = $form->returnForm();
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('message_new.png', get_lang('ComposeMessage')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
}
$action = null;
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
}
$keyword = '';
$message_content = null;
$actions .= Display::toolbarAction(
'toolbar',
[$actionsLeft, $actionsRight]
);
$social_right_content = '';
if ($allowSocial) {
// Block Social Menu
$social_menu_block = SocialManager::show_social_menu('messages');
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('back.png', get_lang('Back'), [], 32).'</a>';
$form = MessageManager::getSearchForm(api_get_path(WEB_PATH).'main/messages/outbox.php');
if ($form->validate()) {
$values = $form->getSubmitValues();
$keyword = $values['keyword'];
}
$actionsRight = $form->returnForm();
$social_right_content .= Display::toolbarAction(
'toolbar',
[$actionsLeft, $actionsRight]
);
}
//MAIN CONTENT
if ($action == 'delete') {
$delete_list_id = [];
@ -94,33 +92,40 @@ if ($action == 'delete') {
$delete_list_id = $_POST['id'];
}
for ($i = 0; $i < count($delete_list_id); $i++) {
$show_message .= MessageManager::delete_message_by_user_sender(
MessageManager::delete_message_by_user_sender(
api_get_user_id(),
$delete_list_id[$i]
);
}
$delete_list_id = [];
$message_content .= MessageManager::outbox_display($keyword);
$social_right_content .= MessageManager::outbox_display($keyword);
} elseif ($action == 'deleteone') {
$delete_list_id = [];
$id = Security::remove_XSS($_GET['id']);
MessageManager::delete_message_by_user_sender(api_get_user_id(), $id);
$delete_list_id = [];
$message_content .= MessageManager::outbox_display($keyword);
$social_right_content .= MessageManager::outbox_display($keyword);
} else {
$message_content .= MessageManager::outbox_display($keyword);
$social_right_content .= MessageManager::outbox_display($keyword);
}
$tpl = new Template(get_lang('Outbox'));
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
if ($actions) {
$tpl->assign('actions', $actions);
if ($allowSocial) {
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);
} else {
$content = $social_right_content;
if ($actions) {
$tpl->assign(
'actions',
Display::toolbarAction('toolbar', [$actions])
);
}
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}
$tpl->assign('content_inbox', $message_content);
$social_layout = $tpl->get_template('message/inbox.html.twig');
$content = $tpl->fetch($social_layout);
$tpl->assign('message', $show_message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -24,21 +24,16 @@ if ($allowSocial) {
}
$interbreadcrumb[] = ['url' => 'inbox.php', 'name' => get_lang('Messages')];
$actions = null;
$social_right_content = '<div class="actions">';
if (api_get_setting('allow_message_tool') === 'true') {
$actionsLeft = '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox'), null, ICON_SIZE_MEDIUM).'</a>';
$actionsLeft .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox'), null, ICON_SIZE_MEDIUM).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.
Display::return_icon('new-message.png', get_lang('ComposeMessage')).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.
Display::return_icon('inbox.png', get_lang('Inbox')).'</a>';
$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.
Display::return_icon('outbox.png', get_lang('Outbox')).'</a>';
}
$actions .= Display::toolbarAction(
'toolbar',
[$actionsLeft]
);
$social_right_content .= '</div>';
if (empty($_GET['id'])) {
$messageId = $_GET['id_send'];
@ -50,31 +45,42 @@ if (empty($_GET['id'])) {
$show_menu = 'messages_inbox';
}
$message = '';
$logInfo = [
'tool' => 'Messages',
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $source,
'action_details' => 'view-message',
'current_id' => $messageId,
'info' => '',
];
Event::registerLog($logInfo);
// LEFT COLUMN
if (api_get_setting('allow_social_tool') === 'true') {
// Block Social Menu
$social_menu_block = SocialManager::show_social_menu($show_menu);
}
// MAIN CONTENT
$message_content = MessageManager::showMessageBox($messageId, $source);
$message .= MessageManager::showMessageBox($messageId, $source);
if (empty($message_content)) {
if (!empty($message)) {
$social_right_content .= $message;
} else {
api_not_allowed(true);
}
$tpl = new Template(get_lang('View'));
// Block Social Avatar
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), $show_menu);
if (api_get_setting('allow_social_tool') === 'true') {
$tpl->assign('social_menu_block', $social_menu_block);
$tpl->assign('social_right_content', $social_right_content);
$social_layout = $tpl->get_template('social/inbox.tpl');
$tpl->display($social_layout);
} else {
$content = $social_right_content;
if ($actions) {
$tpl->assign('actions', $actions);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
}
$tpl->assign('content_inbox', $message_content);
$social_layout = $tpl->get_template('message/inbox.html.twig');
$content = $tpl->fetch($social_layout);
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -27,7 +27,7 @@ $defaults['course_id'] = $courseId;
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$(function() {
$("#exercise_course_id").on("change", function(e) {
var data = $(this).select2(\'data\');
var option = data[0];
@ -35,7 +35,7 @@ $(document).ready( function() {
var value = option.id;
var selectedDate = $("#start_date").datepicker({ dateFormat: \'dd,MM,yyyy\' }).val();
window.location.replace("'.$currentUrl.'?start_date="+selectedDate+"&course_id="+value);
});
});
});
</script>';

@ -42,8 +42,6 @@ $logInfo = [
'tool_id_detail' => 0,
'action' => '',
'action_details' => '',
'current_id' => 0,
'info' => '',
];
Event::registerLog($logInfo);

@ -1155,7 +1155,7 @@ if (empty($details)) {
$isSubscribed = CourseManager::is_user_subscribed_in_course(
$student_id,
$courseCodeItem,
false
false
);
} else {
$isSubscribed = CourseManager::is_user_subscribed_in_course(
@ -1387,7 +1387,7 @@ if (empty($details)) {
];
$timeCourse = null;
if (api_get_configuration_value('lp_minimum_time')) {
if (Tracking::minimunTimeAvailable($session_id, $courseInfo['real_id'])) {
$timeCourse = Tracking::getCalculateTime($student_id, $courseInfo['real_id'], $session_id);
}

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Fhaculty\Graph\Graph;
require_once __DIR__.'/../inc/global.inc.php';
if (api_get_configuration_value('allow_career_diagram') == false) {
@ -41,7 +43,8 @@ foreach ($sessionCategories as $category) {
'career_diagram'
);
if ($diagram && !empty($diagram['value'])) {
$graph = unserialize($diagram['value']);
/** @var Graph $graph */
$graph = UnserializeApi::unserialize('career', $diagram['value']);
$content .= Career::renderDiagram($careerInfo, $graph);
}
}

@ -13,9 +13,6 @@ require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
$this_section = SECTION_TRACKING;
api_block_anonymous_users();
$export_csv = false;
if (isset($_GET['export']) && $_GET['export'] == 'csv') {
$export_csv = true;
@ -71,6 +68,13 @@ if (api_is_platform_admin(true, true)) {
api_get_path(WEB_CODE_PATH).'admin/teachers_time_by_session_report.php'
);
if (!api_is_session_admin()) {
$menu_items[] = Display::url(
Display::return_icon('1day.png', get_lang('SessionsPlanCalendar'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."calendar/planification.php"
);
}
$actionsLeft = '';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {

@ -31,7 +31,7 @@ function sliderClose()
$(".slider").animate({"height": sliderHeight}, {duration: "fast" });
}
$(document).ready(function () {
$(function() {
// Show the slider content
$('.slider').show();
$('.slider').each(function () {
@ -40,4 +40,4 @@ $(document).ready(function () {
});
$(".slider").css("height", sliderHeight);
});
});

@ -46,8 +46,8 @@ if (api_get_setting('add_users_by_coach') === 'true') {
}
set_time_limit(0);
if ($_POST['formSent'] && $_FILES['import_file']['size'] !== 0) {
$errors = [];
if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['size'] !== 0) {
$file_type = $_POST['file_type'];
$id_session = intval($_POST['id_session']);
if ($file_type == 'csv') {
@ -76,19 +76,21 @@ if ($_POST['formSent'] && $_FILES['import_file']['size'] !== 0) {
MySpace::save_data($users, $course_list, $id_session);
}
} else {
header('Location: course.php?id_session='.$id_session.'&action=error_message&message='.urlencode(get_lang('NoSessionId')));
Display::addFlash(Display::return_message(get_lang('NoSessionId'), 'warning'));
header('Location: course.php?id_session='.$id_session);
exit;
}
}
} else {
header('Location: course.php?id_session='.$id_session.'&action=error_message&message='.urlencode(get_lang('NoUsersRead')));
Display::addFlash(Display::return_message(get_lang('NoUsersRead'), 'warning'));
header('Location: course.php?id_session='.$id_session);
exit;
}
}
Display :: display_header($tool_name);
if ($_FILES['import_file']['size'] == 0 && $_POST) {
if (isset($_FILES['import_file']) && $_FILES['import_file']['size'] == 0 && $_POST) {
echo Display::return_message(get_lang('ThisFieldIsRequired'), 'error');
}
@ -110,8 +112,20 @@ $form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
$form->addRule('import_file', get_lang('ThisFieldIsRequired'), 'required');
$allowed_file_types = ['xml', 'csv'];
$form->addRule('import_file', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types);
$form->addElement('radio', 'file_type', get_lang('FileType'), 'XML (<a href="../admin/example.xml" target="_blank">'.get_lang('ExampleXMLFile').'</a>)', 'xml');
$form->addElement('radio', 'file_type', null, 'CSV (<a href="../admin/example.csv" target="_blank">'.get_lang('ExampleCSVFile').'</a>)', 'csv');
$form->addElement(
'radio',
'file_type',
get_lang('FileType'),
'XML (<a href="../admin/example.xml" target="_blank" download>'.get_lang('ExampleXMLFile').'</a>)',
'xml'
);
$form->addElement(
'radio',
'file_type',
null,
'CSV (<a href="../admin/example.csv" target="_blank" download>'.get_lang('ExampleCSVFile').'</a>)',
'csv'
);
$form->addElement('radio', 'sendMail', get_lang('SendMailToUsers'), get_lang('Yes'), 1);
$form->addElement('radio', 'sendMail', null, get_lang('No'), 0);
$form->addElement('submit', 'submit', get_lang('Ok'));

@ -26,7 +26,7 @@ $htmlHeadXtra[] = '<script>
function setFocus(){
$("#note_title").focus();
}
$(document).ready(function () {
$(function() {
setFocus();
});
</script>';
@ -45,10 +45,9 @@ $logInfo = [
'tool_id_detail' => 0,
'action' => $action,
'action_details' => '',
'current_id' => isset($_REQUEST['notebook_id']) ? (int) $_REQUEST['notebook_id'] : 0,
'info' => '',
];
Event::registerLog($logInfo);
// Tool name
if ($action === 'addnote') {
$tool = 'NoteAddNew';

@ -15,24 +15,16 @@ $xajax->registerFunction('search_users');
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
$id_session = (int) $_GET['id_session'];
$courseId = isset($_GET['course_id']) ? (int) $_GET['course_id'] : 0;
if (empty($id_session) || empty($courseId)) {
api_not_allowed(true);
}
$id_session = intval($_GET['id_session']);
$addProcess = isset($_GET['add']) ? Security::remove_XSS($_GET['add']) : null;
SessionManager::protectSession($id_session);
$courseInfo = api_get_course_info_by_id($courseId);
// setting breadcrumbs
$interbreadcrumb[] = ['url' => 'session_list.php', 'name' => get_lang('SessionList')];
$interbreadcrumb[] = [
'url' => "resume_session.php?id_session=".$id_session,
'name' => get_lang('SessionOverview'),
"name" => get_lang('SessionOverview'),
];
// Database Table Definitions
@ -40,7 +32,6 @@ $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tableRelSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// setting the name of the tool
$tool_name = get_lang('SubscribeUsersToSession');
@ -81,11 +72,10 @@ if (is_array($extra_field_list)) {
function search_users($needle, $type)
{
global $id_session, $courseId;
global $id_session;
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tableRelSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$xajax_response = new xajaxResponse();
$return = '';
@ -121,14 +111,8 @@ function search_users($needle, $type)
$id_session = intval($id_session);
// check id_user from session_rel_user table
$sql = "
SELECT su.user_id
FROM $tbl_session_rel_user su
INNER JOIN $tableRelSessionCourseUser sc
ON (sc.session_id = su.session_id AND su.user_id = sc.user_id)
WHERE
sc.c_id = $courseId AND
su.session_id = $id_session AND
relation_type <> ".SESSION_RELATION_TYPE_RRHH;
SELECT user_id FROM $tbl_session_rel_user
WHERE session_id = $id_session AND relation_type <> ".SESSION_RELATION_TYPE_RRHH;
$res = Database::query($sql);
$user_ids = [];
if (Database::num_rows($res) > 0) {
@ -194,7 +178,7 @@ function search_users($needle, $type)
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.id)
ON (url_user.user_id = user.id)
WHERE
access_url_id = '$access_url_id'
AND (
@ -263,6 +247,7 @@ function search_users($needle, $type)
$xajax_response->addAssign('ajax_list_users_single', 'innerHTML', api_utf8_encode($return));
} else {
global $nosessionUsersList;
$return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
while ($user = Database:: fetch_array($rs)) {
$person_name =
@ -342,21 +327,15 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) {
}
if ($form_sent == 1) {
$notEmptyList = api_get_configuration_value('session_multiple_subscription_students_list_avoid_emptying');
// Added a parameter to send emails when registering a user
SessionManager::subscribeUsersToSession(
$id_session,
$UserList,
null,
false,
false
!$notEmptyList
);
SessionManager::subscribe_users_to_session_course(
$UserList,
$id_session,
$courseInfo['code']
);
Display::addFlash(Display::return_message(get_lang('Updated')));
header('Location: resume_session.php?id_session='.$id_session);
exit;
@ -386,18 +365,14 @@ if ($orderListByOfficialCode === 'true') {
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_RELATION_TYPE_RRHH." AND
sc.c_id = $courseId AND
u.status<>".DRH." AND
u.status <> 6
SELECT u.id, u.lastname, u.firstname, u.username, session_id, u.official_code
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
ON su.user_id = u.id
AND su.relation_type <> ".SESSION_RELATION_TYPE_RRHH."
AND su.session_id = ".intval($id_session)."
WHERE u.status<>".DRH."
AND u.status <> 6
$order_clause
";
@ -406,18 +381,14 @@ if ($ajax_search) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = "
SELECT u.id, u.lastname, u.firstname, u.username, su.session_id, u.official_code
SELECT u.id, u.lastname, u.firstname, u.username, session_id, u.official_code
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
ON su.user_id = u.id
AND su.relation_type <> ".SESSION_RELATION_TYPE_RRHH."
AND su.session_id = ".intval($id_session)."
INNER JOIN $tbl_user_rel_access_url url_user
ON (url_user.user_id = u.id)
INNER JOIN $tableRelSessionCourseUser sc
ON (sc.session_id = su.session_id AND su.user_id = sc.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
sc.c_id = $courseId AND
AND u.status <> ".DRH."
AND u.status <> 6
$order_clause
@ -430,7 +401,8 @@ if ($ajax_search) {
$sessionUsersList[$user['id']] = $user;
}
$sessionUserInfo = SessionManager::getTotalUserCoursesInSession($id_session, $courseId);
$sessionUserInfo = SessionManager::getTotalUserCoursesInSession($id_session);
// Filter the user list in all courses in the session
foreach ($sessionUserInfo as $sessionUser) {
// filter students in session
@ -510,31 +482,26 @@ if ($ajax_search) {
}
if ($use_extra_fields) {
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
SELECT u.id, lastname, firstname, username, 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_RELATION_TYPE_RRHH."
INNER JOIN $tableRelSessionCourseUser sc
ON (sc.session_id = su.session_id AND su.user_id = sc.user_id)
$where_filter
AND u.status <> ".DRH."
AND u.status <> 6
AND sc.c_id = $courseId
$order_clause
";
} else {
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
SELECT u.id, lastname, firstname, username, 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_RELATION_TYPE_RRHH."
WHERE
u.status <> ".DRH." AND
u.status <> 6
WHERE u.status <> ".DRH." AND u.status <> 6
$order_clause
";
}
@ -543,18 +510,15 @@ if ($ajax_search) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
SELECT u.id, lastname, firstname, username, 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_RELATION_TYPE_RRHH."
INNER JOIN $tbl_user_rel_access_url url_user
ON (url_user.user_id = u.id)
WHERE
access_url_id = $access_url_id
$where_filter
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
@ -579,18 +543,13 @@ if ($ajax_search) {
// filling the correct users in list
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
SELECT u.id, lastname, firstname, username, 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_RELATION_TYPE_RRHH."
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
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_RELATION_TYPE_RRHH."
WHERE u.status <> ".DRH." AND u.status <> 6 $order_clause
";
if (api_is_multiple_url_enabled()) {
@ -598,19 +557,14 @@ if ($ajax_search) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = "
SELECT u.id, lastname, firstname, username, su.session_id, official_code
SELECT u.id, lastname, firstname, username, 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_RELATION_TYPE_RRHH."
INNER JOIN $tbl_user_rel_access_url url_user
ON (url_user.user_id = u.id)
INNER JOIN $tableRelSessionCourseUser sc
ON (sc.session_id = su.session_id AND su.user_id = sc.user_id)
WHERE
sc.c_id = $courseId AND
access_url_id = $access_url_id
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_RELATION_TYPE_RRHH."
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
@ -634,13 +588,13 @@ if ($ajax_search) {
if ($add_type == 'multiple') {
$link_add_type_unique =
'<a href="'.api_get_self().'?course_id='.$courseId.'&id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'.
'<a href="'.api_get_self().'?id_session='.$id_session.'&add='.$addProcess.'&add_type=unique">'.
Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_multiple = Display::url(Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'), '');
} else {
$link_add_type_unique = Display::url(Display::return_icon('single.gif').get_lang('SessionAddTypeUnique'), '');
$link_add_type_multiple =
'<a href="'.api_get_self().'?course_id='.$courseId.'&id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'
'<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'
.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
}
$link_add_group = Display::url(
@ -668,12 +622,12 @@ $newLinks .= Display::url(
?>
</div>
<form name="formulaire" method="post"
action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&course_id=<?php echo $courseId; ?>&id_session=<?php echo $id_session; ?><?php if (!empty($addProcess)) {
action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if (!empty($addProcess)) {
echo '&add=true';
} ?>" <?php if ($ajax_search) {
echo ' onsubmit="valide();"';
} ?>>
<?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') - '.$courseInfo['title'].' </legend>'; ?>
<?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?>
<?php
if ($add_type == 'multiple') {
if (is_array($extra_field_list)) {
@ -784,7 +738,7 @@ $newLinks .= Display::url(
</select>
<br/>
<br/>
<?php
<?php
} ?>
<div class="control-course">
<?php

@ -110,7 +110,7 @@ function search_users($needle, $type)
if (api_is_session_admin()
&& api_get_setting('prevent_session_admins_to_manage_all_users') === 'true'
) {
$order_clause = " AND user.creator_id = ".api_get_user_id().$order_clause;
$order_clause = ' AND user.creator_id = '.api_get_user_id().$order_clause;
}
$cond_user_id = '';
@ -118,7 +118,7 @@ function search_users($needle, $type)
// Only for single & multiple
if (in_array($type, ['single', 'multiple'])) {
if (!empty($id_session)) {
$id_session = intval($id_session);
$id_session = (int) $id_session;
// check id_user from session_rel_user table
$sql = "
SELECT su.user_id
@ -153,10 +153,11 @@ function search_users($needle, $type)
username LIKE '$needle%'
OR lastname LIKE '$needle%'
OR firstname LIKE '$needle%'
)
AND user.status <> 6
AND user.status <> ".DRH."
$order_clause LIMIT 11
) AND
user.status <> 6 AND
user.status <> ".DRH."
$order_clause
LIMIT 11
";
break;
case 'multiple':
@ -164,9 +165,9 @@ function search_users($needle, $type)
SELECT user.id, username, lastname, firstname, official_code
FROM $tbl_user user
WHERE
lastname LIKE '$needle%'
AND user.status <> ".DRH."
AND user.status <> 6 $cond_user_id
lastname LIKE '$needle%' AND
user.status <> ".DRH." AND
user.status <> 6 $cond_user_id
$order_clause
";
break;
@ -174,11 +175,12 @@ function search_users($needle, $type)
$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.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 user.status <> 6 $cond_user_id
s.user_id IS NULL AND
user.status <> ".DRH." AND
user.status <> 6 $cond_user_id
$order_clause
";
break;
@ -393,10 +395,10 @@ if ($ajax_search) {
INNER JOIN $tbl_user u
ON su.user_id = u.id
WHERE
su.session_id = ".intval($id_session)." AND
su.relation_type <> ".SESSION_RELATION_TYPE_RRHH." AND
sc.c_id = $courseId AND
u.status<>".DRH." AND
su.session_id = ".intval($id_session)." AND
su.relation_type <> ".SESSION_RELATION_TYPE_RRHH." AND
sc.c_id = $courseId AND
u.status<>".DRH." AND
u.status <> 6
$order_clause
";
@ -409,17 +411,19 @@ if ($ajax_search) {
SELECT u.id, u.lastname, u.firstname, u.username, su.session_id, u.official_code
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
ON su.user_id = u.id
AND su.relation_type <> ".SESSION_RELATION_TYPE_RRHH."
AND su.session_id = ".intval($id_session)."
ON
su.user_id = u.id AND
su.relation_type <> ".SESSION_RELATION_TYPE_RRHH." AND
su.session_id = ".intval($id_session)."
INNER JOIN $tbl_user_rel_access_url url_user
ON (url_user.user_id = u.id)
INNER JOIN $tableRelSessionCourseUser sc
ON (sc.session_id = su.session_id AND su.user_id = sc.user_id)
WHERE access_url_id = $access_url_id
sc.c_id = $courseId AND
AND u.status <> ".DRH."
AND u.status <> 6
WHERE
access_url_id = $access_url_id AND
sc.c_id = $courseId AND
u.status <> ".DRH." AND
u.status <> 6
$order_clause
";
}
@ -459,7 +463,7 @@ if ($ajax_search) {
$use_extra_fields = true;
if ($fieldtype == ExtraField::FIELD_TYPE_TAG) {
$extra_field_result[] = UserManager::get_extra_user_data_by_tags(
intval($_POST['field_id']),
$_POST['field_id'],
$_POST[$varname]
);
} else {
@ -610,9 +614,9 @@ if ($ajax_search) {
ON (sc.session_id = su.session_id AND su.user_id = sc.user_id)
WHERE
sc.c_id = $courseId AND
access_url_id = $access_url_id
AND u.status <> ".DRH."
AND u.status <> 6
access_url_id = $access_url_id AND
u.status <> ".DRH." AND
u.status <> 6
$order_clause
";
}
@ -643,7 +647,6 @@ if ($add_type == 'multiple') {
'<a href="'.api_get_self().'?course_id='.$courseId.'&id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'
.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
}
?>
<div class="actions">
<?php
@ -764,7 +767,7 @@ if ($add_type == 'multiple') {
</select>
<br/>
<br/>
<?php
<?php
} ?>
<div class="control-course">
<?php

@ -27,6 +27,8 @@ if (empty($sessionId)) {
SessionManager::protectSession($sessionId);
$codePath = api_get_path(WEB_CODE_PATH);
$tool_name = get_lang('SessionOverview');
$interbreadcrumb[] = [
'url' => 'session_list.php',
@ -97,8 +99,10 @@ switch ($action) {
}
if (!empty($_GET['class'])) {
$result = Database::query("DELETE FROM $tbl_session_rel_class
WHERE session_id='$sessionId' AND class_id=".intval($_GET['class']));
$result = Database::query(
"DELETE FROM $tbl_session_rel_class
WHERE session_id='$sessionId' AND class_id=".intval($_GET['class'])
);
$nbr_affected_rows = Database::affected_rows($result);
Database::query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$sessionId'");
}
@ -218,25 +222,51 @@ if ($session->getNbrCourses() === 0) {
if ($allowSkills) {
$courseItem .= Display::url(
Display::return_icon('skills.png', get_lang('Skills')),
api_get_path(WEB_CODE_PATH).'admin/skill_rel_course.php?session_id='.$sessionId.'&course_id='.$course->getId()
$codePath.'admin/skill_rel_course.php?session_id='.$sessionId.'&course_id='.$course->getId()
);
}
$courseItem .= $orderButtons;
$courseItem .= '<a href="add_users_to_session_course.php?id_session='.$sessionId.'&course_id='.$course->getId().'">'.
Display::return_icon('new_user.png', get_lang('AddUsers'), ['style' => 'width:22px'], ICON_SIZE_MEDIUM).'</a>';
$courseItem .= '<a href="session_course_user_list.php?id_session='.$sessionId.'&course_code='.$course->getCode().'">'.
Display::return_icon('user.png', get_lang('Users'), '', ICON_SIZE_SMALL).'</a>';
$courseItem .= '<a href="'.api_get_path(WEB_CODE_PATH).'user/user_import.php?action=import&cidReq='.$course->getCode().'&id_session='.$sessionId.'">'.
Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), null, ICON_SIZE_SMALL).'</a>
<a href="'.api_get_path(WEB_CODE_PATH).'user/user_export.php?file_type=csv&course_session='.$course->getCode().':'.$sessionId.'&addcsvheader=1">'.
Display::return_icon('export_csv.png', get_lang('ExportUsersOfACourse'), null, ICON_SIZE_SMALL).'</a>
<a href="../tracking/courseLog.php?id_session='.$sessionId.'&cidReq='.$course->getCode().$orig_param.'&hide_course_breadcrumb=1">'.
Display::return_icon('statistics.png', get_lang('Tracking'), null, ICON_SIZE_SMALL).'</a>&nbsp;
<a href="session_course_edit.php?id_session='.$sessionId.'&page=resume_session.php&course_code='.$course->getCode().''.$orig_param.'">'.
Display::return_icon('teacher.png', get_lang('ModifyCoach'), '', ICON_SIZE_SMALL).'</a>
<a href="'.api_get_self().'?id_session='.$sessionId.'&action=delete&idChecked[]='.$course->getCode().'" onclick="javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete')).'</a>';
$courseItem .= Display::url(
Display::return_icon('new_user.png', get_lang('AddUsers')),
$codePath."session/add_users_to_session_course.php?id_session=$sessionId&course_id=".$course->getId()
);
$courseItem .= Display::url(
Display::return_icon('user.png', get_lang('Users')),
$codePath."session/session_course_user_list.php?id_session=$sessionId&course_code=".$course->getCode()
);
$courseItem .= Display::url(
Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse')),
$codePath."user/user_import.php?action=import&cidReq={$course->getCode()}&id_session=$sessionId"
);
$courseItem .= Display::url(
Display::return_icon('export_csv.png', get_lang('ExportUsersOfACourse')),
$codePath."user/user_export.php?file_type=csv&course_session={$course->getCode()}:$sessionId&addcsvheader=1"
);
$courseItem .= Display::url(
Display::return_icon('statistics.gif', get_lang('Tracking')),
$codePath."tracking/courseLog.php?id_session=$sessionId&cidReq={$course->getCode()}$orig_param&hide_course_breadcrumb=1"
);
$courseItem .= Display::url(
Display::return_icon('teacher.png', get_lang('ModifyCoach')),
$codePath."session/session_course_edit.php?id_session=$sessionId&page=resume_session.php&course_code={$course->getCode()}$orig_param"
);
$courseItem .= Display::url(
Display::return_icon('folder_document.png', get_lang('UploadFile')),
'#',
[
'class' => 'session-upload-file-btn',
'data-session' => $sessionId,
'data-course' => $course->getId(),
]
);
$courseItem .= Display::url(
Display::return_icon('delete.png', get_lang('Delete')),
api_get_self()."?id_session=$sessionId&action=delete&idChecked[]={$course->getCode()}",
[
'onclick' => "javascript:if(!confirm('".get_lang('ConfirmYourChoice')."')) return false;",
]
);
$courseItem .= '</td></tr>';
$count++;
@ -246,12 +276,12 @@ if ($session->getNbrCourses() === 0) {
$courseListToShow .= '</table><br />';
$url = '&nbsp;'.Display::url(
Display::return_icon('user_subscribe_session.png', get_lang('Add'), [], ICON_SIZE_SMALL),
"add_users_to_session.php?page=resume_session.php&id_session=$sessionId"
Display::return_icon('user_subscribe_session.png', get_lang('Add')),
$codePath."session/add_users_to_session.php?page=resume_session.php&id_session=$sessionId"
);
$url .= Display::url(
Display::return_icon('import_csv.png', get_lang('ImportUsers'), [], ICON_SIZE_SMALL),
"session_user_import.php?id_session=$sessionId"
Display::return_icon('import_csv.png', get_lang('ImportUsers')),
$codePath."session/session_user_import.php?id_session=$sessionId"
);
$url .= Display::url(
Display::return_icon('export_csv.png', get_lang('ExportUsers'), [], ICON_SIZE_SMALL),
@ -275,17 +305,19 @@ if (!empty($userList)) {
$userId = $user['user_id'];
$userInfo = api_get_user_info($userId);
$userLink = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.$userId.'">'.
$userLink = '<a href="'.$codePath.'admin/user_information.php?user_id='.$userId.'">'.
api_htmlentities($userInfo['complete_name_with_username']).'</a>';
$reportingLink = Display::url(
Display::return_icon('statistics.gif', get_lang('Reporting')),
api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$user['user_id'].''.$orig_param.'&id_session='.$sessionId
$codePath.'mySpace/myStudents.php?student='.$user['user_id'].''.$orig_param.'&id_session='
.$sessionId
);
$courseUserLink = Display::url(
Display::return_icon('course.png', get_lang('BlockCoursesForThisUser')),
api_get_path(WEB_CODE_PATH).'session/session_course_user.php?id_user='.$user['user_id'].'&id_session='.$sessionId
$codePath.'session/session_course_user.php?id_user='.$user['user_id'].'&id_session='
.$sessionId
);
$removeLink = Display::url(
@ -297,26 +329,17 @@ if (!empty($userList)) {
$addUserToUrlLink = '';
if ($multiple_url_is_on) {
if ($user['access_url_id'] != $url_id) {
$userLink .= ' '.Display::return_icon(
'warning.png',
get_lang('UserNotAddedInURL'),
[],
ICON_SIZE_SMALL
);
$add = Display::return_icon(
'add.png',
get_lang('AddUsersToURL'),
[],
ICON_SIZE_SMALL
);
$addUserToUrlLink = '<a href="resume_session.php?action=add_user_to_url&id_session='.$sessionId.'&user_id='.$user['user_id'].'">'.$add.'</a>';
$userLink .= ' '.Display::return_icon('warning.png', get_lang('UserNotAddedInURL'));
$add = Display::return_icon('add.png', get_lang('AddUsersToURL'));
$addUserToUrlLink = '<a href="resume_session.php?action=add_user_to_url&id_session='.$sessionId
.'&user_id='.$user['user_id'].'">'.$add.'</a>';
}
}
$editUrl = null;
/*
if (isset($sessionInfo['duration']) && !empty($sessionInfo['duration'])) {
$editUrl = api_get_path(WEB_CODE_PATH) . 'session/session_user_edit.php?session_id=' . $sessionId . '&user_id=' . $userId;
$editUrl = $codePath . 'session/session_user_edit.php?session_id=' . $sessionId . '&user_id=' . $userId;
$editUrl = Display::url(
Display::return_icon('agenda.png', get_lang('SessionDurationEdit')),
$editUrl
@ -330,7 +353,7 @@ if (!empty($userList)) {
$status = get_lang('Drh');
$link = Display::url(
Display::return_icon('edit.png', get_lang('Edit')),
api_get_path(WEB_CODE_PATH).'admin/dashboard_add_sessions_to_user.php?user='.$userId
$codePath.'admin/dashboard_add_sessions_to_user.php?user='.$userId
);
break;
default:

@ -84,7 +84,7 @@ $xajax->processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = "
<script>
$(document).ready( function() {
$(function() {
accessSwitcher(0);
});

@ -64,17 +64,11 @@ if (!list($session_name, $course_title) = Database::fetch_row($result)) {
switch ($action) {
case 'delete':
if (is_array($idChecked) && count($idChecked) > 0) {
array_map('intval', $idChecked);
$idChecked = implode(',', $idChecked);
}
if (!empty($idChecked)) {
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE session_id='$id_session' AND c_id='".$courseId."' AND user_id IN($idChecked)";
$result = Database::query($sql);
$nbr_affected_rows = Database::affected_rows($result);
$sql = "UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows
WHERE session_id='$id_session' AND c_id='".$courseId."'";
Database::query($sql);
foreach ($idChecked as $userId) {
SessionManager::unSubscribeUserFromCourseSession($userId, $courseId, $id_session);
}
} else {
SessionManager::unSubscribeUserFromCourseSession($idChecked, $courseId, $id_session);
}
header('Location: '.api_get_self()
.'?id_session='.$id_session.'&course_code='.urlencode($course_code).'&sort='.$sort);

@ -205,7 +205,7 @@ $form->display();
?>
<script>
$(document).ready( function() {
$(function() {
<?php
if (!empty($sessionInfo['duration'])) {
@ -239,7 +239,7 @@ function emptyDuration() {
}
}
$(document).on('ready', function (){
$(function() {
$('#show-options').on('click', function (e) {
e.preventDefault();
var display = $('#options').css('display');

@ -482,7 +482,7 @@ $form->addElement(
Display::url(
get_lang('ExampleCSVFile'),
api_get_path(WEB_CODE_PATH).'admin/example_session.csv',
['target' => '_blank']
['target' => '_blank', 'download' => null]
),
],
'CSV',
@ -496,7 +496,7 @@ $form->addElement(
Display::url(
get_lang('ExampleXMLFile'),
api_get_path(WEB_CODE_PATH).'admin/example_session.xml',
['target' => '_blank']
['target' => '_blank', 'download' => null]
),
],
'XML',

@ -21,10 +21,14 @@ $idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null;
$list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple';
if ($action == 'delete') {
$response = SessionManager::delete($idChecked);
if ($response) {
Display::addFlash(Display::return_message(get_lang('Deleted')));
$sessionInfo = api_get_session_info($idChecked);
if ($sessionInfo) {
$response = SessionManager::delete($idChecked);
if ($response) {
Display::addFlash(
Display::return_message(get_lang('Deleted').': '.Security::remove_XSS($sessionInfo['name']))
);
}
}
header('Location: session_list.php');
exit();

Loading…
Cancel
Save