Version 4.5.0
This commit is contained in:
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 _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' );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user