Code

Created trunk inside of 2.6-lhm
[gosa.git] / trunk / gosa-plugins / connectivity / 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 /* Remove locks created by this plugin
22 */
23 $lock_msg="";
24 if ($remove_lock || isset($_POST['edit_cancel'])){
25   if(session::is_set('connectivity') && session::is_set('edit')){
26     del_lock($ui->dn);
27   }
28 }
30 /* Remove this plugin from session
31 */
32 if ( $cleanup ){
33   session::un_set('connectivity');
34   session::un_set('edit');
36 }else{
39   /* Reset requested? */
40   if (isset($_POST['edit_cancel'])){
41     session::un_set ('edit');
42     session::un_set ('connectivity');
43   }
45   /* Create connectivity object on demand */
46   if (!session::is_set('connectivity') || (isset($_GET['reset']) &&
47         $_GET['reset'] == 1)){
48     $connectivity= new connectivity ($config, $ui->dn);
49     $connectivity->enable_CSN_check();
50     $connectivity->set_acl_base($ui->dn);
51     $connectivity->set_acl_category("users");
53     /* Adjust acl's to mode */
54     foreach ($connectivity->plugin_name as $name){
55       $connectivity->plugin[$name]->set_acl_category( "users");
56       $connectivity->plugin[$name]->set_acl_base($ui->dn);
57     }
58     session::set('connectivity',$connectivity);
59   }
60   $connectivity = session::get('connectivity');
62   /* save changes back to object */
63   if (session::is_set('edit')){
64     $connectivity->save_object ();
65   }
67   /* Enter edit mode? */
68   if (isset($_POST['edit']) || isset($_POST['delete_lock'])){
70     /* Check locking */
71     if ((($username= get_lock($ui->dn)) != "") && (!session::is_set('edit'))){
72       session::set('back_plugin',$plug);
73       $display = gen_locked_message ($username, $ui->dn);
74     }else{
76       /* Lock the current entry */
77       add_lock ($ui->dn, $ui->dn);
78       session::set('edit',TRUE);
79     }
80   }
82   /* save changes to LDAP and disable edit mode */
83   if (isset($_POST['edit_finish'])){
85     /* Perform checks */
86     $message= $connectivity->check ();
88     /* No errors, save object */
89     if (count ($message) == 0){
90       $connectivity->save ();
91       del_lock ($ui->dn);
92       session::un_set ('edit');
94       /* Remove from session */
95       session::un_set ('connectivity');
96     } else {
97       /* Errors found, show message */
98       msg_dialog::displayChecks($message);
99     }
100   }
102   /* Execute formular */
103   $info= "";
104   $display= $connectivity->execute ();
106   /* Store changes  in session */
107   if (session::is_set('edit')){
108     session::set('connectivity',$connectivity);
109   }
112   $display.="<div align='right'>";
113   if (session::is_set('edit')){
114     $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
115     $display.= "&nbsp;";
116     $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
117     $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png').
118       "\"> ".$ui->dn."&nbsp;";
119   } else {
120     $info= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/unlocked.png').
121       "\"> ".$ui->dn."&nbsp;";
123     $info.= "<img class=\"center\" alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/on.png').
124       "\">".msgPool::clickEditToChange();
125     $display.= "<input type=submit name=\"edit\" value=\"".msgPool::editButton()."\">\n";
126     $display.= "<input type=\"hidden\" name=\"ignore\">\n";
127   }
128   $display.="</div>";
130   /* Page header*/
131   $display= print_header(get_template_path($connectivity->plIcon),
132       _("Connectivity"), $info).$display;
136 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
137 ?>