[vhffs-dev] [1749] Cleanup in quickdelete.pl |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1749
Author: beuss
Date: 2011-05-15 16:54:33 +0200 (Sun, 15 May 2011)
Log Message:
-----------
Cleanup in quickdelete.pl
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Panel/Main.pm
trunk/vhffs-panel/object/quickdelete.pl
trunk/vhffs-panel/templates/layouts/panel.tt
Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2011-05-15 14:54:25 UTC (rev 1748)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2011-05-15 14:54:33 UTC (rev 1749)
@@ -651,6 +651,9 @@
$vars->{title} = sprintf( gettext( '%s\'s Panel' ), $conf->get_host_name );
$vars->{page_title} = $self->{title};
$vars->{has_public_area} = $self->is_public;
+ if(defined $self->{cgi}->param('msg')) {
+ $vars->{msg} = Encode::decode_utf8($self->{cgi}->param('msg'));
+ }
my @langs = $self->{vhffs}->get_config->get_available_languages;
$vars->{languages} = \@langs;
$vars->{errors} = $self->{errors};
Modified: trunk/vhffs-panel/object/quickdelete.pl
===================================================================
--- trunk/vhffs-panel/object/quickdelete.pl 2011-05-15 14:54:25 UTC (rev 1748)
+++ trunk/vhffs-panel/object/quickdelete.pl 2011-05-15 14:54:33 UTC (rev 1749)
@@ -31,7 +31,6 @@
use utf8;
use POSIX qw(locale_h);
-use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
@@ -39,13 +38,9 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Main;
use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Panel::Group;
+use Vhffs::Group;
use Vhffs::Constants;
-use Vhffs::Object;
use Vhffs::ObjectFactory;
my $panel = new Vhffs::Panel::Main();
@@ -59,48 +54,38 @@
my $cgi = $panel->{cgi};
my $oid = $cgi->param('oid');
-$panel->add_error( gettext('CGI Error !') ) unless defined $oid;
-my $object;
-if( defined $oid ) {
- $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $oid );
- $panel->add_error( gettext('This object does not exist') ) unless defined $object;
+unless(defined $oid) {
+ $panel->render('misc/message.tt', { message => gettext('CGI Error !') } );
}
-if( defined $object && $object->get_status != Vhffs::Constants::VALIDATION_REFUSED ) {
- $panel->add_error( gettext('This object is not in refused state') );
- undef $object;
+my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $oid );
+
+unless(defined $object) {
+ $panel->render('misc/message.tt', { message => gettext('This object does not exist') } );
}
-if( defined $object && $object->get_owner_uid != $user->get_uid ) {
- $panel->add_error( gettext('You are not allowed to do it, you don\'t own this object') );
- undef $object;
+unless($object->get_status == Vhffs::Constants::VALIDATION_REFUSED ) {
+ $panel->render('misc/message.tt', { message => gettext('This object is not in refused state') } );
}
-if( $object ) {
+unless($object->get_owner_uid == $user->get_uid ) {
+ $panel->render('misc/message.tt', { message => gettext('You are not allowed to do it, you don\'t own this object') } );
+}
+if( $object ) {
my $url;
if( $object->get_type == Vhffs::Constants::TYPE_GROUP ) {
$url = '/group/index.pl?msg='.gettext('This object has been deleted');
- }
- else {
+ } else {
my $group = Vhffs::Group::get_by_gid( $vhffs , $object->get_owner_gid );
$url = '/group/view.pl?group='.$group->get_groupname.'&msg='.gettext('This object has been deleted');
}
if( $object->delete ) {
$panel->redirect( $url );
+ } else {
+ $panel->render('misc/message.tt', { message => gettext('An error occured while deleting this object.') } );
}
- else {
- $panel->add_error( gettext('An error occured while deleting this object.') );
- }
}
-
-
-if( $panel->has_errors ) {
-
- $panel->set_title( gettext('Object deletion') );
- $panel->build;
- $panel->display;
-}
Modified: trunk/vhffs-panel/templates/layouts/panel.tt
===================================================================
--- trunk/vhffs-panel/templates/layouts/panel.tt 2011-05-15 14:54:25 UTC (rev 1748)
+++ trunk/vhffs-panel/templates/layouts/panel.tt 2011-05-15 14:54:33 UTC (rev 1749)
@@ -13,6 +13,9 @@
[% INCLUDE 'misc/header.tt' %]
<div class="main" id="main">
<h1>[% page_title | html %]</h1>
+[% IF msg %]
+ <p>[% msg | html %]</p>
+[% END %]
[% INCLUDE 'misc/errors.tt' %]
[% INCLUDE 'misc/infos.tt' %]
[% PROCESS $template %]