Source for file folder_list_util.php

Documentation is available at folder_list_util.php

  1. <?php
  2.  
  3. /**
  4.  * folder_list_util.php
  5.  *
  6.  * Provides some functions for use in left_main.php and templates.  Do not echo
  7.  * output from these functions!
  8.  *
  9.  * @copyright 1999-2020 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: folder_list_util.php 14845 2020-01-07 08:09:34Z pdontthink $
  12.  * @package squirrelmail
  13.  * @subpackage templates
  14.  */
  15.  
  16. /**
  17.  * Recursively iterates a mailboxes object to get the cummulative count of
  18.  * messages for all folderes below the current mailbox.
  19.  * 
  20.  * @param object $boxes Object of the class mailboxes
  21.  * @param string $type Whether to fetch unseen only or all messages
  22.  * @author Steve Brown
  23.  * @since 1.5.2
  24.  */
  25. function getMessageCount ($boxes$type='total'{
  26.  
  27.     global $trash_folder;
  28.  
  29.     // The Trash folder isn't counted...
  30.     if ($boxes->mailboxname_full == $trash_folder)
  31.         return 0;
  32.         
  33.     $count 0;
  34.     if (strtolower($type== 'unseen')
  35.         $field 'unseen';
  36.     else $field 'total';
  37.     
  38.     
  39.     $count += !empty($boxes->{$field}$boxes->{$field0;
  40.     for ($j 0$j <count($boxes->mbxs)$j++{
  41.         $count += getMessageCount($boxes->mbxs[$j]$type);
  42.     }
  43.     
  44.     return $count;    
  45. }
  46.  
  47. /**
  48.  * Recursively iterates a mailboxes object to build a data structure that is
  49.  * easy for template authors to work with.
  50. FIXME: well.... why not document that data structure here?
  51.  * 
  52.  * @param object $boxes Object of the class mailboxes
  53.  * @author Steve Brown
  54.  * @since 1.5.2
  55.  */
  56. function getBoxStructure ($boxes{
  57.     global $data_dir$username$icon_theme_path;
  58.         
  59.     // Stop condition   
  60.     if (empty($boxes))  {
  61.         return array();
  62.     }
  63.     
  64.     $mailbox $boxes->mailboxname_full;
  65.     $mailboxURL urlencode($mailbox);
  66.     $box array();
  67.  
  68.     $box['MailboxFullName'$mailbox;
  69.     $box['MailboxName'$boxes->mailboxname_sub;
  70.     $box['MessageCount'!empty($boxes->total$boxes->total 0;
  71.     $box['UnreadCount'!empty($boxes->unseen$boxes->unseen 0;
  72.     
  73.     // Needed in case user enables cummulative message counts
  74.     $box['CummulativeMessageCount'getMessageCount($boxes'total');
  75.     $box['CummulativeUnreadCount'getMessageCount($boxes'unseen');
  76.     
  77.     $box['ViewLink'array'Target' => 'right',
  78.                               'URL'    => 'right_main.php?PG_SHOWALL=0&amp;startMessage=1&amp;mailbox='.$mailboxURL
  79.                             );
  80.                               
  81.     $box['IsRecent'= isset($boxes->recent&& $boxes->recent;
  82.     $box['IsSpecial'= isset($boxes->is_special&& $boxes->is_special;
  83.     $box['IsRoot'=  isset($boxes->is_root&& $boxes->is_root;
  84.     $box['IsNoSelect'= isset($boxes->is_noselect&& $boxes->is_noselect;
  85.  
  86.     $box['IsInbox'= isset($boxes->is_inbox&& $boxes->is_inbox;
  87.     $box['IsSent'= isset($boxes->is_sent&& $boxes->is_sent;
  88.     $box['IsTrash'= isset($boxes->is_trash&& $boxes->is_trash;
  89.     $box['IsDraft'= isset($boxes->is_draft&& $boxes->is_draft;
  90.     $box['IsNoInferiors'= isset($boxes->is_noinferiors&& $boxes->is_noinferiors;
  91.  
  92.     $collapse getPref($data_dir$username'collapse_folder_' $mailbox);
  93.     $collapse ($collapse == '' SM_BOX_UNCOLLAPSED $collapse);
  94.     $collapse = (int)$collapse == SM_BOX_COLLAPSED;
  95.     $box['IsCollapsed'$collapse;
  96.  
  97.     /*
  98.      * Check for an image needed here.  If the file exists in $icon_theme_path
  99.      * assume the template provides all icons.  If not, we will use the 
  100.      * SQM default images.  If icons have been disabled, $icon_theme_path
  101.      * will be NULL.
  102.      */
  103.      
  104.     $text_icon $box['IsCollapsed''+' '-';
  105.     $icon_file $box['IsCollapsed''plus.png' 'minus.png';
  106.     $icon_alt $box['IsCollapsed''Expand Box' 'Collapse Box';
  107.     $icon getIcon($icon_theme_path$icon_file$text_icon$icon_alt);
  108.     
  109.     $box['CollapseLink'array 'Target' => 'left',
  110.                                    'URL'    => 'left_main.php?'.($box['IsCollapsed''unfold' 'fold'.'='.$mailboxURL,
  111.                                    'Icon'   => $icon .'&nbsp;'
  112.                                  )
  113.  
  114.     $box['ChildBoxes'array();
  115.     for ($i 0$i <count($boxes->mbxs)$i++{
  116.         $box['ChildBoxes'][getBoxStructure($boxes->mbxs[$i]);
  117.     }
  118.     
  119.     // if plugins want to add some text or link after the folder name in
  120.     // the folder list, they should add to the "ExtraOutput" array element
  121.     // in $box (remember, it's passed through the hook by reference) -- making
  122.     // sure to play nice with other plugins by *concatenating* to "ExtraOutput"
  123.     // and NOT by overwriting it
  124.     //
  125.     // known users of this hook:
  126.     // empty_folders
  127.     //
  128.     do_hook('left_main_after_each_folder'$box);
  129.  
  130.     return $box;
  131. }

Documentation generated on Mon, 13 Jan 2020 04:22:31 +0100 by phpDocumentor 1.4.3