Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -49,7 +49,7 @@ class Rsvp extends AchievementActionAbstract // NOTE: Other classes exist to pro
|
||||
*/
|
||||
public function filters( ?array $filters, Url $url ): array
|
||||
{
|
||||
$return = array();
|
||||
$return = parent::filters( $filters, $url );
|
||||
|
||||
$return['nodes'] = new Node( 'achievement_filter_Rsvp_nodes', ( $filters and isset( $filters['nodes'] ) and $filters['nodes'] ) ? $filters['nodes'] : 0, FALSE, [
|
||||
'url' => $url,
|
||||
@@ -76,7 +76,7 @@ class Rsvp extends AchievementActionAbstract // NOTE: Other classes exist to pro
|
||||
*/
|
||||
public function formatFilterValues( array $values ): array
|
||||
{
|
||||
$return = [];
|
||||
$return = parent::formatFilterValues( $values );
|
||||
if ( isset( $values['achievement_filter_Rsvp_nodes'] ) )
|
||||
{
|
||||
$return['nodes'] = array_keys( $values['achievement_filter_Rsvp_nodes'] );
|
||||
@@ -149,6 +149,37 @@ class Rsvp extends AchievementActionAbstract // NOTE: Other classes exist to pro
|
||||
{
|
||||
return [ $extra->author() ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the member has already completed this rule.
|
||||
* Used for retroactive rule completion.
|
||||
* So far, this is only used in Quests, but may be used elsewhere at a later point.
|
||||
*
|
||||
* @param Member $member
|
||||
* @param array $filters
|
||||
* @return bool
|
||||
*/
|
||||
public function isRuleCompleted( Member $member, array $filters ) : bool
|
||||
{
|
||||
$where = [
|
||||
[ 'rsvp_member_id=?', $member->member_id ]
|
||||
];
|
||||
|
||||
if( !empty( $filters['nodes'] ) )
|
||||
{
|
||||
$where[] = [ Db::i()->in( 'event_calendar_id', $filters['nodes'] ) ];
|
||||
}
|
||||
|
||||
$total = Db::i()->select( 'count(*)', 'calendar_event_rsvp', $where )
|
||||
->join( 'calendar_events', 'rsvp_event_id=event_id' )->first();
|
||||
|
||||
if( !empty( $filters['milestone'] ) )
|
||||
{
|
||||
return $total >= $filters['milestone'];
|
||||
}
|
||||
|
||||
return $total > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier to prevent the member being awarded points for the same action twice
|
||||
@@ -202,7 +233,7 @@ class Rsvp extends AchievementActionAbstract // NOTE: Other classes exist to pro
|
||||
{
|
||||
$conditions[] = Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'milestone', Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone_nth', FALSE, [ 'pluralize' => [ $rule->filters['milestone'] ] ] ) )
|
||||
Theme::i()->getTemplate( 'achievements', 'core' )->ruleDescriptionBadge( 'milestone', Member::loggedIn()->language()->addToStack( 'achievements_title_filter_milestone_nth', FALSE, [ 'pluralize' => [ $rule->filters['milestone'] ] ] ) )
|
||||
],
|
||||
'sprintf' => [ Member::loggedIn()->language()->addToStack('rsvp') ]
|
||||
] );
|
||||
@@ -211,8 +242,12 @@ class Rsvp extends AchievementActionAbstract // NOTE: Other classes exist to pro
|
||||
{
|
||||
$conditions[] = $nodeCondition;
|
||||
}
|
||||
if( $questCondition = $this->_questFilterDescription( $rule ) )
|
||||
{
|
||||
$conditions[] = $questCondition;
|
||||
}
|
||||
|
||||
return Theme::i()->getTemplate( 'achievements' )->ruleDescription(
|
||||
return Theme::i()->getTemplate( 'achievements', 'core' )->ruleDescription(
|
||||
Member::loggedIn()->language()->addToStack( 'AchievementAction__Rsvp_title' ),
|
||||
$conditions
|
||||
);
|
||||
@@ -241,7 +276,7 @@ class Rsvp extends AchievementActionAbstract // NOTE: Other classes exist to pro
|
||||
{
|
||||
return Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location', FALSE, [
|
||||
'htmlsprintf' => [
|
||||
Theme::i()->getTemplate( 'achievements' )->ruleDescriptionBadge( 'location',
|
||||
Theme::i()->getTemplate( 'achievements', 'core' )->ruleDescriptionBadge( 'location',
|
||||
count( $nodeNames ) === 1 ? $nodeNames[0] : Member::loggedIn()->language()->addToStack( 'achievements_title_filter_location_val', FALSE, [ 'sprintf' => [
|
||||
count( $nodeNames ),
|
||||
Member::loggedIn()->language()->addToStack( 'calendars', FALSE, [ 'strtolower' => TRUE ] )
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace IPS\calendar\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use Exception;
|
||||
use IPS\calendar\Event;
|
||||
use IPS\calendar\Event\Comment;
|
||||
use IPS\calendar\Event\Review;
|
||||
@@ -117,20 +118,25 @@ class Calendar extends EditorLocationsAbstract
|
||||
*/
|
||||
public function attachmentLookup( ?int $id1=null, ?int $id2=null, ?string $id3=null ): Model|Content|Url|Member|null
|
||||
{
|
||||
if ( $id2 )
|
||||
try
|
||||
{
|
||||
if ( $id3 === 'review' )
|
||||
if( $id2 )
|
||||
{
|
||||
return Review::load( $id2 );
|
||||
}
|
||||
else
|
||||
if( $id3 === 'review' )
|
||||
{
|
||||
return Review::load( $id2 );
|
||||
}else
|
||||
{
|
||||
return Comment::load( $id2 );
|
||||
}
|
||||
}else
|
||||
{
|
||||
return Comment::load( $id2 );
|
||||
return Event::load( $id1 );
|
||||
}
|
||||
}
|
||||
else
|
||||
catch( Exception $e )
|
||||
{
|
||||
return Event::load( $id1 );
|
||||
throw new LogicException;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,17 +39,33 @@ class Events extends NotificationsAbstract
|
||||
*/
|
||||
public static function configurationOptions( Member $member = NULL ): array
|
||||
{
|
||||
return array(
|
||||
$return = array(
|
||||
'event_reminder' => array(
|
||||
'type' => 'standard',
|
||||
'notificationTypes' => array( 'event_reminder' ),
|
||||
'title' => 'notifications__calendar_Events',
|
||||
'showTitle' => FALSE,
|
||||
'description' => 'notifications__calendar_Events_desc',
|
||||
'title' => 'notifications__calendar_Reminders',
|
||||
'showTitle' => true,
|
||||
'description' => 'notifications__calendar_Reminders_desc',
|
||||
'default' => array( 'inline', 'push', 'email' ),
|
||||
'disabled' => array()
|
||||
)
|
||||
);
|
||||
|
||||
/* Can we create events? */
|
||||
if( $member === null or Event::canCreate( $member ) )
|
||||
{
|
||||
$return['event_rsvp'] = array(
|
||||
'type' => 'standard',
|
||||
'notificationTypes' => array( 'event_rsvp' ),
|
||||
'title' => 'notifications__calendar_Rsvp',
|
||||
'showTitle' => true,
|
||||
'description' => 'notifications__calendar_Rsvp_desc',
|
||||
'default' => array( 'inline', 'push', 'email' ),
|
||||
'disabled' => array()
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,4 +174,59 @@ class Events extends NotificationsAbstract
|
||||
'channelId' => 'events',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse notification: Event RSVPs
|
||||
*
|
||||
* @param Inline $notification The notification
|
||||
* @param bool $htmlEscape TRUE to escape HTML in title
|
||||
* @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_rsvp( Inline $notification, bool $htmlEscape=TRUE ): array
|
||||
{
|
||||
$item = $notification->item;
|
||||
if ( !$item )
|
||||
{
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
$member = Member::load( $notification->extra['member'] );
|
||||
|
||||
return array(
|
||||
'title' => Member::loggedIn()->language()->addToStack( 'notification__event_rsvp', FALSE, array( 'sprintf' => array( $member->name, $item->mapped( 'title' ) ) ) ),
|
||||
'url' => $notification->item->url(),
|
||||
'author' => $member
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse notification for mobile: event_reminder
|
||||
*
|
||||
* @param Lang $language The language that the notification should be in
|
||||
* @param Event $event The event the notification refers to
|
||||
* @param Member $member The member who RSVPd
|
||||
* @return array
|
||||
*/
|
||||
public static function parse_mobile_event_rsvp( Lang $language, Event $event, Member $member ): array
|
||||
{
|
||||
return array(
|
||||
'title' => $language->addToStack( 'notification__event_rsvp_title' ),
|
||||
'body' => $language->addToStack( 'notification__event_rsvp', FALSE, array( 'sprintf' => array( $member->name, $event->mapped('title') ) ) ),
|
||||
'data' => array(
|
||||
'url' => (string) $event->url(),
|
||||
'author' => $member
|
||||
),
|
||||
'channelId' => 'events',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user