Code

Renoved debug tag
[gosa.git] / plugins / personal / mail / main.inc
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  =""; 
23 if (!$remove_lock){
24   /* Reset requested? */
25   if (isset($_POST['edit_cancel']) || 
26       (isset($_GET['reset']) && $_GET['reset'] == 1)){
27     del_lock ($ui->dn);
28     sess_del ('edit');
29     sess_del ('mailAccount');
30   }
32   /* Create mail object on demand */
33   if (!isset($_SESSION['mailAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
34     $_SESSION['mailAccount']= new mailAccount ($config, $ui->dn);
35     $_SESSION['mailAccount']->set_acl_base($ui->dn);
36     $_SESSION['mailAccount']->set_acl_category("users");
37   }
38   $mailAccount= $_SESSION['mailAccount'];
40   /* save changes back to object */
41   if (isset ($_SESSION['edit'])){
42     $mailAccount->save_object ();
43   }
45   /* Enter edit mode? */
46   if (isset($_POST['edit']) && preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){
48     /* Check locking */
49     if (($username= get_lock($ui->dn)) != ""){
50       $_SESSION['back_plugin']= $plug;
51       $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/");
52       $lock_msg =  gen_locked_message ($username, $ui->dn);
54     }else{
56       /* Lock the current entry */
57       add_lock ($ui->dn, $ui->dn);
58       $_SESSION['dn']= $ui->dn;
59       $_SESSION['edit']= TRUE;
60     }
61   }
63   /* save changes to LDAP and disable edit mode */
64   if (isset($_POST['edit_finish'])){
66     /* Perform checks */
67     $message= $mailAccount->check ();
69     /* No errors, save object */
70     if (count ($message) == 0){
71       $mailAccount->save ();
72       del_lock ($ui->dn);
73       sess_del ('edit');
75       /* Remove object */
76       sess_del ('mailAccount');
77     } else {
78       /* Errors found, show message */
79       show_errors ($message);
80     }
81   }
83   /* Execute formular */
84   if($lock_msg){
85     $display.= $lock_msg;
86   }else{
87     $display.= $mailAccount->execute ();
88   }
90   /* Store changes  in session */
91   if (isset ($_SESSION['edit'])){
92     $_SESSION['mailAccount']= $mailAccount;
93   }
95   $info= "";
96   /* Show page footer depending on the mode */
97   if (!$mailAccount->forward_dialog && $mailAccount->is_account && empty($lock_msg)){
98     $display.= "<p class=\"plugbottom\">";
100     /* Are we in edit mode? */
101     if (isset($_SESSION['edit'])){
102       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
103       $display.= "&nbsp;";
104       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
105       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
106              "\"> ".$ui->dn."&nbsp;";
107     } else {
108       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
109              "\"> ".$ui->dn."&nbsp;";
110       
111         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
112             "\"> "._("Click the 'Edit' button below to change informations in this dialog");
114         if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){
115           $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
116         }
118       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
119     }
120     $display.= "</p>\n";
121   }
123   /* Page header*/
124   $display= print_header(get_template_path('images/email.png'), _("User mail settings"), $info).$display;
128 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
129 ?>