Code

Initialized by array().
[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   }
35   $sambaAccount= $_SESSION['sambaAccount'];
37   /* save changes back to object */
38   if (isset ($_SESSION['edit'])){
39     $sambaAccount->save_object ();
40   }
42   /* Enter edit mode? */
43   if ((isset($_POST['edit'])) && (!isset( $_SESSION['edit']))){
45     /* Check locking */
46     if (($username= get_lock($ui->dn)) != ""){
47       $_SESSION['back_plugin']= $plug;
48       gen_locked_message ($username, $ui->dn);
49       exit ();
50     }
52     /* Lock the current entry */
53     add_lock ($ui->dn, $ui->dn);
54     $_SESSION['dn']= $ui->dn;
55     $_SESSION['edit']= TRUE;
56   }
58   /* Adjust acl's to mode */
59   if (isset($_SESSION['edit'])){
60     $acl= get_permissions ($ui->dn, $ui->subtreeACL);
61     $sambaAccount->acl= get_module_permission($acl, "sambaAccount", $ui->dn);
62   } else {
63     $acl= get_permissions ($ui->dn, $ui->subtreeACL);
64     $editacl= get_module_permission($acl, "sambaAccount", $ui->dn);
65     $sambaAccount->acl= "#none#";
66   }
68   /* save changes to LDAP and disable edit mode */
69   if (isset($_POST['edit_finish'])){
71     /* Perform checks */
72     $message= $sambaAccount->check ();
74     /* No errors, save object */
75     if (count ($message) == 0){
76       $sambaAccount->save ();
77       gosa_log ("User/samba object'".$ui->dn."' has been saved");
78       $sambaAccount->acl= "#none#";
79       $editacl= get_module_permission($acl, "sambaAccount", $ui->dn);
80       del_lock ($ui->dn);
81       sess_del ('edit');
83       /* Remove from session */
84       sess_del ('sambaAccount');
85     } else {
86       /* Errors found, show message */
87       show_errors ($message);
88     }
89   }
91   /* Execute formular */
92   $display= $sambaAccount->execute ();
94   /* Store changes  in session */
95   if (isset ($_SESSION['edit'])){
96     $_SESSION['sambaAccount']= $sambaAccount;
97   }
99   $info= "";
100   if ($sambaAccount->is_account){
101     $display.= "<p class=\"plugbottom\">";
103     /* Are we in edit mode? */
104     if (isset($_SESSION['edit'])){
105       $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
106       $display.= "&nbsp;";
107       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
108       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
109              "\"> ".$ui->dn."&nbsp;";
110     } else {
111       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
112              "\"> ".$ui->dn."&nbsp;";
113       if (isset($editacl) && $editacl != "#none#"){
114         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".
115                 _("Click the 'Edit' button below to change informations in this dialog");
116         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
117       }
118       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
119     }
120     $display.= "</p>\n";
121   }
123   /* Page header*/
124   $display= print_header(get_template_path('images/samba.png'), _("Samba settings"),
125                          $info).$display;
129 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
130 ?>