From 54299b2f49446855107193d4e6c0ffc2fd6813c6 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 24 Jun 2009 00:17:16 -0600 Subject: [PATCH] Convert from Maintenance:: -> Horde_LoginTasks::. --- imp/config/conf.xml | 8 --- imp/config/prefs.php.dist | 44 +++++++------- imp/docs/UPGRADING | 2 + .../Task/DeleteAttachmentsMonthly.php} | 24 ++++++-- .../Task/DeleteSentmailMonthly.php} | 31 ++++++---- .../Task/PurgeSentmail.php} | 40 ++++++++----- .../Task/PurgeSpam.php} | 38 +++++++----- .../Task/PurgeTrash.php} | 40 ++++++++----- .../Task/RenameSentmailMonthly.php} | 33 ++++++---- imp/lib/Maintenance/Task/fetchmail_login.php | 70 ---------------------- imp/lib/Maintenance/Task/tos_agreement.php | 50 ---------------- imp/lib/Maintenance/imp.php | 36 ----------- imp/lib/Session.php | 14 +---- imp/lib/base.php | 6 -- imp/lib/prefs.php | 18 ------ imp/redirect.php | 5 +- kronolith/config/prefs.php.dist | 32 +++++----- kronolith/docs/UPGRADING | 6 ++ .../Task/PurgeEvents.php} | 35 +++++++---- kronolith/lib/Maintenance/kronolith.php | 65 -------------------- kronolith/lib/base.php | 29 ++++----- kronolith/lib/prefs.php | 7 --- 22 files changed, 219 insertions(+), 414 deletions(-) rename imp/lib/{Maintenance/Task/delete_attachments_monthly.php => LoginTasks/Task/DeleteAttachmentsMonthly.php} (72%) rename imp/lib/{Maintenance/Task/delete_sentmail_monthly.php => LoginTasks/Task/DeleteSentmailMonthly.php} (72%) rename imp/lib/{Maintenance/Task/purge_sentmail.php => LoginTasks/Task/PurgeSentmail.php} (65%) rename imp/lib/{Maintenance/Task/purge_spam.php => LoginTasks/Task/PurgeSpam.php} (67%) rename imp/lib/{Maintenance/Task/purge_trash.php => LoginTasks/Task/PurgeTrash.php} (65%) rename imp/lib/{Maintenance/Task/rename_sentmail_monthly.php => LoginTasks/Task/RenameSentmailMonthly.php} (79%) delete mode 100644 imp/lib/Maintenance/Task/fetchmail_login.php delete mode 100644 imp/lib/Maintenance/Task/tos_agreement.php delete mode 100644 imp/lib/Maintenance/imp.php rename kronolith/lib/{Maintenance/Task/purge_events.php => LoginTasks/Task/PurgeEvents.php} (69%) delete mode 100644 kronolith/lib/Maintenance/kronolith.php diff --git a/imp/config/conf.xml b/imp/config/conf.xml index 2c1fecbe1..8a37f2bd8 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -447,14 +447,6 @@ load because the list of available note categories must be generated on every page load), you should disable this checkbox.">true - - - Terms of Service Agreement - - diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 1985b2521..18a93caf3 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -41,7 +41,8 @@ $prefGroups['logintasks'] = array( 'column' => _("General Options"), 'label' => _("Login Tasks"), 'desc' => sprintf(_("Customize tasks to run upon logon to %s."), $GLOBALS['registry']->get('name')), - 'members' => array() + 'members' => array('delete_attachments_monthly', + 'delete_attachments_monthly_keep') ); if (!$is_pop3) { $prefGroups['logintasks']['members'] = array_merge( @@ -53,9 +54,6 @@ if (!$is_pop3) { 'purge_trash_keep', 'purge_spam', 'purge_spam_interval', 'purge_spam_keep')); } -$prefGroups['logintasks']['members'] = array_merge( - $prefGroups['logintasks']['members'], - array('delete_attachments_monthly', 'delete_attachments_monthly_keep')); $prefGroups['compose'] = array( 'column' => _("Message Options"), @@ -380,7 +378,16 @@ $_prefs['acl'] = array( // End folder sharing preferences -// Login/Maintenance Tasks preferences +// Login Tasks preferences + +// Listing of Horde_LoginTasks constants -> strings +$logintasks_labels = array( + Horde_LoginTasks::YEARLY => _("Yearly"), + Horde_LoginTasks::MONTHLY => _("Monthly"), + Horde_LoginTasks::WEEKLY => _("Weekly"), + Horde_LoginTasks::DAILY => _("Daily"), + Horde_LoginTasks::EVERY => _("Every Login") +); // select widget for the initial_page preference $_prefs['initialpageselect'] = array('type' => 'special'); @@ -430,12 +437,12 @@ $_prefs['purge_sentmail'] = array( 'help' => 'prefs-purge_sentmail'); // how often to purge the Sent-Mail folder? -// 'value': yearly = 1, monthly = 2, weekly = 3, daily = 4, every login = 5 $_prefs['purge_sentmail_interval'] = array( - 'value' => '2', + 'value' => Horde_LoginTasks::MONTHLY, 'locked' => false, 'shared' => false, - 'type' => 'select', + 'type' => 'enum', + 'enum' => $logintasks_labels, 'desc' => _("Purge sent-mail how often:"), 'help' => 'prefs-purge_sentmail_interval'); @@ -476,12 +483,12 @@ $_prefs['purge_spam'] = array( 'help' => 'prefs-purge_spam'); // how often to purge the Spam folder? -// 'value': yearly = 1, monthly = 2, weekly = 3, daily = 4, every login = 5 $_prefs['purge_spam_interval'] = array( - 'value' => '2', + 'value' => Horde_LoginTasks::MONTHLY, 'locked' => false, 'shared' => false, - 'type' => 'select', + 'type' => 'enum', + 'enum' => $logintasks_labels, 'desc' => _("Purge Spam how often:"), 'help' => 'prefs-purge_spam_interval'); @@ -504,12 +511,12 @@ $_prefs['purge_trash'] = array( 'help' => 'prefs-purge_trash'); // how often to purge the Trash folder? -// 'value': yearly = 1, monthly = 2, weekly = 3, daily = 4, every login = 5 $_prefs['purge_trash_interval'] = array( - 'value' => '2', + 'value' => Horde_LoginTasks::MONTHLY, 'locked' => false, 'shared' => false, - 'type' => 'select', + 'type' => 'enum', + 'enum' => $logintasks_labels, 'desc' => _("Purge Trash how often:"), 'help' => 'prefs-purge_trash_interval'); @@ -522,14 +529,7 @@ $_prefs['purge_trash_keep'] = array( 'desc' => _("Purge messages in Trash folder older than this amount of days."), 'help' => 'prefs-purge_trash_keep'); -// show tos agreement? -$_prefs['tos_agreement'] = array( - 'value' => 0, - 'locked' => false, - 'shared' => false, - 'type' => 'implicit'); - -// End Login/Maintenance preferences +// End Login Tasks preferences // Message Composition preferences diff --git a/imp/docs/UPGRADING b/imp/docs/UPGRADING index 7256c33c8..cfdca24a0 100644 --- a/imp/docs/UPGRADING +++ b/imp/docs/UPGRADING @@ -29,6 +29,8 @@ supported. * x-priority now handled in the core code * old attachment icon handling see atc_flag pref * imp_hook_msglist_flags hook now used to dynamically set flags on messages +* maintenance tasks +* tos_agreement (moved to Horde) diff --git a/imp/lib/Maintenance/Task/delete_attachments_monthly.php b/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php similarity index 72% rename from imp/lib/Maintenance/Task/delete_attachments_monthly.php rename to imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php index 81e0ec8f5..9352876a1 100644 --- a/imp/lib/Maintenance/Task/delete_attachments_monthly.php +++ b/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php @@ -1,21 +1,33 @@ - * @package Horde_Maintenance + * @package Horde_LoginTasks */ -class Maintenance_Task_delete_attachments_monthly extends Maintenance_Task +class IMP_LoginTasks_Task_DeleteAttachmentsMonthly extends Horde_LoginTasks_Task { /** + * Constructor. + */ + public function __construct() + { + $this->active = $GLOBALS['prefs']->getValue('delete_attachments_monthly'); + if ($this->active && + $GLOBALS['prefs']->isLocked('delete_attachments_monthly')) { + $this->display = Horde_LoginTasks::DISPLAY_NONE; + } + } + + /** * Purges the old linked attachment folders. * * @return boolean Whether any old attachments were deleted. */ - public function doMaintenance() + public function execute() { /* Find the UNIX timestamp of the last second that we will not * purge. */ @@ -41,12 +53,12 @@ class Maintenance_Task_delete_attachments_monthly extends Maintenance_Task } /** - * Returns information for the maintenance function. + * Returns information for the login task. * * @return string Description of what the operation is going to do during * this login. */ - public function describeMaintenance() + public function describe() { return sprintf(_("All old linked attachments more than %s months old will be deleted."), $GLOBALS['prefs']->getValue('delete_attachments_monthly_keep')); } diff --git a/imp/lib/Maintenance/Task/delete_sentmail_monthly.php b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php similarity index 72% rename from imp/lib/Maintenance/Task/delete_sentmail_monthly.php rename to imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php index 0b8846a91..6e1b4406c 100644 --- a/imp/lib/Maintenance/Task/delete_sentmail_monthly.php +++ b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php @@ -1,6 +1,6 @@ - * @package Horde_Maintenance + * @package Horde_LoginTasks */ -class Maintenance_Task_delete_sentmail_monthly extends Maintenance_Task +class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task { /** + * Constructor. + */ + public function __construct() + { + $this->active = $GLOBALS['prefs']->getValue('delete_sentmail_monthly'); + if ($this->active && + $GLOBALS['prefs']->isLocked('delete_sentmail_monthly')) { + $this->display = Horde_LoginTasks::DISPLAY_NONE; + } + } + + /** * Purge the old sent-mail folders. * * @return boolean Whether any sent-mail folders were deleted. */ - function doMaintenance() + public function execute() { - global $notification, $prefs; - /* Get list of all folders, parse through and get the list of all old sent-mail folders. Then sort this array according to the date. */ include_once 'Horde/Identity.php'; - $identity = &Identity::singleton(array('imp', 'imp')); $imp_folder = &IMP_Folder::singleton(); $sent_mail_folders = $identity->getAllSentmailFolders(); @@ -43,9 +52,9 @@ class Maintenance_Task_delete_sentmail_monthly extends Maintenance_Task arsort($folder_array, SORT_NUMERIC); /* See if any folders need to be purged. */ - $purge_folders = array_slice(array_keys($folder_array), $prefs->getValue('delete_sentmail_monthly_keep')); + $purge_folders = array_slice(array_keys($folder_array), $GLOBALS['prefs']->getValue('delete_sentmail_monthly_keep')); if (count($purge_folders)) { - $notification->push(_("Old sent-mail folders being purged."), 'horde.message'); + $GLOBALS['notification']->push(_("Old sent-mail folders being purged."), 'horde.message'); /* Delete the old folders now. */ if ($imp_folder->delete($purge_folders, true)) { @@ -57,12 +66,12 @@ class Maintenance_Task_delete_sentmail_monthly extends Maintenance_Task } /** - * Return information for the maintenance function. + * Return information for the login task. * * @return string Description of what the operation is going to do during * this login. */ - function describeMaintenance() + public function describe() { return sprintf(_("All old sent-mail folders more than %s months old will be deleted."), $GLOBALS['prefs']->getValue('delete_sentmail_monthly_keep')); } diff --git a/imp/lib/Maintenance/Task/purge_sentmail.php b/imp/lib/LoginTasks/Task/PurgeSentmail.php similarity index 65% rename from imp/lib/Maintenance/Task/purge_sentmail.php rename to imp/lib/LoginTasks/Task/PurgeSentmail.php index e4c3ad66e..335560ed8 100644 --- a/imp/lib/Maintenance/Task/purge_sentmail.php +++ b/imp/lib/LoginTasks/Task/PurgeSentmail.php @@ -1,6 +1,6 @@ * @author Jan Schneider - * @package Horde_Maintenance + * @package Horde_LoginTasks */ -class Maintenance_Task_purge_sentmail extends Maintenance_Task +class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task { /** + * Constructor. + */ + public function __construct() + { + $this->active = $GLOBALS['prefs']->getValue('purge_sentmail'); + if ($this->active) { + $this->interval = $GLOBALS['prefs']->getValue('purge_sentmail_interval'); + if ($GLOBALS['prefs']->isLocked('purge_sentmail')) { + $this->display = Horde_LoginTasks::DISPLAY_NONE; + } + } + } + + /** * Purge old messages in the sent-mail folder. * * @return boolean Whether any messages were purged from the sent-mail * folder. */ - function doMaintenance() + public function execute() { - global $prefs, $notification; - $imp_folder = IMP_Folder::singleton(); $imp_message = IMP_Message::singleton(); - $mbox_list = Maintenance_Task_purge_sentmail::_getFolders(); + $mbox_list = $this->_getFolders(); /* Get the current UNIX timestamp minus the number of days specified * in 'purge_sentmail_keep'. If a message has a timestamp prior to * this value, it will be deleted. */ - $del_time = new Horde_Date(time() - ($prefs->getValue('purge_sentmail_keep') * 86400)); + $del_time = new Horde_Date(time() - ($GLOBALS['prefs']->getValue('purge_sentmail_keep') * 86400)); foreach ($mbox_list as $mbox) { /* Make sure the sent-mail mailbox exists. */ @@ -52,9 +64,9 @@ class Maintenance_Task_purge_sentmail extends Maintenance_Task if ($imp_message->delete(array($mbox => $msg_ids), array('nuke' => true))) { $msgcount = count($msg_ids); if ($msgcount == 1) { - $notification->push(sprintf(_("Purging 1 message from sent-mail folder %s."), IMP::displayFolder($mbox)), 'horde.message'); + $GLOBALS['notification']->push(sprintf(_("Purging 1 message from sent-mail folder %s."), IMP::displayFolder($mbox)), 'horde.message'); } else { - $notification->push(sprintf(_("Purging %d messages from sent-mail folder."), $msgcount, IMP::displayFolder($mbox)), 'horde.message'); + $GLOBALS['notification']->push(sprintf(_("Purging %d messages from sent-mail folder."), $msgcount, IMP::displayFolder($mbox)), 'horde.message'); } } } @@ -63,14 +75,14 @@ class Maintenance_Task_purge_sentmail extends Maintenance_Task } /** - * Return information for the maintenance function. + * Return information for the login task. * * @return string Description of what the operation is going to do during * this login. */ - function describeMaintenance() + public function describe() { - $mbox_list = array_map(array('IMP', 'displayFolder'), Maintenance_Task_purge_sentmail::_getFolders()); + $mbox_list = array_map(array('IMP', 'displayFolder'), $this->_getFolders()); return sprintf(_("All messages in the folder(s) \"%s\" older than %s days will be permanently deleted."), implode(', ', $mbox_list), @@ -82,7 +94,7 @@ class Maintenance_Task_purge_sentmail extends Maintenance_Task * * @return array All sent-mail folders. */ - function _getFolders() + protected function _getFolders() { require_once 'Horde/Identity.php'; return Identity::singleton(array('imp', 'imp'))->getAllSentmailfolders(); diff --git a/imp/lib/Maintenance/Task/purge_spam.php b/imp/lib/LoginTasks/Task/PurgeSpam.php similarity index 67% rename from imp/lib/Maintenance/Task/purge_spam.php rename to imp/lib/LoginTasks/Task/PurgeSpam.php index cced3fdb8..244ff3235 100644 --- a/imp/lib/Maintenance/Task/purge_spam.php +++ b/imp/lib/LoginTasks/Task/PurgeSpam.php @@ -1,6 +1,6 @@ . * * Copyright 2006-2009 The Horde Project (http://www.horde.org/) @@ -9,21 +9,33 @@ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * * @author Matt Selsky - * @package Horde_Maintenance + * @package Horde_LoginTasks */ -class Maintenance_Task_purge_spam extends Maintenance_Task +class IMP_LoginTasks_Task_PurgeSpam extends Horde_LoginTasks_Task { /** + * Constructor. + */ + public function __construct() + { + $this->active = $GLOBALS['prefs']->getValue('purge_spam'); + if ($this->active) { + $this->interval = $GLOBALS['prefs']->getValue('purge_spam_interval'); + if ($GLOBALS['prefs']->isLocked('purge_spam')) { + $this->display = Horde_LoginTasks::DISPLAY_NONE; + } + } + } + + /** * Purge old messages in the Spam folder. * * @return boolean Whether any messages were purged from the Spam folder. */ - function doMaintenance() + public function execute() { - global $prefs, $notification; - /* If there is no Spam folder set, just return. */ - $spam_folder = IMP::folderPref($prefs->getValue('spam_folder'), true); + $spam_folder = IMP::folderPref($GLOBALS['prefs']->getValue('spam_folder'), true); if (!$spam_folder) { return false; } @@ -37,7 +49,7 @@ class Maintenance_Task_purge_spam extends Maintenance_Task /* Get the current UNIX timestamp minus the number of days specified in 'purge_spam_keep'. If a message has a timestamp prior to this value, it will be deleted. */ - $del_time = new Horde_Date(time() - ($prefs->getValue('purge_spam_keep') * 86400)); + $del_time = new Horde_Date(time() - ($GLOBALS['prefs']->getValue('purge_spam_keep') * 86400)); /* Get the list of messages older than 'purge_spam_keep' days. */ $query = new Horde_Imap_Client_Search_Query(); @@ -51,23 +63,19 @@ class Maintenance_Task_purge_spam extends Maintenance_Task $imp_message = IMP_Message::singleton(); if ($imp_message->delete(array($spam_folder => $msg_ids), array('nuke' => true))) { $msgcount = count($msg_ids); - if ($msgcount == 1) { - $notification->push(_("Purging 1 message from Spam folder."), 'horde.message'); - } else { - $notification->push(sprintf(_("Purging %d messages from Spam folder."), $msgcount), 'horde.message'); - } + $notification->push(sprintf(ngettext("Purging %d message from Spam folder.", "Purging %d messages from Spam folder.", $msgcount), $msgcount), 'horde.message'); } return true; } /** - * Return information for the maintenance function. + * Return information for the login task. * * @return string Description of what the operation is going to do during * this login. */ - function describeMaintenance() + public function describe() { return sprintf(_("All messages in your \"%s\" folder older than %s days will be permanently deleted."), IMP::displayFolder(IMP::folderPref($GLOBALS['prefs']->getValue('spam_folder'), true)), diff --git a/imp/lib/Maintenance/Task/purge_trash.php b/imp/lib/LoginTasks/Task/PurgeTrash.php similarity index 65% rename from imp/lib/Maintenance/Task/purge_trash.php rename to imp/lib/LoginTasks/Task/PurgeTrash.php index 205c6f19e..6fad9477a 100644 --- a/imp/lib/Maintenance/Task/purge_trash.php +++ b/imp/lib/LoginTasks/Task/PurgeTrash.php @@ -1,6 +1,6 @@ - * @package Horde_Maintenance + * @package Horde_LoginTasks */ -class Maintenance_Task_purge_trash extends Maintenance_Task +class IMP_LoginTasks_Task_PurgeTrash extends Horde_LoginTasks_Task { /** + * Constructor. + */ + public function __construct() + { + $this->active = $GLOBALS['prefs']->getValue('purge_trash'); + if ($this->active) { + $this->interval = $GLOBALS['prefs']->getValue('purge_trash_interval'); + if ($GLOBALS['prefs']->isLocked('purge_trash')) { + $this->display = Horde_LoginTasks::DISPLAY_NONE; + } + } + } + + /** * Purge old messages in the Trash folder. * * @return boolean Whether any messages were purged from the Trash folder. */ - function doMaintenance() + public function execute() { - global $prefs, $notification; - /* If we aren't using a Trash folder or if there is no Trash folder set, just return. */ - $trash_folder = IMP::folderPref($prefs->getValue('trash_folder'), true); - if (!$prefs->getValue('use_trash') || !$trash_folder) { + $trash_folder = IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true); + if (!$GLOBALS['prefs']->getValue('use_trash') || !$trash_folder) { return false; } @@ -37,7 +49,7 @@ class Maintenance_Task_purge_trash extends Maintenance_Task /* Get the current UNIX timestamp minus the number of days specified in 'purge_trash_keep'. If a message has a timestamp prior to this value, it will be deleted. */ - $del_time = new Horde_Date(time() - ($prefs->getValue('purge_trash_keep') * 86400)); + $del_time = new Horde_Date(time() - ($GLOBALS['prefs']->getValue('purge_trash_keep') * 86400)); /* Get the list of messages older than 'purge_trash_keep' days. */ $query = new Horde_Imap_Client_Search_Query(); @@ -51,23 +63,19 @@ class Maintenance_Task_purge_trash extends Maintenance_Task $imp_message = IMP_Message::singleton(); if ($imp_message->delete(array($trash_folder => $msg_ids), array('nuke' => true))) { $msgcount = count($msg_ids); - if ($msgcount == 1) { - $notification->push(_("Purging 1 message from Trash folder."), 'horde.message'); - } else { - $notification->push(sprintf(_("Purging %d messages from Trash folder."), $msgcount), 'horde.message'); - } + $notification->push(sprintf(ngettext("Purging %d message from Trash folder.", "Purging %d messages from Trash folder.", $msgcount), $msgcount), 'horde.message'); } return true; } /** - * Return information for the maintenance function. + * Return information for the login task. * * @return string Description of what the operation is going to do during * this login. */ - function describeMaintenance() + public function describe() { return sprintf(_("All messages in your \"%s\" folder older than %s days will be permanently deleted."), IMP::displayFolder(IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true)), diff --git a/imp/lib/Maintenance/Task/rename_sentmail_monthly.php b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php similarity index 79% rename from imp/lib/Maintenance/Task/rename_sentmail_monthly.php rename to imp/lib/LoginTasks/Task/RenameSentmailMonthly.php index 8f8c07ce5..a84cbd13a 100644 --- a/imp/lib/Maintenance/Task/rename_sentmail_monthly.php +++ b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php @@ -1,6 +1,6 @@ - * @package Horde_Maintenance + * @package Horde_LoginTasks */ -class Maintenance_Task_rename_sentmail_monthly extends Maintenance_Task +class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task { /** + * Constructor. + */ + public function __construct() + { + $this->active = $GLOBALS['prefs']->getValue('rename_sentmail_monthly'); + if ($this->active && + $GLOBALS['prefs']->isLocked('rename_sentmail_monthly')) { + $this->display = Horde_LoginTasks::DISPLAY_NONE; + } + } + + /** * Renames the old sent-mail folders. * * @return boolean Whether all sent-mail folders were renamed. */ - function doMaintenance() + public function execute() { $success = true; @@ -30,7 +42,7 @@ class Maintenance_Task_rename_sentmail_monthly extends Maintenance_Task /* Display a message to the user and rename the folder. Only do this if sent-mail folder currently exists. */ if ($imp_folder->exists($sent_folder)) { - $old_folder = Maintenance_Task_rename_sentmail_monthly::_renameSentmailMonthlyName($sent_folder); + $old_folder = $this->_renameSentmailMonthlyName($sent_folder); $GLOBALS['notification']->push(sprintf(_("%s folder being renamed at the start of the month."), IMP::displayFolder($sent_folder)), 'horde.message'); if ($imp_folder->exists($old_folder)) { $GLOBALS['notification']->push(sprintf(_("%s already exists. Your %s folder was not renamed."), IMP::displayFolder($old_folder), IMP::displayFolder($sent_folder)), 'horde.warning'); @@ -47,12 +59,12 @@ class Maintenance_Task_rename_sentmail_monthly extends Maintenance_Task } /** - * Returns information for the maintenance function. + * Returns information for the login task. * * @return string Description of what the operation is going to do during * this login. */ - function describeMaintenance() + public function describe() { include_once 'Horde/Identity.php'; $identity = &Identity::singleton(array('imp', 'imp')); @@ -60,7 +72,7 @@ class Maintenance_Task_rename_sentmail_monthly extends Maintenance_Task $new_folders = $old_folders = array(); foreach ($identity->getAllSentmailfolders() as $folder) { $old_folders[] = IMP::displayFolder($folder); - $new_folders[] = IMP::displayFolder(Maintenance_Task_rename_sentmail_monthly::_renameSentmailMonthlyName($folder)); + $new_folders[] = IMP::displayFolder($this->_renameSentmailMonthlyName($folder)); } return sprintf(_("The current folder(s) \"%s\" will be renamed to \"%s\"."), implode(', ', $old_folders), implode(', ', $new_folders)); @@ -78,14 +90,13 @@ class Maintenance_Task_rename_sentmail_monthly extends Maintenance_Task * can accurately find all the old sent-mail folders. * * - * @access private - * * @param string $folder The name of the sent-mail folder to rename. * * @return string New sent-mail folder name. */ - function _renameSentmailMonthlyName($folder) + protected function _renameSentmailMonthlyName($folder) { + // @TODO $last_maintenance = $GLOBALS['prefs']->getValue('last_maintenance'); $last_maintenance = empty($last_maintenance) ? mktime(0, 0, 0, date('m') - 1, 1) : $last_maintenance; diff --git a/imp/lib/Maintenance/Task/fetchmail_login.php b/imp/lib/Maintenance/Task/fetchmail_login.php deleted file mode 100644 index 4b56ef39d..000000000 --- a/imp/lib/Maintenance/Task/fetchmail_login.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @author Michael Slusarz - * @package Horde_Maintenance - */ -class Maintenance_Task_fetchmail_login extends Maintenance_Task -{ - /** - * The style of the maintenance page output. - * - * @var integer - */ - var $_display_type = MAINTENANCE_OUTPUT_CONFIRM; - - /** - * Fetch email from other accounts. - */ - function doMaintenance() - { - $fm_account = new IMP_Fetchmail_Account(); - - /* If the user wants to fetch emails from other accounts on login, - * go get those messages now. */ - if ($fm_account->count()) { - $fm_list = array(); - - foreach ($fm_account->getAll('loginfetch') as $id => $val) { - if ($val) { - $fm_list[] = $id; - } - } - - if (!empty($fm_list)) { - IMP_Fetchmail::fetchmail($fm_list); - } - } - } - - /** - * Returns the summary of the accounts to fetch email from. - * - * @return string The summary of the accounts to fetch email from. - */ - function describeMaintenance() - { - $str = _("You are about to fetch email from the following account(s):") . "\n
\n"; - - $fm_account = new IMP_Fetchmail_Account(); - if ($fm_account->count()) { - foreach ($fm_account->getAll('loginfetch') as $id => $val) { - if ($val) { - $str .= " - " . $fm_account->getValue('id', $id) . "
\n"; - } - } - } - - $str .= "\n
\n" . _("Note that this can take some time") . ".\n"; - - return $str; - } - -} diff --git a/imp/lib/Maintenance/Task/tos_agreement.php b/imp/lib/Maintenance/Task/tos_agreement.php deleted file mode 100644 index 44f1a589b..000000000 --- a/imp/lib/Maintenance/Task/tos_agreement.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @package Horde_Maintenance - */ -class Maintenance_Task_tos_agreement extends Maintenance_Task -{ - /** - * The style of the maintenance page output. - * - * @var integer - */ - var $_display_type = MAINTENANCE_OUTPUT_AGREE; - - /** - * Determine if user agreed with the terms or not. If the user does not - * agree, log him/her out immediately. - */ - function doMaintenance() - { - $result = Horde_Util::getFormData('not_agree'); - if (isset($result)) { - header('Location: ' . IMP::getLogoutUrl(array(AUTH_REASON_MESSAGE => _("You did not agree to the Terms of Service agreement, so you were not allowed to login.")), true)); - exit; - } - } - - /** - * Returns the TOS agreement for display on the maintenance page. - * - * @return string The terms of service agreement. - */ - function describeMaintenance() - { - if (empty($GLOBALS['conf']['tos']['file'])) { - Horde::fatal(new Horde_Exception(sprintf(_("Terms of Service file not specified in conf.php"))), __FILE__, __LINE__); - } - - return file_get_contents($GLOBALS['conf']['tos']['file']); - } - -} diff --git a/imp/lib/Maintenance/imp.php b/imp/lib/Maintenance/imp.php deleted file mode 100644 index b876b4a26..000000000 --- a/imp/lib/Maintenance/imp.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @package Horde_Maintenance - */ -class Maintenance_IMP extends Maintenance { - - /** - * Hash holding maintenance preference names. - * - * @var array - */ - var $maint_tasks = array( - 'tos_agreement' => MAINTENANCE_FIRST_LOGIN, - 'fetchmail_login' => MAINTENANCE_EVERY, - 'rename_sentmail_monthly' => MAINTENANCE_MONTHLY, - 'delete_sentmail_monthly' => MAINTENANCE_MONTHLY, - 'delete_attachments_monthly' => MAINTENANCE_MONTHLY, - 'purge_sentmail' => MAINTENANCE_MONTHLY, - 'purge_spam' => MAINTENANCE_MONTHLY, - 'purge_trash' => MAINTENANCE_MONTHLY - ); - -} diff --git a/imp/lib/Session.php b/imp/lib/Session.php index d6f06aed2..35f6de518 100644 --- a/imp/lib/Session.php +++ b/imp/lib/Session.php @@ -202,16 +202,9 @@ class IMP_Session IMP::loginTasksFlag(2); IMP::checkAuthentication(true); - /* Do maintenance operations. */ - if ($GLOBALS['prefs']->getValue('do_maintenance')) { - require_once 'Horde/Maintenance.php'; - $maint = &Maintenance::factory('imp', array('last_maintenance' => $GLOBALS['prefs']->getValue('last_maintenance'))); - if (!$maint) { - $GLOBALS['notification']->push(_("Could not execute maintenance operations."), 'horde.warning'); - } else { - $maint->runMaintenance(); - } - } + /* Do login tasks. */ + $tasks = &Horde_LoginTasks::singleton('imp', Horde_Util::addParameter(Horde::selfUrl(true, true, true), array('logintasks_done' => true))); + $tasks->runTasks(); /* If the user wants to run filters on login, make sure they get run. */ @@ -221,7 +214,6 @@ class IMP_Session $imp_filter->filter('INBOX'); } - /* Check for drafts due to session timeouts. */ $imp_compose = &IMP_Compose::singleton(); $imp_compose->recoverSessionExpireDraft(); diff --git a/imp/lib/base.php b/imp/lib/base.php index 7dcb6403b..ac925d658 100644 --- a/imp/lib/base.php +++ b/imp/lib/base.php @@ -176,12 +176,6 @@ if (($viewmode == 'mimp') || $notification->attach('audio'); } -if ((IMP::loginTasksFlag() === 2) && - !defined('AUTH_HANDLER') && - !strstr($_SERVER['PHP_SELF'], 'maintenance.php')) { - IMP_Session::loginTasks(); -} - // Initialize global $imp_mbox array. $GLOBALS['imp_mbox'] = IMP::getCurrentMailboxInfo(); diff --git a/imp/lib/prefs.php b/imp/lib/prefs.php index 021f19f5d..74a2644bf 100644 --- a/imp/lib/prefs.php +++ b/imp/lib/prefs.php @@ -228,18 +228,6 @@ function prefs_callback() $imaptree->init(); } - /* If a maintenance option has been activated, we need to make sure the - * global Horde 'do_maintenance' pref is also active. */ - if (!$prefs->isLocked('do_maintenance') && - !$prefs->getValue('do_maintenance')) { - foreach (array('rename_sentmail_monthly', 'delete_sentmail_monthly', 'purge_sentmail', 'delete_attachments_monthly', 'purge_trash') as $val) { - if ($prefs->getValue($val)) { - $prefs->setValue('do_maintenance', true); - break; - } - } - } - if ($prefs->isDirty('mail_domain')) { $maildomain = preg_replace('/[^-\.a-z0-9]/i', '', $prefs->getValue('mail_domain')); $prefs->setValue('maildomain', $maildomain); @@ -253,12 +241,6 @@ function prefs_callback() } } -require_once IMP_BASE . '/lib/Maintenance/imp.php'; -$maint = &new Maintenance_IMP(); -foreach (($maint->exportIntervalPrefs()) as $val) { - $$val = &$intervals; -} - /* Make sure we have an active IMAP stream. */ if (!$GLOBALS['registry']->call('mail/server')) { header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('redirect.php'), 'url', Horde::selfUrl(true))); diff --git a/imp/redirect.php b/imp/redirect.php index 06873f0c8..0ea30e396 100644 --- a/imp/redirect.php +++ b/imp/redirect.php @@ -80,7 +80,6 @@ function _addAnchor($url, $type) @define('AUTH_HANDLER', true); $authentication = 'none'; require_once dirname(__FILE__) . '/lib/base.php'; -require_once 'Horde/Maintenance.php'; $actionID = (Horde_Util::getFormData('action') == 'compose') ? 'login_compose' : Horde_Util::getFormData('actionID'); $autologin = Horde_Util::getFormData('autologin'); @@ -101,8 +100,8 @@ if (($pos = strrpos($url_in, '#')) !== false) { $url_in = substr($url_in, 0, $pos); } -/* If we are returning from Maintenance processing. */ -if (Horde_Util::getFormData(MAINTENANCE_DONE_PARAM)) { +/* If we are returning from LoginTasks processing. */ +if (Horde_Util::getFormData('logintasks_done')) { /* Finish up any login tasks we haven't completed yet. */ IMP_Session::loginTasks(); diff --git a/kronolith/config/prefs.php.dist b/kronolith/config/prefs.php.dist index 5e31eb975..f5653609a 100644 --- a/kronolith/config/prefs.php.dist +++ b/kronolith/config/prefs.php.dist @@ -39,10 +39,11 @@ $prefGroups['event_options'] = array( 'desc' => _("Set default values for new events."), 'members' => array('default_alarm_management'), ); -$prefGroups['maintenance'] = array( + +$prefGroups['logintasks'] = array( 'column' => _("Events"), - 'label' => _("Maintenance"), - 'desc' => _("Set options for deleting old events."), + 'label' => _("Login Tasks"), + 'desc' => sprintf(_("Customize tasks to run upon logon to %s."), $GLOBALS['registry']->get('name')), 'members' => array('purge_events', 'purge_events_interval', 'purge_events_keep') ); @@ -404,20 +405,28 @@ $_prefs['fb_cals'] = array( // Free/Busy calendars selector. $_prefs['fb_cals_select'] = array('type' => 'special'); + +// Login Tasks preferences + $_prefs['purge_events'] = array( 'value' => 0, 'locked' => false, 'shared' => false, 'type' => 'checkbox', - 'desc' => _("Purge old events from your calender?"), + 'desc' => _("Purge old events from your calendar?"), ); -// 'value': yearly = 1, monthly = 2, weekly = 3, daily = 4, every login = 5 $_prefs['purge_events_interval'] = array( - 'value' => '2', + 'value' => Horde_LoginTasks::MONTHLY, 'locked' => false, 'shared' => false, - 'type' => 'select', + 'type' => 'enum', + 'enum' => array( + Horde_LoginTasks::YEARLY => _("Yearly"), + Horde_LoginTasks::MONTHLY => _("Monthly"), + Horde_LoginTasks::WEEKLY => _("Weekly"), + Horde_LoginTasks::DAILY => _("Daily"), + Horde_LoginTasks::EVERY => _("Every Login")), 'desc' => _("Purge old events how often:"), ); @@ -429,11 +438,4 @@ $_prefs['purge_events_keep'] = array( 'desc' => _("Purge old events older than this amount of days."), ); -// last time maintenance was run. -// value is a UNIX timestamp of the last time maintenance ran for the user. -$_prefs['last_kronolith_maintenance'] = array( - 'value' => 0, - 'locked' => false, - 'shared' => false, - 'type' => 'implicit' -); +// End Login Tasks preferences diff --git a/kronolith/docs/UPGRADING b/kronolith/docs/UPGRADING index 0612cf8b6..4098843d3 100644 --- a/kronolith/docs/UPGRADING +++ b/kronolith/docs/UPGRADING @@ -12,6 +12,12 @@ backup your existing data before running any of the steps described below. You can't use the updated data with your old Kronolith version anymore. +Upgrading Kronolith from 2.3 to 3.x +===================================== + +* Removed prefs: last_kronolith_maintenance + + Upgrading Kronolith from 2.3 to 2.3.x ===================================== diff --git a/kronolith/lib/Maintenance/Task/purge_events.php b/kronolith/lib/LoginTasks/Task/PurgeEvents.php similarity index 69% rename from kronolith/lib/Maintenance/Task/purge_events.php rename to kronolith/lib/LoginTasks/Task/PurgeEvents.php index c37fc4954..1b5420277 100644 --- a/kronolith/lib/Maintenance/Task/purge_events.php +++ b/kronolith/lib/LoginTasks/Task/PurgeEvents.php @@ -1,8 +1,6 @@ - * @package Horde_Maintenance + * @package Horde_LoginTasks */ -class Maintenance_Task_purge_events extends Maintenance_Task { +class Kronolith_LoginTasks_Task_PurgeEvents extends Horde_LoginTasks_Task +{ + /** + * Constructor. + */ + public function __construct() + { + $this->active = $GLOBALS['prefs']->getValue('purge_events'); + if ($this->active) { + $this->interval = $GLOBALS['prefs']->getValue('purge_events_interval'); + if ($GLOBALS['prefs']->isLocked('purge_events')) { + $this->display = Horde_LoginTasks::DISPLAY_NONE; + } + } + } /** * Purge old messages in the Trash folder. * * @return boolean Whether any messages were purged from the Trash folder. */ - function doMaintenance() + public function execute() { - global $prefs, $notification; - /* Get the current time minus the number of days specified in * 'purge_events_keep'. An event will be deleted if it has an end * time prior to this time. */ $del_time = new Horde_Date($_SERVER['REQUEST_TIME']); - $del_time->mday -= $prefs->getValue('purge_events_keep'); + $del_time->mday -= $GLOBALS['prefs']->getValue('purge_events_keep'); /* Need to have PERMS_DELETE on a calendar to delete events from it */ $calendars = Kronolith::listCalendars(false, PERMS_DELETE); @@ -57,18 +67,19 @@ class Maintenance_Task_purge_events extends Maintenance_Task { } } } - $notification->push(sprintf(ngettext("Deleted %d event older than %d days.", "Deleted %d events older than %d days.", $count), $count, $prefs->getValue('purge_events_keep'))); + + $GLOBALS['notification']->push(sprintf(ngettext("Deleted %d event older than %d days.", "Deleted %d events older than %d days.", $count), $count, $GLOBALS['prefs']->getValue('purge_events_keep'))); return true; } /** - * Return information for the maintenance function. + * Return information for the login task. * * @return string Description of what the operation is going to do during * this login. */ - function describeMaintenance() + public function describe() { return sprintf(_("All of your events older than %d days will be permanently deleted."), $GLOBALS['prefs']->getValue('purge_events_keep')); diff --git a/kronolith/lib/Maintenance/kronolith.php b/kronolith/lib/Maintenance/kronolith.php deleted file mode 100644 index 1c6d4aeb4..000000000 --- a/kronolith/lib/Maintenance/kronolith.php +++ /dev/null @@ -1,65 +0,0 @@ -get('fileroot', 'kronolith') . '/lib/base.php'; - -/** - * The Maintenance_Kronolith class defines the maintenance operations run upon - * login to Kronolith - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (GPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. - * - * @package Horde_Maintenance - */ -class Maintenance_Kronolith extends Maintenance { - - /** - * Hash holding maintenance preference names. - * - * @var array - */ - var $maint_tasks = array( - 'purge_events' => MAINTENANCE_MONTHLY - ); - - /** - * Execute all confirmed tasks. - * - * FIXME: This has to be overridden here since the parent's method will - * set the global last_maintenance pref...and mess up IMP's maintenance. - * This needs to be fixed for Horde 4. - * - * @access private - */ - function _doMaintenanceTasks() - { - $tasks = $this->_tasklist->getList(); - - foreach ($tasks as $key => $val) { - if ($val['newpage']) { - if ($this->_tasklist->processed()) { - $this->_tasklist->setNewPage($key, false); - } - break; - } elseif ($val['confirmed'] || - Horde_Util::getFormData($key . '_confirm')) { - /* Perform maintenance if confirmed. */ - $mod = &$this->_loadModule($key); - $mod->doMaintenance(); - } - $this->_tasklist->removeTask($key); - } - - /* If we've successfully completed every task in the list (or skipped - * it), record now as the last time maintenance was run. */ - if (!count($this->_tasklist->getList())) { - $GLOBALS['prefs']->setValue('last_kronolith_maintenance', time()); - } - } - - - -} diff --git a/kronolith/lib/base.php b/kronolith/lib/base.php index d8fb3865c..ca3348bef 100644 --- a/kronolith/lib/base.php +++ b/kronolith/lib/base.php @@ -59,31 +59,24 @@ Kronolith::initialize(); // TODO - Maintenance operations need to be refactored to a more global // operation and then wen can get rid of these hackish checks -/* Do maintenance operations - need to check for a number of conditions to be +/* Do login tasks - need to check for a number of conditions to be * sure that we aren't here due to alarm notifications (which would occur after * headers are sent), we aren't on any of the portal pages, and that we haven't - * already performed maintenance. + * already performed login tasks. */ -require_once 'Horde/Maintenance.php'; if (empty($no_maint) && Kronolith::loginTasksFlag() && !strstr($_SERVER['PHP_SELF'], 'maintenance.php') && - !headers_sent() && !defined('AUTH_HANDLER') && - $GLOBALS['prefs']->getValue('do_maintenance')) { + !headers_sent() && !defined('AUTH_HANDLER')) { Kronolith::loginTasksFlag(2); - $maint = Maintenance::factory('kronolith', array('last_maintenance' => $GLOBALS['prefs']->getValue('last_kronolith_maintenance'))); - if (!$maint) { - $GLOBALS['notification']->push(_("Could not execute maintenance operations."), 'horde.warning'); - } else { - $maint->runMaintenance(); - } + + $tasks = &Horde_LoginTasks::singleton('kronolith', Horde_Util::addParameter(Horde::selfUrl(true, true, true), array('logintasks_done' => true))); + $tasks->runTasks(); + Kronolith::loginTasksFlag(0); -} elseif (Horde_Util::getFormData(MAINTENANCE_DONE_PARAM) && +} elseif (Horde_Util::getFormData('logintasks_done') && Kronolith::loginTasksFlag()) { - $maint = Maintenance::factory('kronolith', array('last_maintenance' => $GLOBALS['prefs']->getValue('last_kronolith_maintenance'))); - if (!$maint) { - $GLOBALS['notification']->push(_("Could not execute maintenance operations."), 'horde.warning'); - } else { - $maint->runMaintenance(); - } + $tasks = &Horde_LoginTasks::singleton('kronolith', Horde_Util::addParameter(Horde::selfUrl(true, true, true), array('logintasks_done' => true))); + $tasks->runTasks(); + Kronolith::loginTasksFlag(0); } diff --git a/kronolith/lib/prefs.php b/kronolith/lib/prefs.php index 0325db857..049b1632b 100644 --- a/kronolith/lib/prefs.php +++ b/kronolith/lib/prefs.php @@ -178,13 +178,6 @@ function prefs_callback() } -/* Get the interval variables for the prefs */ -require_once KRONOLITH_BASE . '/lib/Maintenance/kronolith.php'; -$maint = &new Maintenance_Kronolith(); -foreach (($maint->exportIntervalPrefs()) as $val) { - $$val = &$intervals; -} - if (!empty($GLOBALS['conf']['holidays']['enable'])) { if (class_exists('Date_Holidays')) { foreach (Date_Holidays::getInstalledDrivers() as $driver) { -- 2.11.0