1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2006 Gina Haeussge <osd@foosel.net>
5 Copyright (C) 2006 Bernd Zeimetz <bernd@zeimetz.de>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
22 if (!$remove_lock) {
23 /* Reset requested? */
24 if (isset ($_POST['edit_cancel']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) {
25 del_lock($ui->dn);
26 sess_del('edit');
27 sess_del('netatalk');
28 }
30 /* Create netatalk object on demand */
31 if (!isset ($_SESSION['netatalk']) || (isset ($_GET['reset']) && $_GET['reset'] == 1)) {
32 $_SESSION['netatalk'] = new netatalk($config, $ui->dn);
33 }
34 $netatalk = $_SESSION['netatalk'];
36 /* save changes back to object */
37 if (isset ($_SESSION['edit'])) {
38 $netatalk->save_object();
39 }
41 /* Enter edit mode? */
42 if ((isset($_POST['edit'])) && (!isset( $_SESSION['edit']))){
44 /* Check locking */
45 if (($username = get_lock($ui->dn)) != "") {
46 $_SESSION['back_plugin'] = $plug;
47 gen_locked_message($username, $ui->dn);
48 exit ();
49 }
51 /* Lock the current entry */
52 add_lock($ui->dn, $ui->dn);
53 $_SESSION['dn'] = $ui->dn;
54 $_SESSION['edit'] = TRUE;
55 }
57 /* Adjust acl's to mode */
58 if (isset ($_SESSION['edit'])) {
59 $acl = get_permissions($ui->dn, $ui->subtreeACL);
60 $netatalk->acl = get_module_permission($acl, "netatalk", $ui->dn);
61 } else {
62 $acl = get_permissions($ui->dn, $ui->subtreeACL);
63 $editacl = get_module_permission($acl, "netatalk", $ui->dn);
64 $netatalk->acl = "#none#";
65 }
67 /* save changes to LDAP and disable edit mode */
68 if (isset ($_POST['edit_finish'])) {
70 /* Perform checks */
71 $message = $netatalk->check();
73 /* No errors, save object */
74 if (count($message) == 0) {
75 $netatalk->save();
76 gosa_log("User/netatalk object'".$ui->dn."' has been saved");
77 $netatalk->acl = "#none#";
78 del_lock($ui->dn);
79 sess_del('edit');
81 /* Store object */
82 $_SESSION['netatalk'] = $netatalk;
83 } else {
84 /* Errors found, show message */
85 show_errors($message);
86 }
87 }
89 /* Execute formular */
90 $display = $netatalk->execute();
92 /* Store changes in session */
93 if (isset ($_SESSION['edit'])) {
94 $_SESSION['netatalk'] = $netatalk;
95 }
97 $info = "";
98 /* Show page footer depending on the mode */
99 if ($netatalk->is_account) {
100 $display .= "<p class=\"plugbottom\">";
102 /* Are we in edit mode? */
103 if (isset ($_SESSION['edit'])) {
104 $display .= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
105 $display .= " ";
106 $display .= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
107 $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$ui->dn." ";
108 } else {
109 $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png')."\"> ".$ui->dn." ";
110 if (isset ($editacl) && $editacl != "#none#") {
111 $info .= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> "._("Click the 'Edit' button below to change informations in this dialog");
112 $display .= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
113 }
115 $display .= "<input type=\"hidden\" name=\"ignore\">\n";
116 }
117 $display .= "</p>\n";
118 }
120 /* Page header*/
121 $display = print_header(get_template_path('images/netatalk.png'), _("Netatalk settings"), $info).$display;
123 }
125 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
126 ?>