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