Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,35 +12,45 @@
|
||||
namespace IPS\forums\modules\admin\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\forums\Forum;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* forums
|
||||
*/
|
||||
class _forums extends \IPS\Node\Controller
|
||||
class forums extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\forums\Forum';
|
||||
protected string $nodeClass = 'IPS\forums\Forum';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'forums_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'forums_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,77 +59,29 @@ class _forums extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function permissions()
|
||||
protected function permissions() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$forum = \IPS\forums\Forum::load( \IPS\Request::i()->id );
|
||||
|
||||
if ( $forum->min_posts_view )
|
||||
$forum = Forum::load( Request::i()->id );
|
||||
|
||||
if ( $forum->password and !$forum->can_view_others )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__view'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__view_rest', FALSE, array( 'pluralize' => array( $forum->min_posts_view ) ) );
|
||||
Member::loggedIn()->language()->words['perm_forum_perm__read'] = Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read2_pass', FALSE );
|
||||
}
|
||||
elseif ( !$forum->can_view_others )
|
||||
{
|
||||
Member::loggedIn()->language()->words['perm_forum_perm__read'] = Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read2', FALSE );
|
||||
}
|
||||
elseif ( $forum->password )
|
||||
{
|
||||
Member::loggedIn()->language()->words['perm_forum_perm__read'] = Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read_pass', FALSE );
|
||||
}
|
||||
|
||||
if ( $forum->forums_bitoptions['bw_enable_answers'] )
|
||||
{
|
||||
if ( $forum->password and !$forum->can_view_others )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__read'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read2_qa_pass', FALSE );
|
||||
}
|
||||
elseif ( !$forum->can_view_others )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__read'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read2_qa', FALSE );
|
||||
}
|
||||
elseif ( $forum->password )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__read'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read_qa_pass', FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__read'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read_qa', FALSE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $forum->password and !$forum->can_view_others )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__read'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read2_pass', FALSE );
|
||||
}
|
||||
elseif ( !$forum->can_view_others )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__read'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read2', FALSE );
|
||||
}
|
||||
elseif ( $forum->password )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__read'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__read_pass', FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $forum->forums_bitoptions['bw_enable_answers'] )
|
||||
{
|
||||
if ( $forum->min_posts_post )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__add'] = \IPS\Member::loggedIn()->language()->addToStack('perm_forum_perm__add_qa_rest', FALSE, array( 'pluralize' => array( $forum->min_posts_post ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__reply'] = \IPS\Member::loggedIn()->language()->addToStack('perm_forum_perm__reply_qa_rest', FALSE, array( 'pluralize' => array( $forum->min_posts_post ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__add'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__add_qa', FALSE, array( 'pluralize' => array( $forum->min_posts_post ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__reply'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__reply_qa', FALSE, array( 'pluralize' => array( $forum->min_posts_post ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $forum->min_posts_post )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__add'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__add_rest', FALSE, array( 'pluralize' => array( $forum->min_posts_post ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words['perm_forum_perm__reply'] = \IPS\Member::loggedIn()->language()->addToStack( 'perm_forum_perm__reply_rest', FALSE, array( 'pluralize' => array( $forum->min_posts_post ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
catch ( OutOfRangeException $e ) {}
|
||||
|
||||
return parent::permissions();
|
||||
parent::permissions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,17 +89,51 @@ class _forums extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function form()
|
||||
protected function form() : void
|
||||
{
|
||||
parent::form();
|
||||
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('edit_forum') . ': ' . \IPS\Output::i()->title;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('edit_forum') . ': ' . Output::i()->title;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('add_forum');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('add_forum');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete(): void
|
||||
{
|
||||
/* Load forum and verify that it is not used for comments */
|
||||
/** @var Forum $nodeClass */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( Request::i()->id );
|
||||
}
|
||||
catch (OutOfRangeException $e )
|
||||
{
|
||||
Output::i()->error( 'node_error', '2S101/J', 404, '' );
|
||||
}
|
||||
|
||||
/* Is any downloads category synced with this forum? */
|
||||
if ( $dbCategory = $node->isUsedByADownloadsCategory() )
|
||||
{
|
||||
Member::loggedIn()->language()->words['downloads_forum_used'] = sprintf( Member::loggedIn()->language()->get('downloads_forum_used'), $dbCategory->_title );
|
||||
Output::i()->error( 'downloads_forum_used', '1D372/1', 403, '' );
|
||||
}
|
||||
|
||||
parent::delete();
|
||||
}
|
||||
}
|
||||
@@ -12,35 +12,40 @@
|
||||
namespace IPS\forums\modules\admin\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Node\Controller;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* savedActions
|
||||
*/
|
||||
class _savedActions extends \IPS\Node\Controller
|
||||
class savedActions extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\forums\SavedAction';
|
||||
protected string $nodeClass = 'IPS\forums\SavedAction';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'savedActions_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'savedActions_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
}
|
||||
@@ -12,53 +12,86 @@
|
||||
namespace IPS\forums\modules\admin\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Topic;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Custom;
|
||||
use IPS\Helpers\Form\Member as FormMember;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings as SettingsClass;
|
||||
use IPS\Theme;
|
||||
use LengthException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function IPS\Cicloud\getForumArchiveForm;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* settings
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
class settings extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Manage Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_access' );
|
||||
Dispatcher::i()->checkAcpPermission( 'settings_access' );
|
||||
|
||||
$tabs = array();
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'forum_settings' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'forum_settings' ) )
|
||||
{
|
||||
$tabs['settings'] = 'forum_settings';
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'archive_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'archive_manage' ) )
|
||||
{
|
||||
$tabs['archiving'] = 'archiving';
|
||||
}
|
||||
|
||||
$activeTab = \IPS\Request::i()->tab ?: 'settings';
|
||||
$methodFunction = 'manage' . mb_ucfirst( $activeTab );
|
||||
$activeTab = Request::i()->tab ?: 'settings';
|
||||
$methodFunction = 'manage' . IPS::mb_ucfirst( $activeTab );
|
||||
$activeTabContents = $this->$methodFunction();
|
||||
|
||||
if( \IPS\Request::i()->isAjax() and !isset( \IPS\Request::i()->ajaxValidate ) )
|
||||
if( Request::i()->isAjax() and !isset( Request::i()->ajaxValidate ) )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
Output::i()->output = $activeTabContents;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__forums_forums_settings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=forums&module=forums&controller=settings" ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__forums_forums_settings');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $activeTabContents, Url::internal( "app=forums&module=forums&controller=settings" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,10 +100,15 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function manageArchiving()
|
||||
protected function manageArchiving(): string
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'archive_manage' );
|
||||
|
||||
Dispatcher::i()->checkAcpPermission( 'archive_manage' );
|
||||
|
||||
if ( Application::appIsEnabled('cloud') )
|
||||
{
|
||||
return getForumArchiveForm();
|
||||
}
|
||||
|
||||
return $this->manageArchivingForm();
|
||||
}
|
||||
|
||||
@@ -79,14 +117,14 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function manageArchivingForm()
|
||||
protected function manageArchivingForm(): string
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_settings.js', 'forums', 'admin' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_settings.js', 'forums', 'admin' ) );
|
||||
|
||||
/* Init */
|
||||
$maxTopics = \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics' )->first();
|
||||
$existingRules = iterator_to_array( \IPS\Db::i()->select( '*', 'forums_archive_rules' ) );
|
||||
$existingCount = \IPS\Settings::i()->archive_on ? \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', array_merge( array( array( 'topic_archive_status!=?', \IPS\forums\Topic::ARCHIVE_EXCLUDE ) ), \IPS\Application::load('forums')->archiveWhere( $existingRules ) ) )->first() : 0;
|
||||
$maxTopics = Db::i()->select( 'COUNT(*)', 'forums_topics' )->first();
|
||||
$existingRules = iterator_to_array( Db::i()->select( '*', 'forums_archive_rules' ) );
|
||||
$existingCount = SettingsClass::i()->archive_on ? Db::i()->select( 'COUNT(*)', 'forums_topics', array_merge( array( array( 'topic_archive_status!=?', Topic::ARCHIVE_EXCLUDE ) ), Application::load('forums')->archiveWhere( $existingRules ) ) )->first() : 0;
|
||||
|
||||
/* Work out existing values */
|
||||
$existingValues = array();
|
||||
@@ -138,24 +176,17 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
break;
|
||||
|
||||
case 'member':
|
||||
$members = array();
|
||||
foreach( explode( ',', $rule['archive_text'] ) AS $v )
|
||||
{
|
||||
$members[] = Member::load( $v );
|
||||
}
|
||||
if ( $rule['archive_value'] == '+' )
|
||||
{
|
||||
$members = array();
|
||||
foreach( explode( ',', $rule['archive_text'] ) AS $v )
|
||||
{
|
||||
$members[] = \IPS\Member::load( $v );
|
||||
}
|
||||
|
||||
$existingValues['archive_topic_starter'] = $members;
|
||||
}
|
||||
else
|
||||
{
|
||||
$members = array();
|
||||
foreach( explode( ',', $rule['archive_text'] ) AS $v )
|
||||
{
|
||||
$members[] = \IPS\Member::load( $v );
|
||||
}
|
||||
|
||||
$existingValues['archive_topic_starter_not'] = $members;
|
||||
}
|
||||
break;
|
||||
@@ -163,10 +194,10 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
$form->attributes['id'] = 'elArchiveForm';
|
||||
$form->addHeader( 'archive_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'archive_on', \IPS\Settings::i()->archive_on, FALSE, array(
|
||||
$form->add( new YesNo( 'archive_on', SettingsClass::i()->archive_on, FALSE, array(
|
||||
'togglesOn' => array(
|
||||
'archive_storage_location',
|
||||
'archive_last_post',
|
||||
@@ -191,45 +222,45 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
)
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'archive_storage_location', \IPS\Settings::i()->archive_remote_sql_host ? 'remote' : 'local', FALSE, array(
|
||||
$form->add( new Radio( 'archive_storage_location', SettingsClass::i()->archive_remote_sql_host ? 'remote' : 'local', FALSE, array(
|
||||
'options' => array( 'local' => 'archive_storage_location_local', 'remote' => 'archive_storage_location_remote' ),
|
||||
'toggles' => array( 'remote' => array( 'archive_sql_host', 'archive_sql_user', 'archive_sql_pass', 'archive_sql_database', 'archive_sql_port', 'archive_sql_socket', 'archive_sql_tbl_prefix' ) )
|
||||
), NULL, NULL, NULL, 'archive_storage_location' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'archive_remote_sql_host', \IPS\Settings::i()->archive_remote_sql_host ?: ini_get('mysqli.default_host') ?: 'localhost', FALSE, array(), NULL, NULL, NULL, 'archive_sql_host' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'archive_remote_sql_user', \IPS\Settings::i()->archive_remote_sql_user ?: ini_get('mysqli.default_user'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_user' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'archive_remote_sql_pass', \IPS\Settings::i()->archive_remote_sql_pass ?: ini_get('mysqli.default_pw'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_pass' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'archive_remote_sql_database', \IPS\Settings::i()->archive_remote_sql_database ?: NULL, FALSE, array(), NULL, NULL, NULL, 'archive_sql_database' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'archive_sql_port', \IPS\Settings::i()->archive_sql_port ?: ini_get('mysqli.default_port'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_port' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'archive_sql_socket', \IPS\Settings::i()->archive_sql_socket ?: ini_get('mysqli.default_socket'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_socket' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'archive_sql_tbl_prefix', \IPS\Settings::i()->archive_sql_tbl_prefix ?: NULL, FALSE, array(), NULL, NULL, NULL, 'archive_sql_tbl_prefix' ) );
|
||||
$form->add( new Text( 'archive_remote_sql_host', SettingsClass::i()->archive_remote_sql_host ?: ini_get('mysqli.default_host') ?: 'localhost', FALSE, array(), NULL, NULL, NULL, 'archive_sql_host' ) );
|
||||
$form->add( new Text( 'archive_remote_sql_user', SettingsClass::i()->archive_remote_sql_user ?: ini_get('mysqli.default_user'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_user' ) );
|
||||
$form->add( new Text( 'archive_remote_sql_pass', SettingsClass::i()->archive_remote_sql_pass ?: ini_get('mysqli.default_pw'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_pass' ) );
|
||||
$form->add( new Text( 'archive_remote_sql_database', SettingsClass::i()->archive_remote_sql_database ?: NULL, FALSE, array(), NULL, NULL, NULL, 'archive_sql_database' ) );
|
||||
$form->add( new Number( 'archive_sql_port', SettingsClass::i()->archive_sql_port ?: ini_get('mysqli.default_port'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_port' ) );
|
||||
$form->add( new Text( 'archive_sql_socket', SettingsClass::i()->archive_sql_socket ?: ini_get('mysqli.default_socket'), FALSE, array(), NULL, NULL, NULL, 'archive_sql_socket' ) );
|
||||
$form->add( new Text( 'archive_sql_tbl_prefix', SettingsClass::i()->archive_sql_tbl_prefix ?: NULL, FALSE, array(), NULL, NULL, NULL, 'archive_sql_tbl_prefix' ) );
|
||||
|
||||
|
||||
$form->addHeader( 'archive_topics_where' );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_last_post', isset( $existingValues['archive_last_post'] ) ? $existingValues['archive_last_post'] : array( '>', 0, 'm', TRUE ), FALSE, array( 'getHtml' => array( $this, '_beforeAfterTimeAgo' ), 'validate' => array( $this, '_validateBeforeAfterTimeAgo' ) ), NULL, NULL, NULL, 'archive_last_post' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'archive_topic_forums', isset( $existingValues['archive_topic_forums'] ) ? $existingValues['archive_topic_forums'] : 0, FALSE, array( 'class' => 'IPS\forums\Forum', 'zeroVal' => 'any', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
$form->add( new Custom( 'archive_last_post', $existingValues['archive_last_post'] ?? array( '>', 0, 'm', TRUE ), FALSE, array( 'getHtml' => array( $this, '_beforeAfterTimeAgo' ), 'validate' => array( $this, '_validateBeforeAfterTimeAgo' ) ), NULL, NULL, NULL, 'archive_last_post' ) );
|
||||
$form->add( new Node( 'archive_topic_forums', $existingValues['archive_topic_forums'] ?? 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, 'archive_topic_forums' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'archive_topic_pinned', isset( $existingValues['archive_topic_pinned'] ) ? $existingValues['archive_topic_pinned'] : array( 1, 0 ), FALSE, array( 'options' => array( 1 => 'pinned', 0 => 'mod_confirm_unpin' ) ), NULL, NULL, NULL, 'archive_topic_pinned' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'archive_topic_featured', isset( $existingValues['archive_topic_featured'] ) ? $existingValues['archive_topic_featured'] : array( 1, 0 ), FALSE, array( 'options' => array( 1 => 'featured', 0 => 'mod_confirm_unfeature' ) ), NULL, NULL, NULL, 'archive_topic_featured' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'archive_topic_state', isset( $existingValues['archive_topic_state'] ) ? $existingValues['archive_topic_state'] : array( 'closed', 'open' ), FALSE, array( 'options' => array( 'closed' => 'locked', 'open' => 'unlocked' ) ), NULL, NULL, NULL, 'archive_topic_state' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'archive_topic_approved', isset( $existingValues['archive_topic_approved'] ) ? $existingValues['archive_topic_approved'] : array( -1, 1 ), FALSE, array( 'options' => array( -1 => 'hidden', 1 => 'unhidden' ) ), NULL, NULL, NULL, 'archive_topic_approved' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'archive_topic_poll', isset( $existingValues['archive_topic_poll'] ) ? $existingValues['archive_topic_poll'] : array( 1, 0 ), FALSE, array( 'options' => array( 1 => 'topic_has_poll', 0 => 'topic_does_not_have_poll' ) ), NULL, NULL, NULL, 'archive_topic_poll' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_topic_post', isset( $existingValues['archive_topic_post'] ) ? $existingValues['archive_topic_post'] : array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_topic_post' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_topic_view', isset( $existingValues['archive_topic_view'] ) ? $existingValues['archive_topic_view'] : array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_topic_view' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_topic_rating', isset( $existingValues['archive_topic_rating'] ) ? $existingValues['archive_topic_rating'] : array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_topic_rating' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'archive_topic_starter', isset( $existingValues['archive_topic_starter'] ) ? $existingValues['archive_topic_starter'] : array(), FALSE, array( 'multiple' => 999999 ), NULL, NULL, NULL, 'archive_topic_starter' ) );
|
||||
$form->add( new CheckboxSet( 'archive_topic_pinned', $existingValues['archive_topic_pinned'] ?? array( 1, 0 ), FALSE, array( 'options' => array( 1 => 'pinned', 0 => 'mod_confirm_unpin' ) ), NULL, NULL, NULL, 'archive_topic_pinned' ) );
|
||||
$form->add( new CheckboxSet( 'archive_topic_featured', $existingValues['archive_topic_featured'] ?? array( 1, 0 ), FALSE, array( 'options' => array( 1 => 'featured', 0 => 'mod_confirm_unfeature' ) ), NULL, NULL, NULL, 'archive_topic_featured' ) );
|
||||
$form->add( new CheckboxSet( 'archive_topic_state', $existingValues['archive_topic_state'] ?? array( 'closed', 'open' ), FALSE, array( 'options' => array( 'closed' => 'locked', 'open' => 'unlocked' ) ), NULL, NULL, NULL, 'archive_topic_state' ) );
|
||||
$form->add( new CheckboxSet( 'archive_topic_approved', $existingValues['archive_topic_approved'] ?? array( -1, 1 ), FALSE, array( 'options' => array( -1 => 'hidden', 1 => 'unhidden' ) ), NULL, NULL, NULL, 'archive_topic_approved' ) );
|
||||
$form->add( new CheckboxSet( 'archive_topic_poll', $existingValues['archive_topic_poll'] ?? array( 1, 0 ), FALSE, array( 'options' => array( 1 => 'topic_has_poll', 0 => 'topic_does_not_have_poll' ) ), NULL, NULL, NULL, 'archive_topic_poll' ) );
|
||||
$form->add( new Custom( 'archive_topic_post', $existingValues['archive_topic_post'] ?? array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_topic_post' ) );
|
||||
$form->add( new Custom( 'archive_topic_view', $existingValues['archive_topic_view'] ?? array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_topic_view' ) );
|
||||
$form->add( new Custom( 'archive_topic_rating', $existingValues['archive_topic_rating'] ?? array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_topic_rating' ) );
|
||||
$form->add( new FormMember( 'archive_topic_starter', $existingValues['archive_topic_starter'] ?? array(), FALSE, array( 'multiple' => 999999 ), NULL, NULL, NULL, 'archive_topic_starter' ) );
|
||||
$form->addHeader( 'archive_topics_not_where' );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'archive_topic_not_forums', isset( $existingValues['archive_topic_not_forums'] ) ? $existingValues['archive_topic_not_forums'] : array(), FALSE, array( 'class' => 'IPS\forums\Forum', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
$form->add( new Node( 'archive_topic_not_forums', $existingValues['archive_topic_not_forums'] ?? array(), FALSE, array( 'class' => 'IPS\forums\Forum', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
{
|
||||
return $forum->sub_can_post and !$forum->redirect_url;
|
||||
} ), NULL, NULL, NULL, 'archive_topic_not_forums' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_not_topic_post', isset( $existingValues['archive_not_topic_post'] ) ? $existingValues['archive_not_topic_post'] : array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_not_topic_post' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_not_topic_view', isset( $existingValues['archive_not_topic_view'] ) ? $existingValues['archive_not_topic_view'] : array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_not_topic_view' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_not_topic_rating', isset( $existingValues['archive_not_topic_rating'] ) ? $existingValues['archive_not_topic_rating'] : array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_not_topic_rating' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'archive_not_last_post', isset( $existingValues['archive_not_last_post'] ) ? $existingValues['archive_not_last_post'] : array( '>', 0, 'm', TRUE ), FALSE, array( 'getHtml' => array( $this, '_beforeAfterTimeAgo' ), 'validate' => array( $this, '_validateBeforeAfterTimeAgo' ) ), NULL, NULL, NULL, 'archive_not_last_post' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'archive_topic_starter_not', isset( $existingValues['archive_topic_starter_not'] ) ? $existingValues['archive_topic_starter_not'] : array(), FALSE, array( 'multiple' => 999999 ), NULL, NULL, NULL, 'archive_topic_starter_not' ) );
|
||||
$form->add( new Custom( 'archive_not_topic_post', $existingValues['archive_not_topic_post'] ?? array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_not_topic_post' ) );
|
||||
$form->add( new Custom( 'archive_not_topic_view', $existingValues['archive_not_topic_view'] ?? array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_not_topic_view' ) );
|
||||
$form->add( new Custom( 'archive_not_topic_rating', $existingValues['archive_not_topic_rating'] ?? array( NULL, NULL, TRUE ), FALSE, array( 'getHtml' => array( $this, '_greaterThanLessThanField' ) ), NULL, NULL, NULL, 'archive_not_topic_rating' ) );
|
||||
$form->add( new Custom( 'archive_not_last_post', $existingValues['archive_not_last_post'] ?? array( '>', 0, 'm', TRUE ), FALSE, array( 'getHtml' => array( $this, '_beforeAfterTimeAgo' ), 'validate' => array( $this, '_validateBeforeAfterTimeAgo' ) ), NULL, NULL, NULL, 'archive_not_last_post' ) );
|
||||
$form->add( new FormMember( 'archive_topic_starter_not', $existingValues['archive_topic_starter_not'] ?? array(), FALSE, array( 'multiple' => 999999 ), NULL, NULL, NULL, 'archive_topic_starter_not' ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -238,7 +269,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
$rules = array();
|
||||
foreach ( $values as $k => $v )
|
||||
{
|
||||
if ( \in_array( $k, array( 'archive_last_post' ) ) )
|
||||
if ( in_array( $k, array( 'archive_last_post' ) ) )
|
||||
{
|
||||
if ( ( !isset( $v[3] ) or !$v[3] ) and $v[1] )
|
||||
{
|
||||
@@ -253,7 +284,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif ( \in_array( $k, array( 'archive_not_last_post' ) ) )
|
||||
elseif ( in_array( $k, array( 'archive_not_last_post' ) ) )
|
||||
{
|
||||
if ( ( !isset( $v[3] ) or !$v[3] ) and $v[1] )
|
||||
{
|
||||
@@ -268,7 +299,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif( \in_array( $k, array( 'archive_topic_forums' ) ) )
|
||||
elseif( in_array( $k, array( 'archive_topic_forums' ) ) )
|
||||
{
|
||||
if ( !empty( $v ) )
|
||||
{
|
||||
@@ -283,7 +314,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif( \in_array( $k, array( 'archive_topic_not_forums' ) ) )
|
||||
elseif( in_array( $k, array( 'archive_topic_not_forums' ) ) )
|
||||
{
|
||||
if ( !empty( $v ) )
|
||||
{
|
||||
@@ -298,9 +329,9 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif ( \in_array( $k, array( 'archive_topic_pinned', 'archive_topic_featured', 'archive_topic_state', 'archive_topic_approved', 'archive_topic_poll' ) ) )
|
||||
elseif ( in_array( $k, array( 'archive_topic_pinned', 'archive_topic_featured', 'archive_topic_state', 'archive_topic_approved', 'archive_topic_poll' ) ) )
|
||||
{
|
||||
if ( !empty( $v ) and \count( $v ) == 1 )
|
||||
if ( !empty( $v ) and count( $v ) == 1 )
|
||||
{
|
||||
$rules[] = array(
|
||||
'archive_key' => md5( "forums_{$k}" ),
|
||||
@@ -313,7 +344,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif( \in_array( $k, array( 'archive_topic_post', 'archive_topic_view', 'archive_topic_rating' ) ) )
|
||||
elseif( in_array( $k, array( 'archive_topic_post', 'archive_topic_view', 'archive_topic_rating' ) ) )
|
||||
{
|
||||
if ( !isset( $v[2] ) and $v[1] and $v[0] )
|
||||
{
|
||||
@@ -328,7 +359,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif( \in_array( $k, array( 'archive_not_topic_post', 'archive_not_topic_view', 'archive_not_topic_rating' ) ) )
|
||||
elseif( in_array( $k, array( 'archive_not_topic_post', 'archive_not_topic_view', 'archive_not_topic_rating' ) ) )
|
||||
{
|
||||
if ( !isset( $v[2] ) and $v[1] and $v[0] )
|
||||
{
|
||||
@@ -343,9 +374,9 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif( \in_array( $k, array( 'archive_topic_starter' ) ) )
|
||||
elseif( in_array( $k, array( 'archive_topic_starter' ) ) )
|
||||
{
|
||||
if ( \is_array( $v ) and \count( $v ) )
|
||||
if ( is_array( $v ) and count( $v ) )
|
||||
{
|
||||
$ids = array();
|
||||
foreach( $v AS $member )
|
||||
@@ -364,9 +395,9 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
elseif( \in_array( $k, array( 'archive_topic_starter_not' ) ) )
|
||||
elseif( in_array( $k, array( 'archive_topic_starter_not' ) ) )
|
||||
{
|
||||
if ( \is_array( $v ) AND \count( $v ) )
|
||||
if ( is_array( $v ) AND count( $v ) )
|
||||
{
|
||||
$ids = array();
|
||||
foreach( $v AS $member )
|
||||
@@ -388,7 +419,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Did we just want a new count? */
|
||||
if ( isset( \IPS\Request::i()->getCount ) )
|
||||
if ( isset( Request::i()->getCount ) )
|
||||
{
|
||||
if ( !$values['archive_on'] )
|
||||
{
|
||||
@@ -396,9 +427,9 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', array_merge( array( array( 'topic_archive_status!=?', \IPS\forums\Topic::ARCHIVE_EXCLUDE ) ), \IPS\Application::load('forums')->archiveWhere( $rules ) ) )->first();
|
||||
$count = Db::i()->select( 'COUNT(*)', 'forums_topics', array_merge( array( array( 'topic_archive_status!=?', Topic::ARCHIVE_EXCLUDE ) ), Application::load('forums')->archiveWhere( $rules ) ) )->first();
|
||||
}
|
||||
\IPS\Output::i()->json( array( 'count' => $count, 'percentage' => ( $maxTopics * $count > 0 ) ? round( 100 / $maxTopics * $count ) : 0 ) );
|
||||
Output::i()->json( array( 'count' => $count, 'percentage' => ( $maxTopics * $count > 0 ) ? round( 100 / $maxTopics * $count ) : 0 ) );
|
||||
}
|
||||
|
||||
/* No, we're actually saving */
|
||||
@@ -409,7 +440,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$remoteDatabase = \IPS\Db::i( 'archive', array(
|
||||
$remoteDatabase = Db::i( 'archive', array(
|
||||
'sql_host' => $values['archive_remote_sql_host'],
|
||||
'sql_user' => $values['archive_remote_sql_user'],
|
||||
'sql_pass' => $values['archive_remote_sql_pass'],
|
||||
@@ -417,17 +448,17 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'sql_port' => $values['archive_sql_port'],
|
||||
'sql_socket' => $values['archive_sql_socket'],
|
||||
'sql_tbl_prefix'=> $values['archive_sql_tbl_prefix'],
|
||||
'sql_utf8mb4' => isset( \IPS\Settings::i()->sql_utf8mb4 ) ? \IPS\Settings::i()->sql_utf8mb4 : FALSE
|
||||
'sql_utf8mb4' => isset( SettingsClass::i()->sql_utf8mb4 ) ? SettingsClass::i()->sql_utf8mb4 : FALSE
|
||||
) );
|
||||
|
||||
if ( !$remoteDatabase->checkForTable('forums_archive_posts') )
|
||||
{
|
||||
$remoteDatabase->createTable( \IPS\Db::i()->getTableDefinition('forums_archive_posts') );
|
||||
$remoteDatabase->createTable( Db::i()->getTableDefinition('forums_archive_posts') );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'archive_remote_db_error', FALSE, array( 'sprintf' => array( "{$e->getMessage()} ({$e->getCode()})" ) ) );
|
||||
$form->error = Member::loggedIn()->language()->addToStack( 'archive_remote_db_error', FALSE, array( 'sprintf' => array( "{$e->getMessage()} ({$e->getCode()})" ) ) );
|
||||
goto showForm; // Dinosaur attack!!!!
|
||||
}
|
||||
}
|
||||
@@ -447,18 +478,18 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
$form->saveAsSettings( $settingValues );
|
||||
|
||||
\IPS\Db::i()->delete( 'forums_archive_rules' );
|
||||
if ( \count( $rules ) )
|
||||
Db::i()->delete( 'forums_archive_rules' );
|
||||
if ( count( $rules ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'forums_archive_rules', $rules );
|
||||
Db::i()->insert( 'forums_archive_rules', $rules );
|
||||
}
|
||||
|
||||
/* Do we need to unarchive some? */
|
||||
if( $values['archive_on'] )
|
||||
{
|
||||
$whereClause = \IPS\Db::i()->compileWhereClause( \IPS\Application::load('forums')->archiveWhere( $rules ) );
|
||||
$whereClause = Db::i()->compileWhereClause( Application::load('forums')->archiveWhere( $rules ) );
|
||||
$_whereClause = array( 'topic_archive_status=? AND !( ' . $whereClause['clause'] . ')' );
|
||||
$_whereClause[] = \IPS\forums\Topic::ARCHIVE_DONE;
|
||||
$_whereClause[] = Topic::ARCHIVE_DONE;
|
||||
foreach ( $whereClause['binds'] as $bind )
|
||||
{
|
||||
$_whereClause[] = $bind;
|
||||
@@ -466,74 +497,74 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$_whereClause = array( 'topic_archive_status NOT IN(' . \IPS\forums\Topic::ARCHIVE_NOT . ',' . \IPS\forums\Topic::ARCHIVE_EXCLUDE . ')' );
|
||||
$_whereClause = array( 'topic_archive_status NOT IN(' . Topic::ARCHIVE_NOT . ',' . Topic::ARCHIVE_EXCLUDE . ')' );
|
||||
}
|
||||
|
||||
/* Make sure the unarchive task is enabled - it will disable itself if there is no work to do */
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'unarchive' ) );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'unarchive' ) );
|
||||
|
||||
/* And disable the archive task if archiving is disabled */
|
||||
if( !$values['archive_on'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'archive' ) );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'archive' ) );
|
||||
}
|
||||
/* Or enable it if archiving is enabled */
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'archive' ) );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'archive' ) );
|
||||
}
|
||||
|
||||
/* Log and redirect */
|
||||
\IPS\Session::i()->log( 'acplogs__archive_settings' );
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'forums_topics', $_whereClause )->first() )
|
||||
Session::i()->log( 'acplogs__archive_settings' );
|
||||
if ( Db::i()->select( 'COUNT(*)', 'forums_topics', $_whereClause )->first() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=settings&do=unarchive' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=forums&module=forums&controller=settings&do=unarchive' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=settings&tab=archiving' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=forums&module=forums&controller=settings&tab=archiving' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
showForm:
|
||||
return \IPS\Theme::i()->getTemplate( 'settings' )->archiveRules( $form, $maxTopics, $existingCount, ( $maxTopics * $existingCount > 0 ) ? round( 100 / $maxTopics * $existingCount ) : 0 );
|
||||
return Theme::i()->getTemplate( 'settings' )->archiveRules( $form, $maxTopics, $existingCount, ( $maxTopics * $existingCount > 0 ) ? round( 100 / $maxTopics * $existingCount ) : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater/Less Than X or Any
|
||||
*
|
||||
* @param \IPS\Helpers\Form\Custom $field The field
|
||||
* @param Custom $field The field
|
||||
* @return string
|
||||
*/
|
||||
public function _greaterThanLessThanField( $field )
|
||||
public function _greaterThanLessThanField( Custom $field ): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'settings' )->archiveRuleGtLt( $field->name, $field->value );
|
||||
return Theme::i()->getTemplate( 'settings' )->archiveRuleGtLt( $field->name, $field->value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Before/After X days/months/years ago
|
||||
*
|
||||
* @param \IPS\Helpers\Form\Custom $field The field
|
||||
* @param Custom $field The field
|
||||
* @return string
|
||||
*/
|
||||
public function _beforeAfterTimeAgo( $field )
|
||||
public function _beforeAfterTimeAgo( Custom $field ): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'settings' )->archiveRuleTime( $field->name, $field->value );
|
||||
return Theme::i()->getTemplate( 'settings' )->archiveRuleTime( $field->name, $field->value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Before/After X days/months/years ago
|
||||
*
|
||||
* @param \IPS\Helpers\Form\Custom $field The field
|
||||
* @return string
|
||||
* @param Custom $field The field
|
||||
* @return void
|
||||
*/
|
||||
public function _validateBeforeAfterTimeAgo( $field )
|
||||
public function _validateBeforeAfterTimeAgo( Custom $field ) : void
|
||||
{
|
||||
if ( isset( $field->value[1] ) and $field->value[1] < 0 )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_number_min', FALSE, array( 'sprintf' => array( 0 ) ) ) );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack( 'form_number_min', FALSE, array( 'sprintf' => array( 0 ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,128 +573,62 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unarchive()
|
||||
public function unarchive() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'archive_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'archive_manage' );
|
||||
|
||||
if ( isset( \IPS\Request::i()->confirm ) )
|
||||
if ( isset( Request::i()->confirm ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
if ( \IPS\Settings::i()->archive_on )
|
||||
if ( SettingsClass::i()->archive_on )
|
||||
{
|
||||
$whereClause = \IPS\Db::i()->compileWhereClause( \IPS\Application::load('forums')->archiveWhere( \IPS\Db::i()->select( '*', 'forums_archive_rules' ) ) );
|
||||
$whereClause = Db::i()->compileWhereClause( Application::load('forums')->archiveWhere( Db::i()->select( '*', 'forums_archive_rules' ) ) );
|
||||
$_whereClause = array( 'topic_archive_status=? AND !( ' . $whereClause['clause'] . ')' );
|
||||
$_whereClause[] = \IPS\forums\Topic::ARCHIVE_DONE;
|
||||
$_whereClause[] = Topic::ARCHIVE_DONE;
|
||||
foreach ( $whereClause['binds'] as $bind )
|
||||
{
|
||||
$_whereClause[] = $bind;
|
||||
}
|
||||
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_RESTORE ), $_whereClause );
|
||||
Db::i()->update( 'forums_topics', array( 'topic_archive_status' => Topic::ARCHIVE_RESTORE ), $_whereClause );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'forums_topics', array( 'topic_archive_status' => \IPS\forums\Topic::ARCHIVE_RESTORE ), array( 'topic_archive_status=?', \IPS\forums\Topic::ARCHIVE_DONE ) );
|
||||
Db::i()->update( 'forums_topics', array( 'topic_archive_status' => Topic::ARCHIVE_RESTORE ), array( 'topic_archive_status=?', Topic::ARCHIVE_DONE ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=settings&tab=archiving' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=forums&module=forums&controller=settings&tab=archiving' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'uanrchive_settings_change', array(
|
||||
'restore_unmatched_settings' => \IPS\Http\Url::internal( 'app=forums&module=forums&controller=settings&do=unarchive&confirm=1' )->csrf(),
|
||||
'leave_archived_topics' => \IPS\Http\Url::internal( 'app=forums&module=forums&controller=settings&tab=archiving' ),
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'uanrchive_settings_change', array(
|
||||
'restore_unmatched_settings' => Url::internal( 'app=forums&module=forums&controller=settings&do=unarchive&confirm=1' )->csrf(),
|
||||
'leave_archived_topics' => Url::internal( 'app=forums&module=forums&controller=settings&tab=archiving' ),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @return string
|
||||
* @return Form|string
|
||||
*/
|
||||
protected function manageSettings()
|
||||
protected function manageSettings(): Form|string
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'forum_settings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'forum_settings' );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
$form->addHeader('forum_settings');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_rss', \IPS\Settings::i()->forums_rss ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'forums_default_view', \IPS\Settings::i()->forums_default_view, FALSE, array(
|
||||
'options' => array(
|
||||
'table' => 'forums_default_view_table',
|
||||
'grid' => 'forums_default_view_grid',
|
||||
'fluid' => 'forums_default_view_fluid'
|
||||
),
|
||||
) ) );
|
||||
$form->add( new YesNo( 'forums_rss', SettingsClass::i()->forums_rss ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_fluid_pinned', \IPS\Settings::i()->forums_fluid_pinned, FALSE, array(), NULL, NULL, NULL, 'forums_fluid_pinned' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'forums_default_view_choose', \IPS\Settings::i()->forums_default_view_choose ? json_decode( \IPS\Settings::i()->forums_default_view_choose, TRUE ) : NULL, FALSE, array(
|
||||
'unlimited' => '*',
|
||||
'unlimitedLang' => 'forums_default_view_choose_none',
|
||||
'multiple' => true,
|
||||
'noDefault' => TRUE,
|
||||
'options' => array(
|
||||
'table' => 'forums_default_view_table',
|
||||
'grid' => 'forums_default_view_grid',
|
||||
'fluid' => 'forums_default_view_fluid'
|
||||
)
|
||||
), function( $value ) {
|
||||
if( $value !== '*' AND \count( $value ) !== 0 AND \count( $value ) < 2 )
|
||||
{
|
||||
throw new \DomainException( 'forums_default_view_choose_error' );
|
||||
}
|
||||
} ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'forums_topics_per_page', \IPS\Settings::i()->forums_topics_per_page , TRUE, array( 'min' => 5, 'max' => 100 ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'forums_view_list_method', \IPS\Settings::i()->forums_view_list_method, FALSE, array(
|
||||
'options' => array(
|
||||
'list' => 'forums_topic_list_list',
|
||||
'snippet' => 'forums_topic_list_snippet'
|
||||
),
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_view_list_choose', \IPS\Settings::i()->forums_view_list_choose, FALSE, array(), NULL, NULL, NULL, 'forums_view_list_choose' ) );
|
||||
|
||||
$form->addHeader('question_settings');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_questions_downvote', \IPS\Settings::i()->forums_questions_downvote ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_answers_downvote', \IPS\Settings::i()->forums_answers_downvote ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'forums_new_questions', \IPS\Settings::i()->forums_new_questions, FALSE, array( 'options' => array( '0' => 'forums_new_questions_best', '1' => 'forums_new_questions_any' ) ) ) );
|
||||
$form->add( new YesNo( 'forums_fluid_pinned', SettingsClass::i()->forums_fluid_pinned, FALSE, array(), NULL, NULL, NULL, 'forums_fluid_pinned' ) );
|
||||
$form->add( new Number( 'forums_topics_per_page', SettingsClass::i()->forums_topics_per_page , TRUE, array( 'min' => 5, 'max' => 100 ) ) );
|
||||
|
||||
$form->addHeader('topic_settings');
|
||||
|
||||
|
||||
/* We no longer use popular time for cloud */
|
||||
$popularNowMaximum = 14400000;
|
||||
if( !\IPS\CIC )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'forums_popular_now', json_decode( \IPS\Settings::i()->forums_popular_now, TRUE ), FALSE, array(
|
||||
'getHtml' => function( $obj ) use ( $popularNowMaximum )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('settings')->popularNow( $obj->name, $obj->value, $popularNowMaximum );
|
||||
},
|
||||
/* If popular now time is greater than 10,000 days */
|
||||
'validate' => function( $obj ) use ( $popularNowMaximum )
|
||||
{
|
||||
$form->add( new Number( 'forums_posts_per_page', SettingsClass::i()->forums_posts_per_page , TRUE, array( 'min' => 2, 'max' => 250 ) ) );
|
||||
|
||||
if( isset( $obj->value['minutes'] ) AND $obj->value['minutes'] > $popularNowMaximum )
|
||||
{
|
||||
throw new \LengthException( \IPS\Member::loggedIn()->language()->addToStack('form_number_max', FALSE, array( 'sprintf' => array( $popularNowMaximum ) ) ) );
|
||||
}
|
||||
}
|
||||
) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$popularSettings = json_decode( \IPS\Settings::i()->forums_popular_now, TRUE );
|
||||
\IPS\Member::loggedIn()->language()->words['forums_popular_now_desc'] = \IPS\Member::loggedIn()->language()->addToStack('forums_popular_now_cloud_desc');
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'forums_popular_now', $popularSettings['minutes'] ?? 0, FALSE, [ 'min' => 1, 'max' => $popularNowMaximum, 'valueAs' => \IPS\Helpers\Form\Interval::MINUTES, 'unlimitedLang' => 'never', 'unlimited' => 0 ], NULL, \IPS\Member::loggedIn()->language()->addToStack('forums_popular_now_cloud_prefix'), NULL ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'forums_posts_per_page', \IPS\Settings::i()->forums_posts_per_page , TRUE, array( 'min' => 2, 'max' => 250 ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'forums_topics_show_meta', \IPS\Settings::i()->forums_topics_show_meta ? json_decode( \IPS\Settings::i()->forums_topics_show_meta, TRUE ) : array(), FALSE, array(
|
||||
$form->add( new CheckboxSet( 'forums_topics_show_meta', SettingsClass::i()->forums_topics_show_meta ? json_decode( SettingsClass::i()->forums_topics_show_meta, TRUE ) : array(), FALSE, array(
|
||||
'options' => array(
|
||||
'time' => 'forums_topic_show_meta_time',
|
||||
'moderation' => 'forums_topic_show_meta_moderation'
|
||||
@@ -672,23 +637,32 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'moderation' => array( 'forums_mod_actions_anon' )
|
||||
) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_mod_actions_anon', !\IPS\Settings::i()->forums_mod_actions_anon, FALSE, array(), NULL, NULL, NULL, 'forums_mod_actions_anon' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'forums_solved_topic_reengage', \IPS\Settings::i()->forums_solved_topic_reengage , FALSE, array( 'min' => 1, 'max' => 365, 'unlimited' => 0, 'unlimitedLang' => 'forums_solved_topic_reengage_never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('forums_solved_topic_reengage_prefix'), \IPS\Member::loggedIn()->language()->addToStack('forums_solved_topic_reengage_suffix') ) );
|
||||
$form->add( new YesNo( 'forums_mod_actions_anon', !SettingsClass::i()->forums_mod_actions_anon, FALSE, array(), NULL, NULL, NULL, 'forums_mod_actions_anon' ) );
|
||||
$form->add( new Number( 'forums_solved_topic_reengage', SettingsClass::i()->forums_solved_topic_reengage , FALSE, array( 'min' => 1, 'max' => 365, 'unlimited' => 0, 'unlimitedLang' => 'forums_solved_topic_reengage_never' ), NULL, Member::loggedIn()->language()->addToStack('forums_solved_nudge_experts_prefix'), Member::loggedIn()->language()->addToStack('forums_solved_nudge_experts_suffix') ) );
|
||||
$form->add( new Number( 'forums_helpful_highlight', SettingsClass::i()->forums_helpful_highlight , FALSE, array( 'min' => 1, 'unlimited' => 0, 'unlimitedLang' => 'forums_helpful_highlight_never' ), NULL, Member::loggedIn()->language()->addToStack('forums_helpful_highlight_prefix'), Member::loggedIn()->language()->addToStack('forums_helpful_highlight_suffix') ) );
|
||||
|
||||
$form->addHeader('topic_summary_settings');
|
||||
if( Bridge::i()->featureIsEnabled( 'experts' ) )
|
||||
{
|
||||
$form->add( new Number( 'forums_solved_nudge_experts', SettingsClass::i()->forums_solved_nudge_experts, FALSE, array( 'min' => 1, 'max' => 365, 'unlimited' => 0, 'unlimitedLang' => 'forums_solved_nudge_experts_never' ), NULL, Member::loggedIn()->language()->addToStack('forums_solved_topic_reengage_prefix'), Member::loggedIn()->language()->addToStack('forums_solved_topic_reengage_suffix') ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'forums_topic_activity', \IPS\Settings::i()->forums_topic_activity ? json_decode( \IPS\Settings::i()->forums_topic_activity, TRUE ) : NULL, FALSE, array(
|
||||
$form->add( new YesNo( "forum_post_use_minimal_editor", (bool) SettingsClass::i()->forum_post_use_minimal_editor, false ) );
|
||||
|
||||
$form->addHeader('topic_overview_settings');
|
||||
|
||||
$form->add( new CheckboxSet( 'forums_topic_activity', SettingsClass::i()->forums_topic_activity ? json_decode( SettingsClass::i()->forums_topic_activity, TRUE ) : NULL, FALSE, array(
|
||||
'options' => array( 'desktop' => 'forums_topic_activity_desktop_on', 'mobile' => 'forums_topic_activity_mobile_on' ),
|
||||
'toggles' => array( 'desktop' => array( 'forums_topic_activity_desktop' ) )
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'forums_topic_activity_desktop', \IPS\Settings::i()->forums_topic_activity_desktop, FALSE, array( 'options' => array( 'sidebar' => 'forums_topic_activity_desktop_sidebar', 'post' => 'forums_topic_activity_desktop_post' ) ), NULL, NULL, NULL, 'forums_topic_activity_desktop' ) );
|
||||
$form->add( new Radio( 'forums_topic_activity_desktop', SettingsClass::i()->forums_topic_activity_desktop, FALSE, array( 'options' => array( 'sidebar' => 'forums_topic_activity_desktop_sidebar', 'post' => 'forums_topic_activity_desktop_post' ) ), NULL, NULL, NULL, 'forums_topic_activity_desktop' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'forums_topics_activity_pages_show', \IPS\Settings::i()->forums_topics_activity_pages_show , TRUE, array( 'unlimited' => 0, 'unlimitedLang'=> 'forums_topics_activity_pages_show_unlimited', 'min' => 0, 'max' => 100 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('forums_topics_activity_pages_show_prefix') ) );
|
||||
$form->add( new Number( 'forums_topics_activity_pages_show', SettingsClass::i()->forums_topics_activity_pages_show , TRUE, array( 'unlimited' => 0, 'unlimitedLang'=> 'forums_topics_activity_pages_show_unlimited', 'min' => 0, 'max' => 100 ), NULL, Member::loggedIn()->language()->addToStack('forums_topics_activity_pages_show_prefix') ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'forums_topic_activity_features', \IPS\Settings::i()->forums_topic_activity_features ? json_decode( \IPS\Settings::i()->forums_topic_activity_features, TRUE ) : array(), FALSE, array(
|
||||
$form->add( new CheckboxSet( 'forums_topic_activity_features', SettingsClass::i()->forums_topic_activity_features ? json_decode( SettingsClass::i()->forums_topic_activity_features, TRUE ) : array(), FALSE, array(
|
||||
'options' => array(
|
||||
'popularDays' => 'forums_topic_activity_features_popularDays',
|
||||
'topPost' => 'forums_topic_activity_features_topPost',
|
||||
'helpful' => 'forums_topic_activity_features_helpful',
|
||||
'uploads' => 'forums_topic_activity_features_uploads'
|
||||
) ) ) );
|
||||
|
||||
@@ -696,29 +670,10 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* This setting needs to be reversed */
|
||||
$values['forums_mod_actions_anon'] = !$values['forums_mod_actions_anon'];
|
||||
if( array_key_exists( 'forums_popular_now', $values ) )
|
||||
{
|
||||
/* This is handled slightly different for Cloud */
|
||||
if( \IPS\CIC )
|
||||
{
|
||||
$values['forums_popular_now'] = json_encode( array( 'posts' => 0, 'minutes' => (int) $values['forums_popular_now'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $values['forums_popular_now']['never'] ) )
|
||||
{
|
||||
$values['forums_popular_now'] = json_encode( array( 'posts' => 0, 'minutes' => 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$values['forums_popular_now'] = json_encode( $values['forums_popular_now'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $values['forums_default_view_choose'] ) )
|
||||
{
|
||||
$values['forums_default_view_choose'] = ( \is_array( $values['forums_default_view_choose'] ) AND !\count( $values['forums_default_view_choose'] ) ) ? NULL : json_encode( $values['forums_default_view_choose'] );
|
||||
$values['forums_default_view_choose'] = ( is_array( $values['forums_default_view_choose'] ) AND !count( $values['forums_default_view_choose'] ) ) ? NULL : json_encode( $values['forums_default_view_choose'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['forums_topic_activity'] ) )
|
||||
@@ -738,11 +693,8 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__forums_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=settings&tab=settings' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__forums_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=forums&module=forums&controller=settings&tab=settings' ), 'saved' );
|
||||
}
|
||||
|
||||
return $form;
|
||||
|
||||
@@ -12,49 +12,66 @@
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Statistics\Chart;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Topic\Post;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\DateRange;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use Throwable;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* posts
|
||||
*/
|
||||
class _posts extends \IPS\Dispatcher\Controller
|
||||
class posts extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Show solved posts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showSolvedPosts()
|
||||
protected function showSolvedPosts() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_solved_index', \IPS\Http\Url::internal( 'app=forums&module=stats&controller=posts&do=showSolvedPosts' ), [ 'solved_date BETWEEN ? AND ?', \IPS\Request::i()->startTime, \IPS\Request::i()->endTime ] );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_solved_index', Url::internal( 'app=forums&module=stats&controller=posts&do=showSolvedPosts' ), [ 'solved_date BETWEEN ? AND ? AND type=?', Request::i()->startTime, Request::i()->endTime, 'solved' ] );
|
||||
$table->quickSearch = NULL;
|
||||
$table->sortBy = $table->sortBy ?: 'solved_date';
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
$table->langPrefix = 'stats_posts_type_';
|
||||
$table->include = [ 'comment_id', 'solved_date' ];
|
||||
$table->widths = array( 'solved_date' => 25, 'comment_id' => 75 );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => \IPS\Request::i()->startTime, 'endTime' => \IPS\Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => Request::i()->startTime, 'endTime' => Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'solved_date' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->html();
|
||||
return DateTime::ts( $val )->html();
|
||||
},
|
||||
'comment_id' => function( $val, $row )
|
||||
{
|
||||
@@ -64,16 +81,16 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$item = $class::load( $row['comment_id'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
return Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
catch ( Throwable $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
return Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'ipsPad' );
|
||||
Output::i()->output = Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'i-padding_3' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,23 +98,23 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function showRecommendedPosts()
|
||||
protected function showRecommendedPosts() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_content_meta', \IPS\Http\Url::internal( 'app=forums&module=stats&controller=posts&do=showRecommendedPosts' ), [ 'meta_type=? AND meta_added BETWEEN ? AND ?', 'core_FeaturedComments', \IPS\Request::i()->startTime, \IPS\Request::i()->endTime ] );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_content_meta', Url::internal( 'app=forums&module=stats&controller=posts&do=showRecommendedPosts' ), [ 'meta_type=? AND meta_added BETWEEN ? AND ?', 'core_FeaturedComments', Request::i()->startTime, Request::i()->endTime ] );
|
||||
$table->quickSearch = NULL;
|
||||
$table->sortBy = $table->sortBy ?: 'meta_added';
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
$table->langPrefix = 'stats_posts_type_';
|
||||
$table->include = [ 'meta_data', 'meta_added' ];
|
||||
$table->widths = array( 'meta_added' => 25, 'meta_data' => 75 );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => \IPS\Request::i()->startTime, 'endTime' => \IPS\Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( array( 'startTime' => Request::i()->startTime, 'endTime' => Request::i()->endTime, 'tab' => 'bytype' ) );
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'meta_added' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->html();
|
||||
return DateTime::ts( $val )->html();
|
||||
},
|
||||
'meta_data' => function( $val, $row )
|
||||
{
|
||||
@@ -105,18 +122,18 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$item = \IPS\forums\Topic\Post::load( $data['comment'] );
|
||||
$item = Post::load( $data['comment'] );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
return Theme::i()->getTemplate( 'activitystats', 'core' )->contentCell( $item );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
catch ( Throwable $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
return Member::loggedIn()->language()->addToStack( 'unavailable' );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'ipsPad' );
|
||||
Output::i()->output = Theme::i()->getTemplate('global', 'core')->block( NULL, (string) $table, TRUE, 'i-padding_3' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,25 +141,25 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'posts_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'posts_manage' );
|
||||
|
||||
$tabs = array( 'total' => 'stats_posts_tab_total', 'bytype' => 'stats_posts_by_type', 'byforum' => 'stats_posts_tab_byforum' );
|
||||
\IPS\Request::i()->tab ??= 'total';
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'total';
|
||||
Request::i()->tab ??= 'total';
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'total';
|
||||
|
||||
if ( $activeTab === 'bytype' )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::create()->setDate( date('Y'), date('m'), 1 ), 'end' => new \IPS\DateTime );
|
||||
$defaults = array( 'start' => DateTime::create()->setDate( date('Y'), date('m'), 1 ), 'end' => new DateTime );
|
||||
|
||||
if( isset( \IPS\Request::i()->badgeDateStart ) AND isset( \IPS\Request::i()->badgeDateEnd ) )
|
||||
if( isset( Request::i()->badgeDateStart ) AND isset( Request::i()->badgeDateEnd ) )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::ts( \IPS\Request::i()->badgeDateStart ), 'end' => \IPS\DateTime::ts( \IPS\Request::i()->badgeDateEnd ) );
|
||||
$defaults = array( 'start' => DateTime::ts( Request::i()->badgeDateStart ), 'end' => DateTime::ts( Request::i()->badgeDateEnd ) );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( $activeTab, 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'date', $defaults, TRUE ) );
|
||||
$form = new Form( $activeTab, 'continue' );
|
||||
$form->add( new DateRange( 'date', $defaults, TRUE ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
@@ -164,37 +181,38 @@ class _posts extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Get a count of solved posts in this time */
|
||||
$solvedCount = \IPS\Db::i()->select( 'count(*)', 'core_solved_index', [
|
||||
$solvedCount = Db::i()->select( 'count(*)', 'core_solved_index', [
|
||||
[ 'solved_date BETWEEN ? AND ?', $startTime, $endTime ],
|
||||
[ 'comment_class=?', 'IPS\forums\Topic\Post' ]
|
||||
[ 'comment_class=?', 'IPS\forums\Topic\Post' ],
|
||||
[ 'type=?', 'solved' ]
|
||||
] )->first();
|
||||
|
||||
/* Get a count of recommended posts in this time */
|
||||
$recommendedCount = \IPS\Db::i()->select( 'count(*)', 'core_content_meta', [
|
||||
$recommendedCount = Db::i()->select( 'count(*)', 'core_content_meta', [
|
||||
[ 'meta_added BETWEEN ? AND ?', $startTime, $endTime ],
|
||||
[ 'meta_type=?', 'core_FeaturedComments' ]
|
||||
] )->first();
|
||||
|
||||
$formHtml = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'stats', 'core' ), 'filtersFormTemplate' ) );
|
||||
$chart = \IPS\Theme::i()->getTemplate( 'stats', 'forums' )->statsTypeWrapper( $formHtml, $solvedCount, $recommendedCount, $startTime, $endTime );
|
||||
$formHtml = $form->customTemplate( array( Theme::i()->getTemplate( 'stats', 'core' ), 'filtersFormTemplate' ) );
|
||||
$chart = Theme::i()->getTemplate( 'stats', 'forums' )->statsTypeWrapper( $formHtml, $solvedCount, $recommendedCount, $startTime, $endTime );
|
||||
}
|
||||
else if ( $activeTab === 'total' )
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'forums', 'Posts' )->getChart( \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
$chart = Chart::loadFromExtension( 'forums', 'Posts' )->getChart( Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'forums', 'PostsByForum' )->getChart( \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
$chart = Chart::loadFromExtension( 'forums', 'PostsByForum' )->getChart( Url::internal( "app=forums&module=stats&controller=posts&tab={$activeTab}" ) );
|
||||
}
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
Output::i()->output = (string) $chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__forums_stats_posts');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, \IPS\Http\Url::internal( "app=forums&module=stats&controller=posts" ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__forums_stats_posts');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $chart, Url::internal( "app=forums&module=stats&controller=posts" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief questions
|
||||
* @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 21 Sep 2021
|
||||
*/
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* questions
|
||||
*/
|
||||
class _questions extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'questions_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'forums', 'Questions' )->getChart( \IPS\Http\Url::internal( "app=forums&module=stats&controller=questions" ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__forums_stats_questions');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Output;
|
||||
@@ -35,34 +38,33 @@ use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
use const IPS\Helpers\Table\SEARCH_MEMBER;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
|
||||
/* 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' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* solved
|
||||
*/
|
||||
class _solved extends Controller
|
||||
class solved extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'topics_manage' );
|
||||
parent::execute();
|
||||
@@ -81,7 +83,7 @@ class _solved extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$tabs = array(
|
||||
'time' => 'forums_solved_stats_time',
|
||||
@@ -98,44 +100,44 @@ class _solved extends Controller
|
||||
'link' => Url::internal( 'app=forums&module=stats&controller=solved&do=rebuildStats' )->csrf(),
|
||||
'data' => array( 'confirm' => '' )
|
||||
);
|
||||
|
||||
|
||||
Request::i()->tab ??= 'time';
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'time';
|
||||
|
||||
$url = Url::internal( "app=forums&module=stats&controller=solved&tab={$activeTab}" );
|
||||
$output = match( $activeTab ) {
|
||||
'percentage' => Chart::loadFromExtension( 'forums', 'PercentageSolved' )->getChart( $url ),
|
||||
'solved' => Chart::loadFromExtension( 'forums', 'SolvedByForum' )->getChart( $url ),
|
||||
'groups' => CHart::LoadFromExtension( 'forums', 'SolvedByGroup' )->getChart( $url ),
|
||||
'unsolved' => $this->_unsolved(),
|
||||
default => Chart::loadFromExtension( 'forums', 'TimeSolved' )->getChart( $url )
|
||||
|
||||
$url = Url::internal( "app=forums&module=stats&controller=solved&tab={$activeTab}" );
|
||||
$chart = match( $activeTab ) {
|
||||
'percentage' => Chart::loadFromExtension( 'forums', 'PercentageSolved' )->getChart( $url ),
|
||||
'solved' => Chart::loadFromExtension( 'forums', 'SolvedByForum' )->getChart( $url ),
|
||||
'groups' => Chart::LoadFromExtension( 'forums', 'SolvedByGroup' )->getChart( $url ),
|
||||
'unsolved' => $this->_unsolved(),
|
||||
default => Chart::loadFromExtension( 'forums', 'TimeSolved' )->getChart( $url )
|
||||
};
|
||||
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
Output::i()->output = (string) $output;
|
||||
Output::i()->output = (string)$chart;
|
||||
}
|
||||
else
|
||||
{
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'menu__forums_stats_solved' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $output, Url::internal( "app=forums&module=stats&controller=solved" ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string)$chart, Url::internal( "app=forums&module=stats&controller=solved" ), 'tab', '', 'i-padding_3' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsolved Topics
|
||||
*
|
||||
* @return \IPS\Helpers\Table\Db
|
||||
* @return TableDb
|
||||
*/
|
||||
protected function _unsolved(): TableDb
|
||||
{
|
||||
/* Load Forums into Memory */
|
||||
Forum::loadIntoMemory( NULL );
|
||||
|
||||
|
||||
$table = new TableDb( 'forums_topics', Url::internal( "app=forums&module=stats&controller=solved&tab=unsolved" ), static::_unsolvedWHere() );
|
||||
$table->langPrefix = 'topics_noposts_';
|
||||
$table->include = array( 'tid', 'title', 'state', 'start_date', 'starter_id', 'views', 'forum_id', 'approved' );
|
||||
|
||||
|
||||
$table->parsers = array(
|
||||
'title' => function( $val, $row )
|
||||
{
|
||||
@@ -152,7 +154,7 @@ class _solved extends Controller
|
||||
},
|
||||
'start_date' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
return (string) DateTime::ts( $val );
|
||||
},
|
||||
'starter_id' => function( $val, $row )
|
||||
{
|
||||
@@ -174,7 +176,7 @@ class _solved extends Controller
|
||||
{
|
||||
$guest->name = $row['starter_name'];
|
||||
}
|
||||
|
||||
|
||||
return $guest->name;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +196,7 @@ class _solved extends Controller
|
||||
{
|
||||
$title = $forum->_title;
|
||||
}
|
||||
|
||||
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $forum->url(), TRUE, $title );
|
||||
},
|
||||
'approved' => function( $val )
|
||||
@@ -209,21 +211,21 @@ class _solved extends Controller
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$table->filters = array(
|
||||
'open' => "state='open'",
|
||||
'locked' => "state='closed'",
|
||||
'approved' => "approved=1",
|
||||
'unapproved' => "approved=0"
|
||||
);
|
||||
|
||||
|
||||
$table->advancedSearch['forum_id'] = array( SEARCH_NODE, array( 'class' => 'IPS\\forums\\Forum', 'clubs' => TRUE ) );
|
||||
$table->advancedSearch['starter_id'] = SEARCH_MEMBER;
|
||||
$table->advancedSearch['start_date'] = SEARCH_DATE_RANGE;
|
||||
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Unsolved Topics Where Clause
|
||||
*
|
||||
@@ -238,15 +240,15 @@ class _solved extends Controller
|
||||
$where[] = array( Db::i()->in( 'approved', array( 0, 1 ) ) );
|
||||
$where[] = array( Db::i()->in( 'forum_id', Db::i()->select( 'id', 'forums_forums' ) ) );
|
||||
$where[] = array( Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) );
|
||||
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Kick off a rebuild of the stats
|
||||
*
|
||||
*/
|
||||
public function rebuildStats()
|
||||
public function rebuildStats() : void
|
||||
{
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
@@ -255,7 +257,7 @@ class _solved extends Controller
|
||||
Task::queue( 'forums', 'RebuildSolvedStats', array( 'forum_id' => $forum['id'] ) );
|
||||
}
|
||||
|
||||
Output::i()->redirect( \IPS\Http\Url::internal('app=forums&module=stats&controller=solved'), 'solved_stats_rebuild_started' );
|
||||
Output::i()->redirect( Url::internal('app=forums&module=stats&controller=solved'), 'solved_stats_rebuild_started' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +265,7 @@ class _solved extends Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getValidForumIds()
|
||||
protected function getValidForumIds(): array
|
||||
{
|
||||
$validForumIds = [];
|
||||
|
||||
|
||||
@@ -11,13 +11,14 @@
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\Url\Friendly;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Theme;
|
||||
use IPS\Output;
|
||||
|
||||
@@ -30,33 +31,33 @@ use const IPS\Helpers\Table\SEARCH_SELECT;
|
||||
/* 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' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* solvers
|
||||
*/
|
||||
class _solvers extends Controller
|
||||
class solvers extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute(): void
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'solvers_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'topics_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -65,17 +66,17 @@ class _solvers extends Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$table = new TableDb( 'core_solved_index', Url::internal( "app=forums&module=stats&controller=solvers" ) );
|
||||
$table->langPrefix = 'top_solvers_';
|
||||
$table->groupBy = array( 'core_members.member_id', 'core_members.name', 'core_members.member_group_id' );
|
||||
$table->selects = array( 'COUNT(core_members.member_id) AS count', 'core_members.member_id', 'core_members.name', 'MAX(core_solved_index.solved_date) AS date', 'core_members.member_group_id' );
|
||||
$table->joins = array( array( 'from' => 'core_members', 'where' => 'core_solved_index.member_id=core_members.member_id', 'type' => 'RIGHT' ) );
|
||||
$table->groupBy = array( 'core_solved_index.member_id', /*'core_members.name', 'core_members.member_group_id'*/ );
|
||||
$table->selects = array( 'COUNT(core_solved_index.member_id) AS count', 'core_solved_index.member_id', 'core_members.name', 'MAX(core_solved_index.solved_date) AS date', 'core_members.member_group_id' );
|
||||
$table->joins = array( array( 'from' => 'core_members', 'where' => 'core_solved_index.member_id=core_members.member_id', 'type' => 'LEFT' ) );
|
||||
$table->include = array( 'name', 'count', 'date', 'member_group_id' );
|
||||
$table->parsers = array(
|
||||
'name' => function( $val, $row ) {
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userLinkWithPhoto( \IPS\Member::load( $row['member_id'] ) );
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userLinkWithPhoto( Member::load( $row['member_id'] ) );
|
||||
},
|
||||
'count' => function( $val, $row ) {
|
||||
$url = Url::internal( "app=core&module=members&controller=profile&id={$row['member_id']}&do=solutions", 'front', 'profile_solutions', array( Friendly::seoTitle( $row['name'] ) ) );
|
||||
@@ -83,15 +84,18 @@ class _solvers extends Controller
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $url, TRUE, $count );
|
||||
},
|
||||
'date' => function( $val ) {
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
if( $val )
|
||||
{
|
||||
return (string) DateTime::ts( $val );
|
||||
}
|
||||
},
|
||||
'member_group_id' => function( $val ) {
|
||||
return \IPS\Member\Group::load( $val )->name;
|
||||
return Group::load( $val )->name;
|
||||
}
|
||||
);
|
||||
|
||||
$groups = array();
|
||||
foreach( \IPS\Member\Group::groups( showGuestGroups: FALSE ) AS $group )
|
||||
foreach( Group::groups( showGuestGroups: FALSE ) AS $group )
|
||||
{
|
||||
$groups[ $group->g_id ] = $group->name;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace IPS\forums\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Db;
|
||||
@@ -32,48 +35,47 @@ use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
use const IPS\Helpers\Table\SEARCH_MEMBER;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
|
||||
/* 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' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* topics
|
||||
*/
|
||||
class _topics extends Controller
|
||||
class topics extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
Dispatcher::i()->checkAcpPermission( 'topics_manage' );
|
||||
|
||||
$tabs = array( 'total' => 'stats_topics_tab_total' );
|
||||
|
||||
if( Db::i()->select( 'COUNT(*)', 'forums_forums', array( 'topics>?', 0 ) )->first() )
|
||||
{
|
||||
$tabs['byforum'] = 'stats_topics_tab_byforum';
|
||||
}
|
||||
|
||||
if ( Db::i()->select( 'COUNT(*)', 'forums_topics', static::_noPostsWhere() )->first() )
|
||||
{
|
||||
$tabs['noposts'] = 'stats_topics_tab_noposts';
|
||||
}
|
||||
if( Db::i()->select( 'COUNT(*)', 'forums_forums', array( 'topics>?', 0 ) )->first() )
|
||||
{
|
||||
$tabs['byforum'] = 'stats_topics_tab_byforum';
|
||||
}
|
||||
|
||||
if ( Db::i()->select( 'COUNT(*)', 'forums_topics', static::_noPostsWhere() )->first() )
|
||||
{
|
||||
$tabs['noposts'] = 'stats_topics_tab_noposts';
|
||||
}
|
||||
|
||||
Request::i()->tab ??= 'total';
|
||||
$activeTab = ( array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'total';
|
||||
@@ -89,26 +91,26 @@ class _topics extends Controller
|
||||
Output::i()->output = (string) $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__forums_stats_topics');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, (string) $output, Url::internal( "app=forums&module=stats&controller=topics" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Topics with No Posts Table
|
||||
*
|
||||
* @return \IPS\Helpers\Table\Db
|
||||
* @return TableDb
|
||||
*/
|
||||
protected function _noPostsTable(): TableDb
|
||||
{
|
||||
/* Load Forums into Memory */
|
||||
Forum::loadIntoMemory( NULL );
|
||||
|
||||
|
||||
$table = new TableDb( 'forums_topics', Url::internal( "app=forums&module=stats&controller=topics&tab=noposts" ), static::_noPostsWhere() );
|
||||
$table->langPrefix = 'topics_noposts_';
|
||||
$table->include = array( 'tid', 'title', 'state', 'start_date', 'starter_id', 'views', 'forum_id', 'approved' );
|
||||
|
||||
|
||||
$table->parsers = array(
|
||||
'title' => function( $val, $row )
|
||||
{
|
||||
@@ -125,7 +127,7 @@ class _topics extends Controller
|
||||
},
|
||||
'start_date' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
return (string) DateTime::ts( $val );
|
||||
},
|
||||
'starter_id' => function( $val, $row )
|
||||
{
|
||||
@@ -147,7 +149,7 @@ class _topics extends Controller
|
||||
{
|
||||
$guest->name = $row['starter_name'];
|
||||
}
|
||||
|
||||
|
||||
return $guest->name;
|
||||
}
|
||||
}
|
||||
@@ -167,7 +169,7 @@ class _topics extends Controller
|
||||
{
|
||||
$title = $forum->_title;
|
||||
}
|
||||
|
||||
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $forum->url(), TRUE, $title );
|
||||
},
|
||||
'approved' => function( $val )
|
||||
@@ -182,21 +184,21 @@ class _topics extends Controller
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
$table->filters = array(
|
||||
'open' => "state='open'",
|
||||
'locked' => "state='closed'",
|
||||
'approved' => "approved=1",
|
||||
'unapproved' => "approved=0"
|
||||
);
|
||||
|
||||
|
||||
$table->advancedSearch['forum_id'] = array( SEARCH_NODE, array( 'class' => 'IPS\\forums\\Forum', 'clubs' => TRUE ) );
|
||||
$table->advancedSearch['starter_id'] = SEARCH_MEMBER;
|
||||
$table->advancedSearch['start_date'] = SEARCH_DATE_RANGE;
|
||||
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get No Posts Where Clause
|
||||
*
|
||||
@@ -211,7 +213,7 @@ class _topics extends Controller
|
||||
$where[] = array( Db::i()->in( 'approved', array( 0, 1 ) ) );
|
||||
$where[] = array( Db::i()->in( 'forum_id', Db::i()->select( 'id', 'forums_forums' ) ) );
|
||||
$where[] = array( Db::i()->in( 'state', array( 'link', 'merged' ), TRUE ) );
|
||||
|
||||
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
@@ -12,31 +12,39 @@
|
||||
namespace IPS\forums\modules\front\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Topic\Post;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy 3.x findpost
|
||||
*/
|
||||
class _findpost extends \IPS\Dispatcher\Controller
|
||||
class findpost extends Controller
|
||||
{
|
||||
/**
|
||||
* Route
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\forums\Topic\Post::loadAndCheckPerms( \IPS\Request::i()->pid )->url(), NULL, 301 );
|
||||
Output::i()->redirect( Post::loadAndCheckPerms( Request::i()->pid )->url(), NULL );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2F284/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2F284/1', 404, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -12,42 +12,66 @@
|
||||
namespace IPS\forums\modules\front\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\Application\Module;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Forum;
|
||||
use IPS\Helpers\Table\Content;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* index
|
||||
*/
|
||||
class _index extends \IPS\Dispatcher\Controller
|
||||
class index extends Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->forumId ) and ! \IPS\forums\Forum::isSimpleView() )
|
||||
if ( isset( Request::i()->forumId ) and ! Forum::isSimpleView() )
|
||||
{
|
||||
/* This is a simple view URL, but we're not using simple view, so redirect */
|
||||
$ids = explode( ',', \IPS\Request::i()->forumId );
|
||||
$ids = explode( ',', Request::i()->forumId );
|
||||
$firstId = array_shift( $ids );
|
||||
if ( $firstId )
|
||||
{
|
||||
try
|
||||
{
|
||||
$forum = \IPS\forums\Forum::loadAndCheckPerms( $firstId );
|
||||
\IPS\Output::i()->redirect( $forum->url(), '', 302 );
|
||||
$forum = Forum::loadAndCheckPerms( $firstId );
|
||||
Output::i()->redirect( $forum->url(), '', 302 );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
catch( Exception $ex ) { }
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'gallery' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_forum.js', 'forums' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_browse.js', 'gallery' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_forum.js', 'forums' ) );
|
||||
|
||||
if ( Application::appIsEnabled('cloud') )
|
||||
{
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_realtime.js', 'cloud', 'front' ) );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
@@ -57,22 +81,21 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @param string $method Desired method
|
||||
* @param array $args Arguments
|
||||
* @return void
|
||||
*/
|
||||
public function __call( $method, $args )
|
||||
public function __call( string $method, mixed $args )
|
||||
{
|
||||
if ( \IPS\forums\Forum::isSimpleView() and isset( \IPS\Request::i()->do ) and isset( \IPS\Request::i()->forumId ) and ! mb_stristr( \IPS\Request::i()->forumId, ',' ) )
|
||||
if ( Forum::isSimpleView() and isset( Request::i()->do ) and isset( Request::i()->forumId ) and ! mb_stristr( Request::i()->forumId, ',' ) )
|
||||
{
|
||||
/* If we have a specific do action that this controller does not handle, then we really want the full forum view to handle it */
|
||||
try
|
||||
{
|
||||
/* Panic not, they are all loaded into memory at this point */
|
||||
$controller = new \IPS\forums\modules\front\forums\forums( $this->url );
|
||||
\IPS\Request::i()->id = \IPS\Request::i()->forumId;
|
||||
$controller = new forums( $this->url );
|
||||
Request::i()->id = Request::i()->forumId;
|
||||
$controller->execute();
|
||||
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
catch( Exception $ex ) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,47 +104,49 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Load into memory */
|
||||
\IPS\forums\Forum::loadIntoMemory();
|
||||
Forum::loadIntoMemory();
|
||||
|
||||
/* Is there only one forum? But don't redirect if it's simple view mode... */
|
||||
if ( $theOnlyForum = \IPS\forums\Forum::theOnlyForum() AND !\IPS\forums\Forum::isSimpleView() )
|
||||
if ( $theOnlyForum = Forum::theOnlyForum() AND !Forum::isSimpleView() )
|
||||
{
|
||||
$controller = new \IPS\forums\modules\front\forums\forums( $this->url );
|
||||
return $controller->_forum( $theOnlyForum );
|
||||
$controller = new forums( $this->url );
|
||||
$controller->_forum( $theOnlyForum );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Prepare output */
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'global_core.js', 'core', 'global' ) );
|
||||
if ( \IPS\forums\Forum::isSimpleView() )
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'global_core.js', 'core', 'global' ) );
|
||||
if ( Forum::isSimpleView() )
|
||||
{
|
||||
\IPS\Output::i()->title = ( isset( \IPS\Request::i()->page ) AND \IPS\Request::i()->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'forums' ), \IPS\Request::i()->page ) ) ) : \IPS\Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
Output::i()->title = ( isset( Request::i()->page ) AND Request::i()->page > 1 ) ? Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( Member::loggedIn()->language()->addToStack( 'forums' ), Request::i()->page ) ) ) : Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
}
|
||||
\IPS\Output::i()->linkTags['canonical'] = (string) \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
\IPS\Output::i()->metaTags['og:title'] = \IPS\Settings::i()->board_name;
|
||||
\IPS\Output::i()->metaTags['og:type'] = 'website';
|
||||
\IPS\Output::i()->metaTags['og:url'] = (string) \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
Output::i()->linkTags['canonical'] = (string) Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
Output::i()->metaTags['og:title'] = Settings::i()->board_name;
|
||||
Output::i()->metaTags['og:type'] = 'website';
|
||||
Output::i()->metaTags['og:url'] = (string) Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
|
||||
/* Set Online Location */
|
||||
$permissions = \IPS\Dispatcher::i()->module->permissions();
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), explode( ',', $permissions['perm_view'] ), 'loc_forums_index' );
|
||||
$permissions = Dispatcher::i()->module->permissions();
|
||||
Session::i()->setLocation( Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), explode( ',', $permissions['perm_view'] ), 'loc_forums_index' );
|
||||
|
||||
/* Display */
|
||||
if ( \IPS\forums\Forum::isSimpleView() )
|
||||
if ( Forum::isSimpleView() )
|
||||
{
|
||||
$where = array();
|
||||
if ( \IPS\forums\Forum::customPermissionNodes() )
|
||||
|
||||
if ( Forum::customPermissionNodes() )
|
||||
{
|
||||
$where = array( 'container' => array( array( 'forums_forums.password IS NULL' ) ) );
|
||||
}
|
||||
|
||||
if ( !\IPS\Settings::i()->club_nodes_in_apps OR !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
if ( !Settings::i()->club_nodes_in_apps OR !Member::loggedIn()->canAccessModule( Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
{
|
||||
$where['container'][] = array( 'forums_forums.club_id IS NULL' );
|
||||
}
|
||||
@@ -129,17 +154,17 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
$map = array();
|
||||
$ids = array();
|
||||
|
||||
if ( isset( \IPS\Request::i()->forumId ) )
|
||||
if ( isset( Request::i()->forumId ) )
|
||||
{
|
||||
$ids = explode( ',', \IPS\Request::i()->forumId );
|
||||
$ids = explode( ',', Request::i()->forumId );
|
||||
}
|
||||
else if ( isset( \IPS\Request::i()->cookie['forums_flowIds'] ) )
|
||||
else if ( isset( Request::i()->cookie['forums_flowIds'] ) )
|
||||
{
|
||||
$ids = explode( ',', \IPS\Request::i()->cookie['forums_flowIds'] );
|
||||
$ids = explode( ',', Request::i()->cookie['forums_flowIds'] );
|
||||
}
|
||||
|
||||
/* Inline forum IDs? */
|
||||
if ( \count( $ids ) )
|
||||
if ( count( $ids ) )
|
||||
{
|
||||
$toUnset = [];
|
||||
foreach( $ids as $id )
|
||||
@@ -149,7 +174,7 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
if ( $id == 'clubs' )
|
||||
{
|
||||
$map['clubs'] = 'clubs';
|
||||
foreach ( \IPS\forums\Forum::clubNodes() as $child )
|
||||
foreach ( Forum::clubNodes() as $child )
|
||||
{
|
||||
$forumIds[ $child->id ] = $child->id;
|
||||
}
|
||||
@@ -157,93 +182,74 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
/* Panic not, they are all loaded into memory at this point */
|
||||
$forum = \IPS\forums\Forum::load( $id );
|
||||
$forum = Forum::load( $id );
|
||||
|
||||
$map[ $forum->parent_id ][] = $forum->_id;
|
||||
$forumIds[] = $forum->id;
|
||||
}
|
||||
}
|
||||
catch( \Exception $ex ) {
|
||||
catch( Exception $ex )
|
||||
{
|
||||
$toUnset[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
/* Redirect to a page with valid forum ids */
|
||||
if( $ids and count($forumIds ) AND $toUnset )
|
||||
{
|
||||
$newUrl = $this->url;
|
||||
$newUrl = $newUrl->setQueryString( 'forumId', implode( ',', array_diff( $ids, $toUnset ) ) );
|
||||
\IPS\Output::i()->redirect( $newUrl );
|
||||
Output::i()->redirect( $newUrl );
|
||||
}
|
||||
|
||||
if ( \count( $forumIds ) )
|
||||
if ( count( $forumIds ) )
|
||||
{
|
||||
$where['container'][] = array( \IPS\Db::i()->in( 'forums_forums.id', array_filter( $forumIds ) ) );
|
||||
$where['container'][] = array( Db::i()->in( 'forums_forums.id', array_filter( $forumIds ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Simplified view */
|
||||
$table = new \IPS\Helpers\Table\Content( 'IPS\forums\Topic', \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), $where, NULL, NULL, 'read' );
|
||||
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedForumTable' );
|
||||
$table->classes = array( 'cTopicList' );
|
||||
$table->limit = \IPS\Settings::i()->forums_topics_per_page;
|
||||
$table = new Content( 'IPS\forums\Topic', Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), $where, NULL, NULL, 'read' );
|
||||
$table->tableTemplate = array( Theme::i()->getTemplate( 'index' ), 'simplifiedForumTable' );
|
||||
$table->classes = array( 'ipsData--topic-list' );
|
||||
$table->limit = Settings::i()->forums_topics_per_page;
|
||||
|
||||
if ( \IPS\forums\Forum::getMemberListView() == 'snippet' )
|
||||
if ( Member::loggedIn()->getLayoutValue('forums_topic') == 'snippet' )
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRowSnippet' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRowSnippet' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRow' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRow' );
|
||||
}
|
||||
|
||||
$table->honorPinned = \IPS\Settings::i()->forums_fluid_pinned;
|
||||
$table->honorPinned = Settings::i()->forums_fluid_pinned;
|
||||
$table->hover = TRUE;
|
||||
$table->sortOptions['num_replies'] = $table->sortOptions['num_comments'];
|
||||
unset( $table->sortOptions['num_comments'] );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'index' )->simplifiedView( $table );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'index' )->simplifiedView( $table );
|
||||
|
||||
if( \IPS\forums\Forum::theOnlyForum() === NULL )
|
||||
if( Forum::theOnlyForum() === NULL )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'index' )->simplifiedViewSidebar( $forumIds, $map );
|
||||
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'index' )->simplifiedViewSidebar( $forumIds, $map );
|
||||
}
|
||||
|
||||
if ( isset( $where['container'] ) )
|
||||
{
|
||||
$allForumIds = iterator_to_array( \IPS\Db::i()->select( 'id', 'forums_forums', $where['container'] ) );
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack('forums_chosen_forums') ] = array( 'type' => 'forums_topic', 'nodes' => implode( ',', $allForumIds ) );
|
||||
$allForumIds = iterator_to_array( Db::i()->select( 'id', 'forums_forums', $where['container'] ) );
|
||||
Output::i()->contextualSearchOptions[ Member::loggedIn()->language()->addToStack('forums_chosen_forums') ] = array( 'type' => 'forums_topic', 'nodes' => implode( ',', $allForumIds ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Merge in follower counts to the immediately visible forums */
|
||||
if ( \IPS\forums\Forum::getMemberView() === 'grid' )
|
||||
if ( Member::loggedIn()->getLayoutValue('forums_forum') )
|
||||
{
|
||||
\IPS\forums\Forum::populateFollowerCounts();
|
||||
Forum::populateFollowerCounts();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'index' )->index();
|
||||
Output::i()->output = Theme::i()->getTemplate( 'index' )->index();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the viewing method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setMethod()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$method = ( isset( \IPS\Request::i()->method ) ) ? \IPS\Request::i()->method : \IPS\Settings::i()->forums_default_view;
|
||||
|
||||
\IPS\Request::i()->setCookie( 'forum_view', $method, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Db::i()->replace( 'forums_view_method', array( 'member_id' => \IPS\Member::loggedIn()->member_id, 'method' => $method, 'type' => 'index' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ) );
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user