summaryrefslogtreecommitdiff
path: root/manager/library/imap/imapParseAction.php
blob: d9e3fb0335fd9057f91a6623afe6c61c51296f5d (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
 * @author markus
 * $Id: $
 */

/**
 * required files
 * @ignore
 */
require_once('exception.IMAPException.php');

/**
 * Supportklasse für imapCleanMailbox
 * Soll den in der Config pro Mailbox angegebenen Action-String auswerten
 * und in eine automatisiert weiterverarbeitbare Form bringen.
 */
class imapParseAction {
    /**
     * Actions als Konstanten
     * @var integer
     */
    const IMAP_ACTION_DELETE = 1;
    const IMAP_ACTION_ARCHIVE = 2;

    /**
     * gesetzte Action
     * @var integer
     */
    private $action = 0;

    /**
     * Modifikator keep gesetzt?
     * @var boolean
     */
    private $delete_keep = false;

    /**
     * Wert des Modifikators keep
     * @var integer
     */
    private $delete_keep_num = 0;

    /**
     * getAction
     * @return integer
     */
    public function getAction() {
        return $this->action;
    }

    /**
     * getDeleteKeep
     * @return boolean
     */
    public function getDeleteKeep() {
        return $this->delete_keep;
    }

    /**
     * getDeleteKeepNum
     * @return integer
     */
    public function getDeleteKeepNum() {
        return $this->delete_keep_num;
    }

    /**
     * Konstruktor, parst eine Zeile mit Tokens und ermittelt, welche Aktionen
     * auf einer Mailbox ausgeführt werden sollen
     * @param string $action
     */
    public function __construct($action) {
        $args = explode(' ', $action);

        $numargs = count($args);

        for ($arg = 0; $arg < $numargs; $arg++) {
            switch ($args[$arg]) {
                case 'delete':
                    $this->action = self::IMAP_ACTION_DELETE;
                    break;
                case 'keep':
                    $arg++;
                    $this->delete_keep = true;
                    $this->delete_keep_num = $args[$arg];
                    break;
                default:
                    /**
                     * @todo Exception werfen
                     */
                    break;
            }
        }
    }
}