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