[ 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/ -> summary.php (source)

   1  <?php
   2  
   3  $block_name = _("Folder Summary");
   4  
   5  /**
   6   * $Horde: imp/lib/Block/summary.php,v 1.54.2.10 2006/09/27 12:04:00 jan Exp $
   7   *
   8   * @package Horde_Block
   9   */
  10  class Horde_Block_imp_summary extends Horde_Block {
  11  
  12      var $_app = 'imp';
  13  
  14      function _title()
  15      {
  16          global $registry;
  17  
  18          require_once dirname(__FILE__) . '/../IMP.php';
  19  
  20          /* Start output buffering to make sure that any output, especially
  21           * script tags, are contained in the block content. */
  22          ob_start();
  23          $title = Horde::link(Horde::url($registry->getInitialPage(), true)) .
  24              $registry->get('name') . '</a> <small>' .
  25              Horde::link(IMP::composeLink()) .
  26              Horde::img('compose.png', _("New Message")) . ' ' .
  27              _("New Message") . '</a></small>';
  28          $title = ob_get_clean() . $title;
  29  
  30          return $title;
  31      }
  32  
  33      function _params()
  34      {
  35          return array('show_unread' => array('type' => 'boolean',
  36                                              'name' => _("Only display folders with unread messages in them?"),
  37                                              'default' => 0),
  38                       'show_total' => array('type' => 'boolean',
  39                                             'name' => _("Show total number of mails in folder?"),
  40                                             'default' => 0)
  41                       );
  42      }
  43  
  44      function _content()
  45      {
  46          global $notification, $prefs, $registry;
  47  
  48          $GLOBALS['authentication'] = 'none';
  49          require dirname(__FILE__) . '/../base.php';
  50  
  51          $html = '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
  52  
  53          $auth = false;
  54          if (IMP::checkAuthentication(OP_HALFOPEN, true)) {
  55              $auth = true;
  56  
  57              /* Get list of mailboxes to poll. */
  58              require_once  IMP_BASE . '/lib/IMAP/Tree.php';
  59              $imptree = &IMP_Tree::singleton();
  60              $folders = $imptree->getPollList();
  61  
  62              /* Filter on INBOX display, if requested. */
  63              if ($prefs->getValue('filter_on_display')) {
  64                  require_once  IMP_BASE . '/lib/Filter.php';
  65                  $imp_filter = &IMP_Filter::singleton();
  66                  $imp_filter->filter('INBOX');
  67              }
  68  
  69              /* Quota info, if available. */
  70              if (isset($_SESSION['imp']['quota']) &&
  71                  is_array($_SESSION['imp']['quota'])) {
  72                  require_once  IMP_BASE . '/lib/Quota.php';
  73                  $quotaDriver = &IMP_Quota::singleton($_SESSION['imp']['quota']['driver'], $_SESSION['imp']['quota']['params']);
  74                  if ($quotaDriver !== false) {
  75                      $quota = $quotaDriver->getQuota();
  76                      if (!is_a($quota, 'PEAR_Error') &&
  77                          isset($quota['usage']) &&
  78                          isset($quota['limit'])) {
  79                          if ($quota['limit'] != 0) {
  80                              $html .= '<tr><td colspan="4" align="center"';
  81                              $quota['usage'] = $quota['usage'] / (1024 * 1024.0);
  82                              $quota['limit'] = $quota['limit'] / (1024 * 1024.0);
  83                              $percent = ($quota['usage'] * 100) / $quota['limit'];
  84                              if ($percent >= 90) {
  85                                  $html .= ' style="color:red"';
  86                              }
  87                              $html .= '>' . sprintf(_("%.2fMB / %.2fMB  (%.2f%%)"), $quota['usage'], $quota['limit'], $percent);
  88                              $html .= '</td></tr>';
  89                          }
  90                      }
  91                  }
  92              }
  93  
  94              $newmsgs = array();
  95              $anyUnseen = false;
  96  
  97              foreach (array_keys($folders) as $folder) {
  98                  if (($folder == 'INBOX') ||
  99                      ($_SESSION['imp']['base_protocol'] != 'pop3')) {
 100                      $info = $imptree->getElementInfo($folder);
 101                      if (!empty($info)) {
 102                          if (empty($this->_params['show_unread']) ||
 103                              !empty($info['unseen'])) {
 104                              if (!empty($info['newmsg'])) {
 105                                  $newmsgs[$folder] = $info['newmsg'];
 106                              }
 107                              $url = Util::addParameter(Horde::applicationUrl('mailbox.php', true), 'no_newmail_popup', 1);
 108                              $url = Util::addParameter($url, 'mailbox', $folder);
 109                              $html .= '<tr style="cursor:pointer" class="text" onclick="self.location=\'' . $url . '\'"><td>';
 110                              if (!empty($info['unseen'])) {
 111                                  $html .= '<strong>';
 112                                  $anyUnseen = true;
 113                              }
 114                              $html .= Horde::link($url, IMP::displayFolder($folder)) . IMP::displayFolder($folder) . '</a>';
 115                              if (!empty($info['unseen'])) {
 116                                  $html .= '</strong>';
 117                              }
 118                              $html .= '</td><td>&nbsp;&nbsp;&nbsp;</td><td>';
 119                              $html .= !empty($info['unseen']) ? '<strong>' . $info['unseen'] . '</strong>' : '0';
 120                              $html .= !empty($this->_params['show_total']) ? '</td><td>(' . $info['messages'] . ')' : '';
 121                              $html .= '</td></tr>';
 122                          }
 123                      }
 124                  }
 125              }
 126          } else {
 127              $html .= '<tr><td class="text">' . Horde::link(Horde::applicationUrl('index.php', true), sprintf(_("Log in to %s"), $registry->applications['imp']['name'])) . sprintf(_("Log in to %s"), $registry->applications['imp']['name']) . '</a></td></tr>';
 128          }
 129  
 130          $html .= '</table>';
 131  
 132          /* Check to see if user wants new mail notification, but only
 133           * if the user is logged into IMP. */
 134          if ($auth && $prefs->getValue('nav_popup')) {
 135              $notification->push(IMP::getNewMessagePopup($newmsgs), 'javascript');
 136          }
 137          if ($auth &&
 138              class_exists('Notification_Listener_audio') &&
 139              $prefs->getValue('nav_audio')) {
 140              $found = false;
 141              foreach ($newmsgs as $mbox => $nm) {
 142                  if ($nm > 0) {
 143                      $found = true;
 144                      break;
 145                  }
 146              }
 147              if ($found) {
 148                  $notification->push($registry->getImageDir() .
 149                                      '/audio/theetone.wav', 'audio');
 150                  $html .= Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'audio'));
 151              }
 152          }
 153  
 154          if ($auth && (count($newmsgs) == 0 &&
 155                        !empty($this->_params['show_unread']))) {
 156              if (count($folders) == 0) {
 157                  $html .= _("No folders are being checked for new mail.");
 158              } else {
 159                  if (!$anyUnseen) {
 160                      $html .= '<em>' . _("No folders with unseen messages") . '</em>';
 161                  } else {
 162                      if ($prefs->getValue('nav_popup')) {
 163                          $html .= '<em>' . _("No folders with new messages") . '</em>';
 164                      }
 165                  }
 166              }
 167          }
 168  
 169          return $html;
 170      }
 171  
 172  }


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