3 * Project Admin page to manage quotas disk and database
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 require_once dirname(__FILE__)."/../../env.inc.php";
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'admin/admin_utils.php';
30 $cmd = getStringFromRequest('cmd');
32 $quota_management = plugin_get_object('quota_management');
34 $_quota_block_size = 1024;
35 $_quota_block_size = trim(shell_exec("echo $BLOCK_SIZE")) + 0;
36 if ($_quota_block_size == 0) $_quota_block_size = 1024;
38 site_admin_header(array('title'=>_('Site admin')));
42 <a href="quota.php"><?php echo _('Ressources usage and quota'); ?></a>
44 <?php echo _('Quota Manager Admin'); ?>
51 $qs = $_POST["qs"] * $_quota_block_size;
52 $qh = $_POST["qh"] * $_quota_block_size;
54 $message = utf8_encode(_('Input error: Hard quota must be greater than soft quota'));
55 echo "<h3 style=\"color:red\">$message</h3>";
57 db_query_params('UPDATE groups SET quota_soft = $1, quota_hard = $2 WHERE group_id = $3',
60 getIntFromRequest('group_id')));
61 $message = utf8_encode(_('Successfully updated quota'));
62 echo "<h3 style=\"color:red\">$message</h3>";
66 // stock projects infos in array
70 $res_db = db_query_params('SELECT group_id, group_name, unix_group_name, quota_soft, quota_hard FROM groups ORDER BY group_id ',
72 if (db_numrows($res_db) > 0) {
73 while($e = db_fetch_array($res_db)) {
74 $qh = $e["quota_hard"] / $_quota_block_size;
75 $qs = $e["quota_soft"] / $_quota_block_size;
76 $quotas["$e[group_id]"]["group_id"] = $e["group_id"];
77 $quotas["$e[group_id]"]["name"] = $e["group_name"];
78 $quotas["$e[group_id]"]["unix_name"] = $e["unix_group_name"];
79 $quotas["$e[group_id]"]["database_size"] = 0;
80 $quotas["$e[group_id]"]["disk_size"] = 0;
81 $quotas["$e[group_id]"]["quota_hard"] = $qh;
82 $quotas["$e[group_id]"]["quota_soft"] = $qs;
86 <table width="700px" cellpadding="2" cellspacing="0" border="0">
87 <tr style="font-weight:bold">
88 <td style="border-top:thick solid #808080" colspan="6"><?php echo _('Projects disk quota'); ?></td>
91 <td style="border-top:thin solid #808080"><?php echo _('id'); ?></td>
92 <td style="border-top:thin solid #808080"><?php echo _('name'); ?></td>
93 <td style="border-top:thin solid #808080"><br /></td>
94 <td style="border-top:thin solid #808080" align="right"><?php echo _('disk quota soft'); ?></td>
95 <td style="border-top:thin solid #808080" align="right"><?php echo _('disk quota hard'); ?></td>
96 <td style="border-top:thin solid #808080"><br /></td>
101 foreach ($quotas as $q)
103 $total_database += $q["database_size"];
104 $total_disk += $q["disk_size"];
106 <form action="quota_admin.php" method="POST">
107 <input type="hidden" name="cmd" value="maj" />
108 <input type="hidden" name="group_id" value="<?php echo $q["group_id"]; ?>" />
110 <td style="border-top:thin solid #808080"><?php echo $q["group_id"]; ?></td>
111 <td style="border-top:thin solid #808080"><a href="<?php echo util_make_url('/plugins/quota_management/index.php?id='.$q['group_id'].'&type=admin&pluginname='.$quota_management->name); ?>">
112 <?php echo $q["unix_name"]; ?>
114 <td style="border-top:thin solid #808080"><?php echo $q["name"]; ?></td>
115 <td style="border-top:thin solid #808080" align="right">
116 <input type="text" name="qs"
118 value="<?php echo $q["quota_soft"]; ?>"
119 style="background:#ffffd0;text-align:right" />
120 <?php echo _('Mb'); ?>
122 <td style="border-top:thin solid #808080" align="right">
123 <input type="text" name="qh"
125 value="<?php echo $q["quota_hard"]; ?>"
126 style="background:#ffffd0;text-align:right" />
127 <?php echo _('Mb'); ?>
129 <td style="border-top:thin solid #808080" align="right">
130 <input type="submit" value="<?php echo _('Modify'); ?>" />
137 <tr style="font-weight:bold">
138 <td style="border-top:thick solid #808080;border-bottom:thick solid #808080"><br /></td>
139 <td style="border-top:thick solid #808080;border-bottom:thick solid #808080"><br /></td>
140 <td style="border-top:thick solid #808080;border-bottom:thick solid #808080"><br /></td>
141 <td style="border-top:thick solid #808080;border-bottom:thick solid #808080"><br /></td>
142 <td style="border-top:thick solid #808080;border-bottom:thick solid #808080"><br /></td>
143 <td style="border-top:thick solid #808080;border-bottom:thick solid #808080"><br /></td>
148 site_admin_footer(array());
152 // c-file-style: "bsd"