Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Advertisement locations extension
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Forums
|
||||
* @since 16 Jul 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\AdvertisementLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Advertisement locations extension
|
||||
*/
|
||||
class _ForumListing
|
||||
{
|
||||
/**
|
||||
* Get the locations and the additional settings
|
||||
*
|
||||
* @param array $settings Current setting values
|
||||
* @return array Array with two elements: 'locations' which should have keys as the location keys and values as the fields to toggle, and 'settings' which are additional fields to add to the form
|
||||
*/
|
||||
public function getSettings( $settings )
|
||||
{
|
||||
return array( 'locations' => array( 'ad_forum_listing' => array() ), 'settings' => array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of setting values to store
|
||||
*
|
||||
* @param array $values Values from the form submission
|
||||
* @return array Array of setting key => value to store
|
||||
*/
|
||||
public function parseSettings( $values )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Advertisement locations extension
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 16 Jul 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\AdvertisementLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Advertisement locations extension
|
||||
*/
|
||||
class _TopicView
|
||||
{
|
||||
/**
|
||||
* Get the locations and the additional settings
|
||||
*
|
||||
* @param array $settings Current setting values
|
||||
* @return array Array with two elements: 'locations' which should have keys as the location keys and values as the fields to toggle, and 'settings' which are additional fields to add to the form
|
||||
*/
|
||||
public function getSettings( $settings )
|
||||
{
|
||||
return array( 'locations' => array( 'ad_topic_view' => array() ), 'settings' => array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of setting values to store
|
||||
*
|
||||
* @param array $values Values from the form submission
|
||||
* @return array Array of setting key => value to store
|
||||
*/
|
||||
public function parseSettings( $values )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Announcements Extension : Forums
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Forums
|
||||
* @since 28 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\Announcements;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Announcements Extension: Forums
|
||||
*/
|
||||
class _Forums
|
||||
{
|
||||
public static $idField = "id";
|
||||
|
||||
public static $controllers = array( "forums", "topic" );
|
||||
|
||||
/**
|
||||
* Get Setting Field
|
||||
*
|
||||
* @param \IPS\core\Announcements\Announcement $announcement
|
||||
* @return Form element
|
||||
*/
|
||||
public function getSettingField( $announcement )
|
||||
{
|
||||
return new \IPS\Helpers\Form\Node( 'announce_forums', ( $announcement AND $announcement->ids ) ? explode( ",", $announcement->ids ) : 0, FALSE, array( 'class' => 'IPS\forums\Forum', 'zeroVal' => 'any', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
{
|
||||
return $forum->sub_can_post and !$forum->redirect_url;
|
||||
} ), NULL, NULL, NULL, 'announce_forums' );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Moderator Permissions: Topics
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 16 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\ContentModeratorPermissions;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moderator Permissions: Topics
|
||||
*/
|
||||
class _Topics
|
||||
{
|
||||
/**
|
||||
* Get Permissions
|
||||
*
|
||||
* @param array $toggles Toggle data
|
||||
* @code
|
||||
return array(
|
||||
'key' => 'YesNo', // Can just return a string with type
|
||||
'key' => array( // Or an array for more options
|
||||
'YesNo', // Type
|
||||
array( ... ), // Options (as defined by type's class)
|
||||
'prefix', // Prefix
|
||||
'suffix', // Suffix
|
||||
),
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissions( $toggles )
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', 'can_view_others=0' )->first() )
|
||||
{
|
||||
$return['can_read_all_topics'] = 'YesNo';
|
||||
}
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', \IPS\Db::i()->bitwiseWhere( \IPS\forums\Forum::$bitOptions['forums_bitoptions'], 'bw_enable_answers' ) )->first() )
|
||||
{
|
||||
$return['can_set_best_answer'] = 'YesNo';
|
||||
}
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'forums_topic_mmod' )->first() )
|
||||
{
|
||||
$return['can_use_saved_actions'] = 'YesNo';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* After change
|
||||
*
|
||||
* @param array $moderator The moderator
|
||||
* @param array $changed Values that were changed
|
||||
* @return void
|
||||
*/
|
||||
public function onChange( $moderator, $changed )
|
||||
{
|
||||
if ( $changed === '*' or array_key_exists( 'can_read_all_topics', $changed ) )
|
||||
{
|
||||
$deleteFirst = TRUE;
|
||||
if ( $changed === '*' or $changed['can_read_all_topics'] == true )
|
||||
{
|
||||
$deleteFirst = FALSE;
|
||||
}
|
||||
|
||||
$this->reindexAuthorOnlyForums( $deleteFirst );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* After change
|
||||
*
|
||||
* @param array $moderator The moderator
|
||||
* @return void
|
||||
*/
|
||||
public function onDelete( $moderator )
|
||||
{
|
||||
$this->reindexAuthorOnlyForums( TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reindex forums where members can only see their own topics
|
||||
*
|
||||
* @param bool $deleteFirst If TRUE, will delete first
|
||||
* @return void
|
||||
*/
|
||||
public function reindexAuthorOnlyForums( $deleteFirst )
|
||||
{
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'forums_forums', 'can_view_others=0' ), 'IPS\forums\Forum' ) as $forum )
|
||||
{
|
||||
if ( $deleteFirst )
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->removeClassFromSearchIndex( 'IPS\forums\Topic', $forum->id );
|
||||
\IPS\Content\Search\Index::i()->removeClassFromSearchIndex( 'IPS\forums\Topic\Post', $forum->id );
|
||||
}
|
||||
\IPS\Task::queue( 'core', 'RebuildSearchIndex', array( 'class' => 'IPS\forums\Topic', 'container' => $forum->id ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildSearchIndex', array( 'class' => 'IPS\forums\Topic\Post', 'container' => $forum->id ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Content Router extension: Topics
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 15 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\ContentRouter;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Content Router extension: Topics
|
||||
*/
|
||||
class _Topics
|
||||
{
|
||||
/**
|
||||
* @brief Content Item Classes
|
||||
*/
|
||||
public $classes = array( 'IPS\forums\Topic' );
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Create Menu Extension : Topic
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Forums
|
||||
* @since 14 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\CreateMenu;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Menu Extension: Topic
|
||||
*/
|
||||
class _Topic
|
||||
{
|
||||
/**
|
||||
* Get Items
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
if ( \IPS\forums\Forum::canOnAny( 'add' ) )
|
||||
{
|
||||
if ( $theOnlyForum = \IPS\forums\Forum::theOnlyForum() )
|
||||
{
|
||||
return array(
|
||||
'topic' => array(
|
||||
'link' => $theOnlyForum->url()->setQueryString( 'do', 'add' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
'topic' => array(
|
||||
'link' => \IPS\Http\Url::internal( "app=forums&module=forums&controller=forums&do=createMenu", 'front', 'topic_create' ),
|
||||
'extraData' => array( 'data-ipsDialog' => true, 'data-ipsDialog-size' => "narrow" ),
|
||||
'title' => 'select_forum'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Forums
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 08 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\EditorLocations;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Forums
|
||||
*/
|
||||
class _Forums
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $id3 )
|
||||
{
|
||||
return \IPS\forums\Forum::load( $id1 )->can( 'attachments', $member );
|
||||
}
|
||||
elseif ( $id2 )
|
||||
{
|
||||
$post = \IPS\forums\Topic\Post::load( $id2 );
|
||||
|
||||
/* Check forums attachments permission */
|
||||
if ( $post->container()->can( 'attachments', $member ) )
|
||||
{
|
||||
/* Can we view post? */
|
||||
return $post->canView( $member );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic = \IPS\forums\Topic::load( $id1 );
|
||||
|
||||
/* Check forums attachments permission */
|
||||
if ( $topic->container()->can( 'attachments', $member ) )
|
||||
{
|
||||
/* Can we view the topic? */
|
||||
return \IPS\forums\Topic::load( $id1 )->canView( $member );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
if ( $id3 )
|
||||
{
|
||||
return \IPS\forums\Forum::load( $id1 );
|
||||
}
|
||||
elseif ( $id2 )
|
||||
{
|
||||
return \IPS\forums\Topic\Post::load( $id2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\forums\Topic::load( $id1 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild attachment images in non-content item areas
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildAttachmentImages( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\Parser', 'rebuildAttachmentUrls' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild content post-upgrade
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildContent( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\LegacyParser', 'parseStatic' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @param callable $callback Method to call to rebuild content
|
||||
* @return int Number completed
|
||||
*/
|
||||
protected function performRebuild( $offset, $max, $callback )
|
||||
{
|
||||
$did = 0;
|
||||
|
||||
/* Language bits */
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', "word_key LIKE 'forums_forum_%_desc' OR word_key LIKE 'forums_forum_%_rules' OR word_key LIKE 'forums_forum_%_permerror'", 'word_id ASC', array( $offset, $max ) ) as $word )
|
||||
{
|
||||
$did++;
|
||||
|
||||
try
|
||||
{
|
||||
$rebuilt = call_user_func( $callback, $word['word_custom'] );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
$rebuilt = preg_replace( "#\[/?([^\]]+?)\]#", '', $word['word_custom'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if( $rebuilt !== FALSE )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $did;
|
||||
}
|
||||
|
||||
/**
|
||||
* Total content count to be used in progress indicator
|
||||
*
|
||||
* @return int Total Count
|
||||
*/
|
||||
public function contentCount()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'core_sys_lang_words', "word_key LIKE 'forums_forum_%_desc' OR word_key LIKE 'forums_forum_%_rules' OR word_key LIKE 'forums_forum_%_permerror'" )->first();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Icons
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 06 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\FileStorage;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Icons
|
||||
*/
|
||||
class _Icons
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'forums_forums', 'icon IS NOT NULL' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$forum = \IPS\forums\Forum::constructFromData( \IPS\Db::i()->select( '*', 'forums_forums', 'icon IS NOT NULL', 'id', array( $offset, 1 ) )->first() );
|
||||
|
||||
try
|
||||
{
|
||||
$forum->icon = \IPS\File::get( $oldConfiguration ?: 'forums_Icons', $forum->icon )->move( $storageConfiguration );
|
||||
$forum->save();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$forum = \IPS\forums\Forum::constructFromData( \IPS\Db::i()->select( '*', 'forums_forums', 'icon IS NOT NULL', 'id', array( $offset, 1 ) )->first() );
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $forum->icon ) )
|
||||
{
|
||||
$forum->icon = $new;
|
||||
$forum->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 'id', 'forums_forums', array( 'icon=?', $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'forums_forums', "icon IS NOT NULL" ) as $forum )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'forums_Icons', $forum['icon'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Front Navigation Extension: Forums
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Board
|
||||
* @since 08 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\FrontNavigation;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Forums
|
||||
*/
|
||||
class _Forums
|
||||
{
|
||||
/**
|
||||
* Can access?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
{
|
||||
return !\IPS\Application::load('forums')->hide_tab and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'forums', 'forums' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('frontnavigation_forums');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=forums&module=forums&controller=index", 'front', 'forums' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'forums';
|
||||
}
|
||||
|
||||
/**
|
||||
* Children
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Live Search Extension
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Forums
|
||||
* @since 08 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\LiveSearch;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Live Search Extension
|
||||
*/
|
||||
class _Forums
|
||||
{
|
||||
/**
|
||||
* Check we have access
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function hasAccess()
|
||||
{
|
||||
/* Check Permissions */
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'forums_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the search results
|
||||
*
|
||||
* @param string Search Term
|
||||
* @return array Array of results
|
||||
*/
|
||||
public function getResults( $searchTerm )
|
||||
{
|
||||
/* Init */
|
||||
$results = array();
|
||||
$searchTerm = mb_strtolower( $searchTerm );
|
||||
|
||||
/* Start with categories */
|
||||
if( $this->hasAccess() )
|
||||
{
|
||||
/* Perform the search */
|
||||
$forums = \IPS\Db::i()->select(
|
||||
"*",
|
||||
'forums_forums',
|
||||
array( "word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=?", $searchTerm, \IPS\Member::loggedIn()->language()->id ),
|
||||
NULL,
|
||||
NULL
|
||||
)->join(
|
||||
'core_sys_lang_words',
|
||||
"word_key=CONCAT( 'forums_forum_', id )"
|
||||
);
|
||||
|
||||
/* Format results */
|
||||
foreach ( $forums as $forum )
|
||||
{
|
||||
$forum = \IPS\forums\Forum::constructFromData( $forum );
|
||||
|
||||
$results[] = \IPS\Theme::i()->getTemplate( 'livesearch', 'forums', 'admin' )->forum( $forum );
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Member Sync
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 14 Jul 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\MemberSync;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member Sync
|
||||
*/
|
||||
class _Forums
|
||||
{
|
||||
/**
|
||||
* Member is merged with another member
|
||||
*
|
||||
* @param \IPS\Member $member Member being kept
|
||||
* @param \IPS\Member $member2 Member being removed
|
||||
* @return void
|
||||
*/
|
||||
public function onMerge( $member, $member2 )
|
||||
{
|
||||
\IPS\Db::i()->update( 'forums_answer_ratings', array( 'member' => $member->member_id ), array( 'member=?', $member2->member_id ), array(), NULL, \IPS\Db::IGNORE );
|
||||
\IPS\Db::i()->update( 'forums_question_ratings', array( 'member' => $member->member_id ), array( 'member=?', $member2->member_id ), array(), NULL, \IPS\Db::IGNORE );
|
||||
\IPS\Db::i()->update( 'forums_rss_import', array( 'rss_import_mid' => $member->member_id ), array( 'rss_import_mid=?', $member2->member_id ) );
|
||||
|
||||
if ( \IPS\Settings::i()->archive_on )
|
||||
{
|
||||
$archiveStorage = !\IPS\Settings::i()->archive_remote_sql_host ? \IPS\Db::i() : \IPS\Db::i( 'archive', array(
|
||||
'sql_host' => \IPS\Settings::i()->archive_remote_sql_host,
|
||||
'sql_user' => \IPS\Settings::i()->archive_remote_sql_user,
|
||||
'sql_pass' => \IPS\Settings::i()->archive_remote_sql_pass,
|
||||
'sql_database' => \IPS\Settings::i()->archive_remote_sql_database,
|
||||
'sql_port' => \IPS\Settings::i()->archive_sql_port,
|
||||
'sql_socket' => \IPS\Settings::i()->archive_sql_socket,
|
||||
'sql_tbl_prefix'=> \IPS\Settings::i()->archive_sql_tbl_prefix,
|
||||
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
|
||||
) );
|
||||
$archiveStorage->update( 'forums_archive_posts', array( 'archive_author_id' => $member->member_id ), array( 'archive_author_id=?', $member2->member_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Member is deleted
|
||||
*
|
||||
* @param $member \IPS\Member The member
|
||||
* @return void
|
||||
*/
|
||||
public function onDelete( $member )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'forums_answer_ratings', array( 'member=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'forums_question_ratings', array( 'member=?', $member->member_id ) );
|
||||
\IPS\Db::i()->update( 'forums_rss_import', array( 'rss_import_mid' => 0 ), array( 'rss_import_mid=?', $member->member_id ) );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Permissions
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 16 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\Permissions;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permissions
|
||||
*/
|
||||
class _Permissions
|
||||
{
|
||||
/**
|
||||
* Get node classes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNodeClasses()
|
||||
{
|
||||
return array(
|
||||
'IPS\forums\Forum' => function( $current, $group )
|
||||
{
|
||||
$rows = array();
|
||||
|
||||
foreach( \IPS\forums\Forum::roots( NULL ) AS $root )
|
||||
{
|
||||
\IPS\forums\Forum::populatePermissionMatrix( $rows, $root, $group, $current );
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Forums
|
||||
* @since 18 Mar 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\Queue;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Task
|
||||
*/
|
||||
class _DeleteLegacyPosts
|
||||
{
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int|null New offset or NULL if complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$select = \IPS\Db::i()->select( '*', 'forums_posts', 'queued > 2', 'pid ASC', array( 0, 5 ) );
|
||||
if ( !count( $select ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$done = 0;
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\forums\Topic\Post' ) as $post )
|
||||
{
|
||||
$post->delete();
|
||||
$done++;
|
||||
}
|
||||
|
||||
return $offset + $done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaning task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', 'queued > 2' )->first();
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('queue_deleting_legacy_posts'), 'complete' => 100 / ( $count ?: 1 + $offset ) * $offset );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Background Task
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Forums
|
||||
* @since 18 Mar 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\forums\extensions\core\Queue;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Task
|
||||
*/
|
||||
class _DeleteLegacyTopics
|
||||
{
|
||||
/**
|
||||
* Run Background Task
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return int|null New offset or NULL if complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function run( $data, $offset )
|
||||
{
|
||||
$select = \IPS\Db::i()->select( '*', 'forums_topics', 'approved > 1', 'tid ASC', array( 0, 5 ) );
|
||||
if ( !count( $select ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$done = 0;
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\forums\Topic' ) as $topic )
|
||||
{
|
||||
$topic->delete();
|
||||
$done++;
|
||||
}
|
||||
|
||||
return $offset + $done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Progress
|
||||
*
|
||||
* @param mixed $data Data as it was passed to \IPS\Task::queue()
|
||||
* @param int $offset Offset
|
||||
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaning task and percentage complete
|
||||
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
|
||||
*/
|
||||
public function getProgress( $data, $offset )
|
||||
{
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', 'approved > 1' )->first();
|
||||
return array( 'text' => \IPS\Member::loggedIn()->language()->addToStack('queue_deleting_legacy_topics'), 'complete' => 100 / ( $count ?: 1 + $offset ) * $offset );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user