Code

Added ACL tag to connectivty plugin.
[gosa.git] / 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 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     session::un_set ('edit');
28     session::un_set ('scalixAccount');
29   }
31   /* Create mail object on demand */
32   if (!session::is_set('scalixAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
33     $scalixAccount= new scalixAccount ($config, $ui->dn);
34     $scalixAccount->enable_CSN_check();
35     $scalixAccount->set_acl_base($ui->dn);
36     $scalixAccount->set_acl_category("users");
37     session::set('scalixAccount',$scalixAccount);
38   }
39   $scalixAccount = session::get('scalixAccount');
41   /* save changes back to object */
42   if (session::is_set('edit')){
43     $scalixAccount->save_object ();
44   }
46   /* Enter edit mode? */
47   if (isset($_POST['edit'])){
49     /* Check locking */
50     if (($username= get_lock($ui->dn)) != ""){
51       session::set('back_plugin',$plug);
52       session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
53       $lock_msg =  gen_locked_message ($username, $ui->dn);
55     }else{
57       /* Lock the current entry */
58       add_lock ($ui->dn, $ui->dn);
59       session::set('dn',$ui->dn);
60       session::set('edit',TRUE);
61     }
62   }
64   /* save changes to LDAP and disable edit mode */
65   if (isset($_POST['edit_finish'])){
67     /* Perform checks */
68     $message= $scalixAccount->check ();
70     /* No errors, save object */
71     if (count ($message) == 0){
72       $scalixAccount->save ();
73       gosa_log ("User/scalix object'".$ui->dn."' has been saved");
74       $scalixAccount->acl= "#none#";
75       del_lock ($ui->dn);
76       session::un_set ('edit');
78       /* Remove object */
79       session::un_set ('scalixAccount');
80     } else {
81       /* Errors found, show message */
82       msg_dialog::displayChecks($message);
83     }
84   }
86   /* Execute formular */
87   $display= $scalixAccount->execute ();
89   /* Store changes  in session */
90   if (session::is_set('edit')){
91     session::set('scalixAccount',$scalixAccount);
92   }
94  /* Show page footer depending on the mode */
95   if ($scalixAccount->is_account){
97     $display.= "<p class=\"plugbottom\">";
99     /* Are we in edit mode? */
100     if (session::is_set('edit')){
101       $display.= "<input type=submit name=\"edit_finish\" value=\"".msgPool::saveButton()."\">\n";
102       $display.= "&nbsp;";
103       $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
104       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
105              "\"> ".$ui->dn."&nbsp;";
106     } else {
107       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
108              "\"> ".$ui->dn."&nbsp;";
110       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/scalix"))){
111         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png')."\"> ".
112                 _("Click the 'Edit' button below to change informations in this dialog");
114         $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
115       }
116       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
117     }
118     $display.= "</p>\n";
119   }
122   $info= "";
124   /* Page header*/
125   $display= print_header(get_template_path('images/scalix.png'), _("Scalix settings"), $info).$display;
129 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
130 ?>