Code

Applied new divlist management
[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";
34   var $departments=array();
36   /* Dialog attributes */
37   var $systab= NULL;
38   var $terminals= array();
39   var $ui= NULL;
40   var $acl= "";
41   var $DivListSystem;
43   function systems ($config, $ui)
44   {
45     /* Save configuration for internal use */
46     $this->config= $config;
47     $this->ui= $ui;
49     /* Creat dialog object */
50     $this->DivListSystem = new divListSystem($this->config,$this);
51   }
53   function execute()
54   {
55     /* Call parent execute */
56     plugin::execute();
58     $_SESSION['LOCK_VARS_TO_USE'] = array("/^user_edit_/i","/^user_del_/","/^act/","/^id/");
60     /********************
61       Check for functional posts, edit|delete|add|... system devices 
62      ********************/
63     $s_action     = "";                       // Contains the action to proceed
64     $s_entry      = "";                       // The value for s_action
65     $base_back    = "";                       // The Link for Backbutton
66     $smarty       = get_smarty();
68     /* Test Posts */
69     foreach($_POST as $key => $val){
70       // Post for delete
71       if(preg_match("/user_del.*/",$key)){
72         $s_action = "del";
73         $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
74         // Post for edit
75       }elseif(preg_match("/user_edit_.*/",$key)){
76         $s_action="edit";
77         $s_entry  = preg_replace("/user_".$s_action."_/i","",$key);
78         // Post for new
79       }elseif(preg_match("/user_new.*/",$key)){
80         $s_action="new";
81       }elseif(preg_match("/user_tplnew.*/i",$key)){
82         $s_action="new_tpl";
83       }elseif(preg_match("/user_setpwd_.*/i",$key)){
84         $s_action="change_pw";
85         $s_entry  = preg_replace("/user_setpwd_/i","",$key);
86       }elseif(preg_match("/newsystem_.*/i",$key)){
87         $s_action="newsystem";
88         $s_entry  = preg_replace("/newsystem_/i","",$key);
89       }
90     }
92     /* Incoming handling  
93      * If someone made a systemtype and ogroup selection 
94      * Display the new requested entry type ... servtab  in case of server and so on.
95      */
96     if(isset($_POST['SystemTypeChoosen'])){
97       $s_action = "SelectedSystemType";
98       $s_entry  = $_POST['SystemType'];
99       $this->systab = NULL;
100     }
102     /* remove image tags from posted entry  (posts looks like this 'name_x')*/
103     $s_entry  = preg_replace("/_.$/","",$s_entry);
105     /* Edit was requested by pressing the name(link) of an item */
106     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
107       $s_action ="edit";
108       $s_entry  = $_GET['id'];
109     }
111     /* Save Termfilter .... */
112     $this->reload();
114     /* Check for exeeded sizelimit */
115     if (($message= check_sizelimit()) != ""){
116       return($message);
117     }
119     /* Try to get informations about what kind of system to create */
120     if ($s_action=="new") {
121       return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
122     }
124     /********************
125       Create new system ...   
126      ********************/
127     /* Create new default terminal 
128      * Or create specified object of selected system type, from given incoming object  
129      */
130     if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") {
132       /* If the current entry is an incoming object 
133        * $sw = System type as posted in new incoming handling dialog 
134        */ 
135       if($s_action == "SelectedSystemType") {
136         $sw         = $s_entry;
137       }else{
138         if(isset($_POST['system'])){
139           $sw = $_POST['system'];
140         }else{
141           $sw = $s_entry;
142         }
143         $this->dn= "new";
144       }
145       $this->acl= array(":all");
146       $tabs = array(
147           "terminal"    => array("CLASS"=>"TERMTABS",     "TABNAME"=>"termgeneric",     "TABCLASS" =>"termtabs"),
148           "workstation" => array("CLASS"=>"WORKTABS",     "TABNAME"=>"workgeneric",     "TABCLASS" =>"worktabs"),
149           "server"      => array("CLASS"=>"SERVTABS",     "TABNAME"=>"servgeneric",     "TABCLASS" =>"servtabs"),
150           "printer"     => array("CLASS"=>"PRINTTABS",    "TABNAME"=>"printgeneric",    "TABCLASS" =>"printtabs"),
151           "phone"       => array("CLASS"=>"PHONETABS",    "TABNAME"=>"phonegeneric",    "TABCLASS" =>"phonetabs"),
152           "component"   => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentgeneric","TABCLASS" =>"componenttabs"));
154       if(isset($tabs[$sw])){
155         $class    = $tabs[$sw]["CLASS"];
156         $tabname  = $tabs[$sw]["TABNAME"];
157         $tabclass = $tabs[$sw]["TABCLASS"];
158         $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn);
159         $this->systab->set_acl ($this->acl);
160         $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
161         $this->systab->base = $this->DivListSystem->selectedBase;
162       }
163     }
165     /********************
166       Edit system ...   
167      ********************/
169     /* User wants to edit data? */
170     if (($s_action == "edit") && (!isset($this->systab->config))){
172       $this->dn= $this->terminals[$s_entry]['dn'];
174       /* Check locking, save current plugin in 'back_plugin', so
175          the dialog knows where to return. */
176       if (($user= get_lock($this->dn)) != ""){
177         return(gen_locked_message ($user, $this->dn));
178       }
180       /* Set up the users ACL's for this 'dn' */
181       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
183       /* Find out more about the object type */
184       $ldap= $this->config->get_ldap_link();
185       $ldap->cat($this->dn);
186       $attrs= $ldap->fetch();
187       $type= $this->get_system_type($attrs['objectClass']);
189       /* Lock the current entry, so everyone will get the
190          above dialog */
191       $tabs = array(
192           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs"),
193           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs"),
194           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs"),
195           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs"),
196           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs"),
197           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs"),
198           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs"));
201       if($type == "NewDevice"){
202         $this->systab = new SelectDeviceType($this->config,$this->dn) ;
203       }elseif(isset($tabs[$type])){
205         $class    = $tabs[$type]["CLASS"];
206         $tabclass = $tabs[$type]["TABCLASS"];
208         $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn);
209         $this->systab->set_acl($acl);
210         $_SESSION['objectinfo']= $this->dn;
211         add_lock ($this->dn, $this->ui->dn);
212       }else{ 
213         print_red (_("You can't edit this object type yet!"));
214         del_lock($this->dn);
215       }
216     }
219     /********************
220       Change password ...   
221      ********************/
223     /* Set terminals root password */
224     if ($s_action=="change_pw"){
225       $this->dn= $this->terminals[$s_entry]['dn'];
226       $_SESSION['objectinfo']= $this->dn;
227       return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
228     }
231     /********************
232       Password cahnge finish, but check if entered data is ok 
233      ********************/
235     /* Correctly specified? */
236     if (isset($_POST['password_finish'])){
237       if ($_POST['new_password'] != $_POST['repeated_password']){
238         print_red (_("Passwords entered as new and repeated do not match!"));
239         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
240       }
241     }
243     /********************
244       Password change finish
245      ********************/
247     /* Change terminal password */
248     if (isset($_POST['password_finish']) && 
249         $_POST['new_password'] == $_POST['repeated_password']){
251       /* Check if user is allowed to set password */
252       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
253       $acl= get_module_permission($acl, "terminal", $this->dn);
254       if (chkacl($acl, "password") != ""){
255         print_red (_("You are not allowed to set this systems password!"));
256       } else {
257         $ldap= $this->config->get_ldap_link();
258         $ldap->cd($this->dn);
260         $attrs= array();
261         if ($_POST['new_password'] == ""){
262           $attrs['gotoRootPasswd']= array();
263         } else {
264           $attrs['gotoRootPasswd']= crypt($_POST['new_password'],
265               substr(session_id(),0,2));
266         }
267         $ldap->modify($attrs);
268         gosa_log ("Password for '".$this->dn."' has been changed");
269       }
270       unset($_SESSION['objectinfo']);
271     }
274     /********************
275       Delete system cancel
276      ********************/
278     /* Delete terminal canceled? */
279     if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
280       del_lock ($this->dn);
281       unset($_SESSION['objectinfo']);
282     }
285     /********************
286       Delete system, confirm dialog
287      ********************/
289     /* Remove terminal was requested */
290     if ($s_action=="del"){
292       /* Get 'dn' from posted termlinst */
293       $this->dn= $this->terminals[$s_entry]['dn'];
295       /* Load permissions for selected 'dn' and check if
296          we're allowed to remove this 'dn' */
297       $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
298       $this->acl= get_module_permission($acl, "terminal", $this->dn);
299       if (chkacl($this->acl, "delete") == ""){
301         /* Check locking, save current plugin in 'back_plugin', so
302            the dialog knows where to return. */
303         if (($user= get_lock($this->dn)) != ""){
304           return(gen_locked_message ($user, $this->dn));
305         }
307         /* Lock the current entry, so nobody will edit it during deletion */
308         add_lock ($this->dn, $this->ui->dn);
309         $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), LDAP::fix($this->dn)));
310         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
311       } else {
313         /* Obviously the user isn't allowed to delete. Show message and
314            clean session. */
315         print_red (_("You are not allowed to delete this component!"));
316       }
317     }
320     /********************
321       Delete system, confirmed
322      ********************/
323     /* Confirmation for deletion has been passed. Terminal should be deleted. */
324     if (isset($_POST['delete_terminal_confirm'])){
326       /* Some nice guy may send this as POST, so we've to check
327          for the permissions again. */
328       if (chkacl($this->acl, "delete") == ""){
330         /* Find out more about the object type */
331         $ldap= $this->config->get_ldap_link();
332         $ldap->cat($this->dn);
333         $attrs= $ldap->fetch();
334         $type= $this->get_system_type($attrs['objectClass']);
336         $tabs = array(
337             "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs"),
338             "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs"),
339             "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs"),
340             "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs"),
341             "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs"),
342             "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs"),
343             "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs"));
345         /* get object type */
346         $tabtype  = "termtabs";
347         $tabobj   = "TERMTABS";
348         if(isset($tabs[$type])){
349           $tabtype = $tabs[$type]['TABCLASS'];
350           $tabobj  = $tabs[$type]['CLASS'];
351         }
353         /* Delete request is permitted, perform LDAP action */
354         if($tabtype=="phonetabs"){
355           $this->systab= new $tabtype($this->config,
356               $this->config->data['TABS'][$tabobj], $this->dn);
357           $this->systab->set_acl(array($this->acl));
358           $this->systab->by_object['phonegeneric']->remove_from_parent ();
359         }else{  
360           $this->systab= new $tabtype($this->config,
361               $this->config->data['TABS'][$tabobj], $this->dn);
362           $this->systab->set_acl(array($this->acl));
363           $this->systab->delete();
364 #$this->systab->by_object['termgeneric']->remove_from_parent ();
365         }
366         unset ($this->systab);
367         gosa_log ("System object'".$this->dn."' has been removed");
368         $this->systab= NULL;
370         /* Terminal list has changed, reload it. */
371         $this->reload ();
372       } else {
374         /* Normally this shouldn't be reached, send some extra
375            logs to notify the administrator */
376         print_red (_("You are not allowed to delete this component!"));
377         gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
378             "deletion.");
379       }
381       /* Remove lock file after successfull deletion */
382       del_lock ($this->dn);
383     }
386     /********************
387       Edit system type finished, check if everything went ok 
388      ********************/
389     /* Finish user edit is triggered by the tabulator dialog, so
390        the user wants to save edited data. Check and save at this
391        point. */
392     if ((isset($_POST['edit_finish'])) && (isset($this->systab->config))){
394       /* Check tabs, will feed message array */
395       $message= $this->systab->check();
397       /* Save, or display error message? */
398       if (count($message) == 0){
400         /* Save terminal data to ldap */
401         gosa_log ("System object'".$this->dn."' has been saved");
402         $this->systab->save();
404         /* Incoming behavior; you can select a system type and an ogroup membership. 
405          * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset.
406          * Check if we must add the new object to an object group.
407          * 
408          * If this is done, delete the old incoming entry... it is still there, because this is a new 
409          * entry and not an edited one, so we will delete it.
410          */
411         if(isset($_SESSION['SelectedSystemType'])){
412           $SelectedSystemType= $_SESSION['SelectedSystemType'];
413           unset($_SESSION['SelectedSystemType']);
414           if($SelectedSystemType['ogroup'] != "none"){
415             $og = new ogroup($this->config,$SelectedSystemType['ogroup']);
416             if($og){
417               $og->AddDelMembership($this->systab->dn);
418             }
419             $og->save();
420           }
421           if(!isset($ldap)){
422             $ldap = $this->config->get_ldap_link();
423           }
424           $ldap->cd ($this->dn);
425           $ldap->cat($this->dn);  
426           if(count($ldap->fetch())){
427             $ldap->cd($this->dn);
428             $ldap->rmDir($this->dn);
429           }
430           $ldap->cd($this->config->current['BASE']);
431         }
433         /* Terminal has been saved successfully, remove lock from
434            LDAP. */
435         if ($this->dn != "new"){
436           del_lock ($this->dn);
437         }
439         /* There's no page reload so we have to read new terminals at
440            this point. */
441         $this->reload ();
442         unset ($this->systab);
443         $this->systab= NULL;
444         unset($_SESSION['objectinfo']);
445       } else {
446         /* Ok. There seem to be errors regarding to the tab data,
447            show message and continue as usual. */
448         show_errors($message);
449       }
450     }
452     /********************
453       Edit system was canceled 
454      ********************/
455     /* Cancel dialogs */
456     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){
457       if (isset($this->systab)){
458         del_lock ($this->systab->dn);
459         unset ($this->systab);
460       }
461       $this->systab= NULL;
462       unset($_SESSION['objectinfo']);
464       /* Remove ogroup selection, which was set while editing a new incoming entry */
465       if(isset($_SESSION['SelectedSystemType'])){
466         unset($_SESSION['SelectedSystemType']);
467       }
468     }
470     /********************
471       Display edit dialog, or some other
472      ********************/
474     /* Show tab dialog if object is present */
475     if (isset($this->systab->config)){
476       $display= $this->systab->execute();
478       /* Don't show buttons if tab dialog requests this */
479       if ((isset($this->systab->by_object))&&(!$this->systab->by_object[$this->systab->current]->dialog)){
480         $display.= "<p style=\"text-align:right\">\n";
481         $display.= "<input type=\"submit\" name=\"edit_finish\" value=\""._("Save")."\">\n";
482         $display.= "&nbsp;\n";
483         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
484         $display.= "</p>";
485       }
486       return ($display);
487     }
489     /* Display dialog with system list */
490     $this->DivListSystem->execute();
491     $this->DivListSystem->setEntries($this->terminals);
492     return($this->DivListSystem->Draw());
493   }
497   function remove_from_parent()
498   {
499     /* Optionally execute a command after we're done */
500     $this->postremove();
501   }
504   /* Save data to object */
505   function save_object()
506   {
507     $this->DivListSystem->save_object();
508   }
511   /* Check values */
512   function check()
513   {
514   }
517   /* Save to LDAP */
518   function save()
519   {
520   }
522   function adapt_from_template($dn)
523   {
524   }
526   function password_change_needed()
527   {
528   }
530   function reload()
531   {
532     /* Load terminal shortcuts */
533     $responsible= array();
534     foreach ($this->config->departments as $key => $value){
535       if (get_module_permission(get_permissions ($value, $this->ui->subtreeACL),
536             "terminal", $value) == "#all#"){
537         $responsible[$key]= $value;
538       }
539     }
541     /* some var init */
542     $res              = array();
543     $this->terminals  = array();
544     $userregex        = "";
546     /* Set base for all searches */
547     $base=  $this->DivListSystem->selectedBase;
549     /* Prepare samba class name */
550     $samba  ="";
551     if ($this->DivListSystem->ShowWinWorkstations){
552       if ($this->config->current['SAMBAVERSION'] == "3"){
553         $samba= "sambaSamAccount";
554       } else {
555         $samba= "sambaAccount";
556       }
557     }
559     /* This array represents the combination between checkboxes and search filters */
560     $objs = array( "ShowServers"        => array("CLASS" => "goServer"        ,"TREE" => "ou=servers,ou=systems," ),
561         "ShowTerminals"      => array("CLASS" => "goHard"          ,"TREE" => "ou=terminals,ou=systems,"), 
562         "ShowPrinters"       => array("CLASS" => "gotoPrinter"     ,"TREE" => "ou=printers,ou=systems," ),
563         "ShowDevices"        => array("CLASS" => "ieee802Device"   ,"TREE" => "ou=netdevices,ou=systems," ),
564         "ShowPhones"         => array("CLASS" => "goFonHardware"   ,"TREE" => "ou=phones,ou=systems," ),
565         "ShowWorkstations"   => array("CLASS" => "gotoWorkstation" ,"TREE" => "ou=workstations,ou=systems," ),
566         "ShowWinWorkstations"=> array("CLASS" => $samba            ,"TREE" => get_winstations_ou() ));
568     /* Include the 'Display Systems of user' attribute */ 
569     if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){
570       $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")";
571     }
573     /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled  */
574     foreach($objs as $checkBox => $oc){
576       if($this->DivListSystem->$checkBox){
577         /* User filter? */
578         if($oc['CLASS'] != ""){
579           $filter = "(|(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex.")))";
580           $res = array_merge($res,get_list($filter,$this->ui->subtreeACL, $oc['TREE'].$base,
581                 array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), GL_NONE));
582         }
583       } 
584     }
586     /* Search for incoming objects */ 
587     $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
588     $res = array_merge($res,get_list($filter,$this->ui->subtreeACL, "ou=incoming,".$base,
589           array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), GL_NONE));
591     /* Get all gotoTerminal's */
592     foreach ($res as $value){
594       $tmp= $value['dn'];
595       $add= "";
597       /* Extract base */
598       foreach($objs as $obj){
599         if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){
600           $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn']));
601         }
602       }
604       /* check if current object is a new one */
605       if (preg_match ("/,ou=incoming,/i", $tmp)){
606         if (in_array('gotoTerminal', $value['objectClass'])){
607           $add= "- "._("New terminal");
608         }elseif (in_array('gotoWorkstation', $value['objectClass'])){
609           $add= "- "._("New workstation");
610         }elseif (in_array('GOhard', $value['objectClass'])){
611           $add= "- "._("New Device");
612         }
613       } 
615       /* Detect type of object and create an entry for $this->terminals */
616       $terminal = array();
617       if ((in_array ($tmp, $responsible)) || ($add != "")){
618         if (in_array('gotoTerminal', $value["objectClass"])){
619           if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
620             $terminal             = $value;
621             $terminal['type']     = "T";
622             $terminal['is_new']   = $add;
623           } else {
624             $terminal             = $value;
625             $terminal['type']     = "D";
626             $terminal['message']  = _("Terminal template for");
627             $terminal['location'] = array_search($tmp, $this->config->departments); 
628           }
629         } elseif (in_array('gotoWorkstation', $value["objectClass"])){
630           if (isset($value["macAddress"][0]) &&  $value["macAddress"][0] != "-"){
631             $terminal             = $value;
632             $terminal['type']     = "L";
633             $terminal['is_new']   = $add;
634           } else {
635             $terminal             = $value;
636             $terminal['type']     = "D";
637             $terminal['location'] = array_search($tmp, $this->config->departments);
638             $terminal['message']  = _("Workstation template for");
639           }
640         } elseif (in_array('gotoPrinter', $value["objectClass"])){
641           $terminal             = $value;
642           $terminal['type']     = "P";
643         } elseif (in_array('goServer', $value["objectClass"])){
644           $terminal             = $value;
645           $terminal['type']     = "S";
646         } elseif (in_array('goFonHardware', $value["objectClass"])){
647           $terminal             = $value;
648           $terminal['type']     = "F";
649         }elseif (in_array("GOhard",$value['objectClass'])){
650           $terminal = $value;
651           $terminal['type']   = "Q";
652           $terminal['is_new'] = $add;
653         } elseif (in_array('ieee802Device', $value["objectClass"])){
654           $terminal             = $value;
655           $terminal['type']     = "C";
656         } else{
657           $name= preg_replace('/\$$/', '', $value['cn'][0]);
658           if (isset($value['sambaDomainName'])){
659             $domain= " [".$value['sambaDomainName'][0]."]";
660           } else {
661             $domain= "";
662           }
663           $terminal=$value;
664           $terminal['type']     ="W";
665           $terminal['domain']   = $name.$domain;
666         }
667         $this->terminals[]=$terminal;
668       }
669     }
671     $tmp=array();
672     foreach($this->terminals as $tkey => $val ){
673       $tmp[strtolower($val['cn'][0]).$val['dn']]=$val;
674     }
675     ksort($tmp);
676     $this->terminals=array();
677     foreach($tmp as $val){
678       $this->terminals[]=$val;
679     }
680     reset ($this->terminals);
681   }
683   function remove_lock()
684   {
685     if (isset($this->systab->dn)){
686       del_lock ($this->systab->dn);
687     }
688   }
691   function get_system_type($classes)
692   {
693     $type= "";
694     if (in_array('ieee802Device', $classes)){
695       $type= "component";
696     }elseif (in_array('gotoTerminal', $classes)){
697       $type= "terminal";
698     }elseif (in_array('gotoWorkstation', $classes)){
699       $type= "workstation";
700     }elseif (in_array('gotoPrinter', $classes)){
701       $type= "printer";
702     }elseif (in_array('goFonHardware', $classes)){
703       $type= "phone";
704     }elseif (in_array('goServer', $classes)){
705       $type= "server";
706     }elseif (in_array('GOhard', $classes)){
707       $type= "NewDevice";
708     }elseif (in_array('sambaAccount', $classes) ||
709         in_array('sambaSamAccount', $classes)){
710       $type= "winstation";
711     }
712     return ($type);
713   }
716   function convert_list($input)
717   {
718     $temp= "";
719     $conv= array(       
720         "NQ" => array("select_newsystem.png",_("New System from incoming")),
721         "D" => array("select_default.png",_("Template")),
722         "T" => array("select_terminal.png",_("Terminal")),
723         "L" => array("select_workstation.png",_("Workstation")),
724         "F" => array("select_phone.png",_("Phone")),
725         "S" => array("select_server.png",_("Server")),
726         "W" => array("select_winstation.png",_("Winstation")),
727         "C" => array("select_component.png",_("Network Device")),
728         "NT"=> array("select_new_terminal.png",_("New Terminal")),
729         "NL"=> array("select_new_workstation.png",_("New Workstation")),
730         "P" => array("select_printer.png",_("Printer")));
732     if((isset($input['is_new']))&&(!empty($input['is_new']))){
733       $input['type']="N".$input['type'];
734     }
735     foreach ($conv  as $key => $value){
736       if($input['type']==$key){
737         $tmp['img'] ="<img class='center' src='images/".$value[0]."' alt='".$key."' title='".$value['1']."'>";
738         $tmp['class']=$key;
739         return $tmp;
740       }
741     }
742   }
746 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
747 ?>