Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -117,7 +117,8 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
'bw_disable_prefixes' => 2,
|
||||
'bw_enable_answers' => 4,
|
||||
'bw_enable_answers_member' => 8,
|
||||
'bw_enable_answers_moderator' => 16
|
||||
'bw_enable_answers_moderator' => 16,
|
||||
'bw_fluid_view' => 32,
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -234,7 +235,22 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
$this->topics = (int) $val;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [Node] Return the custom badge for each row
|
||||
*
|
||||
* @return NULL|array Null for no badge, or an array of badge data (0 => CSS class type, 1 => language string, 2 => optional raw HTML to show instead of language string)
|
||||
*/
|
||||
protected function get__badge()
|
||||
{
|
||||
if( $this->isCombinedView() )
|
||||
{
|
||||
return array( 0 => 'positive ipsPos_right', 1 => 'combined_fluid_view' );
|
||||
}
|
||||
|
||||
return parent::get__badge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of comments
|
||||
*
|
||||
@@ -641,7 +657,11 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
if ( $this->skin_id )
|
||||
{
|
||||
\IPS\Theme::switchTheme( $this->skin_id );
|
||||
try
|
||||
{
|
||||
\IPS\Theme::switchTheme( $this->skin_id );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
if ( !$this->viglink )
|
||||
@@ -703,7 +723,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
|
||||
if ( \in_array( $permissionCheck, array( 'read', 'add' ) ) )
|
||||
{
|
||||
if ( static::hasPasswordForums() )
|
||||
if ( static::customPermissionNodes() )
|
||||
{
|
||||
$whereString = 'password=? OR ' . \IPS\Db::i()->findInSet( 'forums_forums.password_override', $member->groups );
|
||||
$whereParams = array( NULL );
|
||||
@@ -951,7 +971,14 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'forum_card_image', $this->card_image ? \IPS\File::get( 'forums_Cards', $this->card_image ) : NULL, FALSE, array( 'image' => array( 'maxWidth' => 800, 'maxHeight' => 800 ), 'storageExtension' => 'forums_Cards', 'allowStockPhotos' => TRUE ), NULL, NULL, NULL, 'forum_card_image' ) );
|
||||
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'forum_redirect_url', $this->id ? $this->redirect_url : array(), FALSE, array( 'placeholder' => 'http://www.example.com/' ), NULL, NULL, NULL, 'forum_redirect_url' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'forum_redirect_url', $this->id ? $this->redirect_url : array(), FALSE, array( 'placeholder' => 'http://www.example.com/' ),
|
||||
function( $val )
|
||||
{
|
||||
if ( !$val and \IPS\Request::i()->forum_type === 'redirect' )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'forum_redirect_url' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'forum_redirect_hits', $this->id ? $this->redirect_hits : 0, FALSE, array(), NULL, NULL, NULL, 'forum_redirect_hits' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forum_password_on', $this->id ? ( $this->password !== NULL ) : FALSE, FALSE, array( 'togglesOn' => array( 'forum_password', 'forum_password_override' ) ), NULL, NULL, NULL, 'forum_password_on' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'forum_password', $this->password, FALSE, array(), NULL, NULL, NULL, 'forum_password' ) );
|
||||
@@ -1022,6 +1049,19 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
),
|
||||
)
|
||||
) ) );
|
||||
|
||||
/* Show the combined fluid view option if we have children */
|
||||
$disabledFluidView = FALSE;
|
||||
if ( ! $this->hasChildren() )
|
||||
{
|
||||
$disabledFluidView = TRUE;
|
||||
$this->forums_bitoptions['bw_fluid_view'] = FALSE;
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['bw_fluid_view_warning'] = \IPS\Member::loggedIn()->language()->addToStack( 'bw_fluid_view__warning' );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'bw_fluid_view', $this->id ? $this->forums_bitoptions['bw_fluid_view'] : FALSE, FALSE, array( 'disabled' => $disabledFluidView ), NULL, NULL, NULL, 'bw_fluid_view' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'forum_rules_title', NULL, FALSE, array( 'app' => 'forums', 'key' => ( $this->id ? "forums_forum_{$this->id}_rulestitle" : NULL ) ), NULL, NULL, NULL, 'forum_rules_title' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'forum_rules_text', NULL, FALSE, array( 'app' => 'forums', 'key' => ( $this->id ? "forums_forum_{$this->id}_rules" : NULL ), 'editor' => array( 'app' => 'forums', 'key' => 'Forums', 'autoSaveKey' => ( $this->id ? "forums-rules-{$this->id}" : "forums-new-rules" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'rules' ) : NULL ) ), NULL, NULL, NULL, 'forum_rules_text' ) );
|
||||
|
||||
@@ -1148,7 +1188,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
if( !isset( $values['forum_type'] ) AND isset( $values['bw_enable_answers__member'] ) )
|
||||
{
|
||||
/* We don't want to copy this to QA forums */
|
||||
if( $this->forum_type == 'normal' )
|
||||
if( $this->_forum_type == 'normal' )
|
||||
{
|
||||
$values['bw_enable_answers_member'] = $values['bw_enable_answers__member'];
|
||||
}
|
||||
@@ -1169,11 +1209,11 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
}
|
||||
|
||||
/* Bitwise */
|
||||
foreach ( array( 'bw_disable_tagging', 'bw_disable_prefixes', 'bw_enable_answers_member', 'bw_enable_answers_moderator' ) as $k )
|
||||
foreach ( array( 'bw_disable_tagging', 'bw_disable_prefixes', 'bw_enable_answers_member', 'bw_enable_answers_moderator', 'bw_fluid_view' ) as $k )
|
||||
{
|
||||
if( isset( $values[ $k ] ) )
|
||||
{
|
||||
$values['forums_bitoptions'][ $k ] = ( $k == 'bw_enable_answers_member' or $k == 'bw_enable_answers_moderator' ) ? $values[ $k ] : !$values[ $k ];
|
||||
$values['forums_bitoptions'][ $k ] = ( $k == 'bw_enable_answers_member' or $k == 'bw_enable_answers_moderator' or $k == 'bw_fluid_view' ) ? $values[ $k ] : !$values[ $k ];
|
||||
unset( $values[ $k ] );
|
||||
}
|
||||
}
|
||||
@@ -1301,7 +1341,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function postSaveForm( $values )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->forumsHavePasswords );
|
||||
unset( \IPS\Data\Store::i()->forumsCustomNodes );
|
||||
|
||||
\IPS\File::claimAttachments( 'forums-new-forum', $this->id, NULL, 'description', TRUE );
|
||||
\IPS\File::claimAttachments( 'forums-new-permerror', $this->id, NULL, 'permerror', TRUE );
|
||||
@@ -1357,7 +1397,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
unset( \IPS\Data\Store::i()->forumsHavePasswords );
|
||||
unset( \IPS\Data\Store::i()->forumsCustomNodes );
|
||||
|
||||
parent::delete();
|
||||
|
||||
@@ -1842,6 +1882,11 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$return['permissions'] = $this->permissions();
|
||||
}
|
||||
|
||||
if ( \IPS\IPS::classUsesTrait( \get_called_class(), 'IPS\Content\ClubContainer' ) AND $this->club() )
|
||||
{
|
||||
$return['public'] = ( $this->isPublic() ) ? 1 : 0;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -1853,12 +1898,17 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
* @param \IPS\Helpers\Form $form Form object
|
||||
* @return void
|
||||
*/
|
||||
public function clubForm( \IPS\Helpers\Form $form )
|
||||
public function clubForm( \IPS\Helpers\Form $form, \IPS\Member\Club $club )
|
||||
{
|
||||
$itemClass = static::$contentItemClass;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'club_node_name', $this->_id ? $this->_title : \IPS\Member::loggedIn()->language()->addToStack( $itemClass::$title . '_pl' ), TRUE, array( 'maxLength' => 255 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'club_node_description', $this->_id ? \IPS\Member::loggedIn()->language()->get( static::$titleLangPrefix . $this->_id . '_desc' ) : NULL, FALSE, array( 'app' => 'forums', 'key' => 'Forums', 'autoSaveKey' => ( $this->id ? "forums-forum-{$this->id}" : "forums-new-forum" ), 'attachIds' => $this->id ? array( $this->id, NULL, 'description' ) : NULL, 'minimize' => 'forum_description_placeholder' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forum_can_view_others_club', $this->id ? $this->can_view_others : TRUE ) );
|
||||
|
||||
if( $club->type == 'closed' )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'club_node_public', $this->id ? $this->isPublic() : FALSE ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1894,7 +1944,18 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
\IPS\File::claimAttachments( 'forums-new-forum', $this->id, NULL, 'description' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is this forum set to show topics from this forum and any children in one
|
||||
* combined 'simple' view?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isCombinedView()
|
||||
{
|
||||
return (bool) $this->forums_bitoptions['bw_fluid_view'];
|
||||
}
|
||||
|
||||
/* !Simple view */
|
||||
|
||||
/**
|
||||
@@ -2017,18 +2078,34 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this forum has a password set or not
|
||||
* Return if this node has custom permissions
|
||||
*
|
||||
* @return boolean
|
||||
* @return null|array
|
||||
*/
|
||||
public static function hasPasswordForums()
|
||||
public static function customPermissionNodes()
|
||||
{
|
||||
if ( ! isset( \IPS\Data\Store::i()->forumsHavePasswords ) )
|
||||
if ( ! isset( \IPS\Data\Store::i()->forumsCustomNodes ) )
|
||||
{
|
||||
\IPS\Data\Store::i()->forumsHavePasswords = (bool) \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', array( 'password IS NOT NULL' ) )->first();
|
||||
$data = [ 'count' => 0, 'password' => [], 'cannotViewOthersItems' => [] ];
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', array( 'password IS NOT NULL or can_view_others=0' ) ) as $forum )
|
||||
{
|
||||
$data['count']++;
|
||||
if ( $forum['password'] )
|
||||
{
|
||||
$data['password'][] = $forum['id'];
|
||||
}
|
||||
|
||||
if ( ! $forum['can_view_others'] )
|
||||
{
|
||||
$data['cannotViewOthersItems'][] = $forum['id'];
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->forumsCustomNodes = $data;
|
||||
}
|
||||
|
||||
return \IPS\Data\Store::i()->forumsHavePasswords;
|
||||
return ( \IPS\Data\Store::i()->forumsCustomNodes['count'] ) ? \IPS\Data\Store::i()->forumsCustomNodes : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2045,6 +2122,11 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
|
||||
return parent::url();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The class of the ACP \IPS\Node\Controller that manages this node type
|
||||
*/
|
||||
protected static $acpController = "IPS\\forums\\modules\\admin\\forums\\forums";
|
||||
|
||||
/**
|
||||
* Get URL from index data
|
||||
@@ -2063,4 +2145,31 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
|
||||
return parent::urlFromIndexData( $indexData, $itemData, $containerData );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get__forum_type()
|
||||
{
|
||||
if ( $this->redirect_url )
|
||||
{
|
||||
$type = 'redirect';
|
||||
}
|
||||
elseif ( !$this->sub_can_post )
|
||||
{
|
||||
$type = 'category';
|
||||
}
|
||||
elseif ( $this->forums_bitoptions['bw_enable_answers'] )
|
||||
{
|
||||
$type = 'qa';
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = 'normal';
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user