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

pull/2588/merge
Alex Aragón 7 years ago
commit 94c98fca6e
  1. 2
      main/admin/add_drh_to_user.php
  2. 12
      main/admin/archive_cleanup.php
  3. 2
      main/admin/user_edit.php
  4. 3
      main/admin/user_information.php
  5. 20
      main/announcements/announcements.php
  6. 2
      main/auth/profile.php
  7. 21
      main/course_info/about.php
  8. 3
      main/forum/editthread.php
  9. 2
      main/forum/forumqualify.php
  10. 5
      main/inc/ajax/message.ajax.php
  11. 5
      main/inc/ajax/session.ajax.php
  12. 8
      main/inc/email_editor.php
  13. 20
      main/inc/global.inc.php
  14. 10
      main/inc/lib/AnnouncementManager.php
  15. 8
      main/inc/lib/api.lib.php
  16. 1
      main/inc/lib/course.lib.php
  17. 2
      main/inc/lib/database.constants.inc.php
  18. 1
      main/inc/lib/display.lib.php
  19. 10
      main/inc/lib/document.lib.php
  20. 6
      main/inc/lib/link.lib.php
  21. 74
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  22. 5
      main/inc/lib/skill.lib.php
  23. 24
      main/inc/lib/template.lib.php
  24. 275
      main/inc/lib/usermanager.lib.php
  25. 5
      main/inc/lib/webservices/Rest.php
  26. 9
      main/link/link.php
  27. 6
      main/session/about.php
  28. 25
      main/social/groups.php
  29. 4
      main/social/home.php
  30. 8
      main/social/invitations.php
  31. 2
      main/social/my_skills_report.php
  32. 1
      main/social/vcard_export.php
  33. 134
      main/template/default/layout/footer.js.tpl
  34. 40
      main/template/default/layout/head.tpl
  35. 255
      main/template/default/layout/header.js.tpl
  36. 2
      main/template/default/layout/page.tpl
  37. 37
      main/template/default/layout/page_footer.tpl
  38. 1
      main/template/default/layout/show_footer.tpl
  39. 2
      plugin/buycourses/src/configure_course.php
  40. 8
      plugin/buycourses/src/service_process.php
  41. 2
      plugin/buycourses/src/services_add.php
  42. 2
      plugin/buycourses/src/services_edit.php
  43. 1
      src/Chamilo/CoreBundle/Composer/ScriptHandler.php
  44. 354
      src/Chamilo/UserBundle/Entity/Repository/UserRepository.php
  45. 2
      src/Chamilo/UserBundle/Entity/User.php
  46. 137
      src/Chamilo/UserBundle/Repository/UserRepository.php
  47. 14
      tests/behat/features/toolGroup.feature

@ -15,7 +15,7 @@ if (!isset($_REQUEST['u'])) {
} }
$em = Database::getManager(); $em = Database::getManager();
$userRepository = $em->getRepository('ChamiloUserBundle:User'); $userRepository = UserManager::getRepository();
/** @var UserEntity $user */ /** @var UserEntity $user */
$user = UserManager::getManager()->find($_REQUEST['u']); $user = UserManager::getManager()->find($_REQUEST['u']);

@ -36,6 +36,18 @@ if ($form->validate()) {
opcache_reset(); opcache_reset();
} }
$file = api_get_path(SYS_PUBLIC_PATH).'build/main.js';
if (file_exists($file)) {
unlink($file);
}
$dir = api_get_path(SYS_PUBLIC_PATH).'build';
$files = scandir($dir);
foreach ($files as $file) {
if (preg_match('/main\..*\.js/', $file)) {
unlink($dir.'/'.$file);
}
}
$archive_path = api_get_path(SYS_ARCHIVE_PATH); $archive_path = api_get_path(SYS_ARCHIVE_PATH);
$htaccess = @file_get_contents($archive_path.'.htaccess'); $htaccess = @file_get_contents($archive_path.'.htaccess');
$result = rmdirr($archive_path, true, true); $result = rmdirr($archive_path, true, true);

