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 /* CLI vars */
30 var $cli_summary= "Manage users pptp account";
31 var $cli_description= "Some longer text\nfor help";
32 var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
34 /* attribute list for save action */
35 var $attributes= array();
36 var $objectclasses= array("pptpServerAccount");
38 var $uid ="";
40 function pptpAccount ($config, $dn= NULL, $parent= NULL)
41 {
42 plugin::plugin ($config, $dn, $parent);
44 /* Setting uid to default */
45 if(isset($this->attrs['uid'][0])){
46 $this->uid = $this->attrs['uid'][0];
47 }
49 }
51 function execute()
52 {
53 /* Call parent execute */
54 // plugin::execute();
56 /* Show tab dialog headers */
57 $display= "";
59 /* Show main page */
60 $smarty= get_smarty();
62 if ($this->is_account){
63 $smarty->assign("pptpState", "checked");
64 } else {
65 $smarty->assign("pptpState", "");
66 $smarty->assign("wstate", "disabled");
67 }
69 $smarty->assign('gosapptpACL', chkacl($this->acl, 'gosapptp'));
71 $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__)));
72 return ($display);
73 }
75 function remove_from_parent()
76 {
77 if(chkacl($this->acl, 'gosapptp') == ""){
78 /* Cancel if there's nothing to do here */
79 if (!$this->initially_was_account){
80 return;
81 }
83 plugin::remove_from_parent();
84 $ldap= $this->config->get_ldap_link();
86 $ldap->cd($this->dn);
87 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
88 $this->attributes, "Save");
89 $this->cleanup();
90 $ldap->modify ($this->attrs);
92 show_ldap_error($ldap->get_error(), _("Removing PPTP account failed"));
94 /* Optionally execute a command after we're done */
95 $this->handle_post_events('remove',array("uid" => $this->uid));
96 }
97 }
100 /* Save data to object */
101 function save_object()
102 {
103 /* Do we need to flip is_account state? */
104 if (isset($_POST['connectivityTab'])){
105 if (isset($_POST['pptp'])){
106 if (!$this->is_account && $_POST['pptp'] == "B"){
107 $this->is_account= TRUE;
108 }
109 } else {
110 $this->is_account= FALSE;
111 }
112 }
114 plugin::save_object();
115 if (isset($_POST["pptpStatus"])){
116 $this->pptpStatus = "disabled";
117 } else {
118 $this->pptpStatus = "enabled";
119 }
120 }
123 /* Save to LDAP */
124 function save()
125 {
126 if(chkacl($this->acl, 'gosapptp') == ""){
127 plugin::save();
129 /* Write back to ldap */
130 $ldap= $this->config->get_ldap_link();
131 $ldap->cd($this->dn);
132 $this->cleanup();
133 $ldap->modify ($this->attrs);
135 show_ldap_error($ldap->get_error(), _("Saving PPTP account failed"));
137 /* Optionally execute a command after we're done */
138 if ($this->initially_was_account == $this->is_account){
139 if ($this->is_modified){
140 $this->handle_post_events("modify",array("uid" => $this->uid));
141 }
142 } else {
143 $this->handle_post_events("add",array("uid" => $this->uid));
144 }
145 }
146 }
148 }
150 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
151 ?>