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 }
109 /* Incoming handling
110 * If someone made a systemtype and ogroup selection
111 * Display the new requested entry type ... servtab in case of server and so on.
112 */
113 if(isset($_POST['SystemTypeChoosen'])){
114 $s_action = "SelectedSystemType";
115 $s_entry = $_POST['SystemType'];
116 $_SESSION['SelectedSystemType']['ogroup'] = $_POST['ObjectGroup'];
117 $this->systab = NULL;
118 }
120 /* remove image tags from posted entry (posts looks like this 'name_x')*/
121 $s_entry = preg_replace("/_.$/","",$s_entry);
123 /* Edit was requested by pressing the name(link) of an item */
124 if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){
125 $s_action ="edit";
126 $s_entry = $_GET['id'];
127 }
129 /* Check for exeeded sizelimit */
130 if (($message= check_sizelimit()) != ""){
131 return($message);
132 }
134 /* Try to get informations about what kind of system to create */
135 if ($s_action=="new") {
136 return ($smarty->fetch(get_template_path('chooser.tpl', TRUE)));
137 }
140 /********************
141 Copy & Paste Handling ...
142 ********************/
144 /* Display the copy & paste dialog, if it is currently open */
145 $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
146 if($ret){
147 return($ret);
148 }
151 /********************
152 Create FAI CD ...
153 ********************/
154 if ($s_action=="gen_cd"){
155 $this->dn= $this->terminals[$s_entry]['dn'];
156 $_SESSION['objectinfo']= $this->dn;
157 return ($smarty->fetch(get_template_path('gencd.tpl', TRUE)));
158 }
161 /* Start CD-Creation */
162 if ((isset($_POST["cd_create"])) && !empty($this->dn)){
163 $smarty->assign("src", "?plug=".$_GET['plug']."&PerformIsoCreation");
164 return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE)));
165 }
168 if ($this->dn != "" && isset($_GET['PerformIsoCreation'])){
170 $return_button = "<form method='get' action='main.php' target='_parent'>
171 <input type='submit' value='"._("Back")."'>
172 <input type='hidden' name='plug' value='".$_GET['plug']."'/>
173 </form>";
175 $dsc = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
177 /* Get and check command */
178 $command= $this->config->search("workgeneric", "ISOCMD",array('tabs'));
180 if (check_command($command)){
181 @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execute");
183 /* Print out html introduction */
184 echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
185 <html>
186 <head>
187 <title></title>
188 <style type="text/css">@import url("themes/default/style.css");</style>
189 <script language="javascript" src="include/focus.js" type="text/javascript"></script>
190 </head>
191 <body style="background: none; margin:4px;" id="body" >
192 <pre>';
194 /* Open process handle and check if it is a valid process */
195 $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
196 if (is_resource($process)) {
197 fclose($pipes[0]);
199 /* Print out returned lines && write JS to scroll down each line */
200 while (!feof($pipes[1])){
201 $cur_dat = fgets($pipes[1], 1024);
202 echo $cur_dat;
203 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
204 flush();
205 }
206 }
208 /* Get error string && close streams */
209 $buffer= stream_get_contents($pipes[2]);
211 fclose($pipes[1]);
212 fclose($pipes[2]);
213 echo "</pre>";
215 /* Check return code */
216 $ret= proc_close($process);
217 if ($ret != 0){
218 echo "<h1 style='color:red'>"._("Creating the image failed. Please see the report below.")."</h1>";
219 echo "<pre style='color:red'>$buffer</pre>";
220 }
224 echo $return_button."<br>";
226 } else {
227 $tmp= "<h1 style='color:red'>".sprintf(_("Command '%s', specified for ISO creation doesn't seem to exist."), $command)."</h1>";
228 echo $tmp;
229 }
231 /* Scroll down completly */
232 echo '<script language="javascript" type="text/javascript">scrollDown2();</script>' ;
233 echo '</body></html>';
234 flush();
235 exit;
236 }
239 /********************
240 Create new system ...
241 ********************/
242 /* Create new default terminal
243 * Or create specified object of selected system type, from given incoming object
244 */
246 $save_object_directly = false;
247 if(($s_action == "SelectedSystemType") && (isset($_POST['ObjectGroup']) && ($_POST['ObjectGroup'] != "none"))){
248 $save_object_directly = true;
249 }
251 if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") {
253 /* If the current entry is an incoming object
254 * $sw = System type as posted in new incoming handling dialog
255 */
256 if($s_action == "SelectedSystemType") {
257 $sw = $s_entry;
258 }else{
259 if(isset($_POST['system'])){
260 $sw = $_POST['system'];
261 }else{
262 $sw = $s_entry;
263 }
264 $this->dn= "new";
265 }
266 $tabs = array(
267 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
268 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"),
269 "server" => array("CLASS"=>"SERVTABS", "TABNAME"=>"servgeneric", "TABCLASS" =>"servtabs", "ACL"=> "server"),
270 "printer" => array("CLASS"=>"PRINTTABS", "TABNAME"=>"printgeneric", "TABCLASS" =>"printtabs", "ACL"=> "printer"),
271 "phone" => array("CLASS"=>"PHONETABS", "TABNAME"=>"phoneGeneric", "TABCLASS" =>"phonetabs", "ACL"=> "phone"),
272 "component" => array("CLASS"=>"COMPONENTTABS","TABNAME"=>"componentgeneric","TABCLASS" =>"componenttabs", "ACL"=> "component"));
274 if(isset($tabs[$sw])){
275 $class = $tabs[$sw]["CLASS"];
276 $tabname = $tabs[$sw]["TABNAME"];
277 $tabclass = $tabs[$sw]["TABCLASS"];
278 $acl_cat = $tabs[$sw]["ACL"];
280 /* Load permissions for selected 'dn' and check if
281 we're allowed to remove this 'dn' */
282 $ui = get_userinfo();
283 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname);
284 if(preg_match("/c/",$tabacl)){
285 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
286 $this->systab->set_acl_base($this->DivListSystem->selectedBase);
287 $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
288 $this->systab->base = $this->DivListSystem->selectedBase;
289 }else{
290 print_red(_("You are not allowed to create a new object of this type."));
291 }
292 }
293 }
295 /********************
296 Edit system ...
297 ********************/
299 /* User wants to edit data? */
300 if (($s_action == "edit") && (!isset($this->systab->config))){
302 $this->dn= $this->terminals[$s_entry]['dn'];
304 /* Check locking, save current plugin in 'back_plugin', so
305 the dialog knows where to return. */
306 if (($user= get_lock($this->dn)) != ""){
307 return(gen_locked_message ($user, $this->dn));
308 }
310 /* Find out more about the object type */
311 $ldap= $this->config->get_ldap_link();
312 $ldap->cat($this->dn, array('objectClass'));
313 $attrs= $ldap->fetch();
314 $type= $this->get_system_type($attrs['objectClass']);
316 /* Lock the current entry, so everyone will get the
317 above dialog */
318 $tabs = array(
319 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
320 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation"),
321 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server"),
322 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer"),
323 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone"),
324 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation"),
325 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component"));
328 if($type == "NewDevice"){
329 $this->systab = new SelectDeviceType($this->config,$this->dn) ;
330 }elseif(isset($tabs[$type])){
332 $class = $tabs[$type]["CLASS"];
333 $acl_cat = $tabs[$type]["ACL"];
334 $tabclass = $tabs[$type]["TABCLASS"];
336 $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$acl_cat);
337 $this->systab->set_acl_base($this->dn);
338 $_SESSION['objectinfo']= $this->dn;
339 add_lock ($this->dn, $this->ui->dn);
340 }else{
341 print_red (_("You can't edit this object type yet!"));
342 del_lock($this->dn);
343 }
344 }
347 /********************
348 Change password ...
349 ********************/
351 /* Set terminals root password */
352 if ($s_action=="change_pw"){
353 $tabs = array(
354 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
355 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"));
357 $type = $this->get_system_type($this->terminals[$s_entry]['objectClass']);
358 $class = $tabs[$type]["CLASS"];
359 $tabname = $tabs[$type]["TABNAME"];
360 $acl_cat = $tabs[$type]["ACL"];
361 $tabclass = $tabs[$type]["TABCLASS"];
362 $ui = get_userinfo();
363 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
364 if(preg_match("/w/",$tabacl)){
365 $this->dn= $this->terminals[$s_entry]['dn'];
366 $_SESSION['objectinfo']= $this->dn;
367 return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
368 }else{
369 print_red(_("You are not allowed to change the password for this object."));
370 }
371 }
374 /********************
375 Password change finish, but check if entered data is ok
376 ********************/
378 /* Correctly specified? */
379 if (isset($_POST['password_finish'])){
380 if ($_POST['new_password'] != $_POST['repeated_password']){
381 print_red (_("Passwords entered as new and repeated do not match!"));
382 return($smarty->fetch(get_template_path('password.tpl', TRUE)));
383 }
384 }
386 /********************
387 Password change finish
388 ********************/
390 /* Change terminal password */
391 if (isset($_POST['password_finish']) &&
392 $_POST['new_password'] == $_POST['repeated_password']){
394 /* Check if user is allowed to set password */
395 $tabs = array(
396 "terminal" => array("CLASS"=>"TERMTABS", "TABNAME"=>"termgeneric", "TABCLASS" =>"termtabs", "ACL"=> "terminal"),
397 "workstation" => array("CLASS"=>"WORKTABS", "TABNAME"=>"workgeneric", "TABCLASS" =>"worktabs", "ACL"=> "workstation"));
399 /* Detect object type */
400 $type = "";
401 foreach($this->terminals as $terminal){
402 if($terminal['dn'] == $this->dn){
403 $type = $this->get_system_type($terminal['objectClass']);
404 break;
405 }
406 }
408 /* Type detected */
409 if(!empty($type)){
411 /* Get infos */
412 $class = $tabs[$type]["CLASS"];
413 $tabname = $tabs[$type]["TABNAME"];
414 $acl_cat = $tabs[$type]["ACL"];
415 $tabclass = $tabs[$type]["TABCLASS"];
417 /* Get acls */
418 $ui = get_userinfo();
419 $tabacl = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname,"gotoRootPasswd");
421 /* Check acls */
422 if(preg_match("/w/",$tabacl)){
423 $ldap = $this->config->get_ldap_link();
424 $ldap->cd($this->dn);
426 $attrs= array();
427 if ($_POST['new_password'] == ""){
428 $attrs['gotoRootPasswd']= array();
429 } else {
430 $attrs['gotoRootPasswd']= crypt($_POST['new_password'],substr(session_id(),0,2));
431 }
432 $ldap->modify($attrs);
433 new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error());
434 }else{
435 print_red(_("You are not allowed to change the password for this object."));
436 }
437 }else{
438 print_red(_("Can't detect object to change password."));
439 }
440 unset($_SESSION['objectinfo']);
441 }
444 /********************
445 Delete system cancel
446 ********************/
448 /* Delete terminal canceled? */
449 if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){
450 del_lock ($this->dn);
451 unset($_SESSION['objectinfo']);
452 }
455 /********************
456 Delete MULTIPLE entries requested, display confirm dialog
457 ********************/
459 if ($s_action=="del_multiple"){
460 $this->dns = array();
461 $ids = $this->list_get_selected_items();
463 if(count($ids)){
465 foreach($ids as $id){
466 $dn = $this->terminals[$id]['dn'];
467 if (($user= get_lock($dn)) != ""){
468 return(gen_locked_message ($user, $dn));
469 }
470 $this->dns[$id] = $dn;
471 }
473 $dns_names = "<br><pre>";
474 foreach($this->dns as $dn){
475 add_lock ($dn, $this->ui->dn);
476 $dns_names .= $dn."\n";
477 }
478 $dns_names .="</pre>";
480 /* Lock the current entry, so nobody will edit it during deletion */
481 if (count($this->dns) == 1){
482 $smarty->assign("warning", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
483 } else {
484 $smarty->assign("warning", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
485 }
486 $smarty->assign("multiple", true);
487 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
488 }
489 }
492 /********************
493 Delete MULTIPLE entries confirmed
494 ********************/
496 /* Confirmation for deletion has been passed. Users should be deleted. */
497 if (isset($_POST['delete_multiple_system_confirm'])){
499 $ui = get_userinfo();
500 $tabs = array(
501 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
502 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
503 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
504 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
505 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
506 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
507 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
510 /* Remove user by user and check acls before removeing them */
511 foreach($this->dns as $key => $dn){
513 /* Get 'dn' from posted termlinst */
514 $attrs = $this->terminals[$key];
515 $type= $this->get_system_type($attrs['objectClass']);
517 /* get object type */
518 $tabtype = "termtabs";
519 $tabobj = "TERMTABS";
520 $tabacl = "";
521 if(isset($tabs[$type])){
522 $tabtype = $tabs[$type]['TABCLASS'];
523 $tabobj = $tabs[$type]['CLASS'];
524 $tabacl = $ui->get_permissions($dn,$tabs[$type]['ACL']);
526 /* Load permissions for selected 'dn' and check if
527 we're allowed to remove this 'dn' */
528 if(preg_match("/d/",$tabacl)){
530 /* Delete request is permitted, perform LDAP action */
531 if($tabtype=="phonetabs"){
532 $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
533 $this->systab->set_acl_base($dn);
534 $this->systab->by_object['phoneGeneric']->remove_from_parent ();
535 }else{
536 $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $dn,$type);
537 $this->systab->set_acl_base($dn);
538 $this->systab->delete();
539 }
540 unset ($this->systab);
541 $this->systab= NULL;
543 } else {
544 /* Normally this shouldn't be reached, send some extra
545 logs to notify the administrator */
546 print_red (_("You are not allowed to delete this component!"));
547 new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
548 }
549 /* Remove lock file after successfull deletion */
550 del_lock ($dn);
551 unset($this->dns[$key]);
552 }
553 }
554 }
556 /********************
557 Delete MULTIPLE entries Canceled
558 ********************/
560 /* Remove lock */
561 if(isset($_POST['delete_multiple_system_cancel'])){
562 foreach($this->dns as $key => $dn){
563 del_lock ($dn);
564 unset($this->dns[$key]);
565 }
566 }
569 /********************
570 Delete system, confirm dialog
571 ********************/
573 /* Remove terminal was requested */
574 if ($s_action=="del"){
576 /* Get 'dn' from posted termlinst */
577 $this->dn = $this->terminals[$s_entry]['dn'];
578 $attrs = $this->terminals[$s_entry];
580 $type= $this->get_system_type($attrs['objectClass']);
581 $ui = get_userinfo();
582 $tabs = array(
583 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
584 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
585 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
586 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
587 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
588 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
589 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
592 /* get object type */
593 $tabtype = "termtabs";
594 $tabobj = "TERMTABS";
595 $tabacl = "";
596 if(isset($tabs[$type])){
597 $tabtype = $tabs[$type]['TABCLASS'];
598 $tabobj = $tabs[$type]['CLASS'];
599 $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
600 }
602 /* Load permissions for selected 'dn' and check if
603 we're allowed to remove this 'dn' */
604 if(preg_match("/d/",$tabacl)){
606 /* Check locking, save current plugin in 'back_plugin', so
607 the dialog knows where to return. */
608 if (($user= get_lock($this->dn)) != ""){
609 return(gen_locked_message ($user, $this->dn));
610 }
612 /* Lock the current entry, so nobody will edit it during deletion */
613 add_lock ($this->dn, $this->ui->dn);
614 $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn)));
615 $smarty->assign("multiple", false);
616 return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
617 } else {
619 /* Obviously the user isn't allowed to delete. Show message and
620 clean session. */
621 print_red (_("You are not allowed to delete this component!"));
622 }
623 }
626 /********************
627 Delete system, confirmed
628 ********************/
629 /* Confirmation for deletion has been passed. Terminal should be deleted. */
630 if (isset($_POST['delete_terminal_confirm'])){
632 /* Find out more about the object type */
633 $ldap= $this->config->get_ldap_link();
634 $ldap->cat($this->dn, array('objectClass'));
635 $attrs= $ldap->fetch();
636 $type= $this->get_system_type($attrs['objectClass']);
638 $ui = get_userinfo();
640 $tabs = array(
641 "terminal" => array("CLASS"=>"TERMTABS", "TABCLASS" =>"termtabs", "ACL"=> "terminal/termgeneric"),
642 "workstation" => array("CLASS"=>"WORKTABS", "TABCLASS" =>"worktabs", "ACL"=> "workstation/workgeneric"),
643 "server" => array("CLASS"=>"SERVTABS", "TABCLASS" =>"servtabs", "ACL"=> "server/servgeneric"),
644 "printer" => array("CLASS"=>"PRINTTABS", "TABCLASS" =>"printtabs", "ACL"=> "printer/printgeneric"),
645 "phone" => array("CLASS"=>"PHONETABS", "TABCLASS" =>"phonetabs", "ACL"=> "phone/phoneGeneric"),
646 "winstation" => array("CLASS"=>"WINTABS", "TABCLASS" =>"wintabs", "ACL"=> "winworkstation/wingeneric"),
647 "component" => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs", "ACL"=> "component/componentGeneric"));
649 /* get object type */
650 $tabtype = "termtabs";
651 $tabobj = "TERMTABS";
652 $tabacl = "";
653 if(isset($tabs[$type])){
654 $tabtype = $tabs[$type]['TABCLASS'];
655 $tabobj = $tabs[$type]['CLASS'];
656 $tabacl = $ui->get_permissions($this->dn,$tabs[$type]['ACL']);
657 }
659 /* Check if we are allowed to remove this object */
660 if(preg_match("/d/",$tabacl)){
662 /* Delete request is permitted, perform LDAP action */
663 if($tabtype=="phonetabs"){
664 $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $this->dn,$type);
665 $this->systab->set_acl_base($this->dn);
666 $this->systab->by_object['phoneGeneric']->remove_from_parent ();
667 }else{
668 $this->systab= new $tabtype($this->config,$this->config->data['TABS'][$tabobj], $this->dn,$type);
669 $this->systab->set_acl_base($this->dn);
670 $this->systab->delete();
671 }
672 unset ($this->systab);
673 $this->systab= NULL;
675 /* Terminal list has changed, reload it. */
676 } else {
678 /* Normally this shouldn't be reached, send some extra
679 logs to notify the administrator */
680 print_red (_("You are not allowed to delete this component!"));
681 new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
682 }
684 /* Remove lock file after successfull deletion */
685 del_lock ($this->dn);
686 }
696 /********************
697 Edit system type finished, check if everything went ok
698 ********************/
699 /* Finish user edit is triggered by the tabulator dialog, so
700 the user wants to save edited data. Check and save at this
701 point. */
702 if ((isset($_POST['edit_finish'])) && (isset($this->systab->config)) || $save_object_directly){
704 /* Check tabs, will feed message array */
705 $message = array();
706 if(!$save_object_directly){
707 $message = $this->systab->check();
708 }else{
709 $found = false;
711 /* Set gotoMode to active if we there was an ogroup selected . (save_object_directly) */
712 foreach(array("workgeneric"=>"active","servgeneric"=>"active","termgeneric"=>"graphic") as $tab => $value){
713 if(isset($this->systab->by_object[$tab]->gotoMode)) {
714 $found = true;
715 $this->systab->by_object[$tab]->gotoMode = $value;
716 }
717 }
718 if(!$found){
719 print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified.")));
720 }
722 }
723 /* Save, or display error message? */
724 if (count($message) == 0){
726 /* Save terminal data to ldap */
727 if(isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){
728 foreach (array("workservice", "termservice") as $cls){
729 if (isset($this->systab->by_object[$cls])){
730 $this->systab->by_object[$cls]->gotoXMouseport= "";
731 $this->systab->by_object[$cls]->gotoXMouseType= "";
732 $this->systab->by_object[$cls]->gotoXResolution= "";
733 $this->systab->by_object[$cls]->gotoXColordepth= "";
734 }
735 }
736 }
738 $this->systab->save();
740 /* Incoming behavior; you can select a system type and an ogroup membership.
741 * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset.
742 * Check if we must add the new object to an object group.
743 *
744 * If this is done, delete the old incoming entry... it is still there, because this is a new
745 * entry and not an edited one, so we will delete it.
746 *
747 */
749 if(isset($_SESSION['SelectedSystemType'])){
750 $SelectedSystemType= $_SESSION['SelectedSystemType'];
751 unset($_SESSION['SelectedSystemType']);
752 if($SelectedSystemType['ogroup'] != "none"){
753 $og = new ogroup($this->config,$SelectedSystemType['ogroup']);
754 if($og){
755 $og->AddDelMembership($this->systab->dn);
756 $og->save();
757 }
758 }
759 if(!isset($ldap)){
760 $ldap = $this->config->get_ldap_link();
761 }
762 $ldap->cd ($this->dn);
763 $ldap->cat($this->dn, array('dn'));
764 if(count($ldap->fetch())){
765 $ldap->cd($this->dn);
766 $ldap->rmDir($this->dn);
767 }
768 $ldap->cd($this->config->current['BASE']);
769 }
771 /* Terminal has been saved successfully, remove lock from
772 LDAP. */
773 if ($this->dn != "new"){
774 del_lock ($this->dn);
775 }
777 unset ($this->systab);
778 $this->systab= NULL;
779 unset($_SESSION['objectinfo']);
780 } else {
781 /* Ok. There seem to be errors regarding to the tab data,
782 show message and continue as usual. */
783 show_errors($message);
784 }
785 }
788 /********************
789 Edit system was canceled
790 ********************/
791 /* Cancel dialogs */
792 if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){
793 if (isset($this->systab)){
794 del_lock ($this->systab->dn);
795 unset ($this->systab);
796 }
797 $this->systab= NULL;
798 unset($_SESSION['objectinfo']);
800 /* Remove ogroup selection, which was set while editing a new incoming entry */
801 if(isset($_SESSION['SelectedSystemType'])){
802 unset($_SESSION['SelectedSystemType']);
803 }
804 }
806 /********************
807 Display edit dialog, or some other
808 ********************/
810 /* Show tab dialog if object is present */
811 if (isset($this->systab->config)){
812 $display= $this->systab->execute();
814 /* Don't show buttons if tab dialog requests this */
816 $dialog = FALSE;
817 if(isset($this->systab->by_object[$this->systab->current]->dialog)){
818 $dia = $this->systab->by_object[$this->systab->current]->dialog;
819 if($dia === TRUE || is_object($dia)){
820 $dialog = TRUE;
821 }
822 }
824 if(isset($this->systab->by_object[$this->systab->current]->netConfigDNS) &&
825 $this->systab->by_object[$this->systab->current]->netConfigDNS->dialog){
826 $dialog = TRUE;
827 }
829 if (!$dialog){
830 $display.= "<p style=\"text-align:right\">\n";
831 $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
832 $display.= " \n";
833 if ($this->dn != "new"){
834 $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
835 $display.= " \n";
836 }
837 $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
838 $display.= "</p>";
839 }
840 return ($display);
841 }
843 /* Check if there is a snapshot dialog open */
844 $base = $this->DivListSystem->selectedBase;
845 if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
846 return($str);
847 }
849 /* Display dialog with system list */
850 $this->DivListSystem->parent = $this;
851 $this->DivListSystem->execute();
853 /* Add departments if subsearch is disabled */
854 if(!$this->DivListSystem->SubSearch){
855 $this->DivListSystem->AddDepartments($this->DivListSystem->selectedBase,3,1);
856 }
857 $this->reload();
858 $this->DivListSystem->setEntries($this->terminals);
859 return($this->DivListSystem->Draw());
860 }
863 /* Return departments, that will be included within snapshot detection */
864 function get_used_snapshot_bases()
865 {
866 $tmp = array();
868 /* Check acls, if we are not allowed to create and write each plugin tab, skip this object */
870 $tabs = array(
871 "terminal" => "ou=terminals,ou=systems,",
872 "workstation" => "ou=workstations,ou=systems,",
873 "incoming" => "ou=incoming,",
874 "server" => "ou=servers,ou=systems,",
875 "printer" => "ou=printers,ou=systems,",
876 "phone" => "ou=phones,ou=systems,",
877 "winworkstation" => get_winstations_ou(),
878 "component" => "ou=netdevices,ou=systems,"
879 );
881 foreach($tabs as $acl_cat => $dn){
883 $acl_all = $this->ui->has_complete_category_acls($dn.$this->DivListSystem->selectedBase,$acl_cat);
884 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
885 $tmp[] = $dn.$this->DivListSystem->selectedBase;
886 }
887 }
888 return($tmp);
889 }
892 function remove_from_parent()
893 {
894 /* Optionally execute a command after we're done */
895 $this->postremove();
896 }
899 /* Save data to object */
900 function save_object()
901 {
902 $this->DivListSystem->save_object();
903 }
906 /* Check values */
907 function check()
908 {
909 }
912 /* Save to LDAP */
913 function save()
914 {
915 }
917 function adapt_from_template($dn)
918 {
919 }
921 function password_change_needed()
922 {
923 }
925 function reload()
926 {
927 /* some var init */
928 $ui = get_userinfo();
929 $res = array();
930 $this->terminals = array();
931 $userregex = "";
933 /* Set base for all searches */
934 $base= $this->DivListSystem->selectedBase;
936 /* Prepare samba class name */
937 $samba ="";
938 if ($this->DivListSystem->ShowWinWorkstations){
939 if ($this->config->current['SAMBAVERSION'] == "3"){
940 $samba= "sambaSamAccount";
941 } else {
942 $samba= "sambaAccount";
943 }
944 }
946 /* This array represents the combination between checkboxes and search filters */
947 $objs = array( "ShowServers" => array("CLASS" => "goServer" ,"TREE" => "ou=servers,ou=systems," ),
948 "ShowTerminals" => array("CLASS" => "gotoTerminal" ,"TREE" => "ou=terminals,ou=systems,"),
949 "ShowPrinters" => array("CLASS" => "gotoPrinter" ,"TREE" => "ou=printers,ou=systems," ),
950 "ShowDevices" => array("CLASS" => "ieee802Device" ,"TREE" => "ou=netdevices,ou=systems," ),
951 "ShowPhones" => array("CLASS" => "goFonHardware" ,"TREE" => "ou=phones,ou=systems," ),
952 "ShowWorkstations" => array("CLASS" => "gotoWorkstation" ,"TREE" => "ou=workstations,ou=systems," ),
953 "ShowWinWorkstations"=> array("CLASS" => $samba ,"TREE" => get_winstations_ou() ));
955 /* Include the 'Display Systems of user' attribute */
956 if ((!empty($this->DivListSystem->UserRegex)) && ($this->DivListSystem->UserRegex!= "*")){
957 $userregex = "(gotoLastUser=".$this->DivListSystem->UserRegex.")";
958 }
960 /* Attributes to fetch */
961 $sys_attrs = array("cn", "description", "macAddress", "objectClass", "sambaDomainName");
962 $sys_categories = array("terminal", "workstation", "server", "phone" ,"printer");
964 /* Add FAIstate to attributes if FAI is activated */
965 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
966 if(!empty($tmp)){
967 $sys_attrs[] = "FAIstate";
968 }
970 /* Walk through all possible search combinations, and search for some objects if the checkbox is enabled */
971 foreach($objs as $checkBox => $oc){
972 if($this->DivListSystem->$checkBox){
973 if($this->DivListSystem->SubSearch){
974 if($oc['CLASS'] != ""){
975 $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
976 $new_res = get_list($filter, $sys_categories , $base,$sys_attrs, GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT);
978 /* Remove all objects that are not in the expected sub department */
979 foreach($new_res as $key => $obj){
980 if(preg_match("/^[^,]+,".normalizePreg($oc['TREE'])."/",$obj['dn'])){
981 $res[$obj['dn']] = $obj;
982 }
983 }
984 }
985 }else{
986 /* User filter? */
987 if($oc['CLASS'] != ""){
988 $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
989 $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_NONE | GL_SIZELIMIT));
990 }
991 }
992 }
993 }
995 /* Search for incoming objects */
996 $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
997 $res = array_merge($res,get_list($filter,$sys_categories,"ou=incoming,".$base,$sys_attrs, GL_NONE | GL_SIZELIMIT));
999 /* Get all gotoTerminal's */
1000 foreach ($res as $value){
1002 $tmp= $value['dn'];
1003 $add= "";
1005 /* Extract base */
1006 foreach($objs as $obj){
1007 if(preg_match("/,".$obj['TREE']."/i",$value['dn'])){
1008 $tmp = trim( preg_replace("/^[^,]+,[^o]*".$obj['TREE']."/i","",$value['dn']));
1009 }
1010 }
1012 /* Create a string containing the last part of the department. */
1013 $dn_name = preg_replace("#^([^/]+/)*#","",convert_department_dn(@LDAP::fix($tmp)));
1014 if(empty($dn_name)){
1015 $dn_name = "/";
1016 }
1018 /* check if current object is a new one */
1019 if (preg_match ("/,ou=incoming,/i", $tmp)){
1020 if (in_array_ics('gotoTerminal', $value['objectClass'])){
1021 $add= "- "._("New terminal");
1022 }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){
1023 $add= "- "._("New workstation");
1024 }elseif (in_array_ics('GOhard', $value['objectClass'])){
1025 $add= "- "._("New Device");
1026 }
1027 }
1029 /* Detect type of object and create an entry for $this->terminals */
1030 $terminal = array();
1032 if (in_array_ics('gotoTerminal', $value["objectClass"])){
1034 /* check acl */
1035 $acl = $ui->get_permissions($value['dn'],"terminal/termgeneric");
1036 if($add != "" || preg_match("/r/",$acl)) {
1037 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1038 $terminal = $value;
1039 $terminal['type'] = "T";
1040 $terminal['is_new'] = $add;
1041 } else {
1042 $terminal = $value;
1043 $terminal['type'] = "D";
1044 $terminal['message'] = _("Terminal template for")." '".$dn_name."' ";
1045 $terminal['location'] = array_search($tmp, $this->config->departments);
1046 }
1047 }
1048 } elseif (in_array_ics('gotoWorkstation', $value["objectClass"])){
1050 $acl = $ui->get_permissions($value['dn'],"workstation/workgeneric");
1051 if($add != "" || preg_match("/r/",$acl)) {
1052 if (isset($value["macAddress"][0]) && $value["macAddress"][0] != "-"){
1053 $terminal = $value;
1054 $terminal['type'] = "L";
1055 $terminal['is_new'] = $add;
1056 } else {
1057 $terminal = $value;
1058 $terminal['type'] = "D";
1059 $terminal['location'] = array_search($tmp, $this->config->departments);
1060 $terminal['message'] = _("Workstation template for")." '".$dn_name."' ";
1061 }
1062 if (isset($value["FAIstate"][0])){
1063 $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1064 }
1065 }
1066 } elseif (in_array_ics('gotoPrinter', $value["objectClass"])){
1069 $acl = $ui->get_permissions($value['dn'],"printer/printgeneric");
1070 if($add != "" || preg_match("/r/",$acl)) {
1072 $terminal = $value;
1073 $terminal['type'] = "P";
1074 }
1075 } elseif (in_array_ics('goServer', $value["objectClass"])){
1077 $acl = $ui->get_permissions($value['dn'],"server/servgeneric");
1078 if($add != "" || preg_match("/r/",$acl)) {
1080 $terminal = $value;
1081 $terminal['type'] = "S";
1082 if (isset($value["FAIstate"][0])){
1083 $terminal['type']= $this->getState($terminal['type'], $value["FAIstate"][0]);
1084 }
1085 }
1086 } elseif (in_array_ics('goFonHardware', $value["objectClass"])){
1088 $acl = $ui->get_permissions($value['dn'],"phone/phoneGeneric");
1089 if($add != "" || preg_match("/r/",$acl)) {
1091 $terminal = $value;
1092 $terminal['type'] = "F";
1093 }
1094 }elseif (in_array_ics("GOhard",$value['objectClass'])){
1096 $acl = $ui->get_permissions($value['dn'],"server/servgeneric").
1097 $ui->get_permissions($value['dn'],"terminal/termgeneric").
1098 $ui->get_permissions($value['dn'],"workstation/workgeneric");
1099 if($add != "" || preg_match("/r/",$acl)) {
1101 $terminal = $value;
1102 $terminal['type'] = "Q";
1103 $terminal['is_new'] = $add;
1104 }
1105 } elseif (in_array_ics('ieee802Device', $value["objectClass"])){
1107 $acl = $ui->get_permissions($value['dn'],"component/componentGeneric");
1108 if($add != "" || preg_match("/r/",$acl)) {
1110 $terminal = $value;
1111 $terminal['type'] = "C";
1112 }
1113 } else{
1115 $name= preg_replace('/\$$/', '', $value['cn'][0]);
1116 if (isset($value['sambaDomainName'])){
1117 $domain= " [".$value['sambaDomainName'][0]."]";
1118 } else {
1119 $domain= "";
1120 }
1121 $terminal=$value;
1122 $terminal['type'] ="W";
1123 $terminal['domain'] = $name.$domain;
1124 }
1126 if(count($terminal)){
1127 $this->terminals[]=$terminal;
1128 }
1129 }
1131 $tmp=array();
1132 foreach($this->terminals as $tkey => $val ){
1133 $tmp[strtolower($val['cn'][0]).$val['dn']]=$val;
1134 }
1135 ksort($tmp);
1136 $this->terminals=array();
1137 foreach($tmp as $val){
1138 $this->terminals[]=$val;
1139 }
1140 reset ($this->terminals);
1141 }
1143 function remove_lock()
1144 {
1145 if (isset($this->systab->dn)){
1146 del_lock ($this->systab->dn);
1147 }
1148 }
1151 function copyPasteHandling_from_queue($s_action,$s_entry)
1152 {
1153 /* Check if Copy & Paste is disabled */
1154 if(!is_object($this->CopyPasteHandler)){
1155 return("");
1156 }
1159 $tabs = array(
1160 "terminal" => array( "CLASS" =>"TERMTABS", "TABNAME" =>"termgeneric",
1161 "TABCLASS" =>"termtabs", "ACL" =>"terminal"),
1162 "workstation" => array( "CLASS" =>"WORKTABS", "TABNAME" =>"workgeneric",
1163 "TABCLASS" =>"worktabs", "ACL" =>"workstation"),
1164 "server" => array( "CLASS" =>"SERVTABS", "TABNAME" =>"servgeneric",
1165 "TABCLASS" =>"servtabs", "ACL" =>"server"),
1166 "printer" => array( "CLASS" =>"PRINTTABS", "TABNAME" =>"printgeneric",
1167 "TABCLASS" =>"printtabs", "ACL" =>"printer"),
1168 "phone" => array( "CLASS" =>"PHONETABS", "TABNAME" =>"phoneGeneric",
1169 "TABCLASS" =>"phonetabs", "ACL" =>"phone"),
1170 "component" => array( "CLASS" =>"COMPONENTTABS","TABNAME" =>"componentgeneric",
1171 "TABCLASS" =>"componenttabs","ACL" =>"component"));
1173 /* Add a single entry to queue */
1174 if($s_action == "cut" || $s_action == "copy"){
1176 /* Cleanup object queue */
1177 $this->CopyPasteHandler->cleanup_queue();
1178 $dn = $this->terminals[$s_entry]['dn'];
1179 $oc = $this->terminals[$s_entry]['objectClass'];
1180 $type = $this->get_system_type($oc);
1182 $tab_o = $tabs[$type]['CLASS'];
1183 $tab_c = $tabs[$type]['TABCLASS'];
1184 $acl = $tabs[$type]['ACL'];
1186 $this->CopyPasteHandler->add_to_queue($dn,$s_action,$tab_c,$tab_o,$acl);
1187 }
1189 /* Add entries to queue */
1190 if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
1192 /* Cleanup object queue */
1193 $this->CopyPasteHandler->cleanup_queue();
1195 /* Add new entries to CP queue */
1196 foreach($this->list_get_selected_items() as $id){
1197 $dn = $this->terminals[$id]['dn'];
1198 $oc = $this->terminals[$id]['objectClass'];
1199 $type = $this->get_system_type($oc);
1201 $tab_o = $tabs[$type]['CLASS'];
1202 $tab_c = $tabs[$type]['TABCLASS'];
1203 $acl = $tabs[$type]['ACL'];
1205 if($s_action == "copy_multiple"){
1206 $this->CopyPasteHandler->add_to_queue($dn,"copy",$tab_c,$tab_o,$acl);
1207 }
1208 if($s_action == "cut_multiple"){
1209 $this->CopyPasteHandler->add_to_queue($dn,"cut",$tab_c,$tab_o,$acl);
1210 }
1211 }
1212 }
1214 /* Start pasting entries */
1215 if($s_action == "editPaste"){
1216 $this->start_pasting_copied_objects = TRUE;
1217 }
1219 /* Return C&P dialog */
1220 if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
1222 /* Load entry from queue and set base */
1223 $this->CopyPasteHandler->load_entry_from_queue();
1224 $this->CopyPasteHandler->SetVar("base",$this->DivListSystem->selectedBase);
1226 /* Get dialog */
1227 $data = $this->CopyPasteHandler->execute();
1229 /* Return dialog data */
1230 if(!empty($data)){
1231 return($data);
1232 }
1233 }
1235 /* Automatically disable status for pasting */
1236 if(!$this->CopyPasteHandler->entries_queued()){
1237 $this->start_pasting_copied_objects = FALSE;
1238 }
1239 return("");
1240 }
1243 function get_system_type($classes)
1244 {
1245 $type= "";
1246 if (in_array_ics('ieee802Device', $classes)){
1247 $type= "component";
1248 }elseif (in_array_ics('gotoTerminal', $classes)){
1249 $type= "terminal";
1250 }elseif (in_array_ics('gotoWorkstation', $classes)){
1251 $type= "workstation";
1252 }elseif (in_array_ics('gotoPrinter', $classes)){
1253 $type= "printer";
1254 }elseif (in_array_ics('goFonHardware', $classes)){
1255 $type= "phone";
1256 }elseif (in_array_ics('goServer', $classes)){
1257 $type= "server";
1258 }elseif (in_array_ics('GOhard', $classes)){
1259 $type= "NewDevice";
1260 }elseif (in_array_ics('sambaAccount', $classes) ||
1261 in_array_ics('sambaSamAccount', $classes)){
1262 $type= "winstation";
1263 }
1264 return ($type);
1265 }
1268 function convert_list($input)
1269 {
1270 $temp= "";
1271 $conv= array(
1272 "NQ" => array("select_newsystem.png",_("New System from incoming")),
1273 "D" => array("select_default.png",_("Template")),
1274 "T" => array("select_terminal.png",_("Terminal")),
1275 "L" => array("select_workstation.png",_("Workstation")),
1276 "GL" => array("select_workstation_green.png",_("Workstation is installing")),
1277 "YL" => array("select_workstation_yellow.png",_("Workstation is waiting for action")),
1278 "RL" => array("select_workstation_red.png",_("Workstation installation failed")),
1279 "F" => array("select_phone.png",_("Phone")),
1280 "S" => array("select_server.png",_("Server")),
1281 "GS" => array("select_server_green.png",_("Server is installing")),
1282 "YS" => array("select_server_yellow.png",_("Server is waiting for action")),
1283 "RS" => array("select_server_red.png",_("Server installation failed")),
1284 "W" => array("select_winstation.png",_("Winstation")),
1285 "C" => array("select_component.png",_("Network Device")),
1286 "NT"=> array("select_new_terminal.png",_("New Terminal")),
1287 "NL"=> array("select_new_workstation.png",_("New Workstation")),
1288 "P" => array("select_printer.png",_("Printer")));
1290 if((isset($input['is_new']))&&(!empty($input['is_new']))){
1291 $input['type']="N".$input['type'];
1292 }
1293 foreach ($conv as $key => $value){
1294 if($input['type']==$key){
1295 $tmp['img'] ="<img class='center' src='images/".$value[0]."' alt='".$key."' title='".$value['1']."'>";
1296 $tmp['class']=$key;
1297 return $tmp;
1298 }
1299 }
1300 }
1303 function getState($type, $state)
1304 {
1305 switch (preg_replace('/:.*$/', '', $state)) {
1306 case 'installing':
1307 $type= 'G'.$type;
1308 break;
1309 case 'error':
1310 $type= 'R'.$type;
1311 break;
1312 case 'install':
1313 case 'sysinfo':
1314 case 'softupdate':
1315 case 'scheduledupdate':
1316 $type= 'Y'.$type;
1317 break;
1318 }
1321 return ($type);
1322 }
1325 function list_get_selected_items()
1326 {
1327 $ids = array();
1328 foreach($_POST as $name => $value){
1329 if(preg_match("/^item_selected_[0-9]*$/",$name)){
1330 $id = preg_replace("/^item_selected_/","",$name);
1331 $ids[$id] = $id;
1332 }
1333 }
1334 return($ids);
1335 }
1338 /* !! Incoming dummy acls, required to defined acls for incoming objects
1339 */
1340 function plInfo()
1341 {
1342 return (array(
1343 "plShortName" => _("Incoming objects"),
1344 "plDescription" => _("Incoming objects"),
1345 "plSelfModify" => FALSE,
1346 "plDepends" => array(),
1347 "plPriority" => 99,
1348 "plSection" => array("administration"),
1349 "plCategory" => array("incoming" => array( "description" => _("Incoming"),
1350 "objectClass" => "")),
1351 "plProvidedAcls"=> array()
1353 ));
1354 }
1359 }
1361 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1362 ?>