Code

Added acls for main
[gosa.git] / plugins / personal / environment / 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 if (!$remove_lock){
22   /* Reset requested? */
23   if (isset($_POST['edit_cancel']) || 
24       (isset($_GET['reset']) && $_GET['reset'] == 1)){
25     del_lock ($ui->dn);
26     sess_del ('edit');
27     sess_del ('environment');
28   }
30   /* Create mail object on demand */
31   if (!isset($_SESSION['environment']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
32     $_SESSION['environment']= new environment ($config, $ui->dn);
33   }
34   $environment= $_SESSION['environment'];
36   /* save changes back to object */
37   if (isset($_SESSION['edit'])){
38     $environment->save_object ();
39   }
41   /* Enter edit mode? */
42   if (isset($_POST['edit'])){
44     /* Check locking */
45     if (($username= get_lock($ui->dn)) != ""){
46       $_SESSION['back_plugin']= $plug;
47       gen_locked_message ($username, $ui->dn);
48       exit ();
49     }
51     /* Lock the current entry */
52     add_lock ($ui->dn, $ui->dn);
53     $_SESSION['dn']= $ui->dn;
54     $_SESSION['edit']= TRUE;
55   }
57   /* save changes to LDAP and disable edit mode */
58   if (isset($_POST['edit_finish'])){
60     /* Perform checks */
61     $message= $environment->check ();
63     /* No errors, save object */
64     if (count ($message) == 0){
65       $environment->save ();
66       gosa_log ("User/environment object'".$ui->dn."' has been saved");
67       $environment->acl= "#none#";
68       del_lock ($ui->dn);
69       sess_del ('edit');
71       /* Store object */
72       $_SESSION['environment']= $environment;
73     } else {
74       /* Errors found, show message */
75       show_errors ($message);
76     }
77   }
79   /* Execute formular */
80   $display= $environment->execute ();
82   /* Store changes  in session */
83   if (isset ($_SESSION['edit'])){
84     $_SESSION['environment']= $environment;
85   }
87   $info= "";
88   /* Show page footer depending on the mode */
89   if (!$environment->in_dialog && $environment->is_account){
90     $display.= "<p class=\"plugbottom\">";
92     /* Are we in edit mode? */
93     if ((isset($_SESSION['edit']))&&($environment->dialog==NULL)){
94       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
95       $display.= "&nbsp;";
96       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
97       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
98              "\"> ".$ui->dn."&nbsp;";
99     } else {
100       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
101              "\"> ".$ui->dn."&nbsp;";
102   #      if (isset($editacl) && $editacl != "#none#"){
103       echo "FIxme, only display edit button if there is at least one attribute writeable";
104         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
105             "\"> "._("Click the 'Edit' button below to change informations in this dialog");
106         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
107    #   }
109       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
110     }
111     $display.= "</p>\n";
112   }
114   /* Page header*/
115   $display= print_header(get_template_path('images/email.png'), _("User environment settings"), $info).$display;
119 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
120 ?>