Code

Fixed date of birth && userPicture
[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);
38   }
40   function execute()
41   {
42     /* Show tab dialog headers */
43     $display= "";
45     /* Show main page */
46     $smarty= get_smarty();
48     if ($this->is_account){
49       $smarty->assign("phpscheduleitState", "checked");
50     } else {
51       $smarty->assign("phpscheduleitState", "");
52       $smarty->assign("wstate", "disabled");
53     }
55     if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
56       $smarty->assign('gosaphpscheduleitACL', "");
57     }else{
58       $smarty->assign('gosaphpscheduleitACL', " disabled ");
59     }
61     $display.= $smarty->fetch (get_template_path('phpscheduleit.tpl', TRUE, dirname(__FILE__)));
62     return ($display);
63   }
65   function remove_from_parent()
66   {
67     /* Cancel if there's nothing to do here */
68     if ($this->acl_is_removeable()){
70       plugin::remove_from_parent();
71       $ldap= $this->config->get_ldap_link();
73       $ldap->cd($this->dn);
74       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
75           $this->attributes, "Save");
76       $this->cleanup();
77       $ldap->modify ($this->attrs); 
78       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
80       /* Optionally execute a command after we're done */
81       $this->handle_post_events('remove');
82     }
83   }
86   /* Save data to object */
87   function save_object()
88   {
89     /* Do we need to flip is_account state? */
90     if (isset($_POST['connectivityTab'])){
91       if (isset($_POST['phpscheduleit'])){
92         if (!$this->is_account && $_POST['phpscheduleit'] == "B"){
93           if($this->acl_is_createable()) {
94             $this->is_account= TRUE;
95           }
96         }
97       } else {
98         if($this->acl_is_removeable()){
99           $this->is_account= FALSE;
100         }
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(), sprintf(_("Saving of user/PHPscheduleit account with dn '%s' failed."),$this->dn));
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   }
138   /* Return plugin informations for acl handling 
139       #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
140   function plInfo()
141   {
142     return (array(
143           "plShortName"     => _("PHP Schedule it"),
144           "plDescription"   => _("PHP Schedule it settings"),
145           "plSelfModify"    => TRUE,
146           "plDepends"       => array("user"),
147           "plPriority"      => 6,                                 // Position in tabs
148           "plSection"       => "personal",                        // This belongs to personal
149           "plCategory"      => array("users"),
150           "plOptions"       => array(),
152           "plProvidedAcls"  => array()
153           ));
154   }
157 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
158 ?>