Code

Updated workstation - Startup
[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  */
21 class systems extends plugin
22 {
23   /* Definitions */
24   var $plHeadline     = "Systems";
25   var $plDescription  = "This does something";
26   var $departments    = array();
28   /* Dialog attributes */
29   var $systab   = NULL;
30   var $terminals= array();
31   var $ui       = NULL;
32   var $DivListSystem;
33   var $start_pasting_copied_objects = FALSE;
34   var $CopyPasteHandler   = NULL;
36   function systems (&$config, $ui)
37   {
38     /* Save configuration for internal use */
39     $this->config= $config;
40     $this->ui= $ui;
42     /* Creat dialog object */
43     $this->DivListSystem = new divListSystem($this->config,$this);
45     /* Copy & Paste enabled ?*/
46     if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
47       $this->CopyPasteHandler = new CopyPasteHandler($this->config);
48     }
49   }
52   function execute()
53   {
54     /* Call parent execute */
55     plugin::execute();
57     $_SESSION['LOCK_VARS_TO_USE'] = array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/");
59     /********************
60       Check for functional posts, edit|delete|add|... system devices 
61      ********************/
62     $s_action     = "";                       // Contains the action to proceed
63     $s_entry      = "";                       // The value for s_action
64     $base_back    = "";                       // The Link for Backbutton
65     $smarty       = get_smarty();
67     /* Test Posts */
68     foreach($_POST as $key => $val){
69       // Post for delete
70       if(preg_match("/system_del.*/",$key)){
71         $s_action = "del";
72         $s_entry  = preg_replace("/system_del_/i","",$key);
73         // Post for edit
74       }elseif(preg_match("/system_edit_.*/",$key)){
75         $s_action="edit";
76         $s_entry  = preg_replace("/system_edit_/i","",$key);
77         // Post for new
78       }elseif(preg_match("/system_new.*/",$key)){
79         $s_action="new";
80       }elseif(preg_match("/system_tplnew.*/i",$key)){
81         $s_action="new_tpl";
82       }elseif(preg_match("/system_setpwd_.*/i",$key)){
83         $s_action="change_pw";
84         $s_entry  = preg_replace("/system_setpwd_/i","",$key);
85       }elseif(preg_match("/gen_cd_.*/i",$key)){
86         $s_action="gen_cd";
87         $s_entry  = preg_replace("/gen_cd_/i","",$key);
88       }elseif(preg_match("/^copy_.*/",$key)){
89         $s_action="copy";
90         $s_entry  = preg_replace("/^copy_/i","",$key);
91       }elseif(preg_match("/^cut_.*/",$key)){
92         $s_action="cut";
93         $s_entry  = preg_replace("/^cut_/i","",$key);
94       }
95     }
96    
97     /* Incoming handling  
98      * If someone made a systemtype and ogroup selection 
99      * Display the new requested entry type ... servtab  in case of server and so on.
100      */
101     if(isset($_POST['SystemTypeChoosen'])){
102       $s_action = "SelectedSystemType";
103       $s_entry  = $_POST['SystemType'];
104       $_SESSION['SelectedSystemType']['ogroup'] = $_POST['ObjectGroup'];
105       $this->systab = NULL;
106     }
108     /* remove image tags from posted entry  (posts looks like this 'name_x')*/
109     $s_entry  = preg_replace("/_.$/","",$s_entry);
111     /* Edit was requested by pressing the name(link) of an item */
112     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
113       $s_action ="edit";
114       $s_entry  = $_GET['id'];
115     }
116     /* Create options */
117     if(isset($_POST['menu_action']) && preg_match("/^newsystem_/",$_POST['menu_action'])){
118       $s_action = "newsystem";
119       $s_entry  = preg_replace("/^newsystem_/","",$_POST['menu_action']);
120     }
122     /* handle C&P from layers menu */
123     if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
124       $s_action = "copy_multiple";
125     }
126     if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
127       $s_action = "cut_multiple";
128     }
129     if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
130       $s_action = "editPaste";
131     }
133     /* handle remove from layers menu */
134     if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
135       $s_action = "del_multiple";
136     }
137     
139     /* Check for exeeded sizelimit */
140     if (($message= check_sizelimit()) != ""){
141       return($message);
142     }
144     /* Try to get informations about what kind of system to create */
145     if ($s_action=="new") {
146       return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
147     }
150     /********************
151       Copy & Paste Handling  ...
152      ********************/
154     /* Display the copy & paste dialog, if it is currently open */
155     $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
156     if($ret){
157       return($ret);
158     }
159   
161     /********************
162       Create FAI CD ...   
163      ********************/
164     if ($s_action=="gen_cd"){
165       $this->dn= $this->terminals[$s_entry]['dn'];
166       $_SESSION['objectinfo']= $this->dn;
167       return ($smarty->fetch(get_template_path('gencd.tpl', TRUE)));
168     }
171     /* Start CD-Creation */
172     if ((isset($_POST["cd_create"])) && !empty($this->dn)){
173       $smarty->assign("src", "?plug=".$_GET['plug']."&amp;PerformIsoCreation");
174       return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE)));
175     }
178     if ($this->dn != "" && isset($_GET['PerformIsoCreation'])){
180       $return_button   = "<form method='get' action='main.php' target='_parent'>
181         <input type='submit' value='"._("Back")."'>
182         <input type='hidden' name='plug' value='".$_GET['plug']."'/>
183         </form>";
185       $dsc             = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
187       /* Get and check command */
188       $command= $this->config->search("workgeneric", "ISOCMD",array('tabs'));
189       
190       if (check_command($command)){
191         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
193         /* Print out html introduction */
194         echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
195           <html>
196           <head>
197           <title></title>
198           <style type="text/css">@import url("themes/default/style.css");</style>
199           <script language="javascript" src="include/focus.js" type="text/javascript"></script>
200           </head>
201           <body style="background: none; margin:4px;" id="body" >
202           <pre>';
204         /* Open process handle and check if it is a valid process */
205         $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
206         if (is_resource($process)) {
207           fclose($pipes[0]);
209           /* Print out returned lines && write JS to scroll down each line */
210           while (!feof($pipes[1])){
211             $cur_dat = fgets($pipes[1], 1024);
212             echo $cur_dat;
213             echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
214             flush();
215           }
216         }
218         /* Get error string && close streams */
219         $buffer= stream_get_contents($pipes[2]);
221         fclose($pipes[1]);
222         fclose($pipes[2]);
223         echo "</pre>";
225         /* Check return code */
226         $ret= proc_close($process);
227         if ($ret != 0){
228           echo "<h1 style='color:red'>"._("Creating the image failed. Please see the report below.")."</h1>";
229           echo "<pre style='color:red'>$buffer</pre>";
230         }
234         echo $return_button."<br>";
236       } else {
237         $tmp= "<h1 style='color:red'>".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."</h1>";
238         echo $tmp;
239       }
241       /* Scroll down completly */
242       echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
243       echo '</body></html>';
244       flush();
245       exit;
246     }
249     /********************
250       Create new system ...   
251      ********************/
252     /* Create new default terminal 
253      * Or create specified object of selected system type, from given incoming object  
254      */
256     $save_object_directly = false;
257     if(($s_action == "SelectedSystemType") && (isset($_POST['ObjectGroup']) && ($_POST['ObjectGroup'] != "none"))){
258       $save_object_directly = true;
259     }
261     if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") {
263       /* If the current entry is an incoming object 
264        * $sw = System type as posted in new incoming handling dialog 
265        */ 
266       if($s_action == "SelectedSystemType") {
267         $sw         = $s_entry;
268       }else{
269         if(isset($_POST['system'])){
270           $sw = $_POST['system'];
271         }else{
272           $sw = $s_entry;
273         }
274         $this->dn= "new";
275       }
277       $tabs = array(
278           "terminal"    => array("CLASS"=>"TERMTABS",     "TABNAME"=>"termgeneric",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
279           "workstation" => array("CLASS"=>"WORKTABS",     "TABNAME"=>"workgeneric",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"),
280           "server"      => array("CLASS"=>"SERVTABS",     "TABNAME"=>"servgeneric",     "TABCLASS" =>"servtabs",      "ACL"=> "server"),
281           "printer"     => array("CLASS"=>"PRINTTABS",    "TABNAME"=>"printgeneric",    "TABCLASS" =>"printtabs",     "ACL"=> "printer"),
282           "phone"       => array("CLASS"=>"PHONETABS",    "TABNAME"=>"phoneGeneric",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone"),
283           "component"   => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentGeneric","TABCLASS" =>"componenttabs", "ACL"=> "component"));
285       if(isset($tabs[$sw])){
286         $class    = $tabs[$sw]["CLASS"];
287         $tabname  = $tabs[$sw]["TABNAME"];
288         $tabclass = $tabs[$sw]["TABCLASS"];
289         $acl_cat  = $tabs[$sw]["ACL"];
291         /* Load permissions for selected 'dn' and check if
292            we're allowed to remove this 'dn' */
293         $ui       = get_userinfo();
294         $tabacl   = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname);
295         if(preg_match("/c/",$tabacl)){
296           $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
297           $this->systab->set_acl_base($this->DivListSystem->selectedBase);
298           $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
299           $this->systab->base = $this->DivListSystem->selectedBase;
300         }else{
301           print_red(_("You are not allowed to create a new object of this type."));
302         }
303       }
304     }
306     /********************
307       Edit system ...   
308      ********************/
310     /* User wants to edit data? */
311     if (($s_action == "edit") && (!isset($this->systab->config))){
313       $this->dn= $this->terminals[$s_entry]['dn'];
315       /* Check locking, save current plugin in 'back_plugin', so
316          the dialog knows where to return. */
317       if (($user= get_lock($this->dn)) != ""){
318         return(gen_locked_message ($user, $this->dn));
319       }
321       /* Find out more about the object type */
322       $ldap= $this->config->get_ldap_link();
323       $ldap->cat($this->dn, array('objectClass','gotoMode'));
324       $attrs= $ldap->fetch();
325       $type= $this->get_system_type($attrs);
327       /* Lock the current entry, so everyone will get the
328          above dialog */
329       $tabs = array(
330           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
331           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"),
332           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server"),
333           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer"),
334           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone"),
335           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation"),
336           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component"));
339       if($type == "ArpNewDevice"){
340         $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn);
341       }elseif($type == "NewDevice"){
342         $this->systab = new SelectDeviceType($this->config,$this->dn) ;
343       }elseif(isset($tabs[$type])){
345         $class    = $tabs[$type]["CLASS"];
346         $acl_cat  = $tabs[$type]["ACL"];
347         $tabclass = $tabs[$type]["TABCLASS"];
349         $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat);
350         $this->systab->set_acl_base($this->dn);
351         $_SESSION['objectinfo']= $this->dn;
352         add_lock ($this->dn, $this->ui->dn);
353       }else{ 
354         print_red (_("You can't edit this object type yet!"));
355         del_lock($this->dn);
356       }
357     }
360     /********************
361       Change password ...   
362      ********************/
364     /* Set terminals root password */
365     if ($s_action=="change_pw"){
366       $tabs = array(
367           "terminal"    => array("CLASS"=>"TERMTABS",     "TABNAME"=>"termgeneric",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
368           "workstation" => array("CLASS"=>"WORKTABS",     "TABNAME"=>"workgeneric",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"));
370       $type = $this->get_system_type($this->terminals[$s_entry]);
371       $class    = $tabs[$type]["CLASS"];
372       $tabname  = $tabs[$type]["TABNAME"];
373       $acl_cat  = $tabs[$type]["ACL"];
374       $tabclass = $tabs[$type]["TABCLASS"];
375       $ui       = get_userinfo();
376       $tabacl   = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
377       if(preg_match("/w/",$tabacl)){
378         $this->dn= $this->terminals[$s_entry]['dn'];
379         $_SESSION['objectinfo']= $this->dn;
380         return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
381       }else{
382         print_red(_("You are not allowed to change the password for this object."));
383       }
384     }
387     /********************
388       Password change finish, but check if entered data is ok 
389      ********************/
391     /* Correctly specified? */
392     if (isset($_POST['password_finish'])){
393       if ($_POST['new_password'] != $_POST['repeated_password']){
394         print_red (_("Passwords entered as new and repeated do not match!"));
395         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
396       }
397     }
399     /********************
400       Password change finish
401      ********************/
403     /* Change terminal password */
404     if (isset($_POST['password_finish']) && 
405         $_POST['new_password'] == $_POST['repeated_password']){
407       /* Check if user is allowed to set password */
408       $tabs = array(
409           "terminal"    => array("CLASS"=>"TERMTABS",     "TABNAME"=>"termgeneric",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
410           "workstation" => array("CLASS"=>"WORKTABS",     "TABNAME"=>"workgeneric",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"));
412       /* Detect object type */
413       $type = "";
414       foreach($this->terminals as $terminal){
415         if($terminal['dn'] == $this->dn){
416           $type = $this->get_system_type($terminal);
417           break;
418         } 
419       }
421       /* Type detected */
422       if(!empty($type)){
424         /* Get infos */
425         $class    = $tabs[$type]["CLASS"];
426         $tabname  = $tabs[$type]["TABNAME"];
427         $acl_cat  = $tabs[$type]["ACL"];
428         $tabclass = $tabs[$type]["TABCLASS"];
429     
430         /* Get acls */
431         $ui       = get_userinfo();
432         $tabacl   = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
434         /* Check acls */
435         if(preg_match("/w/",$tabacl)){
436           $ldap = $this->config->get_ldap_link();
437           $ldap->cd($this->dn);
439           $attrs= array();
440           if ($_POST['new_password'] == ""){
441             $attrs['gotoRootPasswd']= array();
442           } else {
443             $attrs['gotoRootPasswd']= crypt($_POST['new_password'],substr(session_id(),0,2));
444           }
445           $ldap->modify($attrs);
446           new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error());
447         }else{
448           print_red(_("You are not allowed to change the password for this object."));
449         }
450       }else{
451         print_red(_("Can't detect object to change password."));
452       }
453       unset($_SESSION['objectinfo']);
454     }
457     /********************
458       Delete system cancel
459      ********************/
461     /* Delete terminal canceled? */
462     if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
463       del_lock ($this->dn);
464       unset($_SESSION['objectinfo']);
465     }
468     /********************
469       Delete MULTIPLE entries requested, display confirm dialog
470      ********************/
472     if ($s_action=="del_multiple"){
473       $this->dns = array();
474       $ids = $this->list_get_selected_items();
476       if(count($ids)){
478         foreach($ids as $id){
479           $dn = $this->terminals[$id]['dn'];
480           if (($user= get_lock($dn)) != ""){
481             return(gen_locked_message ($user, $dn));
482           }
483           $this->dns[$id] = $dn;
484         }
486         $dns_names = "<br><pre>";
487         foreach($this->dns as $dn){
488           add_lock ($dn, $this->ui->dn);
489           $dns_names .= $dn."\n";
490         }
491         $dns_names .="</pre>";
493         /* Lock the current entry, so nobody will edit it during deletion */
494         if (count($this->dns) == 1){
495           $smarty->assign("warning",     sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
496         } else {
497           $smarty->assign("warning",     sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
498         }
499         $smarty->assign("multiple", true);
500         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
501       }
502     }
505     /********************
506       Delete MULTIPLE entries confirmed
507      ********************/
509     /* Confirmation for deletion has been passed. Users should be deleted. */
510     if (isset($_POST['delete_multiple_system_confirm'])){
512       $ui = get_userinfo();
513       $tabs = array(
514           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal/termgeneric"),
515           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation/workgeneric"),
516           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server/servgeneric"),
517           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer/printgeneric"),
518           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone/phoneGeneric"),
519           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation/wingeneric"),
520           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
523       /* Remove user by user and check acls before removeing them */
524       foreach($this->dns as $key => $dn){
526         /* Get 'dn' from posted termlinst */
527         $attrs    = $this->terminals[$key];
528         $type= $this->get_system_type($attrs);
530         /* get object type */
531         $tabtype  = "termtabs";
532         $tabobj   = "TERMTABS";
533         $tabacl   = "";
534         if(isset($tabs[$type])){
535           $tabtype = $tabs[$type]['TABCLASS'];
536           $tabobj  = $tabs[$type]['CLASS'];
537           $tabacl  = $ui->get_permissions($dn,$tabs[$type]['ACL']);
539           /* Load permissions for selected 'dn' and check if
540              we're allowed to remove this 'dn' */
541           if(preg_match("/d/",$tabacl)){ 
543             /* Delete request is permitted, perform LDAP action */
544             if($tabtype=="phonetabs"){
545               $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
546               $this->systab->set_acl_base($dn);
547               $this->systab->by_object['phoneGeneric']->remove_from_parent ();
548             }else{
549               $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $dn,$type);
550               $this->systab->set_acl_base($dn);
551               $this->systab->delete();
552             }
553             unset ($this->systab);
554             $this->systab= NULL;
556           } else {
557             /* Normally this shouldn't be reached, send some extra
558                logs to notify the administrator */
559             print_red (_("You are not allowed to delete this component!"));
560             new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
561           }
562           /* Remove lock file after successfull deletion */
563           del_lock ($dn);
564           unset($this->dns[$key]);
565         }
566       }
567     }
569     /********************
570       Delete MULTIPLE entries Canceled
571      ********************/
573     /* Remove lock */
574    if(isset($_POST['delete_multiple_system_cancel'])){
575       foreach($this->dns as $key => $dn){
576         del_lock ($dn);
577         unset($this->dns[$key]);
578       }
579     }
582     /********************
583       Delete system, confirm dialog
584      ********************/
586     /* Remove terminal was requested */
587     if ($s_action=="del"){
589       /* Get 'dn' from posted termlinst */
590       $this->dn = $this->terminals[$s_entry]['dn'];
591       $attrs    = $this->terminals[$s_entry];
593       $type= $this->get_system_type($attrs);
594       $ui = get_userinfo();
595       $tabs = array(
596           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal/termgeneric"),
597           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation/workgeneric"),
598           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server/servgeneric"),
599           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer/printgeneric"),
600           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone/phoneGeneric"),
601           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation/wingeneric"),
602           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
605       /* get object type */
606       $tabtype  = "termtabs";
607       $tabobj   = "TERMTABS";
608       $tabacl   = "";
609       if(isset($tabs[$type])){
610         $tabtype = $tabs[$type]['TABCLASS'];
611         $tabobj  = $tabs[$type]['CLASS'];
612         $tabacl  = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
613       }
615       /* Load permissions for selected 'dn' and check if
616          we're allowed to remove this 'dn' */
617       if(preg_match("/d/",$tabacl)){ 
619         /* Check locking, save current plugin in 'back_plugin', so
620            the dialog knows where to return. */
621         if (($user= get_lock($this->dn)) != ""){
622           return(gen_locked_message ($user, $this->dn));
623         }
625         /* Lock the current entry, so nobody will edit it during deletion */
626         add_lock ($this->dn, $this->ui->dn);
627         $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn)));
628         $smarty->assign("multiple", false);
629         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
630       } else {
632         /* Obviously the user isn't allowed to delete. Show message and
633            clean session. */
634         print_red (_("You are not allowed to delete this component!"));
635       }
636     }
639     /********************
640       Delete system, confirmed
641      ********************/
642     /* Confirmation for deletion has been passed. Terminal should be deleted. */
643     if (isset($_POST['delete_terminal_confirm'])){
645       /* Find out more about the object type */
646       $ldap= $this->config->get_ldap_link();
647       $ldap->cat($this->dn, array('objectClass'));
648       $attrs= $ldap->fetch();
649       $type= $this->get_system_type($attrs);
651       $ui = get_userinfo();
653       $tabs = array(
654           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal/termgeneric"),
655           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation/workgeneric"),
656           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server/servgeneric"),
657           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer/printgeneric"),
658           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone/phoneGeneric"),
659           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation/wingeneric"),
660           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
662       /* get object type */
663       $tabtype  = "termtabs";
664       $tabobj   = "TERMTABS";
665       $tabacl   = "";
666       if(isset($tabs[$type])){
667         $tabtype = $tabs[$type]['TABCLASS'];
668         $tabobj  = $tabs[$type]['CLASS'];
669         $tabacl  = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
670       }
672       /* Check if we are allowed to remove this object */
673       if(preg_match("/d/",$tabacl)){
675         /* Delete request is permitted, perform LDAP action */
676         if($tabtype=="phonetabs"){
677           $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type);
678           $this->systab->set_acl_base($this->dn);
679           $this->systab->by_object['phoneGeneric']->remove_from_parent ();
680         }else{  
681           $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $this->dn,$type);
682           $this->systab->set_acl_base($this->dn);
683           $this->systab->delete();
684         }
685         unset ($this->systab);
686         $this->systab= NULL;
688         /* Terminal list has changed, reload it. */
689       } else {
691         /* Normally this shouldn't be reached, send some extra
692            logs to notify the administrator */
693         print_red (_("You are not allowed to delete this component!"));
694         new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
695       }
697       /* Remove lock file after successfull deletion */
698       del_lock ($this->dn);
699     }
709    /********************
710       Edit system type finished, check if everything went ok
711      ********************/
712     /* Finish user edit is triggered by the tabulator dialog, so
713        the user wants to save edited data. Check and save at this
714        point. */
715     if ((isset($_POST['edit_finish'])) && (isset($this->systab->config)) || $save_object_directly){
717       /* Check tabs, will feed message array */
718       $message = array();
719       if(!$save_object_directly){
720         $message = $this->systab->check();
721       }else{
722         $found = false;
724         /* Set gotoMode to active if we there was an ogroup selected . (save_object_directly) */
725         foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"graphic") as $tab => $value){
726           if(isset($this->systab->by_object[$tab]->gotoMode)) {
727             $found = true;
728             $this->systab->by_object[$tab]->gotoMode = $value;
729           }
730         }
731         if(!$found){
732           print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified.")));
733         }
735       }
736       /* Save, or display error message? */
737       if (count($message) == 0){
739         /* Incoming behavior; you can select a system type and an ogroup membership.
740          * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset.
741          * Check if we must add the new object to an object group.
742          *
743          * If this is done, delete the old incoming entry... it is still there, because this is a new
744          * entry and not an edited one, so we will delete it.
745          *
746          */
748         if(isset($_SESSION['SelectedSystemType'])){
749           $SelectedSystemType= $_SESSION['SelectedSystemType'];
750           if($SelectedSystemType['ogroup'] != "none"){
751             $og = new ogroup($this->config,$SelectedSystemType['ogroup']);
752             if($og){
753               $og->AddDelMembership($this->systab->dn);
754               $og->save();
755             }
756           }
757         }
759         /* Save terminal data to ldap */
760         if(isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){
761           foreach (array("workservice", "termservice") as $cls){
762             if (isset($this->systab->by_object[$cls])){
763               $this->systab->by_object[$cls]->gotoXMouseport= "";
764               $this->systab->by_object[$cls]->gotoXMouseType= "";
765               $this->systab->by_object[$cls]->gotoXResolution= "";
766               $this->systab->by_object[$cls]->gotoXColordepth= "";
767             }
768           }
769         }
771         $this->systab->save();
773         if(isset($_SESSION['SelectedSystemType'])){
774           unset($_SESSION['SelectedSystemType']);
775           if(!isset($ldap)){
776             $ldap = $this->config->get_ldap_link();
777           }
778           $ldap->cd ($this->dn);
779           $ldap->cat($this->dn, array('dn'));
780           if(count($ldap->fetch())){
781             $ldap->cd($this->dn);
782             $ldap->rmDir($this->dn);
783           }
784           $ldap->cd($this->config->current['BASE']);
785         }
787         /* Terminal has been saved successfully, remove lock from
788            LDAP. */
789         if ($this->dn != "new"){
790           del_lock ($this->dn);
791         }
793         unset ($this->systab);
794         $this->systab= NULL;
795         unset($_SESSION['objectinfo']);
796       } else {
797         /* Ok. There seem to be errors regarding to the tab data,
798            show message and continue as usual. */
799         show_errors($message);
800       }
801     }
804     /********************
805       Edit system was canceled 
806      ********************/
807     /* Cancel dialogs */
808     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){
809       if (isset($this->systab)){
810         del_lock ($this->systab->dn);
811         unset ($this->systab);
812       }
813       $this->systab= NULL;
814       unset($_SESSION['objectinfo']);
816       /* Remove ogroup selection, which was set while editing a new incoming entry */
817       if(isset($_SESSION['SelectedSystemType'])){
818         unset($_SESSION['SelectedSystemType']);
819       }
820     }
822     /********************
823       Display edit dialog, or some other
824      ********************/
826     /* Show tab dialog if object is present */
827     if (isset($this->systab->config)){
828       $display= $this->systab->execute();
830       /* Don't show buttons if tab dialog requests this */
832       $dialog     = FALSE;
833       $hide_apply = $this->dn == "new";
834       if(is_object($this->systab) && !isset($this->systab->by_object)){
835         $dialog = TRUE;
836         $hide_apply = TRUE;
837       }elseif(isset($this->systab->by_object[$this->systab->current]->dialog)){
838         $dia = $this->systab->by_object[$this->systab->current]->dialog;
839         if($dia === TRUE || is_object($dia)){
840           $dialog = TRUE;
841         }  
842       }elseif(isset($this->systab->by_object[$this->systab->current]->netConfigDNS) && 
843         $this->systab->by_object[$this->systab->current]->netConfigDNS->dialog){
844         $dialog = TRUE;
845       }
847       if (!$dialog){
848         $display.= "<p style=\"text-align:right\">\n";
849         $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
850         $display.= "&nbsp;\n";
851         if ($hide_apply){
852           $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
853           $display.= "&nbsp;\n";
854         }
855         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
856         $display.= "</p>";
857       }
858       return ($display);
859     }
861     /* Check if there is a snapshot dialog open */
862     $base = $this->DivListSystem->selectedBase;
863     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
864       return($str);
865     }
867     /* Display dialog with system list */
868     $this->DivListSystem->parent = $this;
869     $this->DivListSystem->execute();
871     /* Add departments if subsearch is disabled */
872     if(!$this->DivListSystem->SubSearch){
873       $this->DivListSystem->AddDepartments($this->DivListSystem->selectedBase,3,1);
874     }
875     $this->reload();
876     $this->DivListSystem->setEntries($this->terminals);
877     return($this->DivListSystem->Draw());
878   }
881   /* Return departments, that will be included within snapshot detection */
882   function get_used_snapshot_bases()
883   {
884     $tmp = array();
886     /* Check acls, if we are not allowed to create and write each plugin tab, skip this object */
888     $tabs = array(
889         "terminal"        => "ou=terminals,ou=systems,",
890         "workstation"     => "ou=workstations,ou=systems,",
891         "incoming"        => "ou=incoming,",
892         "server"          => "ou=servers,ou=systems,",
893         "printer"         => "ou=printers,ou=systems,",
894         "phone"           => "ou=phones,ou=systems,",
895         "winworkstation"  => get_winstations_ou(),
896         "component"       => "ou=netdevices,ou=systems,"
897         ); 
899     foreach($tabs as $acl_cat => $dn){
901       $acl_all = $this->ui->has_complete_category_acls($dn.$this->DivListSystem->selectedBase,$acl_cat);
902       if(preg_match("/(c.*w|w.*c)/",$acl_all)){
903         $tmp[] = $dn.$this->DivListSystem->selectedBase;
904       }
905     }
906     return($tmp); 
907   }
910   function remove_from_parent()
911   {
912     /* Optionally execute a command after we're done */
913     $this->postremove();
914   }
917   /* Save data to object */
918   function save_object()
919   {
920     $this->DivListSystem->save_object();
921   }
924   /* Check values */
925   function check()
926   {
927   }
930   /* Save to LDAP */
931   function save()
932   {
933   }
935   function adapt_from_template($dn)
936   {
937   }
939   function password_change_needed()
940   {
941   }
943   function reload()
944   {
945     /* some var init */
946     $ui = get_userinfo();
947     $res              = array();
948     $this->terminals  = array();
949     $userregex        = "";
951     /* Set base for all searches */
952     $base=  $this->DivListSystem->selectedBase;
954     /* Prepare samba class name */
955     $samba  ="";
956     if ($this->DivListSystem->ShowWinWorkstations){
957       if ($this->config->current['SAMBAVERSION'] == "3"){
958         $samba= "sambaSamAccount";
959       } else {
960         $samba= "sambaAccount";
961       }
962     }
964     /* This array represents the combination between checkboxes and search filters */
965     $objs = array( "ShowServers"        => array("CLASS" => "goServer"        ,"TREE" => "ou=servers,ou=systems," ),
966         "ShowTerminals"      => array("CLASS" => "gotoTerminal"    ,"TREE" => "ou=terminals,ou=systems,"), 
967         "ShowPrinters"       => array("CLASS" => "gotoPrinter"     ,"TREE" => "ou=printers,ou=systems," ),
968         "ShowDevices"        => array("CLASS" => "ieee802Device"   ,"TREE" => "ou=netdevices,ou=systems," ),
969         "ShowPhones"         => array("CLASS" => "goFonHardware"   ,"TREE" => "ou=phones,ou=systems," ),
970         "ShowWorkstations"   => array("CLASS" => "gotoWorkstation" ,"TREE" => "ou=workstations,ou=systems," ),
971         "ShowWinWorkstations"=> array("CLASS" => $samba            ,"TREE" => get_winstations_ou() ));
973     /* Include the 'Display Systems of user' attribute */ 
974     if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){
975       $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")";
976     }
978     /* Attributes to fetch */
979     $sys_attrs        = array("cn", "description", "macAddress", "objectClass", "sambaDomainName","gotoMode");
980     $sys_categories   = array("terminal", "workstation", "server", "phone" ,"printer");
982     /* Add FAIstate to attributes if FAI is activated */
983     $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
984     if(!empty($tmp)){
985       $sys_attrs[] = "FAIstate";
986     }    
988     /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled  */
989     foreach($objs as $checkBox => $oc){
990       if($this->DivListSystem->$checkBox){
991         if($this->DivListSystem->SubSearch){
992           if($oc['CLASS'] != ""){
993             $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
994             $new_res = get_list($filter, $sys_categories , $base,$sys_attrs, GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT);
995       
996             /* Remove all objects that are not in the expected sub department */
997             foreach($new_res as $key => $obj){
998               if(preg_match("/^[^,]+,".normalizePreg($oc['TREE'])."/",$obj['dn'])){
999                 $res[$obj['dn']] = $obj;
1000               }
1001             }
1002           }
1003         }else{
1004           /* User filter? */
1005           if($oc['CLASS'] != ""){
1006             $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
1007             $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_NONE | GL_SIZELIMIT));
1008           }
1009         }
1010       } 
1011     }
1013     /* Search for incoming objects */ 
1014     $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
1015     $res = array_merge($res,get_list($filter,$sys_categories,"ou=incoming,".$base,$sys_attrs, GL_NONE | GL_SIZELIMIT));
1017     /* Get all gotoTerminal's */
1018     foreach ($res as $value){
1020       $tmp= $value['dn'];
1021       $add= "";
1023       /* Extract base */
1024       foreach($objs as $obj){
1025         if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){
1026           $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn']));
1027         }
1028       }
1030       /* Create a string containing the last part of the department. */
1031       $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp)));
1032       if(empty($dn_name)){
1033         $dn_name = "/";
1034       }
1036       /* check if current object is a new one */
1037       if (preg_match ("/,ou=incoming,/i", $tmp)){
1038         if (in_array_ics('gotoTerminal', $value['objectClass'])){
1039           $add= "- "._("New terminal");
1040         }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){
1041           $add= "- "._("New workstation");
1042         }elseif (in_array_ics('GOhard', $value['objectClass']) && !isset($value['gotoMode'])){
1043           $add= "- "._("Unknown device");
1044         }elseif (in_array_ics('GOhard', $value['objectClass'])){
1045           $add= "- "._("New Device");
1046         }
1047       } 
1049       /* Detect type of object and create an entry for $this->terminals */
1050       $terminal = array();
1052       if (in_array_ics('gotoTerminal', $value["objectClass"])){
1054         /* check acl */
1055         $acl = $ui->get_permissions($value['dn'],"terminal/termgeneric");
1056         if($add != "" || preg_match("/r/",$acl)) {
1057           if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1058             $terminal             = $value;
1059             $terminal['type']     = "T";
1060             $terminal['is_new']   = $add;
1061           } else {
1062             $terminal             = $value;
1063             $terminal['type']     = "D";
1064             $terminal['message']  = _("Terminal template for")."&nbsp;'".$dn_name."'&nbsp;";
1065             $terminal['location'] = array_search($tmp, $this->config->departments); 
1066           }
1067         }
1068       } elseif (in_array_ics('gotoWorkstation', $value["objectClass"])){
1070         $acl = $ui->get_permissions($value['dn'],"workstation/workgeneric");
1071         if($add != "" || preg_match("/r/",$acl)) {
1072           if (isset($value["macAddress"][0]) &&  $value["macAddress"][0] != "-"){
1073             $terminal             = $value;
1074             $terminal['type']     = "L";
1075             $terminal['is_new']   = $add;
1076           } else {
1077             $terminal             = $value;
1078             $terminal['type']     = "D";
1079             $terminal['location'] = array_search($tmp, $this->config->departments);
1080             $terminal['message']  = _("Workstation template for")."&nbsp;'".$dn_name."'&nbsp;";
1081           }
1082           if (isset($value["FAIstate"][0])){
1083             $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1084           }
1085         }
1086       } elseif (in_array_ics('gotoPrinter', $value["objectClass"])){
1087        
1088    
1089         $acl = $ui->get_permissions($value['dn'],"printer/printgeneric");
1090         if($add != "" || preg_match("/r/",$acl)) {
1092           $terminal             = $value;
1093           $terminal['type']     = "P";
1094         }
1095       } elseif (in_array_ics('goServer', $value["objectClass"])){
1097         $acl = $ui->get_permissions($value['dn'],"server/servgeneric");
1098         if($add != "" || preg_match("/r/",$acl)) {
1100           $terminal             = $value;
1101           $terminal['type']     = "S";
1102           if (isset($value["FAIstate"][0])){
1103             $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1104           }
1105         }
1106       } elseif (in_array_ics('goFonHardware', $value["objectClass"])){
1108         $acl = $ui->get_permissions($value['dn'],"phone/phoneGeneric");
1109         if($add != "" || preg_match("/r/",$acl)) {
1111           $terminal             = $value;
1112           $terminal['type']     = "F";
1113         }
1114       }elseif (in_array_ics("GOhard",$value['objectClass'])){
1116         $acl =  $ui->get_permissions($value['dn'],"server/servgeneric"). 
1117                 $ui->get_permissions($value['dn'],"terminal/termgeneric").
1118                 $ui->get_permissions($value['dn'],"workstation/workgeneric");
1119         if($add != "" || preg_match("/r/",$acl)) {
1121           $terminal = $value;
1122           $terminal['type']   = "Q";
1123           $terminal['is_new'] = $add;
1124         }
1125       } elseif (in_array_ics('ieee802Device', $value["objectClass"])){
1127         $acl = $ui->get_permissions($value['dn'],"component/componentGeneric");
1128         if($add != "" || preg_match("/r/",$acl)) {
1130           $terminal             = $value;
1131           $terminal['type']     = "C";
1132         }
1133       } else{
1135         $name= preg_replace('/\$$/', '', $value['cn'][0]);
1136         if (isset($value['sambaDomainName'])){
1137           $domain= " [".$value['sambaDomainName'][0]."]";
1138         } else {
1139           $domain= "";
1140         }
1141         $terminal=$value;
1142         $terminal['type']     ="W";
1143         $terminal['domain']   = $name.$domain;
1144       }
1146       if(count($terminal)){
1147         $this->terminals[]=$terminal;
1148       }
1149     }
1151     $tmp=array();
1152     foreach($this->terminals as $tkey => $val ){
1153       $tmp[strtolower($val['cn'][0]).$val['dn']]=$val;
1154     }
1155     ksort($tmp);
1156     $this->terminals=array();
1157     foreach($tmp as $val){
1158       $this->terminals[]=$val;
1159     }
1160     reset ($this->terminals);
1161   }
1163   function remove_lock()
1164   {
1165     if (isset($this->systab->dn)){
1166       del_lock ($this->systab->dn);
1167     }
1168   }
1171   function copyPasteHandling_from_queue($s_action,$s_entry)
1172   {
1173     /* Check if Copy & Paste is disabled */
1174     if(!is_object($this->CopyPasteHandler)){
1175       return("");
1176     }
1179     $tabs = array(
1180         "terminal"    => array( "CLASS"     =>"TERMTABS",     "TABNAME" =>"termgeneric",     
1181           "TABCLASS"  =>"termtabs",     "ACL"     =>"terminal"),
1182         "workstation" => array( "CLASS"     =>"WORKTABS",     "TABNAME" =>"workgeneric",     
1183           "TABCLASS"  =>"worktabs",     "ACL"     =>"workstation"),
1184         "server"      => array( "CLASS"     =>"SERVTABS",     "TABNAME" =>"servgeneric",     
1185           "TABCLASS"  =>"servtabs",     "ACL"     =>"server"),
1186         "printer"     => array( "CLASS"     =>"PRINTTABS",    "TABNAME" =>"printgeneric",    
1187           "TABCLASS"  =>"printtabs",    "ACL"     =>"printer"),
1188         "phone"       => array( "CLASS"     =>"PHONETABS",    "TABNAME" =>"phoneGeneric",    
1189           "TABCLASS"  =>"phonetabs",    "ACL"     =>"phone"),
1190         "component"   => array( "CLASS"     =>"COMPONENTTABS","TABNAME" =>"componentGeneric",
1191           "TABCLASS"  =>"componenttabs","ACL"     =>"component"));
1193     /* Add a single entry to queue */
1194     if($s_action == "cut" || $s_action == "copy"){
1196       /* Cleanup object queue */
1197       $this->CopyPasteHandler->cleanup_queue();
1198       $dn     = $this->terminals[$s_entry]['dn'];
1199       $oc     = $this->terminals[$s_entry]['objectClass'];
1200       $type   = $this->get_system_type($this->terminals[$s_entry]);
1202       $tab_o  = $tabs[$type]['CLASS'];
1203       $tab_c  = $tabs[$type]['TABCLASS'];
1204       $acl    = $tabs[$type]['ACL'];
1206       $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl);
1207     }
1209     /* Add entries to queue */
1210     if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
1212       /* Cleanup object queue */
1213       $this->CopyPasteHandler->cleanup_queue();
1215       /* Add new entries to CP queue */
1216       foreach($this->list_get_selected_items() as $id){
1217         $dn = $this->terminals[$id]['dn'];
1218         $oc = $this->terminals[$id]['objectClass']; 
1219         $type = $this->get_system_type($this->terminals[$id]);
1221         if(isset($tabs[$type])){
1222           $tab_o  = $tabs[$type]['CLASS'];
1223           $tab_c  = $tabs[$type]['TABCLASS'];
1224           $acl    = $tabs[$type]['ACL'];
1226           if($s_action == "copy_multiple"){
1227             $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl);
1228           }
1229           if($s_action == "cut_multiple"){
1230             $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl);
1231           }
1232         }
1233       }
1234     }
1236     /* Start pasting entries */
1237     if($s_action == "editPaste"){
1238       $this->start_pasting_copied_objects = TRUE;
1239     }
1240   
1241     /* Return C&P dialog */
1242     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1243     
1244       /* Load entry from queue and set base */
1245       $this->CopyPasteHandler->load_entry_from_queue();
1246       $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase);
1248       /* Get dialog */
1249       $data = $this->CopyPasteHandler->execute();
1251       /* Return dialog data */
1252       if(!empty($data)){
1253         return($data);
1254       }
1255     }
1257     /* Automatically disable status for pasting */
1258     if(!$this->CopyPasteHandler->entries_queued()){
1259       $this->start_pasting_copied_objects = FALSE;
1260     }
1261     return("");
1262   }
1265   function get_system_type($attrs)
1266   {
1267     if($this->config->search("ArpNewDevice","CLASS",array('tabs')) != ""){
1268       $enable_arp_device_handling = TRUE;
1269     }
1270  
1271     $classes = $attrs['objectClass'];
1273     $type= "";
1274     if (in_array_ics('ieee802Device', $classes)){
1275       $type= "component";
1276     }elseif (in_array_ics('gotoTerminal', $classes)){
1277       $type= "terminal";
1278     }elseif (in_array_ics('gotoWorkstation', $classes)){
1279       $type= "workstation";
1280     }elseif (in_array_ics('gotoPrinter', $classes)){
1281       $type= "printer";
1282     }elseif (in_array_ics('goFonHardware', $classes)){
1283       $type= "phone";
1284     }elseif (in_array_ics('goServer', $classes)){
1285       $type= "server";
1286     }elseif (in_array_ics('GOhard', $classes) && !isset($attrs['gotoMode']) && $enable_arp_device_handling){
1287       $type= "ArpNewDevice";
1288     }elseif (in_array_ics('GOhard', $classes)){
1289       $type= "NewDevice";
1290     }elseif (in_array_ics('sambaAccount', $classes) ||
1291         in_array_ics('sambaSamAccount', $classes)){
1292       $type= "winstation";
1293     }
1294     return ($type);
1295   }
1298   function convert_list($input)
1299   {
1300     $temp= "";
1301     $conv= array(       
1302         "NQ" => array("select_newsystem.png",_("New System from incoming")),
1303         "D" => array("select_default.png",_("Template")),
1304         "T" => array("select_terminal.png",_("Terminal")),
1305         "L" => array("select_workstation.png",_("Workstation")),
1306         "GL" => array("select_workstation_green.png",_("Workstation is installing")),
1307         "YL" => array("select_workstation_yellow.png",_("Workstation is waiting for action")),
1308         "RL" => array("select_workstation_red.png",_("Workstation installation failed")),
1309         "F" => array("select_phone.png",_("Phone")),
1310         "S" => array("select_server.png",_("Server")),
1311         "GS" => array("select_server_green.png",_("Server is installing")),
1312         "YS" => array("select_server_yellow.png",_("Server is waiting for action")),
1313         "RS" => array("select_server_red.png",_("Server installation failed")),
1314         "W" => array("select_winstation.png",_("Winstation")),
1315         "C" => array("select_component.png",_("Network Device")),
1316         "NT"=> array("select_new_terminal.png",_("New Terminal")),
1317         "NL"=> array("select_new_workstation.png",_("New Workstation")),
1318         "P" => array("select_printer.png",_("Printer")));
1320     if((isset($input['is_new']))&&(!empty($input['is_new']))){
1321       $input['type']="N".$input['type'];
1322     }
1323     foreach ($conv  as $key => $value){
1324       if($input['type']==$key){
1325         $tmp['img'] ="<img class='center' src='images/".$value[0]."' alt='".$key."' title='".$value['1']."'>";
1326         $tmp['class']=$key;
1327         return $tmp;
1328       }
1329     }
1330   }
1332   
1333   function getState($type, $state)
1334   {
1335     switch (preg_replace('/:.*$/', '', $state)) {
1336       case 'installing':
1337                 $type= 'G'.$type;
1338                 break;
1339       case 'error':
1340                 $type= 'R'.$type;
1341                 break;
1342       case 'install':
1343       case 'sysinfo':
1344       case 'softupdate':
1345       case 'scheduledupdate':
1346                 $type= 'Y'.$type;
1347                 break;
1348     }
1351     return ($type);
1352   }
1355   function list_get_selected_items()
1356   {
1357     $ids = array();
1358     foreach($_POST as $name => $value){
1359       if(preg_match("/^item_selected_[0-9]*$/",$name)){
1360         $id   = preg_replace("/^item_selected_/","",$name);
1361         $ids[$id] = $id;
1362       }
1363     }
1364     return($ids);
1365   }
1368   /* !! Incoming dummy acls, required to defined acls for incoming objects
1369    */
1370   function plInfo()
1371   {
1372     return (array(
1373           "plShortName"   => _("Incoming objects"),
1374           "plDescription" => _("Incoming objects"),
1375           "plSelfModify"  => FALSE,
1376           "plDepends"     => array(),
1377           "plPriority"    => 99,
1378           "plSection"     => array("administration"),
1379           "plCategory"    => array("incoming"   => array( "description"  => _("Incoming"),
1380                                                           "objectClass"  => "")),
1381           "plProvidedAcls"=> array()
1382             
1383           ));
1384   }
1387   
1391 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1392 ?>