Code

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