Seditio Source
Root |
./othercms/ips_4.3.4/applications/calendar/extensions/core/Notifications/Events.php
<?php
/**
 * @brief        Notification Options
 * @author        <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
 * @copyright    (c) Invision Power Services, Inc.
 * @license        https://www.invisioncommunity.com/legal/standards/
 * @package        Invision Community
 * @since        20 May 2016
 */

namespace IPS\calendar\extensions\core\Notifications;

/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
   
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
    exit;
}

/**
 * Notification Options
 */
class _Events
{
   
/**
     * Get configuration
     *
     * @param    \IPS\Member|null    $member    The member
     * @return    array
     */
   
public function getConfiguration( $member )
    {
        return array(
           
'event_reminder'    => array( 'default' => array( 'email' ), 'disabled' => array() ),
        );
    }
   
   
/**
     * Parse notification: new_content
     *
     * @param    \IPS\Notification\Inline    $notification    The notification
     * @return    array
     * @code
         return array(
             'title'        => "Mark has replied to A Topic",    // The notification title
             'url'        => new \IPS\Http\Url( ... ),        // The URL the notification should link to
             'content'    => "Lorem ipsum dolar sit",            // [Optional] Any appropriate content. Do not format this like an email where the text
                                                             // explains what the notification is about - just include any appropriate content.
                                                             // For example, if the notification is about a post, set this as the body of the post.
             'author'    =>  \IPS\Member::load( 1 ),            // [Optional] The user whose photo should be displayed for this notification
         );
     * @endcode
     */
   
public function parse_new_content( $notification )
    {
       
$item = $notification->item;
        if ( !
$item )
        {
            throw new \
OutOfRangeException;
        }

        return array(
           
'title'        => \IPS\Member::loggedIn()->language()->addToStack( 'notification__new_content', FALSE, array( 'sprintf' => array( $item->author()->name, mb_strtolower( $item->indefiniteArticle() ), $item->container()->_title, $item->mapped('title') ) ) ),
           
'url'        => $notification->item->url(),
           
'content'    => $notification->item->content(),
           
'author'    => $notification->item->author(),
           
'unread'    => (bool) ( $item->unread() )
        );
    }

   
/**
     * Parse notification: Event reminder
     *
     * @param    \IPS\Notification\Inline    $notification    The notification
     * @return    array
     * @code
    return array(
    'title'        => "Mark has replied to A Topic",    // The notification title
    'url'        => new \IPS\Http\Url( ... ),        // The URL the notification should link to
    'content'    => "Lorem ipsum dolar sit",            // [Optional] Any appropriate content. Do not format this like an email where the text
    // explains what the notification is about - just include any appropriate content.
    // For example, if the notification is about a post, set this as the body of the post.
    'author'    =>  \IPS\Member::load( 1 ),            // [Optional] The user whose photo should be displayed for this notification
    );
     * @endcode
     */
   
public function parse_event_reminder( $notification )
    {
       
$item = $notification->item;
        if ( !
$item )
        {
            throw new \
OutOfRangeException;
        }

        return array(
           
'title'        => \IPS\Member::loggedIn()->language()->addToStack( 'notification__event_reminder', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( "days_to_go", FALSE, array( 'pluralize' => array( $notification->extra['daysToGo'] ) ) ), $item->mapped('title') ) ) ),
           
'url'        => $notification->item->url(),
           
'content'    => $notification->item->content(),
           
'author'    => $notification->item->author(),
           
'unread'    => (bool) ( $item->unread() )
        );
    }
}