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 */
20 $lock_msg = "";
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 $_SESSION['environment']->set_acl_base($ui->dn);
35 }
36 $environment= $_SESSION['environment'];
38 /* save changes back to object */
39 if (isset($_SESSION['edit'])){
40 $environment->save_object ();
41 }
43 /* Enter edit mode? */
44 if (isset($_POST['edit'])){
46 /* Check locking */
47 if (($username= get_lock($ui->dn)) != ""){
48 $_SESSION['back_plugin']= $plug;
49 $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/");
50 $lock_msg = gen_locked_message ($username, $ui->dn);
52 }else{
54 /* Lock the current entry */
55 add_lock ($ui->dn, $ui->dn);
56 $_SESSION['dn']= $ui->dn;
57 $_SESSION['edit']= TRUE;
58 }
59 }
61 /* save changes to LDAP and disable edit mode */
62 if (isset($_POST['edit_finish'])){
64 /* Perform checks */
65 $message= $environment->check ();
67 /* No errors, save object */
68 if (count ($message) == 0){
69 $environment->save ();
70 del_lock ($ui->dn);
71 sess_del ('edit');
73 /* Remove object */
74 sess_del ('environment');
75 } else {
76 /* Errors found, show message */
77 show_errors ($message);
78 }
79 }
81 /* Execute formular */
82 if($lock_msg){
83 $display = $lock_msg;
84 }else{
85 $display = $environment->execute();
86 }
88 /* Store changes in session */
89 if (isset ($_SESSION['edit'])){
90 $_SESSION['environment']= $environment;
91 }
93 $info= "";
94 /* Show page footer depending on the mode */
95 if (!$environment->in_dialog && $environment->is_account && empty($lock_msg)){
96 $display.= "<p class=\"plugbottom\">";
98 /* Are we in edit mode? */
99 if ((isset($_SESSION['edit']))&&($environment->dialog===NULL)){
100 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
101 $display.= " ";
102 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
103 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
104 "\"> ".$ui->dn." ";
105 } else {
106 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
107 "\"> ".$ui->dn." ";
108 if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/environment"))){
109 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
110 "\"> "._("Click the 'Edit' button below to change informations in this dialog");
111 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
112 }
113 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
114 }
115 $display.= "</p>\n";
116 }
118 /* Page header*/
119 $display= print_header(get_template_path('images/email.png'), _("User environment settings"), $info).$display;
121 }
123 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
124 ?>