File: fetchmail_login.php

package info (click to toggle)
imp4 4.2-4lenny3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,252 kB
  • ctags: 5,316
  • sloc: php: 21,340; xml: 19,302; makefile: 68; sql: 14
file content (75 lines) | stat: -rw-r--r-- 2,212 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
 * $Horde: imp/lib/Maintenance/Task/fetchmail_login.php,v 1.5.12.10 2008/01/02 11:32:05 jan Exp $
 *
 * Copyright 2003-2008 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.
 *
 * Maintenance module that fetch mail upon login
 *
 * @author  Nuno Loureiro <nuno@co.sapo.pt>
 * @author  Michael Slusarz <slusarz@horde.org>
 * @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()
    {
        require_once IMP_BASE . '/lib/Fetchmail.php';
        $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):");
        $str .= "\n<blockquote>\n";

        require_once IMP_BASE . '/lib/Fetchmail.php';
        $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) . "<br />\n";
                }
            }
        }

        $str .= "\n</blockquote>\n<strong>" . _("Note that this can take some time") . ".</strong>\n";

        return $str;
    }

}