Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -74,12 +74,13 @@ trait Solvable
|
||||
|
||||
if ( $value )
|
||||
{
|
||||
if ( $this->mapped('solved_comment_id') )
|
||||
if ( $this->$solvedField )
|
||||
{
|
||||
try
|
||||
{
|
||||
$oldComment = $commentClass::load( $this->mapped('solved_comment_id') );
|
||||
$oldComment = $commentClass::load( $this->$solvedField );
|
||||
$oldComment->setSolved( FALSE );
|
||||
$oldComment->save();
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
}
|
||||
@@ -95,6 +96,22 @@ trait Solvable
|
||||
'item_id' => $this->$idField,
|
||||
'solved_date' => time()
|
||||
) );
|
||||
|
||||
/* Send the "solution to your topic" notification but only if we didn't post the solution, we're not marking the solution, we can view the content, and the user isn't ignored */
|
||||
if ( $this->author()->member_id AND $comment->author() != $this->author() AND $this->author() != $member AND $this->canView( $this->author() ) AND !$this->author()->isIgnoring( $comment->author(), 'posts' ) )
|
||||
{
|
||||
$notification = new \IPS\Notification( \IPS\Application::load('core'), 'mine_solved', $this, array( $this, $comment, $member ), array(), TRUE, NULL );
|
||||
$notification->recipients->attach( $this->author() );
|
||||
$notification->send();
|
||||
}
|
||||
|
||||
/* Send the "you solved the topic" notification but only if we didn't mark the solution */
|
||||
if ( $comment->author()->member_id AND $comment->author() != $member )
|
||||
{
|
||||
$notification = new \IPS\Notification( \IPS\Application::load('core'), 'my_solution', $this, array( $this, $comment, $member ), array(), TRUE, NULL );
|
||||
$notification->recipients->attach( $comment->author() );
|
||||
$notification->send();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -102,6 +119,20 @@ trait Solvable
|
||||
$this->save();
|
||||
|
||||
\IPS\Db::i()->delete( 'core_solved_index', array( 'comment_class=? and comment_id=?', $commentClass, $comment->$commentIdField ) );
|
||||
|
||||
$memberIds = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '`member`', 'core_notifications', array( \IPS\Db::i()->in( 'notification_key', array( 'mine_solved', 'my_solution' ) ) . ' AND item_class=? AND item_id=?', (string) \get_class( $this ), (int) $this->$idField ) ) as $memberToRecount )
|
||||
{
|
||||
$memberIds[ $memberToRecount ] = $memberToRecount;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_notifications', array( \IPS\Db::i()->in( 'notification_key', array( 'mine_solved', 'my_solution' ) ) . ' AND item_class=? AND item_id=?', (string) \get_class( $this ), (int) $this->$idField ) );
|
||||
|
||||
foreach( $memberIds as $memberToRecount )
|
||||
{
|
||||
\IPS\Member::load( $memberToRecount )->recountNotifications();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,4 +231,23 @@ trait Solvable
|
||||
/* Otherwise no */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the solution
|
||||
*
|
||||
* @return \IPS\Content\Comment|NULL
|
||||
*/
|
||||
public function getSolution()
|
||||
{
|
||||
try
|
||||
{
|
||||
$commentClass = static::$commentClass;
|
||||
|
||||
return $commentClass::load( $this->mapped('solved_comment_id') );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user