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 $_SESSION['connectivity']->set_acl_base($ui->dn);
36 $_SESSION['connectivity']->set_acl_category("users");
38 /* Adjust acl's to mode */
39 foreach ($_SESSION['connectivity']->plugin_name as $name){
40 $_SESSION['connectivity']->plugin[$name]->set_acl_category( "users");
41 $_SESSION['connectivity']->plugin[$name]->set_acl_base($ui->dn);
42 }
43 }
44 $connectivity= $_SESSION['connectivity'];
46 /* save changes back to object */
47 if (isset ($_SESSION['edit'])){
48 $connectivity->save_object ();
49 }
51 /* Enter edit mode? */
52 if (isset($_POST['edit'])){
54 /* Check locking */
55 if ((($username= get_lock($ui->dn)) != "") && (!isset($_SESSION['edit']))){
56 $_SESSION['back_plugin']= $plug;
57 gen_locked_message ($username, $ui->dn);
58 exit ();
59 }
62 /* Lock the current entry */
63 add_lock ($ui->dn, $ui->dn);
64 $_SESSION['dn']= $ui->dn;
65 $_SESSION['edit']= TRUE;
66 }
68 /* save changes to LDAP and disable edit mode */
69 if (isset($_POST['edit_finish'])){
71 /* Perform checks */
72 $message= $connectivity->check ();
74 /* No errors, save object */
75 if (count ($message) == 0){
76 $connectivity->save ();
77 gosa_log ("User/connectivity object'".$ui->dn."' has been saved");
78 del_lock ($ui->dn);
79 sess_del ('edit');
81 /* Write back to session */
82 $_SESSION['connectivity']= $connectivity;
83 } else {
84 /* Errors found, show message */
85 show_errors ($message);
86 }
87 }
89 /* Execute formular */
90 $display= $connectivity->execute ();
92 /* Store changes in session */
93 if (isset ($_SESSION['edit'])){
94 $_SESSION['connectivity']= $connectivity;
95 }
97 $info= "";
99 $display.="<div align='right'>";
100 if (isset($_SESSION['edit'])){
101 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
102 $display.= " ";
103 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
104 $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
105 "\"> ".$ui->dn." ";
106 } else {
107 $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
108 "\"> ".$ui->dn." ";
110 $info.= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
111 "\">"._("Click the 'Edit' button below to change informations in this dialog");
112 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
113 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
114 }
115 $display.="</div>";
117 /* Page header*/
118 $display= print_header(get_template_path('images/proxy.png'),
119 _("Connectivity"), $info).$display;
121 }
123 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
124 ?>