[vhffs-dev] [1825] No more HTML::Template in object/edit_submit |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1825
Author: beuss
Date: 2011-05-28 22:30:04 +0200 (Sat, 28 May 2011)
Log Message:
-----------
No more HTML::Template in object/edit_submit
Modified Paths:
--------------
trunk/vhffs-panel/Makefile.am
trunk/vhffs-panel/admin/object/edit.pl
trunk/vhffs-panel/templates/admin/object/edit.tt
Removed Paths:
-------------
trunk/vhffs-panel/admin/object/edit_submit.pl
Modified: trunk/vhffs-panel/Makefile.am
===================================================================
--- trunk/vhffs-panel/Makefile.am 2011-05-26 20:43:07 UTC (rev 1824)
+++ trunk/vhffs-panel/Makefile.am 2011-05-28 20:30:04 UTC (rev 1825)
@@ -825,7 +825,6 @@
admin/mysql/list.pl \
admin/mysql/search.pl \
admin/object/delete_avatar.pl \
- admin/object/edit_submit.pl \
admin/object/edit.pl \
admin/object/list.pl \
admin/object/search.pl \
Modified: trunk/vhffs-panel/admin/object/edit.pl
===================================================================
--- trunk/vhffs-panel/admin/object/edit.pl 2011-05-26 20:43:07 UTC (rev 1824)
+++ trunk/vhffs-panel/admin/object/edit.pl 2011-05-28 20:30:04 UTC (rev 1825)
@@ -47,6 +47,8 @@
my $vhffs = $panel->{vhffs};
my $cgi = $panel->{'cgi'};
my $oid = $cgi->param("OID");
+my $status = $cgi->param("STATUS");
+my $description = Encode::decode_utf8( $cgi->param('description') );
unless(defined $oid) {
$panel->render('misc/message.tt', {
@@ -62,6 +64,17 @@
});
}
+if(defined $status and defined $description) {
+ $object->set_status( $status );
+ $object->set_description( $description );
+ if($object->commit() >= 0) {
+ $panel->add_info( gettext('Object updated') );
+ } else {
+ $panel->add_error( gettext('Error while updating object') );
+ }
+}
+
+
$panel->render('admin/object/edit.tt', {
object => $object,
use_avatars => ($object->get_type == Vhffs::Constants::TYPE_USER && $panel->use_users_avatars)
Deleted: trunk/vhffs-panel/admin/object/edit_submit.pl
===================================================================
--- trunk/vhffs-panel/admin/object/edit_submit.pl 2011-05-26 20:43:07 UTC (rev 1824)
+++ trunk/vhffs-panel/admin/object/edit_submit.pl 2011-05-28 20:30:04 UTC (rev 1825)
@@ -1,99 +0,0 @@
-#!%PERL% -w
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-
-use utf8;
-use POSIX qw(locale_h);
-use HTML::Template;
-use locale;
-use Locale::gettext;
-use CGI;
-use CGI::Session;
-use strict;
-use Encode;
-
-use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Stats;
-use Vhffs::Constants;
-
-my $panel = new Vhffs::Panel::Main();
-exit 0 unless $panel;
-my $session = $panel->get_session;
-exit 0 unless $session;
-
-my $vhffs = $panel->{'vhffs'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-my $cgi = $panel->{'cgi'};
-my $oid = $cgi->param("OID");
-my $status = $cgi->param("STATUS");
-my $description = Encode::decode_utf8( $cgi->param('description') );
-
-my $object;
-
-my $templatesdir = $vhffs->get_config->get_templatedir;
-my $template = new HTML::Template( filename => $templatesdir."/panel/misc/simplemsg.tmpl" );
-
-if( $user->is_admin != 1 )
-{
- $template->param( MESSAGE => gettext( "You are not allowed to see it") );
-}
-elsif( ( ! defined $oid ) || ( ! defined $status ) )
-{
- $template->param( MESSAGE => gettext( "CGI Error !") );
-}
-elsif( ! defined ( $object = Vhffs::Object::get_by_oid( $vhffs , $oid ) ) )
-{
- $template->param( MESSAGE => gettext( "Cannot fetch object") );
-}
-else
-{
- $object->set_status( $status );
- $object->set_description( $description );
-
- if( $object->commit < 0 )
- {
- $template->param( MESSAGE => gettext( "An error occured while updating the object") );
- }
- else
- {
- $template->param( MESSAGE => gettext( "Object successfully updated") );
- }
-}
-
-$panel->build( $template );
-$panel->display;
-
Modified: trunk/vhffs-panel/templates/admin/object/edit.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/object/edit.tt 2011-05-26 20:43:07 UTC (rev 1824)
+++ trunk/vhffs-panel/templates/admin/object/edit.tt 2011-05-28 20:30:04 UTC (rev 1825)
@@ -1,15 +1,14 @@
[% USE date %]
<h1>[% 'Object administration' | i18n | html %]</h1>
-<form method="post" action="/admin/object/edit_submit.pl" accept-charset="utf-8">
+<form method="post" action="/admin/object/edit.pl" accept-charset="utf-8">
<p>
<label>[% 'Object ID:' | i18n | html %]</label>
[% object.get_oid %]
</p>
<p>
- <label for="UID">[% 'Owner UID:' | i18n | html %]</label>
- <input type="text" name="UID" id="UID" value="[% object.get_owner_uid %]" />
- ([% object.get_owner_name | html %])
+ <label>[% 'Owner UID:' | i18n | html %]</label>
+ [% object.get_owner_uid %] ([% object.get_owner_name | html %])
</p>
<p>
<label>[% 'Date of creation' | i18n | html %]</label>