View file upload/src/addons/XenCentral/Feedback/NotificationQueue/Email.php

File size: 1.82Kb
<?php
/**
 * @package XenCentral Feedback System
 * @author DNF Technology
 * @copyright Drnoyan & Nalyan LDA, Portugal, EU
 * @license http://dnf.technology/terms/
 * @link http://customers.dnf.technology
 * @version 2.0.0 Beta 10
 * @revision 12
 */

namespace XenCentral\Feedback\NotificationQueue;
use XF\Db\Exception;

/**
 * @package XenCentral Feedback System
 * @author DNF Technology
 * @copyright Drnoyan & Nalyan LDA, Portugal, EU
 * @license http://dnf.technology/terms/
 * @link http://customers.dnf.technology
 * @version 1.7.1
 * @revision 98
 */

class Email extends AbstractNotify
{
	public function checkSendDate($notification, $preferences)
	{
        if($notification['date']<\XF::$time-$preferences['xc_feedback_notify_email']['type']*60*60)
		{
			// notification should be sent now
			return true;
		}

		return false;
	}
    public function checkSendAdminDate($notification, $preferences)
    {
        if($notification['date']<\XF::$time-$preferences['xc_feedback_admin_notify_email_type']*60*60)
        {
            // notification should be sent now
            return true;
        }

        return false;
    }


    public function send($user, $items, $postfix='')
	{

        $allFeedback=$this->_makeUnique($items, 'fb_id');

        if(empty($allFeedback))
        {
            return;
        }

        $feedbackCount=count($allFeedback);

        $allFeedback=array_map(array($this, '_populateFeedbackLink'), $allFeedback);

        $params = array(
            'user' => $user,
            'boardTitle' => $boardTitle = \XF::options()->boardTitle,
            'allFeedback'=> $allFeedback,
            'feedbackCount'=>$feedbackCount
        );


        \XF::app()->mailer()->newMail()
            ->setToUser($user)
            ->setTemplate('xcfs_new_feedback_queue'. $postfix, $params)
            ->queue();

	}

}