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 var $uid ="";
37 function pptpAccount ($config, $dn= NULL)
38 {
39 plugin::plugin ($config, $dn);
41 /* Setting uid to default */
42 if(isset($this->attrs['uid'][0])){
43 $this->uid = $this->attrs['uid'][0];
44 }
46 }
48 function execute()
49 {
50 /* Call parent execute */
51 // plugin::execute();
53 /* Show tab dialog headers */
54 $display= "";
56 /* Show main page */
57 $smarty= get_smarty();
59 if ($this->is_account){
60 $smarty->assign("pptpState", "checked");
61 } else {
62 $smarty->assign("pptpState", "");
63 $smarty->assign("wstate", "disabled");
64 }
66 if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
67 $smarty->assign('gosapptpACL', "");
68 }else{
69 $smarty->assign('gosapptpACL', " disabled ");
70 }
72 $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__)));
73 return ($display);
74 }
76 function remove_from_parent()
77 {
78 if($this->acl_is_removeable()){
79 /* Cancel if there's nothing to do here */
80 if (!$this->initially_was_account){
81 return;
82 }
84 plugin::remove_from_parent();
85 $ldap= $this->config->get_ldap_link();
87 $ldap->cd($this->dn);
88 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
89 $this->attributes, "Save");
90 $this->cleanup();
91 $ldap->modify ($this->attrs);
93 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PPTP account with dn '%s' failed."),$this->dn));
95 /* Optionally execute a command after we're done */
96 $this->handle_post_events('remove',array("uid" => $this->uid));
97 }
98 }
101 /* Save data to object */
102 function save_object()
103 {
104 /* Do we need to flip is_account state? */
105 if (isset($_POST['connectivityTab'])){
106 if (isset($_POST['pptp'])){
107 if (!$this->is_account && $_POST['pptp'] == "B"){
108 if($this->acl_is_createable()){
109 $this->is_account= TRUE;
110 }
111 }
112 } else {
113 if($this->acl_is_removeable()){
114 $this->is_account= FALSE;
115 }
116 }
117 }
119 plugin::save_object();
120 if (isset($_POST["pptpStatus"])){
121 $this->pptpStatus = "disabled";
122 } else {
123 $this->pptpStatus = "enabled";
124 }
125 }
128 /* Save to LDAP */
129 function save()
130 {
131 if($this->acl_is_createable()){
132 plugin::save();
134 /* Write back to ldap */
135 $ldap= $this->config->get_ldap_link();
136 $ldap->cd($this->dn);
137 $this->cleanup();
138 $ldap->modify ($this->attrs);
140 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PPTP account with dn '%s' failed."),$this->dn));
142 /* Optionally execute a command after we're done */
143 if ($this->initially_was_account == $this->is_account){
144 if ($this->is_modified){
145 $this->handle_post_events("modify",array("uid" => $this->uid));
146 }
147 } else {
148 $this->handle_post_events("add",array("uid" => $this->uid));
149 }
150 }
151 }
154 /* Return plugin informations for acl handling */
155 function plInfo()
156 {
157 return (array(
158 "plShortName" => _("PPTP"),
159 "plDescription" => _("PPTP account")." : <u>"._("Connectivity addon")."</u>",
160 "plSelfModify" => TRUE,
161 "plDepends" => array("user"),
162 "plPriority" => 28, // Position in tabs
163 "plSection" => "personal", // This belongs to personal
164 "plCategory" => array("users"),
165 "plOptions" => array(),
167 "plProvidedAcls" => array()
168 ));
169 }
170 }
172 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
173 ?>