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