1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 /* Clear display */
24 $display = "";
25 $lock_msg = "";
26 if (!$remove_lock){
28 /* Reset requested? */
29 if (isset($_POST['edit_cancel']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
30 del_lock ($ui->dn);
31 session::un_set ('edit');
32 session::un_set ('posixAccount');
33 }
35 /* Create posixAccount object on demand */
36 if (!session::is_set('posixAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
37 $posixAccount= new posixAccount ($config, $ui->dn);
38 $posixAccount->enable_CSN_check();
39 $posixAccount->set_acl_base($ui->dn);
40 $posixAccount->set_acl_category("users");
41 session::set('posixAccount',$posixAccount);
42 }
43 $posixAccount = session::get('posixAccount');
45 /* save changes back to object */
46 if (session::is_set('edit')){
47 $posixAccount->save_object ();
48 }
50 /* Enter edit mode? */
51 if ((isset($_POST['edit'])) && (!session::is_set('edit'))){
53 /* Check locking */
54 if (($username= get_lock($ui->dn)) != ""){
55 session::set('back_plugin',$plug);
56 session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
57 $lock_msg = gen_locked_message ($username, $ui->dn);
59 }else{
61 /* Lock the current entry */
62 add_lock ($ui->dn, $ui->dn);
63 session::set('dn',$ui->dn);
64 session::set('edit',TRUE);
65 }
66 }
68 /* save changes to LDAP and disable edit mode */
69 $info= "";
70 if (isset($_POST['edit_finish'])){
72 /* Perform checks */
73 $message= $posixAccount->check ();
75 /* No errors, save object */
76 if (count ($message) == 0){
77 $posixAccount->save ();
78 del_lock ($ui->dn);
79 session::un_set ('edit');
81 /* Remove from session */
82 session::un_set ('posixAccount');
83 } else {
84 /* Errors found, show message */
85 msg_dialog::displayChecks($message);
86 }
87 }
89 /* Execute formular */
90 if($lock_msg){
91 $display = $lock_msg;
92 }else{
93 $display.= $posixAccount->execute ();
94 }
96 /* Store changes in session */
97 if (session::is_set('edit')){
98 session::set('posixAccount',$posixAccount);
99 }
101 /* Show page footer depending on the mode */
102 if (!$posixAccount->group_dialog && !$posixAccount->show_ws_dialog && $posixAccount->is_account && empty($lock_msg)){
104 $display.= "<p class=\"plugbottom\">";
106 /* Are we in edit mode? */
107 if (session::is_set('edit')){
108 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
109 $display.= " ";
110 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
111 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
112 "\"> ".$ui->dn." ";
113 } else {
114 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
115 "\"> ".$ui->dn." ";
117 /* Only display edit button if there is at least one attribute editable */
118 if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/posixAccount"))){
119 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png')."\"> ".
120 msgPool::clickEditToChange();
122 $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
123 }
124 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
125 }
126 $display.= "</p>\n";
127 }
129 /* Page header*/
130 $display= print_header(get_template_path('images/posix.png'),
131 _("POSIX settings"), $info).$display;
133 }
135 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
136 ?>