e626517c405bcdc5b76e4e8bcfefcabf5e5644da
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 /* Arp hanlding activated */
37 var $arp_handling_active = FALSE;
39 function systems (&$config, $ui)
40 {
41 /* Save configuration for internal use */
42 $this->config= $config;
43 $this->ui= $ui;
45 /* Creat dialog object */
46 $this->DivListSystem = new divListSystem($this->config,$this);
48 /* Copy & Paste enabled ?*/
49 if((isset($this->config->data['MAIN']['ENABLECOPYPASTE']))&&(preg_match("/true/i",$this->config->data['MAIN']['ENABLECOPYPASTE']))){
50 $this->CopyPasteHandler = new CopyPasteHandler($this->config);
51 }
53 /* Check whether the arp handling active or not */
54 if($this->config->search("ArpNewDevice","CLASS",array('tabs')) != ""){
55 $this->arp_handling_active = TRUE;
56 }
58 }
61 function execute()
62 {
63 /* Call parent execute */
64 plugin::execute();
66 session::set('LOCK_VARS_TO_USE',array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/","/^menu_action/"));
68 /********************
69 Check for functional posts, edit|delete|add|... system devices
70 ********************/
71 $s_action = ""; // Contains the action to proceed
72 $s_entry = ""; // The value for s_action
73 $base_back = ""; // The Link for Backbutton
74 $smarty = get_smarty();
76 /* Test Posts */
77 foreach($_POST as $key => $val){
78 // Post for delete
79 if(preg_match("/system_del.*/",$key)){
80 $s_action = "del";
81 $s_entry = preg_replace("/system_del_/i","",$key);
82 // Post for edit
83 }elseif(preg_match("/system_edit_.*/",$key)){
84 $s_action="edit";
85 $s_entry = preg_replace("/system_edit_/i","",$key);
86 // Post for new
87 }elseif(preg_match("/system_new.*/",$key)){
88 $s_action="new";
89 }elseif(preg_match("/system_tplnew.*/i",$key)){
90 $s_action="new_tpl";
91 }elseif(preg_match("/system_setpwd_.*/i",$key)){
92 $s_action="change_pw";
93 $s_entry = preg_replace("/system_setpwd_/i","",$key);
94 }elseif(preg_match("/gen_cd_.*/i",$key)){
95 $s_action="gen_cd";
96 $s_entry = preg_replace("/gen_cd_/i","",$key);
97 }elseif(preg_match("/^copy_.*/",$key)){
98 $s_action="copy";
99 $s_entry = preg_replace("/^copy_/i","",$key);
100 }elseif(preg_match("/^cut_.*/",$key)){
101 $s_action="cut";
102 $s_entry = preg_replace("/^cut_/i","",$key);
103 }
104 }
106 /* Incoming handling
107 * If someone made a systemtype and ogroup selection
108 * Display the new requested entry type ... servtab in case of server and so on.
109 */
110 if(isset($_POST['SystemTypeChoosen'])){
111 $SelectedSystemType = session::get('SelectedSystemType');
112 $s_action = "SelectedSystemType";
113 $s_entry = $_POST['SystemType'];
114 $SelectedSystemType['ogroup'] = $_POST['ObjectGroup'];
115 $this->systab = NULL;
116 session::set('SelectedSystemType',$SelectedSystemType);
117 }
119 /* remove image tags from posted entry (posts looks like this 'name_x')*/
120 $s_entry = preg_replace("/_.$/","",$s_entry);
122 /* Edit was requested by pressing the name(link) of an item */
123 if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
124 $s_action ="edit";
125 $s_entry = $_GET['id'];
126 }
127 /* Create options */
128 if(isset($_POST['menu_action']) && preg_match("/^newsystem_/",$_POST['menu_action'])){
129 $s_action = "newsystem";
130 $s_entry = preg_replace("/^newsystem_/","",$_POST['menu_action']);
131 }
133 /* handle C&P from layers menu */
134 if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
135 $s_action = "copy_multiple";
136 }
137 if(isset($_POST['menu_action']) && preg_match("/^multiple_cut_systems/",$_POST['menu_action'])){
138 $s_action = "cut_multiple";
139 }
140 if(isset($_POST['menu_action']) && preg_match("/^editPaste/",$_POST['menu_action'])){
141 $s_action = "editPaste";
142 }
144 /* handle remove from layers menu */
145 if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
146 $s_action = "del_multiple";
147 }
149 /* Handle instant actions from layers menu */
150 foreach (array("halt", "reboot", "reinstall", "update", "wake") as $act){
151 if(isset($_POST['menu_action']) && preg_match("/^${act}_multiple/",$_POST['menu_action'])){
152 $s_action = "${act}_multiple";
153 }
154 }
156 /* Check for exeeded sizelimit */
157 if (($message= check_sizelimit()) != ""){
158 return($message);
159 }
161 /* Try to get informations about what kind of system to create */
162 if ($s_action=="new") {
163 return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
164 }
167 /********************
168 Copy & Paste Handling ...
169 ********************/
171 /* Display the copy & paste dialog, if it is currently open */
172 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
173 if($ret){
174 return($ret);
175 }
178 /********************
179 Create FAI CD ...
180 ********************/
181 if ($s_action=="gen_cd"){
182 $this->dn= $this->terminals[$s_entry]['dn'];
183 session::set('objectinfo',$this->dn);
184 return ($smarty->fetch(get_template_path('gencd.tpl', TRUE)));
185 }
188 /* Start CD-Creation */
189 if ((isset($_POST["cd_create"])) && !empty($this->dn)){
190 $smarty->assign("src", "?plug=".$_GET['plug']."&PerformIsoCreation");
191 return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE)));
192 }
195 if ($this->dn != "" && isset($_GET['PerformIsoCreation'])){
197 $return_button = "<form method='get' action='main.php' target='_parent'>
198 <input type='submit' value='"._("Back")."'>
199 <input type='hidden' name='plug' value='".$_GET['plug']."'/>
200 </form>";
202 $dsc = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
204 /* Get and check command */
205 $command= $this->config->search("workgeneric", "ISOCMD",array('tabs'));
207 if (check_command($command)){
208 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
210 /* Print out html introduction */
211 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
212 <html>
213 <head>
214 <title></title>
215 <style type="text/css">@import url("themes/default/style.css");</style>
216 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
217 </head>
218 <body style="background: none; margin:4px;" id="body" >
219 <pre>';
221 /* Open process handle and check if it is a valid process */
222 $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
223 if (is_resource($process)) {
224 fclose($pipes[0]);
226 /* Print out returned lines && write JS to scroll down each line */
227 while (!feof($pipes[1])){
228 $cur_dat = fgets($pipes[1], 1024);
229 echo $cur_dat;
230 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
231 flush();
232 }
233 }
235 /* Get error string && close streams */
236 $buffer= stream_get_contents($pipes[2]);
238 fclose($pipes[1]);
239 fclose($pipes[2]);
240 echo "</pre>";
242 /* Check return code */
243 $ret= proc_close($process);
244 if ($ret != 0){
245 echo "<h1 style='color:red'>"._("Creating the image failed. Please see the report below.")."</h1>";
246 echo "<pre style='color:red'>$buffer</pre>";
247 }
251 echo $return_button."<br>";
253 } else {
254 $tmp= "<h1 style='color:red'>".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."</h1>";
255 echo $tmp;
256 }
258 /* Scroll down completly */
259 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
260 echo '</body></html>';
261 flush();
262 exit;
263 }
266 /********************
267 Create new system ...
268 ********************/
269 /* Create new default terminal
270 * Or create specified object of selected system type, from given incoming object
271 */
273 $save_object_directly = false;
274 if(($s_action == "SelectedSystemType") && (isset($_POST['ObjectGroup']) && ($_POST['ObjectGroup'] != "none"))){
275 $save_object_directly = true;
276 }
278 if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") {
280 /* If the current entry is an incoming object
281 * $sw = System type as posted in new incoming handling dialog
282 */
283 if($s_action == "SelectedSystemType") {
284 $sw = $s_entry;
285 }else{
286 if(isset($_POST['system'])){
287 $sw = $_POST['system'];
288 }else{
289 $sw = $s_entry;
290 }
291 $this->dn= "new";
292 }
294 $tabs = array(
295 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
296 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"),
297 "server" => array("CLASS"=>"SERVTABS", "TABNAME"=>"servgeneric", "TABCLASS" =>"servtabs", "ACL"=> "server"),
298 "printer" => array("CLASS"=>"PRINTTABS", "TABNAME"=>"printgeneric", "TABCLASS" =>"printtabs", "ACL"=> "printer"),
299 "phone" => array("CLASS"=>"PHONETABS", "TABNAME"=>"phoneGeneric", "TABCLASS" =>"phonetabs", "ACL"=> "phone"),
300 "component" => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentGeneric","TABCLASS" =>"componenttabs", "ACL"=> "component"));
302 if(isset($tabs[$sw])){
303 $class = $tabs[$sw]["CLASS"];
304 $tabname = $tabs[$sw]["TABNAME"];
305 $tabclass = $tabs[$sw]["TABCLASS"];
306 $acl_cat = $tabs[$sw]["ACL"];
308 /* Load permissions for selected 'dn' and check if
309 we're allowed to remove this 'dn' */
310 $ui = get_userinfo();
311 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname);
312 if(preg_match("/c/",$tabacl)){
313 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
314 $this->systab->set_acl_base($this->DivListSystem->selectedBase);
315 $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
316 $this->systab->base = $this->DivListSystem->selectedBase;
317 }else{
318 print_red(_("You are not allowed to create a new object of this type."));
319 }
320 }
321 }
323 /********************
324 Edit system ...
325 ********************/
327 /* User wants to edit data? */
328 if (($s_action == "edit") && (!isset($this->systab->config))){
330 $this->dn= $this->terminals[$s_entry]['dn'];
332 /* Check locking, save current plugin in 'back_plugin', so
333 the dialog knows where to return. */
334 if (($user= get_lock($this->dn)) != ""){
335 return(gen_locked_message ($user, $this->dn));
336 }
338 /* Find out more about the object type */
339 $ldap= $this->config->get_ldap_link();
340 $ldap->cat($this->dn, array('objectClass','gotoMode'));
341 $attrs= $ldap->fetch();
342 $type= $this->get_system_type($attrs);
344 /* Lock the current entry, so everyone will get the
345 above dialog */
346 $tabs = array(
347 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
348 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation"),
349 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server"),
350 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer"),
351 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone"),
352 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation"),
353 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component"));
356 if($type == "ArpNewDevice"){
357 $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn);
358 }elseif($type == "NewDevice"){
359 $this->systab = new SelectDeviceType($this->config,$this->dn) ;
360 }elseif(isset($tabs[$type])){
362 $class = $tabs[$type]["CLASS"];
363 $acl_cat = $tabs[$type]["ACL"];
364 $tabclass = $tabs[$type]["TABCLASS"];
366 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat);
367 $this->systab->set_acl_base($this->dn);
368 session::set('objectinfo',$this->dn);
369 add_lock ($this->dn, $this->ui->dn);
370 }else{
371 print_red (_("You can't edit this object type yet!"));
372 del_lock($this->dn);
373 }
374 }
377 /********************
378 Change password ...
379 ********************/
381 /* Set terminals root password */
382 if ($s_action=="change_pw"){
383 $tabs = array(
384 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
385 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"));
387 $type = $this->get_system_type($this->terminals[$s_entry]);
388 $class = $tabs[$type]["CLASS"];
389 $tabname = $tabs[$type]["TABNAME"];
390 $acl_cat = $tabs[$type]["ACL"];
391 $tabclass = $tabs[$type]["TABCLASS"];
392 $ui = get_userinfo();
393 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
394 if(preg_match("/w/",$tabacl)){
395 $this->dn= $this->terminals[$s_entry]['dn'];
396 session::set('objectinfo',$this->dn);
397 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
398 }else{
399 print_red(_("You are not allowed to change the password for this object."));
400 }
401 }
404 /********************
405 Password change finish, but check if entered data is ok
406 ********************/
408 /* Correctly specified? */
409 if (isset($_POST['password_finish'])){
410 if ($_POST['new_password'] != $_POST['repeated_password']){
411 print_red (_("Passwords entered as new and repeated do not match!"));
412 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
413 }
414 }
416 /********************
417 Password change finish
418 ********************/
420 /* Change terminal password */
421 if (isset($_POST['password_finish']) &&
422 $_POST['new_password'] == $_POST['repeated_password']){
424 /* Check if user is allowed to set password */
425 $tabs = array(
426 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
427 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"));
429 /* Detect object type */
430 $type = "";
431 foreach($this->terminals as $terminal){
432 if($terminal['dn'] == $this->dn){
433 $type = $this->get_system_type($terminal);
434 break;
435 }
436 }
438 /* Type detected */
439 if(!empty($type)){
441 /* Get infos */
442 $class = $tabs[$type]["CLASS"];
443 $tabname = $tabs[$type]["TABNAME"];
444 $acl_cat = $tabs[$type]["ACL"];
445 $tabclass = $tabs[$type]["TABCLASS"];
447 /* Get acls */
448 $ui = get_userinfo();
449 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
451 /* Check acls */
452 if(preg_match("/w/",$tabacl)){
453 $ldap = $this->config->get_ldap_link();
454 $ldap->cd($this->dn);
456 $attrs= array();
457 if ($_POST['new_password'] == ""){
458 $attrs['gotoRootPasswd']= array();
459 } else {
460 $attrs['gotoRootPasswd']= crypt($_POST['new_password'],substr(session_id(),0,2));
461 }
462 $ldap->modify($attrs);
463 new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error());
464 }else{
465 print_red(_("You are not allowed to change the password for this object."));
466 }
467 }else{
468 print_red(_("Can't detect object to change password."));
469 }
470 session::un_set('objectinfo');
471 }
474 /********************
475 Delete system cancel
476 ********************/
478 /* Delete terminal canceled? */
479 if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
480 del_lock ($this->dn);
481 session::un_set('objectinfo');
482 }
485 /********************
486 Action for MULTIPLE entries requested
487 ********************/
488 if (preg_match("/(halt|reboot|reinstall|update|wake|)_multiple/", $s_action)){
489 $this->dns = array();
490 $ids = $this->list_get_selected_items();
492 if(count($ids)){
493 $mac= array();
494 $ldap = $this->config->get_ldap_link();
496 foreach($ids as $id){
497 $ldap->cat ($this->terminals[$id]['dn'], array("macAddress"));
498 $attrs= $ldap->fetch();
499 if (isset($attrs['macAddress'][0])){
500 $mac[]= $attrs['macAddress'][0];
501 }
502 }
504 /* Action.... */
505 $action= preg_replace('/_multiple.*$/', '', $s_action);
506 gosaSupportDaemon::send("gosa_trigger_action_".$action, $mac, array("macAddress" => $mac));
508 }
509 }
512 /********************
513 Delete MULTIPLE entries requested, display confirm dialog
514 ********************/
516 if ($s_action=="del_multiple"){
517 $this->dns = array();
518 $ids = $this->list_get_selected_items();
520 if(count($ids)){
522 foreach($ids as $id){
523 $dn = $this->terminals[$id]['dn'];
524 $this->dns[$id] = $dn;
525 }
526 if ($user= get_multiple_locks($this->dns)){
527 return(gen_locked_message($user,$this->dns));
528 }
530 $dns_names = "<br><pre>";
531 foreach($this->dns as $dn){
532 add_lock ($dn, $this->ui->dn);
533 $dns_names .= $dn."\n";
534 }
535 $dns_names .="</pre>";
537 /* Lock the current entry, so nobody will edit it during deletion */
538 if (count($this->dns) == 1){
539 $smarty->assign("warning", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
540 } else {
541 $smarty->assign("warning", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
542 }
543 $smarty->assign("multiple", true);
544 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
545 }
546 }
549 /********************
550 Delete MULTIPLE entries confirmed
551 ********************/
553 /* Confirmation for deletion has been passed. Users should be deleted. */
554 if (isset($_POST['delete_multiple_system_confirm'])){
556 $ui = get_userinfo();
557 $tabs = array(
558 "ArpNewDevice"=> array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
559 "NewDevice" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
560 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
561 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
562 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
563 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
564 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
565 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
566 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
569 /* Remove user by user and check acls before removeing them */
570 foreach($this->dns as $key => $dn){
572 /* Get 'dn' from posted termlinst */
573 $attrs = $this->terminals[$key];
574 $type= $this->get_system_type($attrs);
576 /* get object type */
577 $tabtype = "termtabs";
578 $tabobj = "TERMTABS";
579 $tabacl = "";
580 if(isset($tabs[$type])){
581 $tabtype = $tabs[$type]['TABCLASS'];
582 $tabobj = $tabs[$type]['CLASS'];
583 $tabacl = $ui->get_permissions($dn,$tabs[$type]['ACL']);
585 /* Load permissions for selected 'dn' and check if
586 we're allowed to remove this 'dn' */
587 if(preg_match("/d/",$tabacl)){
589 /* Delete request is permitted, perform LDAP action */
590 if($tabtype=="phonetabs"){
591 $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
592 $this->systab->set_acl_base($dn);
593 $this->systab->by_object['phoneGeneric']->remove_from_parent ();
594 }else{
595 $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $dn,$type);
596 $this->systab->set_acl_base($dn);
597 $this->systab->delete();
598 }
599 unset ($this->systab);
600 $this->systab= NULL;
602 } else {
603 /* Normally this shouldn't be reached, send some extra
604 logs to notify the administrator */
605 print_red (_("You are not allowed to delete this component!"));
606 new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
607 }
608 /* Remove lock file after successfull deletion */
609 del_lock ($dn);
610 unset($this->dns[$key]);
611 }
612 }
613 }
615 /********************
616 Delete MULTIPLE entries Canceled
617 ********************/
619 /* Remove lock */
620 if(isset($_POST['delete_multiple_system_cancel'])){
621 foreach($this->dns as $key => $dn){
622 del_lock ($dn);
623 unset($this->dns[$key]);
624 }
625 }
628 /********************
629 Delete system, confirm dialog
630 ********************/
632 /* Remove terminal was requested */
633 if ($s_action=="del"){
635 /* Get 'dn' from posted termlinst */
636 $this->dn = $this->terminals[$s_entry]['dn'];
637 $attrs = $this->terminals[$s_entry];
641 $type= $this->get_system_type($attrs);
642 $ui = get_userinfo();
643 $tabs = array(
644 "ArpNewDevice"=> array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
645 "NewDevice" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
646 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
647 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
648 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
649 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
650 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
651 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
652 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
654 /* get object type */
655 $tabtype = "termtabs";
656 $tabobj = "TERMTABS";
657 $tabacl = "";
658 if(isset($tabs[$type])){
659 $tabtype = $tabs[$type]['TABCLASS'];
660 $tabobj = $tabs[$type]['CLASS'];
661 $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
662 }
664 /* Load permissions for selected 'dn' and check if
665 we're allowed to remove this 'dn' */
666 if(preg_match("/d/",$tabacl)){
668 /* Check locking, save current plugin in 'back_plugin', so
669 the dialog knows where to return. */
670 if (($user= get_lock($this->dn)) != ""){
671 return(gen_locked_message ($user, $this->dn));
672 }
674 /* Lock the current entry, so nobody will edit it during deletion */
675 add_lock ($this->dn, $this->ui->dn);
676 $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn)));
677 $smarty->assign("multiple", false);
678 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
679 } else {
681 /* Obviously the user isn't allowed to delete. Show message and
682 clean session. */
683 print_red (_("You are not allowed to delete this component!"));
684 }
685 }
688 /********************
689 Delete system, confirmed
690 ********************/
691 /* Confirmation for deletion has been passed. Terminal should be deleted. */
692 if (isset($_POST['delete_terminal_confirm'])){
694 /* Find out more about the object type */
695 $ldap= $this->config->get_ldap_link();
696 $ldap->cat($this->dn, array('objectClass'));
697 $attrs= $ldap->fetch();
698 $type= $this->get_system_type($attrs);
700 $ui = get_userinfo();
702 $tabs = array(
703 "ArpNewDevice"=> array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
704 "NewDevice" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
705 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
706 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
707 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
708 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
709 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
710 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
711 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
713 /* get object type */
714 $tabtype = "termtabs";
715 $tabobj = "TERMTABS";
716 $tabacl = "";
717 if(isset($tabs[$type])){
718 $tabtype = $tabs[$type]['TABCLASS'];
719 $tabobj = $tabs[$type]['CLASS'];
720 $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
721 }
723 /* Check if we are allowed to remove this object */
724 if(preg_match("/d/",$tabacl)){
726 /* Delete request is permitted, perform LDAP action */
727 if($tabtype=="phonetabs"){
728 $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type);
729 $this->systab->set_acl_base($this->dn);
730 $this->systab->by_object['phoneGeneric']->remove_from_parent ();
731 }else{
732 $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $this->dn,$type);
733 $this->systab->set_acl_base($this->dn);
734 $this->systab->delete();
735 }
736 unset ($this->systab);
737 $this->systab= NULL;
739 /* Terminal list has changed, reload it. */
740 } else {
742 /* Normally this shouldn't be reached, send some extra
743 logs to notify the administrator */
744 print_red (_("You are not allowed to delete this component!"));
745 new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
746 }
748 /* Remove lock file after successfull deletion */
749 del_lock ($this->dn);
750 }
760 /********************
761 Edit system type finished, check if everything went ok
762 ********************/
763 /* Finish user edit is triggered by the tabulator dialog, so
764 the user wants to save edited data. Check and save at this
765 point. */
766 if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->systab->config)) || $save_object_directly){
768 /* Check tabs, will feed message array */
769 $message = array();
770 if(!$save_object_directly){
771 $message = $this->systab->check();
772 }else{
773 $found = false;
775 /* Set gotoMode to active if we there was an ogroup selected . (save_object_directly) */
776 foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"active") as $tab => $value){
777 if(isset($this->systab->by_object[$tab]->gotoMode)) {
778 $found = true;
779 $this->systab->by_object[$tab]->gotoMode = $value;
780 }
781 }
782 if(!$found){
783 print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified.")));
784 }
786 }
787 /* Save, or display error message? */
788 if (count($message) == 0){
790 /* Incoming behavior; you can select a system type and an ogroup membership.
791 * If this object is an Incoming object, session::get('SelectedSystemType') isset.
792 * Check if we must add the new object to an object group.
793 *
794 * If this is done, delete the old incoming entry... it is still there, because this is a new
795 * entry and not an edited one, so we will delete it.
796 *
797 */
799 if(session::is_set('SelectedSystemType')){
800 $SelectedSystemType = session::get('SelectedSystemType');
801 if($SelectedSystemType['ogroup'] != "none"){
802 $og = new ogroup($this->config,$SelectedSystemType['ogroup']);
803 if($og){
804 $og->AddDelMembership($this->systab->dn);
805 $og->save();
806 }
807 }
808 }
810 /* Save terminal data to ldap */
811 $SelectedSystemType = session::get('SelectedSystemType');
812 if(isset($SelectedSystemType['ogroup']) && $SelectedSystemType['ogroup'] != 'none'){
813 foreach (array("workservice", "termservice") as $cls){
814 if (isset($this->systab->by_object[$cls])){
815 $this->systab->by_object[$cls]->gotoXMouseport= "";
816 $this->systab->by_object[$cls]->gotoXMouseType= "";
817 $this->systab->by_object[$cls]->gotoXResolution= "";
818 $this->systab->by_object[$cls]->gotoXColordepth= "";
819 }
820 }
821 }
823 $this->systab->save();
825 if(session::is_set('SelectedSystemType')){
826 session::un_set('SelectedSystemType');
827 if(!isset($ldap)){
828 $ldap = $this->config->get_ldap_link();
829 }
830 $ldap->cd ($this->dn);
831 $ldap->cat($this->dn, array('dn'));
832 if(count($ldap->fetch())){
833 $ldap->cd($this->dn);
834 $ldap->rmDir($this->dn);
835 }
836 $ldap->cd($this->config->current['BASE']);
837 }
839 /* Terminal has been saved successfully, remove lock from LDAP. */
840 if (!isset($_POST['edit_apply'])){
841 if ($this->dn != "new"){
842 del_lock ($this->dn);
843 }
845 unset ($this->systab);
846 $this->systab= NULL;
847 session::un_set('objectinfo');
848 }
849 } else {
850 /* Ok. There seem to be errors regarding to the tab data,
851 show message and continue as usual. */
852 show_errors($message);
853 }
854 }
857 /********************
858 Edit system was canceled
859 ********************/
860 /* Cancel dialogs */
861 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){
862 if (isset($this->systab)){
863 del_lock ($this->systab->dn);
864 unset ($this->systab);
865 }
866 $this->systab= NULL;
867 session::un_set('objectinfo');
869 /* Remove ogroup selection, which was set while editing a new incoming entry */
870 if(session::is_set('SelectedSystemType')){
871 session::un_set('SelectedSystemType');
872 }
873 }
875 /********************
876 Display edit dialog, or some other
877 ********************/
879 /* Show tab dialog if object is present */
880 if (isset($this->systab->config)){
881 $display= $this->systab->execute();
883 /* Don't show buttons if tab dialog requests this */
885 $dialog = FALSE;
886 $hide_apply = $this->dn == "new";
887 if(is_object($this->systab) && !isset($this->systab->by_object)){
888 $dialog = TRUE;
889 $hide_apply = TRUE;
890 }elseif(isset($this->systab->by_object[$this->systab->current]->dialog)){
891 $dia = $this->systab->by_object[$this->systab->current]->dialog;
892 if($dia === TRUE || is_object($dia)){
893 $dialog = TRUE;
894 }
895 }
896 if(isset($this->systab->current) && isset($this->systab->by_object[$this->systab->current]->netConfigDNS) &&
897 $this->systab->by_object[$this->systab->current]->netConfigDNS->dialog){
898 $dialog = TRUE;
899 }
901 if (!$dialog){
902 $display.= "<p style=\"text-align:right\">\n";
903 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
904 $display.= " \n";
905 if (!$hide_apply){
906 $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
907 $display.= " \n";
908 }
909 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
910 $display.= "</p>";
911 }
912 return ($display);
913 }
915 /* Check if there is a snapshot dialog open */
916 $base = $this->DivListSystem->selectedBase;
917 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
918 return($str);
919 }
921 /* Display dialog with system list */
922 $this->DivListSystem->parent = $this;
923 $this->DivListSystem->execute();
925 /* Add departments if subsearch is disabled */
926 if(!$this->DivListSystem->SubSearch){
927 $this->DivListSystem->AddDepartments($this->DivListSystem->selectedBase,3,1);
928 }
929 $this->reload();
930 $this->DivListSystem->setEntries($this->terminals);
931 return($this->DivListSystem->Draw());
932 }
935 /* Return departments, that will be included within snapshot detection */
936 function get_used_snapshot_bases()
937 {
938 $tmp = array();
940 /* Check acls, if we are not allowed to create and write each plugin tab, skip this object */
942 $tabs = array(
943 "terminal" => get_ou('terminalou'),
944 "workstation" => get_ou('workstationou'),
945 "incoming" => get_ou('incomingou'),
946 "server" => get_ou('serverou'),
947 "printer" => get_ou('printerou'),
948 "phone" => get_ou('phoneou'),
949 "winworkstation" => get_winstations_ou(),
950 "component" => get_ou('componentou')
951 );
953 foreach($tabs as $acl_cat => $dn){
955 $acl_all = $this->ui->has_complete_category_acls($dn.$this->DivListSystem->selectedBase,$acl_cat);
956 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
957 $tmp[] = $dn.$this->DivListSystem->selectedBase;
958 }
959 }
960 return($tmp);
961 }
964 function remove_from_parent()
965 {
966 /* Optionally execute a command after we're done */
967 $this->postremove();
968 }
971 /* Save data to object */
972 function save_object()
973 {
974 $this->DivListSystem->save_object();
975 }
978 /* Check values */
979 function check()
980 {
981 }
984 /* Save to LDAP */
985 function save()
986 {
987 }
989 function adapt_from_template($dn)
990 {
991 }
993 function password_change_needed()
994 {
995 }
997 function reload()
998 {
999 /* some var init */
1000 $ui = get_userinfo();
1001 $res = array();
1002 $this->terminals = array();
1003 $userregex = "";
1005 /* Set base for all searches */
1006 $base= $this->DivListSystem->selectedBase;
1008 /* Prepare samba class name */
1009 $samba ="";
1010 if ($this->DivListSystem->ShowWinWorkstations){
1011 if ($this->config->current['SAMBAVERSION'] == "3"){
1012 $samba= "sambaSamAccount";
1013 } else {
1014 $samba= "sambaAccount";
1015 }
1016 }
1018 /* This array represents the combination between checkboxes and search filters */
1019 $objs = array(
1020 "ShowServers" => array("CLASS" => "goServer" ,"TREE" => get_ou('serverou')),
1021 "ShowTerminals" => array("CLASS" => "gotoTerminal" ,"TREE" => get_ou('terminalou')),
1022 "ShowPrinters" => array("CLASS" => "gotoPrinter" ,"TREE" => get_ou('printerou')),
1023 "ShowDevices" => array("CLASS" => "ieee802Device" ,"TREE" => get_ou('componentou')),
1024 "ShowPhones" => array("CLASS" => "goFonHardware" ,"TREE" => get_ou('phoneou')),
1025 "ShowWorkstations" => array("CLASS" => "gotoWorkstation" ,"TREE" => get_ou('workstationou')),
1026 "ShowWinWorkstations"=> array("CLASS" => $samba ,"TREE" => get_winstations_ou() ));
1028 /* Include the 'Display Systems of user' attribute */
1029 if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){
1030 $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")";
1031 }
1033 /* Attributes to fetch */
1034 $sys_attrs = array("cn", "description", "macAddress", "objectClass", "sambaDomainName","gotoMode");
1035 $sys_categories = array("terminal", "workstation", "server", "phone" ,"printer","incoming");
1037 /* Add FAIstate to attributes if FAI is activated */
1038 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
1039 if(!empty($tmp)){
1040 $sys_attrs[] = "FAIstate";
1041 }
1043 /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled */
1044 $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
1045 foreach($objs as $checkBox => $oc){
1046 if($this->DivListSystem->$checkBox){
1047 if($this->DivListSystem->SubSearch){
1048 if($oc['CLASS'] != ""){
1049 $new_res = get_sub_list($filter, $sys_categories ,$oc['TREE'], $base,$sys_attrs, GL_SUBSEARCH | GL_SIZELIMIT);
1050 $res = array_merge($res,$new_res);
1051 }
1052 }else{
1053 /* User filter? */
1054 if($oc['CLASS'] != ""){
1055 $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_SIZELIMIT));
1056 }
1057 }
1058 }
1059 }
1061 /* Search for incoming objects */
1062 $res = array_merge($res,get_list($filter,$sys_categories, get_ou('incomingou').$base,$sys_attrs, GL_SIZELIMIT));
1064 /* Get all gotoTerminal's */
1065 foreach ($res as $value){
1067 $tmp= $value['dn'];
1068 $add= "";
1070 /* Extract base */
1071 foreach($objs as $obj){
1072 if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){
1073 $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn']));
1074 }
1075 }
1077 /* Create a string containing the last part of the department. */
1078 $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp)));
1079 if(empty($dn_name)){
1080 $dn_name = "/";
1081 }
1083 /* check if current object is a new one */
1084 if (preg_match ("/,".get_ou('incomingou')."/i", $tmp)){
1085 if (in_array_ics('gotoTerminal', $value['objectClass'])){
1086 $add= "- "._("New terminal");
1087 }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){
1088 $add= "- "._("New workstation");
1089 }elseif (in_array_ics('GOhard', $value['objectClass']) && !isset($value['gotoMode'])){
1090 $add= "- "._("Unknown device");
1091 }elseif (in_array_ics('GOhard', $value['objectClass'])){
1092 $add= "- "._("New Device");
1093 }
1094 }
1096 /* Detect type of object and create an entry for $this->terminals */
1097 $terminal = array();
1098 if (in_array_ics('gotoTerminal', $value["objectClass"])){
1100 /* check acl */
1101 $acl = $ui->get_permissions($value['dn'],"terminal/termgeneric");
1102 if($add != "" || preg_match("/r/",$acl)) {
1103 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1104 $terminal = $value;
1105 $terminal['type'] = "T";
1106 $terminal['is_new'] = $add;
1107 } else {
1108 $terminal = $value;
1109 $terminal['type'] = "D";
1110 $terminal['message'] = _("Terminal template for")." '".$dn_name."' ";
1111 $terminal['location'] = array_search($tmp, $this->config->departments);
1112 }
1113 }
1114 } elseif (in_array_ics('gotoWorkstation', $value["objectClass"])){
1116 $acl = $ui->get_permissions($value['dn'],"workstation/workgeneric");
1117 if($add != "" || preg_match("/r/",$acl)) {
1118 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1119 $terminal = $value;
1120 $terminal['type'] = "L";
1121 $terminal['is_new'] = $add;
1122 } else {
1123 $terminal = $value;
1124 $terminal['type'] = "D";
1125 $terminal['location'] = array_search($tmp, $this->config->departments);
1126 $terminal['message'] = _("Workstation template for")." '".$dn_name."' ";
1127 }
1128 if (isset($value["FAIstate"][0])){
1129 $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1130 }
1131 }
1132 } elseif (in_array_ics('gotoPrinter', $value["objectClass"])){
1135 $acl = $ui->get_permissions($value['dn'],"printer/printgeneric");
1136 if($add != "" || preg_match("/r/",$acl)) {
1138 $terminal = $value;
1139 $terminal['type'] = "P";
1140 }
1141 } elseif (in_array_ics('goServer', $value["objectClass"])){
1143 $acl = $ui->get_permissions($value['dn'],"server/servgeneric");
1144 if($add != "" || preg_match("/r/",$acl)) {
1146 $terminal = $value;
1147 $terminal['type'] = "S";
1148 if (isset($value["FAIstate"][0])){
1149 $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1150 }
1151 }
1152 } elseif (in_array_ics('goFonHardware', $value["objectClass"])){
1154 $acl = $ui->get_permissions($value['dn'],"phone/phoneGeneric");
1155 if($add != "" || preg_match("/r/",$acl)) {
1157 $terminal = $value;
1158 $terminal['type'] = "F";
1159 }
1160 }elseif (in_array_ics("GOhard",$value['objectClass'])){
1162 $acl = $ui->get_permissions($value['dn'],"server/servgeneric").
1163 $ui->get_permissions($value['dn'],"terminal/termgeneric").
1164 $ui->get_permissions($value['dn'],"workstation/workgeneric");
1165 if($add != "" || preg_match("/r/",$acl)) {
1167 $terminal = $value;
1168 $terminal['type'] = "Q";
1169 $terminal['is_new'] = $add;
1170 }
1171 } elseif (in_array_ics('ieee802Device', $value["objectClass"])){
1173 $acl = $ui->get_permissions($value['dn'],"component/componentGeneric");
1174 if($add != "" || preg_match("/r/",$acl)) {
1176 $terminal = $value;
1177 $terminal['type'] = "C";
1178 }
1179 } else{
1181 $name= preg_replace('/\$$/', '', $value['cn'][0]);
1182 if (isset($value['sambaDomainName'])){
1183 $domain= " [".$value['sambaDomainName'][0]."]";
1184 } else {
1185 $domain= "";
1186 }
1187 $terminal=$value;
1188 $terminal['type'] ="W";
1189 $terminal['domain'] = $name.$domain;
1190 }
1192 if(count($terminal)){
1193 $this->terminals[]=$terminal;
1194 }
1195 }
1197 $tmp =array();
1198 $tmp2 =array();
1199 foreach($this->terminals as $tkey => $val ){
1200 $tmp[strtolower($val['cn'][0]).$val['dn']]=$val;
1201 $tmp2[strtolower($val['cn'][0]).$val['dn']] = strtolower($val['cn'][0]).$val['dn'];
1202 }
1203 natcasesort($tmp2);
1204 $this->terminals=array();
1205 foreach($tmp2 as $val){
1206 $this->terminals[]=$tmp[$val];
1207 }
1208 reset ($this->terminals);
1209 }
1211 function remove_lock()
1212 {
1213 if (isset($this->systab->dn)){
1214 del_lock ($this->systab->dn);
1215 }
1216 }
1219 function copyPasteHandling_from_queue($s_action,$s_entry)
1220 {
1221 /* Check if Copy & Paste is disabled */
1222 if(!is_object($this->CopyPasteHandler)){
1223 return("");
1224 }
1227 $tabs = array(
1228 "terminal" => array( "CLASS" =>"TERMTABS", "TABNAME" =>"termgeneric",
1229 "TABCLASS" =>"termtabs", "ACL" =>"terminal"),
1230 "workstation" => array( "CLASS" =>"WORKTABS", "TABNAME" =>"workgeneric",
1231 "TABCLASS" =>"worktabs", "ACL" =>"workstation"),
1232 "server" => array( "CLASS" =>"SERVTABS", "TABNAME" =>"servgeneric",
1233 "TABCLASS" =>"servtabs", "ACL" =>"server"),
1234 "printer" => array( "CLASS" =>"PRINTTABS", "TABNAME" =>"printgeneric",
1235 "TABCLASS" =>"printtabs", "ACL" =>"printer"),
1236 "phone" => array( "CLASS" =>"PHONETABS", "TABNAME" =>"phoneGeneric",
1237 "TABCLASS" =>"phonetabs", "ACL" =>"phone"),
1238 "component" => array( "CLASS" =>"COMPONENTTABS","TABNAME" =>"componentGeneric",
1239 "TABCLASS" =>"componenttabs","ACL" =>"component"));
1241 /* Add a single entry to queue */
1242 if($s_action == "cut" || $s_action == "copy"){
1244 /* Cleanup object queue */
1245 $this->CopyPasteHandler->cleanup_queue();
1246 $dn = $this->terminals[$s_entry]['dn'];
1247 $oc = $this->terminals[$s_entry]['objectClass'];
1248 $type = $this->get_system_type($this->terminals[$s_entry]);
1250 $tab_o = $tabs[$type]['CLASS'];
1251 $tab_c = $tabs[$type]['TABCLASS'];
1252 $acl = $tabs[$type]['ACL'];
1254 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl);
1255 }
1257 /* Add entries to queue */
1258 if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
1260 /* Cleanup object queue */
1261 $this->CopyPasteHandler->cleanup_queue();
1263 /* Add new entries to CP queue */
1264 foreach($this->list_get_selected_items() as $id){
1265 $dn = $this->terminals[$id]['dn'];
1266 $oc = $this->terminals[$id]['objectClass'];
1267 $type = $this->get_system_type($this->terminals[$id]);
1269 if(isset($tabs[$type])){
1270 $tab_o = $tabs[$type]['CLASS'];
1271 $tab_c = $tabs[$type]['TABCLASS'];
1272 $acl = $tabs[$type]['ACL'];
1274 if($s_action == "copy_multiple"){
1275 $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl);
1276 }
1277 if($s_action == "cut_multiple"){
1278 $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl);
1279 }
1280 }
1281 }
1282 }
1284 /* Start pasting entries */
1285 if($s_action == "editPaste"){
1286 $this->start_pasting_copied_objects = TRUE;
1287 }
1289 /* Return C&P dialog */
1290 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1292 /* Load entry from queue and set base */
1293 $this->CopyPasteHandler->load_entry_from_queue();
1294 $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase);
1296 /* Get dialog */
1297 $data = $this->CopyPasteHandler->execute();
1299 /* Return dialog data */
1300 if(!empty($data)){
1301 return($data);
1302 }
1303 }
1305 /* Automatically disable status for pasting */
1306 if(!$this->CopyPasteHandler->entries_queued()){
1307 $this->start_pasting_copied_objects = FALSE;
1308 }
1309 return("");
1310 }
1313 function get_system_type($attrs)
1314 {
1315 $classes = $attrs['objectClass'];
1317 $type= "";
1318 if (in_array_ics('ieee802Device', $classes)){
1319 $type= "component";
1320 }elseif (in_array_ics('gotoTerminal', $classes)){
1321 $type= "terminal";
1322 }elseif (in_array_ics('gotoWorkstation', $classes)){
1323 $type= "workstation";
1324 }elseif (in_array_ics('gotoPrinter', $classes)){
1325 $type= "printer";
1326 }elseif (in_array_ics('goFonHardware', $classes)){
1327 $type= "phone";
1328 }elseif (in_array_ics('goServer', $classes)){
1329 $type= "server";
1330 }elseif (in_array_ics('GOhard', $classes) && !isset($attrs['gotoMode']) && $this->arp_handling_active){
1331 $type= "ArpNewDevice";
1332 }elseif (in_array_ics('GOhard', $classes)){
1333 $type= "NewDevice";
1334 }elseif (in_array_ics('sambaAccount', $classes) ||
1335 in_array_ics('sambaSamAccount', $classes)){
1336 $type= "winstation";
1337 }
1338 return ($type);
1339 }
1342 function convert_list($input)
1343 {
1344 $temp= "";
1345 $conv= array(
1346 "NQ" => array("select_newsystem.png",_("New System from incoming")),
1347 "D" => array("select_default.png",_("Template")),
1348 "T" => array("select_terminal.png",_("Terminal")),
1349 "L" => array("select_workstation.png",_("Workstation")),
1350 "GL" => array("select_workstation_green.png",_("Workstation is installing")),
1351 "YL" => array("select_workstation_yellow.png",_("Workstation is waiting for action")),
1352 "RL" => array("select_workstation_red.png",_("Workstation installation failed")),
1353 "F" => array("select_phone.png",_("Phone")),
1354 "S" => array("select_server.png",_("Server")),
1355 "GS" => array("select_server_green.png",_("Server is installing")),
1356 "YS" => array("select_server_yellow.png",_("Server is waiting for action")),
1357 "RS" => array("select_server_red.png",_("Server installation failed")),
1358 "W" => array("select_winstation.png",_("Winstation")),
1359 "C" => array("select_component.png",_("Network Device")),
1360 "NT"=> array("select_new_terminal.png",_("New Terminal")),
1361 "NL"=> array("select_new_workstation.png",_("New Workstation")),
1362 "P" => array("select_printer.png",_("Printer")));
1364 if((isset($input['is_new']))&&(!empty($input['is_new']))){
1365 $input['type']="N".$input['type'];
1366 }
1367 foreach ($conv as $key => $value){
1368 if($input['type']==$key){
1369 $tmp['img'] ="<img class='center' src='images/".$value[0]."' alt='".$key."' title='".$value['1']."'>";
1370 $tmp['class']=$key;
1371 return $tmp;
1372 }
1373 }
1374 }
1377 function getState($type, $state)
1378 {
1379 switch (preg_replace('/:.*$/', '', $state)) {
1380 case 'installing':
1381 $type= 'G'.$type;
1382 break;
1383 case 'error':
1384 $type= 'R'.$type;
1385 break;
1386 case 'install':
1387 case 'sysinfo':
1388 case 'softupdate':
1389 case 'scheduledupdate':
1390 $type= 'Y'.$type;
1391 break;
1392 }
1395 return ($type);
1396 }
1399 function list_get_selected_items()
1400 {
1401 $ids = array();
1402 foreach($_POST as $name => $value){
1403 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1404 $id = preg_replace("/^item_selected_/","",$name);
1405 $ids[$id] = $id;
1406 }
1407 }
1408 return($ids);
1409 }
1412 /* !! Incoming dummy acls, required to defined acls for incoming objects
1413 */
1414 static function plInfo()
1415 {
1416 return (array(
1417 "plShortName" => _("Incoming objects"),
1418 "plDescription" => _("Incoming objects"),
1419 "plSelfModify" => FALSE,
1420 "plDepends" => array(),
1421 "plPriority" => 99,
1422 "plSection" => array("administration"),
1423 "plCategory" => array("incoming" => array( "description" => _("Incoming"),
1424 "objectClass" => "")),
1425 "plProvidedAcls"=> array()
1427 ));
1428 }
1433 }
1435 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1436 ?>