@ -388,7 +388,7 @@ if ($form->validate()) {
$picture_uri = $user_data['picture_uri']; $picture_uri = $user_data['picture_uri'];
if (isset($user['delete_picture']) && $user['delete_picture']) { if (isset($user['delete_picture']) && $user['delete_picture']) {
$picture_uri = UserManager::delete_user_picture($user_id); $picture_uri = UserManager::deleteUserPicture($user_id);
} elseif (!empty($picture['name'])) { } elseif (!empty($picture['name'])) {
$picture_uri = UserManager::update_user_picture( $picture_uri = UserManager::update_user_picture(
$user_id, $user_id,

@ -621,8 +621,7 @@ if ($studentBossList) {
} }
$em = Database::getManager(); $em = Database::getManager();
/** @var \Chamilo\UserBundle\Entity\Repository\UserRepository $userRepository */ $userRepository = UserManager::getRepository();
$userRepository = $em->getRepository('ChamiloUserBundle:User');
$hrmList = $userRepository->getAssignedHrmUserList( $hrmList = $userRepository->getAssignedHrmUserList(
$userEntity->getId(), $userEntity->getId(),

@ -378,7 +378,7 @@ switch ($action) {
} }
// DISPLAY ADD ANNOUNCEMENT COMMAND // DISPLAY ADD ANNOUNCEMENT COMMAND
$id = isset($_GET['id']) ? intval($_GET['id']) : 0; $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$url = api_get_self().'?action='.$action.'&id='.$id.'&'.api_get_cidreq(); $url = api_get_self().'?action='.$action.'&id='.$id.'&'.api_get_cidreq();
$form = new FormValidator( $form = new FormValidator(
@ -389,15 +389,13 @@ switch ($action) {
['enctype' => 'multipart/form-data'] ['enctype' => 'multipart/form-data']
); );
$form_name = get_lang('ModifyAnnouncement');
if (empty($id)) { if (empty($id)) {
$form_name = get_lang('AddAnnouncement'); $form_name = get_lang('AddAnnouncement');
} else {
$form_name = get_lang('ModifyAnnouncement');
} }
$interbreadcrumb[] = [ $interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."announcements/announcements.php?".api_get_cidreq(), 'url' => api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq(),
"name" => $nameTools, 'name' => $nameTools,
]; ];
$nameTools = $form_name; $nameTools = $form_name;
@ -424,7 +422,7 @@ switch ($action) {
} elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] === 'true') { } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] === 'true') {
// we want to remind inactive users. The $_GET['since'] parameter // we want to remind inactive users. The $_GET['since'] parameter
// determines which users have to be warned (i.e the users who have been inactive for x days or more // determines which users have to be warned (i.e the users who have been inactive for x days or more
$since = isset($_GET['since']) ? intval($_GET['since']) : 6; $since = isset($_GET['since']) ? (int) $_GET['since'] : 6;
// Getting the users who have to be reminded // Getting the users who have to be reminded
$to = Tracking::getInactiveStudentsInCourse( $to = Tracking::getInactiveStudentsInCourse(
@ -477,7 +475,6 @@ switch ($action) {
$announcementInfo = AnnouncementManager::get_by_id($courseId, $id); $announcementInfo = AnnouncementManager::get_by_id($courseId, $id);
if (isset($announcementInfo) && !empty($announcementInfo)) { if (isset($announcementInfo) && !empty($announcementInfo)) {
$to = AnnouncementManager::load_edit_users('announcement', $id); $to = AnnouncementManager::load_edit_users('announcement', $id);
$defaults = [ $defaults = [
'title' => $announcementInfo['title'], 'title' => $announcementInfo['title'],
'content' => $announcementInfo['content'], 'content' => $announcementInfo['content'],
@ -498,7 +495,6 @@ switch ($action) {
if (!isset($parts[1]) || empty($parts[1])) { if (!isset($parts[1]) || empty($parts[1])) {
continue; continue;
} }
$form->addHtml(" $form->addHtml("
<script> <script>
$(document).on('ready', function () { $(document).on('ready', function () {
@ -515,20 +511,19 @@ switch ($action) {
'text', 'text',
'title', 'title',
get_lang('EmailTitle'), get_lang('EmailTitle'),
["onkeypress" => "return event.keyCode != 13;"] ['onkeypress' => 'return event.keyCode != 13;']
); );
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('hidden', 'id'); $form->addElement('hidden', 'id');
$htmlTags = ''; $htmlTags = '';
$tags = AnnouncementManager::getTags(); $tags = AnnouncementManager::getTags();
foreach ($tags as $tag) { foreach ($tags as $tag) {
$htmlTags .= "<b>".$tag."</b><br />"; $htmlTags .= "<b>$tag</b><br />";
} }
$form->addButtonAdvancedSettings('tags', get_lang('Tags')); $form->addButtonAdvancedSettings('tags', get_lang('Tags'));
$form->addElement('html', '<div id="tags_options" style="display:none">'); $form->addElement('html', '<div id="tags_options" style="display:none">');
$form->addLabel('', Display::return_message($htmlTags, 'normal', false)); $form->addLabel('', Display::return_message($htmlTags, 'normal', false));
$form->addElement('html', '</div>'); $form->addElement('html', '</div>');
$form->addHtmlEditor( $form->addHtmlEditor(
'content', 'content',
get_lang('Description'), get_lang('Description'),
@ -536,7 +531,6 @@ switch ($action) {
false, false,
['ToolbarSet' => 'Announcements'] ['ToolbarSet' => 'Announcements']
); );
$form->addElement('file', 'user_upload', get_lang('AddAnAttachment')); $form->addElement('file', 'user_upload', get_lang('AddAnAttachment'));
$form->addElement('textarea', 'file_comment', get_lang('FileComment')); $form->addElement('textarea', 'file_comment', get_lang('FileComment'));
$form->addHidden('sec_token', $token); $form->addHidden('sec_token', $token);

@ -473,7 +473,7 @@ if ($form->validate()) {
} }
} elseif (!empty($user_data['remove_picture'])) { } elseif (!empty($user_data['remove_picture'])) {
// remove existing picture if asked // remove existing picture if asked
UserManager::delete_user_picture(api_get_user_id()); UserManager::deleteUserPicture(api_get_user_id());
$user_data['picture_uri'] = ''; $user_data['picture_uri'] = '';
} }

@ -1,4 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\CourseRelUser;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CourseBundle\Entity\CCourseDescription;
/** /**
* Course about page * Course about page
* Show information about a course. * Show information about a course.
@ -7,17 +14,11 @@
* *
* @package chamilo.course * @package chamilo.course
*/ */
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\CourseRelUser;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CourseBundle\Entity\CCourseDescription;
use Chamilo\UserBundle\Entity\User;
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$courseId = isset($_GET['course_id']) ? intval($_GET['course_id']) : 0; $courseId = isset($_GET['course_id']) ? (int) $_GET['course_id'] : 0;
$token = Security::get_existing_token(); $token = Security::get_existing_token();
$em = Database::getManager(); $em = Database::getManager();
//userID //userID
@ -29,8 +30,8 @@ $course = $em->find('ChamiloCoreBundle:Course', $courseId);
if (!$course) { if (!$course) {
api_not_allowed(true); api_not_allowed(true);
} }
/** @var User $userRepo */
$userRepo = $em->getRepository('ChamiloUserBundle:User'); $userRepo = UserManager::getRepository();
$fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField'); $fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField');
$fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); $fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag');
@ -51,9 +52,7 @@ $courseValues = new ExtraFieldValue('course');
$userValues = new ExtraFieldValue('user'); $userValues = new ExtraFieldValue('user');
$urlCourse = api_get_path(WEB_PATH).'main/course/about.php?course_id='.$courseId; $urlCourse = api_get_path(WEB_PATH).'main/course/about.php?course_id='.$courseId;
$courseTeachers = $course->getTeachers(); $courseTeachers = $course->getTeachers();
$teachersData = []; $teachersData = [];
/** @var CourseRelUser $teacherSubscription */ /** @var CourseRelUser $teacherSubscription */

@ -253,9 +253,7 @@ if ($form->validate()) {
$values = $form->exportValues(); $values = $form->exportValues();
Security::clear_token(); Security::clear_token();
updateThread($values); updateThread($values);
Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $threadId); Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $threadId);
header('Location: '.$redirectUrl); header('Location: '.$redirectUrl);
exit; exit;
} }
@ -265,7 +263,6 @@ $form->setDefaults(isset($defaults) ? $defaults : null);
$token = Security::get_token(); $token = Security::get_token();
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
$form->setConstants(['sec_token' => $token]); $form->setConstants(['sec_token' => $token]);
$originIsLearnPath = $origin == 'learnpath'; $originIsLearnPath = $origin == 'learnpath';
$view = new Template( $view = new Template(

@ -267,9 +267,7 @@ if (isset($rows)) {
echo "<tr>"; echo "<tr>";
echo "<td rowspan=\"3\" class=\"$leftclass\">"; echo "<td rowspan=\"3\" class=\"$leftclass\">";
echo '<br /><b>'.api_convert_and_format_date($row['post_date'], DATE_TIME_FORMAT_LONG).'</b><br />'; echo '<br /><b>'.api_convert_and_format_date($row['post_date'], DATE_TIME_FORMAT_LONG).'</b><br />';
echo "</td>"; echo "</td>";
// The post title // The post title

@ -1,7 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\UserBundle\Entity\Repository\UserRepository;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
$_dont_save_user_course_access = true; $_dont_save_user_course_access = true;
@ -96,9 +95,7 @@ switch ($action) {
break; break;
} }
/** @var UserRepository $repo */ $repo = UserManager::getRepository();
$repo = Database::getManager()->getRepository('ChamiloUserBundle:User');
$users = $repo->findUsersToSendMessage( $users = $repo->findUsersToSendMessage(
api_get_user_id(), api_get_user_id(),
$_REQUEST['q'], $_REQUEST['q'],

@ -1,7 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\UserBundle\Entity\Repository\UserRepository;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
/** /**
@ -187,9 +186,7 @@ switch ($action) {
'items' => [], 'items' => [],
]; ];
$entityManager = Database::getManager(); $usersRepo = UserManager::getRepository();
/** @var UserRepository $usersRepo */
$usersRepo = $entityManager->getRepository('ChamiloUserBundle:User');
$users = $usersRepo->searchUsersByStatus($_GET['q'], COURSEMANAGER, api_get_current_access_url_id()); $users = $usersRepo->searchUsersByStatus($_GET['q'], COURSEMANAGER, api_get_current_access_url_id());
/** @var User $user */ /** @var User $user */
foreach ($users as $user) { foreach ($users as $user) {

@ -66,7 +66,7 @@ $defaults = [
$form->setDefaults($defaults); $form->setDefaults($defaults);
if ($form->validate()) { if ($form->validate()) {
$text = Security::remove_XSS($_POST['email_text'])."\n\n---\n".get_lang('EmailSentFromLMS')." ".api_get_path(WEB_PATH); $text = Security::remove_XSS($_POST['email_text'])."\n\n---\n".get_lang('EmailSentFromLMS').' '.api_get_path(WEB_PATH);
$email_administrator = Security::remove_XSS($_POST['dest']); $email_administrator = Security::remove_XSS($_POST['dest']);
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$title = Security::remove_XSS($_POST['email_title']); $title = Security::remove_XSS($_POST['email_title']);
@ -80,12 +80,6 @@ if ($form->validate()) {
api_get_person_name($_user['firstname'], $_user['lastname']), api_get_person_name($_user['firstname'], $_user['lastname']),
$_user['mail'] $_user['mail']
); );
UserManager::send_message_in_outbox(
$email_administrator,
$user_id,
$title,
$content
);
} else { } else {
api_mail_html( api_mail_html(
'', '',

@ -632,6 +632,26 @@ $default_quota = api_get_setting('default_document_quotum');
if (empty($default_quota)) { if (empty($default_quota)) {
$default_quota = 100000000; $default_quota = 100000000;
} }
define('DEFAULT_DOCUMENT_QUOTA', $default_quota); define('DEFAULT_DOCUMENT_QUOTA', $default_quota);
// Forcing PclZip library to use a custom temporary folder. // Forcing PclZip library to use a custom temporary folder.
define('PCLZIP_TEMPORARY_DIR', api_get_path(SYS_ARCHIVE_PATH)); define('PCLZIP_TEMPORARY_DIR', api_get_path(SYS_ARCHIVE_PATH));
// Create web/build/main.js
if (!is_dir(api_get_path(SYS_PUBLIC_PATH).'build')) {
mkdir(api_get_path(SYS_PUBLIC_PATH).'build');
}
// Load template layout/header.js.tpl and save it into web/build/main.js
$file = api_get_path(SYS_PUBLIC_PATH).'build/main.js';
if (!empty($language_interface)) {
$file = api_get_path(SYS_PUBLIC_PATH).'build/main.'.$language_interface.'.js';
}
// if portal is in test mode always generate the file
if (!file_exists($file) || api_get_setting('server_type') === 'test') {
$template = new Template();
// Force use of default to avoid problems
$tpl = 'default/layout/header.js.tpl';
$contents = $template->fetch($tpl);
file_put_contents($file, $contents);
}

@ -806,7 +806,7 @@ class AnnouncementManager
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$table = Database::get_course_table(TABLE_ANNOUNCEMENT); $table = Database::get_course_table(TABLE_ANNOUNCEMENT);
$id = intval($id); $id = (int) $id;
$params = [ $params = [
'title' => $title, 'title' => $title,
@ -824,7 +824,7 @@ class AnnouncementManager
$id_attach = 0; $id_attach = 0;
if ($row_attach) { if ($row_attach) {
$id_attach = intval($row_attach['id']); $id_attach = (int) $row_attach['id'];
} }
if (!empty($file)) { if (!empty($file)) {
@ -1123,14 +1123,16 @@ class AnnouncementManager
switch ($toGroup) { switch ($toGroup) {
// it was send to one specific user // it was send to one specific user
case null: case null:
$to[] = "USER:".$row['to_user_id']; if (isset($row['to_user_id']) && !empty($row['to_user_id'])) {
$to[] = 'USER:'.$row['to_user_id'];
}
break; break;
// it was sent to everyone // it was sent to everyone
case 0: case 0:
return 'everyone'; return 'everyone';
break; break;
default: default:
$to[] = "GROUP:".$toGroup; $to[] = 'GROUP:'.$toGroup;
} }
} }

@ -1712,10 +1712,12 @@ function api_get_user_info(
function api_get_user_entity($userId) function api_get_user_entity($userId)
{ {
$userId = (int) $userId; $userId = (int) $userId;
/** @var \Chamilo\UserBundle\Repository\UserRepository $repo */ $repo = UserManager::getRepository();
$repo = Database::getManager()->getRepository('ChamiloUserBundle:User');
return $repo->find($userId); /** @var User $user */
$user = $repo->find($userId);
return $user;
} }
/** /**

@ -5978,6 +5978,7 @@ class CourseManager
{ {
$userList = self::getCourseUsers(true); $userList = self::getCourseUsers(true);
$groupList = self::getCourseGroups(); $groupList = self::getCourseGroups();
$array = self::buildSelectOptions( $array = self::buildSelectOptions(
$groupList, $groupList,
$userList, $userList,

@ -346,4 +346,4 @@ define('TABLE_CAL_TEMP', 'cal_temp');
define('TABLE_STATISTIC_TRACK_E_EXERCICES_TEMP', 'track_e_exercices_temp'); define('TABLE_STATISTIC_TRACK_E_EXERCICES_TEMP', 'track_e_exercices_temp');
define('TABLE_USER_INFO_DEF', 'userinfo_def'); define('TABLE_USER_INFO_DEF', 'userinfo_def');
define('TABLE_USER_INFO_CONTENT', 'userinfo_content'); define('TABLE_USER_INFO_CONTENT', 'userinfo_content');

@ -160,7 +160,6 @@ class Display
*/ */
public static function display_reduced_footer() public static function display_reduced_footer()
{ {
echo self::$global_template->show_footer_js_template();
echo '</body></html>'; echo '</body></html>';
} }

@ -6778,10 +6778,16 @@ class DocumentManager
'id' => $parentId, 'id' => $parentId,
'deleteid' => $documentData['id'], 'deleteid' => $documentData['id'],
]); ]);
$btn = Display::url( $btn = Display::url(
$iconEn, $iconEn,
api_get_self()."?$courseParams&$urlDeleteParams", '#',
['onclick' => "return confirmation('$titleToShow');"] [
'data-item-title' => $titleToShow,
'data-href' => api_get_self()."?$courseParams&$urlDeleteParams",
'data-toggle' => 'modal',
'data-target' => '#confirm-delete',
]
); );
if ( if (

@ -1722,9 +1722,9 @@ class Link extends Model
} }
/** /**
* @param int $linkId * @param int $linkId
* @param $action * @param string $action
* @param null $token * @param null $token
* *
* @return FormValidator * @return FormValidator
*/ */

@ -475,7 +475,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
* Sets element template * Sets element template
* *
* @param string $html (optional) The HTML surrounding select boxes and buttons * @param string $html (optional) The HTML surrounding select boxes and buttons
* @param string $js (optional) if we need to include qfams javascript handler * @param bool $js (optional) if we need to include qfams javascript handler
* *
* @access public * @access public
* @return string * @return string
@ -558,6 +558,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$selectNameFrom = $this->getName().'-f[]'; $selectNameFrom = $this->getName().'-f[]';
$selectNameTo = $this->getName().'[]'; $selectNameTo = $this->getName().'[]';
$selected_count = 0; $selected_count = 0;
$rightAll = '';
$leftAll = '';
// placeholder {unselected} existence determines if we will render // placeholder {unselected} existence determines if we will render
if (strpos($this->_elementTemplate, '{unselected}') === false) { if (strpos($this->_elementTemplate, '{unselected}') === false) {
@ -589,15 +591,14 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
} }
$checkbox_id_suffix++; $checkbox_id_suffix++;
$strHtmlSelected .= $tab $strHtmlSelected .= $tab
. '<label' .'<label'
. $this->_getAttrString($labelAttributes) .'>' .$this->_getAttrString($labelAttributes).'>'
. '<input type="checkbox"' .'<input type="checkbox"'
. ' id="'.$selectId . $checkbox_id_suffix.'"' .' id="'.$selectId.$checkbox_id_suffix.'"'
. ' name="'.$selectName.'"' .' name="'.$selectName.'"'
. $checked .$checked.$this->_getAttrString($option['attr'])
. $this->_getAttrString($option['attr']) .' />'.$option['text'].'</label>'
. ' />' . $option['text'] . '</label>' .PHP_EOL;
. PHP_EOL;
} }
$strHtmlSelected .= $tab . '</div>'. PHP_EOL; $strHtmlSelected .= $tab . '</div>'. PHP_EOL;
@ -657,8 +658,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$this->_attributesHidden $this->_attributesHidden
= array( = array(
'name' => $selectName, 'name' => $selectName,
'style' => 'overflow: hidden; visibility: hidden; '. 'style' => 'overflow: hidden; visibility: hidden; width: 1px; height: 0;',
'width: 1px; height: 0;',
); );
$this->_attributesHidden $this->_attributesHidden
= array_merge($this->_attributes, $this->_attributesHidden); = array_merge($this->_attributes, $this->_attributesHidden);
@ -677,11 +677,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
if ($options > 0) { if ($options > 0) {
$arrHtmlHidden = array_fill(0, $options, ' '); $arrHtmlHidden = array_fill(0, $options, ' ');
foreach ($this->_options as $option) { foreach ($this->_options as $option) {
if (is_array($this->_values) if (is_array($this->_values) && in_array((string) $option['attr']['value'], $this->_values)) {
&& in_array(
(string)$option['attr']['value'],
$this->_values
)) {
// Get the post order // Get the post order
$key = array_search( $key = array_search(
$option['attr']['value'], $option['attr']['value'],
@ -712,28 +708,24 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
// The 'unselected' multi-select which appears on the left // The 'unselected' multi-select which appears on the left
$unselected_count = count($arrHtmlUnselected); $unselected_count = count($arrHtmlUnselected);
if ($unselected_count == 0) { if ($unselected_count == 0) {
//$this->_attributesUnselected['disabled'] = 'disabled'; $this->_attributesUnselected = array_merge($this->_attributes, $this->_attributesUnselected);
$this->_attributesUnselected
= array_merge($this->_attributes, $this->_attributesUnselected);
$attrUnselected = $this->_getAttrString($this->_attributesUnselected); $attrUnselected = $this->_getAttrString($this->_attributesUnselected);
} }
$strHtmlUnselected = "<select$attrUnselected>". PHP_EOL; $strHtmlUnselected = "<select$attrUnselected>". PHP_EOL;
if ($unselected_count > 0) { if ($unselected_count > 0) {
foreach ($arrHtmlUnselected as $data) { foreach ($arrHtmlUnselected as $data) {
$strHtmlUnselected $strHtmlUnselected
.= $tabs . $tab .= $tabs.$tab
. '<option' . $this->_getAttrString($data['attr']) . '>' .'<option'.$this->_getAttrString($data['attr']).'>'
. $data['text'] . '</option>' . PHP_EOL; .$data['text'].'</option>'.PHP_EOL;
} }
} }
$strHtmlUnselected .= '</select>'; $strHtmlUnselected .= '</select>';
// The 'selected' multi-select which appears on the right // The 'selected' multi-select which appears on the right
$selected_count = count($arrHtmlSelected); $selected_count = count($arrHtmlSelected);
if ($selected_count == 0) { if ($selected_count == 0) {
$this->_attributesSelected $this->_attributesSelected = array_merge($this->_attributes, $this->_attributesSelected);
= array_merge($this->_attributes, $this->_attributesSelected);
$attrSelected = $this->_getAttrString($this->_attributesSelected); $attrSelected = $this->_getAttrString($this->_attributesSelected);
} }
$strHtmlSelected = "<select$attrSelected>"; $strHtmlSelected = "<select$attrSelected>";
@ -749,9 +741,9 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$text = $data['text']; $text = $data['text'];
} }
$strHtmlSelected $strHtmlSelected
.= $tabs . $tab .= $tabs.$tab
. '<option' . $attribute. '>' .'<option'.$attribute.'>'
. $text . '</option>'; .$text.'</option>';
} }
} }
$strHtmlSelected .= '</select>'; $strHtmlSelected .= '</select>';
@ -768,6 +760,18 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes); $attrStrAdd = $this->_getAttrString($this->_addButtonAttributes);
$strHtmlAdd = "<button $attrStrAdd /> <em class='fa fa-arrow-right'></em></button><br /><br />"; $strHtmlAdd = "<button $attrStrAdd /> <em class='fa fa-arrow-right'></em></button><br /><br />";
if ($this->selectAllCheckBox) {
$attributes = array('id' => $selectId.'_rightAll');
$this->_addButtonAttributes = array_merge($this->_addButtonAttributes, $attributes);
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes);
$rightAll = "<button $attrStrAdd /> <em class='fa fa-forward'></em></button><br /><br />";
$attributes = array('id' => $selectId.'_leftAll');
$this->_addButtonAttributes = array_merge($this->_addButtonAttributes, $attributes);
$attrStrAdd = $this->_getAttrString($this->_addButtonAttributes);
$leftAll = "<br /><br /><button $attrStrAdd /> <em class='fa fa-backward'></em></button>";
}
// build the select all button with all its attributes // build the select all button with all its attributes
$strHtmlAll = ''; $strHtmlAll = '';
@ -875,8 +879,8 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlSelectedCount, $strHtmlSelectedCount,
$strHtmlUnselected, $strHtmlUnselected,
$strHtmlSelected.$strHtmlHidden, $strHtmlSelected.$strHtmlHidden,
$strHtmlAdd, $rightAll.$strHtmlAdd,
$strHtmlRemove, $strHtmlRemove.$leftAll,
$strHtmlAll, $strHtmlAll,
$strHtmlNone, $strHtmlNone,
$strHtmlToggle, $strHtmlToggle,
@ -886,14 +890,6 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
$strHtmlMoveBottom, $strHtmlMoveBottom,
); );
if ($this->selectAllCheckBox) {
$strHtml .= '<div class="col-sm-8">
<label >'.get_lang('SelectAll').'
<input type="checkbox" class="advmultiselect_checkbox" id="'.$selectId.'_select_all'.'">
</label>
</div>';
}
$strHtml = str_replace($placeHolders, $htmlElements, $strHtml); $strHtml = str_replace($placeHolders, $htmlElements, $strHtml);
$comment = $this->getComment(); $comment = $this->getComment();

@ -5,7 +5,6 @@ use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\Skill as SkillEntity; use Chamilo\CoreBundle\Entity\Skill as SkillEntity;
use Chamilo\SkillBundle\Entity\SkillRelCourse; use Chamilo\SkillBundle\Entity\SkillRelCourse;
use Chamilo\SkillBundle\Entity\SkillRelItem; use Chamilo\SkillBundle\Entity\SkillRelItem;
use Chamilo\UserBundle\Entity\Repository\UserRepository;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
use Fhaculty\Graph\Graph; use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Vertex; use Fhaculty\Graph\Vertex;
@ -2095,9 +2094,7 @@ class Skill extends Model
return true; return true;
} }
$entityManager = Database::getManager(); $userRepo = UserManager::getRepository();
/** @var UserRepository $userRepo */
$userRepo = $entityManager->getRepository('ChamiloUserBundle:User');
$fromUserStatus = $fromUser->getStatus(); $fromUserStatus = $fromUser->getStatus();
switch ($fromUserStatus) { switch ($fromUserStatus) {

@ -564,6 +564,8 @@ class Template
*/ */
public function set_system_parameters() public function set_system_parameters()
{ {
// Get the interface language from global.inc.php
global $language_interface;
$this->theme = api_get_visual_theme(); $this->theme = api_get_visual_theme();
if (!empty($this->preview_theme)) { if (!empty($this->preview_theme)) {
$this->theme = $this->preview_theme; $this->theme = $this->preview_theme;
@ -583,6 +585,7 @@ class Template
'date' => api_format_date('now', DATE_FORMAT_LONG), 'date' => api_format_date('now', DATE_FORMAT_LONG),
'timezone' => api_get_timezone(), 'timezone' => api_get_timezone(),
'gamification_mode' => api_get_setting('gamification_mode'), 'gamification_mode' => api_get_setting('gamification_mode'),
'language_interface' => $language_interface,
]; ];
$this->assign('_s', $_s); $this->assign('_s', $_s);
} }
@ -770,7 +773,7 @@ class Template
} }
} }
if (CHAMILO_LOAD_WYSIWYG == true) { if (CHAMILO_LOAD_WYSIWYG === true) {
$bowerJsFiles[] = 'ckeditor/ckeditor.js'; $bowerJsFiles[] = 'ckeditor/ckeditor.js';
} }
@ -859,15 +862,6 @@ class Template
$this->display($tpl); $this->display($tpl);
} }
/**
* Show footer js template.
*/
public function show_footer_js_template()
{
$tpl = $this->get_template('layout/footer.js.tpl');
$this->display($tpl);
}
/** /**
* Sets the plugin content in a template variable. * Sets the plugin content in a template variable.
* *
@ -1377,6 +1371,7 @@ class Template
'web_query_vars' => api_htmlentities($_SERVER['QUERY_STRING']), 'web_query_vars' => api_htmlentities($_SERVER['QUERY_STRING']),
'web_self_query_vars' => api_htmlentities($_SERVER['REQUEST_URI']), 'web_self_query_vars' => api_htmlentities($_SERVER['REQUEST_URI']),
'web_cid_query' => api_get_cidreq(), 'web_cid_query' => api_get_cidreq(),
'web_rel_code' => api_get_path(REL_CODE_PATH),
]; ];
} }
@ -1401,15 +1396,6 @@ class Template
} }
} }
$this->assign(
'online_button',
Display::return_icon('statusonline.png', null, [], ICON_SIZE_ATOM)
);
$this->assign(
'offline_button',
Display::return_icon('statusoffline.png', null, [], ICON_SIZE_ATOM)
);
// Get language iso-code for this page - ignore errors // Get language iso-code for this page - ignore errors
$this->assign('document_language', api_get_language_isocode()); $this->assign('document_language', api_get_language_isocode());

@ -5,8 +5,8 @@ use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
use Chamilo\CoreBundle\Entity\Repository\AccessUrlRepository; use Chamilo\CoreBundle\Entity\Repository\AccessUrlRepository;
use Chamilo\CoreBundle\Entity\SkillRelUser; use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment; use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\UserBundle\Entity\Repository\UserRepository;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
use Chamilo\UserBundle\Repository\UserRepository;
use ChamiloSession as Session; use ChamiloSession as Session;
use Symfony\Component\Security\Core\Encoder\EncoderFactory; use Symfony\Component\Security\Core\Encoder\EncoderFactory;
@ -638,7 +638,7 @@ class UserManager
* @assert (-1) === false * @assert (-1) === false
* @assert ('abc') === false * @assert ('abc') === false
*/ */
public static function can_delete_user($user_id) public static function canDeleteUser($user_id)
{ {
$deny = api_get_configuration_value('deny_delete_users'); $deny = api_get_configuration_value('deny_delete_users');
@ -692,7 +692,7 @@ class UserManager
return false; return false;
} }
if (!self::can_delete_user($user_id)) { if (!self::canDeleteUser($user_id)) {
return false; return false;
} }
@ -1106,7 +1106,7 @@ class UserManager
} }
$userManager = self::getManager(); $userManager = self::getManager();
/** @var Chamilo\UserBundle\Entity\User $user */ /** @var User $user */
$user = self::getRepository()->find($user_id); $user = self::getRepository()->find($user_id);
if (empty($user)) { if (empty($user)) {
@ -1238,7 +1238,10 @@ class UserManager
get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)."\n\n". get_lang('Address')." ".api_get_setting('siteName')." ".get_lang('Is')." : ".api_get_path(WEB_PATH)."\n\n".
get_lang('Problem')."\n\n". get_lang('Problem')."\n\n".
get_lang('SignatureFormula').",\n\n". get_lang('SignatureFormula').",\n\n".
api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n". api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname')
)."\n".
get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n". get_lang('Manager')." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".
get_lang('Email')." : ".api_get_setting('emailAdministrator'); get_lang('Email')." : ".api_get_setting('emailAdministrator');
} }
@ -1991,7 +1994,6 @@ class UserManager
} }
$pictureSysPath = self::get_user_picture_path_by_id($user_id, 'system'); $pictureSysPath = self::get_user_picture_path_by_id($user_id, 'system');
$file = $pictureSysPath['dir'].$realSizeName.$pictureWebFile; $file = $pictureSysPath['dir'].$realSizeName.$pictureWebFile;
$picture = ''; $picture = '';
if (file_exists($file)) { if (file_exists($file)) {
@ -2190,13 +2192,13 @@ class UserManager
* Deletes user photos. * Deletes user photos.
* Note: This method relies on configuration setting from main/inc/conf/profile.conf.php. * Note: This method relies on configuration setting from main/inc/conf/profile.conf.php.
* *
* @param int $user_id the user internal identification number * @param int $userId the user internal identification number
* *
* @return mixed returns empty string on success, FALSE on error * @return mixed returns empty string on success, FALSE on error
*/ */
public static function delete_user_picture($user_id) public static function deleteUserPicture($userId)
{ {
return self::update_user_picture($user_id); return self::update_user_picture($userId);
} }
/** /**
@ -2929,7 +2931,8 @@ class UserManager
* Gives a list of [session_category][session_id] for the current user. * Gives a list of [session_category][session_id] for the current user.
* *
* @param int $user_id * @param int $user_id
* @param bool $is_time_over whether to fill the first element or not (to give space for courses out of categories) * @param bool $is_time_over whether to fill the first element or not
* (to give space for courses out of categories)
* @param bool $ignore_visibility_for_admins optional true if limit time from session is over, false otherwise * @param bool $ignore_visibility_for_admins optional true if limit time from session is over, false otherwise
* @param bool $ignoreTimeLimit ignore time start/end * @param bool $ignoreTimeLimit ignore time start/end
* *
@ -2980,17 +2983,17 @@ class UserManager
WHERE (scu.user = :user OR s.generalCoach = :user) AND url.accessUrlId = :url "; WHERE (scu.user = :user OR s.generalCoach = :user) AND url.accessUrlId = :url ";
// Default order // Default order
$order = "ORDER BY sc.name, s.name"; $order = 'ORDER BY sc.name, s.name';
// Order by date if showing all sessions // Order by date if showing all sessions
$showAllSessions = api_get_configuration_value('show_all_sessions_on_my_course_page') === true; $showAllSessions = api_get_configuration_value('show_all_sessions_on_my_course_page') === true;
if ($showAllSessions) { if ($showAllSessions) {
$order = "ORDER BY s.accessStartDate"; $order = 'ORDER BY s.accessStartDate';
} }
// Order by position // Order by position
if ($allowOrder) { if ($allowOrder) {
$order = "ORDER BY s.position"; $order = 'ORDER BY s.position';
} }
// Order by dates according to settings // Order by dates according to settings
@ -3842,43 +3845,6 @@ class UserManager
return false; return false;
} }
/**
* @author Isaac flores <isaac.flores@dokeos.com>
*
* @param string The email administrator
* @param int The user id
* @param string The message title
* @param string The content message
*/
public static function send_message_in_outbox(
$email_administrator,
$user_id,
$title,
$content
) {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$title = api_utf8_decode($title);
$content = api_utf8_decode($content);
$email_administrator = Database::escape_string($email_administrator);
//message in inbox
$sql_message_outbox = 'SELECT id from '.$table_user.' WHERE email="'.$email_administrator.'" ';
//$num_row_query = Database::num_rows($sql_message_outbox);
$res_message_outbox = Database::query($sql_message_outbox);
$array_users_administrator = [];
while ($row_message_outbox = Database::fetch_array($res_message_outbox, 'ASSOC')) {
$array_users_administrator[] = $row_message_outbox['id'];
}
//allow to insert messages in outbox
for ($i = 0; $i < count($array_users_administrator); $i++) {
$sql = "INSERT INTO $table_message (user_sender_id, user_receiver_id, msg_status, send_date, title, content ) ".
" VALUES (".
"'".(int) $user_id."', '".(int) ($array_users_administrator[$i])."', '4', '".api_get_utc_datetime()."','".Database::escape_string($title)."','".Database::escape_string($content)."'".
")";
Database::query($sql);
}
}
/** /**
* Gets the tags of a specific field_id * Gets the tags of a specific field_id
* USER TAGS. * USER TAGS.
@ -3940,7 +3906,7 @@ class UserManager
// all the information of the field // all the information of the field
$sql = "SELECT count(*) count, tag FROM $table_user_tag_values uv $sql = "SELECT count(*) count, tag FROM $table_user_tag_values uv
INNER JOIN $table_user_tag ut INNER JOIN $table_user_tag ut
ON(ut.id = uv.tag_id) ON (ut.id = uv.tag_id)
WHERE field_id = $field_id WHERE field_id = $field_id
GROUP BY tag_id GROUP BY tag_id
ORDER BY count DESC ORDER BY count DESC
@ -4034,7 +4000,7 @@ class UserManager
} }
if (is_array($user_tags) && count($user_tags) > 0) { if (is_array($user_tags) && count($user_tags) > 0) {
$return = implode(', ', $tag_tmp); return implode(', ', $tag_tmp);
} else { } else {
return ''; return '';
} }
@ -6042,110 +6008,15 @@ SQL;
} }
/** /**
* @return EncoderFactory * Anonymize a user. Replace personal info by anonymous info.
*/
private static function getEncoderFactory()
{
$encryption = self::getPasswordEncryption();
$encoders = [
'Chamilo\\UserBundle\\Entity\\User' => new \Chamilo\UserBundle\Security\Encoder($encryption),
];
$encoderFactory = new EncoderFactory($encoders);
return $encoderFactory;
}
/**
* @param User $user
*
* @return \Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface
*/
private static function getEncoder(User $user)
{
$encoderFactory = self::getEncoderFactory();
return $encoderFactory->getEncoder($user);
}
/**
* Disables or enables a user.
* *
* @param int $user_id * @param int $userId User id
* @param int $active Enable or disable * @param bool $deleteIP Whether to replace the IP address in logs tables by 127.0.0.1 or to leave as is
*
* @return bool True on success, false on failure
* @assert (-1,0) === false
* @assert (1,1) === true
*/
private static function change_active_state($user_id, $active)
{
if (strval(intval($user_id)) != $user_id) {
return false;
}
if ($user_id < 1) {
return false;
}
$user_id = intval($user_id);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $table_user SET active = '$active' WHERE id = $user_id";
$r = Database::query($sql);
$ev = LOG_USER_DISABLE;
if ($active == 1) {
$ev = LOG_USER_ENABLE;
}
if ($r !== false) {
Event::addEvent($ev, LOG_USER_ID, $user_id);
}
return $r;
}
/**
* Get either a Gravatar URL or complete image tag for a specified email address.
* *
* @param string $email The email address * @throws \Exception
* @param int $s Size in pixels, defaults to 80px [ 1 - 2048 ]
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
* @param bool $img True to return a complete IMG tag False for just the URL
* @param array $atts Optional, additional key/value attributes to include in the IMG tag
* *
* @return string containing either just a URL or a complete image tag
* @source http://gravatar.com/site/implement/images/php/
*/
private static function getGravatar(
$email,
$s = 80,
$d = 'mm',
$r = 'g',
$img = false,
$atts = []
) {
$url = 'http://www.gravatar.com/avatar/';
if (!empty($_SERVER['HTTPS'])) {
$url = 'https://secure.gravatar.com/avatar/';
}
$url .= md5(strtolower(trim($email)));
$url .= "?s=$s&d=$d&r=$r";
if ($img) {
$url = '<img src="'.$url.'"';
foreach ($atts as $key => $val) {
$url .= ' '.$key.'="'.$val.'"';
}
$url .= ' />';
}
return $url;
}
/**
* Anonymize a user. Replace personal info by anonymous info
* @param int $userId User id
* @param bool $deleteIP Whether to replace the IP address in logs tables by 127.0.0.1 or to leave as is
* @return bool * @return bool
* @assert (0) === false * @assert (0) === false
* @throws \Exception
*/ */
public static function anonymize($userId, $deleteIP = true) public static function anonymize($userId, $deleteIP = true)
{ {
@ -6174,7 +6045,7 @@ SQL;
$user->setUsernameCanonical($uniqueId); $user->setUsernameCanonical($uniqueId);
$user->setPhone(''); $user->setPhone('');
$user->setOfficialCode(''); $user->setOfficialCode('');
UserManager::delete_user_picture($userId); UserManager::deleteUserPicture($userId);
// The IP address is a border-case personal data, as it does // The IP address is a border-case personal data, as it does
// not directly allow for personal identification (it is not // not directly allow for personal identification (it is not
// a completely safe value in most countries - the IP could // a completely safe value in most countries - the IP could
@ -6236,11 +6107,109 @@ SQL;
if ($res === false && $debug > 0) { if ($res === false && $debug > 0) {
error_log("Could not anonymize IP address for user $userId ($sql)"); error_log("Could not anonymize IP address for user $userId ($sql)");
} }
} }
$em->persist($user); $em->persist($user);
$em->flush($user); $em->flush($user);
Event::addEvent(LOG_USER_ANONYMIZE, LOG_USER_ID, $userId); Event::addEvent(LOG_USER_ANONYMIZE, LOG_USER_ID, $userId);
return true; return true;
} }
/**
* @return EncoderFactory
*/
private static function getEncoderFactory()
{
$encryption = self::getPasswordEncryption();
$encoders = [
'Chamilo\\UserBundle\\Entity\\User' => new \Chamilo\UserBundle\Security\Encoder($encryption),
];
$encoderFactory = new EncoderFactory($encoders);
return $encoderFactory;
}
/**
* @param User $user
*
* @return \Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface
*/
private static function getEncoder(User $user)
{
$encoderFactory = self::getEncoderFactory();
return $encoderFactory->getEncoder($user);
}
/**
* Disables or enables a user.
*
* @param int $user_id
* @param int $active Enable or disable
*
* @return bool True on success, false on failure
* @assert (-1,0) === false
* @assert (1,1) === true
*/
private static function change_active_state($user_id, $active)
{
if (strval(intval($user_id)) != $user_id) {
return false;
}
if ($user_id < 1) {
return false;
}
$user_id = intval($user_id);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $table_user SET active = '$active' WHERE id = $user_id";
$r = Database::query($sql);
$ev = LOG_USER_DISABLE;
if ($active == 1) {
$ev = LOG_USER_ENABLE;
}
if ($r !== false) {
Event::addEvent($ev, LOG_USER_ID, $user_id);
}
return $r;
}
/**
* Get either a Gravatar URL or complete image tag for a specified email address.
*
* @param string $email The email address
* @param int $s Size in pixels, defaults to 80px [ 1 - 2048 ]
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
* @param bool $img True to return a complete IMG tag False for just the URL
* @param array $atts Optional, additional key/value attributes to include in the IMG tag
*
* @return string containing either just a URL or a complete image tag
* @source http://gravatar.com/site/implement/images/php/
*/
private static function getGravatar(
$email,
$s = 80,
$d = 'mm',
$r = 'g',
$img = false,
$atts = []
) {
$url = 'http://www.gravatar.com/avatar/';
if (!empty($_SERVER['HTTPS'])) {
$url = 'https://secure.gravatar.com/avatar/';
}
$url .= md5(strtolower(trim($email)));
$url .= "?s=$s&d=$d&r=$r";
if ($img) {
$url = '<img src="'.$url.'"';
foreach ($atts as $key => $val) {
$url .= ' '.$key.'="'.$val.'"';
}
$url .= ' />';
}
return $url;
}
} }

