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 if (!$remove_lock){
22 /* Reset requested? */
23 if (isset($_POST['edit_cancel']) ||
24 (isset($_GET['reset']) && $_GET['reset'] == 1)){
25 del_lock ($ui->dn);
26 sess_del ('edit');
27 sess_del ('mailAccount');
28 }
30 /* Create mail object on demand */
31 if (!isset($_SESSION['mailAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
32 $_SESSION['mailAccount']= new mailAccount ($config, $ui->dn);
33 $_SESSION['mailAccount']->set_acl_base($ui->dn);
34 $_SESSION['mailAccount']->set_acl_category("users");
35 }
36 $mailAccount= $_SESSION['mailAccount'];
38 /* save changes back to object */
39 if (isset ($_SESSION['edit'])){
40 $mailAccount->save_object ();
41 }
43 /* Enter edit mode? */
44 if (isset($_POST['edit'])){
46 /* Check locking */
47 if (($username= get_lock($ui->dn)) != ""){
48 $_SESSION['back_plugin']= $plug;
49 gen_locked_message ($username, $ui->dn);
50 exit ();
51 }
53 /* Lock the current entry */
54 add_lock ($ui->dn, $ui->dn);
55 $_SESSION['dn']= $ui->dn;
56 $_SESSION['edit']= TRUE;
57 }
59 /* save changes to LDAP and disable edit mode */
60 if (isset($_POST['edit_finish'])){
62 /* Perform checks */
63 $message= $mailAccount->check ();
65 /* No errors, save object */
66 if (count ($message) == 0){
67 $mailAccount->save ();
68 gosa_log ("User/mail object'".$ui->dn."' has been saved");
69 del_lock ($ui->dn);
70 sess_del ('edit');
72 /* Store object */
73 $_SESSION['mailAccount']= $mailAccount;
74 } else {
75 /* Errors found, show message */
76 show_errors ($message);
77 }
78 }
80 /* Execute formular */
81 $display= $mailAccount->execute ();
83 /* Store changes in session */
84 if (isset ($_SESSION['edit'])){
85 $_SESSION['mailAccount']= $mailAccount;
86 }
88 $info= "";
89 /* Show page footer depending on the mode */
90 if (!$mailAccount->forward_dialog && $mailAccount->is_account){
91 $display.= "<p class=\"plugbottom\">";
93 /* Are we in edit mode? */
94 if (isset($_SESSION['edit'])){
95 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
96 $display.= " ";
97 $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
98 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
99 "\"> ".$ui->dn." ";
100 } else {
101 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
102 "\"> ".$ui->dn." ";
104 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
105 "\"> "._("Click the 'Edit' button below to change informations in this dialog");
106 $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
108 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
109 }
110 $display.= "</p>\n";
111 }
113 /* Page header*/
114 $display= print_header(get_template_path('images/email.png'), _("User mail settings"), $info).$display;
116 }
118 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
119 ?>