浏览代码

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

BT#12723
jmontoyaa 7 年之前
父节点
当前提交
6065370a26
共有 2 个文件被更改,包括 17 次插入11 次删除
  1. 7 2
      plugin/studentfollowup/StudentFollowUpPlugin.php
  2. 10 9
      plugin/studentfollowup/posts.php

+ 7 - 2
plugin/studentfollowup/StudentFollowUpPlugin.php

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

+ 10 - 9
plugin/studentfollowup/posts.php

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