@ -955,8 +955,7 @@ class Rest extends WebService
*/ */
public function getMessageUsers($search) public function getMessageUsers($search)
{ {
/** @var UserRepository $repo */ $repo = UserManager::getRepository();
$repo = Database::getManager()->getRepository('ChamiloUserBundle:User');
$users = $repo->findUsersToSendMessage($this->user->getId(), $search); $users = $repo->findUsersToSendMessage($this->user->getId(), $search);
@ -1160,8 +1159,6 @@ class Rest extends WebService
$results = []; $results = [];
$orig_user_id_value = []; $orig_user_id_value = [];
$userManager = UserManager::getManager(); $userManager = UserManager::getManager();
$userRepository = UserManager::getRepository();
$firstName = $user_param['firstname']; $firstName = $user_param['firstname'];
$lastName = $user_param['lastname']; $lastName = $user_param['lastname'];
$status = $user_param['status']; $status = $user_param['status'];

@ -82,17 +82,14 @@ if ($action === 'addcategory') {
} }
if ($action === 'editlink') { if ($action === 'editlink') {
$nameTools = ''; $nameTools = get_lang('EditLink');
$interbreadcrumb[] = ['url' => 'link.php', 'name' => get_lang('Links')]; $interbreadcrumb[] = ['url' => 'link.php', 'name' => get_lang('Links')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('EditLink')];
} }
// Statistics // Statistics
Event::event_access_tool(TOOL_LINK); Event::event_access_tool(TOOL_LINK);
/* Action Handling */ /* Action Handling */
$nameTools = get_lang('Links');
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$scope = isset($_REQUEST['scope']) ? $_REQUEST['scope'] : null; $scope = isset($_REQUEST['scope']) ? $_REQUEST['scope'] : null;
$show = isset($_REQUEST['show']) && in_array(trim($_REQUEST['show']), ['all', 'none']) ? $_REQUEST['show'] : ''; $show = isset($_REQUEST['show']) && in_array(trim($_REQUEST['show']), ['all', 'none']) ? $_REQUEST['show'] : '';
@ -224,10 +221,6 @@ switch ($action) {
} }
Display::display_header($nameTools, 'Links'); Display::display_header($nameTools, 'Links');
/* Introduction section */
Display::display_introduction_section(TOOL_LINK); Display::display_introduction_section(TOOL_LINK);
echo $content; echo $content;
Display::display_footer(); Display::display_footer();

