Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

+4 -5
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief Feed Import Node
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 4 Fed 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums;
+167 -57
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief Forum Node
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 7 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums;
@@ -24,6 +23,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
{
use \IPS\Content\ClubContainer;
use \IPS\Node\Colorize;
/**
* @brief [ActiveRecord] Multiton Store
*/
@@ -302,7 +304,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
public function get__sortBy()
{
return $this->sort_key;
}
}
/**
* Last Poster ID Column
@@ -570,6 +572,7 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
$return[] = 'password';
$return[] = 'password_override';
$return[] = 'min_posts_view';
$return[] = 'club_id';
return $return;
}
@@ -1022,6 +1025,10 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
$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' ) );
/* Color */
$form->add( new \IPS\Helpers\Form\YesNo( 'forum_use_feature_color', $this->feature_color ? 1 : 0, FALSE, array( 'togglesOn' => array( 'forum_feature_color' ) ), NULL, NULL, NULL, 'forum_use_feature_color' ) );
$form->add( new \IPS\Helpers\Form\Color( 'forum_feature_color', $this->feature_color ?: '', FALSE, array(), NULL, NULL, NULL, 'forum_feature_color' ) );
$form->addHeader( 'forum_display_topic' );
$form->addHeader( 'forum_display_question' );
$form->add( new \IPS\Helpers\Form\YesNo( 'bw_enable_answers_member', $this->id ? $this->forums_bitoptions['bw_enable_answers_member'] : TRUE, FALSE, array(), NULL, NULL, NULL, 'bw_enable_answers_member' ) );
@@ -1217,7 +1224,18 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
$values['preview_posts'] = 0;
}
}
/* Feature color */
if ( isset( $values['use_feature_color'] ) )
{
if ( ! $values['use_feature_color'] )
{
$values['feature_color'] = NULL;
}
unset( $values['use_feature_color'] );
}
if ( !$this->id )
{
$this->save();
@@ -1397,58 +1415,9 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public static function theOnlyForum()
{
if ( count( \IPS\forums\Forum::roots() ) === 1 )
{
foreach ( \IPS\forums\Forum::roots() as $root )
{
if ( $root->childrenCount() === 1 )
{
foreach ( $root->children() as $forum )
{
if ( !$forum->redirect_url and !$forum->password )
{
return $forum;
}
}
}
}
}
return NULL;
return static::theOnlyNode( array( 'redirect_url' => FALSE, 'password' => FALSE, 'club_id' => 0 ), FALSE );
}
/**
* Search Index Permissions
* Overloaded here so we can discard categories as they should not influence permissions overall.
*
* @return string Comma-delimited values or '*'
* @li Number indicates a group
* @li Number prepended by "m" indicates a member
* @li Number prepended by "s" indicates a social group
*/
public function searchIndexPermissions()
{
/* Compare both read and view */
$result = static::_getPermissions( $this );
/* And then loop up the parents too... */
foreach ( $this->parents() as $parent )
{
$parentResult = static::_getPermissions( $parent );
if( $result == '*' )
{
$result = $parentResult;
}
else if( $parentResult != '*' )
{
$result = implode( ',', array_intersect( explode( ',', $result ), explode( ',', $parentResult ) ) );
}
}
return $result;
}
/**
* Get which permission keys can access all topics in a forum which
* can normally only show topics to the author
@@ -1746,4 +1715,145 @@ class _Forum extends \IPS\Node\Model implements \IPS\Node\Permissions
'url' => (string) $this->url()
);
}
/* !Clubs */
/**
* Set form for creating a node of this type in a club
*
* @param \IPS\Helpers\Form $form Form object
* @return void
*/
public function clubForm( \IPS\Helpers\Form $form )
{
$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' ) ) );
}
/**
* Class-specific routine when saving club form
*
* @param \IPS\Member\Club $club The club
* @param array $values Values
* @return void
*/
public function _saveClubForm( \IPS\Member\Club $club, $values )
{
if ( $values['club_node_name'] )
{
$this->name_seo = \IPS\Http\Url\Friendly::seoTitle( $values['club_node_name'] );
}
}
/* !Simple view */
/**
* Is simple view one? Calculates admin settings and user's choice
*
* @param \IPS\forums\Forum|NULL $forum The forum objectr
* @return boolean
*/
public static function isSimpleView( $forum=NULL )
{
$simpleView = false;
/* Clubs cannot be simple mode or it breaks out of the club container */
if ( $forum and $forum->club() )
{
return false;
}
/* Guests are locked to the admin choice */
if ( ! \IPS\Member::loggedIn()->member_id )
{
return \IPS\Settings::i()->forums_default_view === 'fluid' ? true : false;
}
if ( \IPS\Settings::i()->forums_default_view === 'fluid' )
{
$simpleView = true;
}
$method = static::getMemberView();
if ( $method !== 'fluid' )
{
$simpleView = false;
}
else if ( $method === 'fluid' )
{
$simpleView = true;
}
return $simpleView;
}
/**
* Get the member's view method
*
* @return string
*/
public static function getMemberView()
{
$method = ( isset( \IPS\Request::i()->cookie['forum_view'] ) ) ? \IPS\Request::i()->cookie['forum_view'] : NULL;
$chooseable = \IPS\Settings::i()->forums_default_view_choose ? json_decode( \IPS\Settings::i()->forums_default_view_choose , TRUE ) : FALSE;
if ( ! $chooseable )
{
return \IPS\Settings::i()->forums_default_view;
}
if ( ! $method )
{
try
{
$method = \IPS\Db::i()->select( 'method', 'forums_view_method', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
/* Attempt to set the cookie again */
\IPS\Request::i()->setCookie( 'forum_view', $method, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
}
catch( \UnderFlowException $e ){ }
}
if ( ! $method or ( $chooseable != '*' AND ! in_array( $method, $chooseable ) ) )
{
$method = \IPS\Settings::i()->forums_default_view;
}
return $method;
}
/**
* Get URL
*
* @return \IPS\Http\Url
*/
public function url()
{
if ( static::isSimpleView() and ! $this->club() )
{
return \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index&forumId=' . $this->id, 'front', 'forums' );
}
return parent::url();
}
/**
* Get URL from index data
*
* @param array $indexData Data from the search index
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
* @return \IPS\Http\Url
*/
public static function urlFromIndexData( $indexData, $itemData, $containerData )
{
if ( static::isSimpleView() and ! $containerData['club_id'] )
{
return \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index&forumId=' . $indexData['index_container_id'], 'front', 'forums' );
}
return parent::urlFromIndexData( $indexData, $itemData, $containerData );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Saved Action Node
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 31 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Archived Post Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 24 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums\Topic;
@@ -180,14 +179,13 @@ class _ArchivedPost extends Post
}
/**
* Can give reputation?
* Can react?
*
* @note This method is also ran to check if a member can "unrep"
* @param int $type 1 for positive, -1 for negative
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @return bool
*/
public function canGiveReputation( $type, \IPS\Member $member = NULL )
public function canReact( \IPS\Member $member = NULL )
{
return FALSE;
}
+43 -13
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief Post Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 8 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums\Topic;
@@ -22,8 +21,10 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
/**
* Post Model
*/
class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Reputation, \IPS\Content\Shareable, \IPS\Content\Searchable, \IPS\Content\Embeddable
class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Shareable, \IPS\Content\Searchable, \IPS\Content\Embeddable
{
use \IPS\Content\Reactable;
/**
* @brief [ActiveRecord] Multiton Store
*/
@@ -82,11 +83,6 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \
*/
public static $icon = 'comment';
/**
* @brief Reputation Type
*/
public static $reputationType = 'pid';
/**
* @brief [Content\Comment] Comment Template
*/
@@ -227,9 +223,10 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \
* @param bool $asItem Displaying results as items?
* @param bool $canIgnoreComments Can ignore comments in the result stream? Activity stream can, but search results cannot.
* @param array $template Optional custom template
* @param array $reactions Reaction Data
* @return string
*/
public static function searchResult( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments=FALSE, $template=NULL )
public static function searchResult( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments=FALSE, $template=NULL, $reactions=array() )
{
/* Password protected */
if (
@@ -257,10 +254,21 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \
/* Normal */
else
{
return parent::searchResult( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments, $template );
return parent::searchResult( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments, $template, $reactions );
}
}
/**
* Can promote this comment/item?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @return boolean
*/
public function canPromoteToSocialMedia( $member=NULL )
{
return $this->item()->canPromoteToSocialMedia( $member );
}
/* !Questions & Answers */
/**
@@ -437,4 +445,26 @@ class _Post extends \IPS\Content\Comment implements \IPS\Content\ReportCenter, \
{
return (boolean) $this->post_htmlstate > 0;
}
/**
* Reaction type
*
* @return string
*/
public static function reactionType()
{
return 'pid';
}
/**
* Get content for embed
*
* @param array $params Additional parameters to add to URL
* @return string
*/
public function embedContent( $params )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'forums', 'front' ) );
return \IPS\Theme::i()->getTemplate( 'global', 'forums' )->embedPost( $this, $this->item(), $this->url()->setQueryString( $params ) );
}
}
+98 -10
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief Topic Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 8 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums;
@@ -34,7 +33,8 @@ class _Topic extends \IPS\Content\Item implements
\IPS\Content\Polls, \SplObserver,
\IPS\Content\Ratings,
\IPS\Content\Searchable,
\IPS\Content\Embeddable
\IPS\Content\Embeddable,
\IPS\Content\MetaData
{
const ARCHIVE_NOT = 0;
const ARCHIVE_DONE = 1;
@@ -97,7 +97,8 @@ class _Topic extends \IPS\Content\Item implements
'moved_on' => 'moved_on',
'featured' => 'featured',
'state' => 'state',
'updated' => 'last_post'
'updated' => 'last_post',
'meta_data' => 'topic_meta_data'
);
/**
@@ -1085,6 +1086,17 @@ class _Topic extends \IPS\Content\Item implements
return parent::unhide( $member );
}
/**
* Can promote this comment/item?
*
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
* @return boolean
*/
public function canPromoteToSocialMedia( $member=NULL )
{
return parent::canPromoteToSocialMedia( $member ) and $this->container()->can_view_others;
}
/* !Saved Actions */
@@ -1105,10 +1117,11 @@ class _Topic extends \IPS\Content\Item implements
* @param string $action The action
* @param \IPS\Member|NULL $member The member doing the action (NULL for currently logged in member)
* @param string|NULL $reason Reason (for hides)
* @param bool $immedaitely Delete Immediately
* @return void
* @throws \OutOfRangeException|\InvalidArgumentException|\RuntimeException
*/
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL )
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL, $immediately = FALSE )
{
if ( mb_substr( $action, 0, 12 ) === 'savedAction-' )
{
@@ -1450,6 +1463,23 @@ class _Topic extends \IPS\Content\Item implements
}
return FALSE;
}
/**
* Should this topic be archived again?
*
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
* @return bool
*/
public function canRemoveArchiveExcludeFlag( $member=NULL )
{
$member = $member ?: \IPS\Member::loggedIn();
if ( $member->hasAcpRestriction( 'forums', 'forums', 'archive_manage' ) AND $this->topic_archive_status == static::ARCHIVE_EXCLUDE )
{
return TRUE;
}
return FALSE;
}
/**
* Unarchive confirm message
@@ -1650,6 +1680,41 @@ class _Topic extends \IPS\Content\Item implements
return parent::commentMultimodActions( $member );
}
/**
* Can Feature a Comment
*
* @param \IPS\Member|NULL The member, or NULL for currently logged in
* @return bool
* @note This is a wrapper for the extension so content items can extend and apply their own logic
*/
public function canFeatureComment( \IPS\Member $member = NULL )
{
if ( $this->isArchived() OR $this->isQuestion() )
{
return FALSE;
}
return parent::canFeatureComment( $member );
}
/**
* Can perform an action on a message
*
* @param string The action
* @param \IPS\Member|NULL The member, or NULL for currently logged in
* @return bool
* @note This is a wrapper for the extension so content items can extend and apply their own logic
*/
public function canOnMessage( $action, \IPS\Member $member = NULL )
{
if ( $this->isArchived() )
{
return FALSE;
}
return parent::canOnMessage( $action, $member );
}
/**
* Get comments
*
@@ -1662,9 +1727,10 @@ class _Topic extends \IPS\Content\Item implements
* @param \IPS\DateTime|NULL $cutoff If an \IPS\DateTime object is provided, only comments posted AFTER that date will be included
* @param mixed $extraWhereClause Additional where clause(s) (see \IPS\Db::build for details)
* @param bool|NULL $bypassCache Used in cases where comments may have already been loaded i.e. splitting comments on an item.
* @param bool $includeDeleted Include Deleted Content
* @return array|NULL|\IPS\Content\Comment If $limit is 1, will return \IPS\Content\Comment or NULL for no results. For any other number, will return an array.
*/
public function comments( $limit=NULL, $offset=NULL, $order='date', $orderDirection='asc', $member=NULL, $includeHiddenComments=NULL, $cutoff=NULL, $extraWhereClause=NULL, $bypassCache=FALSE )
public function comments( $limit=NULL, $offset=NULL, $order='date', $orderDirection='asc', $member=NULL, $includeHiddenComments=NULL, $cutoff=NULL, $extraWhereClause=NULL, $bypassCache=FALSE, $includeDeleted=FALSE )
{
static $comments = array();
$idField = static::$databaseColumnId;
@@ -1708,7 +1774,7 @@ class _Topic extends \IPS\Content\Item implements
$class = static::$commentClass;
}
$comments[ $_hash ] = $this->_comments( $class, $limit ?: static::getCommentsPerPage(), $offset, ( isset( $class::$databaseColumnMap[ $order ] ) ? ( $class::$databasePrefix . $class::$databaseColumnMap[ $order ] ) : $order ) . ' ' . $orderDirection, $member, $includeHiddenComments, $cutoff, $includeWarnings, $extraWhereClause );
$comments[ $_hash ] = $this->_comments( $class, $limit ?: static::getCommentsPerPage(), $offset, ( isset( $class::$databaseColumnMap[ $order ] ) ? ( $class::$databasePrefix . $class::$databaseColumnMap[ $order ] ) : $order ) . ' ' . $orderDirection, $member, $includeHiddenComments, $cutoff, $includeWarnings, $extraWhereClause, $includeDeleted );
/* Restore comment class now */
if( $commentClass )
@@ -1873,4 +1939,26 @@ class _Topic extends \IPS\Content\Item implements
$firstComment = $this->firstComment();
return $firstComment ? $firstComment->content() : '';
}
/**
* Supported Meta Data Types
*
* @return array|NULL
*/
public static function supportedMetaDataTypes()
{
return array( 'core_FeaturedComments', 'core_ContentMessages' );
}
/**
* Get content for embed
*
* @param array $params Additional parameters to add to URL
* @return string
*/
public function embedContent( $params )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'forums', 'front' ) );
return \IPS\Theme::i()->getTemplate( 'global', 'forums' )->embedTopic( $this, $this->url()->setQueryString( $params ) );
}
}