Code

Added logging to ogroup
[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");
33   var $ReadOnly =false;
35   function phpscheduleitAccount ($config, $dn= NULL)
36   {
37     plugin::plugin ($config, $dn);
39     if($this->is_account){
40       @log::log("view","users/".get_class($this),$this->dn);
41     }
42   }
44   function execute()
45   {
46     /* Show tab dialog headers */
47     $display= "";
49     /* Show main page */
50     $smarty= get_smarty();
52     if ($this->is_account){
53       $smarty->assign("phpscheduleitState", "checked");
54     } else {
55       $smarty->assign("phpscheduleitState", "");
56       $smarty->assign("wstate", "disabled");
57     }
59     if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
60       $smarty->assign('gosaphpscheduleitACL', "");
61     }else{
62       $smarty->assign('gosaphpscheduleitACL', " disabled ");
63     }
65     $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__)));
66     return ($display);
67   }
69   function remove_from_parent()
70   {
71     /* Cancel if there's nothing to do here */
72     if ($this->acl_is_removeable()){
74       plugin::remove_from_parent();
75       $ldap= $this->config->get_ldap_link();
77       $ldap->cd($this->dn);
78       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
79           $this->attributes, "Save");
80       $this->cleanup();
81       $ldap->modify ($this->attrs); 
82       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
84       if($this->is_account){
85         @log::log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
86       }
87       /* Optionally execute a command after we're done */
88       $this->handle_post_events('remove',array("uid" => $this->uid));
89     }
90   }
93   /* Save data to object */
94   function save_object()
95   {
96     /* Do we need to flip is_account state? */
97     if (isset($_POST['connectivityTab'])){
98       if (isset($_POST['phpscheduleit'])){
99         if (!$this->is_account && $_POST['phpscheduleit'] == "B"){
100           if($this->acl_is_createable()) {
101             $this->is_account= TRUE;
102           }
103         }
104       } else {
105         if($this->acl_is_removeable()){
106           $this->is_account= FALSE;
107         }
108       }
109     }
111     plugin::save_object();
112     if (isset($_POST["phpscheduleitStatus"])){
113       $this->pptpStatus = "disabled";
114     } else {
115       $this->pptpStatus = "enabled";
116     }
117   }
120   /* Save to LDAP */
121   function save()
122   {
123     plugin::save();
125     /* Write back to ldap */
126     $ldap= $this->config->get_ldap_link();
127     $ldap->cd($this->dn);
128     $this->cleanup();
129     $ldap->modify ($this->attrs); 
131     if($this->initially_was_account){
132       @log::log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
133     }else{
134       @log::log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
135     }
137     show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
139     /* Optionally execute a command after we're done */
140     if ($this->initially_was_account == $this->is_account){
141       if ($this->is_modified){
142         $this->handle_post_events("modify",array("uid" => $this->uid));
143       }
144     } else {
145       $this->handle_post_events("add",array("uid" => $this->uid));
146     }
148   }
151   /* Return plugin informations for acl handling 
152       #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
153   function plInfo()
154   {
155     return (array(
156           "plShortName"     => _("PHP Schedule it"),
157           "plDescription"   => _("PHP Schedule it settings")."&nbsp;:&nbsp;<u>"._("Connectivity addon")."</u>",
158           "plSelfModify"    => TRUE,
159           "plDepends"       => array("user"),
160           "plPriority"      => 29,                                 // Position in tabs
161           "plSection"     => array("personal" => _("My account")),
162           "plCategory"    => array("users"),
164           "plOptions"       => array(),
166           "plProvidedAcls"  => array()
167           ));
168   }
171 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
172 ?>