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