Code

1618c5c702d48317cbc1268293305a2c84726bf6
[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   /* 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   function webdavAccount ($config, $dn= NULL)
19   {
20     plugin::plugin ($config, $dn);
21   }
23   function execute()
24   {
25     /* Show tab dialog headers */
26     $display= "";
28     /* Show main page */
29     $smarty= get_smarty();
31     if ($this->is_account){
32       $smarty->assign("webdavState", "checked");
33     } else {
34       $smarty->assign("wstate", "disabled");
35     }
37     if ($this->parent != NULL){
38       $smarty->assign("tabbed", 1);
39     }
41     $display.= $smarty->fetch (get_template_path('webdav.tpl', TRUE, dirname(__FILE__)));
42     return ($display);
43   }
45   function remove_from_parent()
46   {
47     /* Cancel if there's nothing to do here */
48     if (!$this->initially_was_account){
49       return;
50     }
52     plugin::remove_from_parent();
53     $ldap= $this->config->get_ldap_link();
55     $ldap->cd($this->dn);
56     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
57         $this->attributes, "Save");
58     $ldap->modify($this->attrs);
59     show_ldap_error($ldap->get_error());
61     /* Optionally execute a command after we're done */
62     $this->handle_post_events('remove');
63   }
66   /* Save data to object */
67   function save_object()
68   {
69     /* Do we need to flip is_account state? */
70     if (isset($_POST['connectivityTab'])){
71       if (isset($_POST['webdav'])){
72         if (!$this->is_account && $_POST['webdav'] == "B"){
73           $this->is_account= TRUE;
74         }
75       } else {
76         $this->is_account= FALSE;
77       }
78     }
80     plugin::save_object();
81     if (isset($_POST["WEBDAVStatus"])){
82       $this->WEBDAVStatus = "disabled";
83     } else {
84       $this->WEBDAVStatus = "enabled";
85     }
86   }
89   /* Save to LDAP */
90   function save()
91   {
92     plugin::save();
94     /* Write back to ldap */
95     $ldap= $this->config->get_ldap_link();
96     $ldap->cd($this->dn);
97     $ldap->modify($this->attrs);
98     show_ldap_error($ldap->get_error());
100     /* Optionally execute a command after we're done */
101     if ($this->initially_was_account == $this->is_account){
102       if ($this->is_modified){
103         $this->handle_post_events("mofify");
104       }
105     } else {
106       $this->handle_post_events("add");
107     }
109   }
113 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
114 ?>