[vhffs-dev] [svn] commit: r217 - in /trunk: vhffs-api/src/Vhffs/ vhffs-api/src/Vhffs/Panel/ vhffs-backend/mails/ vhffs-panel/largefile/ vhffs-panel/templates/largefile/ vhffs-robots/src/ |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [svn] commit: r217 - in /trunk: vhffs-api/src/Vhffs/ vhffs-api/src/Vhffs/Panel/ vhffs-backend/mails/ vhffs-panel/largefile/ vhffs-panel/templates/largefile/ vhffs-robots/src/
- From: vhffs-dev@xxxxxxxxx
- Date: Sun, 20 Aug 2006 19:40:49 -0000
Author: soda
Date: Sun Aug 20 21:40:47 2006
New Revision: 217
Log:
* Add templated mails
* Continue largefile implementation
Added:
trunk/vhffs-backend/mails/
trunk/vhffs-backend/mails/largefile-upload
trunk/vhffs-panel/templates/largefile/prefs-waiting.tmpl
Modified:
trunk/vhffs-api/src/Vhffs/Constants.pm
trunk/vhffs-api/src/Vhffs/Functions.pm
trunk/vhffs-api/src/Vhffs/Panel/LargeFile.pm
trunk/vhffs-panel/largefile/prefs.pl
trunk/vhffs-robots/src/create_largefile.pl
Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm Sun Aug 20 21:40:47 2006
@@ -48,6 +48,8 @@
ML_RIGHT_SUB => 4,
ML_RIGHT_ADMIN => 10,
ML_RIGHT_SUB_WAITING_FOR_DEL => 12,
+
+ MAILS_DIR => "/usr/share/vhffs/mails/",
};
1;
Modified: trunk/vhffs-api/src/Vhffs/Functions.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Functions.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Functions.pm Sun Aug 20 21:40:47 2006
@@ -1,6 +1,9 @@
#!/usr/bin/perl
package Vhffs::Functions;
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw( send_mail mail_template);
use strict;
use DBI;
@@ -194,6 +197,8 @@
Type => 'text/plain; charset=utf-8',
Data => "$message";
$msg -> send;
+
+ return( 1 );
}
#Connect to the database
@@ -373,5 +378,45 @@
}
}
+sub mail_template
+{
+ my( $user , $keys , $template , $file , $content , $line , $key , $vhffs );
+ $vhffs = shift;
+ $template = shift;
+ $user = shift;
+ $keys = shift;
+
+ $file = Vhffs::Constants::MAILS_DIR . "/" . $template;
+
+ return( -1 ) if( $user->fetch != 1 );
+
+ return( -1 ) if( ! -f $file );
+ return( -1 ) if( ! -r $file );
+
+ $content = "";
+
+ open( FIC , $file );
+
+ while( $line = <FIC> )
+ {
+ foreach $key ( keys %{$keys} )
+ {
+ $line =~ s/$key/$keys->{$key}/g;
+ }
+ $content .= $line;
+ }
+
+ if( send_mail( $keys->{FROM} , $user->get_mail , $keys->{SUBJECT} , $content , $vhffs ) != 1 )
+ {
+ return( -2 );
+ }
+
+ close( FIC );
+
+
+
+ return( 1 );
+}
+
1;
Modified: trunk/vhffs-api/src/Vhffs/Panel/LargeFile.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/LargeFile.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Panel/LargeFile.pm Sun Aug 20 21:40:47 2006
@@ -42,7 +42,7 @@
{
foreach $obj ( @{$objs} )
{
- if( $obj->get_status == Vhffs::Constants::ACTIVATED )
+ if( ( $obj->get_status == Vhffs::Constants::ACTIVATED ) || ( $obj->get_status == Vhffs::Constants::CREATED ) )
{
$subtemplate = new HTML::Template( filename => "$templatesdir/largefile/menu_sub.tmpl" );
$subtemplate->param( NAME => $obj->get_filename);
Modified: trunk/vhffs-panel/largefile/prefs.pl
==============================================================================
--- trunk/vhffs-panel/largefile/prefs.pl (original)
+++ trunk/vhffs-panel/largefile/prefs.pl Sun Aug 20 21:40:47 2006
@@ -71,7 +71,7 @@
$message = gettext( "You're not allowed to do this (ACL rights)");
$template->param( MESSAGE => $message );
}
-elsif( ( $file->get_status != Vhffs::Constants::ACTIVATED ) && ( $user->is_admin != 1 ) )
+elsif( ( ( $file->get_status != Vhffs::Constants::ACTIVATED ) || ( $file->get_status != Vhffs::Constants::CREATED ) )&& ( $user->is_admin != 1 ) )
{
$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
$message = gettext( "This object is not functionnal yet. Please wait creation, moderation or modification.");
@@ -79,33 +79,58 @@
}
else
{
- $template = new HTML::Template( filename => $templatedir."/largefile/prefs.tmpl" );
+ if( $file->get_status == Vhffs::Constants::CREATED )
+ {
+ $template = open_template( $vhffs , 'largefile' , 'prefs-waiting' );
+ $template->param( VALUE_FILENAME => $file->get_filename() );
- $template->param( TEXT_TITLE => gettext("Hosted file administration") );
+ $template->param( TEXT_TITLE => gettext("Hosted file administration") );
- $template->param( TEXT_FILENAME => gettext("Filename") );
- $template->param( VALUE_FILENAME => $file->get_filename() );
+ $template->param( 'NOT-ACTIVE' => gettext("This file is not active yet") );
+ $template->param( 'TEXT-EXPLAIN' => gettext("Your file is not active at this time. In fact, you need upload it and declare it uploaded on the panel (see following instructions). You probably received a mail with all instructions to upload the file on our servers.") );
+
+ $template->param( 'TITLE-SEND-INFOS' => gettext("Send me informations back") );
+ $template->param( 'TITLE-COMPLETE' => gettext( "Declare the file as uploaded and complete" ) );
+
+ $template->param( 'TEXT-INFOS' => gettext("All instructions were sended to you. But you may forgot these informations. Click on the link, and we will send them again. Be careful, it takes lot of time. ") );
+ $template->param( 'CONFIRM-INFOS' => gettext("Yes, I want instructions back") );
- $template->param( TEXT_LICENCE => gettext("License") );
- $template->param( VALUE_LICENCE => $file->get_licence() );
- $template->param( TEXT_FILESIZE => gettext("Size") );
- $template->param( VALUE_FILESIZE => $file->get_size() );
+ $template->param( 'TEXT-COMPLETE' => gettext("If your file has been uploaded and seems to be complete, you can declare it as uploaded. Once done, we will add it on our public servers and will be mirrored all around the world.") );
+ $template->param( 'CONFIRM-COMPLETE' => gettext("Yes, my file was successfully uploaded") );
- $template->param( TEXT_FILETYPE => gettext("Type") );
- $template->param( VALUE_FILETYPE => $file->get_type() );
+ }
+ else
+ {
+ $template = open_template( $vhffs , 'largefile' , 'prefs' );
- $template->param( TEXT_DELETE_FILENAME => gettext("Delete this file from servers") );
- $template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. All services associated to this project will be DESTROYED.") );
- $template->param( ASK_DELETE_FILENAME => gettext("Are you SURE you want DELETE this subversion repository ?") );
- $template->param( YES => gettext("Yes I'm sure of what I do") );
- $template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
- $template->param( TEXT_DELETE => gettext("Delete") );
-
- $template->param( TEXT_ACL_ADMIN => "Admin Rights on this object (ACL)" );
- $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" );
+ $template->param( TEXT_TITLE => gettext("Hosted file administration") );
+
+
+ $template->param( TEXT_FILENAME => gettext("Filename") );
+ $template->param( VALUE_FILENAME => $file->get_filename() );
+
+ $template->param( TEXT_LICENCE => gettext("License") );
+ $template->param( VALUE_LICENCE => $file->get_licence() );
+
+ $template->param( TEXT_FILESIZE => gettext("Size") );
+ $template->param( VALUE_FILESIZE => $file->get_size() );
+
+ $template->param( TEXT_FILETYPE => gettext("Type") );
+ $template->param( VALUE_FILETYPE => $file->get_type() );
+
+ $template->param( TEXT_DELETE_FILENAME => gettext("Delete this file from servers") );
+ $template->param( TEXT_BEFORE_DELETE => gettext("This action is non-reversible. All services associated to this project will be DESTROYED.") );
+ $template->param( ASK_DELETE_FILENAME => gettext("Are you SURE you want DELETE this subversion repository ?") );
+ $template->param( YES => gettext("Yes I'm sure of what I do") );
+ $template->param( NO => gettext("No, I'm not sure, I prefer to keep this project.") );
+ $template->param( TEXT_DELETE => gettext("Delete") );
+
+ $template->param( TEXT_ACL_ADMIN => "Admin Rights on this object (ACL)" );
+ $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" );
+ }
if( $user->is_admin == 1 )
{
@@ -115,7 +140,6 @@
$subtemplate->param( OPART_TITLE => gettext("Object part") );
$template->param( OPART => $subtemplate->output );
}
-
}
Modified: trunk/vhffs-robots/src/create_largefile.pl
==============================================================================
--- trunk/vhffs-robots/src/create_largefile.pl (original)
+++ trunk/vhffs-robots/src/create_largefile.pl Sun Aug 20 21:40:47 2006
@@ -4,6 +4,8 @@
use Vhffs::Robots;
use Vhffs::Functions;
use Vhffs::Main;
+use locale;
+use Locale::gettext;
my $vhffs = init Vhffs::Main;
@@ -33,7 +35,22 @@
$file->commit;
- print $file->get_filename . "\n" ;
+ mail_template( $vhffs ,
+ "largefile-upload" ,
+ $file->get_user ,
+ { FILENAME => $file->get_filename ,
+ USERNAME => $file->get_user->get_username ,
+ 'FTP-USERNAME' => $file->get_username ,
+ 'FTP-PASSWORD' => $pass ,
+ 'FTP-SERVER' => $vhffs->get_config->largefile_upload_host ,
+ 'FROM' => $vhffs->get_config->get_moderator_mail ,
+ 'SUBJECT' => sprintf( gettext( "Upload file %s for file-hosting" ), $file->get_filename ) ,
+ 'HOSTINGSERVICE' => $vhffs->get_config->get_host_name
+ }
+ );
+
+ $file->set_status( Vhffs::Constants::CREATED );
+ $file->commit;
}
unlock( $vhffs );