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...
31 $this->_addHook('groupisactivecheckbox'); // The "use ..." checkbox in editgroupinfo
32 $this->_addHook('groupisactivecheckboxpost'); //
33 $this->_addHook('userisactivecheckbox'); // The "use ..." checkbox in user account
34 $this->_addHook('userisactivecheckboxpost'); //
35 $this->_addHook('project_admin_plugins'); // to show up in the admin page fro group
36 $this->_addHook('site_admin_option_hook'); // to show in admin
37 $this->_addHook('groupadminmenu');
40 function CallHook($hookname, &$params) {
41 global $use_quota_managementplugin, $G_SESSION, $HTML;
44 case "project_admin_plugins": {
45 // this displays the link in the project admin options page to it's quota_management administration
46 $group_id = $params['group_id'];
47 $group = group_get_object($group_id);
48 if ( $group->usesPlugin($this->name)) {
49 echo util_make_link('/plugins/quota_management/index.php?id='.$group->getID().'&type=admin&pluginname='.$this->name,
50 _('View the quota_management Administration')
57 case "site_admin_option_hook": {
58 echo '<li>'.$this->getAdminOptionLink().'</li>';
62 case "groupadminmenu": {
63 $params['labels'][] = _ ('Quota');
64 $group_id = $params['group'];
65 $params['links'][] = '/plugins/quota_management/index.php?id='.$group_id.'&type=admin&pluginname='.$this->name;
66 $params['attr_r'][] = array('class' => 'tabtitle', 'title' => _('View the quota_management Administration'));
74 function getAdminOptionLink() {
75 return util_make_link('/plugins/'.$this->name.'/quota.php', _('Ressources usage and quota'));
78 function convert_bytes_to_mega($mega) {
79 $b = round($mega / (1024*1024), 2);
83 function add_numbers_separator($val, $sep=' ') {
85 $size = strrev($size);
86 $size = wordwrap($size, 3, $sep, 1);
87 $size = strrev($size);
91 function get_dir_size($dir) {
93 $cmd = "/usr/bin/du -bs $dir";
94 $res = shell_exec ($cmd);
95 $a = explode("\t", $res);
96 if (isset($a[1])) $size = $a[0];
100 function quota_management_Project_Header($params) {
102 $params['toptab'] = 'quota_management';
103 $params['group'] = $id;
105 Show horizontal links
107 site_project_header($params);
113 // c-file-style: "bsd"