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

File size: 1.64Kb
<?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;

/**
 * @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 PM extends AbstractNotify
{
	public function checkSendDate($notification, $preferences)
	{
        if($notification['date']<\XF::$time-$preferences['xc_feedback_notify_pm']['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_pm_type']*60*60)
        {
            // notification should be sent now
            return true;
        }

        return false;
    }

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


	    foreach ($items as $item) {
            $fromUser = \XF::em()->find('XF:User', [
                'user_id' => $item['fromuserid']
            ]);


            $creator = \XF::service('XF:Conversation\Creator', $fromUser);
            $creator->isAutomated();
            $creator->setRecipientsTrusted($user);
            $creator->setContent($item['review'], $item['review']);
            if (!$creator->validate()) {
                return;
            }
            $creator->save();


        }

    }

}