Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+99 -27
View File
@@ -269,11 +269,6 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function get__sortBy()
{
if ( $this->sort_key === 'last_post' )
{
return 'last_real_post';
}
return $this->sort_key;
}
@@ -352,6 +347,22 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
return $this->last_post ? \IPS\DateTime::ts( $this->last_post ) : NULL;
}
/**
* Set the comment/approved/hidden counts
*
* @return void
*/
public function resetCommentCounts()
{
parent::resetCommentCounts();
/* Archiving? */
if ( \IPS\Settings::i()->archive_on )
{
$this->_comments += \IPS\forums\Topic\ArchivedPost::db()->select( 'COUNT(*)', 'forums_archive_posts', array( 'archive_forum_id=?', $this->id ) )->first();
}
}
/**
* Get last post data
*
@@ -369,7 +380,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
and
(
!(
\IPS\Member::loggedIn()->modPermission( 'forums' ) === 0
\IPS\Member::loggedIn()->modPermission( 'forums' ) === -1
or
(
is_array( \IPS\Member::loggedIn()->modPermission( 'forums' ) )
@@ -434,8 +445,21 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
if( $this->last_post )
{
if ( $this->last_poster_id )
{
$lastAuthor = \IPS\Member::load( $this->last_poster_id );
}
else
{
$lastAuthor = new \IPS\Member;
if ( $this->last_poster_name )
{
$lastAuthor->name = $this->last_poster_name;
}
}
$result = array(
'author' => \IPS\Member::load( $this->last_poster_id ),
'author' => $lastAuthor,
'topic_url' => \IPS\Http\Url::internal( "app=forums&module=forums&controller=topic&id={$this->last_id}", 'front', 'forums_topic', array( $this->seo_last_title ) ),
'topic_title' => $this->last_title,
'date' => $this->last_post
@@ -470,6 +494,21 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
return static::$permissionMap;
}
/**
* Columns needed to query for search result / stream view
*
* @return array
*/
public static function basicDataColumns()
{
$return = parent::basicDataColumns();
$return[] = 'forums_bitoptions';
$return[] = 'password';
$return[] = 'password_override';
$return[] = 'min_posts_view';
return $return;
}
/**
* Check if the currently logged in member has access to a password protected forum
*
@@ -704,6 +743,11 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
$buttons['permissions']['data'] = NULL;
}
if ( !$this->sub_can_post and isset( $buttons['add'] ) )
{
$buttons['add']['title'] = 'forums_add_child_cat';
}
return $buttons;
}
@@ -876,8 +920,8 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
$form->addTab( 'forum_display' );
$form->addHeader( 'forum_display_forum' );
$form->add( new \IPS\Helpers\Form\Select( 'forum_sort_key', $this->id ? $this->sort_key : 'last_post', FALSE, array( 'options' => array( 'last_post' => 'sort_updated', 'posts' => 'sort_num_comments', 'views' => 'sort_views', 'title' => 'sort_title', 'starter_name' => 'sort_author_name', 'last_poster_name' => 'sort_last_comment_name', 'start_date' => 'sort_date' ) ), NULL, NULL, NULL, 'forum_sort_key' ) );
$form->add( new \IPS\Helpers\Form\Select( 'forum_sort_key', $this->id ? $this->sort_key : 'last_post', FALSE, array( 'options' => array( 'last_post' => 'sort_updated', 'last_real_post' => 'sort_last_comment', 'posts' => 'sort_num_comments', 'views' => 'sort_views', 'title' => 'sort_title', 'starter_name' => 'sort_author_name', 'last_poster_name' => 'sort_last_comment_name', 'start_date' => 'sort_date' ) ), NULL, NULL, NULL, 'forum_sort_key' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'forum_show_rules', $this->id ? $this->show_rules : 0, FALSE, array(
'options' => array(
0 => 'forum_show_rules_none',
@@ -942,7 +986,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
$form->add( new \IPS\Helpers\Form\YesNo( 'bw_disable_prefixes', !$this->forums_bitoptions['bw_disable_prefixes'], FALSE, array(), NULL, NULL, NULL, 'bw_disable_prefixes' ) );
if ( !\IPS\Settings::i()->tags_open_system )
{
$form->add( new \IPS\Helpers\Form\Text( 'forum_tag_predefined', $this->tag_predefined, FALSE, array( 'autocomplete' => array( 'unique' => 'true' ), 'nullLang' => 'forum_tag_predefined_unlimited' ), NULL, NULL, NULL, 'forum_tag_predefined' ) );
$form->add( new \IPS\Helpers\Form\Text( 'forum_tag_predefined', $this->tag_predefined ?: NULL, FALSE, array( 'autocomplete' => array( 'unique' => 'true' ), 'nullLang' => 'forum_tag_predefined_unlimited' ), NULL, NULL, NULL, 'forum_tag_predefined' ) );
}
}
}
@@ -1149,21 +1193,21 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
* @brief Cached URL
*/
protected $_url = NULL;
/**
* Get URL
*
* @return \IPS\Http\Url
* @brief URL Base
*/
public function url()
{
if( $this->_url === NULL )
{
$this->_url = \IPS\Http\Url::internal( "app=forums&module=forums&controller=forums&id={$this->_id}", 'front', 'forums_forum', array( $this->name_seo ) );
}
return $this->_url;
}
public static $urlBase = 'app=forums&module=forums&controller=forums&id=';
/**
* @brief URL Base
*/
public static $urlTemplate = 'forums_forum';
/**
* @brief SEO Title Column
*/
public static $seoTitleColumn = 'name_seo';
/**
* Delete Record
@@ -1190,6 +1234,16 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
{
return array( \IPS\Theme::i()->getTemplate( 'index', 'forums' ), 'forumTableRow' );
}
/**
* Get template for managing this nodes follows
*
* @return callable
*/
public static function manageFollowNodeRow()
{
return array( \IPS\Theme::i()->getTemplate( 'global', 'forums' ), 'manageFollowNodeRow' );
}
/**
* [ActiveRecord] Duplicate
@@ -1234,7 +1288,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
}
/**
* If there is only one forum (and it isn't a redirect forum), that forum, or NULL
* If there is only one forum (and it isn't a redirect forum or password protected), that forum, or NULL
*
* @return \IPS\forums\Forum||NULL
*/
@@ -1248,7 +1302,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
{
foreach ( $root->children() as $forum )
{
if ( !$forum->redirect_url )
if ( !$forum->redirect_url and !$forum->password )
{
return $forum;
}
@@ -1277,8 +1331,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
/* And then loop up the parents too... */
foreach ( $this->parents() as $parent )
{
$permissions = $parent->permissions();
$parentResult = $permissions['perm_view'];
$parentResult = static::_getPermissions( $parent );
if( $result == '*' )
{
@@ -1447,4 +1500,23 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
return $return;
}
/**
* Disabled permissions
* Allow node classes to define permissions that are unselectable in the permission matrix
*
* @return array array( {group_id} => array( 'read', 'view', 'perm_7' );
*/
public function disabledPermissions()
{
$disabled = array();
$guestGroup = \IPS\Member\Group::load( \IPS\Settings::i()->guest_group );
if( !$this->can_view_others )
{
$disabled[ $guestGroup->g_id ][] = 'view';
}
return $disabled;
}
}