Code

Prepared for multiple asterisk servers
[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 $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     sess_del ('edit');
30     sess_del ('sambaAccount');
31   }
33   /* Create sambaAccount object on demand */
34   if (!isset($_SESSION['sambaAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
35     $_SESSION['sambaAccount']= new sambaAccount ($config, $ui->dn);
36     $_SESSION['sambaAccount']->set_acl_base($ui->dn);
37     $_SESSION['sambaAccount']->set_acl_category("users");
38   }
39   $sambaAccount= $_SESSION['sambaAccount'];
41   /* save changes back to object */
42   if (isset ($_SESSION['edit'])){
43     $sambaAccount->save_object ();
44   }
46   /* Enter edit mode? */
47   if (isset($_POST['edit'])){
49     /* Check locking */
50     if (($username= get_lock($ui->dn)) != ""){
51       $_SESSION['back_plugin']= $plug;
52       $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/");
53       $lock_msg =  gen_locked_message ($username, $ui->dn);
55     }else{
57       /* Lock the current entry */
58       add_lock ($ui->dn, $ui->dn);
59       $_SESSION['dn']= $ui->dn;
60       $_SESSION['edit']= TRUE;
61     }
62   }
64   /* save changes to LDAP and disable edit mode */
65   if (isset($_POST['edit_finish'])){
67     /* Perform checks */
68     $message= $sambaAccount->check ();
70     /* No errors, save object */
71     if (count ($message) == 0){
72       $sambaAccount->save ();
73       gosa_log ("User/samba object'".$ui->dn."' has been saved");
74       del_lock ($ui->dn);
75       sess_del ('edit');
77       /* Reload */
78       $_SESSION['sambaAccount']= $sambaAccount;
79     } else {
80       /* Errors found, show message */
81       show_errors ($message);
82     }
83   }
85   /* Execute formular */
86   if($lock_msg){
87     $display.= $lock_msg;
88   }else{
89     $display.= $sambaAccount->execute ();
90   }
92   /* Store changes  in session */
93   if (isset ($_SESSION['edit'])){
94     $_SESSION['sambaAccount']= $sambaAccount;
95   }
97   $info= "";
98   if (($sambaAccount->is_account) && (!$sambaAccount->show_ws_dialog) && empty($lock_msg)){
99     $display.= "<p class=\"plugbottom\">";
101     /* Are we in edit mode? */
102     if (isset($_SESSION['edit'])){
103       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
104       $display.= "&nbsp;";
105       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
106       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
107              "\"> ".$ui->dn."&nbsp;";
108     } else {
109       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
110              "\"> ".$ui->dn."&nbsp;";
112       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/sambaAccount"))){
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 ?>