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);
83 show_ldap_error($ldap->get_error(), _("Removing PHPscheduleit account failed"));
85 /* Optionally execute a command after we're done */
86 $this->handle_post_events('remove');
87 }
90 /* Save data to object */
91 function save_object()
92 {
93 /* Do we need to flip is_account state? */
94 if (isset($_POST['connectivityTab'])){
95 if (isset($_POST['phpscheduleit'])){
96 if (!$this->is_account && $_POST['phpscheduleit'] == "B"){
97 $this->is_account= TRUE;
98 }
99 } else {
100 $this->is_account= FALSE;
101 }
102 }
104 plugin::save_object();
105 if (isset($_POST["phpscheduleitStatus"])){
106 $this->pptpStatus = "disabled";
107 } else {
108 $this->pptpStatus = "enabled";
109 }
110 }
113 /* Save to LDAP */
114 function save()
115 {
116 plugin::save();
118 /* Write back to ldap */
119 $ldap= $this->config->get_ldap_link();
120 $ldap->cd($this->dn);
121 $this->cleanup();
122 $ldap->modify ($this->attrs);
124 show_ldap_error($ldap->get_error(), _("Saving PHPscheduleit account failed"));
126 /* Optionally execute a command after we're done */
127 if ($this->initially_was_account == $this->is_account){
128 if ($this->is_modified){
129 $this->handle_post_events("mofify");
130 }
131 } else {
132 $this->handle_post_events("add");
133 }
135 }
137 }
139 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
140 ?>