Code

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