Code

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