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