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 */
24 /* Remove locks created by this plugin
25 */
26 $lock_msg="";
27 if ($remove_lock || isset($_POST['edit_cancel'])){
28 if(session::is_set('posixAccount') && session::is_set('edit')){
29 del_lock($ui->dn);
30 }
31 }
33 /* Remove this plugin from session
34 */
35 if ( $cleanup ){
36 session::un_set('posixAccount');
37 session::un_set('edit');
39 }else{
41 /* Reset requested? */
42 if (isset($_POST['edit_cancel'])){
43 session::un_set ('edit');
44 session::un_set ('posixAccount');
45 }
47 /* Create posixAccount object on demand */
48 if (!session::is_set('posixAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
49 $posixAccount= new posixAccount ($config, $ui->dn);
50 $posixAccount->enable_CSN_check();
51 $posixAccount->set_acl_base($ui->dn);
52 $posixAccount->set_acl_category("users");
53 session::set('posixAccount',$posixAccount);
54 }
55 $posixAccount = session::get('posixAccount');
57 /* save changes back to object */
58 if (session::is_set('edit')){
59 $posixAccount->save_object ();
60 }
62 /* Enter edit mode? */
63 if ((isset($_POST['edit'])) && (!session::is_set('edit'))){
65 /* Check locking */
66 if (($username= get_lock($ui->dn)) != ""){
67 session::set('back_plugin',$plug);
68 session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
69 $lock_msg = gen_locked_message ($username, $ui->dn);
71 }else{
73 /* Lock the current entry */
74 add_lock ($ui->dn, $ui->dn);
75 session::set('edit',TRUE);
76 }
77 }
79 /* save changes to LDAP and disable edit mode */
80 $info= "";
81 if (isset($_POST['edit_finish'])){
83 /* Perform checks */
84 $message= $posixAccount->check ();
86 /* No errors, save object */
87 if (count ($message) == 0){
88 $posixAccount->save ();
89 del_lock ($ui->dn);
90 session::un_set ('edit');
92 /* Remove from session */
93 session::un_set ('posixAccount');
94 } else {
95 /* Errors found, show message */
96 msg_dialog::displayChecks($message);
97 }
98 }
100 /* Execute formular */
101 if($lock_msg){
102 $display = $lock_msg;
103 }else{
104 $display.= $posixAccount->execute ();
105 }
107 /* Store changes in session */
108 if (session::is_set('edit')){
109 session::set('posixAccount',$posixAccount);
110 }
112 /* Show page footer depending on the mode */
113 if (!$posixAccount->groupSelect && !$posixAccount->show_ws_dialog && $posixAccount->is_account && empty($lock_msg)){
115 $display.= "<p class=\"plugbottom\">";
117 /* Are we in edit mode? */
118 if (session::is_set('edit')){
119 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
120 $display.= " ";
121 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
122 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
123 "\"> ".$ui->dn." ";
124 } else {
125 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
126 "\"> ".$ui->dn." ";
128 /* Only display edit button if there is at least one attribute editable */
129 if(preg_match("/r/",$ui->get_permissions($ui->dn,"users/posixAccount"))){
130 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png')."\"> ".
131 msgPool::clickEditToChange();
133 $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
134 }
135 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
136 }
137 $display.= "</p>\n";
138 }
140 /* Page header*/
141 $display= print_header(get_template_path('plugins/posix/images/plugin.png'),
142 _("POSIX settings"), $info).$display;
144 }
146 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
147 ?>