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 $display = "";
22 $lock_msg = "";
24 if (!$remove_lock){
25 /* Reset requested? */
26 if (isset($_POST['edit_cancel']) ||
27 (isset($_GET['reset']) && $_GET['reset'] == 1)){
28 del_lock ($ui->dn);
29 session::un_set ('edit');
30 session::un_set ('nagiosAccount');
31 }
33 /* Create mail object on demand */
34 if (!session::is_set('nagiosAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
35 $nagiosAccount= new nagiosAccount ($config, $ui->dn);
36 $nagiosAccount->enable_CSN_check();
37 $nagiosAccount->set_acl_base($ui->dn);
38 $nagiosAccount->set_acl_category("users");
39 session::set('nagiosAccount',$nagiosAccount);
40 }
41 $nagiosAccount = session::get('nagiosAccount');
43 /* save changes back to object */
44 if (session::is_set('edit')){
45 $nagiosAccount->save_object ();
46 }
48 /* Enter edit mode? */
49 if (isset($_POST['edit'])){
51 /* Check locking */
52 if (($username= get_lock($ui->dn)) != ""){
53 session::set('back_plugin',$plug);
54 session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
55 $lock_msg = gen_locked_message ($username, $ui->dn);
57 }else{
59 /* Lock the current entry */
60 add_lock ($ui->dn, $ui->dn);
61 session::set('dn',$ui->dn);
62 session::set('edit',TRUE);
63 }
64 }
66 /* save changes to LDAP and disable edit mode */
67 if (isset($_POST['edit_finish'])){
69 /* Perform checks */
70 $message= $nagiosAccount->check ();
72 /* No errors, save object */
73 if (count ($message) == 0){
74 $nagiosAccount->save ();
75 del_lock ($ui->dn);
76 session::un_set ('edit');
78 /* Remove object */
79 session::un_set ('nagiosAccount');
80 } else {
81 /* Errors found, show message */
82 msgDialog::displayChecks($message);
83 }
84 }
86 /* Execute formular */
87 if($lock_msg){
88 $display.= $lock_msg;
89 }else{
90 $display.= $nagiosAccount->execute ();
91 }
93 /* Store changes in session */
94 if (session::is_set('edit')){
95 session::set('nagiosAccount',$nagiosAccount);
96 }
98 $info= "";
99 /* Show page footer depending on the mode */
100 if ($nagiosAccount->is_account && empty($lock_msg)){
101 $display.= "<p class=\"plugbottom\">";
103 /* Are we in edit mode? */
104 if (session::is_set('edit')){
105 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
106 $display.= " ";
107 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
108 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
109 "\"> ".$ui->dn." ";
110 } else {
111 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
112 "\"> ".$ui->dn." ";
114 if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/nagiosAccount"))){
115 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
116 "\"> "._("Click the 'Edit' button below to change informations in this dialog");
117 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
118 }
119 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
120 }
121 $display.= "</p>\n";
122 }
124 /* Page header*/
125 $display= print_header(get_template_path('images/monitoring.png'), _("Nagios settings"), $info).$display;
127 }
129 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
130 ?>