1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2005 Benoit Mortier
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 if (!$remove_lock){
22 /* Reset requested? */
23 if (isset($_POST['edit_cancel']) ||
24 (isset($_GET['reset']) && $_GET['reset'] == 1)){
25 del_lock ($ui->dn);
26 sess_del ('edit');
27 sess_del ('nagiosAccount');
28 }
30 /* Create mail object on demand */
31 if (!isset($_SESSION['nagiosAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
32 $_SESSION['nagiosAccount']= new nagiosAccount ($config, $ui->dn);
33 $_SESSION['nagiosAccount']->set_acl_base($ui->dn);
34 $_SESSION['nagiosAccount']->set_acl_category("users");
35 }
36 $nagiosAccount= $_SESSION['nagiosAccount'];
38 /* save changes back to object */
39 if (isset ($_SESSION['edit'])){
40 $nagiosAccount->save_object ();
41 }
43 /* Enter edit mode? */
44 if (isset($_POST['edit'])){
46 /* Check locking */
47 if (($username= get_lock($ui->dn)) != ""){
48 $_SESSION['back_plugin']= $plug;
49 gen_locked_message ($username, $ui->dn);
50 exit ();
51 }
53 /* Lock the current entry */
54 add_lock ($ui->dn, $ui->dn);
55 $_SESSION['dn']= $ui->dn;
56 $_SESSION['edit']= TRUE;
57 }
59 /* save changes to LDAP and disable edit mode */
60 if (isset($_POST['edit_finish'])){
62 /* Perform checks */
63 $message= $nagiosAccount->check ();
65 /* No errors, save object */
66 if (count ($message) == 0){
67 $nagiosAccount->save ();
68 gosa_log ("User/nagios object'".$ui->dn."' has been saved");
69 del_lock ($ui->dn);
70 sess_del ('edit');
72 /* Store object */
73 $_SESSION['nagiosAccount']= $nagiosAccount;
74 } else {
75 /* Errors found, show message */
76 show_errors ($message);
77 }
78 }
80 /* Execute formular */
81 $display= $nagiosAccount->execute ();
83 /* Store changes in session */
84 if (isset ($_SESSION['edit'])){
85 $_SESSION['nagiosAccount']= $nagiosAccount;
86 }
88 $info= "";
89 /* Show page footer depending on the mode */
90 if ($nagiosAccount->is_account){
91 $display.= "<p class=\"plugbottom\">";
93 /* Are we in edit mode? */
94 if (isset($_SESSION['edit'])){
95 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
96 $display.= " ";
97 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
98 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
99 "\"> ".$ui->dn." ";
100 } else {
101 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
102 "\"> ".$ui->dn." ";
104 if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/nagiosAccount"))){
105 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
106 "\"> "._("Click the 'Edit' button below to change informations in this dialog");
107 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
108 }
109 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
110 }
111 $display.= "</p>\n";
112 }
114 /* Page header*/
115 $display= print_header(get_template_path('images/monitoring.png'), _("Nagios settings"), $info).$display;
117 }
119 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
120 ?>