Code

Fixed self edit mode
[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   function pptpAccount ($config, $dn= NULL)
34   {
35     plugin::plugin ($config, $dn);
36   }
38   function execute()
39   {
40     /* Call parent execute */
41     //  plugin::execute();
43     /* Show tab dialog headers */
44     $display= "";
46     /* Show main page */
47     $smarty= get_smarty();
49     if ($this->is_account){
50       $smarty->assign("pptpState", "checked");
51     } else {
52       $smarty->assign("pptpState", "");
53       $smarty->assign("wstate", "disabled");
54     }
56     if(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) {
57       $smarty->assign('gosapptpACL', "");
58     }else{
59       $smarty->assign('gosapptpACL', " disabled ");
60     }
62     $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__)));
63     return ($display);
64   }
66   function remove_from_parent()
67   {
68     if($this->acl_is_removeable()){
69       /* Cancel if there's nothing to do here */
70       if (!$this->initially_was_account){
71         return;
72       }
74       plugin::remove_from_parent();
75       $ldap= $this->config->get_ldap_link();
77       $ldap->cd($this->dn);
78       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
79           $this->attributes, "Save");
80       $this->cleanup();
81       $ldap->modify ($this->attrs); 
83       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PPTP account with dn '%s' failed."),$this->dn));
85       /* Optionally execute a command after we're done */
86       $this->handle_post_events('remove');
87     }
88   }
91   /* Save data to object */
92   function save_object()
93   {
94     /* Do we need to flip is_account state? */
95     if (isset($_POST['connectivityTab'])){
96       if (isset($_POST['pptp'])){
97         if (!$this->is_account && $_POST['pptp'] == "B"){
98           if($this->acl_is_createable()){
99             $this->is_account= TRUE;
100           }
101         }
102       } else {
103         if($this->acl_is_removeable()){
104           $this->is_account= FALSE;
105         }
106       }
107     }
109     plugin::save_object();
110     if (isset($_POST["pptpStatus"])){
111       $this->pptpStatus = "disabled";
112     } else {
113       $this->pptpStatus = "enabled";
114     }
115   }
118   /* Save to LDAP */
119   function save()
120   {
121     if(chkacl($this->acl, 'gosapptp') == ""){
122       plugin::save();
124       /* Write back to ldap */
125       $ldap= $this->config->get_ldap_link();
126       $ldap->cd($this->dn);
127       $this->cleanup();
128       $ldap->modify ($this->attrs); 
130       show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PPTP account with dn '%s' failed."),$this->dn));
132       /* Optionally execute a command after we're done */
133       if ($this->initially_was_account == $this->is_account){
134         if ($this->is_modified){
135           $this->handle_post_events("mofify");
136         }
137       } else {
138         $this->handle_post_events("add");
139       }
140     }
141   }
144   /* Return plugin informations for acl handling */ 
145   function plInfo()
146   {
147     return (array(
148           "plShortName"     => _("PPTP"),
149           "plDescription"   => _("PPTP account"),
150           "plSelfModify"    => TRUE,
151           "plDepends"       => array("user"),
152           "plPriority"      => 1,                                 // Position in tabs
153           "plSection"       => "personal",                        // This belongs to personal
154           "plCategory"      => array("users"),
155           "plOptions"       => array(),
157           "plProvidedAcls"  => array()
158           ));
159   }
162 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
163 ?>