1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2004 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 session::un_set ('edit');
30 session::un_set ('phoneAccount');
31 }
33 /* Create phoneAccount object on demand */
34 if (!session::is_set('phoneAccount') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
35 $phoneAccount= new phoneAccount ($config, $ui->dn);
36 $phoneAccount->set_acl_base($ui->dn);
37 $phoneAccount->set_acl_category("users");
38 session::set('phoneAccount',$phoneAccount);
39 }
40 $phoneAccount = session::get('phoneAccount');
42 /* save changes back to object */
43 if (session::is_set('edit')){
44 $phoneAccount->save_object ();
45 }
47 /* Enter edit mode? */
48 if (isset($_POST['edit'])){
50 /* Check locking */
51 if (($username= get_lock($ui->dn)) != ""){
52 session::set('back_plugin',$plug);
53 session::set('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::set('dn',$ui->dn);
61 session::set('edit',TRUE);
62 }
64 }
66 /* save changes to LDAP and disable edit mode */
67 if (isset($_POST['edit_finish'])){
69 /* Perform checks */
70 $message= $phoneAccount->check ();
72 /* No errors, save object */
73 if (count ($message) == 0){
74 $phoneAccount->save ();
76 del_lock ($ui->dn);
77 session::un_set ('edit');
79 /* Write back to session */
80 session::set('phoneAccount',$phoneAccount);
81 } else {
82 /* Errors found, show message */
83 msg_dialog::displayChecks($message);
84 }
85 }
87 /* Execute formular */
88 if($lock_msg){
89 $display.= $lock_msg;
90 }else{
91 $display.= $phoneAccount->execute ();
92 }
94 /* Store changes in session */
95 if (session::is_set('edit')){
96 session::set('phoneAccount',$phoneAccount);
97 }
99 $info= "";
100 if ($phoneAccount->is_account && empty($lock_msg)){
101 $display.= "<p class=\"plugbottom\">";
103 /* Are we in edit mode? */
104 if (session::is_set('edit')){
105 $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
106 $display.= " ";
107 $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
108 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png')."\"> ".$ui->dn." ";
109 } else {
110 $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png')."\"> ".$ui->dn." ";
112 if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/phoneAccount"))){
113 $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png')."\">"._("Click the 'Edit' button below to change informations in this dialog");
114 $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
115 }
116 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
117 }
118 $display.= "</p>\n";
119 $display.= "<input type=\"hidden\" name=\"ignore\">\n";
120 }
122 /* Page header*/
123 $display= print_header(get_template_path('images/phone.png'), _("Phone settings"), $info).$display;
125 }
126 ?>