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 function webdavAccount ($config, $dn= NULL)
15 {
16 plugin::plugin ($config, $dn);
17 }
19 function execute()
20 {
21 /* Call parent execute */
22 // plugin::execute();
24 /* Show tab dialog headers */
25 $display= "";
27 /* Show main page */
28 $smarty= get_smarty();
30 if ($this->is_account){
31 $smarty->assign("webdavState", "checked");
32 } else {
33 $smarty->assign("webdavState", "");
34 $smarty->assign("wstate", "disabled");
35 }
37 if ($this->parent != NULL){
38 $smarty->assign("tabbed", 1);
39 }
41 if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
42 $smarty->assign('webdavAccountACL', "");
43 }else{
44 $smarty->assign('webdavAccountACL', " disabled ");
45 }
47 $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
48 return ($display);
49 }
51 function remove_from_parent()
52 {
53 if($this->acl_is_createable() || $this->is_account){
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 if($this->acl_is_createable()){
84 $this->is_account= TRUE;
85 }
86 }
87 } else {
88 if($this->acl_is_removeable()){
89 $this->is_account= FALSE;
90 }
91 }
92 }
94 plugin::save_object();
95 if (isset($_POST["WEBDAVStatus"])){
96 $this->WEBDAVStatus = "disabled";
97 } else {
98 $this->WEBDAVStatus = "enabled";
99 }
100 }
103 /* Save to LDAP */
104 function save()
105 {
106 if($this->acl_is_createable()){
107 plugin::save();
109 /* Write back to ldap */
110 $ldap= $this->config->get_ldap_link();
111 $ldap->cd($this->dn);
112 $this->cleanup();
113 $ldap->modify ($this->attrs);
115 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/webDAV account with dn '%s' failed."),$this->dn));
117 /* Optionally execute a command after we're done */
118 if ($this->initially_was_account == $this->is_account){
119 if ($this->is_modified){
120 $this->handle_post_events("mofify");
121 }
122 } else {
123 $this->handle_post_events("add");
124 }
125 }
126 }
128 /* Return plugin informations for acl handling
129 #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
130 function plInfo()
131 {
132 return (array(
133 "plShortName" => _("WebDAV"),
134 "plDescription" => _("WebDAV account"),
135 "plSelfModify" => TRUE,
136 "plDepends" => array("user"),
137 "plPriority" => 9, // Position in tabs
138 "plSection" => "personal", // This belongs to personal
139 "plCategory" => array("users"),
140 "plOptions" => array(),
142 "plProvidedAcls" => array()
143 ));
144 }
145 }
147 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
148 ?>