PKPNotificationOperationManager::sendToMailingList PHP Method

sendToMailingList() public method

Send an update to all users on the mailing list
public sendToMailingList ( $request, $notification )
$request PKPRequest
$notification object Notification
    public function sendToMailingList($request, $notification)
    {
        $notificationMailListDao = DAORegistry::getDAO('NotificationMailListDAO');
        $mailList = $notificationMailListDao->getMailList($notification->getContextId());
        AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON);
        foreach ($mailList as $email) {
            $context = $request->getContext();
            $site = $request->getSite();
            $router = $request->getRouter();
            $dispatcher = $router->getDispatcher();
            $mail = $this->getMailTemplate('NOTIFICATION_MAILLIST');
            if ($context) {
                $mail->setReplyTo($context->getContactEmail(), $context->getContactName());
            } else {
                $mail->setReplyTo($site->getLocalizedContactEmail(), $site->getLocalizedContactName());
            }
            $mail->assignParams(array('notificationContents' => $this->getNotificationContents($request, $notification), 'url' => $this->getNotificationUrl($request, $notification), 'siteTitle' => $context->getLocalizedName(), 'unsubscribeLink' => $dispatcher->url($request, ROUTE_PAGE, null, 'notification', 'unsubscribeMailList')));
            $mail->addRecipient($email);
            $mail->send();
        }
    }

Usage Example

 /**
  * Check if the manager delegate can send to mailing list
  * the passed type of notification.
  * @copydoc PKPNotificationOperationManager::sendToMailingList()
  */
 function sendToMailingList($request, $notification)
 {
     assert($notification->getType() !== $this->getNotificationType() || $this->multipleTypesUpdate());
     parent::sendToMailingList($request, $notification);
 }