<?php if (!defined('VB_ENTRY')) die('Access denied.'); abstract class vB_Notification_UserRelation extends vB_Notification { protected static $updateEvents = array( 'visited_user_profile', 'deleted_user', 'merged_user', ); const GUESTS_CAN_SEND = false; const TYPENAME = 'UserRelation'; protected function validateProvidedRecipients($recipients) { if (empty($recipients)) { throw new Exception("Missing recipients"); } return parent::validateProvidedRecipients($recipients); } final protected function validateAndCleanNotificationData($notificationData) { $newData = parent::validateAndCleanNotificationData($notificationData); unset($notificationData); if (!isset($newData['sender'])) { throw new Exception("Missing Notification Data: sender"); } if (empty($newData['sender'])) { throw new Exception("Invalid Notification Data: sender"); } $newData['sentbynodeid'] = NULL; return $newData; } protected function overwriteRule() { return 'if_read'; } final protected static function defineUnique($notificationData, $skipValidation) { return array('sender' => (int) $notificationData['sender']); } public static function handleUpdateEvents($event, $eventData) { if (!static::validateUpdateEvent($event)) { return false; } $types = vB_Library::instance('Notification')->getNotificationTypes(); $typeid = $types[static::TYPENAME]['typeid']; $assertor = vB::getDbAssertor(); switch($event) { case 'deleted_user': $userid = (int) $eventData['userid']; $check = $assertor->getRow('user', array('userid' => $userid)); if (empty($check)) { $assertor->assertQuery( 'vBForum:notification', array( vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'recipient' => $userid, 'typeid' => $typeid ) ); $assertor->assertQuery( 'vBForum:notification', array( vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_DELETE, 'sender' => $userid, 'typeid' => $typeid ) ); } break; default: break; } return; } protected function filterRecipients() { return; } } 