Code

66dc9faa6b119dfdd30de6998aaff2e99d0f9be0
[gosa.git] / plugins / personal / connectivity / class_pureftpdAccount.inc
1 <?php
3 class pureftpdAccount extends plugin
4 {
5   /* Definitions */
6   var $plHeadline= "FTP";
7   var $plDescription= "This does something";
9   /* CLI vars */
10   var $cli_summary= "Manage users ftp 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   /* FTP attributes */
15   var $FTPQuotaFiles = 0;
16   var $FTPQuotaMBytes = 0;
17   var $FTPUploadRatio = 0;
18   var $FTPDownloadRatio = 0;
19   var $FTPUploadBandwidth = 0;
20   var $FTPDownloadBandwidth = 0;
21   var $FTPStatus = "enabled";
22   var $FTPuid = "";
23   var $FTPgid = "";
25   /* attribute list for save action */
26   var $attributes= array("FTPQuotaFiles","FTPQuotaMBytes","FTPUploadRatio","FTPDownloadRatio",
27       "FTPUploadBandwidth","FTPDownloadBandwidth","FTPStatus","FTPuid","FTPgid");
28   var $objectclasses= array("PureFTPdUser");
30   function pureftpdAccount ($config, $dn= NULL)
31   {
32     plugin::plugin ($config, $dn);
33   }
35   function execute()
36   {
37         /* Call parent execute */
38 //      plugin::execute();
40     /* Show tab dialog headers */
41     $display= "";
43     /* Show main page */
44     $smarty= get_smarty();
46     /* Load attributes */
47     foreach($this->attributes as $val){
48       $smarty->assign("$val", $this->$val);
49       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
50     }
51     if ($this->is_account){
52       $smarty->assign("pureftpdState", "checked");
53       $smarty->assign("fstate", "");
54     } else {
55       $smarty->assign("pureftpdState", "");
56       $smarty->assign("fstate", "disabled");
57     }
58     $smarty->assign("use_FTPStatus", ($this->FTPStatus == "disabled") ? "checked" : "");
60     # Hickert, Added Else. Smarty have to know the variable in both cases
61     if ($this->parent != NULL){
62       $smarty->assign("tabbed", 1);
63     }else {
64       $smarty->assign("tabbed", 0);
65     }
66     
67     $smarty->assign("pureftpdACL", chkacl($this->acl, 'pureftpd'));
69     $display.= $smarty->fetch (get_template_path('pureftpd.tpl', TRUE, dirname(__FILE__)));
70     return ($display);
71   }
73   function remove_from_parent()
74   {
75     /* Cancel if there's nothing to do here */
76     if (!$this->initially_was_account){
77       return;
78     }
80     plugin::remove_from_parent();
81     $ldap= $this->config->get_ldap_link();
83     $ldap->cd($this->dn);
84     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
85         $this->attributes, "Save");
86     $ldap->modify($this->attrs);
87     show_ldap_error($ldap->get_error());
89     /* Optionally execute a command after we're done */
90     $this->handle_post_events('remove');
91   }
94   /* Save data to object */
95   function save_object()
96   {
97     /* Do we need to flip is_account state? */
98     if (isset($_POST['connectivityTab'])){
99       if (isset($_POST['pureftpd'])){
100         if (!$this->is_account && $_POST['pureftpd'] == "B"){
101           $this->is_account= TRUE;
102         }
103       } else {
104         $this->is_account= FALSE;
105       }
106     }
108     plugin::save_object();
110     $old= $this->FTPStatus;
111     if (isset($_POST["FTPStatus"])){
112       $this->FTPStatus = "disabled";
113     } else {
114       $this->FTPStatus = "enabled";
115     }
116     $this->is_modified= ($old != $this->FTPStatus)?TRUE:$this->is_modified;
117   }
120   /* Check values */
121   function check()
122   {
123     $message= array();
125     /* Check for positive integer values */
126     if ($this->is_account){
127       if (!is_id($this->FTPUploadBandwidth)){
128         $message[]= _("Value specified as 'Upload bandwidth' is not valid.");
129       }
130       if (!is_id($this->FTPDownloadBandwidth)){
131         $message[]= _("Value specified as 'Download bandwidth' is not valid.");
132       }
133       if (!is_id($this->FTPQuotaFiles)){
134         $message[]= _("Value specified as 'Files' is not valid.");
135       }
136       if (!is_id($this->FTPQuotaMBytes)){
137         $message[]= _("Value specified as 'Size' is not valid.");
138       }
139       if (!is_id($this->FTPUploadRatio) || !is_id($this->FTPDownloadRatio)){
140         $message[]= _("Value specified as 'Ratio' is not valid.");
141       }
142     }
144     return $message;
145   }
148   /* Save to LDAP */
149   function save()
150   {
151     plugin::save();
153     /* Write back to ldap */
154     $ldap= $this->config->get_ldap_link();
155     $ldap->cd($this->dn);
156     $ldap->modify($this->attrs);
157     show_ldap_error($ldap->get_error());
159     /* Optionally execute a command after we're done */
160     if ($this->initially_was_account == $this->is_account){
161       if ($this->is_modified){
162         $this->handle_post_events("mofify");
163       }
164     } else {
165       $this->handle_post_events("add");
166     }
168   }
172 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
173 ?>