Code

Added \$this->cleanup before all calls of $ldap->modify
[gosa.git] / plugins / personal / connectivity / class_phpscheduleitAccount.inc
1 <?php
3 /*
4   This code is part of GOsa (https://gosa.gonicus.de)
5   Copyright (C) 2005 Guillaume Delecourt
6   Copuright (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 */
24 class phpscheduleitAccount extends plugin
25 {
26   /* Definitions */
27   var $plHeadline= "PHPscheduleit";
28   var $plDescription= "This does something";
30   /* CLI vars */
31   var $cli_summary= "Manage users phpscheduleit account";
32   var $cli_description= "Some longer text\nfor help";
33   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
35   /* attribute list for save action */
36   var $attributes= array();
37   var $objectclasses= array("phpscheduleitAccount");
39   function phpscheduleitAccount ($config, $dn= NULL)
40   {
41     plugin::plugin ($config, $dn);
42   }
44   function execute()
45   {
46         /* Call parent execute */
47 //      plugin::execute();
49     /* Show tab dialog headers */
50     $display= "";
52     /* Show main page */
53     $smarty= get_smarty();
55     if ($this->is_account){
56       $smarty->assign("phpscheduleitState", "checked");
57     } else {
58       $smarty->assign("phpscheduleitState", "");
59       $smarty->assign("wstate", "disabled");
60     }
62     $smarty->assign('gosaphpscheduleitACL', chkacl($this->acl, 'gosaphpscheduleit'));
64     $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__)));
65     return ($display);
66   }
68   function remove_from_parent()
69   {
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   }
91   /* Save data to object */
92   function save_object()
93   {
94     /* Do we need to flip is_account state? */
95     if (isset($_POST['connectivityTab'])){
96       if (isset($_POST['phpscheduleit'])){
97         if (!$this->is_account && $_POST['phpscheduleit'] == "B"){
98           $this->is_account= TRUE;
99         }
100       } else {
101         $this->is_account= FALSE;
102       }
103     }
105     plugin::save_object();
106     if (isset($_POST["phpscheduleitStatus"])){
107       $this->pptpStatus = "disabled";
108     } else {
109       $this->pptpStatus = "enabled";
110     }
111   }
114   /* Save to LDAP */
115   function save()
116   {
117     plugin::save();
119     /* Write back to ldap */
120     $ldap= $this->config->get_ldap_link();
121     $ldap->cd($this->dn);
122     $this->cleanup();
123 $ldap->modify ($this->attrs); 
125     show_ldap_error($ldap->get_error());
127     /* Optionally execute a command after we're done */
128     if ($this->initially_was_account == $this->is_account){
129       if ($this->is_modified){
130         $this->handle_post_events("mofify");
131       }
132     } else {
133       $this->handle_post_events("add");
134     }
136   }
140 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
141 ?>