mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
[mailing list] add paging
Summary: The mailing list page in MetaMTA only showed the first 100 sorted by ID, so it made it seem like lists were missing. Changed it to do paging and short by name, so it has some user-understandable order. Test Plan: - Go to /mail/lists/ - Step through pager, confirm ordering. Reviewers: nh, epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1670
This commit is contained in:
parent
5c5514b948
commit
913c931cb0
2 changed files with 25 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,8 +20,27 @@ class PhabricatorMetaMTAMailingListsController
|
||||||
extends PhabricatorMetaMTAController {
|
extends PhabricatorMetaMTAController {
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$lists = id(new PhabricatorMetaMTAMailingList())->loadAllWhere(
|
$request = $this->getRequest();
|
||||||
'1 = 1 ORDER BY id DESC LIMIT 100');
|
$user = $request->getUser();
|
||||||
|
$offset = $request->getInt('offset', 0);
|
||||||
|
|
||||||
|
$pager = new AphrontPagerView();
|
||||||
|
$pager->setPageSize(1000);
|
||||||
|
$pager->setOffset($offset);
|
||||||
|
$pager->setURI($request->getRequestURI(), 'offset');
|
||||||
|
|
||||||
|
$list = new PhabricatorMetaMTAMailingList();
|
||||||
|
$conn_r = $list->establishConnection('r');
|
||||||
|
$data = queryfx_all(
|
||||||
|
$conn_r,
|
||||||
|
'SELECT * FROM %T
|
||||||
|
ORDER BY name ASC
|
||||||
|
LIMIT %d, %d',
|
||||||
|
$list->getTableName(),
|
||||||
|
$pager->getOffset(), $pager->getPageSize() + 1);
|
||||||
|
$data = $pager->sliceResults($data);
|
||||||
|
|
||||||
|
$lists = $list->loadAllFromArray($data);
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($lists as $list) {
|
foreach ($lists as $list) {
|
||||||
|
@ -59,6 +78,7 @@ class PhabricatorMetaMTAMailingListsController
|
||||||
$panel->appendChild($table);
|
$panel->appendChild($table);
|
||||||
$panel->setHeader('Mailing Lists');
|
$panel->setHeader('Mailing Lists');
|
||||||
$panel->setCreateButton('Add New List', '/mail/lists/edit/');
|
$panel->setCreateButton('Add New List', '/mail/lists/edit/');
|
||||||
|
$panel->appendChild($pager);
|
||||||
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$panel,
|
$panel,
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'applications/metamta/controller/base');
|
phutil_require_module('phabricator', 'applications/metamta/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist');
|
phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist');
|
||||||
|
phutil_require_module('phabricator', 'storage/queryfx');
|
||||||
|
phutil_require_module('phabricator', 'view/control/pager');
|
||||||
phutil_require_module('phabricator', 'view/control/table');
|
phutil_require_module('phabricator', 'view/control/table');
|
||||||
phutil_require_module('phabricator', 'view/layout/panel');
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
phutil_require_module('phutil', 'utils');
|
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('PhabricatorMetaMTAMailingListsController.php');
|
phutil_require_source('PhabricatorMetaMTAMailingListsController.php');
|
||||||
|
|
Loading…
Reference in a new issue