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