Code

088f0103035bd5f9f0f6d4baba0040b2cebd4e72
[gosa.git] / plugins / personal / connectivity / class_webdavAccount.inc
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");
13   function webdavAccount ($config, $dn= NULL)
14   {
15     plugin::plugin ($config, $dn);
16   }
18   function execute()
19   {
20         /* Call parent execute */
21 //      plugin::execute();
23     /* Show tab dialog headers */
24     $display= "";
26     /* Show main page */
27     $smarty= get_smarty();
29     if ($this->is_account){
30       $smarty->assign("webdavState", "checked");
31     } else {
32       $smarty->assign("webdavState", "");
33       $smarty->assign("wstate", "disabled");
34     }
36     if ($this->parent != NULL){
37       $smarty->assign("tabbed", 1);
38     }
40     $smarty->assign('webdavAccountACL', chkacl($this->acl, 'webdavAccount'));
42     $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
43     return ($display);
44   }
46   function remove_from_parent()
47   {
48     if(chkacl($this->acl,"webdavAccount")==""){
49       /* Cancel if there's nothing to do here */
50       if (!$this->initially_was_account){
51         return;
52       }
54       plugin::remove_from_parent();
55       $ldap= $this->config->get_ldap_link();
57       $ldap->cd($this->dn);
58       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
59           $this->attributes, "Save");
60       $this->cleanup();
61       $ldap->modify ($this->attrs); 
63       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/webDAV account with dn '%s' failed."),$this->dn));
65       /* Optionally execute a command after we're done */
66       $this->handle_post_events('remove');
67     }
68   }
71   /* Save data to object */
72   function save_object()
73   {
74     /* Do we need to flip is_account state? */
75     if (isset($_POST['connectivityTab'])){
76       if (isset($_POST['webdav'])){
77         if (!$this->is_account && $_POST['webdav'] == "B"){
78           $this->is_account= TRUE;
79         }
80       } else {
81         $this->is_account= FALSE;
82       }
83     }
85     plugin::save_object();
86     if (isset($_POST["WEBDAVStatus"])){
87       $this->WEBDAVStatus = "disabled";
88     } else {
89       $this->WEBDAVStatus = "enabled";
90     }
91   }
94   /* Save to LDAP */
95   function save()
96   {
97     if(chkacl($this->acl,"webdavAccount")==""){
98       plugin::save();
100       /* Write back to ldap */
101       $ldap= $this->config->get_ldap_link();
102       $ldap->cd($this->dn);
103       $this->cleanup();
104       $ldap->modify ($this->attrs); 
106       show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/webDAV account with dn '%s' failed."),$this->dn));
108       /* Optionally execute a command after we're done */
109       if ($this->initially_was_account == $this->is_account){
110         if ($this->is_modified){
111           $this->handle_post_events("mofify");
112         }
113       } else {
114         $this->handle_post_events("add");
115       }
116     }
117   }
119   /* Return plugin informations for acl handling
120       #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
121   function plInfo()
122   {
123     return (array(  
124           "plDescription"     => _("Intranet account settings"),
125           "plSelfModify"      => TRUE,
126           "plDepends"         => array("objectClass" => "gosaAccount"),
127           "gosaWebdavAccount" => "!!! FIXME "._("WebDAV account")));
128   }
131 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
132 ?>