Code

skipping . .. when deleting smarty spool dir
[gosa.git] / plugins / admin / systems / class_systemManagement.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 require "tabs_terminal.inc";
21 require "tabs_workstation.inc";
22 require "tabs_printers.inc";
23 require "tabs_phone.inc";
24 require "tabs_server.inc";
25 require "tabs_component.inc";
26 require "tabs_winstation.inc";
29 class systems extends plugin
30 {
31   /* Definitions */
32   var $plHeadline= "Systems";
33   var $plDescription= "This does something";
35   /* Dialog attributes */
36   var $systab= NULL;
37   var $terminals= array();
38   var $ui= NULL;
39   var $acl= "";
41   function systems ($config, $ui)
42   {
43     /* Save configuration for internal use */
44     $this->config= $config;
45     $this->ui= $ui;
47     /* Get global filter config */
48     if (!is_global("terminalfilter")){
49       $ui= get_userinfo();
50       $base= get_base_from_people($ui->dn);
51       $terminalfilter= array("workstations" => "checked",
52           "thins" => "checked",
53           "winstations" => "checked",
54           "servers" => "checked",
55           "printers" => "checked",
56           "phones" => "checked",
57           "netdev" => "checked",
58           "user" => "*",
59           "depselect" => $base,
60           "regex" => "*");
61       register_global("terminalfilter", $terminalfilter);
62     }
63   }
65   function execute()
66   {
67     /* Save data */
68     $terminalfilter= get_global("terminalfilter");
69     foreach( array("depselect", "user", "regex") as $type){
70       if (isset($_POST[$type])){
71         $terminalfilter[$type]= $_POST[$type];
72       }
73     }
74     if (isset($_POST['depselect'])){
75       foreach( array("workstations", "thins", "winstations", "printers", "phones", "servers", "netdev") as $type){
77         if (isset($_POST[$type])) {
78           $terminalfilter[$type]= "checked";
79         } else {
80           $terminalfilter[$type]= "";
81         }
82       }
83     }
84     if (isset($_GET['search'])){
85       $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
86       if ($s == "**"){
87         $s= "*";
88       }
89       $terminalfilter['regex']= $s;
90     }
91     register_global("terminalfilter", $terminalfilter);
93     /* Check sorting variable */
94     if (!isset($this->systab) &&
95         !isset($_POST['new_terminal']) &&
96         !isset($_POST['delete_terminal']) &&
97         !isset($_POST['set_password']) &&
98         !isset($_POST['select_terminal'])){
99       $this->reload();
100     }
101     $smarty= get_smarty();
103     /* Check for exeeded sizelimit */
104     if (($message= check_sizelimit()) != ""){
105       return($message);
106     }
108     /* Try to get informations about what kind of system to create */
109     if (isset($_POST['new_terminal'])) {
110       return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
111     }
113     /* Create new default terminal */
114     if (isset($_POST['create_system'])) {
115       $this->dn= "new";
116       $this->acl= array(":all");
118       switch ($_POST['system']){
119         case 'terminal':
120           $this->systab= new termtabs($this->config,
121               $this->config->data['TABS']['TERMTABS'], $this->dn);
122           $this->systab->set_acl ($this->acl);
123           $this->systab->by_object['termgeneric']->cn= "default";
124           $this->systab->by_object['termservice']->cn= "default";
125           break;
127         case 'workstation':
128           $this->systab= new worktabs($this->config,
129               $this->config->data['TABS']['WORKTABS'], $this->dn);
130           $this->systab->set_acl ($this->acl);
131           $this->systab->by_object['workgeneric']->cn= "wdefault";
132           $this->systab->by_object['termservice']->cn= "default";
133           break;
135         case 'server':
136           $this->systab= new servtabs($this->config,
137               $this->config->data['TABS']['SERVTABS'], $this->dn);
138           $this->systab->set_acl ($this->acl);
139           break;
141         case 'printer':
142           $this->systab= new printtabs($this->config,
143               $this->config->data['TABS']['PRINTTABS'], $this->dn);
144           $this->systab->set_acl ($this->acl);
145           break;
147         case 'phone':
148           $this->systab= new phonetabs($this->config,
149               $this->config->data['TABS']['PHONETABS'], $this->dn);
150           $this->systab->set_acl ($this->acl);
151           break;
153         case 'component':
154           $this->systab= new componenttabs($this->config,
155               $this->config->data['TABS']['COMPONENTTABS'], $this->dn);
156           $this->systab->set_acl ($this->acl);
157           break;
158       }
159     }
161     /* User wants to edit data? */
162     if ((isset($_POST['select_terminal']) || (isset($_POST['edit_helper']) && $_POST['edit_helper'] == "1")) && isset($_POST['termlist']) &&
163           $_POST['termlist'] != ""){
165       /* Get 'dn' from posted 'cn', must be unique */
166       $this->dn= trim($_POST['termlist']);
168       /* Check locking, save current plugin in 'back_plugin', so
169          the dialog knows where to return. */
170       if (($user= get_lock($this->dn)) != ""){
171         return(gen_locked_message ($user, $this->dn));
172       }
174       /* Set up the users ACL's for this 'dn' */
175       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
177       /* Find out more about the object type */
178       $ldap= $this->config->get_ldap_link();
179       $ldap->cat($this->dn);
180       $attrs= $ldap->fetch();
181       $type= $this->get_system_type($attrs['objectClass']);
183       /* Lock the current entry, so everyone will get the
184          above dialog */
185       add_lock ($this->dn, $this->ui->dn);
187       switch ($type){
188         case "terminal":
189           /* Register systab to trigger edit dialog */
190           $this->systab= new termtabs($this->config,
191               $this->config->data['TABS']['TERMTABS'], $this->dn);
192           $this->systab->set_acl($acl);
193           $_SESSION['objectinfo']= $this->dn;
194           break;
196         case "server":
197           /* Register systab to trigger edit dialog */
198           $this->systab= new servtabs($this->config,
199               $this->config->data['TABS']['SERVTABS'], $this->dn);
200           $this->systab->set_acl($acl);
201           $_SESSION['objectinfo']= $this->dn;
202           break;
204         case "workstation":
205           /* Register systab to trigger edit dialog */
206           $this->systab= new worktabs($this->config,
207               $this->config->data['TABS']['WORKTABS'], $this->dn);
208           $this->systab->set_acl($acl);
209           $_SESSION['objectinfo']= $this->dn;
210           break;
212         case "printer":
213           /* Register systab to trigger edit dialog */
214           $this->systab= new printtabs($this->config,
215               $this->config->data['TABS']['PRINTTABS'], $this->dn);
216           $this->systab->set_acl($acl);
217           $_SESSION['objectinfo']= $this->dn;
218           break;
220         case "phone":
221           /* Register systab to trigger edit dialog */
222           $this->systab= new phonetabs($this->config,
223               $this->config->data['TABS']['PHONETABS'], $this->dn);
224           $this->systab->set_acl($acl);
225           $_SESSION['objectinfo']= $this->dn;
226           break;
228         case "component":
229           /* Register systab to trigger edit dialog */
230           $this->systab= new componenttabs($this->config,
231               $this->config->data['TABS']['COMPONENTTABS'], $this->dn);
232           $this->systab->set_acl($acl);
233           $_SESSION['objectinfo']= $this->dn;
234           break;
235        
236         case "winstation":
237           /* Register systab to trigger edit dialog */
238           $this->systab= new wintabs($this->config,
239               $this->config->data['TABS']['WINTABS'], $this->dn);
240           $this->systab->set_acl($acl);
241           $_SESSION['objectinfo']= $this->dn;
242           break;
245         default:
246           print_red (_("You can't edit this object type yet!"));
247           del_lock($this->dn);
248           break;
249       }
250     }
252     /* Set terminals root password */
253     if (isset($_POST['set_password']) && isset($_POST['termlist'])){
254       $this->dn= trim($_POST['termlist']);
255       $_SESSION['objectinfo']= $this->dn;
256       return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
257     }
259     /* Correctly specified? */
260     if (isset($_POST['password_finish'])){
261       if ($_POST['new_password'] != $_POST['repeated_password']){
262         print_red (_("Passwords entered as new and repeated do not match!"));
263         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
264       }
265     }
267     /* Change terminal password */
268     if (isset($_POST['password_finish']) && 
269         $_POST['new_password'] == $_POST['repeated_password']){
271       /* Check if user is allowed to set password */
272       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
273       $acl= get_module_permission($acl, "terminal", $this->dn);
274       if (chkacl($acl, "password") != ""){
275         print_red (_("You are not allowed to set this systems password!"));
276       } else {
277         $ldap= $this->config->get_ldap_link();
278         $ldap->cd($this->dn);
280         $attrs= array();
281         if ($_POST['new_password'] == ""){
282           $attrs['gotoRootPasswd']= array();
283         } else {
284           $attrs['gotoRootPasswd']= crypt($_POST['new_password'],
285               substr(session_id(),0,2));
286         }
287         $ldap->modify($attrs);
288         gosa_log ("Password for '".$this->dn."' has been changed");
289       }
290       unset($_SESSION['objectinfo']);
291     }
293     /* Delete terminal canceled? */
294     if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
295       del_lock ($this->dn);
296       unset($_SESSION['objectinfo']);
297     }
299     /* Remove terminal was requested */
300     if (isset($_POST['delete_terminal']) && isset($_POST['termlist'])){
302       /* Get 'dn' from posted termlinst */
303       $this->dn= $_POST['termlist'];
305       /* Load permissions for selected 'dn' and check if
306          we're allowed to remove this 'dn' */
307       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
308       $this->acl= get_module_permission($acl, "terminal", $this->dn);
309       if (chkacl($this->acl, "delete") == ""){
311         /* Check locking, save current plugin in 'back_plugin', so
312            the dialog knows where to return. */
313         if (($user= get_lock($this->dn)) != ""){
314           return(gen_locked_message ($user, $this->dn));
315         }
317         /* Lock the current entry, so nobody will edit it during deletion */
318         add_lock ($this->dn, $this->ui->dn);
319         $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), $this->dn));
320         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
321       } else {
323         /* Obviously the user isn't allowed to delete. Show message and
324            clean session. */
325         print_red (_("You are not allowed to delete this component!"));
326       }
327     }
329     /* Confirmation for deletion has been passed. Terminal should be deleted. */
330     if (isset($_POST['delete_terminal_confirm'])){
332       /* Some nice guy may send this as POST, so we've to check
333          for the permissions again. */
334       if (chkacl($this->acl, "delete") == ""){
336         /* Find out more about the object type */
337         $ldap= $this->config->get_ldap_link();
338         $ldap->cat($this->dn);
339         $attrs= $ldap->fetch();
340         $type= $this->get_system_type($attrs['objectClass']);
342         switch ($type){
343           case "terminal":
344             $tabtype= "termtabs";
345           break;
347           case "workstation":
348             $tabtype= "worktabs";
349           break;
351           case "server":
352             $tabtype= "servtabs";
353           break;
355           default:
356 #print_red (_("You can't remove this object type yet!"));
357 #del_lock($this->dn);
358 #return;
359           $tabtype= "termtabs";
360           break;
361         }
363         /* Delete request is permitted, perform LDAP action */
364         $this->systab= new $tabtype($this->config,
365             $this->config->data['TABS']['TERMTABS'], $this->dn);
366         $this->systab->set_acl(array($this->acl));
367         $this->systab->by_object['termgeneric']->remove_from_parent ();
368         unset ($this->systab);
369         gosa_log ("System object'".$this->dn."' has been removed");
370         $this->systab= NULL;
372         /* Terminal list has changed, reload it. */
373         $this->reload ();
374       } else {
376         /* Normally this shouldn't be reached, send some extra
377            logs to notify the administrator */
378         print_red (_("You are not allowed to delete this component!"));
379         gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
380             "deletion.");
381       }
383       /* Remove lock file after successfull deletion */
384       del_lock ($this->dn);
385     }
387     /* Finish user edit is triggered by the tabulator dialog, so
388        the user wants to save edited data. Check and save at this
389        point. */
390     if (isset($_POST['edit_finish'])){
392       /* Check tabs, will feed message array */
393       $message= $this->systab->check();
395       /* Save, or display error message? */
396       if (count($message) == 0){
398         /* Save terminal data to ldap */
399         gosa_log ("System object'".$this->dn."' has been saved");
400         $this->systab->save();
402         /* Terminal has been saved successfully, remove lock from
403            LDAP. */
404         if ($this->dn != "new"){
405           del_lock ($this->dn);
406         }
408         /* There's no page reload so we have to read new terminals at
409            this point. */
410         $this->reload ();
411         unset ($this->systab);
412         $this->systab= NULL;
413         unset($_SESSION['objectinfo']);
415       } else {
416         /* Ok. There seem to be errors regarding to the tab data,
417            show message and continue as usual. */
418         show_errors($message);
419       }
421     }
423     /* Cancel dialogs */
424     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
425       if (isset($this->systab)){
426         del_lock ($this->systab->dn);
427         unset ($this->systab);
428       }
429       $this->systab= NULL;
430       unset($_SESSION['objectinfo']);
431     }
433     /* Show tab dialog if object is present */
434     if ($this->systab){
435       $display= $this->systab->execute();
437       /* Don't show buttons if tab dialog requests this */
438       if (!$this->systab->by_object[$this->systab->current]->dialog){
439         $display.= "<p style=\"text-align:right\">\n";
440         $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
441         $display.= "&nbsp;\n";
442         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
443         $display.= "</p>";
444       }
445       return ($display);
446     }
448     /* Show main page */
449     $smarty->assign("terminals", $this->convert_list($this->terminals));
450     $smarty->assign("search_image", get_template_path('images/search.png'));
451     $smarty->assign("tree_image", get_template_path('images/tree.png'));
452     $smarty->assign("infoimage", get_template_path('images/info.png'));
453     $smarty->assign("launchimage", get_template_path('images/launch.png'));
454     foreach( array("depselect", "user", "regex", "workstations", "thins", "servers",
455           "winstations", "printers", "phones", "netdev") as $type){
457       $smarty->assign("$type", $terminalfilter[$type]);
458     }
459     $smarty->assign("deplist", $this->config->idepartments);
461     /* Extend if we are not using javascript */
462     $smarty->assign("apply", apply_filter());
463     $smarty->assign("alphabet", generate_alphabet());
464     $smarty->assign("hint", print_sizelimit_warning());
466     return($smarty->fetch(get_template_path('headpage.tpl', TRUE)));
467   }
470   function convert_list($input)
471   {
472     $temp= "";
473     $conv= array(       "D" => "select_default.png",
474         "T" => "select_terminal.png",
475         "L" => "select_workstation.png",
476         "F" => "select_phone.png",
477         "S" => "select_server.png",
478         "NT" => "select_new_terminal.png",
479         "NL" => "select_new_workstation.png",
480         "W" => "select_winstation.png",
481         "C" => "select_component.png",
482         "P" => "select_printer.png");
484     foreach ($input as $key => $value){
485       $mode= preg_replace('/^.*(.)$/', '\\1', $value);
486       if ($mode == "D"){
487         $temp= "<option value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path('images/select_default.png')."');\">".preg_replace('/.$/', '', $value)."</option>\n".$temp;
488       } else {
489         if (preg_match('/^\+/', $value)){
490           $value= preg_replace('/^\+ /', '', $value);
491           $new= "N";
492         } else {
493           $new= "";
494         }
495         $temp.= "<option value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path('images/'.$conv["$new$mode"])."');\">".preg_replace('/.$/', '', $value)."</option>\n";
496       }
497     }
499     return ($temp);
500   }
502   function remove_from_parent()
503   {
504     /* Optionally execute a command after we're done */
505     $this->postremove();
506   }
509   /* Save data to object */
510   function save_object()
511   {
512   }
515   /* Check values */
516   function check()
517   {
518   }
521   /* Save to LDAP */
522   function save()
523   {
524   }
526   function adapt_from_template($dn)
527   {
528   }
530   function password_change_needed()
531   {
532   }
534   function show_header($button_text, $text, $disabled= FALSE)
535   {
536   }
538   function reload()
539   {
540     /* Load terminal shortcuts */
541     $responsible= array();
542     foreach ($this->config->departments as $key => $value){
543       if (get_module_permission(get_permissions ($value, $this->ui->subtreeACL),
544             "terminal", $value) == "#all#"){
545         $responsible[$key]= $value;
546       }
547     }
549     /* Get config */
550     $terminalfilter= get_global('terminalfilter');
551     $filter= "";
553     /* Set base for all searches */
554     $base= $terminalfilter['depselect'];
556     /* Regex filter? */
557     if ($terminalfilter['regex'] != ""){
558       $regex= $terminalfilter['regex'];
559     } else {
560       $regex= "*";
561     }
563     /* Get list of terminals to be shown */
564     if ($terminalfilter['thins'] == "checked"){
565       $termfilter= "(&(objectClass=gotoTerminal)(cn=$regex))";
566     } else {
567       $termfilter= "";
568     }
569     if ($terminalfilter['workstations'] == "checked"){
570       $workfilter= "(&(objectClass=gotoWorkstation)(cn=$regex))";
571     } else {
572       $workfilter= "";
573     }
574     if ($terminalfilter['winstations'] == "checked"){
575       if ($this->config->current['SAMBAVERSION'] == "3"){
576         $samba= "sambaSamAccount";
577       } else {
578         $samba= "sambaAccount";
579       }
580       $winfilter= "(&(objectClass=$samba)(cn=$regex\$))";
581     } else {
582       $winfilter= "";
583     }
584     if ($terminalfilter['printers'] == "checked"){
585       $printfilter= "(&(objectClass=gotoPrinter)(cn=$regex))";
586     } else {
587       $printfilter= "";
588     }
589     if ($terminalfilter['phones'] == "checked"){
590       $phonefilter= "(&(objectClass=goFonHardware)(cn=$regex))";
591     } else {
592       $phonefilter= "";
593     }
594     if ($terminalfilter['netdev'] == "checked"){
595       $netfilter= "(&(objectClass=ieee802Device)(cn=$regex))";
596     } else {
597       $netfilter= "";
598     }
599     if ($terminalfilter['servers'] == "checked"){
600       $serverfilter= "(&(objectClass=goServer)(cn=$regex))";
601     } else {
602       $serverfilter= "";
603     }
605     /* User filter? */
606     if ($terminalfilter['user'] != "" && $terminalfilter['user'] != "*"){
607       $filter.= "(gotoLastUser=".$terminalfilter['user'].")";
608     }
610     /* Get all gotoTerminal's */
611     $this->terminals= array();
613     $res= get_list($this->ui->subtreeACL, "(|$termfilter$workfilter$winfilter$printfilter$phonefilter$serverfilter$netfilter)", TRUE, $base, array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), TRUE);
614     foreach ($res as $value){
616       /* Look for new terminals and mark them with '+' */
617       $tmp= "";
618       if (preg_match('/,ou=terminals,ou=systems,/i', $value["dn"])){
619         $tmp= preg_replace("/^[^,]+,[^o]*ou=terminals,ou=systems,/i", "", $value["dn"]);
620       }
621       if (preg_match('/,ou=workstations,ou=systems,/i', $value["dn"])){
622         $tmp= preg_replace("/^[^,]+,[^o]*ou=workstations,ou=systems,/i", "", $value["dn"]);
623       }
624       if (preg_match('/,ou=servers,ou=systems,/i', $value["dn"])){
625         $tmp= preg_replace("/^[^,]+,[^o]*ou=servers,ou=systems,/i", "", $value["dn"]);
626       }
627       if (preg_match('/,'.get_winstations_ou().'/i', $value["dn"])){
628         $tmp= preg_replace("/^[^,]+,[^o]*".get_winstations_ou()."/i", "", $value["dn"]);
629       }
630       if (preg_match('/,ou=printers,ou=systems,/i', $value["dn"])){
631         $tmp= preg_replace("/^[^,]+,[^o]*ou=printers,ou=systems,/i", "", $value["dn"]);
632       }
633       if (preg_match('/,ou=phones,ou=systems,/i', $value["dn"])){
634         $tmp= preg_replace("/^[^,]+,[^o]*ou=phones,ou=systems,/i", "", $value["dn"]);
635       }
636       if (preg_match('/,ou=netdevices,ou=systems,/i', $value["dn"])){
637         $tmp= preg_replace("/^[^,]+,[^o]*ou=netdevices,ou=systems,/i", "", $value["dn"]);
638       }
639       if ($tmp == ""){
640         $tmp= $value["dn"];
641       }
642       if (preg_match ("/,ou=incoming,/i", $tmp)){
643         if (in_array('gotoTerminal', $value['objectClass'])){
644           $add= "+ "._("New terminal");
645         }
646         if (in_array('gotoWorkstation', $value['objectClass'])){
647           $add= "+ "._("New workstation");
648         }
649       } else {
650         $add= "";
651       }
653       if (in_array ($tmp, $responsible) || $add != ""){
654         if (in_array('gotoTerminal', $value["objectClass"])){
655           if (isset($value["macAddress"][0]) &&
656               $value["macAddress"][0] != "-"){
658             $this->terminals[$value["dn"]]= $add." ".
659               $value["cn"][0].
660               " [".$value["macAddress"][0]."]T";
661           } else {
662             $location= array_search($tmp, $this->config->departments);
663             $this->terminals[$value["dn"]]= _("Thin client template for").
664               " $location"."D";
665           }
666         } elseif (in_array('gotoWorkstation', $value["objectClass"])){
667           if (isset($value["macAddress"][0]) &&
668               $value["macAddress"][0] != "-"){
670             $this->terminals[$value["dn"]]= $add." ".
671               $value["cn"][0].
672               " [".$value["macAddress"][0]."]L";
673           } else {
674             $location= array_search($tmp, $this->config->departments);
675             $this->terminals[$value["dn"]]= _("Workstation template for").
676               " $location"."D";
677           }
678         } elseif (in_array('gotoPrinter', $value["objectClass"])){
679           if (isset($value['description'][0])){
680             $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]P";
681           } else {
682             $this->terminals[$value['dn']]= $value['cn'][0]."P";
683           }
684         } elseif (in_array('goServer', $value["objectClass"])){
685           if (isset($value['description'][0])){
686             $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]S";
687           } else {
688             $this->terminals[$value['dn']]= $value['cn'][0]."S";
689           }
690         } elseif (in_array('goFonHardware', $value["objectClass"])){
692           if (isset($value['description'][0])){
693             $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]F";
694           } else {
695             $this->terminals[$value['dn']]= $value['cn'][0]."F";
696           }
697         } elseif (in_array('ieee802Device', $value["objectClass"])){
699           if (isset($value['description'][0])){
700             $this->terminals[$value['dn']]= $value['cn'][0]." [".$value['description'][0]."]C";
701           } else {
702             $this->terminals[$value['dn']]= $value['cn'][0]."C";
703           }
704         } else{
705           $name= preg_replace('/\$$/', '', $value['cn'][0]);
706           if (isset($value['sambaDomainName'])){
707             $domain= " [".$value['sambaDomainName'][0]."]";
708           } else {
709             $domain= "";
710           }
711           $this->terminals[$value['dn']]= $name.$domain."W";
712         }
713       }
714     }
715     natcasesort ($this->terminals);
716     reset ($this->terminals);
717   }
719   function remove_lock()
720   {
721     if (isset($this->systab->dn)){
722       del_lock ($this->systab->dn);
723     }
724   }
727   function get_system_type($classes)
728   {
729     $type= "";
731     if (in_array('ieee802Device', $classes)){
732       $type= "component";
733     }
734     if (in_array('gotoTerminal', $classes)){
735       $type= "terminal";
736     }
737     if (in_array('gotoWorkstation', $classes)){
738       $type= "workstation";
739     }
740     if (in_array('gotoPrinter', $classes)){
741       $type= "printer";
742     }
743     if (in_array('goFonHardware', $classes)){
744       $type= "phone";
745     }
746     if (in_array('goServer', $classes)){
747       $type= "server";
748     }
749     if (in_array('sambaAccount', $classes) ||
750         in_array('sambaSamAccount', $classes)){
751       $type= "winstation";
752     }
754     return ($type);
755   }
759 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
760 ?>