Code

Fixed undefined index
[gosa.git] / plugins / personal / connectivity / class_pptpAccount.inc
1 <?php
3 /*
4    This code is part of GOsa (https://gosa.gonicus.de)
5    Copyright (C) 2005 Guillaume Delecourt
6    Copyright (C) 2005 Benoit Mortier
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class pptpAccount extends plugin
24 {
25   /* Definitions */
26   var $plHeadline= "PPTP";
27   var $plDescription= "This does something";
29   /* attribute list for save action */
30   var $attributes= array();
31   var $objectclasses= array("pptpServerAccount");
33   var $ReadOnly = false;
35   function pptpAccount ($config, $dn= NULL)
36   {
37     plugin::plugin ($config, $dn);
38   }
40   function execute()
41   {
42     /* Call parent execute */
43     //  plugin::execute();
45     /* Show tab dialog headers */
46     $display= "";
48     /* Show main page */
49     $smarty= get_smarty();
51     if ($this->is_account){
52       $smarty->assign("pptpState", "checked");
53     } else {
54       $smarty->assign("pptpState", "");
55       $smarty->assign("wstate", "disabled");
56     }
58     if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
59       $smarty->assign('gosapptpACL', "");
60     }else{
61       $smarty->assign('gosapptpACL', " disabled ");
62     }
64     $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__)));
65     return ($display);
66   }
68   function remove_from_parent()
69   {
70     if($this->acl_is_removeable()){
71       /* Cancel if there's nothing to do here */
72       if (!$this->initially_was_account){
73         return;
74       }
76       plugin::remove_from_parent();
77       $ldap= $this->config->get_ldap_link();
79       $ldap->cd($this->dn);
80       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
81           $this->attributes, "Save");
82       $this->cleanup();
83       $ldap->modify ($this->attrs); 
85       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PPTP account with dn '%s' failed."),$this->dn));
87       /* Optionally execute a command after we're done */
88       $this->handle_post_events('remove');
89     }
90   }
93   /* Save data to object */
94   function save_object()
95   {
96     /* Do we need to flip is_account state? */
97     if (isset($_POST['connectivityTab'])){
98       if (isset($_POST['pptp'])){
99         if (!$this->is_account && $_POST['pptp'] == "B"){
100           if($this->acl_is_createable()){
101             $this->is_account= TRUE;
102           }
103         }
104       } else {
105         if($this->acl_is_removeable()){
106           $this->is_account= FALSE;
107         }
108       }
109     }
111     plugin::save_object();
112     if (isset($_POST["pptpStatus"])){
113       $this->pptpStatus = "disabled";
114     } else {
115       $this->pptpStatus = "enabled";
116     }
117   }
120   /* Save to LDAP */
121   function save()
122   {
123     if(chkacl($this->acl, 'gosapptp') == ""){
124       plugin::save();
126       /* Write back to ldap */
127       $ldap= $this->config->get_ldap_link();
128       $ldap->cd($this->dn);
129       $this->cleanup();
130       $ldap->modify ($this->attrs); 
132       show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PPTP account with dn '%s' failed."),$this->dn));
134       /* Optionally execute a command after we're done */
135       if ($this->initially_was_account == $this->is_account){
136         if ($this->is_modified){
137           $this->handle_post_events("mofify");
138         }
139       } else {
140         $this->handle_post_events("add");
141       }
142     }
143   }
146   /* Return plugin informations for acl handling */ 
147   function plInfo()
148   {
149     return (array(
150           "plShortName"     => _("PPTP"),
151           "plDescription"   => _("PPTP account"),
152           "plSelfModify"    => TRUE,
153           "plDepends"       => array("user"),
154           "plPriority"      => 1,                                 // Position in tabs
155           "plSection"       => "personal",                        // This belongs to personal
156           "plCategory"      => array("users"),
157           "plOptions"       => array(),
159           "plProvidedAcls"  => array()
160           ));
161   }
164 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
165 ?>