Code

* Updated Changelog
[gosa.git] / plugins / personal / nagios / main.inc
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   }
34   $nagiosAccount= $_SESSION['nagiosAccount'];
36   /* save changes back to object */
37   if (isset ($_SESSION['edit'])){
38     $nagiosAccount->save_object ();
39   }
41   /* Enter edit mode? */
42   if (isset($_POST['edit'])){
44     /* Check locking */
45     if (($username= get_lock($ui->dn)) != ""){
46       $_SESSION['back_plugin']= $plug;
47       gen_locked_message ($username, $ui->dn);
48       exit ();
49     }
51     /* Lock the current entry */
52     add_lock ($ui->dn, $ui->dn);
53     $_SESSION['dn']= $ui->dn;
54     $_SESSION['edit']= TRUE;
55   }
57   /* Adjust acl's to mode */
58   if (isset($_SESSION['edit'])){
59     $acl= get_permissions ($ui->dn, $ui->subtreeACL);
60     $nagiosAccount->acl= get_module_permission($acl, "nagiosAccount", $ui->dn);
61   } else {
62     $acl= get_permissions ($ui->dn, $ui->subtreeACL);
63     $editacl= get_module_permission($acl, "nagiosAccount", $ui->dn);
64     $nagiosAccount->acl= "#none#";
65   }
67   /* save changes to LDAP and disable edit mode */
68   if (isset($_POST['edit_finish'])){
70     /* Perform checks */
71     $message= $nagiosAccount->check ();
73     /* No errors, save object */
74     if (count ($message) == 0){
75       $nagiosAccount->save ();
76       gosa_log ("User/nagios object'".$ui->dn."' has been saved");
77       $nagiosAccount->acl= "#none#";
78       $editacl= get_module_permission($acl, "nagiosAccount", $ui->dn);
79       del_lock ($ui->dn);
80       sess_del ('edit');
82       /* Remove object */
83       sess_del ('nagiosAccount');
84     } else {
85       /* Errors found, show message */
86       show_errors ($message);
87     }
88   }
90   /* Execute formular */
91   $display= $nagiosAccount->execute ();
93   /* Store changes  in session */
94   if (isset ($_SESSION['edit'])){
95     $_SESSION['nagiosAccount']= $nagiosAccount;
96   }
98   $info= "";
99   /* Show page footer depending on the mode */
100   if ($nagiosAccount->is_account){
101     $display.= "<p class=\"plugbottom\">";
103     /* Are we in edit mode? */
104     if (isset($_SESSION['edit'])){
105       $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
106       $display.= "&nbsp;";
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."&nbsp;";
110     } else {
111       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
112              "\"> ".$ui->dn."&nbsp;";
113       if (isset($editacl) && $editacl != "#none#"){
114         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
115             "\"> "._("Click the 'Edit' button below to change informations in this dialog");
116         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
117       }
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;
129 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
130 ?>