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)){
25 del_lock ($ui->dn);
26 sess_del ('edit');
27 sess_del ('environment');
28 }
30 /* Create mail object on demand */
31 if (!isset($_SESSION['environment']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
32 $_SESSION['environment']= new environment ($config, $ui->dn);
33 $_SESSION['environment']->set_acl_category('users');
34 }
35 $environment= $_SESSION['environment'];
37 /* save changes back to object */
38 if (isset($_SESSION['edit'])){
39 $environment->save_object ();
40 }
42 /* Enter edit mode? */
43 if (isset($_POST['edit'])){
45 /* Check locking */
46 if (($username= get_lock($ui->dn)) != ""){
47 $_SESSION['back_plugin']= $plug;
48 gen_locked_message ($username, $ui->dn);
49 exit ();
50 }
52 /* Lock the current entry */
53 add_lock ($ui->dn, $ui->dn);
54 $_SESSION['dn']= $ui->dn;
55 $_SESSION['edit']= TRUE;
56 }
58 /* save changes to LDAP and disable edit mode */
59 if (isset($_POST['edit_finish'])){
61 /* Perform checks */
62 $message= $environment->check ();
64 /* No errors, save object */
65 if (count ($message) == 0){
66 $environment->save ();
67 gosa_log ("User/environment object'".$ui->dn."' has been saved");
68 $environment->acl= "#none#";
69 del_lock ($ui->dn);
70 sess_del ('edit');
72 /* Store object */
73 $_SESSION['environment']= $environment;
74 } else {
75 /* Errors found, show message */
76 show_errors ($message);
77 }
78 }
80 /* Execute formular */
81 $display= $environment->execute ();
83 /* Store changes in session */
84 if (isset ($_SESSION['edit'])){
85 $_SESSION['environment']= $environment;
86 }
88 $info= "";
89 /* Show page footer depending on the mode */
90 if (!$environment->in_dialog && $environment->is_account){
91 $display.= "<p class=\"plugbottom\">";
93 /* Are we in edit mode? */
94 if ((isset($_SESSION['edit']))&&($environment->dialog==NULL)){
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." ";
103 # if (isset($editacl) && $editacl != "#none#"){
104 echo "FIxme, only display edit button if there is at least one attribute writeable";
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 # }
110 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
111 }
112 $display.= "</p>\n";
113 }
115 /* Page header*/
116 $display= print_header(get_template_path('images/email.png'), _("User environment settings"), $info).$display;
118 }
120 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
121 ?>