3 * quota_managementPlugin Class
5 * Copyright 2005, Fabio Bertagnin
6 * Copyright 2011, Franck Villaume - Capgemini
7 * http://fusionforge.org
9 * This file is part of FusionForge.
11 * FusionForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 class quota_managementPlugin extends Plugin {
27 function quota_managementPlugin () {
29 $this->name = "quota_management";
30 $this->text = _("Quota Management"); // To show in the tabs, use...
32 _("This is a quota_management plugin within FusionForge.");
33 $this->_addHook('groupisactivecheckbox'); // The "use ..." checkbox in editgroupinfo
34 $this->_addHook('groupisactivecheckboxpost'); //
35 $this->_addHook('userisactivecheckbox'); // The "use ..." checkbox in user account
36 $this->_addHook('userisactivecheckboxpost'); //
37 $this->_addHook('project_admin_plugins'); // to show up in the admin page fro group
38 $this->_addHook('site_admin_option_hook'); // to show in admin
39 $this->_addHook('groupadminmenu');
42 function CallHook($hookname, &$params) {
43 global $use_quota_managementplugin, $G_SESSION, $HTML;
46 case "project_admin_plugins": {
47 // this displays the link in the project admin options page to it's quota_management administration
48 $group_id = $params['group_id'];
49 $group = group_get_object($group_id);
50 if ( $group->usesPlugin($this->name)) {
51 echo util_make_link('/plugins/quota_management/index.php?id='.$group->getID().'&type=admin&pluginname='.$this->name,
52 _('View the quota_management Administration')
59 case "site_admin_option_hook": {
60 echo '<li>'.$this->getAdminOptionLink().'</li>';
64 case "groupadminmenu": {
65 $params['labels'][] = _ ('Quota');
66 $group_id = $params['group'];
67 $params['links'][] = '/plugins/quota_management/index.php?id='.$group_id.'&type=admin&pluginname='.$this->name;
68 $params['attr_r'][] = array('title' => _('View the quota_management Administration'));
76 function getAdminOptionLink() {
77 return util_make_link('/plugins/'.$this->name.'/quota.php', _('Ressources usage and quota'));
80 function convert_bytes_to_mega($mega) {
81 $b = round($mega / (1024*1024), 2);
85 function add_numbers_separator($val, $sep=' ') {
87 $size = strrev($size);
88 $size = wordwrap($size, 3, $sep, 1);
89 $size = strrev($size);
93 function get_dir_size($dir) {
95 $cmd = "/usr/bin/du -bs $dir";
96 $res = shell_exec ($cmd);
97 $a = explode("\t", $res);
98 if (isset($a[1])) $size = $a[0];
102 function quota_management_Project_Header($params) {
104 $params['toptab'] = 'quota_management';
105 $params['group'] = $id;
107 Show horizontal links
109 site_project_header($params);
115 // c-file-style: "bsd"