[ Index ]
 

Code source de IMP H3 (4.1.5)

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/lib/Block/ -> tree_folders.php (source)

   1  <?php
   2  
   3  $block_name = _("Menu Folder List");
   4  $block_type = 'tree';
   5  
   6  /**
   7   * $Horde: imp/lib/Block/tree_folders.php,v 1.28.2.17 2006/03/08 07:20:34 slusarz Exp $
   8   *
   9   * @package Horde_Block
  10   */
  11  class Horde_Block_imp_tree_folders extends Horde_Block {
  12  
  13      var $_app = 'imp';
  14  
  15      function _buildTree(&$tree, $indent = 0, $parent = null)
  16      {
  17          global $registry, $prefs;
  18  
  19          $GLOBALS['authentication'] = 'none';
  20          @define('IMP_BASE', dirname(__FILE__) . '/../..');
  21          require_once  IMP_BASE . '/lib/base.php';
  22          require_once  IMP_BASE . '/lib/IMAP/Tree.php';
  23          require_once 'Horde/Identity.php';
  24  
  25          /* Abort immediately if we're not currently logged in. */
  26          if (IMP::checkAuthentication(OP_HALFOPEN, true) !== true) {
  27              return;
  28          }
  29  
  30          /* Call the mailbox icon hook, if requested. */
  31          $mbox_icons = array();
  32          if (!empty($GLOBALS['conf']['hooks']['mbox_icon'])) {
  33              require_once HORDE_BASE . '/config/hooks.php';
  34              if (function_exists('_imp_hook_mbox_icons')) {
  35                  $mbox_icons = call_user_func('_imp_hook_mbox_icons');
  36              }
  37          }
  38  
  39          /* Cache some additional values. */
  40          $image_dir = $registry->getImageDir();
  41          $use_vtrash = $prefs->getValue('use_vtrash');
  42  
  43          /* Initialize the user's identities. */
  44          $identity = &Identity::singleton(array('imp', 'imp'));
  45  
  46          $tree->addNode($parent . 'compose', $parent, _("New Message"),
  47                         $indent, false,
  48                         array('icon' => 'compose.png',
  49                               'icondir' => $image_dir,
  50                               'url' => IMP::composeLink(),
  51                               'target' => $prefs->getValue('compose_popup') ? 'horde_menu' : 'horde_main'));
  52  
  53          /* Add link to the search page. */
  54          $tree->addNode($parent . 'search', $parent, _("Search"),
  55                         $indent, false,
  56                         array('icon' => 'search.png',
  57                               'icondir' => $registry->getImageDir('horde'),
  58                               'url' => Horde::applicationUrl('search.php')));
  59  
  60          if ($_SESSION['imp']['base_protocol'] == 'pop3') {
  61              return;
  62          }
  63  
  64          /* Get special folders. */
  65          $trash = IMP::folderPref($prefs->getValue('trash_folder'), true);
  66          $draft = IMP::folderPref($prefs->getValue('drafts_folder'), true);
  67          $sent = $identity->getAllSentmailFolders();
  68  
  69          $name_url = Util::addParameter(Horde::applicationUrl('mailbox.php'), 'no_newmail_popup', 1);
  70  
  71          /* Initialize the IMP_Tree object. */
  72          $imptree = &IMP_Tree::singleton();
  73          $mask = IMAPTREE_NEXT_SHOWCLOSED;
  74          if ($prefs->getValue('subscribe') &&
  75              defined('IMAPTREE_NEXT_SHOWSUB')) {
  76              $mask |= IMAPTREE_NEXT_SHOWSUB;
  77          }
  78  
  79          /* Start iterating through the list of mailboxes, displaying them. */
  80          $unseen = 0;
  81          $inbox = null;
  82          $mailbox = $imptree->reset();
  83          if ($mailbox) {
  84              do {
  85                  $node_params = array();
  86  
  87                  if (!$imptree->isContainer($mailbox)) {
  88                      /* We are dealing with mailboxes here. Determine if we
  89                       * need to poll this mailbox for new messages. */
  90                      if ($imptree->isPolled($mailbox)) {
  91                          /* If we need message information for this folder,
  92                           * update it now. */
  93                          $msgs_info = $imptree->getElementInfo($mailbox['value']);
  94                          if (!empty($msgs_info)) {
  95                              /* Highlight mailboxes with unread messages in
  96                               * bold. */
  97                              if (!empty($msgs_info['unseen'])) {
  98                                  $unseen += $msgs_info['unseen'];
  99                                  $mailbox['label'] = '<span dir="ltr"><strong>' . $mailbox['label'] . '</strong> (' . $msgs_info['unseen'] . ') </span>';
 100                              }
 101                          }
 102                      }
 103  
 104                      /* If this is the INBOX, save it to later rewrite our parent
 105                       * node to include new mail notification. */
 106                      if (strcasecmp($mailbox['value'], 'INBOX') == 0) {
 107                          $inbox = $mailbox;
 108                      }
 109  
 110                      switch ($mailbox['value']) {
 111                      case 'INBOX':
 112                          $dir2 = 'inbox.png';
 113                          break;
 114  
 115                      case $trash:
 116                          $dir2 = ($use_vtrash) ? 'folder.png' : 'trash.png';
 117                          break;
 118  
 119                      case $draft:
 120                          $dir2 = 'drafts.png';
 121                          break;
 122  
 123                      default:
 124                          if ($imptree->isVFolder($mailbox) &&
 125                              $GLOBALS['imp_search']->isVTrashFolder($mailbox['value'])) {
 126                              $dir2 = 'trash.png';
 127                          } elseif ($imptree->isVFolder($mailbox) &&
 128                                    $GLOBALS['imp_search']->isVINBOXFolder($mailbox['value'])) {
 129                              $dir2 = 'inbox.png';
 130                          } elseif (in_array($mailbox['value'], $sent)) {
 131                              $dir2 = 'sent.png';
 132                          } else {
 133                              $dir2 = 'folder.png';
 134                          }
 135                          break;
 136                      }
 137                  } else {
 138                      /* We are dealing with folders here. */
 139                      $dir2 = 'folder.png';
 140                  }
 141  
 142                  if (isset($mbox_icons[$mailbox['value']]) &&
 143                      preg_match('/src="([^"]+)"/', $mbox_icons[$mailbox['value']], $match)) {
 144                      $icon = $match[1];
 145                      $icondir = '';
 146                  } else {
 147                      $icon = 'folders/' . $dir2;
 148                      $icondir = $image_dir;
 149                  }
 150  
 151                  $node_params += array('icon' => $icon,
 152                                        'icondir' => $icondir,
 153                                        'url' => ($imptree->isContainer($mailbox)) ? null : Util::addParameter($name_url, 'mailbox', $mailbox['value']),
 154                                       );
 155                  $tree->addNode($parent . $mailbox['value'],
 156                                 $parent . $mailbox['parent'],
 157                                 $mailbox['label'], $indent + $mailbox['level'], $imptree->isOpenSidebar($mailbox['value']), $node_params);
 158              } while (($mailbox = $imptree->next($mask)));
 159          }
 160  
 161          /* We want to rewrite the parent node of the INBOX to include new mail
 162           * notification. */
 163          if ($inbox) {
 164              $url = $registry->get('url', $parent);
 165              if (empty($url)) {
 166                  if (($registry->get('status', $parent) == 'heading') ||
 167                      !$registry->get('webroot')) {
 168                      $url = null;
 169                  } else {
 170                      $url = Horde::url($registry->getInitialPage($parent));
 171                  }
 172              }
 173  
 174              $node_params = array('url' => $url,
 175                                   'icon' => $registry->get('icon', $parent),
 176                                   'icondir' => '');
 177              $menu_parent = $registry->get('menu_parent', $parent);
 178              $name = $registry->get('name', $parent);
 179              if ($unseen) {
 180                  $node_params['icon'] = 'newmail.png';
 181                  $node_params['icondir'] = $image_dir;
 182                  $name = sprintf('<strong>%s</strong> (%s)', $name, $unseen);
 183              }
 184              $tree->addNode($parent, $menu_parent, $name, $indent - 1, $imptree->isOpenSidebar($parent), $node_params);
 185          }
 186      }
 187  
 188  }


Généré le : Thu Nov 29 12:30:07 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics