[ 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/Maintenance/Task/ -> delete_sentmail_monthly.php (source)

   1  <?php
   2  /**
   3   * Maintenance module that deletes old sent-mail folders.
   4   *
   5   * $Horde: imp/lib/Maintenance/Task/delete_sentmail_monthly.php,v 1.18.10.8 2007/01/02 13:55:01 jan Exp $
   6   *
   7   * Copyright 2001-2007 Michael Slusarz <slusarz@bigworm.colorado.edu>
   8   *
   9   * See the enclosed file COPYING for license information (GPL). If you
  10   * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  11   *
  12   * @author  Michael Slusarz <slusarz@bigworm.colorado.edu>
  13   * @since   IMP 2.3.7
  14   * @package Horde_Maintenance
  15   */
  16  class Maintenance_Task_delete_sentmail_monthly extends Maintenance_Task {
  17  
  18      /**
  19       * Purge the old sent-mail folders.
  20       *
  21       * @return boolean  Whether any sent-mail folders were deleted.
  22       */
  23      function doMaintenance()
  24      {
  25          global $imp, $notification, $prefs;
  26  
  27          /* Get list of all folders, parse through and get the list of all
  28             old sent-mail folders. Then sort this array according to
  29             the date. */
  30          include_once 'Horde/Identity.php';
  31          include_once  IMP_BASE . '/lib/Folder.php';
  32  
  33          $identity = &Identity::singleton(array('imp', 'imp'));
  34          $imp_folder = &IMP_Folder::singleton();
  35          $sent_mail_folders = $identity->getAllSentmailFolders();
  36  
  37          $folder_array = array();
  38          $old_folders = $imp_folder->flist();
  39  
  40          foreach (array_keys($old_folders) as $k) {
  41              foreach ($sent_mail_folders as $folder) {
  42                  if (preg_match('/^' . str_replace('/', '\/', $folder) . '-([^-]+)-([0-9]{4})$/i', $k, $regs)) {
  43                      $folder_array[$k] = (is_numeric($regs[1])) ? mktime(0, 0, 0,$regs[1], 1, $regs[2]) : strtotime("$regs[1] 1, $regs[2]");
  44                  }
  45              }
  46          }
  47          arsort($folder_array, SORT_NUMERIC);
  48  
  49          /* See if any folders need to be purged. */
  50          $purge_folders = array_slice(array_keys($folder_array), $prefs->getValue('delete_sentmail_monthly_keep'));
  51          if (count($purge_folders)) {
  52              $notification->push(_("Old sent-mail folders being purged."), 'horde.message');
  53  
  54              /* Delete the old folders now. */
  55              if ($imp_folder->delete($purge_folders, $prefs->getValue('subscribe'))) {
  56                  return true;
  57              }
  58          }
  59  
  60          return false;
  61      }
  62  
  63      /**
  64       * Return information for the maintenance function.
  65       *
  66       * @return string  Description of what the operation is going to do during
  67       *                 this login.
  68       */
  69      function describeMaintenance()
  70      {
  71          global $prefs;
  72  
  73          return sprintf(_("All old sent-mail folders more than %s months old will be deleted."), $prefs->getValue('delete_sentmail_monthly_keep'));
  74      }
  75  
  76  }


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