public static function sendNotification($fromMember, $toMember, $messageId) { $rootPath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot(); $url = $rootPath . '/message/read/' . $messageId; $message = sfContext::getInstance()->getI18n()->__('There are new %d messages!', array('%d' => 1)); opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'message', 'url' => $url, 'icon_url' => null)); }
public static function sendNotification($fromMember, $toMember, $diaryId) { $url = '/diary/' . $diaryId; sfApplicationConfiguration::getActive()->loadHelpers(array('I18N')); $message = format_number_choice('[1]1 diary has new comments|(1,Inf]%1% diaries have new comments', array('%1%' => '1'), 1); opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'other', 'url' => $url, 'icon_url' => null)); }
public static function sendNewCommentNotification($fromMember, $toMember, $topicId) { $rootPath = sfContext::getInstance()->getRequest()->getRelativeUrlRoot(); $url = $rootPath . '/communityTopic/' . $topicId; sfApplicationConfiguration::getActive()->loadHelpers(array('I18N')); $message = format_number_choice('[1]1 topic has new comments|(1,Inf]%1% topics have new comments', array('%1%' => '1'), 1); opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'other', 'url' => $url, 'icon_url' => null)); }
public static function hasScreenName($body) { preg_match_all('/(@+)([-._0-9A-Za-z]+)/', $body, $matches); if ($matches[2]) { $memberIds = array(); foreach ($matches[2] as $screenName) { $member = Doctrine::getTable('MemberConfig')->findOneByNameAndValue('op_screen_name', $screenName); if ($member) { $memberIds[] = $member->getMemberId(); $memberObject = Doctrine::getTable('Member')->find($member->getMemberId()); opNotificationCenter::notify(sfContext::getInstance()->getUser()->getMember(), $memberObject, $body, array('category' => 'other', 'url' => url_for('@member_timeline?id=' . sfContext::getInstance()->getUser()->getMemberId()))); } } $memberId = implode("|", $memberIds); return '|' . $memberId . '|'; } else { return null; } }
public static function sendNotification($fromMember, $toMember, $url = null) { $message = sfContext::getInstance()->getI18n()->__('%member% says that it is Like.', array('%member%' => $fromMember->getName())); opNotificationCenter::notify($fromMember, $toMember, $message, array('category' => 'other', 'url' => $url, 'icon_url' => null)); }
//============================================================================== $t->diag('opNotificationCenter::getNotifications()'); $t->info('empty value'); $conn->beginTransaction(); $notifications = opNotificationCenter::getNotifications($member2); $t->ok(is_array($notifications)); $t->is(count($notifications), 0); $conn->rollback(); $t->info('check format'); $conn->beginTransaction(); opNotificationCenter::notify($member1, $member2, 'hogehoge'); $notifications = opNotificationCenter::getNotifications($member2); $t->ok(is_array($notifications)); $t->is(count($notifications), 1); $t->ok(is_string($notifications[0]['id'])); $t->is($notifications[0]['body'], 'hogehoge'); $t->is($notifications[0]['member_id_from'], 1); $t->is($notifications[0]['unread'], true); $t->is($notifications[0]['category'], 'other'); $t->is($notifications[0]['url'], null); $t->is($notifications[0]['icon_url'], null); $conn->rollback(); $t->info('2 notifications'); $conn->beginTransaction(); opNotificationCenter::notify($member1, $member2, 'notify1'); opNotificationCenter::notify($member1, $member2, 'notify2'); $notifications = opNotificationCenter::getNotifications($member2); $t->is(count($notifications), 2); $t->is($notifications[0]['body'], 'notify2'); $t->is($notifications[1]['body'], 'notify1'); $conn->rollback();
public function postSave($event) { if ($this->isFriendPreFrom()) { opNotificationCenter::notify($this->getMemberRelatedByMemberIdFrom(), $this->getMember(), 'Do you accept friend request?', array('category' => 'link')); } }