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 $smarty->assign('gosapptpACL', chkacl($this->acl, 'gosapptp'));
58 $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__)));
59 return ($display);
60 }
62 function remove_from_parent()
63 {
64 if(chkacl($this->acl, 'gosapptp') == ""){
65 /* Cancel if there's nothing to do here */
66 if (!$this->initially_was_account){
67 return;
68 }
70 plugin::remove_from_parent();
71 $ldap= $this->config->get_ldap_link();
73 $ldap->cd($this->dn);
74 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
75 $this->attributes, "Save");
76 $this->cleanup();
77 $ldap->modify ($this->attrs);
79 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PPTP account with dn '%s' failed."),$this->dn));
81 /* Optionally execute a command after we're done */
82 $this->handle_post_events('remove');
83 }
84 }
87 /* Save data to object */
88 function save_object()
89 {
90 /* Do we need to flip is_account state? */
91 if (isset($_POST['connectivityTab'])){
92 if (isset($_POST['pptp'])){
93 if (!$this->is_account && $_POST['pptp'] == "B"){
94 $this->is_account= TRUE;
95 }
96 } else {
97 $this->is_account= FALSE;
98 }
99 }
101 plugin::save_object();
102 if (isset($_POST["pptpStatus"])){
103 $this->pptpStatus = "disabled";
104 } else {
105 $this->pptpStatus = "enabled";
106 }
107 }
110 /* Save to LDAP */
111 function save()
112 {
113 if(chkacl($this->acl, 'gosapptp') == ""){
114 plugin::save();
116 /* Write back to ldap */
117 $ldap= $this->config->get_ldap_link();
118 $ldap->cd($this->dn);
119 $this->cleanup();
120 $ldap->modify ($this->attrs);
122 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PPTP account with dn '%s' failed."),$this->dn));
124 /* Optionally execute a command after we're done */
125 if ($this->initially_was_account == $this->is_account){
126 if ($this->is_modified){
127 $this->handle_post_events("mofify");
128 }
129 } else {
130 $this->handle_post_events("add");
131 }
132 }
133 }
136 /* Return plugin informations for acl handling
137 #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
138 function plInfo()
139 {
140 return (array(
141 "plDescription" => _("PPTP account"),
142 "plSelfModify" => TRUE,
143 "plDepends" => array("objectClass" => "gosaAccount"),
144 "pptpServerAccount" => "!!! FIXME "._("PPTP account")));
145 }
148 }
150 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
151 ?>