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