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

   1  <?php
   2  /**
   3   * Maintenance module that deletes old linked attachments.
   4   *
   5   * $Horde: imp/lib/Maintenance/Task/delete_attachments_monthly.php,v 1.4.10.5 2005/10/18 12:13:36 jan Exp $
   6   *
   7   * See the enclosed file COPYING for license information (GPL). If you
   8   * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
   9   *
  10   * @author  Andrew Coleman <mercury@appisolutions.net>
  11   * @package Horde_Maintenance
  12   */
  13  class Maintenance_Task_delete_attachments_monthly extends Maintenance_Task {
  14  
  15      /**
  16       * Purges the old linked attachment folders.
  17       *
  18       * @return boolean  Whether any old attachments were deleted.
  19       */
  20      function doMaintenance()
  21      {
  22          global $conf, $prefs;
  23  
  24          require_once  IMP_BASE . '/lib/Compose.php';
  25          require_once 'Horde/Auth.php';
  26          require_once 'VFS.php';
  27  
  28          /* Find the UNIX timestamp of the last second that we will not
  29           * purge. */
  30          $del_time = gmmktime(0, 0, 0, date('n') - $prefs->getValue('delete_attachments_monthly_keep'), 1, date('Y'));
  31  
  32          $vfs = &VFS::singleton($conf['vfs']['type'], Horde::getDriverConfig('vfs', $conf['vfs']['type']));
  33          $path = IMP_VFS_LINK_ATTACH_PATH . '/' . Auth::getAuth();
  34  
  35          /* Make sure cleaning is done recursively. */
  36          $files = $vfs->listFolder($path, null, true, false, true);
  37          if (is_a($files, 'PEAR_Error') || !is_array($files)) {
  38              return false;
  39          }
  40  
  41          foreach ($files as $dir) {
  42              $filetime = (isset($dir['date'])) ? $dir['date'] : intval(basename($dir['name']));
  43              if ($del_time > $filetime) {
  44                  $vfs->deleteFolder($path, $dir['name'], true);
  45              }
  46          }
  47  
  48          return true;
  49      }
  50  
  51      /**
  52       * Returns information for the maintenance function.
  53       *
  54       * @return string  Description of what the operation is going to do during
  55       *                 this login.
  56       */
  57      function describeMaintenance()
  58      {
  59          return sprintf(_("All old linked attachments more than %s months old will be deleted."), $GLOBALS['prefs']->getValue('delete_attachments_monthly_keep'));
  60      }
  61  
  62  }


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