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