Code

Udpated gotomasses
[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("/^remove_multiple_systems/i",$key)){
89         $s_action="del_multiple";
90       }elseif(preg_match("/newsystem_.*/i",$key)){
91         $s_action="newsystem";
92         $s_entry  = preg_replace("/newsystem_/i","",$key);
93       }elseif(preg_match("/^multiple_copy_systems/",$key)){
94         $s_action = "copy_multiple";
95       }elseif(preg_match("/^multiple_cut_systems/",$key)){
96         $s_action = "cut_multiple";
97       }elseif(preg_match("/^editPaste.*/i",$key)){
98         $s_action="editPaste";
99       }elseif(preg_match("/^copy_.*/",$key)){
100         $s_action="copy";
101         $s_entry  = preg_replace("/^copy_/i","",$key);
102       }elseif(preg_match("/^cut_.*/",$key)){
103         $s_action="cut";
104         $s_entry  = preg_replace("/^cut_/i","",$key);
105       }
106     }
107     
108       
109     /* Incoming handling  
110      * If someone made a systemtype and ogroup selection 
111      * Display the new requested entry type ... servtab  in case of server and so on.
112      */
113     if(isset($_POST['SystemTypeChoosen'])){
114       $s_action = "SelectedSystemType";
115       $s_entry  = $_POST['SystemType'];
116       $_SESSION['SelectedSystemType']['ogroup'] = $_POST['ObjectGroup'];
117       $this->systab = NULL;
118     }
120     /* remove image tags from posted entry  (posts looks like this 'name_x')*/
121     $s_entry  = preg_replace("/_.$/","",$s_entry);
123     /* Edit was requested by pressing the name(link) of an item */
124     if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
125       $s_action ="edit";
126       $s_entry  = $_GET['id'];
127     }
129     /* Check for exeeded sizelimit */
130     if (($message= check_sizelimit()) != ""){
131       return($message);
132     }
134     /* Try to get informations about what kind of system to create */
135     if ($s_action=="new") {
136       return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
137     }
140     /********************
141       Copy & Paste Handling  ...
142      ********************/
144     /* Display the copy & paste dialog, if it is currently open */
145     $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
146     if($ret){
147       return($ret);
148     }
149   
151     /********************
152       Create FAI CD ...   
153      ********************/
154     if ($s_action=="gen_cd"){
155       $this->dn= $this->terminals[$s_entry]['dn'];
156       $_SESSION['objectinfo']= $this->dn;
157       return ($smarty->fetch(get_template_path('gencd.tpl', TRUE)));
158     }
161     /* Start CD-Creation */
162     if ((isset($_POST["cd_create"])) && !empty($this->dn)){
163       $smarty->assign("src", "?plug=".$_GET['plug']."&amp;PerformIsoCreation");
164       return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE)));
165     }
168     if ($this->dn != "" && isset($_GET['PerformIsoCreation'])){
170       $return_button   = "<form method='get' action='main.php' target='_parent'>
171         <input type='submit' value='"._("Back")."'>
172         <input type='hidden' name='plug' value='".$_GET['plug']."'/>
173         </form>";
175       $dsc             = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
177       /* Get and check command */
178       $command= $this->config->search("workgeneric", "ISOCMD",array('tabs'));
179       
180       if (check_command($command)){
181         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
183         /* Print out html introduction */
184         echo '  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
185           <html>
186           <head>
187           <title></title>
188           <style type="text/css">@import url("themes/default/style.css");</style>
189           <script language="javascript" src="include/focus.js" type="text/javascript"></script>
190           </head>
191           <body style="background: none; margin:4px;" id="body" >
192           <pre>';
194         /* Open process handle and check if it is a valid process */
195         $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
196         if (is_resource($process)) {
197           fclose($pipes[0]);
199           /* Print out returned lines && write JS to scroll down each line */
200           while (!feof($pipes[1])){
201             $cur_dat = fgets($pipes[1], 1024);
202             echo $cur_dat;
203             echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
204             flush();
205           }
206         }
208         /* Get error string && close streams */
209         $buffer= stream_get_contents($pipes[2]);
211         fclose($pipes[1]);
212         fclose($pipes[2]);
213         echo "</pre>";
215         /* Check return code */
216         $ret= proc_close($process);
217         if ($ret != 0){
218           echo "<h1 style='color:red'>"._("Creating the image failed. Please see the report below.")."</h1>";
219           echo "<pre style='color:red'>$buffer</pre>";
220         }
224         echo $return_button."<br>";
226       } else {
227         $tmp= "<h1 style='color:red'>".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."</h1>";
228         echo $tmp;
229       }
231       /* Scroll down completly */
232       echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
233       echo '</body></html>';
234       flush();
235       exit;
236     }
239     /********************
240       Create new system ...   
241      ********************/
242     /* Create new default terminal 
243      * Or create specified object of selected system type, from given incoming object  
244      */
246     $save_object_directly = false;
247     if(($s_action == "SelectedSystemType") && (isset($_POST['ObjectGroup']) && ($_POST['ObjectGroup'] != "none"))){
248       $save_object_directly = true;
249     }
251     if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") {
253       /* If the current entry is an incoming object 
254        * $sw = System type as posted in new incoming handling dialog 
255        */ 
256       if($s_action == "SelectedSystemType") {
257         $sw         = $s_entry;
258       }else{
259         if(isset($_POST['system'])){
260           $sw = $_POST['system'];
261         }else{
262           $sw = $s_entry;
263         }
264         $this->dn= "new";
265       }
266       $tabs = array(
267           "terminal"    => array("CLASS"=>"TERMTABS",     "TABNAME"=>"termgeneric",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
268           "workstation" => array("CLASS"=>"WORKTABS",     "TABNAME"=>"workgeneric",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"),
269           "server"      => array("CLASS"=>"SERVTABS",     "TABNAME"=>"servgeneric",     "TABCLASS" =>"servtabs",      "ACL"=> "server"),
270           "printer"     => array("CLASS"=>"PRINTTABS",    "TABNAME"=>"printgeneric",    "TABCLASS" =>"printtabs",     "ACL"=> "printer"),
271           "phone"       => array("CLASS"=>"PHONETABS",    "TABNAME"=>"phoneGeneric",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone"),
272           "component"   => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentgeneric","TABCLASS" =>"componenttabs", "ACL"=> "component"));
274       if(isset($tabs[$sw])){
275         $class    = $tabs[$sw]["CLASS"];
276         $tabname  = $tabs[$sw]["TABNAME"];
277         $tabclass = $tabs[$sw]["TABCLASS"];
278         $acl_cat  = $tabs[$sw]["ACL"];
280         /* Load permissions for selected 'dn' and check if
281            we're allowed to remove this 'dn' */
282         $ui       = get_userinfo();
283         $tabacl   = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname);
284         if(preg_match("/c/",$tabacl)){
285           $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
286           $this->systab->set_acl_base($this->DivListSystem->selectedBase);
287           $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
288           $this->systab->base = $this->DivListSystem->selectedBase;
289         }else{
290           print_red(_("You are not allowed to create a new object of this type."));
291         }
292       }
293     }
295     /********************
296       Edit system ...   
297      ********************/
299     /* User wants to edit data? */
300     if (($s_action == "edit") && (!isset($this->systab->config))){
302       $this->dn= $this->terminals[$s_entry]['dn'];
304       /* Check locking, save current plugin in 'back_plugin', so
305          the dialog knows where to return. */
306       if (($user= get_lock($this->dn)) != ""){
307         return(gen_locked_message ($user, $this->dn));
308       }
310       /* Find out more about the object type */
311       $ldap= $this->config->get_ldap_link();
312       $ldap->cat($this->dn, array('objectClass','gotoMode'));
313       $attrs= $ldap->fetch();
314       $type= $this->get_system_type($attrs);
316       /* Lock the current entry, so everyone will get the
317          above dialog */
318       $tabs = array(
319           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
320           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"),
321           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server"),
322           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer"),
323           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone"),
324           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation"),
325           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component"));
328       if($type == "ArpNewDevice"){
329         $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn);
330       }elseif($type == "NewDevice"){
331         $this->systab = new SelectDeviceType($this->config,$this->dn) ;
332       }elseif(isset($tabs[$type])){
334         $class    = $tabs[$type]["CLASS"];
335         $acl_cat  = $tabs[$type]["ACL"];
336         $tabclass = $tabs[$type]["TABCLASS"];
338         $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat);
339         $this->systab->set_acl_base($this->dn);
340         $_SESSION['objectinfo']= $this->dn;
341         add_lock ($this->dn, $this->ui->dn);
342       }else{ 
343         print_red (_("You can't edit this object type yet!"));
344         del_lock($this->dn);
345       }
346     }
349     /********************
350       Change password ...   
351      ********************/
353     /* Set terminals root password */
354     if ($s_action=="change_pw"){
355       $tabs = array(
356           "terminal"    => array("CLASS"=>"TERMTABS",     "TABNAME"=>"termgeneric",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
357           "workstation" => array("CLASS"=>"WORKTABS",     "TABNAME"=>"workgeneric",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"));
359       $type = $this->get_system_type($this->terminals[$s_entry]);
360       $class    = $tabs[$type]["CLASS"];
361       $tabname  = $tabs[$type]["TABNAME"];
362       $acl_cat  = $tabs[$type]["ACL"];
363       $tabclass = $tabs[$type]["TABCLASS"];
364       $ui       = get_userinfo();
365       $tabacl   = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
366       if(preg_match("/w/",$tabacl)){
367         $this->dn= $this->terminals[$s_entry]['dn'];
368         $_SESSION['objectinfo']= $this->dn;
369         return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
370       }else{
371         print_red(_("You are not allowed to change the password for this object."));
372       }
373     }
376     /********************
377       Password change finish, but check if entered data is ok 
378      ********************/
380     /* Correctly specified? */
381     if (isset($_POST['password_finish'])){
382       if ($_POST['new_password'] != $_POST['repeated_password']){
383         print_red (_("Passwords entered as new and repeated do not match!"));
384         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
385       }
386     }
388     /********************
389       Password change finish
390      ********************/
392     /* Change terminal password */
393     if (isset($_POST['password_finish']) && 
394         $_POST['new_password'] == $_POST['repeated_password']){
396       /* Check if user is allowed to set password */
397       $tabs = array(
398           "terminal"    => array("CLASS"=>"TERMTABS",     "TABNAME"=>"termgeneric",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal"),
399           "workstation" => array("CLASS"=>"WORKTABS",     "TABNAME"=>"workgeneric",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation"));
401       /* Detect object type */
402       $type = "";
403       foreach($this->terminals as $terminal){
404         if($terminal['dn'] == $this->dn){
405           $type = $this->get_system_type($terminal);
406           break;
407         } 
408       }
410       /* Type detected */
411       if(!empty($type)){
413         /* Get infos */
414         $class    = $tabs[$type]["CLASS"];
415         $tabname  = $tabs[$type]["TABNAME"];
416         $acl_cat  = $tabs[$type]["ACL"];
417         $tabclass = $tabs[$type]["TABCLASS"];
418     
419         /* Get acls */
420         $ui       = get_userinfo();
421         $tabacl   = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
423         /* Check acls */
424         if(preg_match("/w/",$tabacl)){
425           $ldap = $this->config->get_ldap_link();
426           $ldap->cd($this->dn);
428           $attrs= array();
429           if ($_POST['new_password'] == ""){
430             $attrs['gotoRootPasswd']= array();
431           } else {
432             $attrs['gotoRootPasswd']= crypt($_POST['new_password'],substr(session_id(),0,2));
433           }
434           $ldap->modify($attrs);
435           new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error());
436         }else{
437           print_red(_("You are not allowed to change the password for this object."));
438         }
439       }else{
440         print_red(_("Can't detect object to change password."));
441       }
442       unset($_SESSION['objectinfo']);
443     }
446     /********************
447       Delete system cancel
448      ********************/
450     /* Delete terminal canceled? */
451     if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
452       del_lock ($this->dn);
453       unset($_SESSION['objectinfo']);
454     }
457     /********************
458       Delete MULTIPLE entries requested, display confirm dialog
459      ********************/
461     if ($s_action=="del_multiple"){
462       $this->dns = array();
463       $ids = $this->list_get_selected_items();
465       if(count($ids)){
467         foreach($ids as $id){
468           $dn = $this->terminals[$id]['dn'];
469           if (($user= get_lock($dn)) != ""){
470             return(gen_locked_message ($user, $dn));
471           }
472           $this->dns[$id] = $dn;
473         }
475         $dns_names = "<br><pre>";
476         foreach($this->dns as $dn){
477           add_lock ($dn, $this->ui->dn);
478           $dns_names .= $dn."\n";
479         }
480         $dns_names .="</pre>";
482         /* Lock the current entry, so nobody will edit it during deletion */
483         if (count($this->dns) == 1){
484           $smarty->assign("warning",     sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
485         } else {
486           $smarty->assign("warning",     sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
487         }
488         $smarty->assign("multiple", true);
489         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
490       }
491     }
494     /********************
495       Delete MULTIPLE entries confirmed
496      ********************/
498     /* Confirmation for deletion has been passed. Users should be deleted. */
499     if (isset($_POST['delete_multiple_system_confirm'])){
501       $ui = get_userinfo();
502       $tabs = array(
503           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal/termgeneric"),
504           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation/workgeneric"),
505           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server/servgeneric"),
506           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer/printgeneric"),
507           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone/phoneGeneric"),
508           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation/wingeneric"),
509           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
512       /* Remove user by user and check acls before removeing them */
513       foreach($this->dns as $key => $dn){
515         /* Get 'dn' from posted termlinst */
516         $attrs    = $this->terminals[$key];
517         $type= $this->get_system_type($attrs);
519         /* get object type */
520         $tabtype  = "termtabs";
521         $tabobj   = "TERMTABS";
522         $tabacl   = "";
523         if(isset($tabs[$type])){
524           $tabtype = $tabs[$type]['TABCLASS'];
525           $tabobj  = $tabs[$type]['CLASS'];
526           $tabacl  = $ui->get_permissions($dn,$tabs[$type]['ACL']);
528           /* Load permissions for selected 'dn' and check if
529              we're allowed to remove this 'dn' */
530           if(preg_match("/d/",$tabacl)){ 
532             /* Delete request is permitted, perform LDAP action */
533             if($tabtype=="phonetabs"){
534               $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
535               $this->systab->set_acl_base($dn);
536               $this->systab->by_object['phoneGeneric']->remove_from_parent ();
537             }else{
538               $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $dn,$type);
539               $this->systab->set_acl_base($dn);
540               $this->systab->delete();
541             }
542             unset ($this->systab);
543             $this->systab= NULL;
545           } else {
546             /* Normally this shouldn't be reached, send some extra
547                logs to notify the administrator */
548             print_red (_("You are not allowed to delete this component!"));
549             new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
550           }
551           /* Remove lock file after successfull deletion */
552           del_lock ($dn);
553           unset($this->dns[$key]);
554         }
555       }
556     }
558     /********************
559       Delete MULTIPLE entries Canceled
560      ********************/
562     /* Remove lock */
563    if(isset($_POST['delete_multiple_system_cancel'])){
564       foreach($this->dns as $key => $dn){
565         del_lock ($dn);
566         unset($this->dns[$key]);
567       }
568     }
571     /********************
572       Delete system, confirm dialog
573      ********************/
575     /* Remove terminal was requested */
576     if ($s_action=="del"){
578       /* Get 'dn' from posted termlinst */
579       $this->dn = $this->terminals[$s_entry]['dn'];
580       $attrs    = $this->terminals[$s_entry];
582       $type= $this->get_system_type($attrs);
583       $ui = get_userinfo();
584       $tabs = array(
585           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal/termgeneric"),
586           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation/workgeneric"),
587           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server/servgeneric"),
588           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer/printgeneric"),
589           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone/phoneGeneric"),
590           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation/wingeneric"),
591           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
594       /* get object type */
595       $tabtype  = "termtabs";
596       $tabobj   = "TERMTABS";
597       $tabacl   = "";
598       if(isset($tabs[$type])){
599         $tabtype = $tabs[$type]['TABCLASS'];
600         $tabobj  = $tabs[$type]['CLASS'];
601         $tabacl  = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
602       }
604       /* Load permissions for selected 'dn' and check if
605          we're allowed to remove this 'dn' */
606       if(preg_match("/d/",$tabacl)){ 
608         /* Check locking, save current plugin in 'back_plugin', so
609            the dialog knows where to return. */
610         if (($user= get_lock($this->dn)) != ""){
611           return(gen_locked_message ($user, $this->dn));
612         }
614         /* Lock the current entry, so nobody will edit it during deletion */
615         add_lock ($this->dn, $this->ui->dn);
616         $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn)));
617         $smarty->assign("multiple", false);
618         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
619       } else {
621         /* Obviously the user isn't allowed to delete. Show message and
622            clean session. */
623         print_red (_("You are not allowed to delete this component!"));
624       }
625     }
628     /********************
629       Delete system, confirmed
630      ********************/
631     /* Confirmation for deletion has been passed. Terminal should be deleted. */
632     if (isset($_POST['delete_terminal_confirm'])){
634       /* Find out more about the object type */
635       $ldap= $this->config->get_ldap_link();
636       $ldap->cat($this->dn, array('objectClass'));
637       $attrs= $ldap->fetch();
638       $type= $this->get_system_type($attrs);
640       $ui = get_userinfo();
642       $tabs = array(
643           "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs",      "ACL"=> "terminal/termgeneric"),
644           "workstation" => array("CLASS"=>"WORKTABS",     "TABCLASS" =>"worktabs",      "ACL"=> "workstation/workgeneric"),
645           "server"      => array("CLASS"=>"SERVTABS",     "TABCLASS" =>"servtabs",      "ACL"=> "server/servgeneric"),
646           "printer"     => array("CLASS"=>"PRINTTABS",    "TABCLASS" =>"printtabs",     "ACL"=> "printer/printgeneric"),
647           "phone"       => array("CLASS"=>"PHONETABS",    "TABCLASS" =>"phonetabs",     "ACL"=> "phone/phoneGeneric"),
648           "winstation"  => array("CLASS"=>"WINTABS",      "TABCLASS" =>"wintabs",       "ACL"=> "winworkstation/wingeneric"),
649           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
651       /* get object type */
652       $tabtype  = "termtabs";
653       $tabobj   = "TERMTABS";
654       $tabacl   = "";
655       if(isset($tabs[$type])){
656         $tabtype = $tabs[$type]['TABCLASS'];
657         $tabobj  = $tabs[$type]['CLASS'];
658         $tabacl  = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
659       }
661       /* Check if we are allowed to remove this object */
662       if(preg_match("/d/",$tabacl)){
664         /* Delete request is permitted, perform LDAP action */
665         if($tabtype=="phonetabs"){
666           $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type);
667           $this->systab->set_acl_base($this->dn);
668           $this->systab->by_object['phoneGeneric']->remove_from_parent ();
669         }else{  
670           $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $this->dn,$type);
671           $this->systab->set_acl_base($this->dn);
672           $this->systab->delete();
673         }
674         unset ($this->systab);
675         $this->systab= NULL;
677         /* Terminal list has changed, reload it. */
678       } else {
680         /* Normally this shouldn't be reached, send some extra
681            logs to notify the administrator */
682         print_red (_("You are not allowed to delete this component!"));
683         new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
684       }
686       /* Remove lock file after successfull deletion */
687       del_lock ($this->dn);
688     }
698    /********************
699       Edit system type finished, check if everything went ok
700      ********************/
701     /* Finish user edit is triggered by the tabulator dialog, so
702        the user wants to save edited data. Check and save at this
703        point. */
704     if ((isset($_POST['edit_finish'])) && (isset($this->systab->config)) || $save_object_directly){
706       /* Check tabs, will feed message array */
707       $message = array();
708       if(!$save_object_directly){
709         $message = $this->systab->check();
710       }else{
711         $found = false;
713         /* Set gotoMode to active if we there was an ogroup selected . (save_object_directly) */
714         foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"graphic") as $tab => $value){
715           if(isset($this->systab->by_object[$tab]->gotoMode)) {
716             $found = true;
717             $this->systab->by_object[$tab]->gotoMode = $value;
718           }
719         }
720         if(!$found){
721           print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified.")));
722         }
724       }
725       /* Save, or display error message? */
726       if (count($message) == 0){
728         /* Save terminal data to ldap */
729         if(isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){
730           foreach (array("workservice", "termservice") as $cls){
731             if (isset($this->systab->by_object[$cls])){
732               $this->systab->by_object[$cls]->gotoXMouseport= "";
733               $this->systab->by_object[$cls]->gotoXMouseType= "";
734               $this->systab->by_object[$cls]->gotoXResolution= "";
735               $this->systab->by_object[$cls]->gotoXColordepth= "";
736             }
737           }
738         }
740         $this->systab->save();
742         /* Incoming behavior; you can select a system type and an ogroup membership.
743          * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset.
744          * Check if we must add the new object to an object group.
745          *
746          * If this is done, delete the old incoming entry... it is still there, because this is a new
747          * entry and not an edited one, so we will delete it.
748          *
749          */
751         if(isset($_SESSION['SelectedSystemType'])){
752           $SelectedSystemType= $_SESSION['SelectedSystemType'];
753           unset($_SESSION['SelectedSystemType']);
754           if($SelectedSystemType['ogroup'] != "none"){
755             $og = new ogroup($this->config,$SelectedSystemType['ogroup']);
756             if($og){
757               $og->AddDelMembership($this->systab->dn);
758               $og->save();
759             }
760           }
761           if(!isset($ldap)){
762             $ldap = $this->config->get_ldap_link();
763           }
764           $ldap->cd ($this->dn);
765           $ldap->cat($this->dn, array('dn'));
766           if(count($ldap->fetch())){
767             $ldap->cd($this->dn);
768             $ldap->rmDir($this->dn);
769           }
770           $ldap->cd($this->config->current['BASE']);
771         }
773         /* Terminal has been saved successfully, remove lock from
774            LDAP. */
775         if ($this->dn != "new"){
776           del_lock ($this->dn);
777         }
779         unset ($this->systab);
780         $this->systab= NULL;
781         unset($_SESSION['objectinfo']);
782       } else {
783         /* Ok. There seem to be errors regarding to the tab data,
784            show message and continue as usual. */
785         show_errors($message);
786       }
787     }
790     /********************
791       Edit system was canceled 
792      ********************/
793     /* Cancel dialogs */
794     if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){
795       if (isset($this->systab)){
796         del_lock ($this->systab->dn);
797         unset ($this->systab);
798       }
799       $this->systab= NULL;
800       unset($_SESSION['objectinfo']);
802       /* Remove ogroup selection, which was set while editing a new incoming entry */
803       if(isset($_SESSION['SelectedSystemType'])){
804         unset($_SESSION['SelectedSystemType']);
805       }
806     }
808     /********************
809       Display edit dialog, or some other
810      ********************/
812     /* Show tab dialog if object is present */
813     if (isset($this->systab->config)){
814       $display= $this->systab->execute();
816       /* Don't show buttons if tab dialog requests this */
818       $dialog     = FALSE;
819       $hide_apply = $this->dn == "new";
820       if(is_object($this->systab) && !isset($this->systab->by_object)){
821         $dialog = TRUE;
822         $hide_apply = TRUE;
823       }elseif(isset($this->systab->by_object[$this->systab->current]->dialog)){
824         $dia = $this->systab->by_object[$this->systab->current]->dialog;
825         if($dia === TRUE || is_object($dia)){
826           $dialog = TRUE;
827         }  
828       }elseif(isset($this->systab->by_object[$this->systab->current]->netConfigDNS) && 
829         $this->systab->by_object[$this->systab->current]->netConfigDNS->dialog){
830         $dialog = TRUE;
831       }
833       if (!$dialog){
834         $display.= "<p style=\"text-align:right\">\n";
835         $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
836         $display.= "&nbsp;\n";
837         if ($hide_apply){
838           $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
839           $display.= "&nbsp;\n";
840         }
841         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
842         $display.= "</p>";
843       }
844       return ($display);
845     }
847     /* Check if there is a snapshot dialog open */
848     $base = $this->DivListSystem->selectedBase;
849     if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
850       return($str);
851     }
853     /* Display dialog with system list */
854     $this->DivListSystem->parent = $this;
855     $this->DivListSystem->execute();
857     /* Add departments if subsearch is disabled */
858     if(!$this->DivListSystem->SubSearch){
859       $this->DivListSystem->AddDepartments($this->DivListSystem->selectedBase,3,1);
860     }
861     $this->reload();
862     $this->DivListSystem->setEntries($this->terminals);
863     return($this->DivListSystem->Draw());
864   }
867   /* Return departments, that will be included within snapshot detection */
868   function get_used_snapshot_bases()
869   {
870     $tmp = array();
872     /* Check acls, if we are not allowed to create and write each plugin tab, skip this object */
874     $tabs = array(
875         "terminal"        => "ou=terminals,ou=systems,",
876         "workstation"     => "ou=workstations,ou=systems,",
877         "incoming"        => "ou=incoming,",
878         "server"          => "ou=servers,ou=systems,",
879         "printer"         => "ou=printers,ou=systems,",
880         "phone"           => "ou=phones,ou=systems,",
881         "winworkstation"  => get_winstations_ou(),
882         "component"       => "ou=netdevices,ou=systems,"
883         ); 
885     foreach($tabs as $acl_cat => $dn){
887       $acl_all = $this->ui->has_complete_category_acls($dn.$this->DivListSystem->selectedBase,$acl_cat);
888       if(preg_match("/(c.*w|w.*c)/",$acl_all)){
889         $tmp[] = $dn.$this->DivListSystem->selectedBase;
890       }
891     }
892     return($tmp); 
893   }
896   function remove_from_parent()
897   {
898     /* Optionally execute a command after we're done */
899     $this->postremove();
900   }
903   /* Save data to object */
904   function save_object()
905   {
906     $this->DivListSystem->save_object();
907   }
910   /* Check values */
911   function check()
912   {
913   }
916   /* Save to LDAP */
917   function save()
918   {
919   }
921   function adapt_from_template($dn)
922   {
923   }
925   function password_change_needed()
926   {
927   }
929   function reload()
930   {
931     /* some var init */
932     $ui = get_userinfo();
933     $res              = array();
934     $this->terminals  = array();
935     $userregex        = "";
937     /* Set base for all searches */
938     $base=  $this->DivListSystem->selectedBase;
940     /* Prepare samba class name */
941     $samba  ="";
942     if ($this->DivListSystem->ShowWinWorkstations){
943       if ($this->config->current['SAMBAVERSION'] == "3"){
944         $samba= "sambaSamAccount";
945       } else {
946         $samba= "sambaAccount";
947       }
948     }
950     /* This array represents the combination between checkboxes and search filters */
951     $objs = array( "ShowServers"        => array("CLASS" => "goServer"        ,"TREE" => "ou=servers,ou=systems," ),
952         "ShowTerminals"      => array("CLASS" => "gotoTerminal"    ,"TREE" => "ou=terminals,ou=systems,"), 
953         "ShowPrinters"       => array("CLASS" => "gotoPrinter"     ,"TREE" => "ou=printers,ou=systems," ),
954         "ShowDevices"        => array("CLASS" => "ieee802Device"   ,"TREE" => "ou=netdevices,ou=systems," ),
955         "ShowPhones"         => array("CLASS" => "goFonHardware"   ,"TREE" => "ou=phones,ou=systems," ),
956         "ShowWorkstations"   => array("CLASS" => "gotoWorkstation" ,"TREE" => "ou=workstations,ou=systems," ),
957         "ShowWinWorkstations"=> array("CLASS" => $samba            ,"TREE" => get_winstations_ou() ));
959     /* Include the 'Display Systems of user' attribute */ 
960     if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){
961       $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")";
962     }
964     /* Attributes to fetch */
965     $sys_attrs        = array("cn", "description", "macAddress", "objectClass", "sambaDomainName","gotoMode");
966     $sys_categories   = array("terminal", "workstation", "server", "phone" ,"printer");
968     /* Add FAIstate to attributes if FAI is activated */
969     $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
970     if(!empty($tmp)){
971       $sys_attrs[] = "FAIstate";
972     }    
974     /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled  */
975     foreach($objs as $checkBox => $oc){
976       if($this->DivListSystem->$checkBox){
977         if($this->DivListSystem->SubSearch){
978           if($oc['CLASS'] != ""){
979             $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
980             $new_res = get_list($filter, $sys_categories , $base,$sys_attrs, GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT);
981       
982             /* Remove all objects that are not in the expected sub department */
983             foreach($new_res as $key => $obj){
984               if(preg_match("/^[^,]+,".normalizePreg($oc['TREE'])."/",$obj['dn'])){
985                 $res[$obj['dn']] = $obj;
986               }
987             }
988           }
989         }else{
990           /* User filter? */
991           if($oc['CLASS'] != ""){
992             $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
993             $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_NONE | GL_SIZELIMIT));
994           }
995         }
996       } 
997     }
999     /* Search for incoming objects */ 
1000     $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
1001     $res = array_merge($res,get_list($filter,$sys_categories,"ou=incoming,".$base,$sys_attrs, GL_NONE | GL_SIZELIMIT));
1003     /* Get all gotoTerminal's */
1004     foreach ($res as $value){
1006       $tmp= $value['dn'];
1007       $add= "";
1009       /* Extract base */
1010       foreach($objs as $obj){
1011         if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){
1012           $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn']));
1013         }
1014       }
1016       /* Create a string containing the last part of the department. */
1017       $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp)));
1018       if(empty($dn_name)){
1019         $dn_name = "/";
1020       }
1022       /* check if current object is a new one */
1023       if (preg_match ("/,ou=incoming,/i", $tmp)){
1024         if (in_array_ics('gotoTerminal', $value['objectClass'])){
1025           $add= "- "._("New terminal");
1026         }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){
1027           $add= "- "._("New workstation");
1028         }elseif (in_array_ics('GOhard', $value['objectClass']) && !isset($value['gotoMode'])){
1029           $add= "- "._("Unknown device");
1030         }elseif (in_array_ics('GOhard', $value['objectClass'])){
1031           $add= "- "._("New Device");
1032         }
1033       } 
1035       /* Detect type of object and create an entry for $this->terminals */
1036       $terminal = array();
1038       if (in_array_ics('gotoTerminal', $value["objectClass"])){
1040         /* check acl */
1041         $acl = $ui->get_permissions($value['dn'],"terminal/termgeneric");
1042         if($add != "" || preg_match("/r/",$acl)) {
1043           if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1044             $terminal             = $value;
1045             $terminal['type']     = "T";
1046             $terminal['is_new']   = $add;
1047           } else {
1048             $terminal             = $value;
1049             $terminal['type']     = "D";
1050             $terminal['message']  = _("Terminal template for")."&nbsp;'".$dn_name."'&nbsp;";
1051             $terminal['location'] = array_search($tmp, $this->config->departments); 
1052           }
1053         }
1054       } elseif (in_array_ics('gotoWorkstation', $value["objectClass"])){
1056         $acl = $ui->get_permissions($value['dn'],"workstation/workgeneric");
1057         if($add != "" || preg_match("/r/",$acl)) {
1058           if (isset($value["macAddress"][0]) &&  $value["macAddress"][0] != "-"){
1059             $terminal             = $value;
1060             $terminal['type']     = "L";
1061             $terminal['is_new']   = $add;
1062           } else {
1063             $terminal             = $value;
1064             $terminal['type']     = "D";
1065             $terminal['location'] = array_search($tmp, $this->config->departments);
1066             $terminal['message']  = _("Workstation template for")."&nbsp;'".$dn_name."'&nbsp;";
1067           }
1068           if (isset($value["FAIstate"][0])){
1069             $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1070           }
1071         }
1072       } elseif (in_array_ics('gotoPrinter', $value["objectClass"])){
1073        
1074    
1075         $acl = $ui->get_permissions($value['dn'],"printer/printgeneric");
1076         if($add != "" || preg_match("/r/",$acl)) {
1078           $terminal             = $value;
1079           $terminal['type']     = "P";
1080         }
1081       } elseif (in_array_ics('goServer', $value["objectClass"])){
1083         $acl = $ui->get_permissions($value['dn'],"server/servgeneric");
1084         if($add != "" || preg_match("/r/",$acl)) {
1086           $terminal             = $value;
1087           $terminal['type']     = "S";
1088           if (isset($value["FAIstate"][0])){
1089             $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1090           }
1091         }
1092       } elseif (in_array_ics('goFonHardware', $value["objectClass"])){
1094         $acl = $ui->get_permissions($value['dn'],"phone/phoneGeneric");
1095         if($add != "" || preg_match("/r/",$acl)) {
1097           $terminal             = $value;
1098           $terminal['type']     = "F";
1099         }
1100       }elseif (in_array_ics("GOhard",$value['objectClass'])){
1102         $acl =  $ui->get_permissions($value['dn'],"server/servgeneric"). 
1103                 $ui->get_permissions($value['dn'],"terminal/termgeneric").
1104                 $ui->get_permissions($value['dn'],"workstation/workgeneric");
1105         if($add != "" || preg_match("/r/",$acl)) {
1107           $terminal = $value;
1108           $terminal['type']   = "Q";
1109           $terminal['is_new'] = $add;
1110         }
1111       } elseif (in_array_ics('ieee802Device', $value["objectClass"])){
1113         $acl = $ui->get_permissions($value['dn'],"component/componentGeneric");
1114         if($add != "" || preg_match("/r/",$acl)) {
1116           $terminal             = $value;
1117           $terminal['type']     = "C";
1118         }
1119       } else{
1121         $name= preg_replace('/\$$/', '', $value['cn'][0]);
1122         if (isset($value['sambaDomainName'])){
1123           $domain= " [".$value['sambaDomainName'][0]."]";
1124         } else {
1125           $domain= "";
1126         }
1127         $terminal=$value;
1128         $terminal['type']     ="W";
1129         $terminal['domain']   = $name.$domain;
1130       }
1132       if(count($terminal)){
1133         $this->terminals[]=$terminal;
1134       }
1135     }
1137     $tmp=array();
1138     foreach($this->terminals as $tkey => $val ){
1139       $tmp[strtolower($val['cn'][0]).$val['dn']]=$val;
1140     }
1141     ksort($tmp);
1142     $this->terminals=array();
1143     foreach($tmp as $val){
1144       $this->terminals[]=$val;
1145     }
1146     reset ($this->terminals);
1147   }
1149   function remove_lock()
1150   {
1151     if (isset($this->systab->dn)){
1152       del_lock ($this->systab->dn);
1153     }
1154   }
1157   function copyPasteHandling_from_queue($s_action,$s_entry)
1158   {
1159     /* Check if Copy & Paste is disabled */
1160     if(!is_object($this->CopyPasteHandler)){
1161       return("");
1162     }
1165     $tabs = array(
1166         "terminal"    => array( "CLASS"     =>"TERMTABS",     "TABNAME" =>"termgeneric",     
1167           "TABCLASS"  =>"termtabs",     "ACL"     =>"terminal"),
1168         "workstation" => array( "CLASS"     =>"WORKTABS",     "TABNAME" =>"workgeneric",     
1169           "TABCLASS"  =>"worktabs",     "ACL"     =>"workstation"),
1170         "server"      => array( "CLASS"     =>"SERVTABS",     "TABNAME" =>"servgeneric",     
1171           "TABCLASS"  =>"servtabs",     "ACL"     =>"server"),
1172         "printer"     => array( "CLASS"     =>"PRINTTABS",    "TABNAME" =>"printgeneric",    
1173           "TABCLASS"  =>"printtabs",    "ACL"     =>"printer"),
1174         "phone"       => array( "CLASS"     =>"PHONETABS",    "TABNAME" =>"phoneGeneric",    
1175           "TABCLASS"  =>"phonetabs",    "ACL"     =>"phone"),
1176         "component"   => array( "CLASS"     =>"COMPONENTTABS","TABNAME" =>"componentgeneric",
1177           "TABCLASS"  =>"componenttabs","ACL"     =>"component"));
1179     /* Add a single entry to queue */
1180     if($s_action == "cut" || $s_action == "copy"){
1182       /* Cleanup object queue */
1183       $this->CopyPasteHandler->cleanup_queue();
1184       $dn     = $this->terminals[$s_entry]['dn'];
1185       $oc     = $this->terminals[$s_entry]['objectClass'];
1186       $type   = $this->get_system_type($this->terminals[$s_entry]);
1188       $tab_o  = $tabs[$type]['CLASS'];
1189       $tab_c  = $tabs[$type]['TABCLASS'];
1190       $acl    = $tabs[$type]['ACL'];
1192       $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl);
1193     }
1195     /* Add entries to queue */
1196     if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
1198       /* Cleanup object queue */
1199       $this->CopyPasteHandler->cleanup_queue();
1201       /* Add new entries to CP queue */
1202       foreach($this->list_get_selected_items() as $id){
1203         $dn = $this->terminals[$id]['dn'];
1204         $oc = $this->terminals[$id]['objectClass']; 
1205         $type = $this->get_system_type($this->terminals[$id]);
1207         $tab_o  = $tabs[$type]['CLASS'];
1208         $tab_c  = $tabs[$type]['TABCLASS'];
1209         $acl    = $tabs[$type]['ACL'];
1210           
1211         if($s_action == "copy_multiple"){
1212           $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl);
1213         }
1214         if($s_action == "cut_multiple"){
1215           $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl);
1216         }
1217       }
1218     }
1220     /* Start pasting entries */
1221     if($s_action == "editPaste"){
1222       $this->start_pasting_copied_objects = TRUE;
1223     }
1224   
1225     /* Return C&P dialog */
1226     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1227     
1228       /* Load entry from queue and set base */
1229       $this->CopyPasteHandler->load_entry_from_queue();
1230       $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase);
1232       /* Get dialog */
1233       $data = $this->CopyPasteHandler->execute();
1235       /* Return dialog data */
1236       if(!empty($data)){
1237         return($data);
1238       }
1239     }
1241     /* Automatically disable status for pasting */
1242     if(!$this->CopyPasteHandler->entries_queued()){
1243       $this->start_pasting_copied_objects = FALSE;
1244     }
1245     return("");
1246   }
1249   function get_system_type($attrs)
1250   {
1251     if($this->config->search("ArpNewDevice","CLASS",array('tabs')) != ""){
1252       $enable_arp_device_handling = TRUE;
1253     }
1254  
1255     $classes = $attrs['objectClass'];
1257     $type= "";
1258     if (in_array_ics('ieee802Device', $classes)){
1259       $type= "component";
1260     }elseif (in_array_ics('gotoTerminal', $classes)){
1261       $type= "terminal";
1262     }elseif (in_array_ics('gotoWorkstation', $classes)){
1263       $type= "workstation";
1264     }elseif (in_array_ics('gotoPrinter', $classes)){
1265       $type= "printer";
1266     }elseif (in_array_ics('goFonHardware', $classes)){
1267       $type= "phone";
1268     }elseif (in_array_ics('goServer', $classes)){
1269       $type= "server";
1270     }elseif (in_array_ics('GOhard', $classes) && !isset($attrs['gotoMode']) && $enable_arp_device_handling){
1271       $type= "ArpNewDevice";
1272     }elseif (in_array_ics('GOhard', $classes)){
1273       $type= "NewDevice";
1274     }elseif (in_array_ics('sambaAccount', $classes) ||
1275         in_array_ics('sambaSamAccount', $classes)){
1276       $type= "winstation";
1277     }
1278     return ($type);
1279   }
1282   function convert_list($input)
1283   {
1284     $temp= "";
1285     $conv= array(       
1286         "NQ" => array("select_newsystem.png",_("New System from incoming")),
1287         "D" => array("select_default.png",_("Template")),
1288         "T" => array("select_terminal.png",_("Terminal")),
1289         "L" => array("select_workstation.png",_("Workstation")),
1290         "GL" => array("select_workstation_green.png",_("Workstation is installing")),
1291         "YL" => array("select_workstation_yellow.png",_("Workstation is waiting for action")),
1292         "RL" => array("select_workstation_red.png",_("Workstation installation failed")),
1293         "F" => array("select_phone.png",_("Phone")),
1294         "S" => array("select_server.png",_("Server")),
1295         "GS" => array("select_server_green.png",_("Server is installing")),
1296         "YS" => array("select_server_yellow.png",_("Server is waiting for action")),
1297         "RS" => array("select_server_red.png",_("Server installation failed")),
1298         "W" => array("select_winstation.png",_("Winstation")),
1299         "C" => array("select_component.png",_("Network Device")),
1300         "NT"=> array("select_new_terminal.png",_("New Terminal")),
1301         "NL"=> array("select_new_workstation.png",_("New Workstation")),
1302         "P" => array("select_printer.png",_("Printer")));
1304     if((isset($input['is_new']))&&(!empty($input['is_new']))){
1305       $input['type']="N".$input['type'];
1306     }
1307     foreach ($conv  as $key => $value){
1308       if($input['type']==$key){
1309         $tmp['img'] ="<img class='center' src='images/".$value[0]."' alt='".$key."' title='".$value['1']."'>";
1310         $tmp['class']=$key;
1311         return $tmp;
1312       }
1313     }
1314   }
1316   
1317   function getState($type, $state)
1318   {
1319     switch (preg_replace('/:.*$/', '', $state)) {
1320       case 'installing':
1321                 $type= 'G'.$type;
1322                 break;
1323       case 'error':
1324                 $type= 'R'.$type;
1325                 break;
1326       case 'install':
1327       case 'sysinfo':
1328       case 'softupdate':
1329       case 'scheduledupdate':
1330                 $type= 'Y'.$type;
1331                 break;
1332     }
1335     return ($type);
1336   }
1339   function list_get_selected_items()
1340   {
1341     $ids = array();
1342     foreach($_POST as $name => $value){
1343       if(preg_match("/^item_selected_[0-9]*$/",$name)){
1344         $id   = preg_replace("/^item_selected_/","",$name);
1345         $ids[$id] = $id;
1346       }
1347     }
1348     return($ids);
1349   }
1352   /* !! Incoming dummy acls, required to defined acls for incoming objects
1353    */
1354   function plInfo()
1355   {
1356     return (array(
1357           "plShortName"   => _("Incoming objects"),
1358           "plDescription" => _("Incoming objects"),
1359           "plSelfModify"  => FALSE,
1360           "plDepends"     => array(),
1361           "plPriority"    => 99,
1362           "plSection"     => array("administration"),
1363           "plCategory"    => array("incoming"   => array( "description"  => _("Incoming"),
1364                                                           "objectClass"  => "")),
1365           "plProvidedAcls"=> array()
1366             
1367           ));
1368   }
1371   
1375 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1376 ?>