@ -4,7 +4,6 @@
use Chamilo\CoreBundle\Entity\ExtraField; use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Entity\SequenceResource; use Chamilo\CoreBundle\Entity\SequenceResource;
use Chamilo\CourseBundle\Entity\CCourseDescription; use Chamilo\CourseBundle\Entity\CCourseDescription;
use Chamilo\UserBundle\Entity\Repository\UserRepository;
use Chamilo\UserBundle\Entity\User; use Chamilo\UserBundle\Entity\User;
use ChamiloSession as Session; use ChamiloSession as Session;
@ -21,7 +20,7 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0; $sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0;
$em = Database::getManager(); $em = Database::getManager();
@ -35,8 +34,7 @@ $courses = [];
$sessionCourses = $em->getRepository('ChamiloCoreBundle:Session')->getCoursesOrderedByPosition($session); $sessionCourses = $em->getRepository('ChamiloCoreBundle:Session')->getCoursesOrderedByPosition($session);
$fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField'); $fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField');
$fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); $fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag');
/** @var UserRepository $userRepo */ $userRepo = UserManager::getRepository();
$userRepo = $em->getRepository('ChamiloUserBundle:User');
$sequenceResourceRepo = $em->getRepository('ChamiloCoreBundle:SequenceResource'); $sequenceResourceRepo = $em->getRepository('ChamiloCoreBundle:SequenceResource');
$tagField = $fieldsRepo->findOneBy([ $tagField = $fieldsRepo->findOneBy([

@ -172,13 +172,11 @@ foreach ($results as $result) {
$html .= '<div class="members-groups">'.$members.'</div>'; $html .= '<div class="members-groups">'.$members.'</div>';
if ($result['description'] != '') { if ($result['description'] != '') {
$html .= '<div class="description-groups">'.cut($result['description'], 100, true).'</div>'; $html .= '<div class="description-groups">'.cut($result['description'], 100, true).'</div>';
} else {
$html .= '';
} }
//Avoiding my groups // Avoiding my groups
if (!in_array($id, $my_group_list)) { if (!in_array($id, $my_group_list)) {
$html .= '<a class="btn btn-primary" href="group_view.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a> '; $html .= '<a class="btn btn-primary" href="group_view.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.
get_lang('JoinGroup').'</a> ';
} }
$html .= '<div class="group-actions" >'.$join_url.'</div>'; $html .= '<div class="group-actions" >'.$join_url.'</div>';
@ -237,9 +235,10 @@ if (is_array($results) && count($results) > 0) {
} else { } else {
$html .= ''; $html .= '';
} }
//Avoiding my groups // Avoiding my groups
if (!in_array($id, $my_group_list)) { if (!in_array($id, $my_group_list)) {
$html .= '<a class="btn btn-primary" href="group_view.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a> '; $html .= '<a class="btn btn-primary" href="group_view.php?id='.$id.'&action=join&u='.api_get_user_id().'">'.
get_lang('JoinGroup').'</a> ';
} }
$html .= '<div class="group-actions" >'.$join_url.'</div>'; $html .= '<div class="group-actions" >'.$join_url.'</div>';
@ -270,11 +269,13 @@ if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
); );
} }
if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') { if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
$create_group_item = '<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'. $create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>'; get_lang('CreateASocialGroup').'</a>';
} else { } else {
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$create_group_item = '<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'. $create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>'; get_lang('CreateASocialGroup').'</a>';
} }
} }
@ -322,11 +323,13 @@ if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
$my_group_content = '<span class="muted">'.get_lang('GroupNone').'</span>'; $my_group_content = '<span class="muted">'.get_lang('GroupNone').'</span>';
} }
if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') { if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
$create_group_item = '<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'. $create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>'; get_lang('CreateASocialGroup').'</a>';
} else { } else {
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$create_group_item = '<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'. $create_group_item =
'<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
get_lang('CreateASocialGroup').'</a>'; get_lang('CreateASocialGroup').'</a>';
} }
} }

