Code

Starting move
[gosa.git] / gosa-core / plugins / personal / posix / 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 /* Clear display */
22 $display  = "";
23 $lock_msg = "";
24 if (!$remove_lock){
26   /* Reset requested? */
27   if (isset($_POST['edit_cancel']) ||  (isset($_GET['reset']) && $_GET['reset'] == 1)){
28     del_lock ($ui->dn);
29     sess_del ('edit');
30     sess_del ('posixAccount');
31   }
33   /* Create posixAccount object on demand */
34   if (!isset($_SESSION['posixAccount']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
35     $_SESSION['posixAccount']= new posixAccount ($config, $ui->dn);
36     $_SESSION['posixAccount']->enable_CSN_check();
37     $_SESSION['posixAccount']->set_acl_base($ui->dn);
38     $_SESSION['posixAccount']->set_acl_category("users");
39   }
40   $posixAccount= $_SESSION['posixAccount'];
42   /* save changes back to object */
43   if (isset ($_SESSION['edit'])){
44     $posixAccount->save_object ();
45   }
47   /* Enter edit mode? */
48   if ((isset($_POST['edit'])) && (!isset($_SESSION['edit']))){
49     
50     /* Check locking */
51     if (($username= get_lock($ui->dn)) != ""){
52       $_SESSION['back_plugin']= $plug;
53       $_SESSION['LOCK_VARS_TO_USE'] = array("/^edit$/","/^plug$/");
54       $lock_msg =  gen_locked_message ($username, $ui->dn);
56     }else{
58       /* Lock the current entry */
59       add_lock ($ui->dn, $ui->dn);
60       $_SESSION['dn']= $ui->dn;
61       $_SESSION['edit']= TRUE;
62     }
63   }
65   /* save changes to LDAP and disable edit mode */
66   $info= "";
67   if (isset($_POST['edit_finish'])){
69     /* Perform checks */
70     $message= $posixAccount->check ();
72     /* No errors, save object */
73     if (count ($message) == 0){
74       $posixAccount->save ();
75       del_lock ($ui->dn);
76       sess_del ('edit');
78       /* Remove from session */
79       sess_del ('posixAccount');
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.= $posixAccount->execute ();
91   }
93   /* Store changes  in session */
94   if (isset ($_SESSION['edit'])){
95     $_SESSION['posixAccount']= $posixAccount;
96   }
98   /* Show page footer depending on the mode */
99   if (!$posixAccount->group_dialog && !$posixAccount->show_ws_dialog && $posixAccount->is_account && empty($lock_msg)){
101     $display.= "<p class=\"plugbottom\">";
103     /* Are we in edit mode? */
104     if (isset($_SESSION['edit'])){
105       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\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;";
114       /* Only display edit button if there is at least one attribute editable */
115       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/posixAccount"))){
116         $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".
117           _("Click the 'Edit' button below to change informations in this dialog");
119         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
120       }
121       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
122     }
123     $display.= "</p>\n";
124   }
126   /* Page header*/
127   $display= print_header(get_template_path('images/posix.png'),
128                          _("Unix settings"), $info).$display;
132 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
133 ?>