Code

Starting move
[gosa.git] / gosa-core / 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']->enable_CSN_check();
35     $_SESSION['scalixAccount']->set_acl_base($ui->dn);
36     $_SESSION['scalixAccount']->set_acl_category("users");
37   }
38   $scalixAccount= $_SESSION['scalixAccount'];
40   /* save changes back to object */
41   if (isset ($_SESSION['edit'])){
42     $scalixAccount->save_object ();
43   }
45   /* Enter edit mode? */
46   if (isset($_POST['edit'])){
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= $scalixAccount->check ();
69     /* No errors, save object */
70     if (count ($message) == 0){
71       $scalixAccount->save ();
72       gosa_log ("User/scalix object'".$ui->dn."' has been saved");
73       $scalixAccount->acl= "#none#";
74       del_lock ($ui->dn);
75       sess_del ('edit');
77       /* Remove object */
78       sess_del ('scalixAccount');
79     } else {
80       /* Errors found, show message */
81       show_errors ($message);
82     }
83   }
85   /* Execute formular */
86   $display= $scalixAccount->execute ();
88   /* Store changes  in session */
89   if (isset ($_SESSION['edit'])){
90     $_SESSION['scalixAccount']= $scalixAccount;
91   }
93  /* Show page footer depending on the mode */
94   if ($scalixAccount->is_account){
96     $display.= "<p class=\"plugbottom\">";
98     /* Are we in edit mode? */
99     if (isset($_SESSION['edit'])){
100       $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
101       $display.= "&nbsp;";
102       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
103       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
104              "\"> ".$ui->dn."&nbsp;";
105     } else {
106       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
107              "\"> ".$ui->dn."&nbsp;";
109       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/scalix"))){
110         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".
111                 _("Click the 'Edit' button below to change informations in this dialog");
113         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
114       }
115       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
116     }
117     $display.= "</p>\n";
118   }
121   $info= "";
123   /* Page header*/
124   $display= print_header(get_template_path('images/scalix.png'), _("Scalix settings"), $info).$display;
128 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
129 ?>