1: <?php
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: class Horde_Kolab_Server_Object_Kolabpop3account extends Horde_Kolab_Server_Object_Top
29: {
30:
31:
32:
33: const ATTRIBUTE_SERVER = 'externalPop3AccountServer';
34:
35:
36: const ATTRIBUTE_LOGINNAME = 'externalPop3AccountLoginName';
37:
38:
39: const ATTRIBUTE_PASSWORD = 'externalPop3EncryptedAccountPassword';
40:
41:
42: const ATTRIBUTE_DESCRIPTION = 'externalPop3AccountDescription';
43:
44:
45: const ATTRIBUTE_MAIL = 'externalPop3AccountMail';
46:
47:
48: const ATTRIBUTE_PORT = 'externalPop3AccountPort';
49:
50:
51: const ATTRIBUTE_USESSL = 'externalPop3AccountUseSSL';
52:
53:
54: const ATTRIBUTE_USETLS = 'externalPop3AccountUseTLS';
55:
56:
57: const ATTRIBUTE_LOGINMETHOD = 'externalPop3AccountLoginMethod';
58:
59:
60: const ATTRIBUTE_CHECKCERTIFICATE = 'externalPop3AccountCheckServerCertificate';
61:
62:
63: const ATTRIBUTE_KEEPMAILONSERVER = 'externalPop3AccountKeepMailOnServer';
64:
65:
66: const ATTRIBUTE_OWNERUID = 'externalPop3AccountOwnerUid';
67:
68:
69: const OBJECTCLASS_KOLABEXTERNALPOP3ACCOUNT = 'kolabExternalPop3Account';
70:
71: 72: 73: 74: 75:
76: static public $init_attributes = array(
77: 'defined' => array(
78: self::ATTRIBUTE_SERVER,
79: self::ATTRIBUTE_LOGINNAME,
80: self::ATTRIBUTE_PASSWORD,
81: self::ATTRIBUTE_DESCRIPTION,
82: self::ATTRIBUTE_MAIL,
83: self::ATTRIBUTE_PORT,
84: self::ATTRIBUTE_USESSL,
85: self::ATTRIBUTE_USETLS,
86: self::ATTRIBUTE_LOGINMETHOD,
87: self::ATTRIBUTE_CHECKCERTIFICATE,
88: self::ATTRIBUTE_KEEPMAILONSERVER,
89: ),
90: 'derived' => array(
91: self::ATTRIBUTE_OWNERUID => array(
92: 'method' => 'getParentUid',
93: ),
94: ),
95: 'collapsed' => array(
96: self::ATTRIBUTE_OWNERUID => array(
97: 'base' => array(
98: self::ATTRIBUTE_OWNERUID
99: ),
100: 'method' => 'removeAttribute',
101: ),
102: ),
103: 'required' => array(
104: self::ATTRIBUTE_MAIL,
105: self::ATTRIBUTE_SERVER,
106: self::ATTRIBUTE_LOGINNAME,
107: self::ATTRIBUTE_PASSWORD,
108: ),
109: 'object_classes' => array(
110: self::OBJECTCLASS_KOLABEXTERNALPOP3ACCOUNT,
111: ),
112: );
113:
114: 115: 116: 117: 118: 119: 120:
121: public function generateId(array &$info)
122: {
123: if (!isset($info[self::ATTRIBUTE_OWNERUID])) {
124: $uid = $this->get(self::ATTRIBUTE_OWNERUID);
125: if (empty($uid)) {
126: throw new Horde_Kolab_Server_Exception("No parent object provided!",
127: Horde_Kolab_Server_Exception::INVALID_INFORMATION);
128: }
129: } else {
130: if (is_array($info[self::ATTRIBUTE_OWNERUID])) {
131: $uid = $info[self::ATTRIBUTE_OWNERUID][0];
132: } else {
133: $uid = $info[self::ATTRIBUTE_OWNERUID];
134: }
135: }
136:
137: $object = $this->server->fetch($uid);
138: if (!$object->exists()) {
139: throw new Horde_Kolab_Server_Exception(sprintf("The parent object %s does not exist!",
140: $uid),
141: Horde_Kolab_Server_Exception::INVALID_INFORMATION);
142: }
143:
144: if (!isset($info[self::ATTRIBUTE_MAIL])) {
145: $mail = $this->get(self::ATTRIBUTE_MAIL);
146: if (empty($mail)) {
147: throw new Horde_Kolab_Server_Exception("No mail given!",
148: Horde_Kolab_Server_Exception::INVALID_INFORMATION);
149: }
150: } else {
151: if (is_array($info[self::ATTRIBUTE_MAIL])) {
152: $mail = $info[self::ATTRIBUTE_MAIL][0];
153: } else {
154: $mail = $info[self::ATTRIBUTE_MAIL];
155: }
156: }
157:
158: $base = substr($uid, 0, strpos($uid, $this->server->getBaseUid()) - 1);
159:
160: unset($info[self::ATTRIBUTE_OWNERUID]);
161:
162: return self::ATTRIBUTE_MAIL . '=' . $this->server->structure->quoteForUid($mail) . ',' . $base;
163: }
164:
165: 166: 167: 168: 169:
170: static public function getSearchOperations()
171: {
172: $searches = array(
173:
174: );
175: return $searches;
176: }
177:
178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188:
189: static public function pop3AccountsForMail($server, $mail)
190: {
191: $uid = $server->uidForMail($mail, Horde_Kolab_Server_Object::RESULT_SINGLE);
192: return self::objectsForUid($server, $uid, self::OBJECTCLASS_KOLABEXTERNALPOP3ACCOUNT);
193: }
194:
195: }