Code

Added checkboxes to management dialog to filter actions
[gosa.git] / plugins / personal / netatalk / main.inc
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     $_SESSION['netatalk']->set_acl_base($ui->dn);
34     $_SESSION['netatalk']->set_acl_category("users");
35   }
36   $netatalk = $_SESSION['netatalk'];
38   /* save changes back to object */
39   if (isset ($_SESSION['edit'])) {
40     $netatalk->save_object();
41   }
43   /* Enter edit mode? */
44   if (isset ($_POST['edit'])) {
46     /* Check locking */
47     if (($username = get_lock($ui->dn)) != "") {
48       $_SESSION['back_plugin'] = $plug;
49       gen_locked_message($username, $ui->dn);
50       exit ();
51     }
53     /* Lock the current entry */
54     add_lock($ui->dn, $ui->dn);
55     $_SESSION['dn'] = $ui->dn;
56     $_SESSION['edit'] = TRUE;
57   }
59   /* save changes to LDAP and disable edit mode */
60   if (isset ($_POST['edit_finish'])) {
62     /* Perform checks */
63     $message = $netatalk->check();
65     /* No errors, save object */
66     if (count($message) == 0) {
67       $netatalk->save();
68       del_lock($ui->dn);
69       sess_del('edit');
71       /* Remove object */
72       sess_del('netatalk');
73     } else {
74       /* Errors found, show message */
75       show_errors($message);
76     }
77   }
79   /* Execute formular */
80   $display = $netatalk->execute();
82   /* Store changes  in session */
83   if (isset ($_SESSION['edit'])) {
84     $_SESSION['netatalk'] = $netatalk;
85   }
87   $info = "";
88   /* Show page footer depending on the mode */
89   if ($netatalk->is_account) {
90     $display .= "<p class=\"plugbottom\">";
92     /* Are we in edit mode? */
93     if (isset ($_SESSION['edit'])) {
94       $display .= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
95       $display .= "&nbsp;";
96       $display .= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
97       $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$ui->dn."&nbsp;";
98     } else {
99       $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png')."\"> ".$ui->dn."&nbsp;";
100       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/netatalk"))){
101         $info .= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> "._("Click the 'Edit' button below to change informations in this dialog");
102         $display .= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
103       }
105       $display .= "<input type=\"hidden\" name=\"ignore\">\n";
106     }
107     $display .= "</p>\n";
108   }
110   /* Page header*/
111   $display = print_header(get_template_path('images/netatalk.png'), _("Netatalk settings"), $info).$display;
115 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
116 ?>