9e1fd2cb5457c989fcf03b18532fdf52fc8acca6
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 }
150 /* Check for exeeded sizelimit */
151 if (($message= check_sizelimit()) != ""){
152 return($message);
153 }
155 /* Try to get informations about what kind of system to create */
156 if ($s_action=="new") {
157 return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
158 }
161 /********************
162 Copy & Paste Handling ...
163 ********************/
165 /* Display the copy & paste dialog, if it is currently open */
166 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
167 if($ret){
168 return($ret);
169 }
172 /********************
173 Create FAI CD ...
174 ********************/
175 if ($s_action=="gen_cd"){
176 $this->dn= $this->terminals[$s_entry]['dn'];
177 session::set('objectinfo',$this->dn);
178 return ($smarty->fetch(get_template_path('gencd.tpl', TRUE)));
179 }
182 /* Start CD-Creation */
183 if ((isset($_POST["cd_create"])) && !empty($this->dn)){
184 $smarty->assign("src", "?plug=".$_GET['plug']."&PerformIsoCreation");
185 return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE)));
186 }
189 if ($this->dn != "" && isset($_GET['PerformIsoCreation'])){
191 $return_button = "<form method='get' action='main.php' target='_parent'>
192 <input type='submit' value='"._("Back")."'>
193 <input type='hidden' name='plug' value='".$_GET['plug']."'/>
194 </form>";
196 $dsc = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
198 /* Get and check command */
199 $command= $this->config->search("workgeneric", "ISOCMD",array('tabs'));
201 if (check_command($command)){
202 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
204 /* Print out html introduction */
205 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
206 <html>
207 <head>
208 <title></title>
209 <style type="text/css">@import url("themes/default/style.css");</style>
210 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
211 </head>
212 <body style="background: none; margin:4px;" id="body" >
213 <pre>';
215 /* Open process handle and check if it is a valid process */
216 $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
217 if (is_resource($process)) {
218 fclose($pipes[0]);
220 /* Print out returned lines && write JS to scroll down each line */
221 while (!feof($pipes[1])){
222 $cur_dat = fgets($pipes[1], 1024);
223 echo $cur_dat;
224 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
225 flush();
226 }
227 }
229 /* Get error string && close streams */
230 $buffer= stream_get_contents($pipes[2]);
232 fclose($pipes[1]);
233 fclose($pipes[2]);
234 echo "</pre>";
236 /* Check return code */
237 $ret= proc_close($process);
238 if ($ret != 0){
239 echo "<h1 style='color:red'>"._("Creating the image failed. Please see the report below.")."</h1>";
240 echo "<pre style='color:red'>$buffer</pre>";
241 }
245 echo $return_button."<br>";
247 } else {
248 $tmp= "<h1 style='color:red'>".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."</h1>";
249 echo $tmp;
250 }
252 /* Scroll down completly */
253 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
254 echo '</body></html>';
255 flush();
256 exit;
257 }
260 /********************
261 Create new system ...
262 ********************/
263 /* Create new default terminal
264 * Or create specified object of selected system type, from given incoming object
265 */
267 $save_object_directly = false;
268 if(($s_action == "SelectedSystemType") && (isset($_POST['ObjectGroup']) && ($_POST['ObjectGroup'] != "none"))){
269 $save_object_directly = true;
270 }
272 if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") {
274 /* If the current entry is an incoming object
275 * $sw = System type as posted in new incoming handling dialog
276 */
277 if($s_action == "SelectedSystemType") {
278 $sw = $s_entry;
279 }else{
280 if(isset($_POST['system'])){
281 $sw = $_POST['system'];
282 }else{
283 $sw = $s_entry;
284 }
285 $this->dn= "new";
286 }
288 $tabs = array(
289 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
290 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"),
291 "server" => array("CLASS"=>"SERVTABS", "TABNAME"=>"servgeneric", "TABCLASS" =>"servtabs", "ACL"=> "server"),
292 "printer" => array("CLASS"=>"PRINTTABS", "TABNAME"=>"printgeneric", "TABCLASS" =>"printtabs", "ACL"=> "printer"),
293 "phone" => array("CLASS"=>"PHONETABS", "TABNAME"=>"phoneGeneric", "TABCLASS" =>"phonetabs", "ACL"=> "phone"),
294 "component" => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentGeneric","TABCLASS" =>"componenttabs", "ACL"=> "component"));
296 if(isset($tabs[$sw])){
297 $class = $tabs[$sw]["CLASS"];
298 $tabname = $tabs[$sw]["TABNAME"];
299 $tabclass = $tabs[$sw]["TABCLASS"];
300 $acl_cat = $tabs[$sw]["ACL"];
302 /* Load permissions for selected 'dn' and check if
303 we're allowed to remove this 'dn' */
304 $ui = get_userinfo();
305 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname);
306 if(preg_match("/c/",$tabacl)){
307 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
308 $this->systab->set_acl_base($this->DivListSystem->selectedBase);
309 $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
310 $this->systab->base = $this->DivListSystem->selectedBase;
311 }else{
312 print_red(_("You are not allowed to create a new object of this type."));
313 }
314 }
315 }
317 /********************
318 Edit system ...
319 ********************/
321 /* User wants to edit data? */
322 if (($s_action == "edit") && (!isset($this->systab->config))){
324 $this->dn= $this->terminals[$s_entry]['dn'];
326 /* Check locking, save current plugin in 'back_plugin', so
327 the dialog knows where to return. */
328 if (($user= get_lock($this->dn)) != ""){
329 return(gen_locked_message ($user, $this->dn));
330 }
332 /* Find out more about the object type */
333 $ldap= $this->config->get_ldap_link();
334 $ldap->cat($this->dn, array('objectClass','gotoMode'));
335 $attrs= $ldap->fetch();
336 $type= $this->get_system_type($attrs);
338 /* Lock the current entry, so everyone will get the
339 above dialog */
340 $tabs = array(
341 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
342 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation"),
343 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server"),
344 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer"),
345 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone"),
346 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation"),
347 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component"));
350 if($type == "ArpNewDevice"){
351 $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn);
352 }elseif($type == "NewDevice"){
353 $this->systab = new SelectDeviceType($this->config,$this->dn) ;
354 }elseif(isset($tabs[$type])){
356 $class = $tabs[$type]["CLASS"];
357 $acl_cat = $tabs[$type]["ACL"];
358 $tabclass = $tabs[$type]["TABCLASS"];
360 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat);
361 $this->systab->set_acl_base($this->dn);
362 session::set('objectinfo',$this->dn);
363 add_lock ($this->dn, $this->ui->dn);
364 }else{
365 print_red (_("You can't edit this object type yet!"));
366 del_lock($this->dn);
367 }
368 }
371 /********************
372 Change password ...
373 ********************/
375 /* Set terminals root password */
376 if ($s_action=="change_pw"){
377 $tabs = array(
378 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
379 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"));
381 $type = $this->get_system_type($this->terminals[$s_entry]);
382 $class = $tabs[$type]["CLASS"];
383 $tabname = $tabs[$type]["TABNAME"];
384 $acl_cat = $tabs[$type]["ACL"];
385 $tabclass = $tabs[$type]["TABCLASS"];
386 $ui = get_userinfo();
387 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
388 if(preg_match("/w/",$tabacl)){
389 $this->dn= $this->terminals[$s_entry]['dn'];
390 session::set('objectinfo',$this->dn);
391 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
392 }else{
393 print_red(_("You are not allowed to change the password for this object."));
394 }
395 }
398 /********************
399 Password change finish, but check if entered data is ok
400 ********************/
402 /* Correctly specified? */
403 if (isset($_POST['password_finish'])){
404 if ($_POST['new_password'] != $_POST['repeated_password']){
405 print_red (_("Passwords entered as new and repeated do not match!"));
406 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
407 }
408 }
410 /********************
411 Password change finish
412 ********************/
414 /* Change terminal password */
415 if (isset($_POST['password_finish']) &&
416 $_POST['new_password'] == $_POST['repeated_password']){
418 /* Check if user is allowed to set password */
419 $tabs = array(
420 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
421 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"));
423 /* Detect object type */
424 $type = "";
425 foreach($this->terminals as $terminal){
426 if($terminal['dn'] == $this->dn){
427 $type = $this->get_system_type($terminal);
428 break;
429 }
430 }
432 /* Type detected */
433 if(!empty($type)){
435 /* Get infos */
436 $class = $tabs[$type]["CLASS"];
437 $tabname = $tabs[$type]["TABNAME"];
438 $acl_cat = $tabs[$type]["ACL"];
439 $tabclass = $tabs[$type]["TABCLASS"];
441 /* Get acls */
442 $ui = get_userinfo();
443 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
445 /* Check acls */
446 if(preg_match("/w/",$tabacl)){
447 $ldap = $this->config->get_ldap_link();
448 $ldap->cd($this->dn);
450 $attrs= array();
451 if ($_POST['new_password'] == ""){
452 $attrs['gotoRootPasswd']= array();
453 } else {
454 $attrs['gotoRootPasswd']= crypt($_POST['new_password'],substr(session_id(),0,2));
455 }
456 $ldap->modify($attrs);
457 new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error());
458 }else{
459 print_red(_("You are not allowed to change the password for this object."));
460 }
461 }else{
462 print_red(_("Can't detect object to change password."));
463 }
464 session::un_set('objectinfo');
465 }
468 /********************
469 Delete system cancel
470 ********************/
472 /* Delete terminal canceled? */
473 if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
474 del_lock ($this->dn);
475 session::un_set('objectinfo');
476 }
479 /********************
480 Delete MULTIPLE entries requested, display confirm dialog
481 ********************/
483 if ($s_action=="del_multiple"){
484 $this->dns = array();
485 $ids = $this->list_get_selected_items();
487 if(count($ids)){
489 foreach($ids as $id){
490 $dn = $this->terminals[$id]['dn'];
491 $this->dns[$id] = $dn;
492 }
493 if ($user= get_multiple_locks($this->dns)){
494 return(gen_locked_message($user,$this->dns));
495 }
497 $dns_names = "<br><pre>";
498 foreach($this->dns as $dn){
499 add_lock ($dn, $this->ui->dn);
500 $dns_names .= $dn."\n";
501 }
502 $dns_names .="</pre>";
504 /* Lock the current entry, so nobody will edit it during deletion */
505 if (count($this->dns) == 1){
506 $smarty->assign("warning", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
507 } else {
508 $smarty->assign("warning", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
509 }
510 $smarty->assign("multiple", true);
511 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
512 }
513 }
516 /********************
517 Delete MULTIPLE entries confirmed
518 ********************/
520 /* Confirmation for deletion has been passed. Users should be deleted. */
521 if (isset($_POST['delete_multiple_system_confirm'])){
523 $ui = get_userinfo();
524 $tabs = array(
525 "ArpNewDevice"=> array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
526 "NewDevice" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
527 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
528 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
529 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
530 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
531 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
532 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
533 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
536 /* Remove user by user and check acls before removeing them */
537 foreach($this->dns as $key => $dn){
539 /* Get 'dn' from posted termlinst */
540 $attrs = $this->terminals[$key];
541 $type= $this->get_system_type($attrs);
543 /* get object type */
544 $tabtype = "termtabs";
545 $tabobj = "TERMTABS";
546 $tabacl = "";
547 if(isset($tabs[$type])){
548 $tabtype = $tabs[$type]['TABCLASS'];
549 $tabobj = $tabs[$type]['CLASS'];
550 $tabacl = $ui->get_permissions($dn,$tabs[$type]['ACL']);
552 /* Load permissions for selected 'dn' and check if
553 we're allowed to remove this 'dn' */
554 if(preg_match("/d/",$tabacl)){
556 /* Delete request is permitted, perform LDAP action */
557 if($tabtype=="phonetabs"){
558 $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
559 $this->systab->set_acl_base($dn);
560 $this->systab->by_object['phoneGeneric']->remove_from_parent ();
561 }else{
562 $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $dn,$type);
563 $this->systab->set_acl_base($dn);
564 $this->systab->delete();
565 }
566 unset ($this->systab);
567 $this->systab= NULL;
569 } else {
570 /* Normally this shouldn't be reached, send some extra
571 logs to notify the administrator */
572 print_red (_("You are not allowed to delete this component!"));
573 new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
574 }
575 /* Remove lock file after successfull deletion */
576 del_lock ($dn);
577 unset($this->dns[$key]);
578 }
579 }
580 }
582 /********************
583 Delete MULTIPLE entries Canceled
584 ********************/
586 /* Remove lock */
587 if(isset($_POST['delete_multiple_system_cancel'])){
588 foreach($this->dns as $key => $dn){
589 del_lock ($dn);
590 unset($this->dns[$key]);
591 }
592 }
595 /********************
596 Delete system, confirm dialog
597 ********************/
599 /* Remove terminal was requested */
600 if ($s_action=="del"){
602 /* Get 'dn' from posted termlinst */
603 $this->dn = $this->terminals[$s_entry]['dn'];
604 $attrs = $this->terminals[$s_entry];
608 $type= $this->get_system_type($attrs);
609 $ui = get_userinfo();
610 $tabs = array(
611 "ArpNewDevice"=> array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
612 "NewDevice" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
613 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
614 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
615 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
616 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
617 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
618 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
619 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
621 /* get object type */
622 $tabtype = "termtabs";
623 $tabobj = "TERMTABS";
624 $tabacl = "";
625 if(isset($tabs[$type])){
626 $tabtype = $tabs[$type]['TABCLASS'];
627 $tabobj = $tabs[$type]['CLASS'];
628 $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
629 }
631 /* Load permissions for selected 'dn' and check if
632 we're allowed to remove this 'dn' */
633 if(preg_match("/d/",$tabacl)){
635 /* Check locking, save current plugin in 'back_plugin', so
636 the dialog knows where to return. */
637 if (($user= get_lock($this->dn)) != ""){
638 return(gen_locked_message ($user, $this->dn));
639 }
641 /* Lock the current entry, so nobody will edit it during deletion */
642 add_lock ($this->dn, $this->ui->dn);
643 $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn)));
644 $smarty->assign("multiple", false);
645 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
646 } else {
648 /* Obviously the user isn't allowed to delete. Show message and
649 clean session. */
650 print_red (_("You are not allowed to delete this component!"));
651 }
652 }
655 /********************
656 Delete system, confirmed
657 ********************/
658 /* Confirmation for deletion has been passed. Terminal should be deleted. */
659 if (isset($_POST['delete_terminal_confirm'])){
661 /* Find out more about the object type */
662 $ldap= $this->config->get_ldap_link();
663 $ldap->cat($this->dn, array('objectClass'));
664 $attrs= $ldap->fetch();
665 $type= $this->get_system_type($attrs);
667 $ui = get_userinfo();
669 $tabs = array(
670 "ArpNewDevice"=> array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
671 "NewDevice" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "incoming/systems"),
672 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
673 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
674 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
675 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
676 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
677 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
678 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
680 /* get object type */
681 $tabtype = "termtabs";
682 $tabobj = "TERMTABS";
683 $tabacl = "";
684 if(isset($tabs[$type])){
685 $tabtype = $tabs[$type]['TABCLASS'];
686 $tabobj = $tabs[$type]['CLASS'];
687 $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
688 }
690 /* Check if we are allowed to remove this object */
691 if(preg_match("/d/",$tabacl)){
693 /* Delete request is permitted, perform LDAP action */
694 if($tabtype=="phonetabs"){
695 $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type);
696 $this->systab->set_acl_base($this->dn);
697 $this->systab->by_object['phoneGeneric']->remove_from_parent ();
698 }else{
699 $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $this->dn,$type);
700 $this->systab->set_acl_base($this->dn);
701 $this->systab->delete();
702 }
703 unset ($this->systab);
704 $this->systab= NULL;
706 /* Terminal list has changed, reload it. */
707 } else {
709 /* Normally this shouldn't be reached, send some extra
710 logs to notify the administrator */
711 print_red (_("You are not allowed to delete this component!"));
712 new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
713 }
715 /* Remove lock file after successfull deletion */
716 del_lock ($this->dn);
717 }
727 /********************
728 Edit system type finished, check if everything went ok
729 ********************/
730 /* Finish user edit is triggered by the tabulator dialog, so
731 the user wants to save edited data. Check and save at this
732 point. */
733 if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->systab->config)) || $save_object_directly){
735 /* Check tabs, will feed message array */
736 $message = array();
737 if(!$save_object_directly){
738 $message = $this->systab->check();
739 }else{
740 $found = false;
742 /* Set gotoMode to active if we there was an ogroup selected . (save_object_directly) */
743 foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"active") as $tab => $value){
744 if(isset($this->systab->by_object[$tab]->gotoMode)) {
745 $found = true;
746 $this->systab->by_object[$tab]->gotoMode = $value;
747 }
748 }
749 if(!$found){
750 print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified.")));
751 }
753 }
754 /* Save, or display error message? */
755 if (count($message) == 0){
757 /* Incoming behavior; you can select a system type and an ogroup membership.
758 * If this object is an Incoming object, session::get('SelectedSystemType') isset.
759 * Check if we must add the new object to an object group.
760 *
761 * If this is done, delete the old incoming entry... it is still there, because this is a new
762 * entry and not an edited one, so we will delete it.
763 *
764 */
766 if(session::is_set('SelectedSystemType')){
767 $SelectedSystemType = session::get('SelectedSystemType');
768 if($SelectedSystemType['ogroup'] != "none"){
769 $og = new ogroup($this->config,$SelectedSystemType['ogroup']);
770 if($og){
771 $og->AddDelMembership($this->systab->dn);
772 $og->save();
773 }
774 }
775 }
777 /* Save terminal data to ldap */
778 $SelectedSystemType = session::get('SelectedSystemType');
779 if(isset($SelectedSystemType['ogroup']) && $SelectedSystemType['ogroup'] != 'none'){
780 foreach (array("workservice", "termservice") as $cls){
781 if (isset($this->systab->by_object[$cls])){
782 $this->systab->by_object[$cls]->gotoXMouseport= "";
783 $this->systab->by_object[$cls]->gotoXMouseType= "";
784 $this->systab->by_object[$cls]->gotoXResolution= "";
785 $this->systab->by_object[$cls]->gotoXColordepth= "";
786 }
787 }
788 }
790 $this->systab->save();
792 if(session::is_set('SelectedSystemType')){
793 session::un_set('SelectedSystemType');
794 if(!isset($ldap)){
795 $ldap = $this->config->get_ldap_link();
796 }
797 $ldap->cd ($this->dn);
798 $ldap->cat($this->dn, array('dn'));
799 if(count($ldap->fetch())){
800 $ldap->cd($this->dn);
801 $ldap->rmDir($this->dn);
802 }
803 $ldap->cd($this->config->current['BASE']);
804 }
806 /* Terminal has been saved successfully, remove lock from LDAP. */
807 if (!isset($_POST['edit_apply'])){
808 if ($this->dn != "new"){
809 del_lock ($this->dn);
810 }
812 unset ($this->systab);
813 $this->systab= NULL;
814 session::un_set('objectinfo');
815 }
816 } else {
817 /* Ok. There seem to be errors regarding to the tab data,
818 show message and continue as usual. */
819 show_errors($message);
820 }
821 }
824 /********************
825 Edit system was canceled
826 ********************/
827 /* Cancel dialogs */
828 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){
829 if (isset($this->systab)){
830 del_lock ($this->systab->dn);
831 unset ($this->systab);
832 }
833 $this->systab= NULL;
834 session::un_set('objectinfo');
836 /* Remove ogroup selection, which was set while editing a new incoming entry */
837 if(session::is_set('SelectedSystemType')){
838 session::un_set('SelectedSystemType');
839 }
840 }
842 /********************
843 Display edit dialog, or some other
844 ********************/
846 /* Show tab dialog if object is present */
847 if (isset($this->systab->config)){
848 $display= $this->systab->execute();
850 /* Don't show buttons if tab dialog requests this */
852 $dialog = FALSE;
853 $hide_apply = $this->dn == "new";
854 if(is_object($this->systab) && !isset($this->systab->by_object)){
855 $dialog = TRUE;
856 $hide_apply = TRUE;
857 }elseif(isset($this->systab->by_object[$this->systab->current]->dialog)){
858 $dia = $this->systab->by_object[$this->systab->current]->dialog;
859 if($dia === TRUE || is_object($dia)){
860 $dialog = TRUE;
861 }
862 }
863 if(isset($this->systab->current) && isset($this->systab->by_object[$this->systab->current]->netConfigDNS) &&
864 $this->systab->by_object[$this->systab->current]->netConfigDNS->dialog){
865 $dialog = TRUE;
866 }
868 if (!$dialog){
869 $display.= "<p style=\"text-align:right\">\n";
870 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
871 $display.= " \n";
872 if (!$hide_apply){
873 $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
874 $display.= " \n";
875 }
876 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
877 $display.= "</p>";
878 }
879 return ($display);
880 }
882 /* Check if there is a snapshot dialog open */
883 $base = $this->DivListSystem->selectedBase;
884 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
885 return($str);
886 }
888 /* Display dialog with system list */
889 $this->DivListSystem->parent = $this;
890 $this->DivListSystem->execute();
892 /* Add departments if subsearch is disabled */
893 if(!$this->DivListSystem->SubSearch){
894 $this->DivListSystem->AddDepartments($this->DivListSystem->selectedBase,3,1);
895 }
896 $this->reload();
897 $this->DivListSystem->setEntries($this->terminals);
898 return($this->DivListSystem->Draw());
899 }
902 /* Return departments, that will be included within snapshot detection */
903 function get_used_snapshot_bases()
904 {
905 $tmp = array();
907 /* Check acls, if we are not allowed to create and write each plugin tab, skip this object */
909 $tabs = array(
910 "terminal" => get_ou('terminalou'),
911 "workstation" => get_ou('workstationou'),
912 "incoming" => get_ou('incomingou'),
913 "server" => get_ou('serverou'),
914 "printer" => get_ou('printerou'),
915 "phone" => get_ou('phoneou'),
916 "winworkstation" => get_winstations_ou(),
917 "component" => get_ou('componentou')
918 );
920 foreach($tabs as $acl_cat => $dn){
922 $acl_all = $this->ui->has_complete_category_acls($dn.$this->DivListSystem->selectedBase,$acl_cat);
923 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
924 $tmp[] = $dn.$this->DivListSystem->selectedBase;
925 }
926 }
927 return($tmp);
928 }
931 function remove_from_parent()
932 {
933 /* Optionally execute a command after we're done */
934 $this->postremove();
935 }
938 /* Save data to object */
939 function save_object()
940 {
941 $this->DivListSystem->save_object();
942 }
945 /* Check values */
946 function check()
947 {
948 }
951 /* Save to LDAP */
952 function save()
953 {
954 }
956 function adapt_from_template($dn)
957 {
958 }
960 function password_change_needed()
961 {
962 }
964 function reload()
965 {
966 /* some var init */
967 $ui = get_userinfo();
968 $res = array();
969 $this->terminals = array();
970 $userregex = "";
972 /* Set base for all searches */
973 $base= $this->DivListSystem->selectedBase;
975 /* Prepare samba class name */
976 $samba ="";
977 if ($this->DivListSystem->ShowWinWorkstations){
978 if ($this->config->current['SAMBAVERSION'] == "3"){
979 $samba= "sambaSamAccount";
980 } else {
981 $samba= "sambaAccount";
982 }
983 }
985 /* This array represents the combination between checkboxes and search filters */
986 $objs = array(
987 "ShowServers" => array("CLASS" => "goServer" ,"TREE" => get_ou('serverou')),
988 "ShowTerminals" => array("CLASS" => "gotoTerminal" ,"TREE" => get_ou('terminalou')),
989 "ShowPrinters" => array("CLASS" => "gotoPrinter" ,"TREE" => get_ou('printerou')),
990 "ShowDevices" => array("CLASS" => "ieee802Device" ,"TREE" => get_ou('componentou')),
991 "ShowPhones" => array("CLASS" => "goFonHardware" ,"TREE" => get_ou('phoneou')),
992 "ShowWorkstations" => array("CLASS" => "gotoWorkstation" ,"TREE" => get_ou('workstationou')),
993 "ShowWinWorkstations"=> array("CLASS" => $samba ,"TREE" => get_winstations_ou() ));
995 /* Include the 'Display Systems of user' attribute */
996 if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){
997 $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")";
998 }
1000 /* Attributes to fetch */
1001 $sys_attrs = array("cn", "description", "macAddress", "objectClass", "sambaDomainName","gotoMode");
1002 $sys_categories = array("terminal", "workstation", "server", "phone" ,"printer","incoming");
1004 /* Add FAIstate to attributes if FAI is activated */
1005 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
1006 if(!empty($tmp)){
1007 $sys_attrs[] = "FAIstate";
1008 }
1010 /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled */
1011 $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
1012 foreach($objs as $checkBox => $oc){
1013 if($this->DivListSystem->$checkBox){
1014 if($this->DivListSystem->SubSearch){
1015 if($oc['CLASS'] != ""){
1016 $new_res = get_sub_list($filter, $sys_categories ,$oc['TREE'], $base,$sys_attrs, GL_SUBSEARCH | GL_SIZELIMIT);
1017 $res = array_merge($res,$new_res);
1018 }
1019 }else{
1020 /* User filter? */
1021 if($oc['CLASS'] != ""){
1022 $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_SIZELIMIT));
1023 }
1024 }
1025 }
1026 }
1028 /* Search for incoming objects */
1029 $res = array_merge($res,get_list($filter,$sys_categories, get_ou('incomingou').$base,$sys_attrs, GL_SIZELIMIT));
1031 /* Get all gotoTerminal's */
1032 foreach ($res as $value){
1034 $tmp= $value['dn'];
1035 $add= "";
1037 /* Extract base */
1038 foreach($objs as $obj){
1039 if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){
1040 $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn']));
1041 }
1042 }
1044 /* Create a string containing the last part of the department. */
1045 $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp)));
1046 if(empty($dn_name)){
1047 $dn_name = "/";
1048 }
1050 /* check if current object is a new one */
1051 if (preg_match ("/,".get_ou('incomingou')."/i", $tmp)){
1052 if (in_array_ics('gotoTerminal', $value['objectClass'])){
1053 $add= "- "._("New terminal");
1054 }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){
1055 $add= "- "._("New workstation");
1056 }elseif (in_array_ics('GOhard', $value['objectClass']) && !isset($value['gotoMode'])){
1057 $add= "- "._("Unknown device");
1058 }elseif (in_array_ics('GOhard', $value['objectClass'])){
1059 $add= "- "._("New Device");
1060 }
1061 }
1063 /* Detect type of object and create an entry for $this->terminals */
1064 $terminal = array();
1065 if (in_array_ics('gotoTerminal', $value["objectClass"])){
1067 /* check acl */
1068 $acl = $ui->get_permissions($value['dn'],"terminal/termgeneric");
1069 if($add != "" || preg_match("/r/",$acl)) {
1070 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1071 $terminal = $value;
1072 $terminal['type'] = "T";
1073 $terminal['is_new'] = $add;
1074 } else {
1075 $terminal = $value;
1076 $terminal['type'] = "D";
1077 $terminal['message'] = _("Terminal template for")." '".$dn_name."' ";
1078 $terminal['location'] = array_search($tmp, $this->config->departments);
1079 }
1080 }
1081 } elseif (in_array_ics('gotoWorkstation', $value["objectClass"])){
1083 $acl = $ui->get_permissions($value['dn'],"workstation/workgeneric");
1084 if($add != "" || preg_match("/r/",$acl)) {
1085 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1086 $terminal = $value;
1087 $terminal['type'] = "L";
1088 $terminal['is_new'] = $add;
1089 } else {
1090 $terminal = $value;
1091 $terminal['type'] = "D";
1092 $terminal['location'] = array_search($tmp, $this->config->departments);
1093 $terminal['message'] = _("Workstation template for")." '".$dn_name."' ";
1094 }
1095 if (isset($value["FAIstate"][0])){
1096 $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1097 }
1098 }
1099 } elseif (in_array_ics('gotoPrinter', $value["objectClass"])){
1102 $acl = $ui->get_permissions($value['dn'],"printer/printgeneric");
1103 if($add != "" || preg_match("/r/",$acl)) {
1105 $terminal = $value;
1106 $terminal['type'] = "P";
1107 }
1108 } elseif (in_array_ics('goServer', $value["objectClass"])){
1110 $acl = $ui->get_permissions($value['dn'],"server/servgeneric");
1111 if($add != "" || preg_match("/r/",$acl)) {
1113 $terminal = $value;
1114 $terminal['type'] = "S";
1115 if (isset($value["FAIstate"][0])){
1116 $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1117 }
1118 }
1119 } elseif (in_array_ics('goFonHardware', $value["objectClass"])){
1121 $acl = $ui->get_permissions($value['dn'],"phone/phoneGeneric");
1122 if($add != "" || preg_match("/r/",$acl)) {
1124 $terminal = $value;
1125 $terminal['type'] = "F";
1126 }
1127 }elseif (in_array_ics("GOhard",$value['objectClass'])){
1129 $acl = $ui->get_permissions($value['dn'],"server/servgeneric").
1130 $ui->get_permissions($value['dn'],"terminal/termgeneric").
1131 $ui->get_permissions($value['dn'],"workstation/workgeneric");
1132 if($add != "" || preg_match("/r/",$acl)) {
1134 $terminal = $value;
1135 $terminal['type'] = "Q";
1136 $terminal['is_new'] = $add;
1137 }
1138 } elseif (in_array_ics('ieee802Device', $value["objectClass"])){
1140 $acl = $ui->get_permissions($value['dn'],"component/componentGeneric");
1141 if($add != "" || preg_match("/r/",$acl)) {
1143 $terminal = $value;
1144 $terminal['type'] = "C";
1145 }
1146 } else{
1148 $name= preg_replace('/\$$/', '', $value['cn'][0]);
1149 if (isset($value['sambaDomainName'])){
1150 $domain= " [".$value['sambaDomainName'][0]."]";
1151 } else {
1152 $domain= "";
1153 }
1154 $terminal=$value;
1155 $terminal['type'] ="W";
1156 $terminal['domain'] = $name.$domain;
1157 }
1159 if(count($terminal)){
1160 $this->terminals[]=$terminal;
1161 }
1162 }
1164 $tmp =array();
1165 $tmp2 =array();
1166 foreach($this->terminals as $tkey => $val ){
1167 $tmp[strtolower($val['cn'][0]).$val['dn']]=$val;
1168 $tmp2[strtolower($val['cn'][0]).$val['dn']] = strtolower($val['cn'][0]).$val['dn'];
1169 }
1170 natcasesort($tmp2);
1171 $this->terminals=array();
1172 foreach($tmp2 as $val){
1173 $this->terminals[]=$tmp[$val];
1174 }
1175 reset ($this->terminals);
1176 }
1178 function remove_lock()
1179 {
1180 if (isset($this->systab->dn)){
1181 del_lock ($this->systab->dn);
1182 }
1183 }
1186 function copyPasteHandling_from_queue($s_action,$s_entry)
1187 {
1188 /* Check if Copy & Paste is disabled */
1189 if(!is_object($this->CopyPasteHandler)){
1190 return("");
1191 }
1194 $tabs = array(
1195 "terminal" => array( "CLASS" =>"TERMTABS", "TABNAME" =>"termgeneric",
1196 "TABCLASS" =>"termtabs", "ACL" =>"terminal"),
1197 "workstation" => array( "CLASS" =>"WORKTABS", "TABNAME" =>"workgeneric",
1198 "TABCLASS" =>"worktabs", "ACL" =>"workstation"),
1199 "server" => array( "CLASS" =>"SERVTABS", "TABNAME" =>"servgeneric",
1200 "TABCLASS" =>"servtabs", "ACL" =>"server"),
1201 "printer" => array( "CLASS" =>"PRINTTABS", "TABNAME" =>"printgeneric",
1202 "TABCLASS" =>"printtabs", "ACL" =>"printer"),
1203 "phone" => array( "CLASS" =>"PHONETABS", "TABNAME" =>"phoneGeneric",
1204 "TABCLASS" =>"phonetabs", "ACL" =>"phone"),
1205 "component" => array( "CLASS" =>"COMPONENTTABS","TABNAME" =>"componentGeneric",
1206 "TABCLASS" =>"componenttabs","ACL" =>"component"));
1208 /* Add a single entry to queue */
1209 if($s_action == "cut" || $s_action == "copy"){
1211 /* Cleanup object queue */
1212 $this->CopyPasteHandler->cleanup_queue();
1213 $dn = $this->terminals[$s_entry]['dn'];
1214 $oc = $this->terminals[$s_entry]['objectClass'];
1215 $type = $this->get_system_type($this->terminals[$s_entry]);
1217 $tab_o = $tabs[$type]['CLASS'];
1218 $tab_c = $tabs[$type]['TABCLASS'];
1219 $acl = $tabs[$type]['ACL'];
1221 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl);
1222 }
1224 /* Add entries to queue */
1225 if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
1227 /* Cleanup object queue */
1228 $this->CopyPasteHandler->cleanup_queue();
1230 /* Add new entries to CP queue */
1231 foreach($this->list_get_selected_items() as $id){
1232 $dn = $this->terminals[$id]['dn'];
1233 $oc = $this->terminals[$id]['objectClass'];
1234 $type = $this->get_system_type($this->terminals[$id]);
1236 if(isset($tabs[$type])){
1237 $tab_o = $tabs[$type]['CLASS'];
1238 $tab_c = $tabs[$type]['TABCLASS'];
1239 $acl = $tabs[$type]['ACL'];
1241 if($s_action == "copy_multiple"){
1242 $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl);
1243 }
1244 if($s_action == "cut_multiple"){
1245 $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl);
1246 }
1247 }
1248 }
1249 }
1251 /* Start pasting entries */
1252 if($s_action == "editPaste"){
1253 $this->start_pasting_copied_objects = TRUE;
1254 }
1256 /* Return C&P dialog */
1257 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1259 /* Load entry from queue and set base */
1260 $this->CopyPasteHandler->load_entry_from_queue();
1261 $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase);
1263 /* Get dialog */
1264 $data = $this->CopyPasteHandler->execute();
1266 /* Return dialog data */
1267 if(!empty($data)){
1268 return($data);
1269 }
1270 }
1272 /* Automatically disable status for pasting */
1273 if(!$this->CopyPasteHandler->entries_queued()){
1274 $this->start_pasting_copied_objects = FALSE;
1275 }
1276 return("");
1277 }
1280 function get_system_type($attrs)
1281 {
1282 $classes = $attrs['objectClass'];
1284 $type= "";
1285 if (in_array_ics('ieee802Device', $classes)){
1286 $type= "component";
1287 }elseif (in_array_ics('gotoTerminal', $classes)){
1288 $type= "terminal";
1289 }elseif (in_array_ics('gotoWorkstation', $classes)){
1290 $type= "workstation";
1291 }elseif (in_array_ics('gotoPrinter', $classes)){
1292 $type= "printer";
1293 }elseif (in_array_ics('goFonHardware', $classes)){
1294 $type= "phone";
1295 }elseif (in_array_ics('goServer', $classes)){
1296 $type= "server";
1297 }elseif (in_array_ics('GOhard', $classes) && !isset($attrs['gotoMode']) && $this->arp_handling_active){
1298 $type= "ArpNewDevice";
1299 }elseif (in_array_ics('GOhard', $classes)){
1300 $type= "NewDevice";
1301 }elseif (in_array_ics('sambaAccount', $classes) ||
1302 in_array_ics('sambaSamAccount', $classes)){
1303 $type= "winstation";
1304 }
1305 return ($type);
1306 }
1309 function convert_list($input)
1310 {
1311 $temp= "";
1312 $conv= array(
1313 "NQ" => array("select_newsystem.png",_("New System from incoming")),
1314 "D" => array("select_default.png",_("Template")),
1315 "T" => array("select_terminal.png",_("Terminal")),
1316 "L" => array("select_workstation.png",_("Workstation")),
1317 "GL" => array("select_workstation_green.png",_("Workstation is installing")),
1318 "YL" => array("select_workstation_yellow.png",_("Workstation is waiting for action")),
1319 "RL" => array("select_workstation_red.png",_("Workstation installation failed")),
1320 "F" => array("select_phone.png",_("Phone")),
1321 "S" => array("select_server.png",_("Server")),
1322 "GS" => array("select_server_green.png",_("Server is installing")),
1323 "YS" => array("select_server_yellow.png",_("Server is waiting for action")),
1324 "RS" => array("select_server_red.png",_("Server installation failed")),
1325 "W" => array("select_winstation.png",_("Winstation")),
1326 "C" => array("select_component.png",_("Network Device")),
1327 "NT"=> array("select_new_terminal.png",_("New Terminal")),
1328 "NL"=> array("select_new_workstation.png",_("New Workstation")),
1329 "P" => array("select_printer.png",_("Printer")));
1331 if((isset($input['is_new']))&&(!empty($input['is_new']))){
1332 $input['type']="N".$input['type'];
1333 }
1334 foreach ($conv as $key => $value){
1335 if($input['type']==$key){
1336 $tmp['img'] ="<img class='center' src='images/".$value[0]."' alt='".$key."' title='".$value['1']."'>";
1337 $tmp['class']=$key;
1338 return $tmp;
1339 }
1340 }
1341 }
1344 function getState($type, $state)
1345 {
1346 switch (preg_replace('/:.*$/', '', $state)) {
1347 case 'installing':
1348 $type= 'G'.$type;
1349 break;
1350 case 'error':
1351 $type= 'R'.$type;
1352 break;
1353 case 'install':
1354 case 'sysinfo':
1355 case 'softupdate':
1356 case 'scheduledupdate':
1357 $type= 'Y'.$type;
1358 break;
1359 }
1362 return ($type);
1363 }
1366 function list_get_selected_items()
1367 {
1368 $ids = array();
1369 foreach($_POST as $name => $value){
1370 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1371 $id = preg_replace("/^item_selected_/","",$name);
1372 $ids[$id] = $id;
1373 }
1374 }
1375 return($ids);
1376 }
1379 /* !! Incoming dummy acls, required to defined acls for incoming objects
1380 */
1381 static function plInfo()
1382 {
1383 return (array(
1384 "plShortName" => _("Incoming objects"),
1385 "plDescription" => _("Incoming objects"),
1386 "plSelfModify" => FALSE,
1387 "plDepends" => array(),
1388 "plPriority" => 99,
1389 "plSection" => array("administration"),
1390 "plCategory" => array("incoming" => array( "description" => _("Incoming"),
1391 "objectClass" => "")),
1392 "plProvidedAcls"=> array()
1394 ));
1395 }
1400 }
1402 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1403 ?>