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 if (!$remove_lock){
22 /* Reset requested? */
23 if (isset($_POST['edit_cancel']) ||
24 (isset($_GET['reset']) && $_GET['reset'] == 1)){
26 del_lock ($ui->dn);
27 sess_del ('edit');
28 sess_del ('connectivity');
29 }
31 /* Create connectivity object on demand */
32 if (!isset($_SESSION['connectivity']) || (isset($_GET['reset']) &&
33 $_GET['reset'] == 1)){
34 $_SESSION['connectivity']= new connectivity ($config, $ui->dn);
35 }
36 $connectivity= $_SESSION['connectivity'];
38 /* save changes back to object */
39 if (isset ($_SESSION['edit'])){
40 $connectivity->save_object ();
41 }
43 /* Enter edit mode? */
44 if ((isset($_POST['edit'])) && (!isset( $_SESSION['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= $connectivity->check ();
65 /* No errors, save object */
66 if (count ($message) == 0){
67 $connectivity->save ();
68 gosa_log ("User/connectivity object'".$ui->dn."' has been saved");
69 $connectivity->acl= "#none#";
70 $editacl= get_module_permission($acl, "connectivity", $ui->dn);
71 del_lock ($ui->dn);
72 sess_del ('edit');
74 /* Write back to session */
75 $_SESSION['connectivity']= $connectivity;
76 } else {
77 /* Errors found, show message */
78 show_errors ($message);
79 }
80 }
82 /* Adjust acl's to mode */
83 if (isset($_SESSION['edit'])){
84 $acl= get_permissions ($ui->dn, $ui->subtreeACL);
85 $connectivity->acl= get_module_permission($acl, "connectivity", $ui->dn);
86 foreach ($connectivity->plugin_name as $name){
87 $connectivity->plugin[$name]->acl= get_module_permission($acl, "$name", $ui->dn);
88 }
89 } else {
90 $acl= get_permissions ($ui->dn, $ui->subtreeACL);
91 $editacl= get_module_permission($acl, "connectivity", $ui->dn);
92 $connectivity->acl= "#none#";
93 foreach ($connectivity->plugin_name as $name){
94 $connectivity->plugin[$name]->acl= "#none#";
95 }
96 }
98 /* Execute formular */
99 $display= $connectivity->execute ();
101 /* Store changes in session */
102 if (isset ($_SESSION['edit'])){
103 $_SESSION['connectivity']= $connectivity;
104 }
106 $info= "";
108 /* Are we in edit mode? */
109 $in_edit_mode= false;
110 foreach ($connectivity->plugin_name as $name){
111 $acls = get_module_permission($acl, "$name", $ui->dn);
112 if($acls != "#none#"){
113 $in_edit_mode|= true;
114 }
115 }
116 if ($in_edit_mode){
117 $display.="<div align='right'>";
118 if (isset($_SESSION['edit'])){
119 $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
120 $display.= " ";
121 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
122 $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
123 "\"> ".$ui->dn." ";
124 } else {
125 $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
126 "\"> ".$ui->dn." ";
127 if ($editacl != "#none#"){
128 $info.= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
129 "\">"._("Click the 'Edit' button below to change informations in this dialog");
130 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
131 }
132 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
133 }
134 $display.="</div>";
135 }
136 // $display.= "</p>\n";
138 /* Page header*/
139 $display= print_header(get_template_path('images/proxy.png'),
140 _("Connectivity"), $info).$display;
142 }
144 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
145 ?>