[ Index ] |
|
Code source de IMP H3 (4.1.5) |
1 <?php 2 /** 3 * $Horde: imp/lib/Maintenance/Task/purge_trash.php,v 1.23.10.10 2007/01/02 13:55:01 jan Exp $ 4 * 5 * Maintenance module that purges old messages in the Trash folder. 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_purge_trash extends Maintenance_Task { 17 18 /** 19 * Purge old messages in the Trash folder. 20 * 21 * @return boolean Whether any messages were purged from the Trash folder. 22 */ 23 function doMaintenance() 24 { 25 global $imp, $prefs, $notification; 26 27 /* If we aren't using a Trash folder or if there is no Trash 28 folder set, just return. */ 29 $trash_folder = IMP::folderPref($prefs->getValue('trash_folder'), true); 30 if (!$prefs->getValue('use_trash') || !$trash_folder) { 31 return false; 32 } 33 34 /* Make sure the Trash folder exists. */ 35 require_once IMP_BASE . '/lib/Folder.php'; 36 $imp_folder = &IMP_Folder::singleton(); 37 if (!$imp_folder->exists($trash_folder)) { 38 return false; 39 } 40 41 /* Get the current UNIX timestamp minus the number of days 42 specified in 'purge_trash_keep'. If a message has a 43 timestamp prior to this value, it will be deleted. */ 44 $del_time = date("r", time() - ($prefs->getValue('purge_trash_keep') * 86400)); 45 46 /* Open the Trash mailbox and get the list of messages older 47 than 'purge_trash_keep' days. */ 48 require_once IMP_BASE . '/lib/IMAP.php'; 49 require_once IMP_BASE . '/lib/Message.php'; 50 $imp_imap = &IMP_IMAP::singleton(); 51 $imp_message = &IMP_Message::singleton(); 52 $imp_imap->changeMbox($trash_folder); 53 $msg_ids = @imap_search($imp['stream'], "BEFORE \"$del_time\"", SE_UID); 54 if (empty($msg_ids)) { 55 return false; 56 } 57 58 /* Go through the message list and delete the messages. */ 59 $indices = array($trash_folder => $msg_ids); 60 if ($imp_message->delete($indices, true)) { 61 $msgcount = count($msg_ids); 62 if ($msgcount == 1) { 63 $notification->push(_("Purging 1 message from Trash folder."), 'horde.message'); 64 } else { 65 $notification->push(sprintf(_("Purging %d messages from Trash folder."), $msgcount), 'horde.message'); 66 } 67 } 68 69 return true; 70 } 71 72 /** 73 * Return information for the maintenance function. 74 * 75 * @return string Description of what the operation is going to do during 76 * this login. 77 */ 78 function describeMaintenance() 79 { 80 return sprintf(_("All messages in your \"%s\" folder older than %s days will be permanently deleted."), 81 IMP::displayFolder(IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true)), 82 $GLOBALS['prefs']->getValue('purge_trash_keep')); 83 } 84 85 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 12:30:07 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |