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 $display = "";
22 $lock_msg = "";
23 if ( $remove_lock){
24 if(session::is_set('sambaAccount') && session::is_set('edit')){
25 del_lock ($ui->dn);
26 }
28 }else{
30 /* Reset requested? */
31 if (isset($_POST['edit_cancel']) ||
32 (isset($_GET['reset']) && $_GET['reset'] == 1)){
34 /* Only remove lock if object was opened
35 */
36 if(session::is_set('sambaAccount') && session::is_set('edit')){
37 del_lock ($ui->dn);
38 }
39 session::un_set ('edit');
40 session::un_set ('sambaAccount');
41 }
43 /* Create sambaAccount object on demand */
44 if (!session::is_set('sambaAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
45 $sambaAccount= new sambaAccount ($config, $ui->dn);
46 $sambaAccount->enable_CSN_check();
47 $sambaAccount->set_acl_base($ui->dn);
48 $sambaAccount->set_acl_category("users");
49 session::set('sambaAccount',$sambaAccount);
50 }
51 $sambaAccount = session::get('sambaAccount');
53 /* save changes back to object */
54 if (session::is_set('edit')){
55 $sambaAccount->save_object ();
56 }
58 /* Enter edit mode? */
59 if (isset($_POST['edit'])){
61 /* Check locking */
62 if (($username= get_lock($ui->dn)) != ""){
63 session::set('back_plugin',$plug);
64 session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
65 $lock_msg = gen_locked_message ($username, $ui->dn);
67 }else{
69 /* Lock the current entry */
70 add_lock ($ui->dn, $ui->dn);
71 session::set('edit',TRUE);
72 }
73 }
75 /* save changes to LDAP and disable edit mode */
76 if (isset($_POST['edit_finish'])){
78 /* Perform checks */
79 $message= $sambaAccount->check ();
81 /* No errors, save object */
82 if (count ($message) == 0){
83 $sambaAccount->save ();
84 del_lock ($ui->dn);
85 session::un_set ('edit');
87 /* Remove from session */
88 session::un_set ('sambaAccount');
89 } else {
90 /* Errors found, show message */
91 msg_dialog::displayChecks($message);
92 }
93 }
95 /* Execute formular */
96 if($lock_msg){
97 $display.= $lock_msg;
98 }else{
99 $display.= $sambaAccount->execute ();
100 }
102 /* Store changes in session */
103 if (session::is_set('edit')){
104 session::set('sambaAccount',$sambaAccount);
105 }
107 $info= "";
108 if (($sambaAccount->is_account) && (!$sambaAccount->dialog) && (!$sambaAccount->show_ws_dialog) && empty($lock_msg)){
109 $display.= "<p class=\"plugbottom\">";
111 /* Are we in edit mode? */
112 if (session::is_set('edit')){
113 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
114 $display.= " ";
115 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
116 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
117 "\"> ".$ui->dn." ";
118 } else {
119 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
120 "\"> ".$ui->dn." ";
122 if(preg_match("/r/",$ui->get_permissions($ui->dn,"users/sambaAccount"))){
124 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png')."\"> ".
125 msgPool::clickEditToChange();
126 $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
127 }
128 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
129 }
130 $display.= "</p>\n";
131 }
133 /* Page header*/
134 $display= print_header(get_template_path('plugins/samba/images/plugin.png'), _("Samba settings"),
135 $info).$display;
137 }
139 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
140 ?>