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