Code

3a23148bc1e90fe490c181551b300554cdded296
[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   /* 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   function pptpAccount ($config, $dn= NULL)
39   {
40     plugin::plugin ($config, $dn);
41   }
43   function execute()
44   {
45         /* Call parent execute */
46         plugin::execute();
48     /* Show tab dialog headers */
49     $display= "";
51     /* Show main page */
52     $smarty= get_smarty();
54     if ($this->is_account){
55       $smarty->assign("pptpState", "checked");
56     } else {
57       $smarty->assign("pptpState", "");
58       $smarty->assign("wstate", "disabled");
59     }
61     if ($this->parent != NULL){
62       $smarty->assign("tabbed", 1);
63     }
65     $smarty->assign('gosapptpACL', chkacl($this->acl, 'gosapptp'));
67     $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__)));
68     return ($display);
69   }
71   function remove_from_parent()
72   {
73     /* Cancel if there's nothing to do here */
74     if (!$this->initially_was_account){
75       return;
76     }
78     plugin::remove_from_parent();
79     $ldap= $this->config->get_ldap_link();
81     $ldap->cd($this->dn);
82     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
83         $this->attributes, "Save");
84     $ldap->modify($this->attrs);
85     show_ldap_error($ldap->get_error());
87     /* Optionally execute a command after we're done */
88     $this->handle_post_events('remove');
89   }
92   /* Save data to object */
93   function save_object()
94   {
95     /* Do we need to flip is_account state? */
96     if (isset($_POST['connectivityTab'])){
97       if (isset($_POST['pptp'])){
98         if (!$this->is_account && $_POST['pptp'] == "B"){
99           $this->is_account= TRUE;
100         }
101       } else {
102         $this->is_account= FALSE;
103       }
104     }
106     plugin::save_object();
107     if (isset($_POST["pptpStatus"])){
108       $this->pptpStatus = "disabled";
109     } else {
110       $this->pptpStatus = "enabled";
111     }
112   }
115   /* Save to LDAP */
116   function save()
117   {
118     plugin::save();
120     /* Write back to ldap */
121     $ldap= $this->config->get_ldap_link();
122     $ldap->cd($this->dn);
123     $ldap->modify($this->attrs);
124     show_ldap_error($ldap->get_error());
126     /* Optionally execute a command after we're done */
127     if ($this->initially_was_account == $this->is_account){
128       if ($this->is_modified){
129         $this->handle_post_events("mofify");
130       }
131     } else {
132       $this->handle_post_events("add");
133     }
135   }
139 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
140 ?>