Code

Fixed win workstation acls.
[gosa.git] / plugins / 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 if (!$remove_lock){
22   /* Reset requested? */
23   if (isset($_POST['edit_cancel']) ||
24       (isset($_GET['reset']) && $_GET['reset'] == 1)){
26     del_lock ($ui->dn);
27     sess_del ('edit');
28     sess_del ('sambaAccount');
29   }
31   /* Create sambaAccount object on demand */
32   if (!isset($_SESSION['sambaAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
33     $_SESSION['sambaAccount']= new sambaAccount ($config, $ui->dn);
34     $_SESSION['sambaAccount']->set_acl_base($ui->dn);
35     $_SESSION['sambaAccount']->set_acl_category("users");
36   }
37   $sambaAccount= $_SESSION['sambaAccount'];
39   /* save changes back to object */
40   if (isset ($_SESSION['edit'])){
41     $sambaAccount->save_object ();
42   }
44   /* Enter edit mode? */
45   if (isset($_POST['edit'])){
47     /* Check locking */
48     if (($username= get_lock($ui->dn)) != ""){
49       $_SESSION['back_plugin']= $plug;
50       gen_locked_message ($username, $ui->dn);
51       exit ();
52     }
54     /* Lock the current entry */
55     add_lock ($ui->dn, $ui->dn);
56     $_SESSION['dn']= $ui->dn;
57     $_SESSION['edit']= TRUE;
58   }
60   /* save changes to LDAP and disable edit mode */
61   if (isset($_POST['edit_finish'])){
63     /* Perform checks */
64     $message= $sambaAccount->check ();
66     /* No errors, save object */
67     if (count ($message) == 0){
68       $sambaAccount->save ();
69       gosa_log ("User/samba object'".$ui->dn."' has been saved");
70       del_lock ($ui->dn);
71       sess_del ('edit');
73       /* Reload */
74       $_SESSION['sambaAccount']= $sambaAccount;
75     } else {
76       /* Errors found, show message */
77       show_errors ($message);
78     }
79   }
81   /* Execute formular */
82   $display= $sambaAccount->execute ();
84   /* Store changes  in session */
85   if (isset ($_SESSION['edit'])){
86     $_SESSION['sambaAccount']= $sambaAccount;
87   }
89   $info= "";
90   if (($sambaAccount->is_account) && (!$sambaAccount->show_ws_dialog)){
91     $display.= "<p class=\"plugbottom\">";
93     /* Are we in edit mode? */
94     if (isset($_SESSION['edit'])){
95       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
96       $display.= "&nbsp;";
97       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
98       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
99              "\"> ".$ui->dn."&nbsp;";
100     } else {
101       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
102              "\"> ".$ui->dn."&nbsp;";
104       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/sambaAccount"))){
106         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".
107                 _("Click the 'Edit' button below to change informations in this dialog");
108         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
109       }
110       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
111     }
112     $display.= "</p>\n";
113   }
115   /* Page header*/
116   $display= print_header(get_template_path('images/samba.png'), _("Samba settings"),
117                          $info).$display;
121 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
122 ?>