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){
23 /* Reset requested? */
24 if (isset($_POST['edit_cancel']) ||
25 (isset($_GET['reset']) && $_GET['reset'] == 1)){
26 del_lock ($ui->dn);
27 session::un_set ('edit');
28 session::un_set ('environment');
29 }
31 /* Create mail object on demand */
32 if (!session::is_set('environment') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
33 $environment= new environment ($config, $ui->dn);
34 $environment->enable_CSN_check();
35 $environment->set_acl_category('users');
36 $environment->set_acl_base($ui->dn);
37 session::set('environment',$environment);
38 }
39 $environment = session::get('environment');
41 /* save changes back to object */
42 if (session::is_set('edit')){
43 $environment->save_object ();
44 }
46 /* Enter edit mode? */
47 if (isset($_POST['edit']) || isset($_POST['delete_lock'])){
49 /* Check locking */
50 if (($username= get_lock($ui->dn)) != ""){
51 session::set('back_plugin',$plug);
52 session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
53 $lock_msg = gen_locked_message ($username, $ui->dn);
55 }else{
57 /* Lock the current entry */
58 add_lock ($ui->dn, $ui->dn);
59 session::set('dn',$ui->dn);
60 session::set('edit',TRUE);
61 }
62 }
64 /* save changes to LDAP and disable edit mode */
65 if (isset($_POST['edit_finish'])){
67 /* Perform checks */
68 $message= $environment->check ();
70 /* No errors, save object */
71 if (count ($message) == 0){
72 $environment->save ();
73 del_lock ($ui->dn);
74 session::un_set ('edit');
76 /* Remove object */
77 session::un_set ('environment');
78 } else {
79 /* Errors found, show message */
80 msg_dialog::displayChecks($message);
81 }
82 }
84 /* Execute formular */
85 if($lock_msg){
86 $display = $lock_msg;
87 }else{
88 $display = $environment->execute();
89 }
91 /* Store changes in session */
92 if (session::is_set('edit')){
93 session::set('environment',$environment);
94 }
96 $info= "";
97 /* Show page footer depending on the mode */
98 if (!$environment->in_dialog && !$environment->dialog && $environment->is_account && empty($lock_msg)){
99 $display.= "<p class=\"plugbottom\">";
101 /* Are we in edit mode? */
102 if (session::is_set('edit')){
103 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
104 $display.= " ";
105 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
106 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
107 "\"> ".$ui->dn." ";
108 } else {
109 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
110 "\"> ".$ui->dn." ";
111 if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/environment"))){
112 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png').
113 "\"> ".msgPool::clickEditToChange();
114 $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
115 }
116 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
117 }
118 $display.= "</p>\n";
119 }
121 /* Page header*/
122 $display= print_header(get_template_path('plugins/goto/images/plugin.png'), _("User environment settings"), $info).$display;
124 }
126 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
127 ?>