imap class / mail controller
[cacert-mgr.git] / manager / library / imap / imapParseAction.php
1 <?php
2 /**
3 * @author markus
4 * $Id: $
5 */
6
7 /**
8 * required files
9 * @ignore
10 */
11 require_once('exception.IMAPException.php');
12
13 /**
14 * Supportklasse für imapCleanMailbox
15 * Soll den in der Config pro Mailbox angegebenen Action-String auswerten
16 * und in eine automatisiert weiterverarbeitbare Form bringen.
17 */
18 class imapParseAction {
19 /**
20 * Actions als Konstanten
21 * @var integer
22 */
23 const IMAP_ACTION_DELETE = 1;
24 const IMAP_ACTION_ARCHIVE = 2;
25
26 /**
27 * gesetzte Action
28 * @var integer
29 */
30 private $action = 0;
31
32 /**
33 * Modifikator keep gesetzt?
34 * @var boolean
35 */
36 private $delete_keep = false;
37
38 /**
39 * Wert des Modifikators keep
40 * @var integer
41 */
42 private $delete_keep_num = 0;
43
44 /**
45 * getAction
46 * @return integer
47 */
48 public function getAction() {
49 return $this->action;
50 }
51
52 /**
53 * getDeleteKeep
54 * @return boolean
55 */
56 public function getDeleteKeep() {
57 return $this->delete_keep;
58 }
59
60 /**
61 * getDeleteKeepNum
62 * @return integer
63 */
64 public function getDeleteKeepNum() {
65 return $this->delete_keep_num;
66 }
67
68 /**
69 * Konstruktor, parst eine Zeile mit Tokens und ermittelt, welche Aktionen
70 * auf einer Mailbox ausgeführt werden sollen
71 * @param string $action
72 */
73 public function __construct($action) {
74 $args = explode(' ', $action);
75
76 $numargs = count($args);
77
78 for ($arg = 0; $arg < $numargs; $arg++) {
79 switch ($args[$arg]) {
80 case 'delete':
81 $this->action = self::IMAP_ACTION_DELETE;
82 break;
83 case 'keep':
84 $arg++;
85 $this->delete_keep = true;
86 $this->delete_keep_num = $args[$arg];
87 break;
88 default:
89 /**
90 * @todo Exception werfen
91 */
92 break;
93 }
94 }
95 }
96 }