Code

Udpated gotomasses
[gosa.git] / plugins / personal / scalix / main.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2006  Jörn Dreyer, based on work by
5                        Cajus Pollmeier
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
22 if (!$remove_lock){
23   /* Reset requested? */
24   if (isset($_POST['edit_cancel']) || 
25       (isset($_GET['reset']) && $_GET['reset'] == 1)){
26     del_lock ($ui->dn);
27     sess_del ('edit');
28     sess_del ('scalixAccount');
29   }
31   /* Create mail object on demand */
32   if (!isset($_SESSION['scalixAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
33     $_SESSION['scalixAccount']= new scalixAccount ($config, $ui->dn);
34     $_SESSION['scalixAccount']->set_acl_base($ui->dn);
35     $_SESSION['scalixAccount']->set_acl_category("users");
36   }
37   $scalixAccount= $_SESSION['scalixAccount'];
39   /* save changes back to object */
40   if (isset ($_SESSION['edit'])){
41     $scalixAccount->save_object ();
42   }
44   /* Enter edit mode? */
45   if (isset($_POST['edit'])){
47     /* Check locking */
48     if (($username= get_lock($ui->dn)) != ""){
49       $_SESSION['back_plugin']= $plug;
50       $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/");
51       $lock_msg =  gen_locked_message ($username, $ui->dn);
53     }else{
55       /* Lock the current entry */
56       add_lock ($ui->dn, $ui->dn);
57       $_SESSION['dn']= $ui->dn;
58       $_SESSION['edit']= TRUE;
59     }
60   }
62   /* save changes to LDAP and disable edit mode */
63   if (isset($_POST['edit_finish'])){
65     /* Perform checks */
66     $message= $scalixAccount->check ();
68     /* No errors, save object */
69     if (count ($message) == 0){
70       $scalixAccount->save ();
71       gosa_log ("User/scalix object'".$ui->dn."' has been saved");
72       $scalixAccount->acl= "#none#";
73       del_lock ($ui->dn);
74       sess_del ('edit');
76       /* Remove object */
77       sess_del ('scalixAccount');
78     } else {
79       /* Errors found, show message */
80       show_errors ($message);
81     }
82   }
84   /* Execute formular */
85   $display= $scalixAccount->execute ();
87   /* Store changes  in session */
88   if (isset ($_SESSION['edit'])){
89     $_SESSION['scalixAccount']= $scalixAccount;
90   }
92  /* Show page footer depending on the mode */
93   if ($scalixAccount->is_account){
95     $display.= "<p class=\"plugbottom\">";
97     /* Are we in edit mode? */
98     if (isset($_SESSION['edit'])){
99       $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
100       $display.= "&nbsp;";
101       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
102       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
103              "\"> ".$ui->dn."&nbsp;";
104     } else {
105       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
106              "\"> ".$ui->dn."&nbsp;";
108       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/scalix"))){
109         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".
110                 _("Click the 'Edit' button below to change informations in this dialog");
112         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
113       }
114       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
115     }
116     $display.= "</p>\n";
117   }
120   $info= "";
122   /* Page header*/
123   $display= print_header(get_template_path('images/scalix.png'), _("Scalix settings"), $info).$display;
127 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
128 ?>