Merge branch '1.11.x' of https://github.com/chamilo/chamilo-lms into 1.11.x
commit
94c98fca6e
@ -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> |
|
||||||
@ -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; |
|
||||||
} |
|
||||||
} |
|
||||||
Loading…
Reference in new issue