Code

[COSMETIC] Most of the imgs are now centered vertically in most browsers.
[gosa.git] / plugins / personal / connectivity / main.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  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 if (!$remove_lock){
22   /* Reset requested? */
23   if (isset($_POST['edit_cancel']) ||
24       (isset($_GET['reset']) && $_GET['reset'] == 1)){
26     del_lock ($ui->dn);
27     sess_del ('edit');
28     sess_del ('connectivity');
29   }
31   /* Create connectivity object on demand */
32   if (!isset($_SESSION['connectivity']) || (isset($_GET['reset']) &&
33       $_GET['reset'] == 1)){
34     $_SESSION['connectivity']= new connectivity ($config, $ui->dn);
35   }
36   $connectivity= $_SESSION['connectivity'];
38   /* save changes back to object */
39   if (isset ($_SESSION['edit'])){
40     $connectivity->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= $connectivity->check ();
65     /* No errors, save object */
66     if (count ($message) == 0){
67       $connectivity->save ();
68       gosa_log ("User/connectivity object'".$ui->dn."' has been saved");
69       $connectivity->acl= "#none#";
70       del_lock ($ui->dn);
71       sess_del ('edit');
73       /* Write back to session */
74       $_SESSION['connectivity']= $connectivity;
75     } else {
76       /* Errors found, show message */
77       show_errors ($message);
78     }
79   }
81   /* Adjust acl's to mode */
82   if (isset($_SESSION['edit'])){
83     $acl= get_permissions ($ui->dn, $ui->subtreeACL);
84     $connectivity->acl= get_module_permission($acl, "connectivity", $ui->dn);
85     foreach ($connectivity->plugin_name as $name){
86       $connectivity->plugin[$name]->acl= get_module_permission($acl, "$name", $ui->dn);
87     }
88   } else {
89     $acl= get_permissions ($ui->dn, $ui->subtreeACL);
90     $editacl= get_module_permission($acl, "connectivity", $ui->dn);
91     $connectivity->acl= "#none#";
92     foreach ($connectivity->plugin_name as $name){
93       $connectivity->plugin[$name]->acl= "#none#";
94     }
95   }
97   /* Execute formular */
98   $display= $connectivity->execute ();
100   /* Store changes  in session */
101   if (isset ($_SESSION['edit'])){
102     $_SESSION['connectivity']= $connectivity;
103   }
105   $info= "";
107   /* Are we in edit mode? */
108   $in_edit_mode= false;
109   foreach ($connectivity->plugin_name as $name){
110     $acls = get_module_permission($acl, "$name", $ui->dn);
111     if($acls != "#none#"){
112       $in_edit_mode|= true;
113     }
114   }
115   if ($in_edit_mode){
116     $display.="<div align='right'>";
117     if (isset($_SESSION['edit'])){
118       $display.= "<input type=submit name=\"edit_finish\" value=\""._("Finish")."\">\n";
119       $display.= "&nbsp;";
120       $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
121       $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/closedlock.png').
122              "\"> ".$ui->dn."&nbsp;";
123     } else {
124       $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
125              "\"> ".$ui->dn."&nbsp;";
126       if ($editacl != "#none#"){
127         $info.= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
128                 "\">"._("Click the 'Edit' button below to change informations in this dialog");
129         $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
130       }
131       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
132     }
133     $display.="</div>";
134   }
135   $display.= "</p>\n";
137   /* Page header*/
138   $display= print_header(get_template_path('images/proxy.png'),
139                          _("Connectivity"), $info).$display;
143 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
144 ?>