Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -16,9 +16,11 @@ namespace IPS\forums\modules\admin\forums;
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\Content\Tag;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Forum;
|
||||
use IPS\forums\Topic;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
@@ -33,12 +35,11 @@ use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
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;
|
||||
@@ -79,6 +80,10 @@ class settings extends Controller
|
||||
{
|
||||
$tabs['archiving'] = 'archiving';
|
||||
}
|
||||
if( Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'autolock_settings' ) )
|
||||
{
|
||||
$tabs['autolock'] = 'autolock';
|
||||
}
|
||||
|
||||
$activeTab = Request::i()->tab ?: 'settings';
|
||||
$methodFunction = 'manage' . IPS::mb_ucfirst( $activeTab );
|
||||
@@ -94,7 +99,7 @@ class settings extends Controller
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $activeTabContents, Url::internal( "app=forums&module=forums&controller=settings" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Archive settings
|
||||
*
|
||||
@@ -164,7 +169,6 @@ class settings extends Controller
|
||||
|
||||
case 'post':
|
||||
case 'view':
|
||||
case 'rating':
|
||||
if ( $rule['archive_skip'] )
|
||||
{
|
||||
$existingValues[ "archive_not_topic_{$rule['archive_field']}" ] = array( $rule['archive_value'], $rule['archive_text'], FALSE );
|
||||
@@ -209,12 +213,10 @@ class settings extends Controller
|
||||
'archive_topic_poll',
|
||||
'archive_topic_post',
|
||||
'archive_topic_view',
|
||||
'archive_topic_rating',
|
||||
'archive_topic_starter',
|
||||
'archive_topic_not_forums',
|
||||
'archive_not_topic_post',
|
||||
'archive_not_topic_view',
|
||||
'archive_not_topic_rating',
|
||||
'archive_not_last_post',
|
||||
'archive_topic_starter_not',
|
||||
'form_header_archive_topics_where',
|
||||
@@ -249,7 +251,6 @@ class settings extends Controller
|
||||
$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 Node( 'archive_topic_not_forums', $existingValues['archive_topic_not_forums'] ?? array(), FALSE, array( 'class' => 'IPS\forums\Forum', 'multiple' => TRUE, 'permissionCheck' => function ( $forum )
|
||||
@@ -258,7 +259,6 @@ class settings extends Controller
|
||||
} ), NULL, NULL, NULL, 'archive_topic_not_forums' ) );
|
||||
$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' ) );
|
||||
|
||||
@@ -344,7 +344,7 @@ class settings extends 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' ) ) )
|
||||
{
|
||||
if ( !isset( $v[2] ) and $v[1] and $v[0] )
|
||||
{
|
||||
@@ -359,7 +359,7 @@ class settings extends 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' ) ) )
|
||||
{
|
||||
if ( !isset( $v[2] ) and $v[1] and $v[0] )
|
||||
{
|
||||
@@ -641,11 +641,6 @@ class settings extends Controller
|
||||
$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') ) );
|
||||
|
||||
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 YesNo( "forum_post_use_minimal_editor", (bool) SettingsClass::i()->forum_post_use_minimal_editor, false ) );
|
||||
|
||||
$form->addHeader('topic_overview_settings');
|
||||
@@ -699,4 +694,93 @@ class settings extends Controller
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-Lock topics settings
|
||||
*
|
||||
* @return Form|string
|
||||
*/
|
||||
protected function manageAutolock() : Form|string
|
||||
{
|
||||
$settings = SettingsClass::i()->autolock_topic_settings ? json_decode( SettingsClass::i()->autolock_topic_settings, true ) : [];
|
||||
|
||||
$form = new Form;
|
||||
$form->add( new YesNo( 'autolock_enabled', $settings['enabled'] ?? null, false, [
|
||||
'togglesOn' => [ 'autolock_days', 'autolock_pinned', 'autolock_featured', 'autolock_forums', 'autolock_members', 'autolock_tags' ]
|
||||
] ) );
|
||||
$form->add( new Number( 'autolock_days', $settings['days'] ?? 7, null, suffix: Member::loggedIn()->language()->addToStack( 'autolock_days_suffix' ), id: 'autolock_days' ) );
|
||||
$form->add( new YesNo( 'autolock_pinned', $settings['pinned'] ?? false, false, id: 'autolock_pinned' ) );
|
||||
$form->add( new YesNo( 'autolock_featured', $settings['featured'] ?? false, id: 'autolock_featured' ) );
|
||||
|
||||
$form->add( new Node( 'autolock_forums', $settings['forums'] ?? null, false, [
|
||||
'class' => Forum::class,
|
||||
'multiple' => true
|
||||
], id: 'autolock_forums' ) );
|
||||
|
||||
$excludedMembers = [];
|
||||
if( !empty( $settings['members'] ) )
|
||||
{
|
||||
$excludedMembers = iterator_to_array(
|
||||
new ActiveRecordIterator(
|
||||
Db::i()->select( '*', 'core_members', Db::i()->in( 'member_id', $settings['members'] ) ),
|
||||
Member::class
|
||||
)
|
||||
);
|
||||
}
|
||||
$form->add( new FormMember( 'autolock_members', count( $excludedMembers ) ? $excludedMembers : null, false, [ 'multiple' => null ], id: 'autolock_members' ) );
|
||||
|
||||
$form->add( new Text( 'autolock_tags', $settings['tags'] ?? null, false, [
|
||||
'autocomplete' => array(
|
||||
'unique' => TRUE,
|
||||
'source' => Tag::allTags(),
|
||||
'resultItemTemplate' => 'core.autocomplete.tagsResultItem',
|
||||
'freeChoice' => false,
|
||||
'minimized' => false,
|
||||
'alphabetical' => true,
|
||||
'addTokenText' => Member::loggedIn()->language()->get( 'tags_optional' ),
|
||||
)
|
||||
], id: 'autolock_tags' ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
if( $values['autolock_enabled'] )
|
||||
{
|
||||
$members = FormMember::stringValue( $values['autolock_members'] );
|
||||
$settings = [
|
||||
'enabled' => true,
|
||||
'days' => $values['autolock_days'],
|
||||
'pinned' => $values['autolock_pinned'],
|
||||
'featured' => $values['autolock_featured'],
|
||||
'members' => ( $members ? explode( "\n", $members ) : null ),
|
||||
'forums' => ( !empty( $values['autolock_forums'] ) ? array_keys( $values['autolock_forums'] ) : null ),
|
||||
'tags' => $values['autolock_tags']
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings = [ 'enabled' => false ];
|
||||
}
|
||||
|
||||
$form->saveAsSettings([
|
||||
'autolock_topic_settings' => json_encode( $settings )
|
||||
]);
|
||||
|
||||
Session::i()->log( 'acplogs__forums_autolock' );
|
||||
|
||||
/* And disable task if this feaure is disabled */
|
||||
if( !$values['autolock_enabled'] )
|
||||
{
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'autolock' ) );
|
||||
}
|
||||
/* Or enable it if necessary */
|
||||
else
|
||||
{
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'autolock' ) );
|
||||
}
|
||||
|
||||
Output::i()->redirect( Url::internal( 'app=forums&module=forums&controller=settings&tab=autolock' ), 'saved' );
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user