Code

Added remove and activate script button
[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       gosa_log ("User/mail object'".$ui->dn."' has been saved");
73       del_lock ($ui->dn);
74       sess_del ('edit');
76       /* Store object */
77       $_SESSION['mailAccount']= $mailAccount;
78     } else {
79       /* Errors found, show message */
80       show_errors ($message);
81     }
82   }
84   /* Execute formular */
85   if($lock_msg){
86     $display.= $lock_msg;
87   }else{
88     $display.= $mailAccount->execute ();
89   }
91   /* Store changes  in session */
92   if (isset ($_SESSION['edit'])){
93     $_SESSION['mailAccount']= $mailAccount;
94   }
96   $info= "";
97   /* Show page footer depending on the mode */
98   if (!$mailAccount->forward_dialog && $mailAccount->is_account && empty($lock_msg)){
99     $display.= "<p class=\"plugbottom\">";
101     /* Are we in edit mode? */
102     if (isset($_SESSION['edit'])){
103       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
104       $display.= "&nbsp;";
105       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
106       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
107              "\"> ".$ui->dn."&nbsp;";
108     } else {
109       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
110              "\"> ".$ui->dn."&nbsp;";
111       
112         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
113             "\"> "._("Click the 'Edit' button below to change informations in this dialog");
115         if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/mailAccount"))){
116           $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
117         }
119       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
120     }
121     $display.= "</p>\n";
122   }
124   /* Page header*/
125   $display= print_header(get_template_path('images/email.png'), _("User mail settings"), $info).$display;
129 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
130 ?>