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
@@ -11,30 +11,51 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Data\Store;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use const IPS\Helpers\Table\SEARCH_CONTAINS_TEXT;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ban
|
||||
*/
|
||||
class _ban extends \IPS\Dispatcher\Controller
|
||||
class ban extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'ban_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'ban_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -43,9 +64,9 @@ class _ban extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_banfilters', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban' ) );
|
||||
$table = new TableDb( 'core_banfilters', Url::internal( 'app=core&module=membersettings&controller=ban' ) );
|
||||
|
||||
$table->filters = array(
|
||||
'ban_filter_ip' => 'ban_type=\'ip\'',
|
||||
@@ -61,30 +82,30 @@ class _ban extends \IPS\Dispatcher\Controller
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
$table->quickSearch = 'ban_content';
|
||||
$table->advancedSearch = array(
|
||||
'ban_reason' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'ban_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE
|
||||
'ban_reason' => SEARCH_CONTAINS_TEXT,
|
||||
'ban_date' => SEARCH_DATE_RANGE
|
||||
);
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'ban_date' => function( $val, $row )
|
||||
'ban_date' => function( $val )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
return DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'ban_type' => function( $val, $row )
|
||||
'ban_type' => function( $val )
|
||||
{
|
||||
switch( $val )
|
||||
{
|
||||
default:
|
||||
case 'ip':
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('ban_filter_ip_select');
|
||||
break;
|
||||
return Member::loggedIn()->language()->addToStack('ban_filter_ip_select');
|
||||
|
||||
case 'email':
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('ban_filter_email_select');
|
||||
break;
|
||||
return Member::loggedIn()->language()->addToStack('ban_filter_email_select');
|
||||
|
||||
case 'name':
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('ban_filter_name_select');
|
||||
break;
|
||||
return Member::loggedIn()->language()->addToStack('ban_filter_name_select');
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -97,8 +118,8 @@ class _ban extends \IPS\Dispatcher\Controller
|
||||
$return['edit'] = array(
|
||||
'icon' => 'pencil',
|
||||
'title' => 'edit',
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit') ),
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban&do=form&id=' ) . $row['ban_id'],
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('edit') ),
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=ban&do=form&id=' ) . $row['ban_id'],
|
||||
);
|
||||
|
||||
|
||||
@@ -106,7 +127,7 @@ class _ban extends \IPS\Dispatcher\Controller
|
||||
$return['delete'] = array(
|
||||
'icon' => 'times-circle',
|
||||
'title' => 'delete',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban&do=delete&id=' ) . $row['ban_id'],
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=ban&do=delete&id=' ) . $row['ban_id'],
|
||||
'data' => array( 'delete' => '' ),
|
||||
);
|
||||
|
||||
@@ -114,41 +135,41 @@ class _ban extends \IPS\Dispatcher\Controller
|
||||
};
|
||||
|
||||
/* Specify the buttons */
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'add' => array(
|
||||
'primary' => TRUE,
|
||||
'icon' => 'plus',
|
||||
'title' => 'ban_filter_add',
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('ban_filter_add') ),
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban&do=form' )
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('ban_filter_add') ),
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=ban&do=form' )
|
||||
)
|
||||
);
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_membersettings_ban');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_membersettings_ban');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Edit Rank
|
||||
*/
|
||||
public function form()
|
||||
public function form() : void
|
||||
{
|
||||
$current = NULL;
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', \IPS\Request::i()->id ) )->first();
|
||||
$current = Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', Request::i()->id ) )->first();
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'ban_type', $current ? $current['ban_type'] : NULL , TRUE, array( 'options' => array(
|
||||
$form = new Form();
|
||||
$form->add( new Select( 'ban_type', $current ? $current['ban_type'] : NULL , TRUE, array( 'options' => array(
|
||||
'ip' => 'ban_filter_ip_select',
|
||||
'email' => 'ban_filter_email_select',
|
||||
'name' => 'ban_filter_name_select'
|
||||
) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ban_content', $current ? $current['ban_content'] : "", TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ban_reason', $current ? $current['ban_reason'] : "" ) );
|
||||
$form->add( new Text( 'ban_content', $current ? $current['ban_content'] : "", TRUE ) );
|
||||
$form->add( new Text( 'ban_reason', $current ? $current['ban_reason'] : "" ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -163,22 +184,22 @@ class _ban extends \IPS\Dispatcher\Controller
|
||||
if ( $current )
|
||||
{
|
||||
unset( $save['ban_date'] );
|
||||
\IPS\Db::i()->update( 'core_banfilters', $save, array( 'ban_id=?', $current['ban_id'] ) );
|
||||
\IPS\Session::i()->log( 'acplog__ban_edited', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
|
||||
Db::i()->update( 'core_banfilters', $save, array( 'ban_id=?', $current['ban_id'] ) );
|
||||
Session::i()->log( 'acplog__ban_edited', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_banfilters', $save );
|
||||
\IPS\Session::i()->log( 'acplog__ban_created', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
|
||||
Db::i()->insert( 'core_banfilters', $save );
|
||||
Session::i()->log( 'acplog__ban_created', array( 'ban_filter_' . $save['ban_type'] . '_select' => TRUE, $save['ban_content'] => FALSE ) );
|
||||
}
|
||||
|
||||
unset( \IPS\Data\Store::i()->bannedIpAddresses );
|
||||
unset( Store::i()->bannedIpAddresses );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=ban' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( $current ? $current['ban_content'] : 'add', $form, FALSE );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( $current ? $current['ban_content'] : 'add', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,20 +207,20 @@ class _ban extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', \IPS\Request::i()->id ) )->first();
|
||||
\IPS\Session::i()->log( 'acplog__ban_deleted', array( 'ban_filter_' . $current['ban_type'] . '_select' => TRUE, $current['ban_content'] => FALSE ) );
|
||||
\IPS\Db::i()->delete( 'core_banfilters', array( 'ban_id=?', \IPS\Request::i()->id ) );
|
||||
unset( \IPS\Data\Store::i()->bannedIpAddresses );
|
||||
$current = Db::i()->select( '*', 'core_banfilters', array( 'ban_id=?', Request::i()->id ) )->first();
|
||||
Session::i()->log( 'acplog__ban_deleted', array( 'ban_filter_' . $current['ban_type'] . '_select' => TRUE, $current['ban_content'] => FALSE ) );
|
||||
Db::i()->delete( 'core_banfilters', array( 'ban_id=?', Request::i()->id ) );
|
||||
unset( Store::i()->bannedIpAddresses );
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException $e ) { }
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ban' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=ban' ) );
|
||||
}
|
||||
}
|
||||
@@ -11,30 +11,56 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use DomainException;
|
||||
use IPS\Application;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Helpers\Table\Custom;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Notification;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use const IPS\CIC;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Settings
|
||||
*/
|
||||
class _notifications extends \IPS\Dispatcher\Controller
|
||||
class notifications extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'notifications_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'notifications_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -43,58 +69,58 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$types = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'Notifications' ) as $k => $extension )
|
||||
foreach ( Application::allExtensions( 'core', 'Notifications' ) as $k => $extension )
|
||||
{
|
||||
$types[ $k ] = array(
|
||||
'title' => \IPS\Member::loggedIn()->language()->get('notifications__' . $k)
|
||||
'title' => Member::loggedIn()->language()->get('notifications__' . $k)
|
||||
);
|
||||
}
|
||||
|
||||
$typeTable = new \IPS\Helpers\Table\Custom( $types, \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications', 'admin' ) );
|
||||
$typeTable = new Custom( $types, Url::internal( 'app=core&module=membersettings&controller=notifications', 'admin' ) );
|
||||
$typeTable->langPrefix = 'notificationsettings_';
|
||||
$typeTable->rowButtons = function( $row, $k ) {
|
||||
return array(
|
||||
'edit' => array(
|
||||
'title' => 'edit',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications&do=edit', 'admin' )->setQueryString( 'id', $k ),
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=notifications&do=edit', 'admin' )->setQueryString( 'id', $k ),
|
||||
'icon' => 'pencil'
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if( !\IPS\CIC )
|
||||
if( !CIC )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'prunesettings',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications&do=pruneSettings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('prunesettings') )
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=notifications&do=pruneSettings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('prunesettings') )
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profiles_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profiles_manage' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['reset'] = array(
|
||||
Output::i()->sidebar['actions']['reset'] = array(
|
||||
'icon' => 'undo',
|
||||
'title' => 'notification_prefs_reset',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications&do=updateMemberFollowPrefs' )->csrf(),
|
||||
'data' => array( 'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->addToStack('notification_prefs_reset_confirm') )
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=notifications&do=updateMemberFollowPrefs' )->csrf(),
|
||||
'data' => array( 'confirm' => '', 'confirmSubMessage' => Member::loggedIn()->language()->addToStack('notification_prefs_reset_confirm') )
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('notifications');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('notifications');
|
||||
|
||||
if ( ! \IPS\Notification::canUseWebPush() )
|
||||
if ( ! Notification::canUseWebPush() )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->message( 'acp_notifications_cannot_use_web_push', 'general' );
|
||||
Output::i()->output = Theme::i()->getTemplate('global')->message( 'acp_notifications_cannot_use_web_push', 'general' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output .= $typeTable;
|
||||
Output::i()->output .= $typeTable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,52 +128,52 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function pruneSettings()
|
||||
protected function pruneSettings() : void
|
||||
{
|
||||
if( \IPS\CIC )
|
||||
if( CIC )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C413/1', 403, '' );
|
||||
Output::i()->error( 'node_error', '2C413/1', 403, '' );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_follows', \IPS\Settings::i()->prune_follows, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
$form = new Form;
|
||||
$form->add( new Interval( 'prune_follows', Settings::i()->prune_follows, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
if( $val > 0 AND $val < 30 )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 29 ) ) ) );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 29 ) ) ) );
|
||||
}
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_follows' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_notifications', \IPS\Settings::i()->prune_notifications, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
}, Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_follows' ) );
|
||||
$form->add( new Interval( 'prune_notifications', Settings::i()->prune_notifications, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
if( $val > 0 AND $val < 7 )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
|
||||
}
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('after') ) );
|
||||
}, Member::loggedIn()->language()->addToStack('after') ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* If we're enabling pruning on a potentially large table, handle that */
|
||||
if( !\IPS\Settings::i()->prune_follows AND $values['prune_follows'] )
|
||||
if( !Settings::i()->prune_follows AND $values['prune_follows'] )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'PruneLargeTable', array(
|
||||
Task::queue( 'core', 'PruneLargeTable', array(
|
||||
'table' => 'core_follow',
|
||||
'where' => array( 'follow_app!=? AND follow_area!=? AND follow_member_id IN(?)', 'core', 'member', \IPS\Db::i()->select( 'member_id', 'core_members', array( 'last_activity < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_follows'] . 'D' ) )->getTimestamp() ) ) ),
|
||||
'where' => array( 'follow_app!=? AND follow_area!=? AND follow_member_id IN(?)', 'core', 'member', Db::i()->select( 'member_id', 'core_members', array( 'last_activity < ?', DateTime::create()->sub( new DateInterval( 'P' . $values['prune_follows'] . 'D' ) )->getTimestamp() ) ) ),
|
||||
'setting' => 'prune_follows',
|
||||
'deleteJoin' => array(
|
||||
'column' => 'member_id',
|
||||
'table' => 'core_members',
|
||||
'where' => array( 'last_activity < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_follows'] . 'D' ) )->getTimestamp() ),
|
||||
'where' => array( 'last_activity < ?', DateTime::create()->sub( new DateInterval( 'P' . $values['prune_follows'] . 'D' ) )->getTimestamp() ),
|
||||
'outerColumn' => 'follow_member_id'
|
||||
)
|
||||
), 4 );
|
||||
}
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Session::i()->log( 'acplog__follow_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications' ), 'saved' );
|
||||
Session::i()->log( 'acplog__follow_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=notifications' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('notification_pruning');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'notification_pruning', $form, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('notification_pruning');
|
||||
Output::i()->output = Theme::i()->getTemplate('global')->block( 'notification_pruning', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,20 +181,20 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function edit()
|
||||
protected function edit() : void
|
||||
{
|
||||
$extensions = \IPS\Application::allExtensions( 'core', 'Notifications' );
|
||||
if ( !isset( $extensions[ \IPS\Request::i()->id ] ) )
|
||||
$extensions = Application::allExtensions( 'core', 'Notifications' );
|
||||
if ( !isset( $extensions[ Request::i()->id ] ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C404/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C404/2', 404, '' );
|
||||
}
|
||||
$extension = $extensions[ \IPS\Request::i()->id ];
|
||||
$extension = $extensions[ Request::i()->id ];
|
||||
|
||||
$defaultConfiguration = \IPS\Notification::defaultConfiguration();
|
||||
$defaultConfiguration = Notification::defaultConfiguration();
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
|
||||
foreach ( \IPS\Notification::availableOptions( NULL, $extension ) as $key => $option )
|
||||
foreach ( Notification::availableOptions( NULL, $extension ) as $key => $option )
|
||||
{
|
||||
if ( $option['type'] === 'standard' )
|
||||
{
|
||||
@@ -182,13 +208,13 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
$form->addMessage( $option['description'] );
|
||||
}
|
||||
|
||||
if ( !\in_array( 'inline', $option['disabled'] ) or ( \IPS\Notification::webPushEnabled() and !\in_array( 'push', $option['disabled'] ) ) or !\in_array( 'email', $option['disabled'] ) )
|
||||
if ( !in_array( 'inline', $option['disabled'] ) or ( Notification::webPushEnabled() and !in_array( 'push', $option['disabled'] ) ) or !in_array( 'email', $option['disabled'] ) )
|
||||
{
|
||||
$canEditField = new \IPS\Helpers\Form\YesNo( 'notificationsettings_editable_' . $key, $defaultConfiguration[ $key ]['editable'], FALSE, array(
|
||||
$canEditField = new YesNo( 'notificationsettings_editable_' . $key, $defaultConfiguration[ $key ]['editable'], FALSE, array(
|
||||
'togglesOn' => array( "member_notifications_{$key}_inline_editable", "member_notifications_{$key}_push", "member_notifications_{$key}_email_editable" ),
|
||||
'togglesOff' => array( "member_notifications_{$key}_inline", "member_notifications_{$key}_email" )
|
||||
) );
|
||||
$canEditField->label = \IPS\Member::loggedIn()->language()->addToStack('notificationsettings_editable');
|
||||
$canEditField->label = Member::loggedIn()->language()->addToStack('notificationsettings_editable');
|
||||
$form->add( $canEditField );
|
||||
}
|
||||
|
||||
@@ -198,17 +224,17 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( isset( $extra['adminCanSetDefault'] ) and $extra['adminCanSetDefault'] )
|
||||
{
|
||||
$field = new \IPS\Helpers\Form\Radio( 'member_notifications_' . $key . '_' . $k, $extra['default'] ? 'default' : 'optional', FALSE, array( 'options' => array(
|
||||
$field = new Radio( 'member_notifications_' . $key . '_' . $k, $extra['default'] ? 'default' : 'optional', FALSE, array( 'options' => array(
|
||||
'default' => isset( $extra['admin_lang'] ) ? $extra['admin_lang']['default'] : 'admin_notification_pref_default',
|
||||
'optional' => isset( $extra['admin_lang'] ) ? $extra['admin_lang']['optional'] : 'admin_notification_pref_optional',
|
||||
) ), NULL, NULL, NULL, 'member_notifications_' . $k );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( isset( $extra['admin_lang'] ) ? $extra['admin_lang']['title'] : $extra['title'] );
|
||||
$field->label = Member::loggedIn()->language()->addToStack( isset( $extra['admin_lang'] ) ? $extra['admin_lang']['title'] : $extra['title'] );
|
||||
$form->add( $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\Notification::canUseWebPush() )
|
||||
if ( Notification::canUseWebPush() )
|
||||
{
|
||||
$types = array( 'inline', 'push', 'email' );
|
||||
}
|
||||
@@ -218,16 +244,16 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
foreach ( $types as $k )
|
||||
{
|
||||
if ( !\in_array( $k, $option['disabled'] ) )
|
||||
if ( !in_array( $k, $option['disabled'] ) )
|
||||
{
|
||||
$editableFieldValue = \in_array( $k, $defaultConfiguration[ $key ]['default'] ) ? 'default' : 'optional';
|
||||
if ( \in_array( $k, $defaultConfiguration[ $key ]['disabled'] ) )
|
||||
$editableFieldValue = in_array( $k, $defaultConfiguration[ $key ]['default'] ) ? 'default' : 'optional';
|
||||
if ( in_array( $k, $defaultConfiguration[ $key ]['disabled'] ) )
|
||||
{
|
||||
$editableFieldValue = 'disabled';
|
||||
}
|
||||
if ( $k !== 'push' )
|
||||
{
|
||||
$editableField = new \IPS\Helpers\Form\Radio( 'member_notifications_' . $key . '_' . $k . '_editable', $editableFieldValue, FALSE, array(
|
||||
$editableField = new Radio( 'member_notifications_' . $key . '_' . $k . '_editable', $editableFieldValue, FALSE, array(
|
||||
'options' => array(
|
||||
'default' => 'admin_notification_pref_default',
|
||||
'optional' => 'admin_notification_pref_optional',
|
||||
@@ -238,15 +264,15 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
'optional' => array( 'member_notifications_' . $key . '_push' ),
|
||||
) : array()
|
||||
), NULL, NULL, NULL, 'member_notifications_' . $key . '_' . $k . '_editable' );
|
||||
$editableField->label = \IPS\Member::loggedIn()->language()->addToStack( 'member_notifications_' . $k );
|
||||
$editableField->label = Member::loggedIn()->language()->addToStack( 'member_notifications_' . $k );
|
||||
$form->add( $editableField );
|
||||
}
|
||||
|
||||
$nonEditableField = new \IPS\Helpers\Form\Radio( 'member_notifications_' . $key . '_' . $k, \in_array( $k, $defaultConfiguration[ $key ]['disabled'] ) ? 'disabled' : 'default', FALSE, array( 'options' => array(
|
||||
$nonEditableField = new Radio( 'member_notifications_' . $key . '_' . $k, in_array( $k, $defaultConfiguration[ $key ]['disabled'] ) ? 'disabled' : 'default', FALSE, array( 'options' => array(
|
||||
'default' => $k === 'push' ? 'admin_notification_pref_available' : 'admin_notification_pref_force',
|
||||
'disabled' => 'admin_notification_pref_disabled'
|
||||
) ), NULL, NULL, NULL, 'member_notifications_' . $key . '_' . $k );
|
||||
$nonEditableField->label = \IPS\Member::loggedIn()->language()->addToStack( 'member_notifications_' . $k );
|
||||
$nonEditableField->label = Member::loggedIn()->language()->addToStack( 'member_notifications_' . $k );
|
||||
$form->add( $nonEditableField );
|
||||
}
|
||||
}
|
||||
@@ -266,7 +292,7 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
foreach ( \IPS\Notification::availableOptions( NULL, $extension ) as $key => $option )
|
||||
foreach ( Notification::availableOptions( NULL, $extension ) as $key => $option )
|
||||
{
|
||||
if ( $option['type'] === 'standard' )
|
||||
{
|
||||
@@ -281,7 +307,7 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ( !\in_array( 'inline', $option['disabled'] ) or ( \IPS\Notification::webPushEnabled()and !\in_array( 'push', $option['disabled'] ) ) or !\in_array( 'email', $option['disabled'] ) )
|
||||
if ( !in_array( 'inline', $option['disabled'] ) or ( Notification::webPushEnabled()and !in_array( 'push', $option['disabled'] ) ) or !in_array( 'email', $option['disabled'] ) )
|
||||
{
|
||||
$row = array(
|
||||
'notification_key' => $key,
|
||||
@@ -292,11 +318,11 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach ( array( 'inline', 'push', 'email' ) as $k )
|
||||
{
|
||||
if ( !\in_array( $k, $option['disabled'] ) )
|
||||
if ( !in_array( $k, $option['disabled'] ) )
|
||||
{
|
||||
if ( $k === 'push' )
|
||||
{
|
||||
if ( !\IPS\Notification::webPushEnabled() )
|
||||
if ( !Notification::webPushEnabled() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -321,7 +347,7 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
$row['default'] = implode( ',', $row['default'] );
|
||||
$row['disabled'] = implode( ',', $row['disabled'] );
|
||||
|
||||
\IPS\Db::i()->replace( 'core_notification_defaults', $row, array( 'notification_key=?', $key ) );
|
||||
Db::i()->replace( 'core_notification_defaults', $row );
|
||||
|
||||
$extensionConfiguration = $extension->configurationOptions();
|
||||
if ( isset( $extensionConfiguration[ $key ] ) and $extensionConfiguration[ $key ]['type'] === 'standard' )
|
||||
@@ -329,7 +355,7 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
foreach ( $extensionConfiguration[ $key ]['notificationTypes'] as $notificationType )
|
||||
{
|
||||
$row['notification_key'] = $notificationType;
|
||||
\IPS\Db::i()->replace( 'core_notification_defaults', $row, array( 'notification_key=?', $notificationType ) );
|
||||
Db::i()->replace( 'core_notification_defaults', $row );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,13 +369,13 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__notifications_edited' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications' ), 'saved' );
|
||||
Session::i()->log( 'acplog__notifications_edited' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=notifications' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications' ), \IPS\Member::loggedIn()->language()->addToStack( 'menu__core_membersettings_notifications' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'notifications__' . \IPS\Request::i()->id );
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->breadcrumb[] = array( Url::internal( 'app=core&module=membersettings&controller=notifications' ), Member::loggedIn()->language()->addToStack( 'menu__core_membersettings_notifications' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'notifications__' . Request::i()->id );
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,25 +383,22 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function updateMemberFollowPrefs()
|
||||
protected function updateMemberFollowPrefs() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Do standard preferences */
|
||||
\IPS\Db::i()->delete( 'core_notification_preferences' );
|
||||
Db::i()->delete( 'core_notification_preferences' );
|
||||
|
||||
/* Do "extra" preferences */
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'Notifications' ) as $k => $extension )
|
||||
foreach ( Application::allExtensions( 'core', 'Notifications' ) as $k => $extension )
|
||||
{
|
||||
if ( method_exists( $extension, 'resetExtra' ) )
|
||||
{
|
||||
$extension->resetExtra();
|
||||
}
|
||||
$extension->resetExtra();
|
||||
}
|
||||
|
||||
/* Log and redirect */
|
||||
\IPS\Session::i()->log( 'acplog__notification_settings_existing' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications' ), 'reset' );
|
||||
Session::i()->log( 'acplog__notification_settings_existing' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=notifications' ), 'reset' );
|
||||
}
|
||||
}
|
||||
@@ -11,47 +11,62 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\ProfileStep;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile Completion
|
||||
*/
|
||||
class _profilecompletion extends \IPS\Node\Controller
|
||||
class profilecompletion extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = '\IPS\Member\ProfileStep';
|
||||
protected string $nodeClass = '\IPS\Member\ProfileStep';
|
||||
|
||||
/**
|
||||
* Show the "add" button in the page root rather than the table root
|
||||
*/
|
||||
protected $_addButtonInRoot = FALSE;
|
||||
protected bool $_addButtonInRoot = FALSE;
|
||||
|
||||
/**
|
||||
* Get Root Buttons
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _getRootButtons()
|
||||
public function _getRootButtons(): array
|
||||
{
|
||||
$return = parent::_getRootButtons();
|
||||
|
||||
if ( isset( \IPS\Output::i()->sidebar['actions']['add'] ) )
|
||||
if ( isset( Output::i()->sidebar['actions']['add'] ) )
|
||||
{
|
||||
$class = new \IPS\Member\ProfileStep;
|
||||
$class = new ProfileStep;
|
||||
if ( ! $class->canAdd() )
|
||||
{
|
||||
unset( \IPS\Output::i()->sidebar['actions']['add'] );
|
||||
unset( Output::i()->sidebar['actions']['add'] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +78,9 @@ class _profilecompletion extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'profilefields_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'profilefields_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -74,10 +89,10 @@ class _profilecompletion extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$class = new \IPS\Member\ProfileStep;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'members' )->profileCompleteBlurb( $class->canAdd() );
|
||||
$class = new ProfileStep;
|
||||
Output::i()->output = Theme::i()->getTemplate( 'members' )->profileCompleteBlurb( $class->canAdd() );
|
||||
parent::manage();
|
||||
}
|
||||
|
||||
@@ -86,15 +101,15 @@ class _profilecompletion extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enableQuickRegister()
|
||||
public function enableQuickRegister() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'quick_register' => 1 ) );
|
||||
Settings::i()->changeValues( array( 'quick_register' => 1 ) );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__quick_register_enabled' );
|
||||
Session::i()->log( 'acplog__quick_register_enabled' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=profilecompletion' ), 'profile_complete_quick_register_off_enabled' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=profiles&tab=profilecompletion' ), 'profile_complete_quick_register_off_enabled' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,23 +117,23 @@ class _profilecompletion extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function form()
|
||||
public function form() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
if ( isset( \IPS\Request::i()->id ) )
|
||||
$form = new Form;
|
||||
if ( isset( Request::i()->id ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$step = \IPS\Member\ProfileStep::load( \IPS\Request::i()->id );
|
||||
$step = ProfileStep::load( Request::i()->id );
|
||||
}
|
||||
catch( \OutOFRangeException $e )
|
||||
catch( OutOFRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C360/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C360/1', 404, '' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$step = new \IPS\Member\ProfileStep;
|
||||
$step = new ProfileStep;
|
||||
}
|
||||
|
||||
$step->form( $form );
|
||||
@@ -127,27 +142,25 @@ class _profilecompletion extends \IPS\Node\Controller
|
||||
{
|
||||
$values = $step->formatFormValues( $values );
|
||||
|
||||
$step->extension = \IPS\Member\ProfileStep::findExtensionFromAction( $values['step_completion_act'] );
|
||||
$step->required = ( isset( $values['step_required'] ) ) ? $values['step_required'] : FALSE;
|
||||
$extension = ProfileStep::loadExtensionFromAction( $values['step_completion_act'] );
|
||||
$step->required = ( isset( $values['step_required'] ) ) ? $values['step_required'] : FALSE;
|
||||
$step->registration = $values['step_registration'];
|
||||
$step->completion_act = $values['step_completion_act'];
|
||||
$step->subcompletion_act = isset( $values['step_subcompletion_act'] ) ? $values['step_subcompletion_act'] : NULL;
|
||||
$step->subcompletion_act = $values['step_subcompletion_act'] ?? NULL;
|
||||
$step->save();
|
||||
|
||||
$step->postSaveForm( $values );
|
||||
|
||||
if ( method_exists( $step->extension, 'postAcpSave' ) )
|
||||
{
|
||||
$step->extension->postAcpSave( $step, $values );
|
||||
}
|
||||
$extension->postAcpSave( $step, $values );
|
||||
|
||||
\IPS\Member::updateAllMembers( array( "members_bitoptions2 = members_bitoptions2 & ~" . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['profile_completed'] ) );
|
||||
Member::updateAllMembers( array( "members_bitoptions2 = members_bitoptions2 & ~" . Member::$bitOptions['members_bitoptions']['members_bitoptions2']['profile_completed'] ) );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__profile_step_added', array( "profile_step_title_{$step->id}" => TRUE ) );
|
||||
Session::i()->log( 'acplog__profile_step_added', array( "profile_step_title_{$step->id}" => TRUE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=membersettings&controller=profiles&tab=profilecompletion" ), 'saved' );
|
||||
Output::i()->redirect( 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;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'profile_completion' );
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Profile Fields and Settings
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
@@ -11,40 +12,47 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\ProfileFields\Field;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Member;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile Fields and Settings
|
||||
*/
|
||||
class _profilefields extends \IPS\Node\Controller
|
||||
class profilefields extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = '\IPS\core\ProfileFields\Group';
|
||||
protected string $nodeClass = '\IPS\core\ProfileFields\Group';
|
||||
|
||||
/**
|
||||
* Show the "add" button in the page root rather than the table root
|
||||
*/
|
||||
protected $_addButtonInRoot = FALSE;
|
||||
protected bool $_addButtonInRoot = FALSE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'profilefields_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'profilefields_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -53,8 +61,9 @@ class _profilefields extends \IPS\Node\Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _getRootButtons()
|
||||
public function _getRootButtons(): array
|
||||
{
|
||||
/* @var Field $nodeClass */
|
||||
$nodeClass = $this->nodeClass;
|
||||
|
||||
if ( $nodeClass::canAddRoot() )
|
||||
@@ -63,7 +72,7 @@ class _profilefields extends \IPS\Node\Controller
|
||||
'icon' => 'plus',
|
||||
'title' => 'add',
|
||||
'link' => $this->url->setQueryString( 'do', 'form' ),
|
||||
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') ) : array() )
|
||||
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('add') ) : array() )
|
||||
);
|
||||
|
||||
return array( 'add' => $add );
|
||||
|
||||
@@ -11,21 +11,30 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile settings gateway
|
||||
*/
|
||||
class _profiles extends \IPS\Dispatcher\Controller
|
||||
class profiles extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Call
|
||||
@@ -35,19 +44,19 @@ class _profiles extends \IPS\Dispatcher\Controller
|
||||
public function __call( $method, $args )
|
||||
{
|
||||
/* Init */
|
||||
$activeTab = \IPS\Request::i()->tab ?: 'profilefields';
|
||||
$activeTab = Request::i()->tab ?: 'profilefields';
|
||||
$activeTabContents = '';
|
||||
$tabs = array();
|
||||
|
||||
/* Add a tab for fields and completion */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profilefields_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profilefields_manage' ) )
|
||||
{
|
||||
$tabs['profilefields'] = 'profile_fields';
|
||||
$tabs['profilecompletion'] = 'profile_completion';
|
||||
}
|
||||
|
||||
/* Add a tab for settings */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profiles_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profiles_manage' ) )
|
||||
{
|
||||
$tabs['profilesettings'] = 'profile_settings';
|
||||
}
|
||||
@@ -55,19 +64,19 @@ class _profiles extends \IPS\Dispatcher\Controller
|
||||
/* 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->url = Url::internal("app=core&module=membersettings&controller=profiles&tab={$activeTab}");
|
||||
$class->execute();
|
||||
|
||||
$output = \IPS\Output::i()->output;
|
||||
$output = Output::i()->output;
|
||||
|
||||
if ( $method !== 'manage' or \IPS\Request::i()->isAjax() )
|
||||
if ( $method !== 'manage' or Request::i()->isAjax() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
\IPS\Output::i()->output = '';
|
||||
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" ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('module__core_profile');
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $output, Url::internal( "app=core&module=membersettings&controller=profiles" ) );
|
||||
}
|
||||
}
|
||||
@@ -10,35 +10,57 @@
|
||||
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
use IPS\Application;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use DomainException;
|
||||
use IPS\Application;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Custom;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
use const IPS\CIC;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile Settings
|
||||
*/
|
||||
class _profilesettings extends \IPS\Dispatcher\Controller
|
||||
class profilesettings extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_members.js', 'core' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_members.js', 'core' ) );
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
@@ -48,43 +70,43 @@ class _profilesettings extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
|
||||
$form->addHeader( 'photos' );
|
||||
$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->add( new Radio( 'letter_photos', 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(
|
||||
$form->add( new Custom( 'user_name_length', array( Settings::i()->min_user_name_length, Settings::i()->max_user_name_length ), FALSE, array(
|
||||
'getHtml' => function( $field ) {
|
||||
return \IPS\Theme::i()->getTemplate('members')->usernameLengthSetting( $field->name, $field->value );
|
||||
return Theme::i()->getTemplate('members')->usernameLengthSetting( $field->name, $field->value );
|
||||
}
|
||||
),
|
||||
function( $val )
|
||||
{
|
||||
if ( $val[0] < 1 )
|
||||
{
|
||||
throw new \DomainException('user_name_length_too_low');
|
||||
throw new DomainException('user_name_length_too_low');
|
||||
}
|
||||
if ( $val[1] > 255 )
|
||||
{
|
||||
throw new \DomainException('user_name_length_too_high');
|
||||
throw new DomainException('user_name_length_too_high');
|
||||
}
|
||||
if ( $val[0] > $val[1] )
|
||||
{
|
||||
throw new \DomainException('user_name_length_no_match');
|
||||
throw new DomainException('user_name_length_no_match');
|
||||
}
|
||||
} ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'username_characters', \IPS\Settings::i()->username_characters, FALSE, array(
|
||||
$form->add( new Custom( 'username_characters', Settings::i()->username_characters, FALSE, array(
|
||||
'getHtml' => function( $field ) {
|
||||
$easy = NULL;
|
||||
if ( \is_array( $field->value ) )
|
||||
if ( is_array( $field->value ) )
|
||||
{
|
||||
$easy['letters'] = $field->value['letters'];
|
||||
$easy['numbers'] = $field->value['numbers'];
|
||||
$easy['spaces'] = (bool) isset( $field->value['spaces'] );
|
||||
$easy['spaces'] = isset( $field->value['spaces'] );
|
||||
$easy['extra'] = isset( $field->value['extra_enabled'] ) ? $field->value['extra'] : '';
|
||||
$field->value = $field->value['regex'];
|
||||
}
|
||||
@@ -100,81 +122,68 @@ class _profilesettings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$easy['numbers'] = 'none';
|
||||
}
|
||||
$easy['spaces'] = (bool) isset( $matches[4] );
|
||||
$easy['spaces'] = isset( $matches[4] );
|
||||
$easy['extra'] = stripslashes( $matches[3] );
|
||||
}
|
||||
}
|
||||
return \IPS\Theme::i()->getTemplate('members')->usernameRegexSetting( $field->name, $field->value, $easy );
|
||||
return Theme::i()->getTemplate('members')->usernameRegexSetting( $field->name, $field->value, $easy );
|
||||
}
|
||||
) ) );
|
||||
$form->addHeader( 'signatures' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'signatures_enabled', \IPS\Settings::i()->signatures_enabled, FALSE, array( 'togglesOn' => array( 'signatures_mobile', 'signatures_guests' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'signatures_mobile', \IPS\Settings::i()->signatures_mobile, FALSE, array(), NULL, NULL, NULL, 'signatures_mobile' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'signatures_guests', \IPS\Settings::i()->signatures_guests, FALSE, array(), NULL, NULL, NULL, 'signatures_guests' ) );
|
||||
|
||||
/* 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->add( new YesNo( 'signatures_enabled', Settings::i()->signatures_enabled, FALSE, array( 'togglesOn' => array( 'signatures_mobile', 'signatures_guests' ) ) ) );
|
||||
$form->add( new YesNo( 'signatures_mobile', Settings::i()->signatures_mobile, FALSE, array(), NULL, NULL, NULL, 'signatures_mobile' ) );
|
||||
$form->add( new YesNo( 'signatures_guests', Settings::i()->signatures_guests, FALSE, array(), NULL, NULL, NULL, 'signatures_guests' ) );
|
||||
|
||||
$form->addHeader( 'profile_settings_birthdays' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'profile_birthday_type', \IPS\Settings::i()->profile_birthday_type, TRUE, array(
|
||||
$form->add( new Radio( 'profile_birthday_type', 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\CIC AND \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'member_history_prune' ) )
|
||||
if( !CIC AND Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'member_history_prune' ) )
|
||||
{
|
||||
$form->addHeader( 'profile_member_history' );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_member_history', \IPS\Settings::i()->prune_member_history, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_member_history' ) );
|
||||
$form->add( new Interval( 'prune_member_history', Settings::i()->prune_member_history, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_member_history' ) );
|
||||
|
||||
if ( Application::appIsEnabled('nexus') )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'nexus_prune_history', \IPS\Settings::i()->nexus_prune_history, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'nexus_prune_history' ) );
|
||||
$form->add( new Interval( 'nexus_prune_history', Settings::i()->nexus_prune_history, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL, 'nexus_prune_history' ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_known_ips', \IPS\Settings::i()->prune_known_ips, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
$form->add( new Interval( 'prune_known_ips', Settings::i()->prune_known_ips, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
if( $val > 0 AND $val < 7 )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
|
||||
}
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_known_ips' ) );
|
||||
}, Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_known_ips' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_known_devices', \IPS\Settings::i()->prune_known_devices, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
$form->add( new Interval( 'prune_known_devices', Settings::i()->prune_known_devices, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
if( $val > 0 AND $val < 30 )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 29 ) ) ) );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 29 ) ) ) );
|
||||
}
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_known_devices' ) );
|
||||
}, Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_known_devices' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_item_markers', \IPS\Settings::i()->prune_item_markers, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
$form->add( new Interval( 'prune_item_markers', Settings::i()->prune_item_markers, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), function( $val ) {
|
||||
if( $val > 0 AND $val < 7 )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
|
||||
}
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_item_markers' ) );
|
||||
}, Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_item_markers' ) );
|
||||
}
|
||||
|
||||
$form->addHeader( 'profile_settings_pms' );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'prune_pms', \IPS\Settings::i()->prune_pms, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_pms' ) );
|
||||
$form->add( new Interval( 'prune_pms', Settings::i()->prune_pms, FALSE, array( 'valueAs' => Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_pms' ) );
|
||||
|
||||
$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' ) );
|
||||
$form->add( new YesNo( 'ignore_system_on', Settings::i()->ignore_system_on, FALSE, array(), NULL, NULL, NULL, 'ignore_system_on' ) );
|
||||
|
||||
$form->addHeader( 'profile_settings_display' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'group_formatting_type', \IPS\Settings::i()->group_formatting, FALSE, array( 'options' => array(
|
||||
$form->add( new Radio( 'group_formatting_type', Settings::i()->group_formatting, FALSE, array( 'options' => array(
|
||||
'legacy' => 'group_formatting_type_legacy',
|
||||
'global' => 'group_formatting_type_global'
|
||||
) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'link_default', \IPS\Settings::i()->link_default, FALSE, array( 'options' => array(
|
||||
$form->add( new Radio( 'link_default', Settings::i()->link_default, FALSE, array( 'options' => array(
|
||||
'unread' => 'profile_settings_cvb_unread',
|
||||
'last' => 'profile_settings_cvb_last',
|
||||
'first' => 'profile_settings_cvb_first'
|
||||
@@ -226,57 +235,54 @@ class _profilesettings extends \IPS\Dispatcher\Controller
|
||||
$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;
|
||||
|
||||
/* If we're enabling pruning on a potentially large table, handle that */
|
||||
if( !\IPS\Settings::i()->prune_member_history AND $values['prune_member_history'] )
|
||||
if( !Settings::i()->prune_member_history AND $values['prune_member_history'] )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'PruneLargeTable', array(
|
||||
Task::queue( 'core', 'PruneLargeTable', array(
|
||||
'table' => 'core_member_history',
|
||||
'where' => array( 'log_date < ? and log_app != ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_member_history'] . 'D' ) )->getTimestamp(), 'nexus' ),
|
||||
'where' => array( 'log_date < ?', DateTime::create()->sub( new DateInterval( 'P' . $values['prune_member_history'] . 'D' ) )->getTimestamp() ),
|
||||
'setting' => 'prune_member_history',
|
||||
), 4 );
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->prune_known_ips AND $values['prune_known_ips'] )
|
||||
if( !Settings::i()->prune_known_ips AND $values['prune_known_ips'] )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'PruneLargeTable', array(
|
||||
Task::queue( 'core', 'PruneLargeTable', array(
|
||||
'table' => 'core_members_known_ip_addresses',
|
||||
'where' => array( 'last_seen < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_known_ips'] . 'D' ) )->getTimestamp() ),
|
||||
'where' => array( 'last_seen < ?', DateTime::create()->sub( new DateInterval( 'P' . $values['prune_known_ips'] . 'D' ) )->getTimestamp() ),
|
||||
'setting' => 'prune_known_ips',
|
||||
), 4 );
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->prune_known_devices AND $values['prune_known_devices'] )
|
||||
if( !Settings::i()->prune_known_devices AND $values['prune_known_devices'] )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'PruneLargeTable', array(
|
||||
Task::queue( 'core', 'PruneLargeTable', array(
|
||||
'table' => 'core_members_known_devices',
|
||||
'where' => array( 'last_seen < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_known_devices'] . 'D' ) )->getTimestamp() ),
|
||||
'where' => array( 'last_seen < ?', DateTime::create()->sub( new DateInterval( 'P' . $values['prune_known_devices'] . 'D' ) )->getTimestamp() ),
|
||||
'setting' => 'prune_known_devices',
|
||||
), 4 );
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->prune_item_markers AND $values['prune_item_markers'] )
|
||||
if( !Settings::i()->prune_item_markers AND $values['prune_item_markers'] )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'PruneLargeTable', array(
|
||||
Task::queue( 'core', 'PruneLargeTable', array(
|
||||
'table' => 'core_item_markers',
|
||||
'where' => array( 'item_member_id IN(?)', \IPS\Db::i()->select( 'member_id', 'core_members', array( 'last_activity < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_item_markers'] . 'D' ) )->getTimestamp() ) ) ),
|
||||
'where' => array( 'item_member_id IN(?)', Db::i()->select( 'member_id', 'core_members', array( 'last_activity < ?', DateTime::create()->sub( new DateInterval( 'P' . $values['prune_item_markers'] . 'D' ) )->getTimestamp() ) ) ),
|
||||
'setting' => 'prune_item_markers',
|
||||
'deleteJoin' => array(
|
||||
'column' => 'member_id',
|
||||
'table' => 'core_members',
|
||||
'where' => array( 'last_activity < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_item_markers'] . 'D' ) )->getTimestamp() ),
|
||||
'where' => array( 'last_activity < ?', DateTime::create()->sub( new DateInterval( 'P' . $values['prune_item_markers'] . 'D' ) )->getTimestamp() ),
|
||||
'outerColumn' => 'item_member_id'
|
||||
)
|
||||
), 4 );
|
||||
}
|
||||
|
||||
$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' );
|
||||
Session::i()->log( 'acplog__profile_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=profiles&tab=profilesettings' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = (string) $form;
|
||||
Output::i()->output = (string) $form;
|
||||
}
|
||||
}
|
||||
@@ -12,45 +12,53 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* referralbanners
|
||||
*/
|
||||
class _referralbanners extends \IPS\Node\Controller
|
||||
class referralbanners extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\core\ReferralBanner';
|
||||
protected string $nodeClass = 'IPS\core\ReferralBanner';
|
||||
|
||||
/**
|
||||
* Show the "add" button in the page root rather than the table root
|
||||
*/
|
||||
protected $_addButtonInRoot = FALSE;
|
||||
protected bool $_addButtonInRoot = FALSE;
|
||||
|
||||
/**
|
||||
* Title can contain HTML?
|
||||
*/
|
||||
public $_titleHtml = TRUE;
|
||||
public bool $_titleHtml = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'referrals_manage', 'core', 'membersettings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'referrals_manage', 'core', 'membersettings' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -59,10 +67,10 @@ class _referralbanners extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'referral_banners_blurb', TRUE, TRUE );
|
||||
return parent::manage();
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'referral_banners_blurb', TRUE, TRUE );
|
||||
parent::manage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,9 +78,9 @@ class _referralbanners extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function form()
|
||||
public function form() : void
|
||||
{
|
||||
parent::form();
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('referral_banners');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('referral_banners');
|
||||
}
|
||||
}
|
||||
@@ -12,40 +12,53 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Translatable;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Lang;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* referralcommission
|
||||
*/
|
||||
class _referralcommission extends \IPS\Node\Controller
|
||||
class referralcommission extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\CommissionRule';
|
||||
protected string $nodeClass = 'IPS\nexus\CommissionRule';
|
||||
|
||||
/**
|
||||
* Show the "add" button in the page root rather than the table root
|
||||
*/
|
||||
protected $_addButtonInRoot = FALSE;
|
||||
protected bool $_addButtonInRoot = FALSE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'commission_rules_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'commission_rules_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -54,12 +67,12 @@ class _referralcommission extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'][] = array(
|
||||
Output::i()->sidebar['actions'][] = array(
|
||||
'icon' => 'cog',
|
||||
'title' => 'commission_settings',
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=customers&controller=referrals&do=settings" )
|
||||
'link' => Url::internal( "app=nexus&module=customers&controller=referrals&do=settings" )
|
||||
);
|
||||
|
||||
parent::manage();
|
||||
@@ -70,28 +83,25 @@ class _referralcommission extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function settings()
|
||||
public function settings() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_com_rules', \IPS\Settings::i()->nexus_com_rules, FALSE, array( 'togglesOff' => array( 'nexus_com_rules_alt' ) ), NULL, NULL, NULL, 'nexus_com_rules' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'nexus_com_rules_alt', NULL, FALSE, array( 'app' => 'nexus', 'key' => 'nexus_com_rules_val', 'editor' => array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'nexus_com_rules_alt', 'attachIds' => array( NULL, NULL, 'nexus_com_rules_alt' ) ) ), NULL, NULL, NULL, 'nexus_com_rules_alt' ) );
|
||||
$form = new Form;
|
||||
$form->add( new YesNo( 'nexus_com_rules', Settings::i()->nexus_com_rules, FALSE, array( 'togglesOff' => array( 'nexus_com_rules_alt' ) ), NULL, NULL, NULL, 'nexus_com_rules' ) );
|
||||
$form->add( new Translatable( 'nexus_com_rules_alt', NULL, FALSE, array( 'app' => 'nexus', 'key' => 'nexus_com_rules_val', 'editor' => array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'nexus_com_rules_alt', 'attachIds' => array( NULL, NULL, 'nexus_com_rules_alt' ) ) ), NULL, NULL, NULL, 'nexus_com_rules_alt' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'nexus', 'nexus_com_rules_val', $values['nexus_com_rules_alt'] );
|
||||
Lang::saveCustom( 'nexus', 'nexus_com_rules_val', $values['nexus_com_rules_alt'] );
|
||||
unset( $values['nexus_com_rules_alt'] );
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__referral_commission_settings_edited' );
|
||||
Session::i()->log( 'acplog__referral_commission_settings_edited' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=customers&controller=referrals'), 'saved' );
|
||||
Output::i()->redirect( Url::internal('app=nexus&module=customers&controller=referrals'), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,47 +12,60 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Table\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Referrals
|
||||
*/
|
||||
class _referrals extends \IPS\Dispatcher\Controller
|
||||
class referrals extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Call
|
||||
*
|
||||
* @param string $method Method name
|
||||
* @param mixed $args Method arguments
|
||||
* @return void
|
||||
*/
|
||||
public function __call( $method, $args )
|
||||
public function __call( string $method, mixed $args )
|
||||
{
|
||||
$tabs = array();
|
||||
if( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'referrals_manage' ) )
|
||||
if( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'referrals_manage' ) )
|
||||
{
|
||||
$tabs['refersettings'] = 'settings';
|
||||
}
|
||||
if( \IPS\Settings::i()->ref_on and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'referrals_manage' ) )
|
||||
if( Settings::i()->ref_on and Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'referrals_manage' ) )
|
||||
{
|
||||
$tabs['referralbanners'] = 'referral_banners';
|
||||
}
|
||||
if( \IPS\Settings::i()->ref_on and \IPS\Application::appIsEnabled( 'nexus' ) )
|
||||
if( Settings::i()->ref_on and Application::appIsEnabled( 'nexus' ) )
|
||||
{
|
||||
$tabs['referralcommission'] = 'referral_commission';
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->tab ) and isset( $tabs[ \IPS\Request::i()->tab ] ) )
|
||||
if ( isset( Request::i()->tab ) and isset( $tabs[ Request::i()->tab ] ) )
|
||||
{
|
||||
$activeTab = \IPS\Request::i()->tab;
|
||||
$activeTab = Request::i()->tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -62,24 +75,24 @@ class _referrals extends \IPS\Dispatcher\Controller
|
||||
|
||||
$classname = 'IPS\core\modules\admin\membersettings\\' . $activeTab;
|
||||
$class = new $classname;
|
||||
$class->url = \IPS\Http\Url::internal("app=core&module=membersettings&controller=referrals&tab={$activeTab}");
|
||||
$class->url = Url::internal("app=core&module=membersettings&controller=referrals&tab={$activeTab}");
|
||||
$class->execute();
|
||||
|
||||
if ( $method !== 'manage' or \IPS\Request::i()->isAjax() )
|
||||
if ( $method !== 'manage' or Request::i()->isAjax() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'history' => array(
|
||||
'title' => 'referral_history',
|
||||
'icon' => 'clock-o',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=referrals&do=history' ),
|
||||
'icon' => 'clock',
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=referrals&do=history' ),
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_membersettings_referrals');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, \IPS\Output::i()->output, \IPS\Http\Url::internal( "app=core&module=membersettings&controller=referrals" ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_membersettings_referrals');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, Output::i()->output, Url::internal( "app=core&module=membersettings&controller=referrals" ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,14 +100,14 @@ class _referrals extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function history()
|
||||
protected function history() : void
|
||||
{
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_referrals', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=referrals&do=history' ) );
|
||||
$table = new Db( 'core_referrals', Url::internal( 'app=core&module=membersettings&controller=referrals&do=history' ) );
|
||||
$table->langPrefix = 'referrals_';
|
||||
|
||||
/* Columns we need */
|
||||
$table->include = array( 'photo', 'member_id', 'referred_by', 'joined' );
|
||||
if( \IPS\Application::appIsEnabled( 'nexus' ) )
|
||||
if( Application::appIsEnabled( 'nexus' ) )
|
||||
{
|
||||
$table->include[] = 'amount';
|
||||
}
|
||||
@@ -110,55 +123,55 @@ class _referrals extends \IPS\Dispatcher\Controller
|
||||
$table->parsers = array(
|
||||
'photo' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->userPhoto( \IPS\Member::constructFromData( $row ), 'tiny' );
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userPhoto( Member::constructFromData( $row ), 'tiny' );
|
||||
|
||||
},
|
||||
'member_id' => function( $val, $row )
|
||||
{
|
||||
if ( $val )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->userLink( \IPS\Member::constructFromData( $row ) );
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'admin' )->userLink( Member::constructFromData( $row ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( \IPS\Member::load( $val ) );
|
||||
return Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( Member::load( $val ) );
|
||||
}
|
||||
},
|
||||
'referred_by' => function( $val, $row )
|
||||
'referred_by' => function( $val )
|
||||
{
|
||||
if ( $val )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->userLink( \IPS\Member::load( $val ) );
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'admin' )->userLink( Member::load( $val ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( \IPS\Member::load( $val ) );
|
||||
return Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( Member::load( $val ) );
|
||||
}
|
||||
},
|
||||
'joined' => function( $val, $row )
|
||||
'joined' => function( $val )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
return DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'amount' => function ( $val, $row )
|
||||
'amount' => function ( $val )
|
||||
{
|
||||
$return = array();
|
||||
if ( $val )
|
||||
{
|
||||
foreach ( json_decode( $val, TRUE ) as $currency => $amount )
|
||||
{
|
||||
$return[] = new \IPS\nexus\Money( $amount, $currency );
|
||||
$return[] = new Money( $amount, $currency );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[] = \IPS\Member::loggedIn()->language()->addToStack('none');
|
||||
$return[] = Member::loggedIn()->language()->addToStack('none');
|
||||
}
|
||||
return implode( '<br>', $return );
|
||||
}
|
||||
);
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('referrals');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('referrals');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
}
|
||||
@@ -12,48 +12,57 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Data\Store;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Output;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Referral Settings
|
||||
*/
|
||||
class _refersettings extends \IPS\Dispatcher\Controller
|
||||
class refersettings extends Controller
|
||||
{
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ref_on', \IPS\Settings::i()->ref_on, FALSE ) );
|
||||
$form = new Form;
|
||||
$form->add( new YesNo( 'ref_on', Settings::i()->ref_on, FALSE, array( 'togglesOn' => array( 'ref_member_input' ) ) ) );
|
||||
$form->add( new YesNo( 'ref_member_input', Settings::i()->ref_member_input, FALSE, array(), NULL, NULL, NULL, 'ref_member_input' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
if ( $values['ref_on'] )
|
||||
{
|
||||
\IPS\Session::i()->log( 'acplog__referrals_enabled' );
|
||||
Session::i()->log( 'acplog__referrals_enabled' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->log( 'acplog__referrals_disabled' );
|
||||
Session::i()->log( 'acplog__referrals_disabled' );
|
||||
}
|
||||
|
||||
/* update the essential cookie name list */
|
||||
unset( \IPS\Data\Store::i()->essentialCookieNames );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=membersettings&controller=referrals') );
|
||||
unset( Store::i()->essentialCookieNames );
|
||||
Output::i()->redirect( Url::internal('app=core&module=membersettings&controller=referrals') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -11,46 +11,81 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Content\Reaction;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Timezone;
|
||||
use IPS\Helpers\Form\Translatable;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Lang;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* reputation
|
||||
*/
|
||||
class _reputation extends \IPS\Node\Controller
|
||||
class reputation extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = '\IPS\Content\Reaction';
|
||||
protected string $nodeClass = '\IPS\Content\Reaction';
|
||||
|
||||
/**
|
||||
* Title can contain HTML?
|
||||
*/
|
||||
public $_titleHtml = TRUE;
|
||||
public bool $_titleHtml = TRUE;
|
||||
|
||||
/**
|
||||
* Show the "add" button in the page root rather than the table root
|
||||
*/
|
||||
protected $_addButtonInRoot = FALSE;
|
||||
protected bool $_addButtonInRoot = FALSE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_manage' );
|
||||
return parent::execute();
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,35 +93,35 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('reputation_title');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('reputation_title');
|
||||
|
||||
/* Init */
|
||||
$activeTab = \IPS\Request::i()->tab ?: NULL;
|
||||
$activeTab = Request::i()->tab ?: NULL;
|
||||
$activeTabContents = '';
|
||||
$tabs = array();
|
||||
|
||||
/* Settings */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
{
|
||||
$tabs['settings'] = 'reputation_settings';
|
||||
}
|
||||
|
||||
/* Reactions */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reactions_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reactions_manage' ) )
|
||||
{
|
||||
$tabs['reactions'] = 'reactions';
|
||||
}
|
||||
|
||||
/* Leaderboard */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
{
|
||||
$tabs['leaderboard'] = 'reputation_leaderboard';
|
||||
}
|
||||
|
||||
/* Levels */
|
||||
if ( \IPS\Settings::i()->reputation_enabled and \IPS\Settings::i()->reputation_show_profile )
|
||||
if ( Settings::i()->reputation_enabled and Settings::i()->reputation_show_profile )
|
||||
{
|
||||
$tabs['levels'] = 'reputation_levels';
|
||||
}
|
||||
@@ -94,27 +129,36 @@ class _reputation extends \IPS\Node\Controller
|
||||
/* Make sure we have a tab */
|
||||
if ( empty( $tabs ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '1C225/1', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '1C225/1', 403, '' );
|
||||
}
|
||||
elseif ( !$activeTab or !array_key_exists( $activeTab, $tabs ) )
|
||||
{
|
||||
$_tabs = array_keys( $tabs );
|
||||
$activeTab = array_shift( $_tabs );
|
||||
}
|
||||
|
||||
$blurbLangKey = $activeTab;
|
||||
|
||||
/* Do it */
|
||||
if ( $activeTab === 'reactions' )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reactions_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reactions_manage' );
|
||||
parent::manage();
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'global' )->paddedBlock( \IPS\Output::i()->output );
|
||||
$activeTabContents = Theme::i()->getTemplate( 'global' )->paddedBlock( Output::i()->output );
|
||||
if ( Bridge::i()->liveTopicsUnconverted() )
|
||||
{
|
||||
$blurbLangKey = 'reactions__locked__livetopics';
|
||||
$message = Theme::i()->getTemplate( 'global', 'cloud' )->reactionsDisabledLivetopicsMessage();
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $message );
|
||||
Member::loggedIn()->language()->words['rep_' . $blurbLangKey . '_blurb' ] = $message . Member::loggedIn()->language()->addToStack( 'rep_reactions_blurb' );
|
||||
}
|
||||
}
|
||||
else if ( $activeTab === 'settings' )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
|
||||
/* Random for the "like" preview */
|
||||
$maxMemberId = \IPS\Db::i()->select( 'MAX(member_id)', 'core_members' )->first();
|
||||
$maxMemberId = Db::i()->select( 'MAX(member_id)', 'core_members' )->first();
|
||||
$names = array();
|
||||
foreach ( range( 1, ( $maxMemberId > 3 ) ? 3 : $maxMemberId ) as $i )
|
||||
{
|
||||
@@ -129,20 +173,20 @@ class _reputation extends \IPS\Node\Controller
|
||||
$where = array( array( 'member_id>=?', $randomMemberId ) );
|
||||
if ( !empty( $names ) )
|
||||
{
|
||||
$where[] = \IPS\Db::i()->in( 'member_id', array_keys( $names ), TRUE );
|
||||
$where[] = Db::i()->in( 'member_id', array_keys( $names ), TRUE );
|
||||
}
|
||||
|
||||
$member = \IPS\Member::constructFromData( \IPS\Db::i()->select( '*', 'core_members', $where, 'member_id ASC', 1 )->first() );
|
||||
$member = Member::constructFromData( Db::i()->select( '*', 'core_members', $where, 'member_id ASC', 1 )->first() );
|
||||
$names[ $member->member_id ] = '<a>' . htmlentities( $member->name, ENT_DISALLOWED, 'UTF-8', FALSE ) . '</a>';
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( \count( $names ) == 3 )
|
||||
if ( count( $names ) == 3 )
|
||||
{
|
||||
$names[] = \IPS\Member::loggedIn()->language()->addToStack( 'like_blurb_others', FALSE, array( 'pluralize' => array( 2 ) ) );
|
||||
$names[] = Member::loggedIn()->language()->addToStack( 'like_blurb_others', FALSE, array( 'pluralize' => array( 2 ) ) );
|
||||
}
|
||||
if ( empty( $names ) )
|
||||
{
|
||||
@@ -150,26 +194,25 @@ class _reputation extends \IPS\Node\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$blurb = \IPS\Member::loggedIn()->language()->addToStack( 'like_blurb', FALSE, array( 'htmlsprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ), 'pluralize' => array( \count( $names ) ) ) );
|
||||
$blurb = Member::loggedIn()->language()->addToStack( 'like_blurb', FALSE, array( 'htmlsprintf' => array( Member::loggedIn()->language()->formatList( $names ) ), 'pluralize' => array( count( $names ) ) ) );
|
||||
}
|
||||
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_enabled', \IPS\Settings::i()->reputation_enabled, FALSE, array( 'togglesOn' => array( 'reputation_point_types', 'reputation_protected_groups', 'reputation_can_self_vote', 'reputation_highlight', 'reputation_show_profile', 'overall_reaction_count' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'reputation_protected_groups', explode( ',', \IPS\Settings::i()->reputation_protected_groups ), FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'reputation_protected_groups' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_can_self_vote', \IPS\Settings::i()->reputation_can_self_vote, FALSE, array(), NULL, NULL, NULL, 'reputation_can_self_vote' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'reputation_highlight', \IPS\Settings::i()->reputation_highlight, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('reputation_highlight_prefix'), \IPS\Member::loggedIn()->language()->addToStack('reputation_highlight_suffix'), 'reputation_highlight' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_show_profile', \IPS\Settings::i()->reputation_show_profile, FALSE, array(), NULL, NULL, NULL, 'reputation_show_profile' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'reaction_count_display', \IPS\Settings::i()->reaction_count_display, FALSE, array( 'options' => array( 'individual' => 'individual_reactions', 'count' => 'overall_reaction_count' ) ) ) );
|
||||
$form = new Form();
|
||||
$form->add( new YesNo( 'reputation_enabled', Settings::i()->reputation_enabled, FALSE, array( 'togglesOn' => array( 'reputation_point_types', 'reputation_protected_groups', 'reputation_can_self_vote', 'reputation_highlight', 'reputation_show_profile', 'overall_reaction_count' ) ) ) );
|
||||
$form->add( new CheckboxSet( 'reputation_protected_groups', explode( ',', Settings::i()->reputation_protected_groups ), FALSE, array( 'options' => Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'reputation_protected_groups' ) );
|
||||
$form->add( new YesNo( 'reputation_can_self_vote', Settings::i()->reputation_can_self_vote, FALSE, array(
|
||||
'disabled' => Bridge::i()->liveTopicsUnconverted()
|
||||
), NULL, NULL, NULL, 'reputation_can_self_vote' ) );
|
||||
$form->add( new Number( 'reputation_highlight', Settings::i()->reputation_highlight, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('reputation_highlight_prefix'), Member::loggedIn()->language()->addToStack('reputation_highlight_suffix'), 'reputation_highlight' ) );
|
||||
$form->add( new YesNo( 'reputation_show_profile', Settings::i()->reputation_show_profile, FALSE, array(), NULL, NULL, NULL, 'reputation_show_profile' ) );
|
||||
$form->add( new Radio( 'reaction_count_display', Settings::i()->reaction_count_display, FALSE, array( 'options' => array( 'individual' => 'individual_reactions', 'count' => 'overall_reaction_count' ) ) ) );
|
||||
|
||||
/* Save */
|
||||
if ( $form->saveAsSettings() )
|
||||
{
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__rep_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=settings' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__rep_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=settings' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
@@ -177,24 +220,24 @@ class _reputation extends \IPS\Node\Controller
|
||||
}
|
||||
else if ( $activeTab === 'leaderboard' )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
|
||||
/* Get available filters */
|
||||
$topMemberFilters = \IPS\Member::topMembersOptions();
|
||||
$topMemberFilters = Member::topMembersOptions();
|
||||
|
||||
/* Build Form */
|
||||
$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', 'leaderboard_excluded_groups' ) ), 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\CheckboxSet( 'leaderboard_excluded_groups', explode( ',', \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 = new Form();
|
||||
$form->add( new YesNo( 'reputation_leaderboard_on', 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', 'leaderboard_excluded_groups' ) ), NULL, NULL, NULL, 'reputation_leaderboard_on' ) );
|
||||
$form->add( new Radio( 'reputation_leaderboard_default_tab', 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 CheckboxSet( 'leaderboard_excluded_groups', explode( ',', Settings::i()->leaderboard_excluded_groups ), FALSE, array( 'options' => 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' ) );
|
||||
$form->add( new YesNo( 'reputation_show_days_won_trophy', Settings::i()->reputation_show_days_won_trophy, FALSE, array( 'togglesOn' => array() ), NULL, NULL, NULL, 'reputation_show_days_won_trophy' ) );
|
||||
$form->add( new Timezone( 'reputation_timezone', Settings::i()->reputation_timezone, FALSE, array(), NULL, NULL, NULL, 'reputation_timezone' ) );
|
||||
$form->addHeader('leaderboard_tabs_members');
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'reputation_top_members_overview', explode( ',', \IPS\Settings::i()->reputation_top_members_overview ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'reputation_overview_max_members', \IPS\Settings::i()->reputation_overview_max_members, FALSE, array( 'min' => 3, 'max' => 100 ), NULL, NULL, NULL, 'reputation_overview_max_members' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'reputation_top_members_filters', \IPS\Settings::i()->reputation_top_members_filters == '*' ? array_keys( $topMemberFilters ) : explode( ',', \IPS\Settings::i()->reputation_top_members_filters ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_top_members_filters' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'reputation_max_members', \IPS\Settings::i()->reputation_max_members, FALSE, array( 'min' => 3, 'max' => '100' ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
$form->add( new CheckboxSet( 'reputation_top_members_overview', explode( ',', Settings::i()->reputation_top_members_overview ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
$form->add( new Number( 'reputation_overview_max_members', Settings::i()->reputation_overview_max_members, FALSE, array( 'min' => 3, 'max' => 100 ), NULL, NULL, NULL, 'reputation_overview_max_members' ) );
|
||||
$form->add( new CheckboxSet( 'reputation_top_members_filters', Settings::i()->reputation_top_members_filters == '*' ? array_keys( $topMemberFilters ) : explode( ',', Settings::i()->reputation_top_members_filters ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_top_members_filters' ) );
|
||||
$form->add( new Number( 'reputation_max_members', Settings::i()->reputation_max_members, FALSE, array( 'min' => 3, 'max' => '100' ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
|
||||
/* Save */
|
||||
if ( $values = $form->values() )
|
||||
@@ -204,12 +247,9 @@ class _reputation extends \IPS\Node\Controller
|
||||
$values['leaderboard_excluded_groups'] = implode( ',', $values['leaderboard_excluded_groups'] );
|
||||
$values['reputation_top_members_filters'] = $values['reputation_top_members_filters'] == array_keys( $topMemberFilters ) ? '*' : implode( ',', $values['reputation_top_members_filters'] );
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__rep_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__rep_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
@@ -218,12 +258,12 @@ class _reputation extends \IPS\Node\Controller
|
||||
else
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_reputation_levels', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
$table = new TableDb( 'core_reputation_levels', Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
$table->langPrefix = 'rep_';
|
||||
|
||||
/* Columns */
|
||||
$table->joins = array(
|
||||
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_reputation_level_', core_reputation_levels.level_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
|
||||
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_reputation_level_', core_reputation_levels.level_id ) AND w.lang_id=" . Member::loggedIn()->language()->id )
|
||||
);
|
||||
$table->include = array( 'word_custom', 'level_image', 'level_points' );
|
||||
$table->mainColumn = 'word_custom';
|
||||
@@ -240,7 +280,7 @@ class _reputation extends \IPS\Node\Controller
|
||||
{
|
||||
if ( $val )
|
||||
{
|
||||
return "<img src='" . \IPS\File::get( "core_Theme", $val )->url . "' alt=''>";
|
||||
return "<img src='" . File::get( "core_Theme", $val )->url . "' alt=''>";
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -251,8 +291,8 @@ class _reputation extends \IPS\Node\Controller
|
||||
'add' => array(
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') )
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('add') )
|
||||
),
|
||||
);
|
||||
$table->rowButtons = function( $row )
|
||||
@@ -261,13 +301,13 @@ class _reputation extends \IPS\Node\Controller
|
||||
'edit' => array(
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm&id=' ) . $row['level_id'],
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit') )
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm&id=' ) . $row['level_id'],
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('edit') )
|
||||
),
|
||||
'delete' => array(
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&do=deleteLevel&id=' ) . $row['level_id'],
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=reputation&do=deleteLevel&id=' ) . $row['level_id'],
|
||||
'data' => array( 'delete' => '' )
|
||||
),
|
||||
);
|
||||
@@ -277,16 +317,16 @@ class _reputation extends \IPS\Node\Controller
|
||||
$activeTabContents = (string) $table;
|
||||
}
|
||||
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'forms' )->blurb( 'rep_' . $activeTab . '_blurb', TRUE, TRUE ) . $activeTabContents;
|
||||
$activeTabContents = Theme::i()->getTemplate( 'forms' )->blurb( 'rep_' . $blurbLangKey . '_blurb', TRUE, TRUE ) . $activeTabContents;
|
||||
|
||||
/* Display */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
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=reputation" ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, Url::internal( "app=core&module=membersettings&controller=reputation" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,19 +335,19 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function levelForm()
|
||||
public function levelForm() : void
|
||||
{
|
||||
$current = NULL;
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', \IPS\Request::i()->id ) )->first();
|
||||
$current = Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', Request::i()->id ) )->first();
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form = new Form();
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'rep_level_title', NULL, TRUE, array( 'app' => 'core', 'key' => ( $current ? "core_reputation_level_{$current['level_id']}" : NULL ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'rep_level_image', ( $current and $current['level_image'] ) ? \IPS\File::get( 'core_Theme', $current['level_image'] ) : NULL, FALSE, array( 'storageExtension' => 'core_Theme' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'rep_level_points', $current ? $current['level_points'] : 0, TRUE, array( 'min' => NULL ) ) );
|
||||
$form->add( new Translatable( 'rep_level_title', NULL, TRUE, array( 'app' => 'core', 'key' => ( $current ? "core_reputation_level_{$current['level_id']}" : NULL ) ) ) );
|
||||
$form->add( new Upload( 'rep_level_image', ( $current and $current['level_image'] ) ? File::get( 'core_Theme', $current['level_image'] ) : NULL, FALSE, array( 'storageExtension' => 'core_Theme' ) ) );
|
||||
$form->add( new Number( 'rep_level_points', $current ? $current['level_points'] : 0, TRUE, array( 'min' => NULL ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -318,27 +358,24 @@ class _reputation extends \IPS\Node\Controller
|
||||
|
||||
if ( $current )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_reputation_levels', $save, array( 'level_id=?', $current['level_id'] ) );
|
||||
Db::i()->update( 'core_reputation_levels', $save, array( 'level_id=?', $current['level_id'] ) );
|
||||
$id = $current['level_id'];
|
||||
\IPS\Session::i()->log( 'acplogs__rep_edited', array( $save['level_points'] => FALSE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = \IPS\Db::i()->insert( 'core_reputation_levels', $save );
|
||||
\IPS\Session::i()->log( 'acplogs__rep_edited', array( $save['level_points'] => FALSE ) );
|
||||
$id = Db::i()->insert( 'core_reputation_levels', $save );
|
||||
}
|
||||
|
||||
unset( \IPS\Data\Store::i()->reputationLevels );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "core_reputation_level_{$id}", $values['rep_level_title'] );
|
||||
Session::i()->log( 'acplogs__rep_edited', array( $save['level_points'] => FALSE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ), 'saved' );
|
||||
unset( Store::i()->reputationLevels );
|
||||
|
||||
Lang::saveCustom( 'core', "core_reputation_level_{$id}", $values['rep_level_title'] );
|
||||
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( $current ? "core_reputation_level_{$current['level_id']}" : 'add', $form, FALSE );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( $current ? "core_reputation_level_{$current['level_id']}" : 'add', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,29 +383,26 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteLevel()
|
||||
public function deleteLevel() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_delete' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_delete' );
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', \IPS\Request::i()->id ) )->first();
|
||||
$current = Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', Request::i()->id ) )->first();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__rep_deleted', array( $current['level_points'] => FALSE ) );
|
||||
\IPS\Db::i()->delete( 'core_reputation_levels', array( 'level_id=?', \IPS\Request::i()->id ) );
|
||||
unset( \IPS\Data\Store::i()->reputationLevels );
|
||||
Session::i()->log( 'acplogs__rep_deleted', array( $current['level_points'] => FALSE ) );
|
||||
Db::i()->delete( 'core_reputation_levels', array( 'level_id=?', Request::i()->id ) );
|
||||
unset( Store::i()->reputationLevels );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Lang::deleteCustom( 'core', 'core_reputation_level_' . \IPS\Request::i()->id );
|
||||
Lang::deleteCustom( 'core', 'core_reputation_level_' . Request::i()->id );
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException $e ) { }
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,59 +410,59 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rebuildLeaderboard()
|
||||
public function rebuildLeaderboard() : void
|
||||
{
|
||||
if ( ! isset( \IPS\Request::i()->process ) )
|
||||
if ( ! isset( Request::i()->process ) )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('reputation_leaderboard_rebuild_title');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'settings' )->reputationLeaderboardRebuild();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('reputation_leaderboard_rebuild_title');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'settings' )->reputationLeaderboardRebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
|
||||
\IPS\Session::i()->log( 'acplog__rebuilt_leaderboard' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'reputation_leaderboard_rebuilding' );
|
||||
Session::i()->csrfCheck();
|
||||
Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
Db::i()->delete('core_reputation_leaderboard_history');
|
||||
Session::i()->log( 'acplog__rebuilt_leaderboard' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'reputation_leaderboard_rebuilding' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to execute after nodes are reordered. Do nothing by default but plugins can extend.
|
||||
* Function to execute after nodes are reordered. Do nothing by default but app can extend.
|
||||
*
|
||||
* @param array $order The new ordering that was saved
|
||||
* @return void
|
||||
*/
|
||||
protected function _afterReorder( $order )
|
||||
protected function _afterReorder( array $order ) : void
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->reactions );
|
||||
unset( Store::i()->reactions );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redirect after save
|
||||
*
|
||||
* @param \IPS\Node\Model $old A clone of the node as it was before or NULL if this is a creation
|
||||
* @param \IPS\Node\Model $new The node now
|
||||
* @param string $lastUsedTab The tab last used in the form
|
||||
* @return void
|
||||
* @param Model|null $old A clone of the node as it was before or NULL if this is a creation
|
||||
* @param Model $new The node now
|
||||
* @param string $lastUsedTab The tab last used in the form
|
||||
* @return void
|
||||
*/
|
||||
protected function _afterSave( ?\IPS\Node\Model $old, \IPS\Node\Model $new, $lastUsedTab = FALSE )
|
||||
protected function _afterSave( ?Model $old, Model $new, mixed $lastUsedTab = FALSE ): void
|
||||
{
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array() );
|
||||
Output::i()->json( array() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( isset( \IPS\Request::i()->save_and_reload ) )
|
||||
if( isset( Request::i()->save_and_reload ) )
|
||||
{
|
||||
$buttons = $new->getButtons( $this->url, !( $new instanceof $this->nodeClass ) );
|
||||
$buttons = $new->getButtons($this->url, !($new instanceof $this->nodeClass));
|
||||
|
||||
\IPS\Output::i()->redirect( ( $lastUsedTab ? $buttons['edit']['link']->setQueryString('activeTab', $lastUsedTab ) : $buttons['edit']['link'] ), 'saved' );
|
||||
Output::i()->redirect( ( $lastUsedTab ? $buttons['edit']['link']->setQueryString('activeTab', $lastUsedTab ) : $buttons['edit']['link'] ), 'saved' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ), 'tab' => 'reactions' ) ), 'saved' );
|
||||
Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ), 'tab' => 'reactions' ) ), 'saved' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,34 +472,35 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
protected function delete() : void
|
||||
{
|
||||
/* Get node */
|
||||
/* @var Reaction $nodeClass */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( \IPS\Request::i()->subnode )
|
||||
if ( Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( \IPS\Request::i()->id );
|
||||
$node = $nodeClass::load( Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S101/J', 404, '' );
|
||||
Output::i()->error( 'node_error', '2S101/J', 404, '' );
|
||||
}
|
||||
|
||||
/* Permission check */
|
||||
if( !$node->canDelete() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_noperm_delete', '2S101/H', 403, '' );
|
||||
Output::i()->error( 'node_noperm_delete', '2S101/H', 403, '' );
|
||||
}
|
||||
|
||||
/* Do we have any children or content? */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'existing_reactions', NULL, TRUE, array( 'options' => array( 'change' => 'change_new_reaction', 'delete' => 'delete' ), 'toggles' => array( 'change' => array( 'new_reaction' ) ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'new_reaction', NULL, TRUE, array( 'class' => 'IPS\Content\Reaction', 'permissionCheck' => function( $row ) use ( $node ) {
|
||||
$form = new Form;
|
||||
$form->add( new Radio( 'existing_reactions', NULL, TRUE, array( 'options' => array( 'change' => 'change_new_reaction', 'delete' => 'delete' ), 'toggles' => array( 'change' => array( 'new_reaction' ) ) ) ) );
|
||||
$form->add( new Node( 'new_reaction', NULL, TRUE, array( 'class' => 'IPS\Content\Reaction', 'permissionCheck' => function( $row ) use ( $node ) {
|
||||
if ( $row->_id == $node->_id )
|
||||
{
|
||||
return FALSE;
|
||||
@@ -478,28 +513,28 @@ class _reputation extends \IPS\Node\Controller
|
||||
{
|
||||
if ( $values['existing_reactions'] == 'change' AND array_key_exists( 'new_reaction', $values ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_reputation_index', array( 'reaction' => $values['new_reaction']->_id ), array( "reaction=?", $node->_id ) );
|
||||
Db::i()->update( 'core_reputation_index', array( 'reaction' => $values['new_reaction']->_id ), array( "reaction=?", $node->_id ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_reputation_index', array( "reaction=?", $node->_id ) );
|
||||
Db::i()->delete( 'core_reputation_index', array( "reaction=?", $node->_id ) );
|
||||
}
|
||||
|
||||
/* Delete it */
|
||||
\IPS\Session::i()->log( 'acplog__node_deleted', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
Session::i()->log( 'acplog__node_deleted', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
$node->delete();
|
||||
|
||||
/* Boink */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( "OK" );
|
||||
Output::i()->json( "OK" );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( 'tab', 'reactions' )->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
|
||||
Output::i()->redirect( $this->url->setQueryString( 'tab', 'reactions' )->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,16 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -22,21 +29,21 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* spam
|
||||
* @deprecated
|
||||
*/
|
||||
class _spam extends \IPS\Dispatcher\Controller
|
||||
class spam extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Output::i()->redirect(\IPS\Http\Url::internal( 'app=core&module=moderation&controller=spam&tab=' . \IPS\Request::i()->tab ) );
|
||||
Output::i()->redirect(Url::internal( 'app=core&module=moderation&controller=spam&tab=' . Request::i()->tab ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user