Code

Created trunk inside of 2.6-lhm
[gosa.git] / trunk / gosa-plugins / scalix / 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 /* Remove locks created by this plugin
23 */
24 $lock_msg="";
25 if ($remove_lock || isset($_POST['edit_cancel'])){
26   if(session::is_set('scalixAccount') && session::is_set('edit')){
27     del_lock($ui->dn);
28   }
29 }
31 /* Remove this plugin from session
32 */
33 if ( $cleanup ){
34   session::un_set('scalixAccount');
35   session::un_set('edit');
37 }else{
40   /* Reset requested? */
41   if (isset($_POST['edit_cancel'])){
42     session::un_set ('edit');
43     session::un_set ('scalixAccount');
44   }
46   /* Create mail object on demand */
47   if (!session::is_set('scalixAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
48     $scalixAccount= new scalixAccount ($config, $ui->dn);
49     $scalixAccount->enable_CSN_check();
50     $scalixAccount->set_acl_base($ui->dn);
51     $scalixAccount->set_acl_category("users");
52     session::set('scalixAccount',$scalixAccount);
53   }
54   $scalixAccount = session::get('scalixAccount');
56   /* save changes back to object */
57   if (session::is_set('edit')){
58     $scalixAccount->save_object ();
59   }
61   /* Enter edit mode? */
62   if (isset($_POST['edit'])){
64     /* Check locking */
65     if (($username= get_lock($ui->dn)) != ""){
66       session::set('back_plugin',$plug);
67       session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
68       $lock_msg =  gen_locked_message ($username, $ui->dn);
70     }else{
72       /* Lock the current entry */
73       add_lock ($ui->dn, $ui->dn);
74       session::set('edit',TRUE);
75     }
76   }
78   /* save changes to LDAP and disable edit mode */
79   if (isset($_POST['edit_finish'])){
81     /* Perform checks */
82     $message= $scalixAccount->check ();
84     /* No errors, save object */
85     if (count ($message) == 0){
86       $scalixAccount->save ();
87       gosa_log ("User/scalix object'".$ui->dn."' has been saved");
88       $scalixAccount->acl= "#none#";
89       del_lock ($ui->dn);
90       session::un_set ('edit');
92       /* Remove object */
93       session::un_set ('scalixAccount');
94     } else {
95       /* Errors found, show message */
96       msg_dialog::displayChecks($message);
97     }
98   }
100   /* Execute formular */
101   $display= $scalixAccount->execute ();
103   /* Store changes  in session */
104   if (session::is_set('edit')){
105     session::set('scalixAccount',$scalixAccount);
106   }
108  /* Show page footer depending on the mode */
109   if ($scalixAccount->is_account){
111     $display.= "<p class=\"plugbottom\">";
113     /* Are we in edit mode? */
114     if (session::is_set('edit')){
115       $display.= "<input type=submit name=\"edit_finish\" value=\"".msgPool::saveButton()."\">\n";
116       $display.= "&nbsp;";
117       $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
118       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
119              "\"> ".$ui->dn."&nbsp;";
120     } else {
121       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
122              "\"> ".$ui->dn."&nbsp;";
124       if(preg_match("/r/",$ui->get_permissions($ui->dn,"users/scalixAccount"))){
125         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png')."\"> ".
126                 _("Click the 'Edit' button below to change informations in this dialog");
128         $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
129       }
130       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
131     }
132     $display.= "</p>\n";
133   }
136   $info= "";
138   /* Page header*/
139   $display= print_header(get_template_path('plugins/scalix/images/plugin.png'), _("Scalix settings"), $info).$display;
143 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
144 ?>