Code

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