Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
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' );
|
||||
exit;
|
||||
@@ -84,14 +84,9 @@ class _SavedAction extends \IPS\Node\Model
|
||||
|
||||
if ( $member->modPermission('can_use_saved_actions') and \IPS\forums\Topic::modPermission( 'use_saved_actions', $member, $forum ) )
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->forumsSavedActions ) )
|
||||
foreach ( static::getStore() as $action )
|
||||
{
|
||||
\IPS\Data\Store::i()->forumsSavedActions = iterator_to_array( \IPS\Db::i()->select( '*', 'forums_topic_mmod' ) );
|
||||
}
|
||||
|
||||
foreach ( \IPS\Data\Store::i()->forumsSavedActions as $action )
|
||||
{
|
||||
if ( $action['mm_enabled'] and ( $action['mm_forums'] == '*' or in_array( $forum->id, array_filter( explode( ',', $action['mm_forums'] ) ) ) ) )
|
||||
if ( $action['mm_enabled'] and ( $action['mm_forums'] == '*' or \in_array( $forum->id, array_filter( explode( ',', $action['mm_forums'] ) ) ) ) )
|
||||
{
|
||||
$return[ $action['mm_id'] ] = static::constructFromData( $action );
|
||||
}
|
||||
@@ -184,7 +179,7 @@ class _SavedAction extends \IPS\Node\Model
|
||||
|
||||
if( isset( $values['topic_move'] ) )
|
||||
{
|
||||
if ( !is_object( $values['topic_move'] ) and $values['topic_move'] == 0 )
|
||||
if ( !\is_object( $values['topic_move'] ) and $values['topic_move'] == 0 )
|
||||
{
|
||||
$values['topic_move'] = -1;
|
||||
}
|
||||
@@ -211,7 +206,7 @@ class _SavedAction extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Run
|
||||
* Check Permissions and run the saved action
|
||||
*
|
||||
* @param \IPS\forums\Topic $topic The topic to run on
|
||||
* @param \IPS\Member|NULL $member Member running (NULL for currently logged in member)
|
||||
@@ -230,25 +225,38 @@ class _SavedAction extends \IPS\Node\Model
|
||||
|
||||
if ( $member->modPermission( 'forums' ) !== -1 AND $member->modPermission( 'forums' ) !== TRUE )
|
||||
{
|
||||
if ( !is_array( $member->modPermission( 'forums' ) ) or !in_array( $topic->container()->_id, $member->modPermission( 'forums' ) ) )
|
||||
if ( !\is_array( $member->modPermission( 'forums' ) ) or !\in_array( $topic->container()->_id, $member->modPermission( 'forums' ) ) )
|
||||
{
|
||||
throw new \DomainException('NO_PERMISSION');
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the action is enabled and allowed for the content item */
|
||||
if ( !$this->mm_enabled )
|
||||
{
|
||||
throw new \DomainException('DISABLED');
|
||||
}
|
||||
if ( $this->mm_forums !== '*' and !in_array( $topic->container()->_id, explode( ',', $this->mm_forums ) ) )
|
||||
{
|
||||
throw new \DomainException('BAD_FORUM');
|
||||
}
|
||||
if ( $topic->isArchived() )
|
||||
{
|
||||
throw new \DomainException('TOPIC_ARCHIVED');
|
||||
}
|
||||
if ( $this->mm_forums !== '*' and !\in_array( $topic->container()->_id, explode( ',', $this->mm_forums ) ) )
|
||||
{
|
||||
throw new \DomainException('BAD_FORUM');
|
||||
}
|
||||
|
||||
$this->_runOn( $topic, $member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run saved action
|
||||
*
|
||||
* @param \IPS\forums\Topic $topic The topic to run on
|
||||
* @param \IPS\Member|NULL $member Member running (NULL for currently logged in member)
|
||||
* @return void
|
||||
*/
|
||||
protected function _runOn( \IPS\forums\Topic $topic, \IPS\Member $member = NULL )
|
||||
{
|
||||
/* Archived Topics can't used saved actions */
|
||||
if ( $topic->isArchived() )
|
||||
{
|
||||
throw new \DomainException('TOPIC_ARCHIVED');
|
||||
}
|
||||
/* Open/Close */
|
||||
if ( $this->topic_state == 'open' )
|
||||
{
|
||||
@@ -258,7 +266,7 @@ class _SavedAction extends \IPS\Node\Model
|
||||
{
|
||||
$topic->state = 'closed';
|
||||
}
|
||||
|
||||
|
||||
/* Pin/Unpin */
|
||||
if ( $this->topic_pin == 'pin' )
|
||||
{
|
||||
@@ -268,7 +276,7 @@ class _SavedAction extends \IPS\Node\Model
|
||||
{
|
||||
$topic->pinned = FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Title */
|
||||
if ( $this->topic_title_st )
|
||||
{
|
||||
@@ -278,10 +286,10 @@ class _SavedAction extends \IPS\Node\Model
|
||||
{
|
||||
$topic->title .= $this->topic_title_end;
|
||||
}
|
||||
|
||||
|
||||
/* Save */
|
||||
$topic->save();
|
||||
|
||||
|
||||
/* Hide/Unhide */
|
||||
if ( $this->topic_approve == 1 )
|
||||
{
|
||||
@@ -291,13 +299,13 @@ class _SavedAction extends \IPS\Node\Model
|
||||
{
|
||||
$topic->hide( $member );
|
||||
}
|
||||
|
||||
|
||||
/* Reply */
|
||||
if ( $this->topic_reply )
|
||||
{
|
||||
$reply = \IPS\forums\Topic\Post::create( $topic, $this->topic_reply_content, FALSE, NULL, isset( $this->topic_reply_postcount ) AND $this->topic_reply_postcount ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
|
||||
/* Move */
|
||||
if ( $this->topic_move != -1 )
|
||||
{
|
||||
@@ -308,18 +316,7 @@ class _SavedAction extends \IPS\Node\Model
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
unset( \IPS\Data\Store::i()->forumsSavedActions );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete Record
|
||||
*
|
||||
@@ -329,8 +326,26 @@ class _SavedAction extends \IPS\Node\Model
|
||||
{
|
||||
\IPS\File::unclaimAttachments( 'core_Admin', $this->mm_id, NULL, 'forumsSavedAction' );
|
||||
parent::delete();
|
||||
|
||||
unset( \IPS\Data\Store::i()->forumsSavedActions );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Caches
|
||||
* @note Defined cache keys will be cleared automatically as needed
|
||||
*/
|
||||
protected $caches = array( 'forumsSavedActions' );
|
||||
|
||||
/**
|
||||
* Get data store
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getStore()
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->forumsSavedActions ) )
|
||||
{
|
||||
\IPS\Data\Store::i()->forumsSavedActions = iterator_to_array( \IPS\Db::i()->select( '*', 'forums_topic_mmod' ) );
|
||||
}
|
||||
|
||||
return \IPS\Data\Store::i()->forumsSavedActions;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user