midcom_cron_loginservice   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 15
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 4
1
<?php
2
/**
3
 * @package midcom.services
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
 * @package midcom.services
11
 */
12
class midcom_cron_loginservice extends midcom_baseclasses_components_cron_handler
13
{
14
    public function execute()
15
    {
16
        if (midcom::get()->config->get('auth_login_session_timeout')) {
17
            $qb = new midgard_query_builder('midgard_parameter');
18
            $qb->add_constraint('domain', '=', 'midcom');
19
            $qb->add_constraint('name', '=', 'online');
20
            $qb->add_constraint('value', '<', time() - midcom::get()->config->get('auth_login_session_timeout'));
21
            foreach ($qb->iterate() as $tmp) {
22
                if (!$tmp->purge()) {
23
                    $msg = "Failed to purge login session {$tmp->id}, last Midgard error was: " . midcom_connection::get_error_string();
24
                    $this->print_error($msg, $tmp);
25
                } else {
26
                    debug_add("Purged login session {$tmp->id}.");
27
                }
28
            }
29
        }
30
    }
31
}