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