Code

Fixed self edit mode
[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   /* attribute list for save action */
31   var $attributes= array();
32   var $objectclasses= array("phpscheduleitAccount");
34   function phpscheduleitAccount ($config, $dn= NULL)
35   {
36     plugin::plugin ($config, $dn);
37   }
39   function execute()
40   {
41     /* Show tab dialog headers */
42     $display= "";
44     /* Show main page */
45     $smarty= get_smarty();
47     if ($this->is_account){
48       $smarty->assign("phpscheduleitState", "checked");
49     } else {
50       $smarty->assign("phpscheduleitState", "");
51       $smarty->assign("wstate", "disabled");
52     }
54     if(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) {
55       $smarty->assign('gosaphpscheduleitACL', "");
56     }else{
57       $smarty->assign('gosaphpscheduleitACL', " disabled ");
58     }
60     $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__)));
61     return ($display);
62   }
64   function remove_from_parent()
65   {
66     /* Cancel if there's nothing to do here */
67     if ($this->acl_is_removeable()){
69       plugin::remove_from_parent();
70       $ldap= $this->config->get_ldap_link();
72       $ldap->cd($this->dn);
73       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
74           $this->attributes, "Save");
75       $this->cleanup();
76       $ldap->modify ($this->attrs); 
77       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
79       /* Optionally execute a command after we're done */
80       $this->handle_post_events('remove');
81     }
82   }
85   /* Save data to object */
86   function save_object()
87   {
88     /* Do we need to flip is_account state? */
89     if (isset($_POST['connectivityTab'])){
90       if (isset($_POST['phpscheduleit'])){
91         if (!$this->is_account && $_POST['phpscheduleit'] == "B"){
92           if($this->acl_is_createable()) {
93             $this->is_account= TRUE;
94           }
95         }
96       } else {
97         if($this->acl_is_removeable()){
98           $this->is_account= FALSE;
99         }
100       }
101     }
103     plugin::save_object();
104     if (isset($_POST["phpscheduleitStatus"])){
105       $this->pptpStatus = "disabled";
106     } else {
107       $this->pptpStatus = "enabled";
108     }
109   }
112   /* Save to LDAP */
113   function save()
114   {
115     plugin::save();
117     /* Write back to ldap */
118     $ldap= $this->config->get_ldap_link();
119     $ldap->cd($this->dn);
120     $this->cleanup();
121     $ldap->modify ($this->attrs); 
123     show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
125     /* Optionally execute a command after we're done */
126     if ($this->initially_was_account == $this->is_account){
127       if ($this->is_modified){
128         $this->handle_post_events("mofify");
129       }
130     } else {
131       $this->handle_post_events("add");
132     }
134   }
137   /* Return plugin informations for acl handling 
138       #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
139   function plInfo()
140   {
141     return (array(
142           "plShortName"     => _("PHP Schedule it"),
143           "plDescription"   => _("PHP Schedule it settings"),
144           "plSelfModify"    => TRUE,
145           "plDepends"       => array("user"),
146           "plPriority"      => 6,                                 // Position in tabs
147           "plSection"       => "personal",                        // This belongs to personal
148           "plCategory"      => array("users"),
149           "plOptions"       => array(),
151           "plProvidedAcls"  => array()
152           ));
153   }
156 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
157 ?>