Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\forums\modules\admin\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Manage Settings
|
||||
*
|
||||
@@ -43,7 +48,8 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$activeTab = \IPS\Request::i()->tab ?: 'settings';
|
||||
$activeTabContents = call_user_func( array( $this, 'manage' . mb_ucfirst( $activeTab ) ) );
|
||||
$methodFunction = 'manage' . mb_ucfirst( $activeTab );
|
||||
$activeTabContents = $this->$methodFunction();
|
||||
|
||||
if( \IPS\Request::i()->isAjax() and !isset( \IPS\Request::i()->ajaxValidate ) )
|
||||
{
|
||||
@@ -64,7 +70,24 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
protected function manageArchiving()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'archive_manage' );
|
||||
|
||||
|
||||
if ( \IPS\CIC2 )
|
||||
{
|
||||
return \IPS\Cicloud\getForumArchiveForm();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->manageArchivingForm();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Archive settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function manageArchivingForm()
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_settings.js', 'forums', 'admin' ) );
|
||||
|
||||
/* Init */
|
||||
@@ -172,7 +195,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'archive_topic_starter_not',
|
||||
'form_header_archive_topics_where',
|
||||
'form_header_archive_topics_not_where'
|
||||
),
|
||||
)
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'archive_storage_location', \IPS\Settings::i()->archive_remote_sql_host ? 'remote' : 'local', FALSE, array(
|
||||
@@ -187,6 +210,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
$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->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' ) );
|
||||
@@ -221,7 +245,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] )
|
||||
{
|
||||
@@ -236,7 +260,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] )
|
||||
{
|
||||
@@ -251,7 +275,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 ) )
|
||||
{
|
||||
@@ -266,7 +290,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 ) )
|
||||
{
|
||||
@@ -281,9 +305,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}" ),
|
||||
@@ -296,9 +320,9 @@ 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] )
|
||||
if ( !isset( $v[2] ) and $v[1] and $v[0] )
|
||||
{
|
||||
$rules[] = array(
|
||||
'archive_key' => md5( "forums_{$k}" ),
|
||||
@@ -311,9 +335,9 @@ 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] )
|
||||
if ( !isset( $v[2] ) and $v[1] and $v[0] )
|
||||
{
|
||||
$rules[] = array(
|
||||
'archive_key' => md5( "forums_{$k}" ),
|
||||
@@ -326,9 +350,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 )
|
||||
@@ -347,9 +371,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 )
|
||||
@@ -431,7 +455,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
$form->saveAsSettings( $settingValues );
|
||||
|
||||
\IPS\Db::i()->delete( 'forums_archive_rules' );
|
||||
if ( count( $rules ) )
|
||||
if ( \count( $rules ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'forums_archive_rules', $rules );
|
||||
}
|
||||
@@ -531,6 +555,8 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( isset( \IPS\Request::i()->confirm ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
if ( \IPS\Settings::i()->archive_on )
|
||||
{
|
||||
$whereClause = \IPS\Db::i()->compileWhereClause( \IPS\Application::load('forums')->archiveWhere( \IPS\Db::i()->select( '*', 'forums_archive_rules' ) ) );
|
||||
@@ -552,7 +578,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'uanrchive_settings_change', array(
|
||||
'restore_unmatched_settings' => \IPS\Http\Url::internal( 'app=forums&module=forums&controller=settings&do=unarchive&confirm=1' ),
|
||||
'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' ),
|
||||
) );
|
||||
}
|
||||
@@ -590,13 +616,31 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'fluid' => 'forums_default_view_fluid'
|
||||
)
|
||||
), function( $value ) {
|
||||
if( $value !== '*' AND count( $value ) !== 0 AND count( $value ) < 2 )
|
||||
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->addHeader('topic_settings');
|
||||
|
||||
|
||||
$popularNowMaximum = 14400000;
|
||||
$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 )
|
||||
@@ -606,18 +650,38 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
/* If popular now time is greater than 10,000 days */
|
||||
'validate' => function( $obj ) use ( $popularNowMaximum )
|
||||
{
|
||||
if( $obj->value['minutes'] > $popularNowMaximum )
|
||||
|
||||
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 ) ) ) );
|
||||
}
|
||||
}
|
||||
) ) );
|
||||
|
||||
$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\Number( 'forums_topics_per_page', \IPS\Settings::i()->forums_topics_per_page , TRUE, array( 'min' => 5, 'max' => 100 ) ) );
|
||||
$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 \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(
|
||||
'options' => array(
|
||||
'time' => 'forums_topic_show_meta_time',
|
||||
'moderation' => 'forums_topic_show_meta_moderation'
|
||||
) ) ) );
|
||||
|
||||
$form->addHeader('topic_summary_settings');
|
||||
|
||||
$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(
|
||||
'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 \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 \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(
|
||||
'options' => array(
|
||||
'popularDays' => 'forums_topic_activity_features_popularDays',
|
||||
'topPost' => 'forums_topic_activity_features_topPost',
|
||||
'uploads' => 'forums_topic_activity_features_uploads'
|
||||
) ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -632,7 +696,22 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
|
||||
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'] ) )
|
||||
{
|
||||
$values['forums_topic_activity'] = json_encode( $values['forums_topic_activity'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['forums_topic_activity_features'] ) )
|
||||
{
|
||||
$values['forums_topic_activity_features'] = json_encode( $values['forums_topic_activity_features'] );
|
||||
}
|
||||
|
||||
if ( isset( $values['forums_topics_show_meta'] ) )
|
||||
{
|
||||
$values['forums_topics_show_meta'] = json_encode( $values['forums_topics_show_meta'] );
|
||||
}
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
Reference in new issue
Block a user