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,25 +11,31 @@
|
||||
|
||||
namespace IPS\{app}\extensions\core\Notifications;
|
||||
|
||||
use IPS\Extensions\NotificationsAbstract;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member as MemberClass;
|
||||
use IPS\Notification\Inline;
|
||||
use function defined;
|
||||
|
||||
/* 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' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Options
|
||||
*/
|
||||
class _{class}
|
||||
class {class} extends NotificationsAbstract
|
||||
{
|
||||
/**
|
||||
* Get fields for configuration
|
||||
*
|
||||
* @param \IPS\Member|null $member The member (to take out any notification types a given member will never see) or NULL if this is for the ACP
|
||||
* @param MemberClass|null $member The member (to take out any notification types a given member will never see) or NULL if this is for the ACP
|
||||
* @return array
|
||||
*/
|
||||
public static function configurationOptions( \IPS\Member $member = NULL ): array
|
||||
public static function configurationOptions( ?MemberClass $member = NULL ): array
|
||||
{
|
||||
// Return an array defining each notification type, including the form elements necessary to allow its configuration
|
||||
|
||||
@@ -37,7 +43,7 @@ class _{class}
|
||||
'setting_key' => array(
|
||||
'type' => 'custom',
|
||||
'adminCanSetDefault'=> TRUE,
|
||||
'field' => \IPS\Helpers\Form\CheckboxSet( 'setting_key', $defaultValue, FALSE, /*...*/ ),
|
||||
'field' => new \IPS\Helpers\Form\CheckboxSet( 'setting_key', null, FALSE, /*...*/ ),
|
||||
'admin_lang' => array(
|
||||
'header' => 'header_lang_key',
|
||||
'title' => 'header_lang_title',
|
||||
@@ -46,7 +52,7 @@ class _{class}
|
||||
'other_setting_key' => array(
|
||||
'type' => 'custom',
|
||||
'adminCanSetDefault'=> FALSE,
|
||||
'field' => $formField,
|
||||
'field' => new \IPS\Helpers\Form\CheckboxSet( 'other_setting_key', null, false ),
|
||||
),
|
||||
'separator1' => array(
|
||||
'type' => 'separator',
|
||||
@@ -58,12 +64,12 @@ class _{class}
|
||||
/**
|
||||
* Save "extra" value
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member or NULL if this is the admin setting defaults
|
||||
* @param string $key The key
|
||||
* @param bool $value The value
|
||||
* @param MemberClass|NULL $member The member or NULL if this is the admin setting defaults
|
||||
* @param string $key The key
|
||||
* @param bool $value The value
|
||||
* @return void
|
||||
*/
|
||||
public static function saveExtra( ?\IPS\Member $member, $key, $value )
|
||||
public static function saveExtra( ?MemberClass $member, string $key, bool $value ) : void
|
||||
{
|
||||
// You can perform extra processing here to save values in a specific manner if needed
|
||||
}
|
||||
@@ -71,11 +77,11 @@ class _{class}
|
||||
/**
|
||||
* Disable all "extra" values for a particular type
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member or NULL if this is the admin setting defaults
|
||||
* @param string $method The method type
|
||||
* @param MemberClass|NULL $member The member or NULL if this is the admin setting defaults
|
||||
* @param string $method The method type
|
||||
* @return void
|
||||
*/
|
||||
public static function disableExtra( ?\IPS\Member $member, $method )
|
||||
public static function disableExtra( ?MemberClass $member, string $method ) : void
|
||||
{
|
||||
// You can disable extra values for a given type, such as if a setting means the notification preference is irrelevant
|
||||
}
|
||||
@@ -85,7 +91,7 @@ class _{class}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function resetExtra()
|
||||
public static function resetExtra() : void
|
||||
{
|
||||
// Any extra processing you may need to perform when resetting all members to default notification options.
|
||||
// Typically you won't have to do anything here unless you have custom settings
|
||||
@@ -97,29 +103,29 @@ class _{class}
|
||||
/**
|
||||
* Parse notification: key
|
||||
*
|
||||
* @param \IPS\Notification\Inline $notification The notification
|
||||
* @param bool $htmlEscape TRUE to escape HTML in title
|
||||
* @param Inline $notification The notification
|
||||
* @param bool $htmlEscape TRUE to escape HTML in title
|
||||
* @return array
|
||||
* @code
|
||||
return array(
|
||||
'title' => "Mark has replied to A Topic", // The notification title
|
||||
'url' => \IPS\Http\Url::internal( ... ), // The URL the notification should link to
|
||||
'url' => Url::internal( ... ), // The URL the notification should link to
|
||||
'content' => "Lorem ipsum dolar sit", // [Optional] Any appropriate content. Do not format this like an email where the text
|
||||
// explains what the notification is about - just include any appropriate content.
|
||||
// For example, if the notification is about a post, set this as the body of the post.
|
||||
'author' => \IPS\Member::load( 1 ), // [Optional] The user whose photo should be displayed for this notification
|
||||
'author' => MemberClass::load( 1 ), // [Optional] The user whose photo should be displayed for this notification
|
||||
);
|
||||
* @endcode
|
||||
*/
|
||||
public function parse_key( \IPS\Notification\Inline $notification, $htmlEscape=TRUE ): array
|
||||
public function parse_key( Inline $notification, bool $htmlEscape=TRUE ): array
|
||||
{
|
||||
return array(
|
||||
'title' => "Mark has replied to A Topic", // The notification title
|
||||
'url' => \IPS\Http\Url::internal( '' ), // The URL the notification should link to
|
||||
'url' => Url::internal( '' ), // The URL the notification should link to
|
||||
'content' => "Lorem ipsum dolar sit", // [Optional] Any appropriate content. Do not format this like an email where the text
|
||||
// explains what the notification is about - just include any appropriate content.
|
||||
// For example, if the notification is about a post, set this as the body of the post.
|
||||
'author' => \IPS\Member::load( 1 ), // [Optional] The user whose photo should be displayed for this notification
|
||||
'author' => MemberClass::load( 1 ), // [Optional] The user whose photo should be displayed for this notification
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user