Code

Added scheduleit account acls
[gosa.git] / plugins / personal / generic / 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 /* Preset display */
23 $display= "";
25 if (!$remove_lock){
26   /* Reset requested? */
27   if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || 
28       (isset($_GET['reset']) && $_GET['reset'] == 1)){
29     del_lock ($ui->dn);
30     sess_del ('edit');
31     sess_del ('user');
32   }
34   /* Create user object on demand */
35   if (!isset($_SESSION['user']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
36     $_SESSION['user']= new user ($config, $ui->dn);
37   }
38   $user= $_SESSION['user'];
40   /* save changes back to object */
41   if (isset ($_SESSION['edit'])){
42     $user->save_object ();
43   }
45   /* Enter edit mode? */
46   if (isset($_POST['edit'])){
48     /* Check locking */
49     if (($username= get_lock($ui->dn)) != ""){
50       $_SESSION['back_plugin']= $plug;
51       gen_locked_message ($username, $ui->dn);
52       exit ();
53     }
55     /* Lock the current entry */
56     add_lock ($ui->dn, $ui->dn);
57     $_SESSION['dn']= $ui->dn;
58     $_SESSION['edit']= TRUE;
59   }
61   /* Perform password change */
62   if (isset($_POST['password_finish'])){
64     /* For security reasons, check if user is allowed to set password again */
65     if ($user->acl_is_writable("userPassword") || $user->acl_is_createable()){
67       /* Check input and feed errors into 'message' */
68       $message= array();
70       /* Sanity checks... */
71       if ($_POST['new_password'] != $_POST['repeated_password']){
73         /* Matching passwords in new and repeated? */
74         $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
75       } else {
77         /* Empty password is not permitted by default. */
78         if ($_POST['new_password'] == ""){
79           $message[]= _("The password you've entered as 'New password' is empty.");
80         }
81       }
83       /* Errors, or change password? */
84       if (count($message) != 0){
86         /* Show error message and continue editing */
87         show_errors ($message);
88         $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
89         return ($display);
90       }
91       change_password ($user->dn, $_POST['new_password'], 0, $user->pw_storage);
92       gosa_log ("Password for '".$user->dn."' has been changed");
94     } else {
96       /* Missing permissions, show message */
97       print_red (_("You are not allowed to set your password!"));
98     }
100     del_lock ($ui->dn);
101   }
103   /* save changes to LDAP and disable edit mode */
104   if (isset($_POST['edit_finish'])){
106     /* Perform checks */
107     $message= $user->check ();
109     /* No errors, save object */
110     if (count ($message) == 0){
111       $user->save ();
112       gosa_log ("User/generic object'".$ui->dn."' has been saved");
113       del_lock ($ui->dn);
114       sess_del ('edit');
116       /* Save object */
117       $_SESSION['user']= $user;
119       /* Need to reset the password? */
120       if($user->password_change_needed()){
121         $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
122         return ($display);
123       }
125     } else {
126       /* Errors found, show message */
127       show_errors ($message);
128     }
129   }
131   /* Execute formular */
132   $display.= $user->execute ();
134   /* Store changes  in session */
135   if (isset ($_SESSION['edit'])){
136     $_SESSION['user']= $user;
137   }
139   $info = "";
140   /* Show page footer depending on the mode */
141   if (!$user->cert_dialog && !$user->picture_dialog && $user->is_account){
142     $display.= "<p class=\"plugbottom\">";
144     /* Are we in edit mode? */
145     if (isset($_SESSION['edit'])){
146       $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
147       $display.= "&nbsp;";
148       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
149       $display.="<script language='javascript'>";
151       $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
152              "\"> ".$ui->dn."&nbsp;";
153     } else {
154       /* 'viewid' may be set by i.e. the phonelist plugin. This
155          means that we want to go back... */
156       if (isset ($viewid)){
157         $str= _("Back");
158         $fn = "back";
159       } else {
160         $str= _("Edit");
161         $fn = "edit";
162         $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
163                "\"> ".$ui->dn."&nbsp;";
164       }
165       if ($fn == "edit"){
166         $info.= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".
167                 _("Click the 'Edit' button below to change informations in this dialog");
168         $display.= "<input type=submit name=\"$fn\" value=\"$str\">\n";
169       }
170       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
171     }
172     $display.= "</p>\n";
173   }
175   /* Page header*/
176   $display= print_header(get_template_path('images/personal.png'),
177                          _("Generic user information"), $info).$display;
181 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
182 ?>