Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _ban extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _notifications extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -32,7 +37,7 @@ class _notifications extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'notifications_manage' );
parent::execute();
}
/**
* Manage
*
@@ -40,136 +45,340 @@ class _notifications extends \IPS\Dispatcher\Controller
*/
protected function manage()
{
/* Init Matrix */
$matrix = new \IPS\Helpers\Form\Matrix;
$matrix->manageable = FALSE;
$matrix->langPrefix = 'notificationsettings_';
$matrix->classes = array( 'cMemberNotifications' );
/* Populate columns */
$matrix->columns = array(
'label' => function( $key, $value, $data )
{
if ( mb_substr( $key, 0, -7 ) === 'new_likes' )
{
if ( \IPS\Content\Reaction::isLikeMode() )
{
return 'notifications__new_likes_like';
}
else
{
return 'notifications__new_likes_rep';
}
}
return $value;
},
'default' => function( $key, $value, $data )
{
return new \IPS\Helpers\Form\CheckboxSet( $key, $value, FALSE, array( 'options' => array( 'email' => 'member_notifications_email', 'inline' => 'member_notifications_inline' ), 'multiple' => TRUE ) );
},
'disabled' => function( $key, $value, $data )
{
return new \IPS\Helpers\Form\CheckboxSet( $key, $value, FALSE, array( 'options' => array( 'email' => 'member_notifications_email', 'inline' => 'member_notifications_inline' ), 'multiple' => TRUE ) );
},
'editable' => function( $key, $value, $data )
{
return new \IPS\Helpers\Form\YesNo( $key, $value );
},
);
/* Populate rows */
$current = iterator_to_array( \IPS\Db::i()->select( '*', 'core_notification_defaults' )->setKeyField( 'notification_key' ) );
foreach( \IPS\Application::allExtensions( 'core', 'Notifications', FALSE ) as $group => $class )
$types = array();
foreach ( \IPS\Application::allExtensions( 'core', 'Notifications' ) as $k => $extension )
{
$configuration = $class->getConfiguration( NULL );
if ( !empty( $configuration ) )
{
$lang = "notifications__{$group}";
$header = \IPS\Member::loggedIn()->language()->addToStack( $lang );
$matrix->rows[] = $header;
foreach ( $configuration as $key => $data )
{
$matrix->rows[ $key ] = array(
'label' => "notifications__{$key}",
'default' => isset( $current[ $key ] ) ? explode( ',', $current[ $key ]['default'] ) : $data['default'],
'disabled' => isset( $current[ $key ] ) ? explode( ',', $current[ $key ]['disabled'] ) : $data['disabled'],
'editable' => isset( $current[ $key ] ) ? $current[ $key ]['editable'] : TRUE,
);
}
}
$types[ $k ] = array(
'title' => \IPS\Member::loggedIn()->language()->get('notifications__' . $k)
);
}
/* Handle submissions */
if ( $values = $matrix->values() )
$typeTable = new \IPS\Helpers\Table\Custom( $types, \IPS\Http\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 ),
'icon' => 'pencil'
)
);
};
$methodTable = new \IPS\Helpers\Table\Custom( array( 'inline' => array( 'method' => \IPS\Member::loggedIn()->language()->addToStack('member_notifications_inline') ) ), \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications', 'admin' ) );
$methodTable->langPrefix = 'notificationsettings_';
$methodTable->rowButtons = function( $row, $k ) {
return array(
'edit' => array(
'title' => 'edit',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications&do=method', 'admin' )->setQueryString( 'id', $k ),
'icon' => 'pencil'
)
);
};
if( !\IPS\CIC )
{
\IPS\Db::i()->delete( 'core_notification_defaults' );
$inserts = array();
foreach ( $values as $k => $data )
{
$inserts[] = array(
'notification_key' => $k,
'default' => implode( ',', $data['default'] ),
'disabled' => implode( ',', $data['disabled'] ),
'editable' => $data['editable']
);
}
if( count( $inserts ) )
{
\IPS\Db::i()->insert( 'core_notification_defaults', $inserts );
}
\IPS\Session::i()->log( 'acplog__notifications_edited' );
\IPS\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') )
),
);
}
/* Add a button for settings */
\IPS\Output::i()->sidebar['actions'] = array(
'settings' => array(
'title' => 'notificationsettings',
'icon' => 'cog',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications&do=settings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('notificationsettings') )
),
);
/* Display */
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'members/notifications.css', 'core', 'admin' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('notifications');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'notifications', $matrix );
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'profiles_manage' ) )
{
\IPS\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') )
);
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('notifications');
\IPS\Output::i()->output = $typeTable . $methodTable;
}
/**
* Profile Settings
* Prune Settings
*
* @return void
*/
protected function settings()
protected function pruneSettings()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
if( \IPS\CIC )
{
\IPS\Output::i()->error( 'node_error', '2C413/1', 403, '' );
}
$form = new \IPS\Helpers\Form;
$form->addHeader('auto_follow_preferences');
$form->addMessage( 'auto_follow_update_all' );
$form->add( new \IPS\Helpers\Form\YesNo( 'auto_follow_new_content', \IPS\Settings::i()->auto_follow_new_content, FALSE, array(), NULL, NULL, NULL, 'auto_follow_new_content' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'auto_follow_replied_to', \IPS\Settings::i()->auto_follow_replied_to, FALSE, array(), NULL, NULL, NULL, 'auto_follow_replied_to' ) );
$form->addHeader('notification_pruning');
$form->add( new \IPS\Helpers\Form\Number( 'subs_autoprune', \IPS\Settings::i()->subs_autoprune, FALSE, array(), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days') ) );
$form->add( new \IPS\Helpers\Form\Number( 'prune_notifications', \IPS\Settings::i()->prune_notifications, FALSE, array(), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('months') ) );
$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 ) {
if( $val > 0 AND $val < 30 )
{
throw new \DomainException( \IPS\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 ) {
if( $val > 0 AND $val < 7 )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
}
}, \IPS\Member::loggedIn()->language()->addToStack('after') ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
/* If we're enabling pruning on a potentially large table, handle that */
if( !\IPS\Settings::i()->prune_follows AND $values['prune_follows'] )
{
\IPS\Task::queue( 'core', 'PruneLargeTable', array(
'table' => 'core_follow',
'where' => array( 'follow_member_id IN(?)', \IPS\Db::i()->select( 'member_id', 'core_members', array( 'last_activity < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_follows'] . 'D' ) )->getTimestamp() ) ) ),
'deleteJoin' => array(
'column' => 'member_id',
'table' => 'core_members',
'where' => array( 'last_activity < ?', \IPS\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' );
}
\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 );
}
/**
* Edit
*
* @return void
*/
protected function edit()
{
$extensions = \IPS\Application::allExtensions( 'core', 'Notifications' );
if ( !isset( $extensions[ \IPS\Request::i()->id ] ) )
{
\IPS\Output::i()->error( 'node_error', '2C404/2', 404, '' );
}
$extension = $extensions[ \IPS\Request::i()->id ];
$defaultConfiguration = \IPS\Notification::defaultConfiguration();
$form = new \IPS\Helpers\Form;
foreach ( \IPS\Notification::availableOptions( NULL, $extension ) as $key => $option )
{
if ( $option['type'] === 'standard' )
{
$form->addHeader( $option['title'] );
if ( isset( $option['adminDescription'] ) )
{
$form->addMessage( $option['adminDescription'] );
}
elseif ( $option['description'] )
{
$form->addMessage( $option['description'] );
}
if ( !\in_array( 'inline', $option['disabled'] ) or ( \IPS\Settings::i()->mobile_app_id 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(
'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');
$form->add( $canEditField );
}
if ( isset( $option['extra'] ) )
{
foreach ( $option['extra'] as $k => $extra )
{
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(
'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'] );
$form->add( $field );
}
}
}
foreach ( array( 'inline', 'push', 'email' ) as $k )
{
if ( !\in_array( $k, $option['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(
'options' => array(
'default' => 'admin_notification_pref_default',
'optional' => 'admin_notification_pref_optional',
'disabled' => 'admin_notification_pref_disabled'
),
'toggles' => $k === 'inline' ? array(
'default' => array( 'member_notifications_' . $key . '_push' ),
'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 );
$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(
'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 );
$form->add( $nonEditableField );
}
}
}
elseif ( $option['type'] === 'custom' )
{
if ( ( isset( $option['adminCanSetDefault'] ) and $option['adminCanSetDefault'] ) or ( isset( $option['adminOnly'] ) and $option['adminOnly'] ) )
{
if ( isset( $option['admin_lang']['header'] ) and isset( $option['admin_lang'] ) )
{
$form->addHeader( $option['admin_lang']['header'] );
}
$form->add( $option['field'] );
}
}
}
if ( $values = $form->values() )
{
foreach ( \IPS\Notification::availableOptions( NULL, $extension ) as $key => $option )
{
if ( $option['type'] === 'standard' )
{
if ( isset( $option['extra'] ) )
{
foreach ( $option['extra'] as $k => $extra )
{
if ( isset( $extra['adminCanSetDefault'] ) and $extra['adminCanSetDefault'] )
{
$extension->saveExtra( NULL, $k, ( $values[ 'member_notifications_' . $key . '_' . $k ] === 'default' ) );
}
}
}
if ( !\in_array( 'inline', $option['disabled'] ) or ( \IPS\Settings::i()->mobile_app_id and !\in_array( 'push', $option['disabled'] ) ) or !\in_array( 'email', $option['disabled'] ) )
{
$row = array(
'notification_key' => $key,
'default' => array(),
'disabled' => array(),
'editable' => $values[ 'notificationsettings_editable_' . $key ]
);
foreach ( array( 'inline', 'push', 'email' ) as $k )
{
if ( !\in_array( $k, $option['disabled'] ) )
{
if ( $k === 'push' )
{
if ( !\IPS\Settings::i()->mobile_app_id )
{
continue;
}
$fieldToCheck = $values[ 'member_notifications_' . $key . '_push' ];
}
else
{
$fieldToCheck = $values[ 'notificationsettings_editable_' . $key ] ? $values[ 'member_notifications_' . $key . '_' . $k . '_editable' ] : $values[ 'member_notifications_' . $key . '_' . $k ];
}
if ( $fieldToCheck === 'default' )
{
$row['default'][] = $k;
}
elseif ( $fieldToCheck === 'disabled' )
{
$row['disabled'][] = $k;
}
}
}
$row['default'] = implode( ',', $row['default'] );
$row['disabled'] = implode( ',', $row['disabled'] );
\IPS\Db::i()->replace( 'core_notification_defaults', $row, array( 'notification_key=?', $key ) );
$extensionConfiguration = $extension->configurationOptions();
if ( isset( $extensionConfiguration[ $key ] ) and $extensionConfiguration[ $key ]['type'] === 'standard' )
{
foreach ( $extensionConfiguration[ $key ]['notificationTypes'] as $notificationType )
{
$row['notification_key'] = $notificationType;
\IPS\Db::i()->replace( 'core_notification_defaults', $row, array( 'notification_key=?', $notificationType ) );
}
}
}
}
elseif ( $option['type'] === 'custom' )
{
if ( ( isset( $option['adminCanSetDefault'] ) and $option['adminCanSetDefault'] ) or ( isset( $option['adminOnly'] ) and $option['adminOnly'] ) )
{
$extension->saveExtra( NULL, $key, $option['field']->value );
}
}
}
\IPS\Session::i()->log( 'acplog__notifications_edited' );
\IPS\Output::i()->redirect( \IPS\Http\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;
}
/**
* Notification List Settings
*
* @return void
*/
protected function method()
{
$form = new \IPS\Helpers\Form;
$form->addHeader('notification_preferences');
$form->add( new \IPS\Helpers\Form\Radio( 'notification_prefs_sound', \IPS\Settings::i()->notification_prefs_sound ? 'default' : 'optional', FALSE, array( 'options' => array(
'default' => 'admin_notification_pref_default',
'optional' => 'admin_notification_pref_optional',
) ), NULL, NULL, NULL, 'notification_prefs_sound' ) );
if ( $values = $form->values() )
{
$values['notification_prefs_sound'] = ( $values['notification_prefs_sound'] === 'default' );
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplog__notification_settings' );
\IPS\Output::i()->redirect( \IPS\Http\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('notificationsettings');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'notificationsettings', $form, FALSE );
}
/**
* Member Auto Follow Preferences
*
@@ -178,14 +387,25 @@ class _notifications extends \IPS\Dispatcher\Controller
protected function updateMemberFollowPrefs()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
\IPS\Session::i()->csrfCheck();
/* Do standard preferences */
\IPS\Db::i()->delete( 'core_notification_preferences' );
/* Do "extra" preferences */
foreach ( \IPS\Application::allExtensions( 'core', 'Notifications' ) as $k => $extension )
{
if ( method_exists( $extension, 'resetExtra' ) )
{
$extension->resetExtra();
}
}
/* Sounds is special */
\IPS\Db::i()->update( 'core_members', 'members_bitoptions2 = members_bitoptions2 ' . ( !\IPS\Settings::i()->notification_prefs_sound ? '|' : '&~' ) . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['disable_notification_sounds'] );
$autoTrack = json_encode( array(
'content' => \IPS\Settings::i()->auto_follow_new_content ? 1 : 0,
'comments' => \IPS\Settings::i()->auto_follow_replied_to ? 1 : 0,
'method' => 'immediate'
) );
\IPS\Db::i()->update( 'core_members', array( 'auto_track' => $autoTrack ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=notifications' ), 'saved' );
/* 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' );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,10 +22,20 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _profilecompletion extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = '\IPS\Member\ProfileStep';
/**
* Show the "add" button in the page root rather than the table root
*/
protected $_addButtonInRoot = FALSE;
/**
* Get Root Buttons
@@ -78,6 +88,8 @@ class _profilecompletion extends \IPS\Node\Controller
*/
public function enableQuickRegister()
{
\IPS\Session::i()->csrfCheck();
\IPS\Settings::i()->changeValues( array( 'quick_register' => 1 ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=profiles&tab=profilecompletion' ), 'profile_complete_quick_register_off_enabled' );
@@ -114,16 +126,9 @@ class _profilecompletion extends \IPS\Node\Controller
$values = $step->formatFormValues( $values );
$step->extension = \IPS\Member\ProfileStep::findExtensionFromAction( $values['step_completion_act'] );
if ( isset( $values['step_required'] ) )
{
$step->required = $values['step_required'];
}
else
{
$step->required = FALSE;
}
$step->required = ( isset( $values['step_required'] ) ) ? $values['step_required'] : FALSE;
$step->completion_act = $values['step_completion_act'];
$step->subcompletion_act = $values['step_subcompletion_act'];
$step->subcompletion_act = isset( $values['step_subcompletion_act'] ) ? $values['step_subcompletion_act'] : NULL;
$step->save();
$step->postSaveForm( $values );
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,11 +22,21 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _profilefields extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = '\IPS\core\ProfileFields\Group';
/**
* Show the "add" button in the page root rather than the table root
*/
protected $_addButtonInRoot = FALSE;
/**
* Execute
*
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _profiles extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Call
*
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _profilesettings extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -30,6 +35,9 @@ class _profilesettings extends \IPS\Dispatcher\Controller
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'profiles_manage' );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_members.js', 'core' ) );
parent::execute();
}
@@ -41,14 +49,9 @@ class _profilesettings extends \IPS\Dispatcher\Controller
public function manage()
{
$form = new \IPS\Helpers\Form;
$form->addHeader( 'photos' );
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_gravatars', \IPS\Settings::i()->allow_gravatars ) );
if( \IPS\Image::canWriteText() )
{
$form->add( new \IPS\Helpers\Form\Radio( 'letter_photos', \IPS\Settings::i()->letter_photos, FALSE, array( 'options' => array( 'default' => 'letterphoto_default', 'letters' => 'letterphoto_letters' ) ) ) );
}
$form->addHeader( '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->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(
@@ -71,9 +74,30 @@ class _profilesettings extends \IPS\Dispatcher\Controller
throw new \DomainException('user_name_length_no_match');
}
} ) );
$form->add( new \IPS\Helpers\Form\Text( 'username_characters', \IPS\Settings::i()->username_characters, FALSE, array( 'max' => 255 ) ) );
$form->add( new \IPS\Helpers\Form\Custom( 'username_characters', \IPS\Settings::i()->username_characters, FALSE, array(
'getHtml' => function( $field ) {
$easy = NULL;
if ( preg_match( '/^\/\^\(\(\[(\\\p\{L\}\\\p\{M\}|A\-Za\-z)(\\\p\{N\}|0-9)?(.+)?\]\+\)( )?\?\)\+\$\/u$/', $field->value, $matches ) )
{
$easy['letters'] = ( $matches[1] == '\\p{L}\\p{M}' ) ? 'all' : 'latin';
if ( $matches[2] )
{
$easy['numbers'] = ( $matches[2] == '\\p{N}' ) ? 'all' : 'arabic';
}
else
{
$easy['numbers'] = 'none';
}
$easy['spaces'] = (bool) isset( $matches[4] );
$easy['extra'] = stripslashes( $matches[3] );
}
return \IPS\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 ) );
$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(
@@ -93,22 +117,135 @@ class _profilesettings extends \IPS\Dispatcher\Controller
'options' => array( 'public' => 'profile_birthday_type_public', 'private' => 'profile_birthday_type_private', 'none' => 'profile_birthday_type_none' )
), NULL, NULL, NULL, 'profile_birthday_type' ) );
if( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'profiles', 'member_history_prune' ) )
if( !\IPS\CIC AND \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'profiles', 'member_history_prune' ) )
{
$form->addHeader( 'profile_member_history' );
$form->add( new \IPS\Helpers\Form\Number( 'prune_member_history', \IPS\Settings::i()->prune_member_history, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_member_history' ) );
$form->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 \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 ) {
if( $val > 0 AND $val < 7 )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
}
}, \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 ) {
if( $val > 0 AND $val < 30 )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 29 ) ) ) );
}
}, \IPS\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 ) {
if( $val > 0 AND $val < 7 )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'form_interval_min_d', FALSE, array( 'pluralize' => array( 6 ) ) ) );
}
}, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'prune_item_markers' ) );
}
$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->addHeader( 'profile_settings_display' );
$form->add( new \IPS\Helpers\Form\Radio( 'group_formatting_type', \IPS\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(
'unread' => 'profile_settings_cvb_unread',
'last' => 'profile_settings_cvb_last',
'first' => 'profile_settings_cvb_first'
) ) ) );
if ( $values = $form->values() )
{
if ( $values['username_characters']['easy'] )
{
$regex = '/^(([';
if ( $values['username_characters']['letters'] == 'all' )
{
$regex .= '\p{L}\p{M}';
}
else
{
$regex .= 'A-Za-z';
}
if ( $values['username_characters']['numbers'] == 'all' )
{
$regex .= '\p{N}';
}
elseif ( $values['username_characters']['numbers'] == 'arabic' )
{
$regex .= '0-9';
}
if ( isset( $values['username_characters']['extra_enabled'] ) )
{
$regex .= preg_quote( $values['username_characters']['extra'], '/' );
}
$regex .= ']+)';
if ( isset( $values['username_characters']['spaces'] ) )
{
$regex .= ' ';
}
$regex .= '?)+$/u';
$values['username_characters'] = $regex;
}
else
{
$values['username_characters'] = $values['username_characters']['regex'];
}
$values['group_formatting'] = $values['group_formatting_type'];
unset( $values['group_formatting_type'] );
$values['min_user_name_length'] = $values['user_name_length'][0];
$values['max_user_name_length'] = $values['user_name_length'][1];
unset( $values['user_name_length'] );
$values['status_updates_mem_enable'] = ( $values['profile_comments'] == 2 ) ? 1 : 0;
$values['profile_comments'] = ( $values['profile_comments'] > 0 ) ? 1 : 0;
/* If we're enabling pruning on a potentially large table, handle that */
if( !\IPS\Settings::i()->prune_member_history AND $values['prune_member_history'] )
{
\IPS\Task::queue( 'core', 'PruneLargeTable', array(
'table' => 'core_member_history',
'where' => array( 'log_date < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $values['prune_member_history'] . 'D' ) )->getTimestamp() ),
), 4 );
}
if( !\IPS\Settings::i()->prune_known_ips AND $values['prune_known_ips'] )
{
\IPS\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() ),
), 4 );
}
if( !\IPS\Settings::i()->prune_known_devices AND $values['prune_known_devices'] )
{
\IPS\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() ),
), 4 );
}
if( !\IPS\Settings::i()->prune_item_markers AND $values['prune_item_markers'] )
{
\IPS\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() ) ) ),
'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() ),
'outerColumn' => 'item_member_id'
)
), 4 );
}
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplog__profile_settings' );
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _ranks extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*
@@ -62,7 +67,7 @@ class _ranks extends \IPS\Dispatcher\Controller
}
else
{
return str_repeat("<span class='ipsPip'></span>", intval($val) );
return str_repeat("<span class='ipsPip'></span>", \intval($val) );
}
}
);
@@ -71,44 +76,34 @@ class _ranks extends \IPS\Dispatcher\Controller
$table->sortDirection = $table->sortDirection ?: 'asc';
/* Root Buttons */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'ranks_manage' ) )
{
\IPS\Output::i()->sidebar['actions'] = array(
'add' => array(
'primary' => TRUE,
'icon' => 'plus',
'title' => 'member_ranks_add',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('member_ranks_add') ),
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ranks&do=form' ),
)
);
}
\IPS\Output::i()->sidebar['actions'] = array(
'add' => array(
'primary' => TRUE,
'icon' => 'plus',
'title' => 'member_ranks_add',
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('member_ranks_add') ),
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ranks&do=form' ),
)
);
/* Row buttons */
$table->rowButtons = function( $row )
{
$return = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'ranks_manage' ) )
{
$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=ranks&do=form&id=' ) . $row['id'],
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'ranks_manage' ) )
{
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ranks&do=delete&id=' ) . $row['id'],
'data' => array( 'delete' => '' ),
);
}
$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=ranks&do=form&id=' ) . $row['id'],
);
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=ranks&do=delete&id=' ) . $row['id'],
'data' => array( 'delete' => '' ),
);
return $return;
};
@@ -142,6 +137,8 @@ class _ranks extends \IPS\Dispatcher\Controller
/**
* Add/Edit Rank
*
* @return void
*/
public function form()
{
@@ -158,7 +155,7 @@ class _ranks extends \IPS\Dispatcher\Controller
$form->add( new \IPS\Helpers\Form\Translatable( 'member_ranks_word_custom', NULL, TRUE, array( 'app' => 'core', 'key' => ( $current ? "core_member_rank_{$current['id']}" : NULL ) ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'member_ranks_posts', $current ? $current['posts'] : 0, TRUE, array( 'min' => 0 ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'member_use_icon', $current['use_icon'], FALSE, array(
$form->add( new \IPS\Helpers\Form\Radio( 'member_use_icon', $current ? $current['use_icon'] : NULL, FALSE, array(
'parse' => 'raw',
'options' => array( 0 => \IPS\Member::loggedIn()->language()->addToStack('member_ranks_pip_number', FALSE, array( 'htmlsprintf' => array( "<span class='ipsPip'></span>" ) ) ), 1 => \IPS\Member::loggedIn()->language()->addToStack('member_ranks_pip_icon') ),
'toggles' => array( 0 => array('member_ranks_pips'), 1 => array('member_ranks_icon') )
@@ -166,7 +163,7 @@ class _ranks extends \IPS\Dispatcher\Controller
/* Pip Icon */
$pip = NULL;
if ( $current['icon'] )
if ( $current AND $current['icon'] )
{
$pip = \IPS\File::get( 'core_Theme', $current['icon'] );
}
@@ -176,9 +173,9 @@ class _ranks extends \IPS\Dispatcher\Controller
if ( $values = $form->values() )
{
$save = array(
'posts' => intval( $values['member_ranks_posts'] ),
'pips' => intval( $values['member_ranks_num_pips'] ),
'use_icon' => intval( $values['member_use_icon'] ),
'posts' => \intval( $values['member_ranks_posts'] ),
'pips' => \intval( $values['member_ranks_num_pips'] ),
'use_icon' => \intval( $values['member_use_icon'] ),
'icon' => '',
);
@@ -0,0 +1,78 @@
<?php
/**
* @brief referralbanners
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Core
* @since 7 Aug 2019
*/
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* referralbanners
*/
class _referralbanners extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = 'IPS\core\ReferralBanner';
/**
* Show the "add" button in the page root rather than the table root
*/
protected $_addButtonInRoot = FALSE;
/**
* Title can contain HTML?
*/
public $_titleHtml = TRUE;
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'core', 'membersettings', 'referrals_manage' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
public function manage()
{
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'referral_banners_blurb', TRUE, TRUE );
return parent::manage();
}
/**
* Form
*
* @return void
*/
public function form()
{
parent::form();
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('referral_banners');
}
}
@@ -0,0 +1,95 @@
<?php
/**
* @brief referralcommission
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 30 Sep 2019
*/
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* referralcommission
*/
class _referralcommission extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = 'IPS\nexus\CommissionRule';
/**
* Show the "add" button in the page root rather than the table root
*/
protected $_addButtonInRoot = FALSE;
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'commission_rules_manage' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
public function manage()
{
\IPS\Output::i()->sidebar['actions'][] = array(
'icon' => 'cog',
'title' => 'commission_settings',
'link' => \IPS\Http\Url::internal( "app=nexus&module=customers&controller=referrals&do=settings" )
);
parent::manage();
}
/**
* Manage
*
* @return void
*/
public function settings()
{
$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' ) );
if ( $values = $form->values() )
{
\IPS\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\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=customers&controller=referrals'), 'saved' );
}
\IPS\Output::i()->output = $form;
}
}
@@ -0,0 +1,164 @@
<?php
/**
* @brief referrals
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 07 Aug 2019
*/
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Referrals
*/
class _referrals extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Call
*
* @param string $method Method name
* @param mixed $args Method arguments
* @return void
*/
public function __call( $method, $args )
{
$tabs = array();
if( \IPS\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' ) )
{
$tabs['referralbanners'] = 'referral_banners';
}
if( \IPS\Settings::i()->ref_on and \IPS\Application::appIsEnabled( 'nexus' ) )
{
$tabs['referralcommission'] = 'referral_commission';
}
if ( isset( \IPS\Request::i()->tab ) and isset( $tabs[ \IPS\Request::i()->tab ] ) )
{
$activeTab = \IPS\Request::i()->tab;
}
else
{
$_tabs = array_keys( $tabs ) ;
$activeTab = array_shift( $_tabs );
}
$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->execute();
if ( $method !== 'manage' or \IPS\Request::i()->isAjax() )
{
return;
}
\IPS\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' ),
),
);
\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" ) );
}
/**
* Referral History
*
* @return void
*/
protected function history()
{
$table = new \IPS\Helpers\Table\Db( 'core_referrals', \IPS\Http\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' ) )
{
$table->include[] = 'amount';
}
$table->sortBy = $table->sortBy ?: 'joined';
$table->sortDirection = $table->sortDirection ?: 'DESC';
$table->noSort = array( 'photo', 'member_id', 'referred_by' );
$table->joins = array(
array( 'select' => 'm.*', 'from' => array( 'core_members', 'm' ), 'where' => "core_referrals.member_id=m.member_id" )
);
$table->parsers = array(
'photo' => function( $val, $row )
{
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->userPhoto( \IPS\Member::constructFromData( $row ), 'tiny' );
},
'member_id' => function( $val, $row )
{
if ( $val )
{
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->userLink( \IPS\Member::constructFromData( $row ) );
}
else
{
return \IPS\Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( \IPS\Member::load( $val ) );
}
},
'referred_by' => function( $val, $row )
{
if ( $val )
{
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->userLink( \IPS\Member::load( $val ) );
}
else
{
return \IPS\Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( \IPS\Member::load( $val ) );
}
},
'joined' => function( $val, $row )
{
return \IPS\DateTime::ts( $val )->localeDate();
},
'amount' => function ( $val, $row )
{
$return = array();
if ( $val )
{
foreach ( json_decode( $val, TRUE ) as $currency => $amount )
{
$return[] = new \IPS\nexus\Money( $amount, $currency );
}
}
else
{
$return[] = \IPS\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;
}
}
@@ -0,0 +1,48 @@
<?php
/**
* @brief Referral Settings
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Core
* @since 7 Aug 2019
*/
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Referral Settings
*/
class _refersettings extends \IPS\Dispatcher\Controller
{
/**
* Manage
*
* @return void
*/
public function execute()
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\YesNo( 'ref_on', \IPS\Settings::i()->ref_on, FALSE ) );
if ( $values = $form->values() )
{
$form->saveAsSettings( $values );
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=membersettings&controller=referrals') );
}
\IPS\Output::i()->output = $form;
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _reputation extends \IPS\Node\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Node Class
*/
@@ -32,6 +37,11 @@ class _reputation extends \IPS\Node\Controller
*/
public $_titleHtml = TRUE;
/**
* Show the "add" button in the page root rather than the table root
*/
protected $_addButtonInRoot = FALSE;
/**
* Execute
*
@@ -130,7 +140,7 @@ class _reputation extends \IPS\Node\Controller
break;
}
}
if ( count( $names ) == 3 )
if ( \count( $names ) == 3 )
{
$names[] = \IPS\Member::loggedIn()->language()->addToStack( 'like_blurb_others', FALSE, array( 'pluralize' => array( 2 ) ) );
}
@@ -140,7 +150,7 @@ 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 = \IPS\Member::loggedIn()->language()->addToStack( 'like_blurb', FALSE, array( 'htmlsprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ), 'pluralize' => array( \count( $names ) ) ) );
}
/* Build Form */
@@ -174,9 +184,9 @@ class _reputation extends \IPS\Node\Controller
/* 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' ) ), NULL, NULL, NULL, 'reputation_leaderboard_on' ) );
$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\Select( 'leaderboard_excluded_groups', \IPS\Settings::i()->leaderboard_excluded_groups, FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'leaderboard_excluded_groups' ) );
$form->add( new \IPS\Helpers\Form\Select( '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->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' ) );
@@ -191,6 +201,7 @@ class _reputation extends \IPS\Node\Controller
{
/* Save */
$values['reputation_top_members_overview'] = implode( ',', $values['reputation_top_members_overview'] );
$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 );
@@ -374,6 +385,7 @@ class _reputation extends \IPS\Node\Controller
}
else
{
\IPS\Session::i()->csrfCheck();
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'reputation_leaderboard_rebuilding' );
@@ -436,7 +448,7 @@ class _reputation extends \IPS\Node\Controller
try
{
$node = call_user_func( "{$nodeClass}::load", \IPS\Request::i()->id );
$node = $nodeClass::load( \IPS\Request::i()->id );
}
catch ( \OutOfRangeException $e )
{
@@ -483,7 +495,7 @@ class _reputation extends \IPS\Node\Controller
}
else
{
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
\IPS\Output::i()->redirect( $this->url->setQueryString( 'tab', 'reactions' )->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
}
}
@@ -12,7 +12,7 @@
namespace IPS\core\modules\admin\membersettings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -24,6 +24,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _spam extends \IPS\Dispatcher\Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
/**
* Execute
*