execute()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 0
dl 0
loc 15
ccs 0
cts 9
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package org.openpsa.directmarketing
4
 * @author The Midgard Project, http://www.midgard-project.org
5
 * @copyright The Midgard Project, http://www.midgard-project.org
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 */
8
9
/**
10
 * Cron handler for cleaning up the database of old entries. Disabled by default in configuration.
11
 *
12
 * @package org.openpsa.directmarketing
13
 */
14
class org_openpsa_directmarketing_cron_cleanup extends midcom_baseclasses_components_cron_handler
15
{
16
    /**
17
     * Find all old entries and delete them.
18
     */
19
    public function execute()
20
    {
21
        if (!$this->_config->get('delete_older')) {
22
            return;
23
        }
24
25
        if (!midcom::get()->auth->request_sudo($this->_component)) {
26
            $this->print_error("Could not get sudo, aborting operation, see error log for details");
27
            return;
28
        }
29
30
        $cleanup = new org_openpsa_directmarketing_cleanup();
31
        $cleanup->delete();
32
33
        midcom::get()->auth->drop_sudo();
34
    }
35
}
36