Code

Set DNS hidden if acount is disabled
[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     $smarty->assign('gosapptpACL', chkacl($this->acl, 'gosapptp'));
63     $display.= $smarty->fetch (get_template_path('pptp.tpl', TRUE, dirname(__FILE__)));
64     return ($display);
65   }
67   function remove_from_parent()
68   {
69     if(chkacl($this->acl, 'gosapptp') == ""){
70       /* Cancel if there's nothing to do here */
71       if (!$this->initially_was_account){
72         return;
73       }
75       plugin::remove_from_parent();
76       $ldap= $this->config->get_ldap_link();
78       $ldap->cd($this->dn);
79       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
80           $this->attributes, "Save");
81       $this->cleanup();
82 $ldap->modify ($this->attrs); 
84       show_ldap_error($ldap->get_error());
86       /* Optionally execute a command after we're done */
87       $this->handle_post_events('remove');
88     }
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     if(chkacl($this->acl, 'gosapptp') == ""){
119       plugin::save();
121       /* Write back to ldap */
122       $ldap= $this->config->get_ldap_link();
123       $ldap->cd($this->dn);
124       $this->cleanup();
125 $ldap->modify ($this->attrs); 
127       show_ldap_error($ldap->get_error());
129       /* Optionally execute a command after we're done */
130       if ($this->initially_was_account == $this->is_account){
131         if ($this->is_modified){
132           $this->handle_post_events("mofify");
133         }
134       } else {
135         $this->handle_post_events("add");
136       }
137     }
138   }
142 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
143 ?>