diff options
author | alecpl <alec@alec.pl> | 2011-12-29 09:35:01 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2011-12-29 09:35:01 +0000 |
commit | 08ffd939a7530c44cd68b455f75175f79698073c (patch) | |
tree | ff3d5dcfef837d47e2a9b5873ef4a864f9da0e4a /program/steps/addressbook | |
parent | 81c2ce9b7b670b05de21f5dcc4be50b70c12fcfc (diff) |
- Add separate pagesize setting for mail messages and contacts (#1488269)
Diffstat (limited to 'program/steps/addressbook')
-rw-r--r-- | program/steps/addressbook/delete.inc | 12 | ||||
-rw-r--r-- | program/steps/addressbook/func.inc | 12 | ||||
-rw-r--r-- | program/steps/addressbook/list.inc | 12 | ||||
-rw-r--r-- | program/steps/addressbook/search.inc | 8 |
4 files changed, 24 insertions, 20 deletions
diff --git a/program/steps/addressbook/delete.inc b/program/steps/addressbook/delete.inc index 222535cf3..30e0ca13b 100644 --- a/program/steps/addressbook/delete.inc +++ b/program/steps/addressbook/delete.inc @@ -103,20 +103,20 @@ if (($search_request = $_REQUEST['_search']) && isset($_SESSION['search'][$searc // create resultset object $count = count($records); - $first = ($page-1) * $CONFIG['pagesize']; + $first = ($page-1) * $PAGE_SIZE; $result = new rcube_result_set($count, $first); // get records from the next page to add to the list - $pages = ceil((count($records) + $delcnt) / $CONFIG['pagesize']); + $pages = ceil((count($records) + $delcnt) / $PAGE_SIZE); if ($_GET['_from'] != 'show' && $pages > 1 && $page < $pages) { // sort the records ksort($records, SORT_LOCALE_STRING); - $first += $CONFIG['pagesize']; + $first += $PAGE_SIZE; // create resultset object $res = new rcube_result_set($count, $first - $delcnt); - if ($CONFIG['pagesize'] < $count) { + if ($PAGE_SIZE < $count) { $records = array_slice($records, $first - $delcnt, $delcnt); } @@ -132,7 +132,7 @@ else { $result = $CONTACTS->count(); // get records from the next page to add to the list - $pages = ceil(($result->count + $delcnt) / $CONFIG['pagesize']); + $pages = ceil(($result->count + $delcnt) / $PAGE_SIZE); if ($_GET['_from'] != 'show' && $pages > 1 && $page < $pages) { $CONTACTS->set_page($page); $records = $CONTACTS->list_records(null, -$delcnt); @@ -140,7 +140,7 @@ else { } // update message count display -$OUTPUT->set_env('pagecount', ceil($result->count / $CONFIG['pagesize'])); +$OUTPUT->set_env('pagecount', ceil($result->count / $PAGE_SIZE)); $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); if (!empty($_SESSION['contact_undo'])) { diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index fac8987f8..e7d3eaebe 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -56,6 +56,10 @@ $CONTACT_COLTYPES = array( // TODO: define fields for vcards like GEO, KEY ); +$PAGE_SIZE = $RCMAIL->config->get('addressbook_pagesize'); +if (!$PAGE_SIZE) { + $PAGE_SIZE = $RCMAIL->config->get('pagesize', 50); +} // Addressbook UI if (!$RCMAIL->action && !$OUTPUT->ajax_call) { @@ -108,7 +112,7 @@ if ($undo = $_SESSION['contact_undo']) { // instantiate a contacts object according to the given source function rcmail_contact_source($source=null, $init_env=false, $writable=false) { - global $RCMAIL, $OUTPUT, $CONFIG, $CONTACT_COLTYPES; + global $RCMAIL, $OUTPUT, $CONTACT_COLTYPES, $PAGE_SIZE; if (!strlen($source)) { $source = get_input_value('_source', RCUBE_INPUT_GPC); @@ -116,7 +120,7 @@ function rcmail_contact_source($source=null, $init_env=false, $writable=false) // Get object $CONTACTS = $RCMAIL->get_address_book($source, $writable); - $CONTACTS->set_pagesize($CONFIG['pagesize']); + $CONTACTS->set_pagesize($PAGE_SIZE); // set list properties and session vars if (!empty($_GET['_page'])) @@ -391,7 +395,7 @@ function rcmail_rowcount_display($attrib) function rcmail_get_rowcount_text($result=null) { - global $CONTACTS, $CONFIG; + global $CONTACTS, $PAGE_SIZE; // read nr of contacts if (!$result) { @@ -405,7 +409,7 @@ function rcmail_get_rowcount_text($result=null) 'name' => $_SESSION['contactcountdisplay'] ? $_SESSION['contactcountdisplay'] : 'contactsfromto', 'vars' => array( 'from' => $result->first + 1, - 'to' => min($result->count, $result->first + $CONFIG['pagesize']), + 'to' => min($result->count, $result->first + $PAGE_SIZE), 'count' => $result->count) )); diff --git a/program/steps/addressbook/list.inc b/program/steps/addressbook/list.inc index b4b7306a6..0e3afa2a9 100644 --- a/program/steps/addressbook/list.inc +++ b/program/steps/addressbook/list.inc @@ -56,13 +56,13 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search ksort($records, SORT_LOCALE_STRING); // create resultset object - $count = count($records); - $first = ($page-1) * $CONFIG['pagesize']; + $count = count($records); + $first = ($page-1) * $PAGE_SIZE; $result = new rcube_result_set($count, $first); // we need only records for current page - if ($CONFIG['pagesize'] < $count) { - $records = array_slice($records, $first, $CONFIG['pagesize']); + if ($PAGE_SIZE < $count) { + $records = array_slice($records, $first, $PAGE_SIZE); } $result->records = array_values($records); @@ -73,7 +73,7 @@ else { // get contacts for this user $result = $CONTACTS->list_records(array('name')); - + if (!$result->count && $result->searchonly) { $OUTPUT->show_message('contactsearchonly', 'notice'); $OUTPUT->command('command', 'advanced-search'); @@ -81,7 +81,7 @@ else { } // update message count display -$OUTPUT->set_env('pagecount', ceil($result->count / $CONFIG['pagesize'])); +$OUTPUT->set_env('pagecount', ceil($result->count / $PAGE_SIZE)); $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); // create javascript list diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc index 643cc60a8..e4ce2d655 100644 --- a/program/steps/addressbook/search.inc +++ b/program/steps/addressbook/search.inc @@ -88,7 +88,7 @@ $OUTPUT->send('contactsearch'); function rcmail_contact_search() { - global $RCMAIL, $OUTPUT, $CONFIG, $SEARCH_MODS_DEFAULT; + global $RCMAIL, $OUTPUT, $SEARCH_MODS_DEFAULT, $PAGE_SIZE; $adv = isset($_POST['_adv']); $sid = get_input_value('_sid', RCUBE_INPUT_GET); @@ -198,8 +198,8 @@ function rcmail_contact_search() $result = new rcube_result_set($count); // cut first-page records - if ($CONFIG['pagesize'] < $count) { - $records = array_slice($records, 0, $CONFIG['pagesize']); + if ($PAGE_SIZE < $count) { + $records = array_slice($records, 0, $PAGE_SIZE); } $result->records = array_values($records); @@ -228,7 +228,7 @@ function rcmail_contact_search() // update message count display $OUTPUT->command('set_env', 'search_request', $search_request); - $OUTPUT->command('set_env', 'pagecount', ceil($result->count / $CONFIG['pagesize'])); + $OUTPUT->command('set_env', 'pagecount', ceil($result->count / $PAGE_SIZE)); $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); // Re-set current source $OUTPUT->command('set_env', 'search_id', $sid); |