1 <?php
3 /*! \brief Exception implementation for ObjectList
4 \author Cajus Pollmeier <pollmeier@gonicus.de>
5 \version 1.00
6 \date 2007/11/02
8 This class handles the exceptions occuring in ObjectList.
9 */
10 class ObjectListException extends Exception {
11 public function __construct($message, $code = 0) {
12 parent::__construct($message, $code);
13 }
14 }
17 /*! \brief Implementation for keeping a list of objects
18 \author Cajus Pollmeier <pollmeier@gonicus.de>
19 \version 1.00
20 \date 2007/11/02
22 The class ObjectList handles a list of objects found in the database
23 based on an optional filter modules. This objects can be iterated
24 directly.
26 \sa ObjectListIterator
27 */
28 class ObjectList implements IteratorAggregate {
30 /*!
31 \brief Container for objects
33 This variable stores the list of objects.
34 */
35 private $objects;
37 /*!
38 \brief Config
40 Config array that keeps the classes we do lists for, filter information, etc.
41 */
42 private $config;
45 /*! \brief ObjectList constructor
47 The ObjectList is initialized by a list of classes we're interested
48 in. Rest is done by instances of Filter registered in the Registry.
50 \param config Config section that is used to configure this ObjectList
51 \sa Registry
52 \sa Filter
53 */
54 public function __construct(&$config){
56 /* Save current config */
57 $this->config= &$config;
59 /* Load and instanciate classes, extract filter, icons, view hooks, etc. */
60 $this->load();
62 }
65 /*! \brief Function to initialy load object list
67 Internally loads the relevant list of objects depending on eventually
68 defined filter modules. Handles sorting, too.
69 */
70 private function load(){
72 $icon =
73 '<img src="images/editcut.png" alt=""> '.
74 '<img src="images/editcopy.png" alt=""> '.
75 '<img src="images/edit.png" alt=""> '.
76 '<img src="images/list_password.png" alt=""> '.
77 '<img src="images/restore.png" alt=""> '.
78 '<img src="images/snapshot.png" alt=""> '.
79 '<img src="images/edittrash.png" alt="">';
81 # Crap filling
82 $tmp= array(
84 array("dn" => "cn=1aherbertskiste,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
85 "cn" => "1aherbertskiste",
86 "_icon" => "select_workstation.png",
87 "_actions" => $icon,
88 "objectClass" => array('gotoWorkstation')),
90 array("dn" => "cn=72:9c:13:e9:72:2b,ou=incoming,o=Landeshauptstadt München,c=de",
91 "cn" => "72:9c:13:e9:72:2b",
92 "_icon" => "select_newsystem.png",
93 "_actions" => $icon,
94 "objectClass" => array('gotoWorkstation')),
96 array("dn" => "cn=8f:9c:d0:d5:42:c0,ou=incoming,o=Landeshauptstadt München,c=de",
97 "cn" => "8f:9c:d0:d5:42:c0",
98 "_icon" => "select_newsystem.png",
99 "_actions" => $icon,
100 "objectClass" => array('gotoWorkstation')),
102 array("dn" => "cn=a.b_c,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
103 "cn" => "a.b_c",
104 "_icon" => "select_printer.png",
105 "_actions" => $icon,
106 "objectClass" => array('gotoWorkstation')),
108 array("dn" => "cn=a5:35:77:86:ff:ca,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
109 "cn" => "a5:35:77:86:ff:ca",
110 "_icon" => "select_workstation.png",
111 "_actions" => $icon,
112 "objectClass" => array('gotoWorkstation')),
114 array("dn" => "cn=cl1--141,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
115 "cn" => "cl1--141",
116 "_icon" => "select_workstation.png",
117 "_actions" => $icon,
118 "objectClass" => array('gotoWorkstation')),
120 array("dn" => "cn=d9:57:9d:08:2c:65,ou=incoming,o=Landeshauptstadt München,c=de",
121 "cn" => "d9:57:9d:08:2c:65",
122 "_icon" => "select_newsystem.png",
123 "_actions" => $icon,
124 "objectClass" => array('gotoWorkstation')),
126 array("dn" => "cn=dyn-111,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
127 "cn" => "dyn-111",
128 "_icon" => "select_server.png",
129 "_actions" => $icon,
130 "objectClass" => array('gotoWorkstation')),
132 array("dn" => "cn=e3:b4:43:51:f6:13,ou=incoming,o=Landeshauptstadt München,c=de",
133 "cn" => "e3:b4:43:51:f6:13",
134 "_icon" => "select_newsystem.png",
135 "_actions" => $icon,
136 "objectClass" => array('gotoWorkstation')),
138 array("dn" => "cn=f2:d7:ef:92:e6:43,ou=incoming,o=Landeshauptstadt München,c=de",
139 "cn" => "f2:d7:ef:92:e6:43",
140 "_icon" => "select_newsystem.png",
141 "_actions" => $icon,
142 "objectClass" => array('gotoWorkstation')),
144 array("dn" => "cn=f9:fa:4e:f8:1a:40,ou=incoming,o=Landeshauptstadt München,c=de",
145 "cn" => "f9:fa:4e:f8:1a:40",
146 "_icon" => "select_newsystem.png",
147 "_actions" => $icon,
148 "objectClass" => array('gotoWorkstation')),
150 array("dn" => "cn=hu_ber-test.gonicus.de,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
151 "cn" => "hu_ber-test.gonicus.de",
152 "_icon" => "select_printer.png",
153 "_actions" => $icon,
154 "objectClass" => array('gotoWorkstation')),
156 array("dn" => "cn=loghost-01,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
157 "cn" => "loghost-01",
158 "_icon" => "select_server.png",
159 "_actions" => $icon,
160 "objectClass" => array('gotoWorkstation')),
162 array("dn" => "cn=ntp.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
163 "cn" => "ntp.jp.",
164 "_icon" => "select_server.png",
165 "_actions" => $icon,
166 "objectClass" => array('gotoWorkstation')),
168 array("dn" => "cn=phone-1.gonicus.de.,ou=phones,ou=systems,o=Landeshauptstadt München,c=de",
169 "cn" => "phone-1.gonicus.de.",
170 "_icon" => "select_phone.png",
171 "_actions" => $icon,
172 "objectClass" => array('gotoWorkstation')),
174 array("dn" => "cn=printer.222,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
175 "cn" => "printer.222",
176 "_icon" => "select_printer.png",
177 "_actions" => $icon,
178 "objectClass" => array('gotoWorkstation')),
180 array("dn" => "cn=printer,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
181 "cn" => "printer",
182 "_icon" => "select_printer.png",
183 "_actions" => $icon,
184 "objectClass" => array('gotoWorkstation')),
186 array("dn" => "cn=shares.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
187 "cn" => "shares.jp. [Share server]",
188 "_icon" => "select_server.png",
189 "_actions" => $icon,
190 "objectClass" => array('gotoWorkstation')),
192 array("dn" => "cn=terminal.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
193 "cn" => "terminal.jp.",
194 "_icon" => "select_server.png",
195 "_actions" => $icon,
196 "objectClass" => array('gotoWorkstation')),
198 array("dn" => "cn=test.test.etst,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
199 "cn" => "test.test.etst",
200 "_icon" => "select_printer.png",
201 "_actions" => $icon,
202 "objectClass" => array('gotoWorkstation')),
204 array("dn" => "cn=tester,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
205 "cn" => "tester",
206 "_icon" => "select_printer.png",
207 "_actions" => $icon,
208 "objectClass" => array('gotoWorkstation')),
210 array("dn" => "cn=vserver-04.intranet.gonicus.de,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
211 "cn" => "vserver-04.",
212 "_icon" => "select_server.png",
213 "_actions" => $icon,
214 "objectClass" => array('gotoWorkstation')),
216 array("dn" => "cn=workstation,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
217 "cn" => "workstation",
218 "_icon" => "select_workstation.png",
219 "_actions" => $icon,
220 "objectClass" => array('gotoWorkstation')),
221 array("dn" => "cn=1aherbertskiste,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
222 "cn" => "1aherbertskiste",
223 "_icon" => "select_workstation.png",
224 "_actions" => $icon,
225 "objectClass" => array('gotoWorkstation')),
227 array("dn" => "cn=72:9c:13:e9:72:2b,ou=incoming,o=Landeshauptstadt München,c=de",
228 "cn" => "72:9c:13:e9:72:2b",
229 "_icon" => "select_newsystem.png",
230 "_actions" => $icon,
231 "objectClass" => array('gotoWorkstation')),
233 array("dn" => "cn=8f:9c:d0:d5:42:c0,ou=incoming,o=Landeshauptstadt München,c=de",
234 "cn" => "8f:9c:d0:d5:42:c0",
235 "_icon" => "select_newsystem.png",
236 "_actions" => $icon,
237 "objectClass" => array('gotoWorkstation')),
239 array("dn" => "cn=a.b_c,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
240 "cn" => "a.b_c",
241 "_icon" => "select_printer.png",
242 "_actions" => $icon,
243 "objectClass" => array('gotoWorkstation')),
245 array("dn" => "cn=a5:35:77:86:ff:ca,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
246 "cn" => "a5:35:77:86:ff:ca",
247 "_icon" => "select_workstation.png",
248 "_actions" => $icon,
249 "objectClass" => array('gotoWorkstation')),
251 array("dn" => "cn=cl1--141,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
252 "cn" => "cl1--141",
253 "_icon" => "select_workstation.png",
254 "_actions" => $icon,
255 "objectClass" => array('gotoWorkstation')),
257 array("dn" => "cn=d9:57:9d:08:2c:65,ou=incoming,o=Landeshauptstadt München,c=de",
258 "cn" => "d9:57:9d:08:2c:65",
259 "_icon" => "select_newsystem.png",
260 "_actions" => $icon,
261 "objectClass" => array('gotoWorkstation')),
263 array("dn" => "cn=dyn-111,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
264 "cn" => "dyn-111",
265 "_icon" => "select_server.png",
266 "_actions" => $icon,
267 "objectClass" => array('gotoWorkstation')),
269 array("dn" => "cn=e3:b4:43:51:f6:13,ou=incoming,o=Landeshauptstadt München,c=de",
270 "cn" => "e3:b4:43:51:f6:13",
271 "_icon" => "select_newsystem.png",
272 "_actions" => $icon,
273 "objectClass" => array('gotoWorkstation')),
275 array("dn" => "cn=f2:d7:ef:92:e6:43,ou=incoming,o=Landeshauptstadt München,c=de",
276 "cn" => "f2:d7:ef:92:e6:43",
277 "_icon" => "select_newsystem.png",
278 "_actions" => $icon,
279 "objectClass" => array('gotoWorkstation')),
281 array("dn" => "cn=f9:fa:4e:f8:1a:40,ou=incoming,o=Landeshauptstadt München,c=de",
282 "cn" => "f9:fa:4e:f8:1a:40",
283 "_icon" => "select_newsystem.png",
284 "_actions" => $icon,
285 "objectClass" => array('gotoWorkstation')),
287 array("dn" => "cn=hu_ber-test.gonicus.de,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
288 "cn" => "hu_ber-test.gonicus.de",
289 "_icon" => "select_printer.png",
290 "_actions" => $icon,
291 "objectClass" => array('gotoWorkstation')),
293 array("dn" => "cn=loghost-01,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
294 "cn" => "loghost-01",
295 "_icon" => "select_server.png",
296 "_actions" => $icon,
297 "objectClass" => array('gotoWorkstation')),
299 array("dn" => "cn=ntp.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
300 "cn" => "ntp.jp.",
301 "_icon" => "select_server.png",
302 "_actions" => $icon,
303 "objectClass" => array('gotoWorkstation')),
305 array("dn" => "cn=phone-1.gonicus.de.,ou=phones,ou=systems,o=Landeshauptstadt München,c=de",
306 "cn" => "phone-1.gonicus.de.",
307 "_icon" => "select_phone.png",
308 "_actions" => $icon,
309 "objectClass" => array('gotoWorkstation')),
311 array("dn" => "cn=printer.222,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
312 "cn" => "printer.222",
313 "_icon" => "select_printer.png",
314 "_actions" => $icon,
315 "objectClass" => array('gotoWorkstation')),
317 array("dn" => "cn=printer,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
318 "cn" => "printer",
319 "_icon" => "select_printer.png",
320 "_actions" => $icon,
321 "objectClass" => array('gotoWorkstation')),
323 array("dn" => "cn=shares.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
324 "cn" => "shares.jp. [Share server]",
325 "_icon" => "select_server.png",
326 "_actions" => $icon,
327 "objectClass" => array('gotoWorkstation')),
329 array("dn" => "cn=terminal.jp.,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
330 "cn" => "terminal.jp.",
331 "_icon" => "select_server.png",
332 "_actions" => $icon,
333 "objectClass" => array('gotoWorkstation')),
335 array("dn" => "cn=test.test.etst,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
336 "cn" => "test.test.etst",
337 "_icon" => "select_printer.png",
338 "_actions" => $icon,
339 "objectClass" => array('gotoWorkstation')),
341 array("dn" => "cn=tester,ou=printers,ou=systems,o=Landeshauptstadt München,c=de",
342 "cn" => "tester",
343 "_icon" => "select_printer.png",
344 "_actions" => $icon,
345 "objectClass" => array('gotoWorkstation')),
347 array("dn" => "cn=vserver-04.intranet.gonicus.de,ou=servers,ou=systems,o=Landeshauptstadt München,c=de",
348 "cn" => "vsernicus.de",
349 "_icon" => "select_server.png",
350 "_actions" => $icon,
351 "objectClass" => array('gotoWorkstation')),
353 array("dn" => "cn=workstation,ou=workstations,ou=systems,o=Landeshauptstadt München,c=de",
354 "cn" => "workstation",
355 "_icon" => "select_workstation.png",
356 "_actions" => $icon,
357 "objectClass" => array('gotoWorkstation'))
359 );
361 $tmp2 = array();
362 foreach($tmp as $key => $entry){
363 $entry['id']= $key;
364 $entry['_icon'] = "<img src='images/".$entry['_icon']."' alt=''>";
365 $tmp2[] = $entry;
366 }
368 $this->objects = $tmp2;
369 }
372 /*! \brief Function to reload object list in case of external changes
374 Triggers a reload the relevant list of objects depending on eventually
375 defined filter modules. Handles sorting, too.
376 */
377 public function reload(){
378 }
381 /*! \brief Function to return the iterator object for this class.
383 This function is used internally by PHP to produce an iterator.
385 \return Iterator object
387 \sa ObjectListIterator
388 */
389 public function getIterator() {
390 return new ObjectListIterator($this->objects);
391 }
393 }
395 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
396 ?>