1: <?php
2: /**
3: * See the enclosed file COPYING for license information (GPL). If you
4: * did not receive this file, see http://www.horde.org/licenses/gpl.
5: *
6: * @category Horde
7: * @license http://www.horde.org/licenses/gpl GPL
8: * @package IMP
9: */
10:
11: /**
12: * Login tasks module that deletes old linked attachments.
13: *
14: * @author Andrew Coleman <mercury@appisolutions.net>
15: * @category Horde
16: * @license http://www.horde.org/licenses/gpl GPL
17: * @package IMP
18: */
19: class IMP_LoginTasks_Task_DeleteAttachmentsMonthly extends Horde_LoginTasks_Task
20: {
21: /**
22: * Constructor.
23: */
24: public function __construct()
25: {
26: global $conf, $prefs;
27:
28: $this->active = !empty($conf['compose']['link_attachments']) &&
29: $prefs->getValue('delete_attachments_monthly_keep');
30: if ($this->active &&
31: $prefs->isLocked('delete_attachments_monthly_keep')) {
32: $this->display = Horde_LoginTasks::DISPLAY_NONE;
33: }
34: }
35:
36: /**
37: * Purges the old linked attachments.
38: *
39: * @return boolean True.
40: */
41: public function execute()
42: {
43: $GLOBALS['injector']->getInstance('IMP_Factory_ComposeAtc')->create(null, null, 'linked')->gc();
44:
45: return true;
46: }
47:
48: /**
49: * Returns information for the login task.
50: *
51: * @return string Description of what the operation is going to do during
52: * this login.
53: */
54: public function describe()
55: {
56: return sprintf(_("All old linked attachments more than %s months old will be deleted."), $GLOBALS['prefs']->getValue('delete_attachments_monthly_keep'));
57: }
58:
59: }
60: