Code

Updated msgPools
[gosa.git] / gosa-plugins / netatalk / 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     session::un_set('edit');
27     session::un_set('netatalk');
28   }
30   /* Create netatalk object on demand */
31   if (!session::is_set('netatalk') || (isset ($_GET['reset']) && $_GET['reset'] == 1)) {
32     $netatalk = new netatalk($config, $ui->dn);
33     $netatalk->enable_CSN_check();
34     $netatalk->set_acl_base($ui->dn);
35     $netatalk->set_acl_category("users");
36     session::set('netatalk',$netatalk);
37   }
38   $netatalk  = session::get('netatalk');
40   /* save changes back to object */
41   if (session::is_set('edit')) {
42     $netatalk->save_object();
43   }
45   /* Enter edit mode? */
46   if (isset ($_POST['edit'])) {
48     /* Check locking */
49     if (($username = get_lock($ui->dn)) != "") {
50       session::set('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::set('dn',$ui->dn);
58     session::set('edit',TRUE);
59   }
61   /* save changes to LDAP and disable edit mode */
62   if (isset ($_POST['edit_finish'])) {
64     /* Perform checks */
65     $message = $netatalk->check();
67     /* No errors, save object */
68     if (count($message) == 0) {
69       $netatalk->save();
70       del_lock($ui->dn);
71       session::un_set('edit');
73       /* Remove object */
74       session::un_set('netatalk');
75     } else {
76       /* Errors found, show message */
77       msgDialog::displayChecks($message);
78     }
79   }
81   /* Execute formular */
82   $display = $netatalk->execute();
84   /* Store changes  in session */
85   if (session::is_set('edit')) {
86     session::set('netatalk',$netatalk);
87   }
89   $info = "";
90   /* Show page footer depending on the mode */
91   if ($netatalk->is_account) {
92     $display .= "<p class=\"plugbottom\">";
94     /* Are we in edit mode? */
95     if (session::is_set('edit')) {
96       $display .= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
97       $display .= "&nbsp;";
98       $display .= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
99       $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png')."\"> ".$ui->dn."&nbsp;";
100     } else {
101       $info = "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png')."\"> ".$ui->dn."&nbsp;";
102       if(preg_match("/w/",$ui->get_permissions($ui->dn,"users/netatalk"))){
103         $info .= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png')."\"> ".msgPool::clickEditToChange());
104         $display .= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
105       }
107       $display .= "<input type=\"hidden\" name=\"ignore\">\n";
108     }
109     $display .= "</p>\n";
110   }
112   /* Page header*/
113   $display = print_header(get_template_path('images/netatalk.png'), _("Netatalk settings"), $info).$display;
117 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
118 ?>