[vhffs-dev] [1051] Admins can now update quota interactively. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1051
Author: beuss
Date: 2007-11-01 08:14:02 +0000 (Thu, 01 Nov 2007)
Log Message:
-----------
Admins can now update quota interactively.
Modified Paths:
--------------
trunk/vhffs-panel/group/prefs.pl
trunk/vhffs-panel/templates/Makefile.am
trunk/vhffs-panel/templates/group/prefs.tmpl
Added Paths:
-----------
trunk/vhffs-panel/templates/group/admin.tmpl
Modified: trunk/vhffs-panel/group/prefs.pl
===================================================================
--- trunk/vhffs-panel/group/prefs.pl 2007-11-01 08:13:11 UTC (rev 1050)
+++ trunk/vhffs-panel/group/prefs.pl 2007-11-01 08:14:02 UTC (rev 1051)
@@ -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::Group;
use Vhffs::Panel::Object;
+use Vhffs::Panel::Template;
use Vhffs::Functions;
use Vhffs::Services::MailGroup;
@@ -73,7 +73,7 @@
$template->param( MESSAGE => gettext( 'You\'re not allowed to do this (ACL rights)' ) );
} else {
- $template = new HTML::Template( filename => $templatedir.'/panel/group/prefs.tmpl', global_vars => 1 );
+ $template = new Vhffs::Panel::Template( filename => $templatedir.'/panel/group/prefs.tmpl', global_vars => 1 );
if( defined( $cgi->param( 'update_desc_submit' ) ) ) {
# Description modification
@@ -196,7 +196,9 @@
}
}
}
- }
+ } elsif( defined( $cgi->param('update_quota_submit')) ) {
+ update_quota();
+ }
$panel->set_title( gettext('Project Preferences') );
@@ -257,9 +259,41 @@
$template->param( USERS_TEXT => gettext( 'Users' ) );
$template->param( CURRENT_USERS => gettext( 'All users in this group' ) );
- my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $group );
- $template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+ if($user->is_admin) {
+ $template->param( ADMIN => 1 );
+ my $adminpart = Vhffs::Panel::Object::admin_part( $panel, $group );
+ $template->param( ADMIN_PART => $adminpart->output ) if( defined $adminpart );
+ $template->param( QUOTA => $group->get_quota );
+ $template->param( USED_QUOTA => $group->get_quota_used );
+ }
}
$panel->build( $template );
$panel->display;
+
+sub update_quota {
+ my $quota = $cgi->param('new_quota');
+ unless(defined $quota && $quota =~ /^\d+$/) {
+ $panel->add_error( gettext('Invalid quota') );
+ return;
+ }
+
+ unless($user->is_admin()) {
+ $panel->add_error( gettext('Only administrators are allowed to do this') );
+ return;
+ }
+
+ if($quota < $group->get_quota_used) {
+ $panel->add_error( gettext('You have to enter a quota greater than the current used quota') );
+ return;
+ }
+
+ $group->set_quota($quota);
+
+ if($group->commit < 0) {
+ $panel->add_error( gettext('Unable to apply modifications, please try again later') );
+ } else {
+ $panel->add_info( gettext('Group updated, please wait while quota is updated on filesystem') );
+ }
+}
+
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2007-11-01 08:13:11 UTC (rev 1050)
+++ trunk/vhffs-panel/templates/Makefile.am 2007-11-01 08:14:02 UTC (rev 1051)
@@ -56,6 +56,7 @@
dns/list_txt_sub.tmpl \
dns/prefs.tmpl \
group/add_user.tmpl \
+ group/admin.tmpl \
group/create.tmpl \
group/info.tmpl \
group/list_user.tmpl \
Added: trunk/vhffs-panel/templates/group/admin.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/admin.tmpl (rev 0)
+++ trunk/vhffs-panel/templates/group/admin.tmpl 2007-11-01 08:14:02 UTC (rev 1051)
@@ -0,0 +1,6 @@
+<form method="post" action="#">
+ <p><label><TMPL_I18N KEY="Used Quota">:</label><TMPL_VAR NAME="USED_QUOTA">/<TMPL_VAR 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 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/group/prefs.tmpl
===================================================================
--- trunk/vhffs-panel/templates/group/prefs.tmpl 2007-11-01 08:13:11 UTC (rev 1050)
+++ trunk/vhffs-panel/templates/group/prefs.tmpl 2007-11-01 08:14:02 UTC (rev 1051)
@@ -61,7 +61,7 @@
<tmpl_if name="ADD_USER_MSG"><p class="<tmpl_var name="ADD_USER_MSG_CLASS">"><tmpl_var name="ADD_USER_MSG"></p></tmpl_if>
<tmpl_var name="USERS_LIST">
-<tmpl_var name="AVATAR">
+<TMPL_VAR ESCAPE=0 name="AVATAR">
<h2><tmpl_var name="TEXT_ACL_ADMIN"></h2>
@@ -104,4 +104,7 @@
</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>