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