Code

Some updates
[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       gosa_log("User/netatalk object'".$ui->dn."' has been saved");
69       del_lock($ui->dn);
70       sess_del('edit');
72       /* Store object */
73       $_SESSION['netatalk'] = $netatalk;
74     } else {
75       /* Errors found, show message */
76       show_errors($message);
77     }
78   }
80   /* Execute formular */
81   $display = $netatalk->execute();
83   /* Store changes  in session */
84   if (isset ($_SESSION['edit'])) {
85     $_SESSION['netatalk'] = $netatalk;
86   }
88   $info = "";
89   /* Show page footer depending on the mode */
90   if ($netatalk->is_account) {
91     $display .= "<p class=\"plugbottom\">";
93     /* Are we in edit mode? */
94     if (isset ($_SESSION['edit'])) {
95       $display .= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
96       $display .= "&nbsp;";
97       $display .= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
98       $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$ui->dn."&nbsp;";
99     } else {
100       $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png')."\"> ".$ui->dn."&nbsp;";
101       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/netatalk"))){
102         $info .= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> "._("Click the 'Edit' button below to change informations in this dialog");
103         $display .= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
104       }
106       $display .= "<input type=\"hidden\" name=\"ignore\">\n";
107     }
108     $display .= "</p>\n";
109   }
111   /* Page header*/
112   $display = print_header(get_template_path('images/netatalk.png'), _("Netatalk settings"), $info).$display;
116 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
117 ?>