mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
Update latests classes
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
class mail
|
||||
{
|
||||
|
||||
public static function mail_test($email)
|
||||
public static function mail_test(Application $app, $email)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$from = array('email' => $registry->get('GV_defaulmailsenderaddr'), 'name' => $registry->get('GV_defaulmailsenderaddr'));
|
||||
|
||||
$subject = _('mail:: test d\'envoi d\'email');
|
||||
@@ -14,33 +16,26 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $message, $to, $from);
|
||||
return self::send_mail($app, $subject, $message, $to, $from);
|
||||
}
|
||||
|
||||
public static function send_validation_results($email, $subject, $from, $message)
|
||||
public static function ftp_sent(Application $app, $email, $subject, $body)
|
||||
{
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $message, $to, $from);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function ftp_sent($email, $subject, $body)
|
||||
{
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function ftp_receive($email, $body)
|
||||
public static function ftp_receive(Application $app, $email, $body)
|
||||
{
|
||||
$subject = _("task::ftp:Someone has sent some files onto FTP server");
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function send_documents($email, $url, $from, $endate_obj, $message = '', $accuse)
|
||||
public static function send_documents(Application $app, $email, $url, $from, $endate_obj, $message = '', $accuse)
|
||||
{
|
||||
$subject = _('export::vous avez recu des documents');
|
||||
|
||||
@@ -49,7 +44,7 @@ class mail
|
||||
|
||||
$body .= '<br><div>' .
|
||||
sprintf(
|
||||
_('Attention, ce lien lien est valable jusqu\'au %s'), phraseadate::getDate($endate_obj) . ' ' . phraseadate::getTime($endate_obj)
|
||||
_('Attention, ce lien lien est valable jusqu\'au %s'), $app['date-formatter']->getDate($endate_obj) . ' ' . $app['date-formatter']->getTime($endate_obj)
|
||||
)
|
||||
. '</div>';
|
||||
|
||||
@@ -59,10 +54,10 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to, $from, array(), $accuse);
|
||||
return self::send_mail($app, $subject, $body, $to, $from, array(), $accuse);
|
||||
}
|
||||
|
||||
public static function forgot_passord($email, $login, $url)
|
||||
public static function forgot_passord(Application $app, $email, $login, $url)
|
||||
{
|
||||
$subject = _('login:: Forgot your password'); // Registration order on .
|
||||
|
||||
@@ -72,12 +67,12 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function register_confirm($email, $accept, $deny)
|
||||
public static function register_confirm(Application $app, $email, $accept, $deny)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$subject = sprintf(_('login::register:email: Votre compte %s'), $registry->get('GV_homeTitle'));
|
||||
|
||||
$body = '<div>' . _('login::register:email: Voici un compte rendu du traitement de vos demandes d\'acces :') . "</div>\n";
|
||||
@@ -91,35 +86,14 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function register_user($email, $auto, $others)
|
||||
public static function reset_email(Application $app, $email, $usr_id)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$subject = sprintf(_('login::register:email: Votre compte %s'), $registry->get('GV_homeTitle'));
|
||||
|
||||
$body = "<div>" . _('login::register:Votre inscription a ete prise en compte') . "</div>\n";
|
||||
|
||||
if ($auto != '') {
|
||||
$body .= "<br/>\n<div>" . _('login::register: vous avez des a present acces aux collections suivantes : ') . "</div>\n<ul>" . $auto . "</ul>\n";
|
||||
}
|
||||
|
||||
if ($others != '') {
|
||||
$body .= "<br/>\n<div>" . _('login::register: vos demandes concernat les collections suivantes sont sujettes a approbation d\'un administrateur') . "</div>\n<ul>" . $others . "</ul>\n";
|
||||
$body .= "<br/>\n<div>" . _('login::register : vous serez avertis par email lorsque vos demandes seront traitees') . "</div>\n";
|
||||
}
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function reset_email($email, $usr_id)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$date = new DateTime('1 day');
|
||||
$token = random::getUrlToken(\random::TYPE_EMAIL, $usr_id, $date, $email);
|
||||
$token = random::getUrlToken($app, \random::TYPE_EMAIL, $usr_id, $date, $email);
|
||||
|
||||
$url = $registry->get('GV_ServerName') . 'account/reset-email/?token=' . $token;
|
||||
|
||||
@@ -130,12 +104,12 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function change_mail_information($display_name, $old_email, $new_email)
|
||||
public static function change_mail_information(Application $app, $display_name, $old_email, $new_email)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$subject = sprintf(_('Update of your email address on %s'), $registry->get('GV_homeTitle'));
|
||||
|
||||
$body = "<div>" . sprintf(_('Dear %s,'), $display_name) . "</div>\n<br/>\n";
|
||||
@@ -152,30 +126,15 @@ class mail
|
||||
$to_old = array('email' => $old_email, 'name' => $display_name);
|
||||
$to_new = array('email' => $new_email, 'name' => $display_name);
|
||||
|
||||
$res_old = $old_email ? self::send_mail($subject, $body, $to_old) : true;
|
||||
$res_new = $new_email ? self::send_mail($subject, $body, $to_new) : true;
|
||||
$res_old = $old_email ? self::send_mail($app, $subject, $body, $to_old) : true;
|
||||
$res_new = $new_email ? self::send_mail($app, $subject, $body, $to_new) : true;
|
||||
|
||||
return $res_old && $res_new;
|
||||
}
|
||||
|
||||
public static function change_password(User_Adapter $user, $ip, \DateTime $date)
|
||||
public static function send_credentials(Application $app, $url, $login, $email)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
|
||||
$subject = sprintf(_('Your account update on %s'), $registry->get('GV_homeTitle'));
|
||||
|
||||
$body = "<div>" . sprintf(_('Dear %s,'), $user->get_display_name()) . "</div><br/>\n\n";
|
||||
$body .= "<div>" . sprintf(_('The password of your account %s has been successfully updated'), $user->get_login()) . "</div><br/>\n\n";
|
||||
$body .= "<div>" . sprintf(_('For your interest, the request has been done from %s at %s'), $ip, $date->format(DATE_ATOM)) . "</div>\n";
|
||||
|
||||
$to = array('email' => $user->get_email(), 'name' => $user->get_email());
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function send_credentials($url, $login, $email)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
$subject = sprintf(_('Your account on %s'), $registry->get('GV_homeTitle'));
|
||||
|
||||
@@ -185,12 +144,12 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function mail_confirm_registered($email)
|
||||
public static function mail_confirm_registered(Application $app, $email)
|
||||
{
|
||||
$registry = \registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
$subject = _('login::register: sujet email : confirmation de votre adresse email');
|
||||
|
||||
@@ -200,10 +159,10 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function mail_confirm_unregistered($email, array $others)
|
||||
public static function mail_confirm_unregistered(Application $app, $email, array $others)
|
||||
{
|
||||
|
||||
$subject = _('login::register: sujet email : confirmation de votre adresse email');
|
||||
@@ -219,14 +178,14 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function mail_confirmation($email, $usr_id)
|
||||
public static function mail_confirmation(Application $app, $email, $usr_id)
|
||||
{
|
||||
$registry = registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$expire = new DateTime('+3 days');
|
||||
$token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $expire, $email);
|
||||
$token = random::getUrlToken($app, \random::TYPE_PASSWORD, $usr_id, $expire, $email);
|
||||
|
||||
$subject = _('login::register: sujet email : confirmation de votre adresse email');
|
||||
|
||||
@@ -235,7 +194,7 @@ class mail
|
||||
|
||||
$to = array('email' => $email, 'name' => $email);
|
||||
|
||||
return self::send_mail($subject, $body, $to);
|
||||
return self::send_mail($app, $subject, $body, $to);
|
||||
}
|
||||
|
||||
public static function validateEmail($email)
|
||||
@@ -243,11 +202,9 @@ class mail
|
||||
return PHPMailer::ValidateAddress($email);
|
||||
}
|
||||
|
||||
public static function send_mail($subject, $body, $to, $from = false, $files = array(), $reading_confirm_to = false)
|
||||
public static function send_mail(Application $app, $subject, $body, $to, $from = false, $files = array(), $reading_confirm_to = false)
|
||||
{
|
||||
$Core = \bootstrap::getCore();
|
||||
|
||||
$registry = $Core->getRegistry();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
if ( ! isset($to['email']) || ! PHPMailer::ValidateAddress($to['email'])) {
|
||||
return false;
|
||||
@@ -255,8 +212,6 @@ class mail
|
||||
|
||||
$mail = new PHPMailer();
|
||||
|
||||
$body = eregi_replace("[\]", '', $body);
|
||||
|
||||
$body .= "<br/><br/><br/><br/>\n\n\n\n";
|
||||
$body .= '<div style="font-style:italic;">' . _('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.') . '</div>';
|
||||
$body .= "<br/>\n";
|
||||
@@ -270,13 +225,13 @@ class mail
|
||||
$mail->CharSet = 'utf-8';
|
||||
$mail->Encoding = 'base64'; //'quoted-printable';
|
||||
|
||||
$registry = registry::get_instance();
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
if ($registry->get('GV_smtp')) {
|
||||
$mail->IsSMTP();
|
||||
if ($registry->get('GV_smtp_host') != '')
|
||||
$mail->Host = $registry->get('GV_smtp_host');
|
||||
// $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
|
||||
|
||||
if ($registry->get('GV_smtp_auth')) {
|
||||
$mail->SMTPAuth = true;
|
||||
|
||||
@@ -311,7 +266,7 @@ class mail
|
||||
$mail->AddAttachment($f); // attachment
|
||||
}
|
||||
|
||||
if ($Core->getConfiguration()->getEnvironnement() !== 'test') {
|
||||
if ($app->getEnvironment() !== 'test') {
|
||||
$mail->Send();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user