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 /* Call parent execute */
26 // plugin::execute();
28 /* Show tab dialog headers */
29 $display= "";
31 /* Show main page */
32 $smarty= get_smarty();
34 if ($this->is_account){
35 $smarty->assign("webdavState", "checked");
36 } else {
37 $smarty->assign("webdavState", "");
38 $smarty->assign("wstate", "disabled");
39 }
41 if ($this->parent != NULL){
42 $smarty->assign("tabbed", 1);
43 }
45 $smarty->assign('webdavAccountACL', chkacl($this->acl, 'webdavAccount'));
47 $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
48 return ($display);
49 }
51 function remove_from_parent()
52 {
53 if(chkacl($this->acl,"webdavAccount")==""){
54 /* Cancel if there's nothing to do here */
55 if (!$this->initially_was_account){
56 return;
57 }
59 plugin::remove_from_parent();
60 $ldap= $this->config->get_ldap_link();
62 $ldap->cd($this->dn);
63 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
64 $this->attributes, "Save");
65 $this->cleanup();
66 $ldap->modify ($this->attrs);
68 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/webDAV account with dn '%s' failed."),$this->dn));
70 /* Optionally execute a command after we're done */
71 $this->handle_post_events('remove');
72 }
73 }
76 /* Save data to object */
77 function save_object()
78 {
79 /* Do we need to flip is_account state? */
80 if (isset($_POST['connectivityTab'])){
81 if (isset($_POST['webdav'])){
82 if (!$this->is_account && $_POST['webdav'] == "B"){
83 $this->is_account= TRUE;
84 }
85 } else {
86 $this->is_account= FALSE;
87 }
88 }
90 plugin::save_object();
91 if (isset($_POST["WEBDAVStatus"])){
92 $this->WEBDAVStatus = "disabled";
93 } else {
94 $this->WEBDAVStatus = "enabled";
95 }
96 }
99 /* Save to LDAP */
100 function save()
101 {
102 if(chkacl($this->acl,"webdavAccount")==""){
103 plugin::save();
105 /* Write back to ldap */
106 $ldap= $this->config->get_ldap_link();
107 $ldap->cd($this->dn);
108 $this->cleanup();
109 $ldap->modify ($this->attrs);
111 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/webDAV account with dn '%s' failed."),$this->dn));
113 /* Optionally execute a command after we're done */
114 if ($this->initially_was_account == $this->is_account){
115 if ($this->is_modified){
116 $this->handle_post_events("mofify");
117 }
118 } else {
119 $this->handle_post_events("add");
120 }
121 }
122 }
124 }
126 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
127 ?>