ActivityModel::sendNotificationQueue PHP Method

sendNotificationQueue() public method

Send all notifications in the queue.
Since: 2.0.17
    public function sendNotificationQueue()
    {
        foreach ($this->_NotificationQueue as $UserID => $Notifications) {
            if (is_array($Notifications)) {
                // Only send out one notification per user.
                $Notification = $Notifications[0];
                /* @var Gdn_Email $Email */
                $Email = $Notification['Email'];
                if (is_object($Email) && method_exists($Email, 'send')) {
                    $this->EventArguments = $Notification;
                    $this->fireEvent('BeforeSendNotification');
                    try {
                        // Only send if the user is not banned
                        $User = Gdn::userModel()->getID($UserID);
                        if (!val('Banned', $User)) {
                            $Email->send();
                            $Emailed = self::SENT_OK;
                        } else {
                            $Emailed = self::SENT_SKIPPED;
                        }
                    } catch (phpmailerException $pex) {
                        if ($pex->getCode() == PHPMailer::STOP_CRITICAL && !$Email->PhpMailer->isServerError($pex)) {
                            $Emailed = self::SENT_FAIL;
                        } else {
                            $Emailed = self::SENT_ERROR;
                        }
                    } catch (Exception $Ex) {
                        switch ($Ex->getCode()) {
                            case Gdn_Email::ERR_SKIPPED:
                                $Emailed = self::SENT_SKIPPED;
                                break;
                            default:
                                $Emailed = self::SENT_FAIL;
                        }
                    }
                    try {
                        $this->SQL->put('Activity', ['Emailed' => $Emailed], ['ActivityID' => $Notification['ActivityID']]);
                    } catch (Exception $Ex) {
                        // Ignore an exception in a behind-the-scenes notification.
                    }
                }
            }
        }
        // Clear out the queue
        unset($this->_NotificationQueue);
        $this->_NotificationQueue = [];
    }