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;
34 var $view_logged = FALSE;
36 function phpscheduleitAccount (&$config, $dn= NULL)
37 {
38 plugin::plugin ($config, $dn);
39 }
41 function execute()
42 {
43 /* Log view */
44 if($this->is_account && !$this->view_logged){
45 $this->view_logged = TRUE;
46 new log("view","users/".get_class($this),$this->dn);
47 }
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 if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
63 $smarty->assign('gosaphpscheduleitACL', "");
64 }else{
65 $smarty->assign('gosaphpscheduleitACL', " disabled ");
66 }
68 $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__)));
69 return ($display);
70 }
72 function remove_from_parent()
73 {
74 /* Cancel if there's nothing to do here */
75 if ($this->acl_is_removeable()){
77 plugin::remove_from_parent();
78 $ldap= $this->config->get_ldap_link();
80 $ldap->cd($this->dn);
81 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
82 $this->attributes, "Save");
83 $this->cleanup();
84 $ldap->modify ($this->attrs);
85 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
87 if($this->is_account){
88 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
89 }
90 /* Optionally execute a command after we're done */
91 $this->handle_post_events('remove',array("uid" => $this->uid));
92 }
93 }
96 /* Save data to object */
97 function save_object()
98 {
99 /* Do we need to flip is_account state? */
100 if (isset($_POST['connectivityTab'])){
101 if (isset($_POST['phpscheduleit'])){
102 if (!$this->is_account && $_POST['phpscheduleit'] == "B"){
103 if($this->acl_is_createable()) {
104 $this->is_account= TRUE;
105 }
106 }
107 } else {
108 if($this->acl_is_removeable()){
109 $this->is_account= FALSE;
110 }
111 }
112 }
114 plugin::save_object();
115 if (isset($_POST["phpscheduleitStatus"])){
116 $this->pptpStatus = "disabled";
117 } else {
118 $this->pptpStatus = "enabled";
119 }
120 }
123 /* Save to LDAP */
124 function save()
125 {
126 plugin::save();
128 /* Write back to ldap */
129 $ldap= $this->config->get_ldap_link();
130 $ldap->cd($this->dn);
131 $this->cleanup();
132 $ldap->modify ($this->attrs);
134 if($this->initially_was_account){
135 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
136 }else{
137 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
138 }
140 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
142 /* Optionally execute a command after we're done */
143 if ($this->initially_was_account == $this->is_account){
144 if ($this->is_modified){
145 $this->handle_post_events("modify",array("uid" => $this->uid));
146 }
147 } else {
148 $this->handle_post_events("add",array("uid" => $this->uid));
149 }
151 }
154 /* Return plugin informations for acl handling
155 #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
156 function plInfo()
157 {
158 return (array(
159 "plShortName" => _("PHP Schedule it"),
160 "plDescription" => _("PHP Schedule it settings")." : <u>"._("Connectivity addon")."</u>",
161 "plSelfModify" => TRUE,
162 "plDepends" => array("user"),
163 "plPriority" => 29, // Position in tabs
164 "plSection" => array("personal" => _("My account")),
165 "plCategory" => array("users"),
167 "plOptions" => array(),
169 "plProvidedAcls" => array()
170 ));
171 }
172 }
174 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
175 ?>