Version 4.7.13
This commit is contained in:
1 parent
fd22d99e69
commit
7124a02564
954 files changed
+29277
-59308
No files matched your search
@@ -65,10 +65,15 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
$tabs['flagging'] = 'spamprevention_flagging';
|
||||
$tabs['service'] = 'enhancements__core_SpamMonitoring';
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_manage' ) and \in_array( \IPS\Login::registrationType(), array( 'normal', 'full' ) ) )
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'qanda_manage' ) )
|
||||
{
|
||||
$tabs['qanda'] = 'qanda_settings';
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'geolocation' ) )
|
||||
{
|
||||
$tabs['geolocation'] = 'geolocation_settings';
|
||||
}
|
||||
|
||||
/* Add a button for logs */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'moderation', 'spam_service_log' ) )
|
||||
@@ -220,7 +225,7 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'spam_service_enabled', 0, FALSE, array( 'disabled' => $disabled, 'togglesOn' => array( 'spam_service_send_to_ips', 'spam_service_action_0', 'spam_service_action_1', 'spam_service_action_2', 'spam_service_action_3', 'spam_service_action_4' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'spam_service_enabled', 0, FALSE, array( 'disabled' => $disabled, 'togglesOn' => array( 'spam_service_send_to_ips', 'spam_service_action_0', 'spam_service_action_1', 'spam_service_action_2', 'spam_service_action_3', 'spam_service_action_4', 'spam_service_disposable' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'spam_service_send_to_ips', 0, FALSE, array( 'disabled' => $disabled ), NULL, NULL, NULL, 'spam_service_send_to_ips' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_1', \IPS\Settings::i()->spam_service_action_1, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_1_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_1' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_action_1_num', ( isset( $days[1] ) ? $days[1] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_1_num' ) );
|
||||
@@ -230,20 +235,23 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_action_3_num', ( isset( $days[3] ) ? $days[3] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_3_num' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_4', \IPS\Settings::i()->spam_service_action_4, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_action_4_num' ) ) ), NULL, NULL, NULL, 'spam_service_action_4' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_action_4_num', ( isset( $days[4] ) ? $days[4] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_action_4_num' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_disposable', \IPS\Settings::i()->spam_service_disposable, FALSE, array( 'disabled' => $disabled, 'options' => $actions, 'toggles' => array( '5' => array( 'spam_service_disposable_num' ) ) ), NULL, NULL, NULL, 'spam_service_disposable' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'spam_service_disposable_num', ( isset( $days['disposable'] ) ? $days['disposable'] : -1 ), FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'spam_service_action_unlimited_days'), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'spam_service_disposable_num' ) );
|
||||
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_0', \IPS\Settings::i()->spam_service_action_0, FALSE, array( 'disabled' => $disabled, 'options' => $actions ), NULL, NULL, NULL, 'spam_service_action_0' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['spam_service_days'] = array();
|
||||
foreach( array( 1, 2, 3, 4 ) as $num )
|
||||
foreach( array( 'action_1', 'action_2', 'action_3', 'action_4', 'disposable' ) as $num )
|
||||
{
|
||||
if ( $values['spam_service_action_' . $num ] == 5 )
|
||||
if ( $values['spam_service_' . $num ] == 5 )
|
||||
{
|
||||
$values['spam_service_days'][ $num ] = $values['spam_service_action_' . $num . '_num' ];
|
||||
$values['spam_service_days'][ str_replace( 'action_', '', $num ) ] = $values['spam_service_' . $num . '_num' ];
|
||||
}
|
||||
|
||||
unset( $values['spam_service_action_' . $num . '_num' ] );
|
||||
unset( $values['spam_service_' . $num . '_num' ] );
|
||||
}
|
||||
|
||||
$values['spam_service_days'] = json_encode( $values['spam_service_days'] );
|
||||
@@ -318,7 +326,7 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
return $return;
|
||||
};
|
||||
|
||||
return (string) $table;
|
||||
return \IPS\Theme::i()->getTemplate( 'spam' )->spamQandASettings( $table );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -596,7 +604,7 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'whitelist_type', $current['whitelist_type'], TRUE,
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'whitelist_type', $current ? $current['whitelist_type'] : NULL, TRUE,
|
||||
array(
|
||||
'options' => array(
|
||||
'ip' => 'spam_whitelist_ip_select',
|
||||
@@ -608,14 +616,14 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
)
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_ip_content', $current['whitelist_content'], TRUE, array(), NULL, NULL, NULL, 'whitelist_ip_content' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_domain_content', $current['whitelist_content'], TRUE, array( 'placeholder' => 'mycompany.com' ), function( $value ) {
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_ip_content', $current ? $current['whitelist_content'] : NULL, TRUE, array(), NULL, NULL, NULL, 'whitelist_ip_content' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_domain_content', $current ? $current['whitelist_content'] : NULL, TRUE, array( 'placeholder' => 'mycompany.com' ), function( $value ) {
|
||||
if( isset( $value ) AND mb_stripos( $value, '@' ) )
|
||||
{
|
||||
throw new \DomainException( 'whitelist_domain_email_detected' );
|
||||
}
|
||||
}, NULL, NULL, 'whitelist_domain_content' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_reason', $current['whitelist_reason'] ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'whitelist_reason', $current ? $current['whitelist_reason'] : NULL ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -669,4 +677,69 @@ class _spam extends \IPS\Dispatcher\Controller
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&do=whitelist' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show GeoLocation settings
|
||||
*
|
||||
* @return string HTML to display
|
||||
*/
|
||||
protected function _manageGeolocation()
|
||||
{
|
||||
$licenseData = \IPS\IPS::licenseKey();
|
||||
|
||||
/* Build Form */
|
||||
$settings = \IPS\Settings::i()->spam_geo_settings ? json_decode( \IPS\Settings::i()->spam_geo_settings, true ) : array();
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$matrix = new \IPS\Helpers\Form\Matrix;
|
||||
|
||||
if( !$licenseData or !isset( $licenseData['products']['spam'] ) or !$licenseData['products']['spam'] or ( !$licenseData['cloud'] AND strtotime( $licenseData['expires'] ) < time() ) )
|
||||
{
|
||||
if( !\IPS\Settings::i()->ipb_reg_number )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__nulling_null_alert' ); //Changing error message to custom
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__nulling_null_alert' ); //Changing error message to custom
|
||||
}
|
||||
}
|
||||
|
||||
$matrix->columns = array(
|
||||
'country' => function( $key, $value, $data ) {
|
||||
$options = array();
|
||||
foreach( \IPS\GeoLocation::$countries AS $country )
|
||||
{
|
||||
$options[ $country ] = \IPS\Member::loggedIn()->language()->addToStack( 'country-' . $country );
|
||||
}
|
||||
return new \IPS\Helpers\Form\Select( $key, $value, TRUE, array( 'options' => $options ) );
|
||||
},
|
||||
'action' => function( $key, $value, $data ) {
|
||||
return new \IPS\Helpers\Form\Select( $key, $value, TRUE, array( 'options' => array( 'moderate' => 'spam_service_act_2', 'block' => 'spam_service_act_4' ) ) );
|
||||
}
|
||||
);
|
||||
|
||||
$matrix->rows = array();
|
||||
foreach( $settings AS $country => $action )
|
||||
{
|
||||
$matrix->rows[] = array(
|
||||
'country' => $country,
|
||||
'action' => $action
|
||||
);
|
||||
}
|
||||
$form->addMatrix( 'geolocation', $matrix );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$save = array();
|
||||
foreach( $values['geolocation'] AS $key => $value )
|
||||
{
|
||||
$save[ $value['country'] ] = $value['action'];
|
||||
}
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'spam_geo_settings' => json_encode( $save ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=moderation&controller=spam&tab=geolocation" ), 'saved' );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'spam' )->spamGeoSettings( $form );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user