Commit c9eee17c by Scott

Convert Notifications classes to namespaces

parent d9cf5d54
......@@ -24,15 +24,19 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
exit;
}
use Q2A\Notifications\Email;
use Q2A\Notifications\Mailer;
use Q2A\Notifications\Status as NotifyStatus;
/**
* @deprecated: Use Q2A_Notifications_Status::suspend() instead.
* Suspend the sending of all email notifications via qa_send_notification(...) if $suspend is true, otherwise
* reinstate it. A counter is kept to allow multiple calls.
* @param bool $suspend
* @deprecated: Use \Q2A\Notifications\Status::suspend() instead.
*/
function qa_suspend_notifications($suspend = true)
{
Q2A_Notifications_Status::suspend($suspend);
NotifyStatus::suspend($suspend);
}
......@@ -53,14 +57,14 @@ function qa_send_notification($userid, $email, $handle, $subject, $body, $subs,
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
if (Q2A_Notifications_Status::isSuspended()) {
if (NotifyStatus::isSuspended()) {
return;
}
if ($userid) {
$sender = Q2A_Notifications_Email::CreateByUserID($userid, $email, $handle);
$sender = Email::CreateByUserID($userid, $email, $handle);
} else {
$sender = Q2A_Notifications_Email::CreateByEmailAddress($email, $handle);
$sender = Email::CreateByEmailAddress($email, $handle);
}
return $sender->sendMessage($subject, $body, $subs, $html);
......@@ -76,7 +80,7 @@ function qa_send_email($params)
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$mailer = new Q2A_Notifications_Mailer($params);
$mailer = new Mailer($params);
$send_status = $mailer->send();
if (!$send_status) {
......
......@@ -18,18 +18,16 @@
More about this license: http://www.question2answer.org/license.php
*/
use Q2A\Exceptions\FatalErrorException;
namespace Q2A\Notifications;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
use Q2A\Exceptions\FatalErrorException;
use Q2A\Notifications\Mailer;
require_once QA_INCLUDE_DIR . 'db/selects.php'; //required for qa_db_select_with_pending()
require_once QA_INCLUDE_DIR . 'app/options.php'; //required for qa_opt()
require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php';
class Q2A_Notifications_Email
class Email
{
private $email;
private $handle;
......@@ -105,7 +103,7 @@ class Q2A_Notifications_Email
$bodyPrefix = (empty($this->handle) ? '' : qa_lang_sub('emails/to_handle_prefix', $this->handle));
if (PHPMailer::validateAddress($this->email)) {
$mailer = new Q2A_Notifications_Mailer(array(
$mailer = new Mailer(array(
'fromemail' => qa_opt('from_email'),
'fromname' => qa_opt('site_title'),
'toemail' => $this->email,
......
......@@ -18,14 +18,11 @@
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
namespace Q2A\Notifications;
require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php';
class Q2A_Notifications_Mailer extends PHPMailer
class Mailer extends PHPMailer
{
public function __construct($params = array())
{
......
......@@ -18,12 +18,9 @@
More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
namespace Q2A\Notifications;
class Q2A_Notifications_Status
class Status
{
protected static $notifications_suspended = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment