521dbf71c5fee28a0af2a1a201178b9817559c11
[gosa.git] / gosa-plugins / phpscheduleit / personal / connectivity / phpscheduleit / 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;
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 if (!$ldap->success()){
86 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
87 }
89 if($this->is_account){
90 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
91 }
92 /* Optionally execute a command after we're done */
93 $this->handle_post_events('remove',array("uid" => $this->uid));
94 }
95 }
98 /* Save data to object */
99 function save_object()
100 {
101 /* Do we need to flip is_account state? */
102 if (isset($_POST['connectivityTab'])){
103 if (isset($_POST['phpscheduleit'])){
104 if (!$this->is_account && $_POST['phpscheduleit'] == "B"){
105 if($this->acl_is_createable()) {
106 $this->is_account= TRUE;
107 }
108 }
109 } else {
110 if($this->acl_is_removeable()){
111 $this->is_account= FALSE;
112 }
113 }
114 }
116 plugin::save_object();
117 if (isset($_POST["phpscheduleitStatus"])){
118 $this->pptpStatus = "disabled";
119 } else {
120 $this->pptpStatus = "enabled";
121 }
122 }
125 /* Save to LDAP */
126 function save()
127 {
128 plugin::save();
130 /* Write back to ldap */
131 $ldap= $this->config->get_ldap_link();
132 $ldap->cd($this->dn);
133 $this->cleanup();
134 $ldap->modify ($this->attrs);
136 if($this->initially_was_account){
137 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
138 }else{
139 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
140 }
142 if (!$ldap->success()){
143 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
144 }
146 /* Optionally execute a command after we're done */
147 if ($this->initially_was_account == $this->is_account){
148 if ($this->is_modified){
149 $this->handle_post_events("modify",array("uid" => $this->uid));
150 }
151 } else {
152 $this->handle_post_events("add",array("uid" => $this->uid));
153 }
155 }
158 /* Return plugin informations for acl handling
159 #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
160 static function plInfo()
161 {
162 return (array(
163 "plShortName" => _("PHP Schedule it"),
164 "plDescription" => _("PHP Schedule it settings")." : <u>"._("Connectivity addon")."</u>",
165 "plSelfModify" => TRUE,
166 "plDepends" => array("user"),
167 "plPriority" => 29, // Position in tabs
168 "plSection" => array("personal" => _("My account")),
169 "plCategory" => array("users"),
171 "plOptions" => array(),
173 "plProvidedAcls" => array()
174 ));
175 }
176 }
178 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
179 ?>