Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,50 +12,74 @@ namespace IPS\core\Messenger;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application\Module;
|
||||
use IPS\Content\Comment;
|
||||
use IPS\Content\Item;
|
||||
use IPS\core\Alerts\Alert;
|
||||
use IPS\core\Reports\Report;
|
||||
use IPS\core\Warnings\Warning;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Member as FormMember;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_int;
|
||||
|
||||
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' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Personal Conversation Model
|
||||
*/
|
||||
class _Conversation extends \IPS\Content\Item
|
||||
class Conversation extends Item
|
||||
{
|
||||
/* !\IPS\Patterns\ActiveRecord */
|
||||
|
||||
/**
|
||||
* @brief Database Table
|
||||
*/
|
||||
public static $databaseTable = 'core_message_topics';
|
||||
public static ?string $databaseTable = 'core_message_topics';
|
||||
|
||||
/**
|
||||
* @brief Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'mt_';
|
||||
public static string $databasePrefix = 'mt_';
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Item] Include the ability to search this content item in global site searches
|
||||
*/
|
||||
public static $includeInSiteSearch = FALSE;
|
||||
public static bool $includeInSiteSearch = FALSE;
|
||||
|
||||
/**
|
||||
* @brief [Content\Item] Include these items in trending content
|
||||
*/
|
||||
public static $includeInTrending = FALSE;
|
||||
public static bool $includeInTrending = FALSE;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Icon
|
||||
*/
|
||||
public static $icon = 'envelope';
|
||||
public static string $icon = 'envelope';
|
||||
|
||||
/**
|
||||
* Should IndexNow be skipped for this item? Can be used to prevent that Private Messages,
|
||||
@@ -67,17 +91,17 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Check posts per day limits? Useful for things that use the content system, but aren't necessarily content themselves.
|
||||
*/
|
||||
public static $checkPostsPerDay = FALSE;
|
||||
public static bool $checkPostsPerDay = FALSE;
|
||||
|
||||
/**
|
||||
* Delete Record
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete(): void
|
||||
{
|
||||
parent::delete();
|
||||
\IPS\Db::i()->delete( 'core_message_topic_user_map', array( 'map_topic_id=?', $this->id ) );
|
||||
Db::i()->delete( 'core_message_topic_user_map', array( 'map_topic_id=?', $this->id ) );
|
||||
}
|
||||
|
||||
/* !\IPS\Content\Item */
|
||||
@@ -85,12 +109,12 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'personal_conversation';
|
||||
public static string $title = 'personal_conversation';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'title' => 'title',
|
||||
'date' => array( 'date', 'start_time', 'last_post_time' ),
|
||||
'author' => 'starter_id',
|
||||
@@ -102,48 +126,48 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'core';
|
||||
public static string $application = 'core';
|
||||
|
||||
/**
|
||||
* @brief Module
|
||||
*/
|
||||
public static $module = 'messaging';
|
||||
public static string $module = 'messaging';
|
||||
|
||||
/**
|
||||
* @brief Language prefix for forms
|
||||
*/
|
||||
public static $formLangPrefix = 'messenger_';
|
||||
public static string $formLangPrefix = 'messenger_';
|
||||
|
||||
/**
|
||||
* @brief Comment Class
|
||||
*/
|
||||
public static $commentClass = 'IPS\core\Messenger\Message';
|
||||
public static ?string $commentClass = 'IPS\core\Messenger\Message';
|
||||
|
||||
/**
|
||||
* @brief [Content\Item] First "comment" is part of the item?
|
||||
*/
|
||||
public static $firstCommentRequired = TRUE;
|
||||
public static bool $firstCommentRequired = TRUE;
|
||||
|
||||
/**
|
||||
* Should posting this increment the poster's post count?
|
||||
*
|
||||
* @param \IPS\Node\Model|NULL $container Container
|
||||
* @return void
|
||||
* @param Model|NULL $container Container
|
||||
* @return bool
|
||||
*/
|
||||
public static function incrementPostCount( \IPS\Node\Model $container = NULL )
|
||||
public static function incrementPostCount( ?Model $container = NULL ): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Can a given member create this type of content?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Node\Model $container Container (e.g. forum) ID, if appropriate
|
||||
* @param bool $showError If TRUE, rather than returning a boolean value, will display an error
|
||||
* @return bool
|
||||
* @param Member $member The member
|
||||
* @param Model|null $container Container (e.g. forum) ID, if appropriate
|
||||
* @param bool $showError If TRUE, rather than returning a boolean value, will display an error
|
||||
* @return bool
|
||||
*/
|
||||
public static function canCreate( \IPS\Member $member, \IPS\Node\Model $container=NULL, $showError=FALSE )
|
||||
public static function canCreate( Member $member, ?Model $container=NULL, bool $showError=FALSE ) : bool
|
||||
{
|
||||
/* Can we access the module? */
|
||||
if ( !parent::canCreate( $member, $container, $showError ) )
|
||||
@@ -156,7 +180,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
{
|
||||
if ( $showError )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission_guest', '1C149/1', 403, '' );
|
||||
Output::i()->error( 'no_module_permission_guest', '1C149/1', 403, '' );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -164,31 +188,31 @@ class _Conversation extends \IPS\Content\Item
|
||||
|
||||
/* If this conversation is associated with an alert, skip the
|
||||
rest of the permission checks, the user should be able to reply */
|
||||
if ( isset( \IPS\Request::i()->alert ) )
|
||||
if ( isset( Request::i()->alert ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$alert = \IPS\core\Alerts\Alert::load( \IPS\Request::i()->alert );
|
||||
$alert = Alert::load( Request::i()->alert );
|
||||
|
||||
if( $alert->forMember( \IPS\Member::loggedIn() ) AND $alert->reply == Alert::REPLY_REQUIRED )
|
||||
if( $alert->forMember( Member::loggedIn() ) AND $alert->reply == 2 )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
catch ( OutOfRangeException $e ) {}
|
||||
}
|
||||
|
||||
/* Have we exceeded our limit for the day/minute? */
|
||||
if ( $member->group['g_pm_perday'] !== -1 )
|
||||
{
|
||||
$messagesSentToday = \IPS\Db::i()->select( 'COUNT(*) AS count, MAX(mt_date) AS max', 'core_message_topics', array( 'mt_starter_id=? AND mt_date>?', $member->member_id, \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) )->getTimeStamp() ) )->first();
|
||||
$messagesSentToday = Db::i()->select( 'COUNT(*) AS count, MAX(mt_date) AS max', 'core_message_topics', array( 'mt_starter_id=? AND mt_date>?', $member->member_id, DateTime::create()->sub( new DateInterval( 'P1D' ) )->getTimeStamp() ) )->first();
|
||||
if ( $messagesSentToday['count'] >= $member->group['g_pm_perday'] )
|
||||
{
|
||||
$next = \IPS\DateTime::ts( $messagesSentToday['max'] )->add( new \DateInterval( 'P1D' ) );
|
||||
$next = DateTime::ts( $messagesSentToday['max'] )->add( new DateInterval( 'P1D' ) );
|
||||
|
||||
if ( $showError )
|
||||
{
|
||||
\IPS\Output::i()->error( $member->language()->addToStack( 'err_too_many_pms_day', FALSE, array( 'pluralize' => array( $member->group['g_pm_perday'] ) ) ), '1C149/2', 429, '', array( 'Retry-After' => $next->format('r') ) );
|
||||
Output::i()->error( $member->language()->addToStack( 'err_too_many_pms_day', FALSE, array( 'pluralize' => array( $member->group['g_pm_perday'] ) ) ), '1C149/2', 429, '', array( 'Retry-After' => $next->format('r') ) );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -196,12 +220,12 @@ class _Conversation extends \IPS\Content\Item
|
||||
}
|
||||
if ( $member->group['g_pm_flood_mins'] !== -1 )
|
||||
{
|
||||
$messagesSentThisMinute = \IPS\Db::i()->select( 'COUNT(*)', 'core_message_topics', array( 'mt_starter_id=? AND mt_date>?', $member->member_id, \IPS\DateTime::create()->sub( new \DateInterval( 'PT1M' ) )->getTimeStamp() ) )->first();
|
||||
$messagesSentThisMinute = Db::i()->select( 'COUNT(*)', 'core_message_topics', array( 'mt_starter_id=? AND mt_date>?', $member->member_id, DateTime::create()->sub( new DateInterval( 'PT1M' ) )->getTimeStamp() ) )->first();
|
||||
if ( $messagesSentThisMinute >= $member->group['g_pm_flood_mins'] )
|
||||
{
|
||||
if ( $showError )
|
||||
{
|
||||
\IPS\Output::i()->error( $member->language()->addToStack( 'err_too_many_pms_minute', FALSE, array( 'pluralize' => array( $member->group['g_pm_flood_mins'] ) ) ), '1C149/3', 429, '', array( 'Retry-After' => 3600 ) );
|
||||
Output::i()->error( $member->language()->addToStack( 'err_too_many_pms_minute', FALSE, array( 'pluralize' => array( $member->group['g_pm_flood_mins'] ) ) ), '1C149/3', 429, '', array( 'Retry-After' => 3600 ) );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -211,12 +235,12 @@ class _Conversation extends \IPS\Content\Item
|
||||
/* Is our inbox full? */
|
||||
if ( $member->group['g_max_messages'] !== -1 )
|
||||
{
|
||||
$messagesInInbox = \IPS\Db::i()->select( 'COUNT(*)', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1', $member->member_id ) )->first();
|
||||
$messagesInInbox = Db::i()->select( 'COUNT(*)', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1', $member->member_id ) )->first();
|
||||
if ( $messagesInInbox > $member->group['g_max_messages'] )
|
||||
{
|
||||
if ( $showError )
|
||||
{
|
||||
\IPS\Output::i()->error( 'err_inbox_full', '1C149/4', 403, '' );
|
||||
Output::i()->error( 'err_inbox_full', '1C149/4', 403, '' );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -229,22 +253,22 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Can Merge?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param Member|null $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canMerge( $member=NULL )
|
||||
public function canMerge( Member|null $member=null ): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get elements for add/edit form
|
||||
*
|
||||
* @param \IPS\Content\Item|NULL $item The current item if editing or NULL if creating
|
||||
* @param int $container Container (e.g. forum) ID, if appropriate
|
||||
* @return array
|
||||
* @param Item|NULL $item The current item if editing or NULL if creating
|
||||
* @param Model|null $container Container (e.g. forum) ID, if appropriate
|
||||
* @return array
|
||||
*/
|
||||
public static function formElements( $item=NULL, \IPS\Node\Model $container=NULL )
|
||||
public static function formElements( Item|null $item=NULL, Model|null $container=NULL ): array
|
||||
{
|
||||
$return = array();
|
||||
foreach ( parent::formElements( $item, $container ) as $k => $v )
|
||||
@@ -255,9 +279,9 @@ class _Conversation extends \IPS\Content\Item
|
||||
{
|
||||
$member = NULL;
|
||||
|
||||
if( \IPS\Request::i()->to )
|
||||
if( Request::i()->to )
|
||||
{
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->to );
|
||||
$member = Member::load( Request::i()->to );
|
||||
|
||||
if( !$member->member_id )
|
||||
{
|
||||
@@ -265,23 +289,23 @@ class _Conversation extends \IPS\Content\Item
|
||||
}
|
||||
}
|
||||
|
||||
$return['to'] = new \IPS\Helpers\Form\Member( 'messenger_to', $member, TRUE, array( 'disabled' => ( \IPS\Request::i()->alert ) ? TRUE : FALSE, 'multiple' => ( \IPS\Member::loggedIn()->group['g_max_mass_pm'] == -1 ) ? NULL : \IPS\Member::loggedIn()->group['g_max_mass_pm'] ), function ( $members )
|
||||
$return['to'] = new FormMember( 'messenger_to', $member, TRUE, array( 'disabled' => (bool)Request::i()->alert, 'multiple' => ( Member::loggedIn()->group['g_max_mass_pm'] == -1 ) ? NULL : Member::loggedIn()->group['g_max_mass_pm'] ), function ( $members )
|
||||
{
|
||||
if ( \is_array( $members ) )
|
||||
if ( is_array( $members ) )
|
||||
{
|
||||
foreach ( $members as $m )
|
||||
{
|
||||
if ( !$m instanceof \IPS\Member OR !static::memberCanReceiveNewMessage( $m, \IPS\Member::loggedIn(), 'new' ) )
|
||||
if ( !$m instanceof Member OR !static::memberCanReceiveNewMessage( $m, Member::loggedIn(), 'new' ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('meesnger_err_bad_recipient', FALSE, array( 'sprintf' => array( ( $m instanceof \IPS\Member ) ? $m->name : $m ) ) ) );
|
||||
throw new InvalidArgumentException( Member::loggedIn()->language()->addToStack('meesnger_err_bad_recipient', FALSE, array( 'sprintf' => array( ( $m instanceof Member ) ? $m->name : $m ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !$members instanceof \IPS\Member OR !$members->member_id OR !static::memberCanReceiveNewMessage( $members, \IPS\Member::loggedIn(), 'new' ) )
|
||||
if ( !$members instanceof Member OR !$members->member_id OR !static::memberCanReceiveNewMessage( $members, Member::loggedIn(), 'new' ) )
|
||||
{
|
||||
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('meesnger_err_bad_recipient', FALSE, array( 'sprintf' => array( ( $members instanceof \IPS\Member ) ? $members->name : $members ) ) ) );
|
||||
throw new InvalidArgumentException( Member::loggedIn()->language()->addToStack('meesnger_err_bad_recipient', FALSE, array( 'sprintf' => array( ( $members instanceof Member ) ? $members->name : $members ) ) ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
@@ -289,9 +313,9 @@ class _Conversation extends \IPS\Content\Item
|
||||
}
|
||||
else if ( $k == 'content' )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->to ) and \IPS\Request::i()->to )
|
||||
if( isset( Request::i()->to ) and Request::i()->to )
|
||||
{
|
||||
$v->options['autoSaveKey'] = 'newMessageTo-' . \IPS\Request::i()->to;
|
||||
$v->options['autoSaveKey'] = 'newMessageTo-' . Request::i()->to;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -303,7 +327,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
$return[ $k ] = $v;
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->alert )
|
||||
if( Request::i()->alert )
|
||||
{
|
||||
unset( $return['title'] );
|
||||
}
|
||||
@@ -315,13 +339,13 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Check if a member can receive new messages
|
||||
*
|
||||
* @param \IPS\Member $member The member to check
|
||||
* @param \IPS\Member $sender The member sending the new message
|
||||
* @param Member $member The member to check
|
||||
* @param Member $sender The member sending the new message
|
||||
* @param string $type Type of message to check (new, reply)
|
||||
|
||||
* @return bool
|
||||
*/
|
||||
public static function memberCanReceiveNewMessage( \IPS\Member $member, \IPS\Member $sender, $type='new' )
|
||||
public static function memberCanReceiveNewMessage( Member $member, Member $sender, string $type='new' ) : bool
|
||||
{
|
||||
/* Messenger is hard disabled */
|
||||
if ( $member->members_disable_pm == 2 )
|
||||
@@ -335,7 +359,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
}
|
||||
|
||||
/* Group can not use messenger */
|
||||
if ( !$member->canAccessModule( \IPS\Application\Module::get( 'core', 'messaging' ) ) )
|
||||
if ( !$member->canAccessModule( Module::get( 'core', 'messaging' ) ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -359,13 +383,13 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Process created object BEFORE the object has been created
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
protected function processBeforeCreate( $values )
|
||||
protected function processBeforeCreate( array $values ): void
|
||||
{
|
||||
$this->maps = array();
|
||||
$this->to_count = ( $values['messenger_to'] instanceof \IPS\Member ) ? 1 : \count( $values['messenger_to'] );
|
||||
$this->to_count = ( $values['messenger_to'] instanceof Member ) ? 1 : count( $values['messenger_to'] );
|
||||
|
||||
parent::processBeforeCreate( $values );
|
||||
}
|
||||
@@ -373,17 +397,17 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Process created object AFTER the object has been created
|
||||
*
|
||||
* @param \IPS\Content\Comment|NULL $comment The first comment
|
||||
* @param array $values Values from form
|
||||
* @param Comment|null $comment The first comment
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
protected function processAfterCreate( $comment, $values )
|
||||
protected function processAfterCreate( ?Comment $comment, array $values ): void
|
||||
{
|
||||
/* Set the first message ID */
|
||||
$this->first_msg_id = $comment->id;
|
||||
$this->save();
|
||||
|
||||
if ( \is_array( $values['messenger_to'] ) )
|
||||
if ( is_array( $values['messenger_to'] ) )
|
||||
{
|
||||
$members = array_map( function( $member )
|
||||
{
|
||||
@@ -407,13 +431,13 @@ class _Conversation extends \IPS\Content\Item
|
||||
$comment->sendNotifications();
|
||||
|
||||
/* If this came from an alert dismiss the alert */
|
||||
if( \IPS\Request::i()->alert )
|
||||
if( Request::i()->alert )
|
||||
{
|
||||
try
|
||||
{
|
||||
$alert = \IPS\core\Alerts\Alert::load( \IPS\Request::i()->alert );
|
||||
$alert = Alert::load( Request::i()->alert );
|
||||
|
||||
if( $alert->forMember( \IPS\Member::loggedIn() ) )
|
||||
if( $alert->forMember( Member::loggedIn() ) )
|
||||
{
|
||||
$alert->dismiss();
|
||||
|
||||
@@ -421,19 +445,19 @@ class _Conversation extends \IPS\Content\Item
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ){}
|
||||
catch ( Exception $e ){}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does a member have permission to access?
|
||||
*
|
||||
* @param \IPS\Member $member The member to check for
|
||||
* @return bool
|
||||
* @param Member|null $member The member to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function canView( $member=NULL )
|
||||
public function canView( ?Member $member=null ): bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
|
||||
/* Is the user part of the conversation? */
|
||||
foreach ( $this->maps() as $map )
|
||||
@@ -448,40 +472,40 @@ class _Conversation extends \IPS\Content\Item
|
||||
if ( $member->modPermission('can_view_reports') )
|
||||
{
|
||||
/* If we are coming directly from a report, and the Report ID is different from what is stored in session, then we need to unset it so it can be reset */
|
||||
if ( isset( $_SESSION['report'] ) AND isset( \IPS\Request::i()->_report ) AND \IPS\Request::i()->_report != $_SESSION['report'] )
|
||||
if ( isset( $_SESSION['report'] ) AND isset( Request::i()->_report ) AND Request::i()->_report != $_SESSION['report'] )
|
||||
{
|
||||
unset( $_SESSION['report'] );
|
||||
}
|
||||
|
||||
$report = isset( $_SESSION['report'] ) ? $_SESSION['report'] : ( isset( \IPS\Request::i()->_report ) ? \IPS\Request::i()->_report : NULL );
|
||||
$report = $_SESSION['report'] ?? ( isset( Request::i()->_report ) ? Request::i()->_report : NULL );
|
||||
if ( $report )
|
||||
{
|
||||
try
|
||||
{
|
||||
$report = \IPS\core\Reports\Report::load( $report );
|
||||
if ( $report->class == 'IPS\core\Messenger\Message' and \in_array( $report->content_id, iterator_to_array( \IPS\Db::i()->select( 'msg_id', 'core_message_posts', array( 'msg_topic_id=?', $this->id ) ) ) ) )
|
||||
$report = Report::load( $report );
|
||||
if ( $report->class == 'IPS\core\Messenger\Message' and in_array( $report->content_id, iterator_to_array( Db::i()->select( 'msg_id', 'core_message_posts', array( 'msg_topic_id=?', $this->id ) ) ) ) )
|
||||
{
|
||||
$_SESSION['report'] = $report->id;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ){ }
|
||||
catch ( OutOfRangeException $e ){ }
|
||||
}
|
||||
}
|
||||
if ( $member->modPermission('mod_see_warn') )
|
||||
{
|
||||
/* If we are coming directly from a warning, and the Warning ID is different from what is stored in session, then we need to unset it so it can be reset */
|
||||
if ( isset( $_SESSION['warning'] ) AND isset( \IPS\Request::i()->_warning ) AND \IPS\Request::i()->_warning != $_SESSION['warning'] )
|
||||
if ( isset( $_SESSION['warning'] ) AND isset( Request::i()->_warning ) AND Request::i()->_warning != $_SESSION['warning'] )
|
||||
{
|
||||
unset( $_SESSION['warning'] );
|
||||
}
|
||||
|
||||
$warning = isset( $_SESSION['warning'] ) ? $_SESSION['warning'] : ( isset( \IPS\Request::i()->_warning ) ? \IPS\Request::i()->_warning : NULL );
|
||||
$warning = $_SESSION['warning'] ?? ( isset( Request::i()->_warning ) ? Request::i()->_warning : NULL );
|
||||
if ( $warning )
|
||||
{
|
||||
try
|
||||
{
|
||||
$warning = \IPS\core\Warnings\Warning::load( $warning );
|
||||
$warning = Warning::load( $warning );
|
||||
|
||||
if ( $warning->content_app == 'core' AND $warning->content_module == 'messaging-comment' AND $warning->content_id1 == $this->id )
|
||||
{
|
||||
@@ -489,7 +513,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
catch( OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,12 +523,12 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Can delete?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete( $member=NULL )
|
||||
public function canDelete( ?Member $member=NULL ): bool
|
||||
{
|
||||
if( \IPS\Member::loggedIn()->modPermission( 'can_view_reports' ) )
|
||||
if( Member::loggedIn()->modPermission( 'can_view_reports' ) )
|
||||
{
|
||||
return TRUE; // Moderators who can manage reported content can "delete" conversations
|
||||
}
|
||||
@@ -515,10 +539,10 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Actions to show in comment multi-mod
|
||||
*
|
||||
* @param \IPS\Member $member Member (NULL for currently logged in member)
|
||||
* @param Member|null $member Member (NULL for currently logged in member)
|
||||
* @return array
|
||||
*/
|
||||
public function commentMultimodActions( \IPS\Member $member = NULL )
|
||||
public function commentMultimodActions( Member|null $member = NULL ): array
|
||||
{
|
||||
return array();
|
||||
}
|
||||
@@ -526,21 +550,21 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Cached URLs
|
||||
*/
|
||||
protected $_url = array();
|
||||
protected mixed $_url = array();
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
* @return Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
public function url( string|null $action=NULL ): Url
|
||||
{
|
||||
$_key = md5( $action );
|
||||
$_key = $action ? md5( $action ) : NULL;
|
||||
|
||||
if( !isset( $this->_url[ $_key ] ) )
|
||||
{
|
||||
$this->_url[ $_key ] = \IPS\Http\Url::internal( "app=core&module=messaging&controller=messenger&id={$this->id}", 'front', 'messenger_convo' );
|
||||
$this->_url[ $_key ] = Url::internal( "app=core&module=messaging&controller=messenger&id={$this->id}", 'front', 'messenger_convo' );
|
||||
|
||||
if ( $action )
|
||||
{
|
||||
@@ -558,9 +582,9 @@ class _Conversation extends \IPS\Content\Item
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_activeParticipants()
|
||||
public function get_activeParticipants() : int
|
||||
{
|
||||
return \count( array_filter( $this->maps, function( $map )
|
||||
return count( array_filter( $this->maps, function( $map )
|
||||
{
|
||||
return $map['map_user_active'];
|
||||
} ) );
|
||||
@@ -569,48 +593,47 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Get the map for the current member
|
||||
*
|
||||
* @return mixed
|
||||
* @return array
|
||||
*/
|
||||
public function get_map()
|
||||
public function get_map() : array
|
||||
{
|
||||
$maps = $this->maps();
|
||||
|
||||
/* From a report? */
|
||||
if ( ( isset( $_SESSION['report'] ) ? $_SESSION['report'] : ( isset( \IPS\Request::i()->_report ) ? \IPS\Request::i()->_report : NULL ) ) AND \IPS\Member::loggedIn()->modPermission( 'can_view_reports' ) )
|
||||
if ( ( $_SESSION['report'] ?? ( isset( Request::i()->_report ) ? Request::i()->_report : NULL ) ) AND Member::loggedIn()->modPermission( 'can_view_reports' ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( isset( $maps[ \IPS\Member::loggedIn()->member_id ] ) )
|
||||
if ( isset( $maps[ Member::loggedIn()->member_id ] ) )
|
||||
{
|
||||
return $maps[ \IPS\Member::loggedIn()->member_id ];
|
||||
return $maps[ Member::loggedIn()->member_id ];
|
||||
}
|
||||
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most recent unread conversation and dismiss the popup
|
||||
*
|
||||
* @param bool $dismiss Whether or not to dismiss the popup for future page loads
|
||||
* @return \IPS\core\Messenger\Conversation|NULL
|
||||
* @return Conversation|NULL
|
||||
*/
|
||||
public static function latestUnreadConversation( $dismiss = TRUE )
|
||||
public static function latestUnreadConversation( bool $dismiss = TRUE ) : ?Conversation
|
||||
{
|
||||
$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' );
|
||||
$latestConversationMap = 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', Member::loggedIn()->member_id ), 'map_last_topic_reply DESC' );
|
||||
|
||||
try
|
||||
{
|
||||
$return = static::loadAndCheckPerms( $latestConversationMap->first() );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( OutOfRangeException | UnderflowException $e ) { }
|
||||
|
||||
if( $dismiss === TRUE )
|
||||
{
|
||||
\IPS\Member::loggedIn()->msg_show_notification = FALSE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
Member::loggedIn()->msg_show_notification = FALSE;
|
||||
Member::loggedIn()->save();
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -620,9 +643,9 @@ class _Conversation extends \IPS\Content\Item
|
||||
* 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
|
||||
* @return Message|NULL
|
||||
*/
|
||||
public static function latestUnreadMessage()
|
||||
public static function latestUnreadMessage() : ?Message
|
||||
{
|
||||
/* Get the latest conversation, but don't dismiss the notification yet */
|
||||
if( $conversation = static::latestUnreadConversation( FALSE ) )
|
||||
@@ -631,8 +654,8 @@ class _Conversation extends \IPS\Content\Item
|
||||
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();
|
||||
Member::loggedIn()->msg_show_notification = FALSE;
|
||||
Member::loggedIn()->save();
|
||||
|
||||
return $latestComment;
|
||||
}
|
||||
@@ -644,16 +667,15 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Recount the member's message counts
|
||||
*
|
||||
* @param \IPS\Member $member Member
|
||||
* @param Member $member Member
|
||||
* @return void
|
||||
*/
|
||||
public static function rebuildMessageCounts( \IPS\Member $member )
|
||||
public static function rebuildMessageCounts( Member $member ) : void
|
||||
{
|
||||
/* @note SELECT_FROM_WRITE_SERVER: Avoid issue where the new message rows are on the writer, but not the reader */
|
||||
$total = \IPS\Db::i()->select( 'count(*)', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1', $member->member_id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$total = Db::i()->select( 'count(*)', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1', $member->member_id ), NULL, NULL, NULL, NULL, Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$member->msg_count_total = $total;
|
||||
|
||||
$new = \IPS\Db::i()->select( 'count(*)', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1 AND map_has_unread=1 AND map_ignore_notification=0 AND map_last_topic_reply>?', $member->member_id, $member->msg_count_reset ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$new = Db::i()->select( 'count(*)', 'core_message_topic_user_map', array( 'map_user_id=? AND map_user_active=1 AND map_has_unread=1 AND map_ignore_notification=0 AND map_last_topic_reply>?', $member->member_id, $member->msg_count_reset ), NULL, NULL, NULL, NULL, Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$member->msg_count_new = $new;
|
||||
|
||||
$member->save();
|
||||
@@ -662,7 +684,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Maps cache
|
||||
*/
|
||||
public $maps = NULL;
|
||||
public ?array $maps = NULL;
|
||||
|
||||
/**
|
||||
* Get maps
|
||||
@@ -670,11 +692,11 @@ class _Conversation extends \IPS\Content\Item
|
||||
* @param boolean $refresh Force maps to be refreshed?
|
||||
* @return array
|
||||
*/
|
||||
public function maps( $refresh = FALSE )
|
||||
public function maps( bool $refresh = FALSE ) : array
|
||||
{
|
||||
if ( $this->maps === NULL || $refresh === TRUE )
|
||||
{
|
||||
$this->maps = iterator_to_array( \IPS\Db::i()->select( '*', 'core_message_topic_user_map', array( 'map_topic_id=?', $this->id ) )->setKeyField( 'map_user_id' ) );
|
||||
$this->maps = iterator_to_array( Db::i()->select( '*', 'core_message_topic_user_map', array( 'map_topic_id=?', $this->id ) )->setKeyField( 'map_user_id' ) );
|
||||
}
|
||||
return $this->maps;
|
||||
}
|
||||
@@ -682,19 +704,19 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Grant a member access
|
||||
*
|
||||
* @param \IPS\Member|array $members The member(s) to grant access
|
||||
* @return bool
|
||||
* @param Member|array $members The member(s) to grant access
|
||||
* @return bool|array
|
||||
*/
|
||||
public function authorize( $members )
|
||||
public function authorize( Member|array $members ) : bool|array
|
||||
{
|
||||
$members = \is_array( $members ) ? $members : array( $members );
|
||||
$members = is_array( $members ) ? $members : array( $members );
|
||||
|
||||
/* Go through each member */
|
||||
foreach ( $members as $member )
|
||||
{
|
||||
if ( \is_int( $member ) )
|
||||
if ( is_int( $member ) )
|
||||
{
|
||||
$member = \IPS\Member::load( $member );
|
||||
$member = Member::load( $member );
|
||||
}
|
||||
|
||||
$done = FALSE;
|
||||
@@ -706,7 +728,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
{
|
||||
$this->maps[ $member->member_id ]['map_user_active'] = TRUE;
|
||||
$this->maps[ $member->member_id ]['map_user_banned'] = FALSE;
|
||||
\IPS\Db::i()->update( 'core_message_topic_user_map', array( 'map_user_active' => 1, 'map_user_banned' => 0 ), array( 'map_user_id=? AND map_topic_id=?', $member->member_id, $this->id ) );
|
||||
Db::i()->update( 'core_message_topic_user_map', array( 'map_user_active' => 1, 'map_user_banned' => 0 ), array( 'map_user_id=? AND map_topic_id=?', $member->member_id, $this->id ) );
|
||||
$done = TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -723,14 +745,14 @@ class _Conversation extends \IPS\Content\Item
|
||||
'map_read_time' => ( $member->member_id == $this->starter_id ) ? time() : 0,
|
||||
'map_user_active' => TRUE,
|
||||
'map_user_banned' => FALSE,
|
||||
'map_has_unread' => ( $member->member_id == $this->starter_id ) ? FALSE : TRUE,
|
||||
'map_has_unread' => !( ( $member->member_id == $this->starter_id ) ),
|
||||
'map_is_system' => FALSE,
|
||||
'map_is_starter' => ( $member->member_id == $this->starter_id ),
|
||||
'map_left_time' => 0,
|
||||
'map_ignore_notification' => FALSE,
|
||||
'map_last_topic_reply' => time(),
|
||||
);
|
||||
\IPS\Db::i()->insert( 'core_message_topic_user_map', $this->maps[ $member->member_id ] );
|
||||
Db::i()->insert( 'core_message_topic_user_map', $this->maps[ $member->member_id ] );
|
||||
}
|
||||
|
||||
if ( $member->members_bitoptions['show_pm_popup'] and $this->author()->member_id != $member->member_id )
|
||||
@@ -754,18 +776,18 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* Remove a member access
|
||||
*
|
||||
* @param \IPS\Member|array $members The member(s) to remove access
|
||||
* @param Member|array $members The member(s) to remove access
|
||||
* @param bool $banned User is being blocked by the conversation starter (as opposed to leaving voluntarily)?
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
public function deauthorize( $members, $banned=FALSE )
|
||||
public function deauthorize( Member|array $members, bool $banned=FALSE ) : void
|
||||
{
|
||||
$members = \is_array( $members ) ? $members : array( $members );
|
||||
$members = is_array( $members ) ? $members : array( $members );
|
||||
foreach ( $members as $member )
|
||||
{
|
||||
unset( $this->maps[ $member->member_id ] );
|
||||
\IPS\Db::i()->update( 'core_message_topic_user_map', array( 'map_user_active' => 0, 'map_user_banned' => $banned ), array( 'map_user_id=? AND map_topic_id=?', $member->member_id, $this->id ) );
|
||||
\IPS\Db::i()->delete( 'core_notifications', array( 'notification_key=? AND item_id = ? AND `member`=?', 'new_private_message', $this->id, $member->member_id ) );
|
||||
Db::i()->update( 'core_message_topic_user_map', array( 'map_user_active' => 0, 'map_user_banned' => $banned ), array( 'map_user_id=? AND map_topic_id=?', $member->member_id, $this->id ) );
|
||||
Db::i()->delete( 'core_notifications', array( 'notification_key=? AND item_id = ? AND `member`=?', 'new_private_message', $this->id, $member->member_id ) );
|
||||
static::rebuildMessageCounts( $member );
|
||||
}
|
||||
$this->rebuildParticipants();
|
||||
@@ -776,7 +798,7 @@ class _Conversation extends \IPS\Content\Item
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rebuildParticipants()
|
||||
public function rebuildParticipants() : void
|
||||
{
|
||||
$activeParticipants = 0;
|
||||
foreach ( $this->maps() as $map )
|
||||
@@ -801,19 +823,19 @@ class _Conversation extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Cache member data we've already looked up so we don't have to do it again
|
||||
*/
|
||||
public static $participantMembers = array();
|
||||
public static array $participantMembers = array();
|
||||
|
||||
/**
|
||||
* @brief Particpant blurb
|
||||
*/
|
||||
public $participantBlurb = NULL;
|
||||
public ?string $participantBlurb = NULL;
|
||||
|
||||
/**
|
||||
* Get participant blurb
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function participantBlurb()
|
||||
public function participantBlurb() : string
|
||||
{
|
||||
if( $this->participantBlurb !== NULL )
|
||||
{
|
||||
@@ -828,9 +850,9 @@ class _Conversation extends \IPS\Content\Item
|
||||
{
|
||||
if( isset( static::$participantMembers[ $memberId ] ) )
|
||||
{
|
||||
if ( $memberId === \IPS\Member::loggedIn()->member_id )
|
||||
if ( $memberId === Member::loggedIn()->member_id )
|
||||
{
|
||||
$people[ $memberId ] = ( $memberId == $this->starter_id ) ? \IPS\Member::loggedIn()->language()->addToStack('participant_you_upper') : \IPS\Member::loggedIn()->language()->addToStack('participant_you_lower');
|
||||
$people[ $memberId ] = ( $memberId == $this->starter_id ) ? Member::loggedIn()->language()->addToStack('participant_you_upper') : Member::loggedIn()->language()->addToStack('participant_you_lower');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -841,13 +863,13 @@ class _Conversation extends \IPS\Content\Item
|
||||
}
|
||||
}
|
||||
|
||||
if( \count( $memberIds ) )
|
||||
if( count( $memberIds ) )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( 'member_id, name', 'core_members', array( \IPS\Db::i()->in( 'member_id', $memberIds ) ) ) as $member )
|
||||
foreach( Db::i()->select( 'member_id, name', 'core_members', array( Db::i()->in( 'member_id', $memberIds ) ) ) as $member )
|
||||
{
|
||||
if ( $member['member_id'] === \IPS\Member::loggedIn()->member_id )
|
||||
if ( $member['member_id'] === Member::loggedIn()->member_id )
|
||||
{
|
||||
$member['name'] = ( $member['member_id'] == $this->starter_id ) ? \IPS\Member::loggedIn()->language()->addToStack('participant_you_upper') : \IPS\Member::loggedIn()->language()->addToStack('participant_you_lower');
|
||||
$member['name'] = ( $member['member_id'] == $this->starter_id ) ? Member::loggedIn()->language()->addToStack('participant_you_upper') : Member::loggedIn()->language()->addToStack('participant_you_lower');
|
||||
}
|
||||
$people[ $member['member_id'] ] = $member['name'];
|
||||
static::$participantMembers[ $member['member_id'] ] = $member['name'];
|
||||
@@ -860,15 +882,15 @@ class _Conversation extends \IPS\Content\Item
|
||||
array_unshift( $people, $starter );
|
||||
unset( $starter );
|
||||
|
||||
if ( \count( $people ) == 1 )
|
||||
if ( count( $people ) == 1 )
|
||||
{
|
||||
$id = key( $people );
|
||||
$name = array_pop( $people );
|
||||
$this->participantBlurb = \IPS\Member::loggedIn()->member_id === $id ? \IPS\Member::loggedIn()->language()->addToStack( 'participant_you_upper' ) : $name;
|
||||
$this->participantBlurb = Member::loggedIn()->member_id === $id ? Member::loggedIn()->language()->addToStack( 'participant_you_upper' ) : $name;
|
||||
}
|
||||
elseif ( \count( $people ) == 2 )
|
||||
elseif ( count( $people ) == 2 )
|
||||
{
|
||||
$this->participantBlurb = \IPS\Member::loggedIn()->language()->addToStack( 'participant_two', FALSE, array( 'sprintf' => $people ) );
|
||||
$this->participantBlurb = Member::loggedIn()->language()->addToStack( 'participant_two', FALSE, array( 'sprintf' => $people ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -889,10 +911,10 @@ class _Conversation extends \IPS\Content\Item
|
||||
$count++;
|
||||
}
|
||||
|
||||
$sprintf[] = \IPS\Member::loggedIn()->language()->formatList( $others );
|
||||
$sprintf[] = \count( $others );
|
||||
$sprintf[] = Member::loggedIn()->language()->formatList( $others );
|
||||
$sprintf[] = count( $others );
|
||||
|
||||
$this->participantBlurb = \IPS\Member::loggedIn()->language()->addToStack( 'participant_three_plus', FALSE, array( 'pluralize' => array( \count( $others ) ), 'sprintf' => $sprintf ) );
|
||||
$this->participantBlurb = Member::loggedIn()->language()->addToStack( 'participant_three_plus', FALSE, array( 'pluralize' => array( count( $others ) ), 'sprintf' => $sprintf ) );
|
||||
}
|
||||
|
||||
return $this->participantBlurb;
|
||||
@@ -902,46 +924,46 @@ class _Conversation extends \IPS\Content\Item
|
||||
* Move a message to a different folder
|
||||
*
|
||||
* @param string $to Folder name
|
||||
* @param \IPS\Member|null $member Member object, or null to use logged in member
|
||||
* @param Member|null $member Member object, or null to use logged in member
|
||||
* @return void
|
||||
* @throws \OutOfRangeException
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public function moveConversation( $to, $member=NULL )
|
||||
public function moveConversation( string $to, ?Member $member=NULL ) : void
|
||||
{
|
||||
$member = ( $member != NULL ) ? $member : \IPS\Member::loggedIn();
|
||||
$member = ( $member != NULL ) ? $member : Member::loggedIn();
|
||||
|
||||
if ( \in_array( $to, array_merge( array( 'myconvo' ), array_keys( json_decode( $member->pconversation_filters, TRUE ) ) ) ) )
|
||||
if ( in_array( $to, array_merge( array( 'myconvo' ), array_keys( json_decode( $member->pconversation_filters, TRUE ) ) ) ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_message_topic_user_map', array( 'map_folder_id' => $to ), array( 'map_user_id=? AND map_topic_id=?', $member->member_id, $this->id ) );
|
||||
Db::i()->update( 'core_message_topic_user_map', array( 'map_folder_id' => $to ), array( 'map_user_id=? AND map_topic_id=?', $member->member_id, $this->id ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build form to create
|
||||
*
|
||||
* @param \IPS\Node\Model|NULL $container Container (e.g. forum), if appropriate
|
||||
* @param \IPS\Content\Item|NULL $item Content item, e.g. if editing
|
||||
* @return \IPS\Helpers\Form
|
||||
* @param Model|NULL $container Container (e.g. forum), if appropriate
|
||||
* @param Item|NULL $item Content item, e.g. if editing
|
||||
* @return Form
|
||||
*/
|
||||
protected static function buildCreateForm( \IPS\Node\Model $container=NULL, \IPS\Content\Item $item=NULL )
|
||||
protected static function buildCreateForm( Model $container=null, Item $item=NULL ): Form
|
||||
{
|
||||
$form = parent::buildCreateForm( $container, $item );
|
||||
|
||||
try
|
||||
{
|
||||
$alert = \IPS\core\Alerts\Alert::load( \IPS\Request::i()->alert );
|
||||
$alert = Alert::load( Request::i()->alert );
|
||||
|
||||
if( $alert->forMember( \IPS\Member::loggedIn() ) )
|
||||
if( $alert->forMember( Member::loggedIn() ) )
|
||||
{
|
||||
$form->hiddenValues['alert'] = $alert->id;
|
||||
$form->hiddenValues['messenger_title'] = $alert->title;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
catch ( OutOfRangeException $e ) {}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user