1 <?php
3 class webdavAccount extends plugin
4 {
5 /* Definitions */
6 var $plHeadline= "WebDAV";
7 var $plDescription= "This does something";
9 /* attribute list for save action */
10 var $attributes= array();
11 var $objectclasses= array("gosaWebdavAccount");
12 var $ReadOnly = false;
14 var $uid ="";
16 function webdavAccount ($config, $dn= NULL)
17 {
18 plugin::plugin ($config, $dn);
20 /* Setting uid to default */
21 if(isset($this->attrs['uid'][0])){
22 $this->uid = $this->attrs['uid'][0];
23 }
25 /* Log view */
26 if($this->is_account){
27 @log::log("view","users/".get_class($this),$this->dn);
28 }
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 if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
54 $smarty->assign('webdavAccountACL', "");
55 }else{
56 $smarty->assign('webdavAccountACL', " disabled ");
57 }
59 $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
60 return ($display);
61 }
63 function remove_from_parent()
64 {
65 if($this->acl_is_createable() || $this->is_account){
66 /* Cancel if there's nothing to do here */
67 if (!$this->initially_was_account){
68 return;
69 }
71 plugin::remove_from_parent();
72 $ldap= $this->config->get_ldap_link();
74 $ldap->cd($this->dn);
75 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
76 $this->attributes, "Save");
77 $this->cleanup();
78 $ldap->modify ($this->attrs);
80 /* Log last action */
81 @log::log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
83 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/webDAV account with dn '%s' failed."),$this->dn));
85 /* Optionally execute a command after we're done */
86 $this->handle_post_events('remove',array("uid" => $this->uid));
87 }
88 }
91 /* Save data to object */
92 function save_object()
93 {
94 /* Do we need to flip is_account state? */
95 if (isset($_POST['connectivityTab'])){
96 if (isset($_POST['webdav'])){
97 if (!$this->is_account && $_POST['webdav'] == "B"){
98 if($this->acl_is_createable()){
99 $this->is_account= TRUE;
100 }
101 }
102 } else {
103 if($this->acl_is_removeable()){
104 $this->is_account= FALSE;
105 }
106 }
107 }
109 plugin::save_object();
110 if (isset($_POST["WEBDAVStatus"])){
111 $this->WEBDAVStatus = "disabled";
112 } else {
113 $this->WEBDAVStatus = "enabled";
114 }
115 }
118 /* Save to LDAP */
119 function save()
120 {
121 if($this->acl_is_createable()){
122 plugin::save();
124 /* Write back to ldap */
125 $ldap= $this->config->get_ldap_link();
126 $ldap->cd($this->dn);
127 $this->cleanup();
128 $ldap->modify ($this->attrs);
130 /* Log last action */
131 if($this->initially_was_account){
132 @log::log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
133 }else{
134 @log::log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
135 }
137 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/webDAV account with dn '%s' failed."),$this->dn));
139 /* Optionally execute a command after we're done */
140 if ($this->initially_was_account == $this->is_account){
141 if ($this->is_modified){
142 $this->handle_post_events("modify",array("uid" => $this->uid));
143 }
144 } else {
145 $this->handle_post_events("add",array("uid" => $this->uid));
146 }
147 }
148 }
150 /* Return plugin informations for acl handling
151 #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
152 function plInfo()
153 {
154 return (array(
155 "plShortName" => _("WebDAV"),
156 "plDescription" => _("WebDAV account")." : <u>"._("Connectivity addon")."</u>",
157 "plSelfModify" => TRUE,
158 "plDepends" => array("user"),
159 "plPriority" => 23, // Position in tabs
160 "plSection" => array("personal" => _("My account")),
161 "plCategory" => array("users"),
162 "plOptions" => array(),
164 "plProvidedAcls" => array()
165 ));
166 }
167 }
169 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
170 ?>