Skip to content

Commit

Permalink
always put the inbox at the top of a sorted folder list
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmunro committed Apr 3, 2017
1 parent 5c450fa commit 1d708f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.php
@@ -1,7 +1,7 @@
<?php

/**
* GIT VERSION: 4133
* GIT VERSION: 4170
*
* Some of the following constants are automatically filled in when
* the build process is run. If you change them in site/index.php
Expand Down
15 changes: 14 additions & 1 deletion modules/imap/hm-imap.php
Expand Up @@ -523,10 +523,23 @@ public function get_mailbox_list($lsub=false, $mailbox='', $keyword='*') {
}

/* sort and return the list */
uksort($folders, 'strcasecmp');
uksort($folders, array($this, 'fsort'));
return $this->cache_return_val($folders, $cache_command);
}

/**
* Sort a folder list with the inbox at the top
*/
function fsort($a, $b) {
if (strtolower($a) == 'inbox') {
return -1;
}
if (strtolower($b) == 'inbox') {
return 1;
}
return strcasecmp($a, $b);
}

/**
* get IMAP folder namespaces
* @return array list of available namespace details
Expand Down
1 change: 0 additions & 1 deletion modules/imap/modules.php
Expand Up @@ -1803,7 +1803,6 @@ protected function output() {
$res = '';
$folder_data = $this->get('imap_expanded_folder_data', array());
if (!empty($folder_data)) {
ksort($folder_data);
$res .= format_imap_folder_section($folder_data, $this->get('imap_expanded_folder_id'), $this);
$this->out('imap_expanded_folder_formatted', $res);
}
Expand Down

0 comments on commit 1d708f2

Please sign in to comment.