Fix pagination, drh that follows session can see student care posts

BT#12723
pull/2487/head
jmontoyaa 9 years ago
parent 9467bf40d1
commit 6065370a26
  1. 9
      plugin/studentfollowup/StudentFollowUpPlugin.php
  2. 19
      plugin/studentfollowup/posts.php

@ -100,7 +100,6 @@ class StudentFollowUpPlugin extends Plugin
]; ];
} }
$isAllow = false;
$showPrivate = false; $showPrivate = false;
if ($studentId === $currentUserId) { if ($studentId === $currentUserId) {
$isAllow = true; $isAllow = true;
@ -112,9 +111,15 @@ class StudentFollowUpPlugin extends Plugin
$sessions = SessionManager::get_sessions_by_user($studentId); $sessions = SessionManager::get_sessions_by_user($studentId);
$isCourseCoach = false; $isCourseCoach = false;
$isDrhSession = false;
if (!empty($sessions)) { if (!empty($sessions)) {
foreach ($sessions as $session) { foreach ($sessions as $session) {
$sessionId = $session['session_id']; $sessionId = $session['session_id'];
$sessionDrhInfo = SessionManager::getSessionFollowedByDrh($currentUserId, $sessionId);
if (!empty($sessionDrhInfo)) {
$isDrhSession = true;
break;
}
foreach ($session['courses'] as $course) { foreach ($session['courses'] as $course) {
//$isCourseCoach = api_is_coach($sessionId, $course['real_id']); //$isCourseCoach = api_is_coach($sessionId, $course['real_id']);
$coachList = SessionManager::getCoachesByCourseSession($sessionId, $course['real_id']); $coachList = SessionManager::getCoachesByCourseSession($sessionId, $course['real_id']);
@ -126,7 +131,7 @@ class StudentFollowUpPlugin extends Plugin
} }
} }
$isAllow = $isAdminOrDrh || $isCourseCoach; $isAllow = $isAdminOrDrh || $isCourseCoach || $isDrhSession;
$showPrivate = $isAdminOrDrh; $showPrivate = $isAdminOrDrh;
} }

@ -44,23 +44,24 @@ $qb
; ;
$query = $qb->getQuery(); $query = $qb->getQuery();
$posts = new Paginator($query, $fetchJoinCollection = true); $posts = new Paginator($query, $fetchJoinCollection = true);
$totalItems = count($posts); $totalItems = count($posts);
$pagesCount = ceil($totalItems / $pageSize); $pagesCount = ceil($totalItems / $pageSize);
$pagination = ''; $pagination = '';
$url = api_get_self().'?student_id='.$studentId; $url = api_get_self().'?student_id='.$studentId;
$pagination .= '<ul class="pagination">'; if ($totalItems > 1) {
for ($i = 0; $i < $pagesCount; $i++) { $pagination .= '<ul class="pagination">';
$newPage = $i + 1; for ($i = 0; $i < $pagesCount; $i++) {
if ($currentPage == $newPage) { $newPage = $i + 1;
$pagination .= '<li class="active"><a href="'.$url.'&page='.$newPage.'">'.$newPage.'</a></li>'; if ($currentPage == $newPage) {
} else { $pagination .= '<li class="active"><a href="'.$url.'&page='.$newPage.'">'.$newPage.'</a></li>';
$pagination .= '<li><a href="'.$url.'&page='.$newPage.'">'.$newPage.'</a></li>'; } else {
$pagination .= '<li><a href="'.$url.'&page='.$newPage.'">'.$newPage.'</a></li>';
}
} }
$pagination .= '</ul>';
} }
$pagination .= '</ul>';
$tpl = new Template($plugin->get_lang('plugin_title')); $tpl = new Template($plugin->get_lang('plugin_title'));
$tpl->assign('posts', $posts); $tpl->assign('posts', $posts);

Loading…
Cancel
Save