Code

MsgPool
[gosa.git] / gosa-plugins / samba / personal / samba / 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  */
21 $display  = "";
22 $lock_msg = "";
23 if (!$remove_lock){
24   /* Reset requested? */
25   if (isset($_POST['edit_cancel']) ||
26       (isset($_GET['reset']) && $_GET['reset'] == 1)){
28     del_lock ($ui->dn);
29     session::un_set ('edit');
30     session::un_set ('sambaAccount');
31   }
33   /* Create sambaAccount object on demand */
34   if (!session::is_set('sambaAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
35     $sambaAccount= new sambaAccount ($config, $ui->dn);
36     $sambaAccount->enable_CSN_check();
37     $sambaAccount->set_acl_base($ui->dn);
38     $sambaAccount->set_acl_category("users");
39     session::set('sambaAccount',$sambaAccount);
40   }
41   $sambaAccount = session::get('sambaAccount');
43   /* save changes back to object */
44   if (session::is_set('edit')){
45     $sambaAccount->save_object ();
46   }
48   /* Enter edit mode? */
49   if (isset($_POST['edit'])){
51     /* Check locking */
52     if (($username= get_lock($ui->dn)) != ""){
53       session::set('back_plugin',$plug);
54       session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
55       $lock_msg =  gen_locked_message ($username, $ui->dn);
57     }else{
59       /* Lock the current entry */
60       add_lock ($ui->dn, $ui->dn);
61       session::set('dn',$ui->dn);
62       session::set('edit',TRUE);
63     }
64   }
66   /* save changes to LDAP and disable edit mode */
67   if (isset($_POST['edit_finish'])){
69     /* Perform checks */
70     $message= $sambaAccount->check ();
72     /* No errors, save object */
73     if (count ($message) == 0){
74       $sambaAccount->save ();
75       del_lock ($ui->dn);
76       session::un_set ('edit');
78       /* Remove from session */
79       session::un_set ('sambaAccount');
80     } else {
81       /* Errors found, show message */
82       show_errors ($message);
83     }
84   }
86   /* Execute formular */
87   if($lock_msg){
88     $display.= $lock_msg;
89   }else{
90     $display.= $sambaAccount->execute ();
91   }
93   /* Store changes  in session */
94   if (session::is_set('edit')){
95     session::set('sambaAccount',$sambaAccount);
96   }
98   $info= "";
99   if (($sambaAccount->is_account) && (!$sambaAccount->show_ws_dialog) && empty($lock_msg)){
100     $display.= "<p class=\"plugbottom\">";
102     /* Are we in edit mode? */
103     if (session::is_set('edit')){
104       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
105       $display.= "&nbsp;";
106       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
107       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
108              "\"> ".$ui->dn."&nbsp;";
109     } else {
110       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
111              "\"> ".$ui->dn."&nbsp;";
113       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/sambaAccount"))){
115         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".
116                 _("Click the 'Edit' button below to change informations in this dialog");
117         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
118       }
119       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
120     }
121     $display.= "</p>\n";
122   }
124   /* Page header*/
125   $display= print_header(get_template_path('images/samba.png'), _("Samba settings"),
126                          $info).$display;
130 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
131 ?>