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 }
27 function execute()
28 {
29 /* Call parent execute */
30 // plugin::execute();
32 /* Show tab dialog headers */
33 $display= "";
35 /* Show main page */
36 $smarty= get_smarty();
38 if ($this->is_account){
39 $smarty->assign("webdavState", "checked");
40 } else {
41 $smarty->assign("webdavState", "");
42 $smarty->assign("wstate", "disabled");
43 }
45 if ($this->parent != NULL){
46 $smarty->assign("tabbed", 1);
47 }
49 if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
50 $smarty->assign('webdavAccountACL', "");
51 }else{
52 $smarty->assign('webdavAccountACL', " disabled ");
53 }
55 $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
56 return ($display);
57 }
59 function remove_from_parent()
60 {
61 if($this->acl_is_createable() || $this->is_account){
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(), sprintf(_("Removing of user/webDAV account with dn '%s' failed."),$this->dn));
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 if($this->acl_is_createable()){
92 $this->is_account= TRUE;
93 }
94 }
95 } else {
96 if($this->acl_is_removeable()){
97 $this->is_account= FALSE;
98 }
99 }
100 }
102 plugin::save_object();
103 if (isset($_POST["WEBDAVStatus"])){
104 $this->WEBDAVStatus = "disabled";
105 } else {
106 $this->WEBDAVStatus = "enabled";
107 }
108 }
111 /* Save to LDAP */
112 function save()
113 {
114 if($this->acl_is_createable()){
115 plugin::save();
117 /* Write back to ldap */
118 $ldap= $this->config->get_ldap_link();
119 $ldap->cd($this->dn);
120 $this->cleanup();
121 $ldap->modify ($this->attrs);
123 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/webDAV account with dn '%s' failed."),$this->dn));
125 /* Optionally execute a command after we're done */
126 if ($this->initially_was_account == $this->is_account){
127 if ($this->is_modified){
128 $this->handle_post_events("modify",array("uid" => $this->uid));
129 }
130 } else {
131 $this->handle_post_events("add",array("uid" => $this->uid));
132 }
133 }
134 }
136 /* Return plugin informations for acl handling
137 #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
138 function plInfo()
139 {
140 return (array(
141 "plShortName" => _("WebDAV"),
142 "plDescription" => _("WebDAV account")." : <u>"._("Connectivity addon")."</u>",
143 "plSelfModify" => TRUE,
144 "plDepends" => array("user"),
145 "plPriority" => 23, // Position in tabs
146 "plSection" => "personal", // This belongs to personal
147 "plCategory" => array("users"),
148 "plOptions" => array(),
150 "plProvidedAcls" => array()
151 ));
152 }
153 }
155 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
156 ?>