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 var $uid ="";
20 function webdavAccount ($config, $dn= NULL, $parent= NULL)
21 {
22 plugin::plugin ($config, $dn, $parent);
24 /* Setting uid to default */
25 if(isset($this->attrs['uid'][0])){
26 $this->uid = $this->attrs['uid'][0];
27 }
29 }
31 function execute()
32 {
33 /* Call parent execute */
34 // plugin::execute();
36 /* Show tab dialog headers */
37 $display= "";
39 /* Show main page */
40 $smarty= get_smarty();
42 if ($this->is_account){
43 $smarty->assign("webdavState", "checked");
44 } else {
45 $smarty->assign("webdavState", "");
46 $smarty->assign("wstate", "disabled");
47 }
49 if ($this->parent != NULL){
50 $smarty->assign("tabbed", 1);
51 }
53 $smarty->assign('webdavAccountACL', chkacl($this->acl, 'webdavAccount'));
55 $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
56 return ($display);
57 }
59 function remove_from_parent()
60 {
61 if(chkacl($this->acl,"webdavAccount")==""){
62 /* Cancel if there's nothing to do here */
63 if (!$this->initially_was_account){
64 return;
65 }
67 plugin::remove_from_parent();
68 $ldap= $this->config->get_ldap_link();
70 $ldap->cd($this->dn);
71 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
72 $this->attributes, "Save");
73 $this->cleanup();
74 $ldap->modify ($this->attrs);
76 show_ldap_error($ldap->get_error(), _("Removing webDAV account failed"));
78 /* Optionally execute a command after we're done */
79 $this->handle_post_events('remove',array("uid" => $this->uid));
80 }
81 }
84 /* Save data to object */
85 function save_object()
86 {
87 /* Do we need to flip is_account state? */
88 if (isset($_POST['connectivityTab'])){
89 if (isset($_POST['webdav'])){
90 if (!$this->is_account && $_POST['webdav'] == "B"){
91 $this->is_account= TRUE;
92 }
93 } else {
94 $this->is_account= FALSE;
95 }
96 }
98 plugin::save_object();
99 if (isset($_POST["WEBDAVStatus"])){
100 $this->WEBDAVStatus = "disabled";
101 } else {
102 $this->WEBDAVStatus = "enabled";
103 }
104 }
107 /* Save to LDAP */
108 function save()
109 {
110 if(chkacl($this->acl,"webdavAccount")==""){
111 plugin::save();
113 /* Write back to ldap */
114 $ldap= $this->config->get_ldap_link();
115 $ldap->cd($this->dn);
116 $this->cleanup();
117 $ldap->modify ($this->attrs);
119 show_ldap_error($ldap->get_error(), _("Saving webDAV account failed"));
121 /* Optionally execute a command after we're done */
122 if ($this->initially_was_account == $this->is_account){
123 if ($this->is_modified){
124 $this->handle_post_events("modify",array("uid" => $this->uid));
125 }
126 } else {
127 $this->handle_post_events("add",array("uid" => $this->uid));
128 }
129 }
130 }
132 }
134 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
135 ?>