1: <?php
2: /**
3: * Copyright 2009-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2009-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Login system task for performing periodical garbage collection.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2009-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_LoginTasks_SystemTask_GarbageCollection extends Horde_LoginTasks_SystemTask
24: {
25: /**
26: * The interval at which to run the task.
27: *
28: * @var integer
29: */
30: public $interval = Horde_LoginTasks::WEEKLY;
31:
32: /**
33: * Perform all functions for this task.
34: */
35: public function execute()
36: {
37: global $injector, $registry;
38:
39: /* These require mail server authentication. */
40: try {
41: /* Purge non-existent nav_poll entries. */
42: $injector->getInstance('IMP_Ftree')->poll->prunePollList();
43:
44: /* Purge non-existent search sorts. */
45: $injector->getInstance('IMP_Prefs_Sort')->gc();
46: } catch (Exception $e) {}
47:
48: /* Only do these tasks as admin, or else they are duplicative across
49: * all users. */
50: if ($registry->isAdmin()) {
51: /* Do garbage collection on sentmail entries. */
52: $injector->getInstance('IMP_Sentmail')->gc();
53:
54: /* Do garbage collection on compose VFS data. */
55: $injector->getInstance('IMP_Factory_ComposeAtc')->create(null, null, 'atc')->gc();
56: }
57: }
58:
59: }
60: