Code

Updated posix plugin
[gosa.git] / gosa-core / 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  */
20 $lock_msg = "";
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     $_SESSION['environment']->enable_CSN_check();
34     $_SESSION['environment']->set_acl_category('users');
35     $_SESSION['environment']->set_acl_base($ui->dn);
36   }
37   $environment= $_SESSION['environment'];
39   /* save changes back to object */
40   if (isset($_SESSION['edit'])){
41     $environment->save_object ();
42   }
44   /* Enter edit mode? */
45   if (isset($_POST['edit'])){
46   
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= $environment->check ();
68     /* No errors, save object */
69     if (count ($message) == 0){
70       $environment->save ();
71       del_lock ($ui->dn);
72       sess_del ('edit');
74       /* Remove object */
75       sess_del ('environment');
76     } else {
77       /* Errors found, show message */
78       show_errors ($message);
79     }
80   }
82   /* Execute formular */
83   if($lock_msg){
84     $display = $lock_msg;
85   }else{
86     $display = $environment->execute();
87   }
89   /* Store changes  in session */
90   if (isset ($_SESSION['edit'])){
91     $_SESSION['environment']= $environment;
92   }
94   $info= "";
95   /* Show page footer depending on the mode */
96   if (!$environment->in_dialog && $environment->is_account  && empty($lock_msg)){
97     $display.= "<p class=\"plugbottom\">";
99     /* Are we in edit mode? */
100     if ((isset($_SESSION['edit']))&&($environment->dialog===NULL)){
101       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
102       $display.= "&nbsp;";
103       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
104       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
105              "\"> ".$ui->dn."&nbsp;";
106     } else {
107       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
108         "\"> ".$ui->dn."&nbsp;";
109       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/environment"))){
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");
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   }
119   /* Page header*/
120   $display= print_header(get_template_path('images/email.png'), _("User environment settings"), $info).$display;
124 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
125 ?>