diff --git a/plugin/bbb/lib/bbb.lib.php b/plugin/bbb/lib/bbb.lib.php index aef62ac9e0..e29f85255e 100755 --- a/plugin/bbb/lib/bbb.lib.php +++ b/plugin/bbb/lib/bbb.lib.php @@ -900,6 +900,8 @@ class bbb * @param int $groupId * @param bool $isAdminReport Optional. Set to true then the report is for admins * @param array $dateRange Optional + * @param int $start Optional + * @param int $limit Optional * * @return array Array of current open meeting rooms * @throws Exception @@ -909,7 +911,9 @@ class bbb $sessionId = 0, $groupId = 0, $isAdminReport = false, - $dateRange = [] + $dateRange = [], + $start = 0, + $limit = 0 ) { $em = Database::getManager(); $manager = $this->isConferenceManager(); @@ -973,6 +977,10 @@ class bbb $conditions['order'] = 'created_at ASC'; + if ($limit) { + $conditions['limit'] = "$start , $limit"; + } + $meetingList = Database::select( '*', $this->table, @@ -1140,6 +1148,80 @@ class bbb return $newMeetingList; } + /** + * Counts all the course meetings saved in the plugin_bbb_meeting table. + * + * @param int $courseId + * @param int $sessionId + * @param int $groupId + * @param array $dateRange + * + * @return int Count of meetings + * @throws Exception + */ + public function getCountMeetings( + $courseId = 0, + $sessionId = 0, + $groupId = 0, + $dateRange = [] + ) { + $conditions = []; + if ($courseId || $sessionId || $groupId) { + $conditions = array( + 'where' => array( + 'c_id = ? AND session_id = ? ' => array($courseId, $sessionId), + ), + ); + + if ($this->hasGroupSupport()) { + $conditions = array( + 'where' => array( + 'c_id = ? AND session_id = ? AND group_id = ? ' => array( + $courseId, + $sessionId, + $groupId, + ), + ), + ); + } + + if ($this->isGlobalConferencePerUserEnabled()) { + $conditions = array( + 'where' => array( + 'c_id = ? AND session_id = ? AND user_id = ?' => array( + $courseId, + $sessionId, + $this->userId, + ), + ), + ); + } + } + + if (!empty($dateRange)) { + $dateStart = date_create($dateRange['search_meeting_start']); + $dateStart = date_format($dateStart, 'Y-m-d H:i:s'); + $dateEnd = date_create($dateRange['search_meeting_end']); + $dateEnd = $dateEnd->add(new DateInterval('P1D')); + $dateEnd = date_format($dateEnd, 'Y-m-d H:i:s'); + + $conditions = array( + 'where' => array( + 'created_at BETWEEN ? AND ? ' => array($dateStart, $dateEnd), + ), + ); + } + + $row = Database::select( + 'count(*) as count', + $this->table, + $conditions, + 'first' + ); + + return $row['count']; + } + /** * @param array $meeting * diff --git a/plugin/bbb/listing.php b/plugin/bbb/listing.php index eb11290e66..fa7c7471c8 100755 --- a/plugin/bbb/listing.php +++ b/plugin/bbb/listing.php @@ -357,11 +357,39 @@ if ($conferenceManager && $allowToEdit) { } } +if (isset($_GET['page_id'])) { + $pageId = (int) $_GET['page_id']; +} + +$meetingsCount = $bbb->getCountMeetings( + api_get_course_int_id(), + api_get_session_id(), + api_get_group_id() +); + +$limit = 10; +$pageNumber = ceil($meetingsCount / $limit); + +if (!isset($pageId)) { + $pageId = 1; +} + +$start = ($pageId - 1) * $limit; + $meetings = $bbb->getMeetings( api_get_course_int_id(), api_get_session_id(), - $groupId + api_get_group_id(), + false, + [], + $start, + $limit ); + +if (empty($meetings)) { + $pageId = 0; +} + if (!empty($meetings)) { $meetings = array_reverse($meetings); } @@ -460,6 +488,8 @@ $tpl->assign('show_join_button', $showJoinButton); $tpl->assign('message', $message); $tpl->assign('form', $formToString); $tpl->assign('enter_conference_links', $urlList); +$tpl->assign('page_number', $pageNumber); +$tpl->assign('page_id', $pageId); $content = $tpl->fetch('bbb/view/listing.tpl'); diff --git a/plugin/bbb/view/listing.tpl b/plugin/bbb/view/listing.tpl index 62254b72e7..712018ae36 100644 --- a/plugin/bbb/view/listing.tpl +++ b/plugin/bbb/view/listing.tpl @@ -111,6 +111,30 @@ {% endfor %} + {% else %}