@ -66,7 +66,6 @@ if (api_get_setting('profile', 'picture') == 'true') {
$_FILES['picture']['tmp_name'] $_FILES['picture']['tmp_name']
)) { )) {
$table_user = Database::get_main_table(TABLE_MAIN_USER); $table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $table_user $sql = "UPDATE $table_user
SET SET
picture_uri = '$new_picture' picture_uri = '$new_picture'
@ -168,7 +167,8 @@ foreach ($results as $result) {
GROUP_IMAGE_SIZE_BIG GROUP_IMAGE_SIZE_BIG
); );
$result['picture_uri'] = '<img class="img-responsive" src="'.$picture['file'].'" />'; $result['picture_uri'] = '<img class="img-responsive" src="'.$picture['file'].'" />';
$group_actions = '<div class="group-more"><a class="btn btn-default" href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>'; $group_actions = '<div class="group-more"><a class="btn btn-default" href="groups.php?#tab_browse-3">'.
get_lang('SeeMore').'</a></div>';
$group_info = '<div class="description"><p>'.cut($result['description'], 120, true)."</p></div>"; $group_info = '<div class="description"><p>'.cut($result['description'], 120, true)."</p></div>";
$groups_pop[] = [ $groups_pop[] = [
Display::url($result['picture_uri'], $group_url), Display::url($result['picture_uri'], $group_url),

@ -123,7 +123,8 @@ if ($number_loop != 0) {
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG); $date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$invitationHtml .= '<div class="row">'; $invitationHtml .= '<div class="row">';
$invitationHtml .= '<div class="col-md-2">'; $invitationHtml .= '<div class="col-md-2">';
$invitationHtml .= '<a href="profile.php?u='.$sender_user_id.'"><img class="img-responsive img-rounded" src="'.$userPicture.'"/></a>'; $invitationHtml .= '<a href="profile.php?u='.$sender_user_id.'">';
$invitationHtml .= '<img class="img-responsive img-rounded" src="'.$userPicture.'"/></a>';
$invitationHtml .= '</div>'; $invitationHtml .= '</div>';
$invitationHtml .= '<div class="col-md-10">'; $invitationHtml .= '<div class="col-md-10">';
@ -170,9 +171,7 @@ if (count($list_get_invitation_sent) > 0) {
foreach ($list_get_invitation_sent as $invitation) { foreach ($list_get_invitation_sent as $invitation) {
$sender_user_id = $invitation['user_receiver_id']; $sender_user_id = $invitation['user_receiver_id'];
$user_info = api_get_user_info($sender_user_id); $user_info = api_get_user_info($sender_user_id);
$invitationSentHtml .= '<div id="id_'.$sender_user_id.'" class="well">'; $invitationSentHtml .= '<div id="id_'.$sender_user_id.'" class="well">';
$title = Security::remove_XSS($invitation['title'], STUDENT, true); $title = Security::remove_XSS($invitation['title'], STUDENT, true);
$content = Security::remove_XSS($invitation['content'], STUDENT, true); $content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG); $date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
@ -203,7 +202,8 @@ if (count($pending_invitations) > 0) {
); );
$img = '<img class="img-responsive" src="'.$picture['file'].'" />'; $img = '<img class="img-responsive" src="'.$picture['file'].'" />';
$invitation['picture_uri'] = '<a href="group_view.php?id='.$invitation['id'].'">'.$img.'</a>'; $invitation['picture_uri'] = '<a href="group_view.php?id='.$invitation['id'].'">'.$img.'</a>';
$invitation['name'] = '<a href="group_view.php?id='.$invitation['id'].'">'.cut($invitation['name'], 120, true).'</a>'; $invitation['name'] = '<a href="group_view.php?id='.$invitation['id'].'">'.
cut($invitation['name'], 120, true).'</a>';
$invitation['description'] = cut($invitation['description'], 220, true); $invitation['description'] = cut($invitation['description'], 220, true);
$new_invitation[] = $invitation; $new_invitation[] = $invitation;
$waitingInvitation .= '<div class="panel-invitations"><div class="row">'; $waitingInvitation .= '<div class="panel-invitations"><div class="row">';

@ -83,7 +83,7 @@ if ($isStudent) {
'course_name' => $resultData['title'], 'course_name' => $resultData['title'],
]; ];
$imageSysPath = sprintf("%s%s/course-pic.png", api_get_path(SYS_COURSE_PATH), $resultData['directory']); $imageSysPath = sprintf('%s%s/course-pic.png', api_get_path(SYS_COURSE_PATH), $resultData['directory']);
if (file_exists($imageSysPath)) { if (file_exists($imageSysPath)) {
$thumbSysPath = sprintf( $thumbSysPath = sprintf(

@ -13,7 +13,6 @@ use JeroenDesloovere\VCard\VCard;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users(); api_block_anonymous_users();
api_protect_admin_script(); api_protect_admin_script();
if (isset($_REQUEST['userId'])) { if (isset($_REQUEST['userId'])) {

@ -1,134 +0,0 @@
<script>
/* Makes row highlighting possible */
$(document).ready( function() {
$("[data-toggle=popover]").each(function(i, obj) {
$(this).popover({
html: true,
content: function() {
var id = $(this).attr('id')
return $('#popover-content-' + id).html();
}
});
});
$('.scrollbar-inner').scrollbar();
// Date time settings.
moment.locale('{{ locale }}');
$.datepicker.setDefaults($.datepicker.regional["{{ locale }}"]);
$.datepicker.regional["local"] = $.datepicker.regional["{{ locale }}"];
// Fix old calls of "inc/lib/mediaplayer/player.swf" and convert to <audio> tag, then rendered by media element js
// see BT#13405
$('embed').each( function () {
var flashVars = $(this).attr('flashvars');
if (flashVars && flashVars.indexOf("file") == -1) {
var audioId = Math.floor( Math.random()*99999 );
flashVars = flashVars.replace('&autostart=false', '');
flashVars = flashVars.replace('&autostart=true', '');
var audioDiv = '<audio id="'+audioId+'" controls="controls" style="width:400px;" width:"400px;" src="'+flashVars+'" ><source src="'+flashVars+'" type="audio/mp3" ></source></audio>';
$(this).hide();
$(this).after(audioDiv);
}
});
// Chosen select
$(".chzn-select").chosen({
disable_search_threshold: 10,
no_results_text: '{{ 'SearchNoResultsFound' | get_lang | escape('js') }}',
placeholder_text_multiple: '{{ 'SelectSomeOptions' | get_lang | escape('js') }}',
placeholder_text_single: '{{ 'SelectAnOption' | get_lang | escape('js') }}',
width: "100%"
});
// Bootstrap tabs.
$('.tab-wrapper a').click(function (e) {
e.preventDefault();
$(this).tab('show');
//$('#tabs a:first').tab('show') // Select first tab
});
// Fixes bug when loading links inside a tab.
$('.tab-wrapper .tab-pane a').unbind();
/**
* Advanced options
* Usage
* <a id="link" href="url">Advanced</a>
* <div id="link_options">
* hidden content :)
* </div>
* */
$(".advanced_options").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('id') + '_options';
var button = $(this);
$("#" + id).toggle();
});
/**
* <a class="advanced_options_open" href="http://" rel="div_id">Open</a>
* <a class="advanced_options_close" href="http://" rel="div_id">Close</a>
* <div id="div_id">Div content</div>
* */
$(".advanced_options_open").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#" + id).show();
});
$(".advanced_options_close").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#" + id).hide();
});
// Adv multi-select search input.
$('.select_class_filter').each( function () {
var inputId = $(this).attr('id');
inputId = inputId.replace('-filter', '');
$("#" + inputId).filterByText($("#" + inputId + "-filter"));
});
// Mediaelement
if ( {{ show_media_element }} == 1) {
$('video:not(.skip), audio:not(.skip)').mediaelementplayer({
pluginPath: '{{ _p.web }}web/assets/mediaelement/build/',
renderers: ['html5', 'flash_video', 'native_flv'],
features: ['{{ video_features }}'],
success: function(mediaElement, originalNode, instance) {
}
});
}
// Table highlight.
$("form .data_table input:checkbox").click(function () {
if ($(this).is(":checked")) {
$(this).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(this).parentsUntil("tr").parent().removeClass("row_selected");
}
});
/* For non HTML5 browsers */
if ($("#formLogin".length > 1)) {
$("input[name=login]").focus();
}
// Tool tip (in exercises)
var tip_options = {
placement: 'right'
};
$('.boot-tooltip').tooltip(tip_options);
var more = '{{ 'SeeMore' | get_lang | escape('js') }}';
var close = '{{ 'Close' | get_lang | escape('js') }}';
$('.list-teachers').readmore({
speed: 75,
moreLink: '<a href="#">' + more + '</a>',
lessLink: '<a href="#">' + close + '</a>',
collapsedHeight: 35,
blockCSS: 'display: block; width: 100%;'
});
});
</script>

@ -19,42 +19,12 @@
{{ css_static_file_to_string }} {{ css_static_file_to_string }}
{{ js_file_to_string }} {{ js_file_to_string }}
{{ extra_headers }} {{ extra_headers }}
<script>
/* Global chat variables */
var ajax_url = '{{ _p.web_ajax }}chat.ajax.php';
var online_button = '{{ online_button }}';
var offline_button = '{{ offline_button }}';
var connect_lang = '{{ "ChatConnected"|get_lang }}';
var disconnect_lang = '{{ "ChatDisconnected"|get_lang }}';
var logOutUrl = '{{ _p.web_ajax }}course.ajax.php?a=course_logout&{{ _p.web_cid_query }}';
function addMainEvent(elm, evType, fn, useCapture) { {% if _s.language_interface %}
if (elm.addEventListener) { <script type="text/javascript" src="{{ _p.web }}web/build/main.{{ _s.language_interface }}.js"></script>
elm.addEventListener(evType, fn, useCapture); {% else %}{# language_interface *should* always be defined, so we should never come here #}
return true; <script type="text/javascript" src="{{ _p.web }}web/build/main.js"></script>
} else if (elm.attachEvent) { {% endif %}
elm.attachEvent('on' + evType, fn);
} else{
elm['on'+evType] = fn;
}
}
function courseLogout() {
$.ajax({
url: logOutUrl,
success: function (data) {
return 1;
}
});
}
$(function() {
addMainEvent(window, 'unload', courseLogout ,false);
});
</script>
{% include 'layout/header.js.tpl'|get_template %}
{{ css_custom_file_to_string }} {{ css_custom_file_to_string }}
{{ css_style_print }} {{ css_style_print }}

@ -1,5 +1,37 @@
<script> /* Global chat variables */
{% if constant('CHAMILO_LOAD_WYSIWYG') %}
var ajax_url = '{{ _p.web_rel_code }}inc/ajax/chat.ajax.php';
var online_button = '{{ 'statusonline.png' |img(8) }}';
var offline_button = '{{ 'statusoffline.png' |img(8) }}';
var connect_lang = '{{ "ChatConnected"|get_lang }}';
var disconnect_lang = '{{ "ChatDisconnected"|get_lang }}';
var logOutUrl = '{{ _p.web_rel_code }}inc/ajax/course.ajax.php?a=course_logout&{{ _p.web_cid_query }}';
function addMainEvent(elm, evType, fn, useCapture) {
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
elm.attachEvent('on' + evType, fn);
} else {
elm['on'+evType] = fn;
}
}
function courseLogout() {
$.ajax({
url: logOutUrl,
success: function (data) {
return 1;
}
});
}
$(function() {
addMainEvent(window, 'unload', courseLogout ,false);
});
if (typeof CKEDITOR !== 'undefined') {
// External plugins not part of the default Ckeditor package. // External plugins not part of the default Ckeditor package.
var plugins = [ var plugins = [
'asciimath', 'asciimath',
@ -24,8 +56,11 @@
'image2_chamilo' 'image2_chamilo'
]; ];
plugins.forEach(function(plugin) { plugins.forEach(function (plugin) {
CKEDITOR.plugins.addExternal(plugin, '{{ _p.web_main ~ 'inc/lib/javascript/ckeditor/plugins/' }}' + plugin + '/'); CKEDITOR.plugins.addExternal(
plugin,
'{{ _p.web_rel_code ~ 'inc/lib/javascript/ckeditor/plugins/' }}' + plugin + '/'
);
}); });
/** /**
@ -70,7 +105,7 @@
$templatesUL.appendTo("#frmModel"); $templatesUL.appendTo("#frmModel");
}); });
}; };
{% endif %} }
function doneResizing() { function doneResizing() {
var widthWindow = $(window).width(); var widthWindow = $(window).width();
@ -122,7 +157,8 @@ $(document).ready(function() {
header: ".accordion-heading" header: ".accordion-heading"
}); });
// Global popup // Start modals
// class='ajax' loads a page in a modal
$('body').on('click', 'a.ajax', function(e) { $('body').on('click', 'a.ajax', function(e) {
e.preventDefault(); e.preventDefault();
@ -157,6 +193,7 @@ $(document).ready(function() {
}); });
}); });
// Expands an image modal
$('a.expand-image').on('click', function(e) { $('a.expand-image').on('click', function(e) {
e.preventDefault(); e.preventDefault();
var title = $(this).attr('title'); var title = $(this).attr('title');
@ -176,11 +213,14 @@ $(document).ready(function() {
image.src = this.href; image.src = this.href;
}); });
// Global confirmation // Delete modal
$('.popup-confirmation').on('click', function() { $('#confirm-delete').on('show.bs.modal', function(e) {
showConfirmationPopup(this); $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
return false; $('.debug-url').html(
'{{ 'AreYouSureToDeleteJS' | get_lang }}: <strong>' + $(e.relatedTarget).data('item-title') + '</strong>'
);
}); });
// End modals
// old jquery.menu.js // old jquery.menu.js
$('#navigation a').stop().animate({ $('#navigation a').stop().animate({
@ -228,11 +268,142 @@ $(document).ready(function() {
}); });
}); });
}; };
$(".black-shadow").mouseenter(function() { $(".black-shadow").mouseenter(function() {
$(this).addClass('hovered-course'); $(this).addClass('hovered-course');
}).mouseleave(function() { }).mouseleave(function() {
$(this).removeClass('hovered-course'); $(this).removeClass('hovered-course');
}); });
$("[data-toggle=popover]").each(function(i, obj) {
$(this).popover({
html: true,
content: function() {
var id = $(this).attr('id')
return $('#popover-content-' + id).html();
}
});
});
$('.scrollbar-inner').scrollbar();
// Date time settings.
moment.locale('{{ locale }}');
$.datepicker.setDefaults($.datepicker.regional["{{ locale }}"]);
$.datepicker.regional["local"] = $.datepicker.regional["{{ locale }}"];
// Fix old calls of "inc/lib/mediaplayer/player.swf" and convert to <audio> tag, then rendered by media element js
// see BT#13405
$('embed').each( function () {
var flashVars = $(this).attr('flashvars');
if (flashVars && flashVars.indexOf("file") == -1) {
var audioId = Math.floor( Math.random()*99999 );
flashVars = flashVars.replace('&autostart=false', '');
flashVars = flashVars.replace('&autostart=true', '');
var audioDiv = '<audio id="'+audioId+'" controls="controls" style="width:400px;" width:"400px;" src="'+flashVars+'" ><source src="'+flashVars+'" type="audio/mp3" ></source></audio>';
$(this).hide();
$(this).after(audioDiv);
}
});
// Chosen select
$(".chzn-select").chosen({
disable_search_threshold: 10,
no_results_text: '{{ 'SearchNoResultsFound' | get_lang | escape('js') }}',
placeholder_text_multiple: '{{ 'SelectSomeOptions' | get_lang | escape('js') }}',
placeholder_text_single: '{{ 'SelectAnOption' | get_lang | escape('js') }}',
width: "100%"
});
// Bootstrap tabs.
$('.tab-wrapper a').click(function (e) {
e.preventDefault();
$(this).tab('show');
//$('#tabs a:first').tab('show') // Select first tab
});
// Fixes bug when loading links inside a tab.
$('.tab-wrapper .tab-pane a').unbind();
/**
* Advanced options
* Usage
* <a id="link" href="url">Advanced</a>
* <div id="link_options">
* hidden content :)
* </div>
* */
$(".advanced_options").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('id') + '_options';
var button = $(this);
$("#" + id).toggle();
});
/**
* <a class="advanced_options_open" href="http://" rel="div_id">Open</a>
* <a class="advanced_options_close" href="http://" rel="div_id">Close</a>
* <div id="div_id">Div content</div>
* */
$(".advanced_options_open").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#" + id).show();
});
$(".advanced_options_close").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#" + id).hide();
});
// Adv multi-select search input.
$('.select_class_filter').each( function () {
var inputId = $(this).attr('id');
inputId = inputId.replace('-filter', '');
$("#" + inputId).filterByText($("#" + inputId + "-filter"));
});
// Mediaelement
if ( {{ show_media_element }} == 1) {
$('video:not(.skip), audio:not(.skip)').mediaelementplayer({
pluginPath: '{{ _p.web }}web/assets/mediaelement/build/',
renderers: ['html5', 'flash_video', 'native_flv'],
features: ['{{ video_features }}'],
success: function(mediaElement, originalNode, instance) {
}
});
}
// Table highlight.
$("form .data_table input:checkbox").click(function () {
if ($(this).is(":checked")) {
$(this).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(this).parentsUntil("tr").parent().removeClass("row_selected");
}
});
/* For non HTML5 browsers */
if ($("#formLogin".length > 1)) {
$("input[name=login]").focus();
}
// Tool tip (in exercises)
var tip_options = {
placement: 'right'
};
$('.boot-tooltip').tooltip(tip_options);
var more = '{{ 'SeeMore' | get_lang | escape('js') }}';
var close = '{{ 'Close' | get_lang | escape('js') }}';
$('.list-teachers').readmore({
speed: 75,
moreLink: '<a href="#">' + more + '</a>',
lessLink: '<a href="#">' + close + '</a>',
collapsedHeight: 35,
blockCSS: 'display: block; width: 100%;'
});
}); });
$(window).resize(function() { $(window).resize(function() {
@ -315,7 +486,8 @@ function get_url_params(q, attribute) {
} }
} }
function check_brand() { function check_brand()
{
if ($('.subnav').length) { if ($('.subnav').length) {
if ($(window).width() >= 969) { if ($(window).width() >= 969) {
$('.subnav .brand').hide(); $('.subnav .brand').hide();
@ -325,66 +497,6 @@ function check_brand() {
} }
} }
function showConfirmationPopup(obj, urlParam) {
if (urlParam) {
url = urlParam
} else {
url = obj.href;
}
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $('<div id="dialog" style="display:none">{{ "ConfirmYourChoice" | get_lang }} </div>').appendTo('body');
}
var width_value = 350;
var height_value = 150;
var resizable_value = true;
var new_param = get_url_params(url, 'width');
if (new_param) {
width_value = new_param;
}
var new_param = get_url_params(url, 'height')
if (new_param) {
height_value = new_param;
}
var new_param = get_url_params(url, 'resizable');
if (new_param) {
resizable_value = new_param;
}
// Show dialog
dialog.dialog({
modal : true,
width : width_value,
height : height_value,
resizable : resizable_value,
buttons: [
{
text: '{{ 'Yes' | get_lang }}',
click: function() {
window.location = url;
},
icons:{
primary:'ui-icon-locked'
}
},
{
text: '{{ 'No' | get_lang }}',
click: function() { $(this).dialog("close"); },
icons:{
primary:'ui-icon-locked'
}
}
]
});
// prevent the browser to follow the link
return false;
}
function setCheckbox(value, table_id) { function setCheckbox(value, table_id) {
checkboxes = $("#"+table_id+" input:checkbox"); checkboxes = $("#"+table_id+" input:checkbox");
$.each(checkboxes, function(index, checkbox) { $.each(checkboxes, function(index, checkbox) {
@ -464,4 +576,3 @@ function expandColumnToogle(buttonSelector, col1Info, col2Info)
col1.removeClass('hide').addClass('col-md-' + col1Info.width); col1.removeClass('hide').addClass('col-md-' + col1Info.width);
}); });
} }
</script>

@ -58,8 +58,6 @@
{% if show_footer == true %} {% if show_footer == true %}
{% include 'layout/page_footer.tpl'|get_template %} {% include 'layout/page_footer.tpl'|get_template %}
{% endif %} {% endif %}
{% include 'layout/footer.js.tpl'|get_template %}
</div> </div>
</body> </body>
</html> </html>

@ -62,6 +62,23 @@
</div> </div>
</footer> </footer>
{# Global modal, load content by AJAX call to href attribute on anchor tag with 'ajax' class #}
<div class="modal fade" id="global-modal" tabindex="-1" role="dialog" aria-labelledby="global-modal-title" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ "Close" | get_lang }}">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="global-modal-title">&nbsp;</h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
{# Expands an image modal #}
<div class="modal fade" id="expand-image-modal" tabindex="-1" role="dialog" aria-labelledby="expand-image-modal-title" aria-hidden="true"> <div class="modal fade" id="expand-image-modal" tabindex="-1" role="dialog" aria-labelledby="expand-image-modal-title" aria-hidden="true">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
@ -74,17 +91,23 @@
</div> </div>
</div> </div>
</div> </div>
{# Global modal, load content by AJAX call to href attribute on anchor tag with 'ajax' class #}
<div class="modal fade" id="global-modal" tabindex="-1" role="dialog" aria-labelledby="global-modal-title" aria-hidden="true"> {# Delete modal #}
<div class="modal-dialog modal-lg"> <div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="confirm-delete-title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ "Close" | get_lang }}"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<span aria-hidden="true">&times;</span> <h4 class="modal-title" id="myModalLabel">{{ 'Delete' | get_lang }}</h4>
</button>
<h4 class="modal-title" id="global-modal-title">&nbsp;</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class="debug-url"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'Cancel' | get_lang }}</button>
<a id="delete_item" class="btn btn-danger btn-ok">{{ 'Delete' | get_lang }}</a>
</div> </div>
</div> </div>
</div> </div>

@ -4,6 +4,5 @@
{% include 'layout/page_footer.tpl'|get_template %} {% include 'layout/page_footer.tpl'|get_template %}
{% endif %} {% endif %}
</div> </div>
{% include 'layout/footer.js.tpl'|get_template %}
</body> </body>
</html> </html>

@ -33,7 +33,7 @@ $editingCourse = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_COURS
$editingSession = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_SESSION; $editingSession = intval($_REQUEST['t']) === BuyCoursesPlugin::PRODUCT_TYPE_SESSION;
$entityManager = Database::getManager(); $entityManager = Database::getManager();
$userRepo = $entityManager->getRepository('ChamiloUserBundle:User'); $userRepo = UserManager::getRepository();
$currency = $plugin->getSelectedCurrency(); $currency = $plugin->getSelectedCurrency();
$currencyIso = null; $currencyIso = null;

@ -116,7 +116,7 @@ $selectOptions = [
]; ];
if ($typeUser) { if ($typeUser) {
$users = $em->getRepository('ChamiloUserBundle:User')->findAll(); $users = UserManager::getRepository()->findAll();
$selectOptions[$userInfo['user_id']] = api_get_person_name( $selectOptions[$userInfo['user_id']] = api_get_person_name(
$userInfo['firstname'], $userInfo['firstname'],
$userInfo['lastname'] $userInfo['lastname']
@ -133,7 +133,7 @@ if ($typeUser) {
$form->addSelect('info_select', get_lang('User'), $selectOptions); $form->addSelect('info_select', get_lang('User'), $selectOptions);
} elseif ($typeCourse) { } elseif ($typeCourse) {
/** @var User $user */ /** @var User $user */
$user = $em->getRepository('ChamiloUserBundle:User')->find($currentUserId); $user = UserManager::getRepository()->find($currentUserId);
$courses = $user->getCourses(); $courses = $user->getCourses();
$checker = false; $checker = false;
foreach ($courses as $course) { foreach ($courses as $course) {
@ -152,7 +152,7 @@ if ($typeUser) {
} elseif ($typeSession) { } elseif ($typeSession) {
$sessions = []; $sessions = [];
/** @var User $user */ /** @var User $user */
$user = $em->getRepository('ChamiloUserBundle:User')->find($currentUserId); $user = UserManager::getRepository()->find($currentUserId);
$userSubscriptions = $user->getSessionCourseSubscriptions(); $userSubscriptions = $user->getSessionCourseSubscriptions();
/** @var SessionRelCourseRelUser $userSubscription */ /** @var SessionRelCourseRelUser $userSubscription */
@ -175,7 +175,7 @@ if ($typeUser) {
} elseif ($typeFinalLp) { } elseif ($typeFinalLp) {
// We need here to check the current user courses first // We need here to check the current user courses first
/** @var User $user */ /** @var User $user */
$user = $em->getRepository('ChamiloUserBundle:User')->find($currentUserId); $user = UserManager::getRepository()->find($currentUserId);
$courses = $user->getCourses(); $courses = $user->getCourses();
$courseLpList = []; $courseLpList = [];
$sessionLpList = []; $sessionLpList = [];

@ -13,7 +13,7 @@ require_once '../../../main/inc/global.inc.php';
$plugin = BuyCoursesPlugin::create(); $plugin = BuyCoursesPlugin::create();
$currency = $plugin->getSelectedCurrency(); $currency = $plugin->getSelectedCurrency();
$em = Database::getManager(); $em = Database::getManager();
$users = $em->getRepository('ChamiloUserBundle:User')->findAll(); $users = UserManager::getRepository()->findAll();
$userOptions = []; $userOptions = [];
if (!empty($users)) { if (!empty($users)) {
foreach ($users as $user) { foreach ($users as $user) {

@ -19,7 +19,7 @@ if (!$serviceId) {
$plugin = BuyCoursesPlugin::create(); $plugin = BuyCoursesPlugin::create();
$currency = $plugin->getSelectedCurrency(); $currency = $plugin->getSelectedCurrency();
$em = Database::getManager(); $em = Database::getManager();
$users = $em->getRepository('ChamiloUserBundle:User')->findAll(); $users = UserManager::getRepository()->findAll();
$userOptions = []; $userOptions = [];
if (!empty($users)) { if (!empty($users)) {
foreach ($users as $user) { foreach ($users as $user) {

@ -199,6 +199,7 @@ class ScriptHandler
__DIR__.'/../../../../src/Chamilo/CoreBundle/Entity/GroupRelTag.php', __DIR__.'/../../../../src/Chamilo/CoreBundle/Entity/GroupRelTag.php',
__DIR__.'/../../../../src/Chamilo/CoreBundle/Entity/GroupRelUser.php', __DIR__.'/../../../../src/Chamilo/CoreBundle/Entity/GroupRelUser.php',
__DIR__.'/../../../../src/Chamilo/CoreBundle/Entity/Groups.php', __DIR__.'/../../../../src/Chamilo/CoreBundle/Entity/Groups.php',
__DIR__.'/../../../../src/Chamilo/UserBundle/Entity/Repository/UserRepository.php',
__DIR__.'/../../../../app/Resources/public/assets/bootstrap/Gemfile', __DIR__.'/../../../../app/Resources/public/assets/bootstrap/Gemfile',
__DIR__.'/../../../../app/Resources/public/assets/bootstrap/Gemfile.lock', __DIR__.'/../../../../app/Resources/public/assets/bootstrap/Gemfile.lock',
__DIR__.'/../../../../app/Resources/public/assets/bootstrap/Gruntfile.js', __DIR__.'/../../../../app/Resources/public/assets/bootstrap/Gruntfile.js',

@ -1,354 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\UserBundle\Entity\Repository;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
use Chamilo\UserBundle\Entity\User;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr\Join;
//use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
//use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
/**
* Class UserRepository.
*
* All functions that query the database (selects)
* Functions should return query builders.
*
* @package Chamilo\UserBundle\Repository
*/
class UserRepository extends EntityRepository
{
/**
* @param string $keyword
*
* @return mixed
*/
public function searchUserByKeyword($keyword)
{
$qb = $this->createQueryBuilder('a');
// Selecting user info
$qb->select('DISTINCT b');
$qb->from('Chamilo\UserBundle\Entity\User', 'b');
// Selecting courses for users
//$qb->innerJoin('u.courses', 'c');
//@todo check app settings
$qb->add('orderBy', 'b.firstname ASC');
$qb->where('b.firstname LIKE :keyword OR b.lastname LIKE :keyword ');
$qb->setParameter('keyword', "%$keyword%");
$query = $qb->getQuery();
return $query->execute();
}
/**
* Get course user relationship based in the course_rel_user table.
*
* @return array
*/
/*public function getCourses(User $user)
{
$queryBuilder = $this->createQueryBuilder('user');
// Selecting course info.
$queryBuilder->select('c');
// Loading User.
//$qb->from('Chamilo\UserBundle\Entity\User', 'u');
// Selecting course
$queryBuilder->innerJoin('Chamilo\CoreBundle\Entity\Course', 'c');
//@todo check app settings
//$qb->add('orderBy', 'u.lastname ASC');
$wherePart = $queryBuilder->expr()->andx();
// Get only users subscribed to this course
$wherePart->add($queryBuilder->expr()->eq('user.userId', $user->getUserId()));
$queryBuilder->where($wherePart);
$query = $queryBuilder->getQuery();
return $query->execute();
}
public function getTeachers()
{
$queryBuilder = $this->createQueryBuilder('u');
// Selecting course info.
$queryBuilder
->select('u')
->where('u.groups.id = :groupId')
->setParameter('groupId', 1);
$query = $queryBuilder->getQuery();
return $query->execute();
}*/
/*public function getUsers($group)
{
$queryBuilder = $this->createQueryBuilder('u');
// Selecting course info.
$queryBuilder
->select('u')
->where('u.groups = :groupId')
->setParameter('groupId', $group);
$query = $queryBuilder->getQuery();
return $query->execute();
}*/
/**
* Get a filtered list of user by status and (optionally) access url.
*
* @param string $query The query to filter
* @param int $status The status
* @param int $accessUrlId The access URL ID
*
* @return array
*/
public function searchUsersByStatus($query, $status, $accessUrlId = 0)
{
$accessUrlId = (int) $accessUrlId;
$queryBuilder = $this->createQueryBuilder('u');
if ($accessUrlId > 0) {
$queryBuilder->innerJoin(
'ChamiloCoreBundle:AccessUrlRelUser',
'auru',
Join::WITH,
'u.id = auru.userId'
);
}
$queryBuilder
->where('u.status = :status')
->andWhere('u.username LIKE :query OR u.firstname LIKE :query OR u.lastname LIKE :query')
->setParameter('status', $status)
->setParameter('query', "$query%");
if ($accessUrlId > 0) {
$queryBuilder
->andWhere('auru.accessUrlId = :url')
->setParameter(':url', $accessUrlId);
}
return $queryBuilder->getQuery()->getResult();
}
/**
* Get the coaches for a course within a session.
*
* @param Session $session The session
* @param Course $course The course
*
* @return array
*/
public function getCoachesForSessionCourse(Session $session, Course $course)
{
$queryBuilder = $this->createQueryBuilder('u');
$queryBuilder
->select('u')
->innerJoin(
'ChamiloCoreBundle:SessionRelCourseRelUser',
'scu',
Join::WITH,
'scu.user = u'
)
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq('scu.session', $session->getId()),
$queryBuilder->expr()->eq('scu.course', $course->getId()),
$queryBuilder->expr()->eq('scu.status', SessionRelCourseRelUser::STATUS_COURSE_COACH)
)
);
return $queryBuilder->getQuery()->getResult();
}
/**
* Get the sessions admins for a user.
*
* @param User $user The user
*
* @return array
*/
public function getSessionAdmins($user)
{
$queryBuilder = $this->createQueryBuilder('u');
$queryBuilder
->distinct()
->innerJoin(
'ChamiloCoreBundle:SessionRelUser',
'su',
Join::WITH,
$queryBuilder->expr()->eq('u', 'su.user')
)
->innerJoin(
'ChamiloCoreBundle:SessionRelCourseRelUser',
'scu',
Join::WITH,
$queryBuilder->expr()->eq('su.session', 'scu.session')
)
->where(
$queryBuilder->expr()->eq('scu.user', $user->getId())
)
->andWhere(
$queryBuilder->expr()->eq('su.relationType', SESSION_RELATION_TYPE_RRHH)
);
return $queryBuilder->getQuery()->getResult();
}
/**
* Get the student bosses for a user.
*
* @param User $user The user
*
* @return array
*/
public function getStudentBosses($user)
{
$queryBuilder = $this->createQueryBuilder('u');
$queryBuilder
->distinct()
->innerJoin(
'ChamiloCoreBundle:UserRelUser',
'uu',
Join::WITH,
$queryBuilder->expr()->eq('u.id', 'uu.friendUserId')
)
->where(
$queryBuilder->expr()->eq('uu.relationType', USER_RELATION_TYPE_BOSS)
)
->andWhere(
$queryBuilder->expr()->eq('uu.userId', $user->getId())
);
return $queryBuilder->getQuery()->getResult();
}
/**
* Find potential users to send a message.
*
* @param int $currentUserId The current user ID
* @param string $search The search text to filter the user list
* @param int $limit Optional. Sets the maximum number of results to retrieve
*
* @return mixed
*/
public function findUsersToSendMessage($currentUserId, $search, $limit = 10)
{
$allowSendMessageToAllUsers = api_get_setting('allow_send_message_to_all_platform_users');
$accessUrlId = api_get_multiple_access_url() ? api_get_current_access_url_id() : 1;
if (api_get_setting('allow_social_tool') === 'true' &&
api_get_setting('allow_message_tool') === 'true'
) {
// All users
if ($allowSendMessageToAllUsers === 'true' || api_is_platform_admin()) {
$dql = "SELECT DISTINCT U
FROM ChamiloUserBundle:User U
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R
WITH U = R.user
WHERE
U.active = 1 AND
U.status != 6 AND
U.id != $currentUserId AND
R.portal = $accessUrlId";
} else {
$dql = "SELECT DISTINCT U
FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF
INNER JOIN ChamiloUserBundle:User AS U
WITH UF.friendUserId = U
WHERE
U.active = 1 AND
U.status != 6 AND
UF.relationType NOT IN(".USER_RELATION_TYPE_DELETED.", ".USER_RELATION_TYPE_RRHH.") AND
UF.userId = $currentUserId AND
UF.friendUserId != $currentUserId AND
U = R.user AND
R.portal = $accessUrlId";
}
} elseif (
api_get_setting('allow_social_tool') === 'false' &&
api_get_setting('allow_message_tool') === 'true'
) {
if ($allowSendMessageToAllUsers === 'true') {
$dql = "SELECT DISTINCT U
FROM ChamiloUserBundle:User U
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R
WITH U = R.user
WHERE
U.active = 1 AND
U.status != 6 AND
U.id != $currentUserId AND
R.portal = $accessUrlId";
} else {
$time_limit = api_get_setting('time_limit_whosonline');
$online_time = time() - $time_limit * 60;
$limit_date = api_get_utc_datetime($online_time);
$dql = "SELECT DISTINCT U
FROM ChamiloUserBundle:User U
INNER JOIN ChamiloCoreBundle:TrackEOnline T
WITH U.id = T.loginUserId
WHERE
U.active = 1 AND
T.loginDate >= '".$limit_date."'";
}
}
$dql .= ' AND (U.firstname LIKE :search OR U.lastname LIKE :search OR U.email LIKE :search OR U.username LIKE :search)';
return $this->getEntityManager()
->createQuery($dql)
->setMaxResults($limit)
->setParameters(['search' => "%$search%"])
->getResult();
}
/**
* Get the list of HRM who have assigned this user.
*
* @param int $userId
* @param int $urlId
*
* @return array
*/
public function getAssignedHrmUserList($userId, $urlId)
{
$qb = $this->createQueryBuilder('user');
$hrmList = $qb
->select('uru')
->innerJoin('ChamiloCoreBundle:UserRelUser', 'uru', Join::WITH, 'uru.userId = user.id')
->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'auru', Join::WITH, 'auru.userId = uru.friendUserId')
->where(
$qb->expr()->eq('auru.accessUrlId', $urlId)
)
->andWhere(
$qb->expr()->eq('uru.userId', $userId)
)
->andWhere(
$qb->expr()->eq('uru.relationType', USER_RELATION_TYPE_RRHH)
)
->getQuery()
->getResult();
return $hrmList;
}
}

@ -40,7 +40,7 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
* } * }
* ) * )
* @UniqueEntity("username") * @UniqueEntity("username")
* @ORM\Entity(repositoryClass="Chamilo\UserBundle\Entity\Repository\UserRepository") * @ORM\Entity(repositoryClass="Chamilo\UserBundle\Repository\UserRepository")
*/ */
class User implements UserInterface //implements ParticipantInterface, ThemeUser class User implements UserInterface //implements ParticipantInterface, ThemeUser
{ {

@ -132,36 +132,35 @@ class UserRepository extends EntityRepository
/** /**
* Get a filtered list of user by status and (optionally) access url. * Get a filtered list of user by status and (optionally) access url.
* *
* @todo not use status
*
* @param string $query The query to filter * @param string $query The query to filter
* @param int $status The status * @param int $status The status
* @param int $accessUrlId The access URL ID * @param int $accessUrlId The access URL ID
* *
* @return array * @return array
*/ */
public function searchUsersByStatus($query, $status, $accessUrlId = null) public function searchUsersByStatus($query, $status, $accessUrlId = 0)
{ {
$accessUrlId = intval($accessUrlId); $accessUrlId = (int) $accessUrlId;
$queryBuilder = $this->createQueryBuilder('u'); $queryBuilder = $this->createQueryBuilder('u');
if ($accessUrlId > 0) { if ($accessUrlId > 0) {
$queryBuilder->innerJoin( $queryBuilder->innerJoin(
'ChamiloCoreBundle:AccessUrlRelUser', 'ChamiloCoreBundle:AccessUrlRelUser',
'auru', 'auru',
\Doctrine\ORM\Query\Expr\Join::WITH, Join::WITH,
'u.id = auru.userId' 'u.id = auru.userId'
); );
} }
$queryBuilder->where('u.status = :status') $queryBuilder
->where('u.status = :status')
->andWhere('u.username LIKE :query OR u.firstname LIKE :query OR u.lastname LIKE :query') ->andWhere('u.username LIKE :query OR u.firstname LIKE :query OR u.lastname LIKE :query')
->setParameter('status', $status) ->setParameter('status', $status)
->setParameter('query', "$query%"); ->setParameter('query', "$query%");
if ($accessUrlId > 0) { if ($accessUrlId > 0) {
$queryBuilder->andWhere('auru.accessUrlId = :url') $queryBuilder
->andWhere('auru.accessUrlId = :url')
->setParameter(':url', $accessUrlId); ->setParameter(':url', $accessUrlId);
} }
@ -174,13 +173,14 @@ class UserRepository extends EntityRepository
* @param Session $session The session * @param Session $session The session
* @param Course $course The course * @param Course $course The course
* *
* @return \Doctrine\ORM\QueryBuilder * @return array
*/ */
public function getCoachesForSessionCourse(Session $session, Course $course) public function getCoachesForSessionCourse(Session $session, Course $course)
{ {
$queryBuilder = $this->createQueryBuilder('u'); $queryBuilder = $this->createQueryBuilder('u');
$queryBuilder->select('u') $queryBuilder
->select('u')
->innerJoin( ->innerJoin(
'ChamiloCoreBundle:SessionRelCourseRelUser', 'ChamiloCoreBundle:SessionRelCourseRelUser',
'scu', 'scu',
@ -263,7 +263,7 @@ class UserRepository extends EntityRepository
/** /**
* Get the sessions admins for a user. * Get the sessions admins for a user.
* *
* @param User $user The user * @param User $user
* *
* @return array * @return array
*/ */
@ -289,8 +289,7 @@ class UserRepository extends EntityRepository
) )
->andWhere( ->andWhere(
$queryBuilder->expr()->eq('su.relationType', SESSION_RELATION_TYPE_RRHH) $queryBuilder->expr()->eq('su.relationType', SESSION_RELATION_TYPE_RRHH)
) );
;
return $queryBuilder->getQuery()->getResult(); return $queryBuilder->getQuery()->getResult();
} }
@ -298,7 +297,7 @@ class UserRepository extends EntityRepository
/** /**
* Get the student bosses for a user. * Get the student bosses for a user.
* *
* @param User $user The user * @param User $user
* *
* @return array * @return array
*/ */
@ -322,4 +321,114 @@ class UserRepository extends EntityRepository
return $queryBuilder->getQuery()->getResult(); return $queryBuilder->getQuery()->getResult();
} }
/**
* Find potential users to send a message.
*
* @param int $currentUserId The current user ID
* @param string $search The search text to filter the user list
* @param int $limit Optional. Sets the maximum number of results to retrieve
*
* @return mixed
*/
public function findUsersToSendMessage($currentUserId, $search, $limit = 10)
{
$allowSendMessageToAllUsers = api_get_setting('allow_send_message_to_all_platform_users');
$accessUrlId = api_get_multiple_access_url() ? api_get_current_access_url_id() : 1;
if (api_get_setting('allow_social_tool') === 'true' &&
api_get_setting('allow_message_tool') === 'true'
) {
// All users
if ($allowSendMessageToAllUsers === 'true' || api_is_platform_admin()) {
$dql = "SELECT DISTINCT U
FROM ChamiloUserBundle:User U
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R
WITH U = R.user
WHERE
U.active = 1 AND
U.status != 6 AND
U.id != $currentUserId AND
R.portal = $accessUrlId";
} else {
$dql = "SELECT DISTINCT U
FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF
INNER JOIN ChamiloUserBundle:User AS U
WITH UF.friendUserId = U
WHERE
U.active = 1 AND
U.status != 6 AND
UF.relationType NOT IN(".USER_RELATION_TYPE_DELETED.", ".USER_RELATION_TYPE_RRHH.") AND
UF.userId = $currentUserId AND
UF.friendUserId != $currentUserId AND
U = R.user AND
R.portal = $accessUrlId";
}
} elseif (
api_get_setting('allow_social_tool') === 'false' &&
api_get_setting('allow_message_tool') === 'true'
) {
if ($allowSendMessageToAllUsers === 'true') {
$dql = "SELECT DISTINCT U
FROM ChamiloUserBundle:User U
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R
WITH U = R.user
WHERE
U.active = 1 AND
U.status != 6 AND
U.id != $currentUserId AND
R.portal = $accessUrlId";
} else {
$time_limit = api_get_setting('time_limit_whosonline');
$online_time = time() - $time_limit * 60;
$limit_date = api_get_utc_datetime($online_time);
$dql = "SELECT DISTINCT U
FROM ChamiloUserBundle:User U
INNER JOIN ChamiloCoreBundle:TrackEOnline T
WITH U.id = T.loginUserId
WHERE
U.active = 1 AND
T.loginDate >= '".$limit_date."'";
}
}
$dql .= ' AND (U.firstname LIKE :search OR U.lastname LIKE :search OR U.email LIKE :search OR U.username LIKE :search)';
return $this->getEntityManager()
->createQuery($dql)
->setMaxResults($limit)
->setParameters(['search' => "%$search%"])
->getResult();
}
/**
* Get the list of HRM who have assigned this user.
*
* @param int $userId
* @param int $urlId
*
* @return array
*/
public function getAssignedHrmUserList($userId, $urlId)
{
$qb = $this->createQueryBuilder('user');
$hrmList = $qb
->select('uru')
->innerJoin('ChamiloCoreBundle:UserRelUser', 'uru', Join::WITH, 'uru.userId = user.id')
->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'auru', Join::WITH, 'auru.userId = uru.friendUserId')
->where(
$qb->expr()->eq('auru.accessUrlId', $urlId)
)
->andWhere(
$qb->expr()->eq('uru.userId', $userId)
)
->andWhere(
$qb->expr()->eq('uru.relationType', USER_RELATION_TYPE_RRHH)
)
->getQuery()
->getResult();
return $hrmList;
}
} }

@ -24,7 +24,6 @@ Feature: Group tool
And I press "submit" And I press "submit"
Then I should see "group(s) has (have) been added" Then I should see "group(s) has (have) been added"
Scenario: Create document folder in group Scenario: Create document folder in group
Given I am on "/main/group/group.php?cidReq=TEMP&id_session=0" Given I am on "/main/group/group.php?cidReq=TEMP&id_session=0"
And I follow "Group 0001" And I follow "Group 0001"
@ -76,11 +75,9 @@ Feature: Group tool
Then I should see "My folder in group" Then I should see "My folder in group"
Then I follow "My folder in group" Then I follow "My folder in group"
Then I follow "Delete" Then I follow "Delete"
And I confirm the popup Then wait for the page to be loaded
Then I should see "Document deleted" Then I should see "Are you sure to delete"
Then I follow "Delete" Then I follow "delete_item"
And I confirm the popup
Then I should see "Document deleted"
Scenario: Delete directory Scenario: Delete directory
Given I am on "/main/group/group.php?cidReq=TEMP&id_session=0" Given I am on "/main/group/group.php?cidReq=TEMP&id_session=0"
@ -89,5 +86,6 @@ Feature: Group tool
And I follow "Documents" And I follow "Documents"
Then I should see "My folder in group" Then I should see "My folder in group"
Then I follow "Delete" Then I follow "Delete"
And I confirm the popup Then wait for the page to be loaded
Then I should see "Document deleted" Then I should see "Are you sure to delete"
Then I follow "delete_item"
Loading…
Cancel
Save