We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

New Console Notifications API | Forum

Michael I.
Michael I. Dec 27 '12

Interface of notifications actions registration had changed:

Event renamed from base.notify_actions to notifications.collect_actions

With the new console functionality of adding notifications has been modified.

Old interface:

$event = new OW_Event('base.notify', array(

   'plugin' => 'base',

   'action' => 'base_add_user_comment', // Label/Name of notification action which was added by base.notify_actions event in previous version

   'userId' => $userId, // User - recipient of notification

   'string' => OW::getLanguage()->text('base', 'profile_comment_notification'), // Text string that is displayed in a console and email notification as a title

   'content' => $comment->getMessage(), // Text string that is displayed in email notification only under the title

   'url' => BOL_UserService::getInstance()->getUserUrl($comment->getUserId()), // URL which will be set for notification in console and email

   'avatar' => BOL_AvatarService::getInstance()->getAvatarUrl($comment->getUserId()), // User avatar from whom notification is sent



Current interface:

$event = new OW_Event('notifications.add', array(

   'pluginKey' => 'base',

   'entityType' => 'base_profile_wall', // Notification type unique ID

   'entityId' => $comment->getId(), // Unique identifier of entity's notification (creates an unique linkage with entityType)

   'action' => 'base_add_user_comment', // Notification action that was added by notifications.collect_actions event before/earlier

   'userId' => $userId, // User - recipient of notification

   'time' => $comment->getCreateStamp() // Notification time

), array(

   'avatar' => $avatar, // User avatar (not just an image, it is an array received using BOL_AvatarService::getInstance()->getDataForUserAvatars($userIdList);) from whom notification is sent


* Parameter ‘string’ can receive a string which will be added to the ‘notifications’ database table. It will be added in user’s current language and will not be translated after switching languages.

Also an ‘delayed language string localization’ array can be received: it allows to store a string with variables or any specified variable in the ‘notifications’ database table. Variables’ values will be changed to actual values every time a page is opened. An example of ‘delayed language string localization’ array:

* array( 

*      'key' => 'base+profile_comment_notification', // Language key

*      'vars' => array( // Variables that will be used in the lang key's value (for example) 

*          'userName' => BOL_UserService::getInstance()->getDisplayName($comment->getUserId()),

*          'userUrl' => BOL_UserService::getInstance()->getUserUrl($comment->getUserId()),

*          'profileUrl' => BOL_UserService::getInstance()->getUserUrl($comment->getUserId())

*      )

   'string' => array(

       'key' => 'base+profile_comment_notification',

       'vars' => array(

           'userName' => BOL_UserService::getInstance()->getDisplayName($comment->getUserId()),

           'userUrl' => BOL_UserService::getInstance()->getUserUrl($comment->getUserId()),

           'profileUrl' => BOL_UserService::getInstance()->getUserUrl($comment->getUserId())



   'content' => $comment->getMessage(), // Notification content that is displayed only in emails, not in the console 

   'url' => BOL_UserService::getInstance()->getUserUrl($comment->getUserId()), // URL which will be set for notification in console and email

   'contentImage' => array( // Image entity that is associated with notification (photo, user's avatar, etc.)

       'src' => [image src],

       'url' => [image link url],

       'title' => [image title]




This topic is sticky
This topic is locked