Code

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