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 /* Clear display */
22 $display= "";
24 if (!$remove_lock){
26 /* Reset requested? */
27 if (isset($_POST['edit_cancel']) ||
28 (isset($_GET['reset']) && $_GET['reset'] == 1)){
30 del_lock ($ui->dn);
31 sess_del ('edit');
32 sess_del ('posixAccount');
33 }
35 /* Create posixAccount object on demand */
36 if (!isset($_SESSION['posixAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
37 $_SESSION['posixAccount']= new posixAccount ($config, $ui->dn);
38 }
39 $posixAccount= $_SESSION['posixAccount'];
41 /* save changes back to object */
42 if (isset ($_SESSION['edit'])){
43 $posixAccount->save_object ();
44 }
46 /* Enter edit mode? */
47 if (isset($_POST['edit'])){
49 /* Check locking */
50 if (($username= get_lock($ui->dn)) != ""){
51 $_SESSION['back_plugin']= $plug;
52 gen_locked_message ($username, $ui->dn);
53 exit ();
54 }
56 /* Lock the current entry */
57 add_lock ($ui->dn, $ui->dn);
58 $_SESSION['dn']= $ui->dn;
59 $_SESSION['edit']= TRUE;
60 }
62 /* save changes to LDAP and disable edit mode */
63 $info= "";
64 if (isset($_POST['edit_finish'])){
66 /* Perform checks */
67 $message= $posixAccount->check ();
69 /* No errors, save object */
70 if (count ($message) == 0){
71 $posixAccount->save ();
72 gosa_log ("User/posix object'".$ui->dn."' has been saved");
73 $posixAccount->acl= "#none#";
74 del_lock ($ui->dn);
75 sess_del ('edit');
77 /* Write back to session */
78 $_SESSION['posixAccount']= $posixAccount;
79 } else {
80 /* Errors found, show message */
81 show_errors ($message);
82 }
83 }
85 /* Execute formular */
86 $display.= $posixAccount->execute ();
88 /* Store changes in session */
89 if (isset ($_SESSION['edit'])){
90 $_SESSION['posixAccount']= $posixAccount;
91 }
93 /* Show page footer depending on the mode */
94 if (!$posixAccount->group_dialog && !$posixAccount->show_ws_dialog && $posixAccount->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\" style=\"width:80px\" value=\""._("Ok")."\">\n";
101 $display.= " ";
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." ";
105 } else {
106 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
107 "\"> ".$ui->dn." ";
109 echo "FIXME : user -> posix, 109, Only display edit button if there is at least one attribute editable.";
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 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
115 }
116 $display.= "</p>\n";
117 }
119 /* Page header*/
120 $display= print_header(get_template_path('images/posix.png'),
121 _("Unix settings"), $info).$display;
123 }
125 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
126 ?>