Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -0,0 +1,122 @@
<?php
/**
* @brief Profile Completion
* @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
* @since 04 Jan 2018
*/
namespace IPS\core\modules\admin\membersettings;
/* 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;
}
/**
* Profile Completion
*/
class _profilecompletion extends \IPS\Node\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\Member\ProfileStep';
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profilefields_manage' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
public function manage()
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'members' )->profileCompleteBlurb();
parent::manage();
}
/**
* Enable quick registration
*
* @return void
*/
public function enableQuickRegister()
{
\IPS\Settings::i()->changeValues( array( 'quick_register' => 1 ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=profilecompletion' ), 'profile_complete_quick_register_off_enabled' );
}
/**
* Add Step Form
*
* @return void
*/
public function form()
{
$form = new \IPS\Helpers\Form;
if ( isset( \IPS\Request::i()->id ) )
{
try
{
$step = \IPS\Member\ProfileStep::load( \IPS\Request::i()->id );
}
catch( \OutOFRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2C360/1', 404, '' );
}
}
else
{
$step = new \IPS\Member\ProfileStep;
}
$step->form( $form );
if ( $values = $form->values() )
{
$values = $step->formatFormValues( $values );
$step->extension = \IPS\Member\ProfileStep::findExtensionFromAction( $values['step_completion_act'] );
if ( isset( $values['step_required'] ) )
{
$step->required = $values['step_required'];
}
else
{
$step->required = FALSE;
}
$step->completion_act = $values['step_completion_act'];
$step->subcompletion_act = $values['step_subcompletion_act'];
$step->save();
$step->postSaveForm( $values );
if ( method_exists( $step->extension, 'postAcpSave' ) )
{
$step->extension->postAcpSave( $step, $values );
}
\IPS\Member::updateAllMembers( array( "members_bitoptions2 = members_bitoptions2 & ~" . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['profile_completed'] ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=membersettings&controller=profiles&tab=profilecompletion" ), 'saved' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'profile_completion' );
\IPS\Output::i()->output = $form;
}
}
@@ -0,0 +1,64 @@
<?php
/**
* @brief Profile Fields and Settings
* @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
* @since 09 Apr 2013
*/
namespace IPS\core\modules\admin\membersettings;
/* 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;
}
/**
* Profile Fields and Settings
*/
class _profilefields extends \IPS\Node\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\core\ProfileFields\Group';
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profilefields_manage' );
parent::execute();
}
/**
* Get Root Buttons
*
* @return array
*/
public function _getRootButtons()
{
$nodeClass = $this->nodeClass;
if ( $nodeClass::canAddRoot() )
{
$add = array(
'icon' => 'plus',
'title' => 'add',
'link' => $this->url->setQueryString( 'do', 'form' ),
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') ) : array() )
);
return array( 'add' => $add );
}
return array();
}
}
@@ -1,11 +1,11 @@
<?php
/**
* @brief Profile Fields and Settings
* @brief Profile settings gateway
* @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
* @since 09 Apr 2013
* @since 08 Jan 2018
*/
namespace IPS\core\modules\admin\membersettings;
@@ -18,326 +18,51 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
}
/**
* Profile Fields and Settings
* Profile settings gateway
*/
class _profiles extends \IPS\Node\Controller
class _profiles extends \IPS\Dispatcher\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\core\ProfileFields\Group';
/**
* Execute
* Call
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profilefields_manage' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
public function __call( $method, $args )
{
/* Init */
$activeTab = \IPS\Request::i()->tab ?: 'fields';
$activeTabContents = '';
$tabs = array( 'fields' => 'profile_fields' );
$activeTab = \IPS\Request::i()->tab ?: 'profilefields';
$activeTabContents = '';
$tabs = array();
/* Add a tab for fields and completion */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profilesfields_manage' ) )
{
$tabs['profilefields'] = 'profile_fields';
$tabs['profilecompletion'] = 'profile_completion';
}
/* Add a tab for settings */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profiles_manage' ) )
{
$tabs['settings'] = 'profile_settings';
$tabs['completion'] = 'profile_completion';
}
$method = '_tab' . ucwords( $activeTab );
if ( method_exists( $this, $method ) )
{
$activeTabContents = (string) $this->$method();
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('module__core_profile');
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output = $activeTabContents;
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=membersettings&controller=profiles" ) );
}
}
/**
* Fields Tab
*
* @return string
*/
protected function _tabFields()
{
parent::manage();
return \IPS\Output::i()->output;
}
/**
* Settings Tab
*
* @return \IPS\Helpers\Form
*/
protected function _tabSettings()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
$form = new \IPS\Helpers\Form;
$form->addHeader( 'photos' );
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_gravatars', \IPS\Settings::i()->allow_gravatars ) );
if( \IPS\Image::canWriteText() )
{
$form->add( new \IPS\Helpers\Form\Radio( 'letter_photos', \IPS\Settings::i()->letter_photos, FALSE, array( 'options' => array( 'default' => 'letterphoto_default', 'letters' => 'letterphoto_letters' ) ) ) );
$tabs['profilesettings'] = 'profile_settings';
}
$form->addHeader( 'usernames' );
$form->add( new \IPS\Helpers\Form\Custom( 'user_name_length', array( \IPS\Settings::i()->min_user_name_length, \IPS\Settings::i()->max_user_name_length ), FALSE, array(
'getHtml' => function( $field ) {
return \IPS\Theme::i()->getTemplate('members')->usernameLengthSetting( $field->name, $field->value );
}
),
function( $val )
{
if ( $val[0] < 1 )
{
throw new \DomainException('user_name_length_too_low');
}
if ( $val[1] > 255 )
{
throw new \DomainException('user_name_length_too_high');
}
if ( $val[0] > $val[1] )
{
throw new \DomainException('user_name_length_no_match');
}
} ) );
$form->add( new \IPS\Helpers\Form\Text( 'username_characters', \IPS\Settings::i()->username_characters, FALSE, array( 'max' => 255 ) ) );
$form->addHeader( 'signatures' );
$form->add( new \IPS\Helpers\Form\YesNo( 'signatures_enabled', \IPS\Settings::i()->signatures_enabled ) );
$form->addHeader( 'statuses_profile_comments' );
$form->add( new \IPS\Helpers\Form\YesNo( 'profile_comments', \IPS\Settings::i()->profile_comments, FALSE, array( 'togglesOn' => array( 'profile_comment_approval' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'profile_comment_approval', \IPS\Settings::i()->profile_comment_approval, FALSE, array(), NULL, NULL, NULL, 'profile_comment_approval' ) );
$form->addHeader( 'profile_settings_birthdays' );
$form->add( new \IPS\Helpers\Form\Radio( 'profile_birthday_type', \IPS\Settings::i()->profile_birthday_type, TRUE, array(
'options' => array( 'public' => 'profile_birthday_type_public', 'private' => 'profile_birthday_type_private', 'none' => 'profile_birthday_type_none' )
), NULL, NULL, NULL, 'profile_birthday_type' ) );
if( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'profiles', 'member_history_prune' ) )
{
$form->addHeader( 'profile_member_history' );
$form->add( new \IPS\Helpers\Form\Number( 'prune_member_history', \IPS\Settings::i()->prune_member_history, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_member_history' ) );
}
$form->addHeader( 'profile_settings_ignore' );
$form->add( new \IPS\Helpers\Form\YesNo( 'ignore_system_on', \IPS\Settings::i()->ignore_system_on, FALSE, array(), NULL, NULL, NULL, 'ignore_system_on' ) );
if ( $values = $form->values() )
{
$values['min_user_name_length'] = $values['user_name_length'][0];
$values['max_user_name_length'] = $values['user_name_length'][1];
unset( $values['user_name_length'] );
/* Route */
$classname = 'IPS\core\modules\admin\membersettings\\' . $activeTab;
$class = new $classname;
$class->url = \IPS\Http\Url::internal("app=core&module=membersettings&controller=profiles&tab={$activeTab}");
$class->execute();
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplog__profile_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=settings' ), 'saved' );
}
return $form;
}
/**
* Completion Tab
*
* @return \IPS\Helpers\Form
*/
protected function _tabCompletion()
{
/* Is the quick register function disabled? */
if ( ! \IPS\Settings::i()->quick_register )
{
return \IPS\Theme::i()->getTemplate( 'members' )->quickRegisterDisabled();
}
$table = new \IPS\Helpers\Table\Db( 'core_profile_steps', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=completion' ) );
$table->langPrefix = 'profile_acp_table_';
$table->include = array( 'step_extension', 'step_required' );
$table->rootButtons = array(
array(
'icon' => 'plus',
'title' => 'add',
'link' => \IPS\Http\Url::internal( "app=core&module=membersettings&controller=profiles&do=step" )
)
);
$table->parsers = array(
'step_extension' => function( $val, $row )
{
return \IPS\Theme::i()->getTemplate( 'members' )->profileCompleteTitle( $row );
},
'step_required' => function( $val ) {
if ( $val )
{
return '&#10003;';
}
else
{
return '&#10007;';
}
}
);
$table->rowButtons = function( $row )
{
return array(
'edit' => array(
'title' => 'edit',
'icon' => 'pencil',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&do=step&id=' . $row['step_id'] )
),
'delete' => array(
'title' => 'delete',
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&do=deleteStep&id=' . $row['step_id'] ),
'data' => array( 'delete' => '' )
),
);
};
$output = \IPS\Output::i()->output;
return \IPS\Theme::i()->getTemplate( 'members' )->profileCompleteBlurb() . $table;
}
/**
* Enable quick registration
*
* @return void
*/
public function enableQuickRegister()
{
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 1 ), array( 'conf_key=?', 'quick_register' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=completion' ), 'profile_complete_quick_register_off_enabled' );
}
/**
* Add Step Form
*
* @return void
*/
public function step()
{
$form = new \IPS\Helpers\Form;
if ( isset( \IPS\Request::i()->id ) )
if ( $method !== 'manage' or \IPS\Request::i()->isAjax() )
{
try
{
$step = \IPS\Member\ProfileStep::load( \IPS\Request::i()->id );
}
catch( \OutOFRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2C360/1', 404, '' );
}
return;
}
else
{
$step = new \IPS\Member\ProfileStep;
}
$step->form( $form );
if ( $values = $form->values() )
{
$values = $step->formatFormValues( $values );
$step->extension = \IPS\Member\ProfileStep::findExtensionFromAction( $values['step_completion_act'] );
if ( isset( $values['step_required'] ) )
{
$step->required = $values['step_required'];
}
else
{
$step->required = FALSE;
}
$step->completion_act = $values['step_completion_act'];
$step->subcompletion_act = $values['step_subcompletion_act'];
$step->save();
$step->postSaveForm( $values );
if ( method_exists( $step->extension, 'postAcpSave' ) )
{
$step->extension->postAcpSave( $step, $values );
}
\IPS\Member::updateAllMembers( array( "members_bitoptions2 = members_bitoptions2 & ~" . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['profile_completed'] ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=membersettings&controller=profiles&tab=completion" ), 'saved' );
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=completion' ), \IPS\Member::loggedIn()->language()->addToStack('profile_completion') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'profile_completion' );
\IPS\Output::i()->output = $form;
}
/**
* Delete Step
*
* @return void
*/
public function deleteStep()
{
try
{
$step = \IPS\Member\ProfileStep::load( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2C360/2', 404, '' );
}
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
$step->delete();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=membersettings&controller=profiles&tab=completion" ), 'deleted' );
}
/**
* Get Root Buttons
*
* @return array
*/
public function _getRootButtons()
{
$nodeClass = $this->nodeClass;
if ( $nodeClass::canAddRoot() )
{
$add = array(
'icon' => 'plus',
'title' => 'add',
'link' => $this->url->setQueryString( 'do', 'form' ),
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') ) : array() )
);
return array( 'add' => $add );
}
return array();
\IPS\Output::i()->output = '';
/* Output */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('module__core_profile');
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $output, \IPS\Http\Url::internal( "app=core&module=membersettings&controller=profiles" ) );
}
}
@@ -0,0 +1,120 @@
<?php
/**
* @brief Profile Settings
* @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
* @since 08 Jan 2018
*/
namespace IPS\core\modules\admin\membersettings;
/* 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;
}
/**
* Profile Settings
*/
class _profilesettings extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
public function manage()
{
$form = new \IPS\Helpers\Form;
$form->addHeader( 'photos' );
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_gravatars', \IPS\Settings::i()->allow_gravatars ) );
if( \IPS\Image::canWriteText() )
{
$form->add( new \IPS\Helpers\Form\Radio( 'letter_photos', \IPS\Settings::i()->letter_photos, FALSE, array( 'options' => array( 'default' => 'letterphoto_default', 'letters' => 'letterphoto_letters' ) ) ) );
}
$form->addHeader( 'usernames' );
$form->add( new \IPS\Helpers\Form\Custom( 'user_name_length', array( \IPS\Settings::i()->min_user_name_length, \IPS\Settings::i()->max_user_name_length ), FALSE, array(
'getHtml' => function( $field ) {
return \IPS\Theme::i()->getTemplate('members')->usernameLengthSetting( $field->name, $field->value );
}
),
function( $val )
{
if ( $val[0] < 1 )
{
throw new \DomainException('user_name_length_too_low');
}
if ( $val[1] > 255 )
{
throw new \DomainException('user_name_length_too_high');
}
if ( $val[0] > $val[1] )
{
throw new \DomainException('user_name_length_no_match');
}
} ) );
$form->add( new \IPS\Helpers\Form\Text( 'username_characters', \IPS\Settings::i()->username_characters, FALSE, array( 'max' => 255 ) ) );
$form->addHeader( 'signatures' );
$form->add( new \IPS\Helpers\Form\YesNo( 'signatures_enabled', \IPS\Settings::i()->signatures_enabled ) );
/* Status updates */
$options = array(
0 => 'status_updates_disabled',
1 => 'status_updates_enabled_nomem',
2 => 'status_updates_enabled_mem'
);
$default = \IPS\Settings::i()->profile_comments ? ( \IPS\Settings::i()->status_updates_mem_enable ? 2 : 1 ) : 0;
$form->addHeader( 'statuses_profile_comments' );
$form->add( new \IPS\Helpers\Form\Radio( 'profile_comments', $default, FALSE, array( 'options' => $options, 'toggles' => array( 1 => array( 'profile_comment_approval' ), 2 => array( 'profile_comment_approval' ) ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'profile_comment_approval', \IPS\Settings::i()->profile_comment_approval, FALSE, array(), NULL, NULL, NULL, 'profile_comment_approval' ) );
$form->addHeader( 'profile_settings_birthdays' );
$form->add( new \IPS\Helpers\Form\Radio( 'profile_birthday_type', \IPS\Settings::i()->profile_birthday_type, TRUE, array(
'options' => array( 'public' => 'profile_birthday_type_public', 'private' => 'profile_birthday_type_private', 'none' => 'profile_birthday_type_none' )
), NULL, NULL, NULL, 'profile_birthday_type' ) );
if( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'profiles', 'member_history_prune' ) )
{
$form->addHeader( 'profile_member_history' );
$form->add( new \IPS\Helpers\Form\Number( 'prune_member_history', \IPS\Settings::i()->prune_member_history, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_member_history' ) );
}
$form->addHeader( 'profile_settings_ignore' );
$form->add( new \IPS\Helpers\Form\YesNo( 'ignore_system_on', \IPS\Settings::i()->ignore_system_on, FALSE, array(), NULL, NULL, NULL, 'ignore_system_on' ) );
if ( $values = $form->values() )
{
$values['min_user_name_length'] = $values['user_name_length'][0];
$values['max_user_name_length'] = $values['user_name_length'][1];
unset( $values['user_name_length'] );
$values['status_updates_mem_enable'] = ( $values['profile_comments'] == 2 ) ? 1 : 0;
$values['profile_comments'] = ( $values['profile_comments'] > 0 ) ? 1 : 0;
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplog__profile_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=profilesettings' ), 'saved' );
}
\IPS\Output::i()->output = (string) $form;
}
}
@@ -1,97 +0,0 @@
<?php
/**
* @brief Registration
* @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
* @since 18 Jul 2013
*/
namespace IPS\core\modules\admin\membersettings;
/* 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;
}
/**
* Registration
*/
class _registration extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'registration_manage' );
parent::execute();
}
/**
* General Member Settings
*
* @return void
*/
protected function manage()
{
$form = $this->getSettingsForm();
if ( $values = $form->values() )
{
if ( isset( $values['allowed_reg_email'] ) and is_array( $values['allowed_reg_email'] ) )
{
$values['allowed_reg_email'] = implode( ',', $values['allowed_reg_email'] );
}
if ( $values['use_coppa'] OR $values['minimum_age'] )
{
$values['quick_register'] = 0;
}
$form->saveAsSettings( $values );
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Session::i()->log( 'acplogs__general_settings' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('membersettings_registration_title');
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global' )->block( 'membersettings_registration_title', $form );
}
/**
* Get the settings form
*
* @return \IPS\Helpers\Form
*/
protected function getSettingsForm()
{
$form = new \IPS\Helpers\Form;
$form->addHeader('registration');
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_reg', \IPS\Settings::i()->allow_reg, FALSE, array( 'togglesOn' => array( 'quick_register', 'new_reg_notify', 'reg_auth_type', 'form_header_coppa', 'use_coppa' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'quick_register', \IPS\Settings::i()->quick_register, FALSE, array(), NULL, NULL, NULL, 'quick_register' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'new_reg_notify', \IPS\Settings::i()->new_reg_notify, FALSE, array(), NULL, NULL, NULL, 'new_reg_notify' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'reg_auth_type', \IPS\Settings::i()->reg_auth_type, TRUE, array(
'options' => array( 'user' => 'reg_auth_type_user', 'admin' => 'reg_auth_type_admin', 'admin_user' => 'reg_auth_type_admin_user', 'none' => 'reg_auth_type_none' ),
'toggles' => array( 'user' => array( 'validate_day_prune' ), 'admin_user' => array( 'validate_day_prune' ) )
), NULL, NULL, NULL, 'reg_auth_type' ) );
$form->add( new \IPS\Helpers\Form\Number( 'validate_day_prune', \IPS\Settings::i()->validate_day_prune, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'validate_day_prune' ) );
$form->add( new \IPS\Helpers\Form\Stack( 'allowed_reg_email', explode( ',', \IPS\Settings::i()->allowed_reg_email ), FALSE, array(), NULL, NULL, NULL ) );
$form->addHeader('age_requirements');
$form->add( new \IPS\Helpers\Form\Number( 'minimum_age', \IPS\Settings::i()->minimum_age, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'any_age', 'unlimitedToggles' => array( 'quick_register' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'use_coppa', \IPS\Settings::i()->use_coppa, FALSE, array( 'togglesOn' => array( 'coppa_fax', 'coppa_address' ), 'togglesOff' => array( 'quick_register' ) ), NULL, NULL, NULL, 'use_coppa' ) );
$form->add( new \IPS\Helpers\Form\Tel( 'coppa_fax', \IPS\Settings::i()->coppa_fax, FALSE, array(), NULL, NULL, NULL, 'coppa_fax' ) );
$form->add( new \IPS\Helpers\Form\Address( 'coppa_address', \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->coppa_address ), FALSE, array(), NULL, NULL, NULL, 'coppa_address' ) );
return $form;
}
}
@@ -123,7 +123,7 @@ class _reputation extends \IPS\Node\Controller
}
$member = \IPS\Member::constructFromData( \IPS\Db::i()->select( '*', 'core_members', $where, 'member_id ASC', 1 )->first() );
$names[ $member->member_id ] = '<a>' . htmlentities( $member->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
$names[ $member->member_id ] = '<a>' . htmlentities( $member->name, ENT_DISALLOWED, 'UTF-8', FALSE ) . '</a>';
}
catch ( \Exception $e )
{
@@ -176,6 +176,7 @@ class _reputation extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form();
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_leaderboard_on', \IPS\Settings::i()->reputation_leaderboard_on, FALSE, array( 'togglesOn' => array( 'reputation_leaderboard_default_tab', 'form_header_leaderboard_tabs_leaderboard', 'reputation_show_days_won_trophy', 'reputation_timezone', 'form_header_leaderboard_tabs_members', 'reputation_top_members_overview', 'reputation_overview_max_members', 'reputation_top_members_filters', 'reputation_max_members' ) ), NULL, NULL, NULL, 'reputation_leaderboard_on' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'reputation_leaderboard_default_tab', \IPS\Settings::i()->reputation_leaderboard_default_tab, FALSE, array( 'options' => array( 'leaderboard' => 'leaderboard_tabs_leaderboard', 'history' => 'leaderboard_tabs_history', 'members' => 'leaderboard_tabs_members' ) ), NULL, NULL, NULL, 'reputation_leaderboard_default_tab' ) );
$form->add( new \IPS\Helpers\Form\Select( 'leaderboard_excluded_groups', \IPS\Settings::i()->leaderboard_excluded_groups, FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'leaderboard_excluded_groups' ) );
$form->addHeader('leaderboard_tabs_leaderboard');
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_show_days_won_trophy', \IPS\Settings::i()->reputation_show_days_won_trophy, FALSE, array( 'togglesOn' => array() ), NULL, NULL, NULL, 'reputation_show_days_won_trophy' ) );
$form->add( new \IPS\Helpers\Form\Timezone( 'reputation_timezone', \IPS\Settings::i()->reputation_timezone, FALSE, array(), NULL, NULL, NULL, 'reputation_timezone' ) );
@@ -1,435 +0,0 @@
<?php
/**
* @brief Spam Prevention Settings
* @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
* @since 18 Apr 2013
*/
namespace IPS\core\modules\admin\membersettings;
/* 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;
}
/**
* Spam Prevention Settings
*/
class _spam extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
/* Get tab content */
$this->activeTab = \IPS\Request::i()->tab ?: 'captcha';
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_manage' );
parent::execute();
}
/**
* Manage Settings
*
* @return void
*/
protected function manage()
{
/* Work out output */
$activeTabContents = call_user_func( array( $this, '_manage'.ucfirst( $this->activeTab ) ) );
/* If this is an AJAX request, just return it */
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output = $activeTabContents;
return;
}
/* Build tab list */
$tabs = array();
$tabs['captcha'] = 'spamprevention_captcha';
$tabs['flagging'] = 'spamprevention_flagging';
$tabs['service'] = 'enhancements__core_SpamMonitoring';
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'qanda_manage' ) )
{
$tabs['qanda'] = 'qanda_settings';
}
/* Add a button for logs */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'spam_service_log' ) )
{
\IPS\Output::i()->sidebar['actions']['errorLog'] = array(
'title' => 'spamlogs',
'icon' => 'exclamation-triangle',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&do=serviceLogs' ),
);
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_membersettings_spam');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $this->activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=membersettings&controller=spam" ) );
}
/**
* Return the CAPTCHA options - abstracted for third parties
*
* @param string $type 'options' for the select options, 'toggles' for the toggles
* @return array
*/
protected function getCaptchaOptions( $type='options' )
{
switch( $type )
{
case 'options':
return array( 'none' => 'captcha_type_none', 'recaptcha2' => 'captcha_type_recaptcha2', 'recaptcha' => 'captcha_type_recaptcha', 'keycaptcha' => 'captcha_type_keycaptcha' );
break;
case 'toggles':
return array(
'none' => array( 'bot_antispam_type_warning' ),
'recaptcha2' => array( 'guest_captcha', 'recaptcha2_public_key', 'recaptcha2_private_key' ),
'recaptcha' => array( 'guest_captcha', 'recaptcha_public_key', 'recaptcha_private_key' ),
'keycaptcha' => array( 'guest_captcha', 'keycaptcha_privatekey' )
);
break;
}
return array();
}
/**
* Show CAPTCHA settings
*
* @return string HTML to display
*/
protected function _manageCaptcha()
{
/* Build Form */
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Radio( 'bot_antispam_type', \IPS\Settings::i()->bot_antispam_type, TRUE, array(
'options' => $this->getCaptchaOptions( 'options' ),
'toggles' => $this->getCaptchaOptions( 'toggles' ),
), NULL, NULL, NULL, 'bot_antispam_type' ) );
$form->add( new \IPS\Helpers\Form\Text( 'recaptcha2_public_key', \IPS\Settings::i()->recaptcha2_public_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha2_public_key' ) );
$form->add( new \IPS\Helpers\Form\Text( 'recaptcha2_private_key', \IPS\Settings::i()->recaptcha2_private_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha2_private_key' ) );
$form->add( new \IPS\Helpers\Form\Text( 'recaptcha_public_key', \IPS\Settings::i()->recaptcha_public_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha_public_key' ) );
$form->add( new \IPS\Helpers\Form\Text( 'recaptcha_private_key', \IPS\Settings::i()->recaptcha_private_key, FALSE, array(), NULL, NULL, NULL, 'recaptcha_private_key' ) );
$form->add( new \IPS\Helpers\Form\Text( 'keycaptcha_privatekey', \IPS\Settings::i()->keycaptcha_privatekey, FALSE, array(), NULL, NULL, NULL, 'keycaptcha_privatekey' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'guest_captcha', \IPS\Settings::i()->guest_captcha, FALSE, array(), NULL, NULL, \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'membertools_delete' ) ? ( "<a href='" . \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=deleteGuestContent' ) . "' data-ipsDialog data-ipsDialog-title='" . \IPS\Member::loggedIn()->language()->addToStack('member_delete_guest_content'). "'>" . \IPS\Member::loggedIn()->language()->addToStack('member_delete_guest_content') . "</a>" ) : '', 'guest_captcha' ) );
/* Save values */
if ( $form->values() )
{
$form->saveAsSettings();
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Session::i()->log( 'acplogs__spamprev_settings' );
}
return $form;
}
/**
* Show spammer flagging settings
*
* @return string HTML to display
*/
protected function _manageFlagging()
{
/* Build Form */
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'spm_option', explode( ',', \IPS\Settings::i()->spm_option ), FALSE, array(
'options' => array( 'disable' => 'spm_option_disable', 'unapprove' => 'spm_option_unapprove', 'delete' => 'spm_option_delete', 'ban' => 'spm_option_ban' ),
) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'spm_notify', \IPS\Settings::i()->spm_notify ) );
/* Save values */
if ( $form->values() )
{
$form->saveAsSettings();
\IPS\Session::i()->log( 'acplogs__spamprev_settings' );
}
return $form;
}
/**
* Show IPS Spam Service settings
*
* @return string HTML to display
*/
protected function _manageService()
{
$licenseData = \IPS\IPS::licenseKey();
/* Build Form */
$actions = array( 1 => 'spam_service_act_1', 2 => 'spam_service_act_2', 3 => 'spam_service_act_3', 4 => 'spam_service_act_4' );
$form = new \IPS\Helpers\Form;
$form->addHeader( 'enhancements__core_SpamMonitoring' );
$disabled = FALSE;
if( !$licenseData or !isset( $licenseData['products']['spam'] ) or !$licenseData['products']['spam'] or strtotime( $licenseData['expires'] ) < time() )
{
$disabled = TRUE;
if( !\IPS\Settings::i()->ipb_reg_number )
{
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom
}
else
{
\IPS\Member::loggedIn()->language()->words['spam_service_enabled_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '__ipbmafia__nulling_null_alert' ); //Changing error message to custom
}
}
$form->add( new \IPS\Helpers\Form\YesNo( 'spam_service_enabled', \IPS\Settings::i()->spam_service_enabled, 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_send_to_ips', \IPS\Settings::i()->spam_service_send_to_ips, 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 ), NULL, NULL, NULL, 'spam_service_action_1' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_2', \IPS\Settings::i()->spam_service_action_2, FALSE, array( 'disabled' => $disabled, 'options' => $actions ), NULL, NULL, NULL, 'spam_service_action_2' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_3', \IPS\Settings::i()->spam_service_action_3, FALSE, array( 'disabled' => $disabled, 'options' => $actions ), NULL, NULL, NULL, 'spam_service_action_3' ) );
$form->add( new \IPS\Helpers\Form\Select( 'spam_service_action_4', \IPS\Settings::i()->spam_service_action_4, FALSE, array( 'disabled' => $disabled, 'options' => $actions ), NULL, NULL, NULL, 'spam_service_action_4' ) );
$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 ( $form->values() )
{
$form->saveAsSettings();
\IPS\Session::i()->log( 'acplog__enhancements_edited', array( 'enhancements__core_SpamMonitoring' => TRUE ) );
}
return $form;
}
/**
* Show question and answer challenge settings
*
* @return string HTML to display
*/
protected function _manageQanda()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_manage' );
/* Create the table */
$table = new \IPS\Helpers\Table\Db( 'core_question_and_answer', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&tab=qanda' ) );
$table->include = array( 'qa_question' );
$table->joins = array(
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_question_and_answer_', core_question_and_answer.qa_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
);
$table->parsers = array(
'qa_question' => function( $val, $row )
{
return ( $row['word_custom'] ? $row['word_custom'] : $row['qa_question'] );
}
);
$table->mainColumn = 'qa_question';
$table->sortBy = $table->sortBy ?: 'qa_question';
$table->quickSearch = array( 'word_custom', 'qa_question' );
$table->sortDirection = $table->sortDirection ?: 'asc';
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'qanda_add' ) )
{
$table->rootButtons = array(
'add' => array(
'icon' => 'plus',
'title' => 'qanda_add_question',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&do=question' ),
)
);
}
$table->rowButtons = function( $row )
{
$return = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'qanda_edit' ) )
{
$return['edit'] = array(
'icon' => 'pencil',
'title' => 'edit',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&do=question&id=' ) . $row['qa_id'],
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'qanda_delete' ) )
{
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&do=delete&id=' ) . $row['qa_id'],
'data' => array( 'delete' => '' ),
);
}
return $return;
};
return (string) $table;
}
/**
* Add/Edit Form
*
* @return void
*/
protected function question()
{
/* Init */
$id = 0;
$question = array();
/* Start the form */
$form = new \IPS\Helpers\Form;
/* Load question */
try
{
$id = intval( \IPS\Request::i()->id );
$form->hiddenValues['id'] = $id;
$question = \IPS\Db::i()->select( '*', 'core_question_and_answer', array( 'qa_id=?', $id ) )->first();
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_edit' );
}
catch ( \UnderflowException $e )
{
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_add' );
}
$form->add( new \IPS\Helpers\Form\Translatable( 'qa_question', NULL, TRUE, array( 'app' => 'core', 'key' => ( $id ? "core_question_and_answer_{$id}" : NULL ) ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'qa_answers', $id ? json_decode( $question['qa_answers'], TRUE ) : array(), TRUE ) );
/* Handle submissions */
if ( $values = $form->values() )
{
$save = array(
'qa_answers' => json_encode( $values['qa_answers'] ),
);
if ( $id )
{
\IPS\Db::i()->update( 'core_question_and_answer', $save, array( 'qa_id=?', $question['qa_id'] ) );
\IPS\Session::i()->log( 'acplogs__question_edited' );
}
else
{
$id = \IPS\Db::i()->insert( 'core_question_and_answer', $save );
\IPS\Session::i()->log( 'acplogs__question_added' );
}
\IPS\Lang::saveCustom( 'core', "core_question_and_answer_{$id}", $values['qa_question'] );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&tab=qanda' ), 'saved' );
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('qanda_settings');
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( \IPS\Output::i()->title, $form );
}
/**
* Delete
*
* @return void
*/
protected function delete()
{
$id = intval( \IPS\Request::i()->id );
\IPS\Dispatcher::i()->checkAcpPermission( 'qanda_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
\IPS\Db::i()->delete( 'core_question_and_answer', array( 'qa_id=?', $id ) );
\IPS\Session::i()->log( 'acplogs__question_deleted' );
\IPS\Lang::deleteCustom( 'core', "core_question_and_answer_{$id}" );
/* And redirect */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=membersettings&controller=spam&tab=qanda" ) );
}
/**
* Spam Service Log
*
* @return void
*/
protected function serviceLogs()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
/* Create the table */
$table = new \IPS\Helpers\Table\Db( 'core_spam_service_log', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&do=serviceLogs' ) );
$table->langPrefix = 'spamlogs_';
/* Columns we need */
$table->include = array( 'log_date', 'log_code', 'email_address', 'ip_address' );
$table->sortBy = $table->sortBy ?: 'log_date';
$table->sortDirection = $table->sortDirection ?: 'DESC';
/* Search */
$table->advancedSearch = array(
'email_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
'log_code' => \IPS\Helpers\Table\SEARCH_NUMERIC,
);
$table->quickSearch = 'email_address';
/* Custom parsers */
$table->parsers = array(
'log_date' => function( $val, $row )
{
return \IPS\DateTime::ts( $val )->localeDate();
},
);
/* Add a button for settings */
\IPS\Output::i()->sidebar['actions'] = array(
'settings' => array(
'title' => 'prunesettings',
'icon' => 'cog',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&do=serviceLogSettings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('prunesettings') )
),
);
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('spamlogs');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'spamlogs', $table );
}
/**
* Prune Settings
*
* @return void
*/
protected function serviceLogSettings()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'spam_service_log' );
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_spam', \IPS\Settings::i()->prune_log_spam, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_spam' ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Session::i()->log( 'acplog__spamlog_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=spam&do=serviceLogs' ), 'saved' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('spamlogssettings');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'spamlogssettings', $form, FALSE );
}
}
@@ -1,273 +0,0 @@
<?php
/**
* @brief Warnings
* @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
* @since 23 Apr 2013
*/
namespace IPS\core\modules\admin\membersettings;
/* 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;
}
/**
* Warnings
*/
class _warnings extends \IPS\Node\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\core\Warnings\Reason';
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'warn_settings' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
public function manage()
{
/* Init */
$activeTab = \IPS\Request::i()->tab ?: NULL;
$activeTabContents = '';
$tabs = array();
/* Reasons */
if ( \IPS\Settings::i()->warn_on and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reasons_view' ) )
{
$tabs['reasons'] = 'warn_reasons';
if ( $activeTab == 'reasons' )
{
parent::manage();
$activeTabContents = \IPS\Output::i()->output;
}
}
/* Actions */
if ( \IPS\Settings::i()->warn_on and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'actions_view' ) )
{
$tabs['actions'] = 'warn_actions';
if ( $activeTab == 'actions' )
{
/* Init */
$table = new \IPS\Helpers\Table\Db( 'core_members_warn_actions', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=warnings' ) );
$table->include = array( 'wa_points', 'wa_mq', 'wa_rpa', 'wa_suspend' );
$table->sortBy = $table->sortBy ?: 'wa_points';
$table->sortDirection = $table->sortDirection ?: 'asc';
/* Row buttons */
$table->rowButtons = function( $row )
{
$return = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'actions_edit' ) )
{
$return['edit'] = array(
'icon' => 'pencil',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=warnings&do=actionForm&id=' ) . $row['wa_id'],
'title' => 'edit',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') )
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'actions_delete' ) )
{
$return['delete'] = array(
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=warnings&do=actionDelete&id=' ) . $row['wa_id'],
'title' => 'delete',
'data' => array( 'delete' => '' )
);
}
return $return;
};
/* Parsers */
$table->parsers = array(
'wa_mq' => function( $val, $row )
{
return $val ? ( ( $val == -1 ) ? \IPS\Member::loggedIn()->language()->addToStack('indefinitely') : ( \IPS\Member::loggedIn()->language()->addToStack('for') . ' ' . $val . ' ' . ( $row['wa_mq_unit'] == 'd' ? \IPS\Member::loggedIn()->language()->addToStack('days') : \IPS\Member::loggedIn()->language()->addToStack('hours') ) ) ) : '-';
},
'wa_rpa' => function( $val, $row )
{
return $val ? ( ( $val == -1 ) ? \IPS\Member::loggedIn()->language()->addToStack('indefinitely') : ( \IPS\Member::loggedIn()->language()->addToStack('for') . ' ' . $val . ' ' . ( $row['wa_rpa_unit'] == 'd' ? \IPS\Member::loggedIn()->language()->addToStack('days') : \IPS\Member::loggedIn()->language()->addToStack('hours') ) ) ) : '-';
},
'wa_suspend' => function( $val, $row )
{
return $val ? ( ( $val == -1 ) ? \IPS\Member::loggedIn()->language()->addToStack('indefinitely') : ( \IPS\Member::loggedIn()->language()->addToStack('for') . ' ' . $val . ' ' . ( $row['wa_suspend_unit'] == 'd' ? \IPS\Member::loggedIn()->language()->addToStack('days') : \IPS\Member::loggedIn()->language()->addToStack('hours') ) ) ) : '-';
}
);
/* Add button */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'actions_add' ) )
{
$table->rootButtons = array(
'add' => array(
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=warnings&do=actionForm' ),
'title' => 'add',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') )
)
);
}
/* Display */
$activeTabContents = (string) $table;
}
}
/* Settings */
$tabs['settings'] = 'settings';
if ( $activeTab == 'settings' )
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\YesNo( 'warn_on', \IPS\Settings::i()->warn_on, FALSE, array( 'togglesOn' => array(
'warn_protected',
'warn_show_own',
'warnings_acknowledge'
) ) ) );
$form->add( new \IPS\Helpers\Form\Select( 'warn_protected', explode( ',', \IPS\Settings::i()->warn_protected ), FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'warn_protected' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'warn_show_own', \IPS\Settings::i()->warn_show_own, FALSE, array(), NULL, NULL, NULL, 'warn_show_own' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'warnings_acknowledge', \IPS\Settings::i()->warnings_acknowledge, FALSE, array(), NULL, NULL, NULL, 'warnings_acknowledge' ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Session::i()->log( 'acplog__warn_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=warnings&tab=settings' ), 'saved' );
}
$activeTabContents = (string) $form;
}
/* Add the blurb in */
if ( $activeTab != 'settings' )
{
$activeTabContents = \IPS\Theme::i()->getTemplate( 'forms' )->blurb( 'warn_' . $activeTab . '_blurb', TRUE, TRUE ) . $activeTabContents;
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('warnings');
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output = $activeTabContents;
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=membersettings&controller=warnings" ) );
}
}
/**
* Warn Action Form
*
* @return void
*/
protected function actionForm()
{
$current = NULL;
if ( \IPS\Request::i()->id )
{
$current = \IPS\Db::i()->select( '*', 'core_members_warn_actions', array( 'wa_id=?', \IPS\Request::i()->id ) )->first();
\IPS\Dispatcher::i()->checkAcpPermission( 'actions_edit' );
}
if ( !$current )
{
\IPS\Dispatcher::i()->checkAcpPermission( 'actions_add' );
}
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Number( 'wa_points', ( $current ? $current['wa_points'] : 0 ), TRUE ) );
foreach ( array( 'mq', 'rpa', 'suspend' ) as $k )
{
$form->add( new \IPS\Helpers\Form\Custom( 'wa_' . $k, ( $current ? array( $current[ 'wa_' . $k ], $current[ 'wa_' . $k . '_unit' ] ) : 0 ), FALSE, array(
'getHtml' => function( $element )
{
return \IPS\Theme::i()->getTemplate( 'members' )->warningTime( $element->name, $element->value, 'for', 'indefinitely' );
},
'formatValue'=> function( $element )
{
if ( isset( $element->value[3] ) )
{
$element->value[0] = -1;
$element->value[1] = 'h';
unset( $element->value[3] );
}
return $element->value;
}
) ) );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'wa_override', ( $current ? $current['wa_override'] : FALSE ) ) );
if ( $values = $form->values() )
{
$save = array( 'wa_points' => $values['wa_points'], 'wa_override' => $values['wa_override'] );
foreach ( array( 'mq', 'rpa', 'suspend' ) as $k )
{
$save[ 'wa_' . $k ] = intval( $values[ 'wa_' . $k ][0] );
$save[ 'wa_' . $k . '_unit' ] = $values[ 'wa_' . $k ][1];
}
if ( $current )
{
\IPS\Db::i()->update( 'core_members_warn_actions', $save, array( 'wa_id=?', $current['wa_id'] ) );
\IPS\Session::i()->log( 'acplog__wa_edited', array( $save['wa_points'] => FALSE ) );
}
else
{
\IPS\Db::i()->insert( 'core_members_warn_actions', $save );
\IPS\Session::i()->log( 'acplog__wa_created', array( $save['wa_points'] => FALSE ) );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=warnings&tab=actions' ), 'saved' );
}
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global' )->block( 'warn_action', $form, FALSE );
}
/**
* Delete Warn Action
*
* @return void
*/
protected function actionDelete()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'actions_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
try
{
$current = \IPS\Db::i()->select( '*', 'core_members_warn_actions', array( 'wa_id=?', \IPS\Request::i()->id ) )->first();
\IPS\Session::i()->log( 'acplog__wa_deleted', array( $current['wa_points'] => FALSE ) );
\IPS\Db::i()->delete( 'core_members_warn_actions', array( 'wa_id=?', \IPS\Request::i()->id ) );
}
catch ( \UnderflowException $e ) { }
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=warnings&tab=actions' ), 'saved' );
}
}