[vhffs-dev] [1115] Admins can now update repository quota using panel. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1115
Author: beuss
Date: 2008-01-07 07:09:58 +0000 (Mon, 07 Jan 2008)
Log Message:
-----------
Admins can now update repository quota using panel.
Modified Paths:
--------------
trunk/vhffs-panel/repository/prefs.pl
trunk/vhffs-panel/templates/Makefile.am
trunk/vhffs-panel/templates/repository/prefs.tmpl
Added Paths:
-----------
trunk/vhffs-panel/templates/repository/admin.tmpl
Modified: trunk/vhffs-panel/repository/prefs.pl
===================================================================
--- trunk/vhffs-panel/repository/prefs.pl 2008-01-07 07:08:18 UTC (rev 1114)
+++ trunk/vhffs-panel/repository/prefs.pl 2008-01-07 07:09:58 UTC (rev 1115)
@@ -32,7 +32,6 @@
use utf8;
use POSIX qw(locale_h);
-use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
@@ -47,6 +46,7 @@
use Vhffs::Panel::Main;
use Vhffs::Panel::Menu;
use Vhffs::Panel::Object;
+use Vhffs::Panel::Template;
my $panel = new Vhffs::Panel::Main();
exit 0 unless $panel;
@@ -73,9 +73,11 @@
$template = new HTML::Template( filename => $templatedir.'/panel/misc/simplemsg.tmpl' );
$template->param( MESSAGE => gettext( 'You\'re not allowed to do this, object is not in active state or you don\'t have enough ACL rights' ) );
} else {
+ if(defined($cgi->param('update_quota_submit'))) {
+ update_quota();
+ }
+ $template = new Vhffs::Panel::Template( filename => $templatedir."/panel/repository/prefs.tmpl" );
- $template = new HTML::Template( filename => $templatedir."/panel/repository/prefs.tmpl" );
-
$panel->set_title( gettext('Admin Download repository') );
$template->param( TEXT_REPONAME => $repo->get_name );
@@ -95,9 +97,39 @@
$template->param( EXPLAIN_ADMIN_ACL => "You can Manage rights on this service for each user in the VHFFS database. Please read help before manage it." );
$template->param( ADMIN_ACL => "Ok, go to ACL admin" );
- my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $repo );
- $template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+ if($user->is_admin() == 1) {
+ $template->param( ADMIN => 1);
+ my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $repo );
+ $template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+ $template->param( QUOTA => $repo->get_quota() );
+ $template->param( USED_QUOTA => $repo->get_quota_used() );
+ }
}
$panel->build( $template );
$panel->display;
+
+sub update_quota {
+ unless($user->is_admin()) {
+ $panel->add_error( gettext('Only administrators are allowed to do this') );
+ return;
+ }
+
+ my $quota = $cgi->param('new_quota');
+ unless(defined $quota && $quota =~ /^\d+$/) {
+ $panel->add_error( gettext('Invalid quota') );
+ return;
+ }
+
+ if($quota < $repo->get_quota_used) {
+ $panel->add_error( gettext('You have to enter a quota greater than the current used quota') );
+ return;
+ }
+ $repo->set_quota($quota);
+
+ if($repo->commit < 0) {
+ $panel->add_error( gettext('Unable to apply modifications, please try again later') );
+ } else {
+ $panel->add_info( gettext('Repository updated, please wait while quota is updated on filesystem') );
+ }
+}
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2008-01-07 07:08:18 UTC (rev 1114)
+++ trunk/vhffs-panel/templates/Makefile.am 2008-01-07 07:09:58 UTC (rev 1115)
@@ -97,6 +97,7 @@
mysql/prefs.tmpl \
pgsql/create.tmpl \
pgsql/prefs.tmpl \
+ repository/admin.tmpl \
repository/create.tmpl \
repository/prefs.tmpl \
svn/create.tmpl \
Added: trunk/vhffs-panel/templates/repository/admin.tmpl
===================================================================
--- trunk/vhffs-panel/templates/repository/admin.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/repository/admin.tmpl 2008-01-07 07:09:58 UTC (rev 1115)
@@ -0,0 +1,8 @@
+<h2><TMPL_I18N KEY="Repository Quota"></h2>
+<form method="post" action="#">
+ <input type="hidden" name="name" value="<TMPL_VAR ESCAPE=1 NAME="TEXT_REPONAME">"/>
+ <p><label><TMPL_I18N KEY="Used Quota">:</label><TMPL_VAR ESCAPE=1 NAME="USED_QUOTA">/<TMPL_VAR ESCAPE=1 NAME="QUOTA"> <TMPL_I18N KEY="MB"></p>
+ <p><label for="new_quota"><TMPL_I18N KEY="New Quota">:</label>
+ <input type="text" name="new_quota" id="new_quota" value="<TMPL_VAR ESCAPE=1 NAME="QUOTA">"/> <TMPL_I18N KEY="MB"></p>
+ <p><input type="submit" name="update_quota_submit" value="<TMPL_I18N KEY="Update Quota">"/></p>
+</form>
Modified: trunk/vhffs-panel/templates/repository/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/repository/prefs.tmpl 2008-01-07 07:08:18 UTC (rev 1114)
+++ trunk/vhffs-panel/templates/repository/prefs.tmpl 2008-01-07 07:09:58 UTC (rev 1115)
@@ -50,4 +50,7 @@
</p>
</form>
-<TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">
+<TMPL_IF NAME="ADMIN">
+ <TMPL_VAR ESCAPE=0 NAME="ADMIN_PART">
+ <TMPL_INCLUDE NAME="admin.tmpl">
+</TMPL_IF>