Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -221,7 +221,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
{
|
||||
if ( !$m instanceof \IPS\Member OR !static::memberCanReceiveNewMessage( $m, \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('meesnger_err_bad_recipient', FALSE, array( 'sprintf' => array( $m ) ) ) );
|
||||
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('meesnger_err_bad_recipient', FALSE, array( 'sprintf' => array( ( $m instanceof \IPS\Member ) ? $m->name : $m ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
else
|
||||
{
|
||||
/* Ensure that the autosave doesn't populate the editor witha previous PM which may be sent by accident */
|
||||
$v->options['autoSaveKey'] = 'newMessageTo-' . uniqid();
|
||||
$v->options['autoSaveKey'] = 'newMessageTo-' . mt_rand();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
*
|
||||
* @param \IPS\Member $member The member to check
|
||||
* @param \IPS\Member $sender The member sending the new message
|
||||
* @return array
|
||||
* @return bool
|
||||
*/
|
||||
public static function memberCanReceiveNewMessage( \IPS\Member $member, \IPS\Member $sender )
|
||||
{
|
||||
@@ -505,9 +505,10 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Get the most recent unread conversation and dismiss the popup
|
||||
*
|
||||
* @return \IPS\Conversation|NULL
|
||||
* @param bool $dismiss Whether or not to dismiss the popup for future page loads
|
||||
* @return \IPS\core\Messenger\Conversation|NULL
|
||||
*/
|
||||
public static function latestUnreadConversation()
|
||||
public static function latestUnreadConversation( $dismiss = TRUE )
|
||||
{
|
||||
$return = NULL;
|
||||
$latestConversationMap = \IPS\Db::i()->select( 'map_topic_id', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1 AND map_has_unread=1 AND map_ignore_notification=0', \IPS\Member::loggedIn()->member_id ), 'map_last_topic_reply DESC' );
|
||||
@@ -519,11 +520,39 @@ class _Conversation extends \IPS\Content\Item
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
\IPS\Member::loggedIn()->msg_show_notification = FALSE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
if( $dismiss === TRUE )
|
||||
{
|
||||
\IPS\Member::loggedIn()->msg_show_notification = FALSE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent unread message and dismiss the popup
|
||||
*
|
||||
* @note This is here and abstracted to account for database read/write separation where the conversation may be available, but not the message itself
|
||||
* @return \IPS\core\Messenger\Message|NULL
|
||||
*/
|
||||
public static function latestUnreadMessage()
|
||||
{
|
||||
/* Get the latest conversation, but don't dismiss the notification yet */
|
||||
if( $conversation = static::latestUnreadConversation( FALSE ) )
|
||||
{
|
||||
/* Get the latest comment, which is what we will actually use in the template */
|
||||
if( $latestComment = $conversation->comments( 1, 0, 'date', 'desc' ) )
|
||||
{
|
||||
/* Ok we have what we need, NOW dismiss the notification */
|
||||
\IPS\Member::loggedIn()->msg_show_notification = FALSE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
return $latestComment;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount the member's message counts
|
||||
|
||||
Reference in new issue
Block a user