1 <?php
3 class webdavAccount extends plugin
4 {
5 /* Definitions */
6 var $plHeadline= "WebDAV";
7 var $plDescription= "This does something";
9 /* CLI vars */
10 var $cli_summary= "Manage users webdav account";
11 var $cli_description= "Some longer text\nfor help";
12 var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
14 /* attribute list for save action */
15 var $attributes= array();
16 var $objectclasses= array("gosaWebdavAccount");
18 function webdavAccount ($config, $dn= NULL)
19 {
20 plugin::plugin ($config, $dn);
21 }
23 function execute()
24 {
25 /* Show tab dialog headers */
26 $display= "";
28 /* Show main page */
29 $smarty= get_smarty();
31 if ($this->is_account){
32 $smarty->assign("webdavState", "checked");
33 } else {
34 $smarty->assign("webdavState", "");
35 $smarty->assign("wstate", "disabled");
36 }
38 if ($this->parent != NULL){
39 $smarty->assign("tabbed", 1);
40 }
42 $smarty->assign('gosaWebdavACL', chkacl($this->acl, 'gosaWebdav'));
44 $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
45 return ($display);
46 }
48 function remove_from_parent()
49 {
50 /* Cancel if there's nothing to do here */
51 if (!$this->initially_was_account){
52 return;
53 }
55 plugin::remove_from_parent();
56 $ldap= $this->config->get_ldap_link();
58 $ldap->cd($this->dn);
59 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
60 $this->attributes, "Save");
61 $ldap->modify($this->attrs);
62 show_ldap_error($ldap->get_error());
64 /* Optionally execute a command after we're done */
65 $this->handle_post_events('remove');
66 }
69 /* Save data to object */
70 function save_object()
71 {
72 /* Do we need to flip is_account state? */
73 if (isset($_POST['connectivityTab'])){
74 if (isset($_POST['webdav'])){
75 if (!$this->is_account && $_POST['webdav'] == "B"){
76 $this->is_account= TRUE;
77 }
78 } else {
79 $this->is_account= FALSE;
80 }
81 }
83 plugin::save_object();
84 if (isset($_POST["WEBDAVStatus"])){
85 $this->WEBDAVStatus = "disabled";
86 } else {
87 $this->WEBDAVStatus = "enabled";
88 }
89 }
92 /* Save to LDAP */
93 function save()
94 {
95 plugin::save();
97 /* Write back to ldap */
98 $ldap= $this->config->get_ldap_link();
99 $ldap->cd($this->dn);
100 $ldap->modify($this->attrs);
101 show_ldap_error($ldap->get_error());
103 /* Optionally execute a command after we're done */
104 if ($this->initially_was_account == $this->is_account){
105 if ($this->is_modified){
106 $this->handle_post_events("mofify");
107 }
108 } else {
109 $this->handle_post_events("add");
110 }
112 }
114 }
116 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
117 ?>