Plugin: BigBlueButton: Add pagination to conferences listing

Authored-By: @juan-cortizas-ponte
pull/4384/head
Juan Cortizas Ponte 3 years ago committed by GitHub
parent fde4156b79
commit c91d81db48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 84
      plugin/bbb/lib/bbb.lib.php
  2. 32
      plugin/bbb/listing.php
  3. 24
      plugin/bbb/view/listing.tpl

@ -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
*

@ -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');

@ -111,6 +111,30 @@
{% endfor %}
</table>
</div>
<nav>
<ul class="pagination">
<li class="page-item {% if page_id <= 1 %} disabled {% endif %} ">
<a class="page-link"
href= "{{ _p.web_self_query_vars ~ '&' ~ {'page_id' : page_id - 1 }|url_encode() }}" >
Anterior
</a>
</li>
{% if page_number > 0 %}
{% for i in 1..page_number %}
<li class="page-item {% if page_id == i %} active {% endif %} ">
<a class="page-link" href="{{ _p.web_self_query_vars ~ '&' ~ {'page_id': i }|url_encode() }}" >
{{ i }}
</a>
</li>
{% endfor %}
{% endif %}
<li class="page-item {% if page_number <= page_id %} disabled {% endif %} ">
<a class="page-link" href= "{{ _p.web_self_query_vars ~ '&' ~ {'page_id' : page_id + 1 }|url_encode() }}">
Siguiente
</a>
</li>
</ul>
</nav>
{% else %}
<div class ="col-md-12" style="text-align:center">
{{ 'ServerIsNotRunning' | get_plugin_lang('BBBPlugin') | return_message('warning') }}

Loading…
Cancel
Save