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,46 +11,66 @@
|
||||
namespace IPS\core\modules\admin\overview;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\core\extensions\core\AdminNotifications\ConfigurationError;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form\Matrix;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification Center
|
||||
*/
|
||||
class _notifications extends \IPS\Dispatcher\Controller
|
||||
class notifications extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Show notifications
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$notifications = \IPS\core\AdminNotification::notifications();
|
||||
$notifications = AdminNotification::notifications();
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() and !isset( \IPS\Request::i()->_table ) )
|
||||
if ( Request::i()->isAjax() and !isset( Request::i()->_table ) )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'data' => \IPS\Theme::i()->getTemplate('notifications')->popupList( $notifications ), 'count' => \count( $notifications ) ) );
|
||||
Output::i()->json( array( 'data' => Theme::i()->getTemplate('notifications')->popupList( $notifications ), 'count' => count( $notifications ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('acp_notifications');
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/notifications.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('notifications')->index( $notifications );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('acp_notifications');
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'system/notifications.css', 'core', 'admin' ) );
|
||||
Output::i()->output = Theme::i()->getTemplate('notifications')->index( $notifications );
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'notification_options',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications&do=settings' ),
|
||||
'link' => Url::internal( 'app=core&module=overview&controller=notifications&do=settings' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -61,19 +81,19 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function dismiss()
|
||||
protected function dismiss() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
\IPS\core\AdminNotification::dismissNotification( \IPS\Request::i()->id );
|
||||
AdminNotification::dismissNotification( Request::i()->id );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'status' => 'OK' ) );
|
||||
Output::i()->json( array( 'status' => 'OK' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +102,11 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
protected function settings() : void
|
||||
{
|
||||
$preferences = iterator_to_array( \IPS\Db::i()->select( '*', 'core_acp_notifications_preferences', array( '`member`=?', \IPS\Member::loggedIn()->member_id ) )->setKeyField('type') );
|
||||
$preferences = iterator_to_array( Db::i()->select( '*', 'core_acp_notifications_preferences', array( '`member`=?', Member::loggedIn()->member_id ) )->setKeyField('type') );
|
||||
|
||||
$matrix = new \IPS\Helpers\Form\Matrix;
|
||||
$matrix = new Matrix;
|
||||
$matrix->langPrefix = 'acp_notifications_';
|
||||
$matrix->manageable = FALSE;
|
||||
$matrix->columns = array(
|
||||
@@ -96,7 +116,7 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
},
|
||||
'view' => function( $key, $value, $data )
|
||||
{
|
||||
return new \IPS\Helpers\Form\YesNo( $key, $data['maybeOptional'] ? $value : TRUE, FALSE, array( 'disabled' => !$data['maybeOptional'] ) );
|
||||
return new YesNo( $key, $data['maybeOptional'] ? $value : TRUE, FALSE, array( 'disabled' => !$data['maybeOptional'] ) );
|
||||
},
|
||||
'email' => function( $key, $value, $data )
|
||||
{
|
||||
@@ -115,15 +135,15 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
'once' => 'acp_notifications_email_yes',
|
||||
);
|
||||
|
||||
return new \IPS\Helpers\Form\Select( $key, $value, FALSE, array( 'options' => $options, 'class' => 'ipsField_medium' ) );
|
||||
return new Select( $key, $value, FALSE, array( 'options' => $options, 'class' => 'ipsField_medium' ) );
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$rows = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'AdminNotifications', TRUE, NULL, NULL, FALSE ) as $ext )
|
||||
foreach ( Application::allExtensions( 'core', 'AdminNotifications', TRUE, NULL, NULL, FALSE ) as $ext )
|
||||
{
|
||||
if ( $ext::permissionCheck( \IPS\Member::loggedIn() ) )
|
||||
if ( $ext::permissionCheck( Member::loggedIn() ) )
|
||||
{
|
||||
$exploded = explode( '\\', $ext );
|
||||
$key = "{$exploded[1]}_{$exploded[5]}";
|
||||
@@ -131,11 +151,11 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
$rows[ $ext::$group ]['priority'] = $ext::$groupPriority;
|
||||
$rows[ $ext::$group ]['rows'][ $ext ] = array(
|
||||
'name' => $ext::settingsTitle(),
|
||||
'view' => isset( $preferences[ $key ]['view'] ) ? $preferences[ $key ]['view'] : $ext::defaultValue(),
|
||||
'email' => isset( $preferences[ $key ]['email'] ) ? $preferences[ $key ]['email'] : 'never',
|
||||
'view' => $preferences[$key]['view'] ?? $ext::defaultValue(),
|
||||
'email' => $preferences[$key]['email'] ?? 'never',
|
||||
'maybeOptional' => $ext::mayBeOptional(),
|
||||
'mayRecur' => $ext::mayRecur(),
|
||||
'customEmail' => $ext::customEmailConfigurationSetting( "{$ext}[email]", isset( $preferences[ $key ]['email'] ) ? $preferences[ $key ]['email'] : NULL ),
|
||||
'customEmail' => $ext::customEmailConfigurationSetting( "{$ext}[email]", $preferences[$key]['email'] ?? NULL ),
|
||||
'priority' => $ext::$itemPriority,
|
||||
);
|
||||
}
|
||||
@@ -147,7 +167,7 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach ( $rows as $group => $data )
|
||||
{
|
||||
$matrix->rows[] = \IPS\Member::loggedIn()->language()->addToStack("acp_notification_group_{$group}");
|
||||
$matrix->rows[] = Member::loggedIn()->language()->addToStack("acp_notification_group_{$group}");
|
||||
|
||||
uasort( $data['rows'], function( $a, $b ) {
|
||||
return $a['priority'] - $b['priority'];
|
||||
@@ -166,28 +186,29 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
$exploded = explode( '\\', $ext );
|
||||
$key = "{$exploded[1]}_{$exploded[5]}";
|
||||
|
||||
$v = \IPS\Request::i()->$ext;
|
||||
|
||||
\IPS\Db::i()->insert( 'core_acp_notifications_preferences', array(
|
||||
'member' => \IPS\Member::loggedIn()->member_id,
|
||||
$v = Request::i()->$ext;
|
||||
|
||||
/* @var AdminNotification $ext */
|
||||
Db::i()->insert( 'core_acp_notifications_preferences', array(
|
||||
'member' => Member::loggedIn()->member_id,
|
||||
'type' => $key,
|
||||
'view' => $ext::mayBeOptional() ? $_values['view'] : TRUE,
|
||||
'email' => isset( $v['email'] ) ? $v['email'] : 'never',
|
||||
'email' => $v['email'] ?? 'never',
|
||||
), TRUE );
|
||||
}
|
||||
|
||||
if( isset( \IPS\Data\Store::i()->acpNotificationIds ) )
|
||||
if( isset( Store::i()->acpNotificationIds ) )
|
||||
{
|
||||
$notificationCache = \IPS\Data\Store::i()->acpNotificationIds;
|
||||
unset( $notificationCache[ \IPS\Member::loggedIn()->member_id ] );
|
||||
\IPS\Data\Store::i()->acpNotificationIds = $notificationCache;
|
||||
$notificationCache = Store::i()->acpNotificationIds;
|
||||
unset( $notificationCache[ Member::loggedIn()->member_id ] );
|
||||
Store::i()->acpNotificationIds = $notificationCache;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('notification_options');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('forms')->blurb( 'acp_notifications_settings_blurb' ) . $matrix;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('notification_options');
|
||||
Output::i()->output = Theme::i()->getTemplate('forms')->blurb( 'acp_notifications_settings_blurb' ) . $matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,11 +216,11 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configurationErrorChecks()
|
||||
protected function configurationErrorChecks() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\core\extensions\core\AdminNotifications\ConfigurationError::runChecksAndSendNotifications();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
Session::i()->csrfCheck();
|
||||
ConfigurationError::runChecksAndSendNotifications();
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,15 +228,15 @@ class _notifications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeOrigTables()
|
||||
protected function removeOrigTables() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$tables = \IPS\Db::i()->getTables( 'orig_' . \IPS\Db::i()->prefix );
|
||||
\IPS\Task::queue( 'core', 'CleanupOrigTables', array( 'originalCount' => \count( $tables ) ), 5 );
|
||||
$tables = Db::i()->getTables( 'orig_' . Db::i()->prefix );
|
||||
Task::queue( 'core', 'CleanupOrigTables', array( 'originalCount' => count( $tables ) ), 5 );
|
||||
|
||||
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'origTables' );
|
||||
AdminNotification::remove( 'core', 'ConfigurationError', 'origTables' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user