Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Notification;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -139,7 +139,7 @@ class _Inline extends \IPS\Patterns\ActiveRecord
|
||||
public function set_item( $item )
|
||||
{
|
||||
$idColumn = $item::$databaseColumnId;
|
||||
$this->_data['item_class'] = get_class( $item );
|
||||
$this->_data['item_class'] = \get_class( $item );
|
||||
$this->_data['item_id'] = $item->$idColumn;
|
||||
}
|
||||
|
||||
@@ -224,10 +224,11 @@ class _Inline extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Get data from extension
|
||||
*
|
||||
* @param bool $htmlEscape TRUE to escape HTML
|
||||
* @return array
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getData()
|
||||
public function getData( $htmlEscape = TRUE )
|
||||
{
|
||||
$method = "parse_{$this->notification_key}";
|
||||
|
||||
@@ -235,7 +236,7 @@ class _Inline extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
if ( method_exists( $class, $method ) )
|
||||
{
|
||||
$return = $class->$method( $this );
|
||||
$return = $class->$method( $this, $htmlEscape );
|
||||
|
||||
if ( !isset( $return['unread'] ) )
|
||||
{
|
||||
@@ -247,4 +248,66 @@ class _Inline extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
throw new \RuntimeException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse string notificationType The type (key) of notification sent
|
||||
* @apiresponse string notificationApp The app that processes this type of notification
|
||||
* @apiresponse string itemClass The class that triggered the notification
|
||||
* @apiresponse int itemId The ID of the content that triggered the notification
|
||||
* @apiresponse string subItemClass The sub-class that triggered the notification (e.g. for comments or reviews)
|
||||
* @apiresponse int subItemId The sub-ID of the content that triggered the notification (e.g. for comments or reviews)
|
||||
* @apiresponse object|null item A representation of the item being notified about (if supported), or null
|
||||
* @apiresponse object|null itemSub A representation of the subitem being notified about (if supported), or null
|
||||
* @apiresponse datetime sentDate Date and time the notification was sent
|
||||
* @apiresponse datetime updatedDate Date and time the notification was last updated
|
||||
* @apiresponse datetime|null readDate Date and time the notification was read by the user
|
||||
* @apiresponse array notificationData Array of additional data relevant to this specific notification
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
try
|
||||
{
|
||||
$ourData = $this->getData();
|
||||
}
|
||||
catch( \LogicException $e )
|
||||
{
|
||||
$ourData = array();
|
||||
}
|
||||
|
||||
return array(
|
||||
'notificationType' => $this->notification_key,
|
||||
'notificationApp' => $this->notification_app->directory,
|
||||
'itemClass' => $this->item_class,
|
||||
'itemId' => $this->item_id,
|
||||
'subItemClass' => $this->item_sub_class,
|
||||
'subItemId' => $this->item_sub_id,
|
||||
'item' => ( $this->item AND method_exists( $this->item, 'apiOutput' ) ) ? $this->item->apiOutput( $authorizedMember ) : NULL,
|
||||
'itemSub' => ( $this->item_sub AND method_exists( $this->item_sub, 'apiOutput' ) ) ? $this->item_sub->apiOutput( $authorizedMember ) : NULL,
|
||||
'sentDate' => $this->sent_time->rfc3339(),
|
||||
'updatedDate' => $this->updated_time->rfc3339(),
|
||||
'readDate' => $this->read_time ? \IPS\DateTime::ts( $this->read_time )->rfc3339() : NULL,
|
||||
'notificationData' => array_map( function( $val ) {
|
||||
if( $val instanceof \IPS\Http\Url )
|
||||
{
|
||||
return (string) $val;
|
||||
}
|
||||
elseif( $val instanceof \IPS\Member )
|
||||
{
|
||||
return $val->apiOutput();
|
||||
}
|
||||
elseif( $val instanceof \IPS\DateTime )
|
||||
{
|
||||
return $val->rfc3339();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $val;
|
||||
}
|
||||
}, $ourData )
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user