Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

@@ -0,0 +1,163 @@
<?php
/**
* @brief Achievement Action Extension
* @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/
{subpackage}
* @since {date}
*/
namespace IPS\{app}\extensions\core\AchievementAction;
/* 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;
}
/**
* Achievement Action Extension
*/
class _{class} extends \IPS\core\Achievements\Actions\AbstractAchievementAction // NOTE: Other classes exist to provided bases for common situations, like where node-based filters will be required
{
/**
* Get filter form elements
*
* @param array|NULL $filters Current filter values (if editing)
* @param \IPS\Http\Url $url The URL the form is being shown on
* @return array
*/
public function filters( ?array $filters, \IPS\Http\Url $url ): array
{
return [];
}
/**
* Format filter form values
*
* @param array $values The values from the form
* @return array
*/
public function formatFilterValues( array $values ): array
{
return [];
}
/**
* Work out if the filters applies for a given action
*
* Important note for milestones: consider the context. This method is called by \IPS\Member::achievementAction(). If your code
* calls that BEFORE making its change in the database (or there is read/write separation), you will need to add
* 1 to the value being considered for milestones
*
* @param \IPS\Member $subject The subject member
* @param array $filters The value returned by formatFilterValues()
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
* @return bool
*/
public function filtersMatch( \IPS\Member $subject, array $filters, $extra = NULL ): bool
{
return TRUE;
}
/**
* Get the labels for the people this action might give awards to
*
* @return array
*/
// You don't need to implement this if your action only gives points to the subject
// public function awardOptions(): array
// {
// return [
// 'subject' => 'achievement_filter_{class}_receiver',
// 'other' => 'achievement_filter_{class}_giver'
// ];
// }
/**
* Get the "other" people we need to award =stuff to
*
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
* @return array
*/
// You don't need to implement this if your action only gives points to the subject
// public function awardOther( $extra = NULL ): array
// {
// return [ \IPS\Member::loggedIn() ];
// }
/**
* Get identifier to prevent the member being awarded points for the same action twice
* Must be unique within within of this domain, must not exceed 32 chars.
*
* @param \IPS\Member $subject The subject member
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
* @return string
*/
public function identifier( \IPS\Member $subject, $extra = NULL ): string
{
return (string) $extra->id;
}
/**
* Return a description for this action to show in the log
*
* @param string $identifier The identifier as returned by identifier()
* @param array $actor If the member was the "subject", "other", or both
* @return string
*/
public function logRow( string $identifier, array $actor ): string
{
return "{class}";
}
/**
* Get "description" for rule
*
* @param \IPS\core\Achievements\Rule $rule The rule
* @return string|NULL
*/
public function ruleDescription( \IPS\core\Achievements\Rule $rule ): ?string
{
return "{class}";
}
/**
* Get rebuild data
*
* @return array
*/
static public function rebuildData()
{
// This method returns an array of tables that this extension uses to award achievements, so for example
// the follow extension uses 'core_follow'.
// We also need to know the primary key for this table. It should be unique but does not need to be an integer
// The date is optional but useful if available for those that want to partially rebuild.
// Where shouldn't attempt to limit based on filters or milestones, but just remove data that you don't need to
// look at, such as banned members, archived items and so on. You can return an empty array if you do not need
// a where statement.
//return [ [
// 'table' => 'table_name',
// 'pkey' => 'field_id',
// 'date' => 'field_date',
// 'where' => [ [ 'banned != 1' ] ],
//] ];
}
/**
* Process the rebuild row
*
* @param array $row Row from database
* @param array $data Data collected when starting rebuild [table, pkey...]
* @return void
*/
public static function rebuildRow( $row, $data )
{
// This method runs the achievementAction on the table row from the table (or tables) you specified in rebuildData()
// You are welcome to load any classes, etc you need here.
//IPS\Member::loggedIn()->achievementAction( '{app}', '{class}', $row['field_id'] ), \IPS\DateTime::ts( $row['field_date'] ) );
}
}
@@ -24,21 +24,72 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class _{class}
{
/**
* Get configuration
* Get fields for configuration
*
* @param \IPS\Member $member The member
* @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
* @return array
*/
public function getConfiguration( $member )
public static function configurationOptions( \IPS\Member $member = NULL )
{
// Basically just return a list of the keys for the types of notification your app will send
// keys can be anything you want. You can specify what should be the default value and any disabled values (acceptable values are "email" and "inline")
// For each key, create a language string "notifications__<key>" which is what will display in the user's Notification Options screen
// Return an array defining each notification type, including the form elements necessary to allow its configuration
return array(
'key' => array( 'default' => array( 'inline', 'push' ), 'disabled' => array() ),
'setting_key' => array(
'type' => 'custom',
'adminCanSetDefault'=> TRUE,
'field' => \IPS\Helpers\Form\CheckboxSet( 'setting_key', $defaultValue, FALSE, /*...*/ ),
'admin_lang' => array(
'header' => 'header_lang_key',
'title' => 'header_lang_title',
),
),
'other_setting_key' => array(
'type' => 'custom',
'adminCanSetDefault'=> FALSE,
'field' => $formField,
),
'separator1' => array(
'type' => 'separator',
),
//...
);
}
/**
* 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
* @return void
*/
public static function saveExtra( ?\IPS\Member $member, $key, $value )
{
// You can perform extra processing here to save values in a specific manner if needed
}
/**
* 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
* @return void
*/
public static function disableExtra( ?\IPS\Member $member, $method )
{
// You can disable extra values for a given type, such as if a setting means the notification preference is irrelevant
}
/**
* Reset "extra" value to the default for all accounts
*
* @return void
*/
public static function resetExtra()
{
// 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
}
// For each type of notification you need a method like this which controls what will be displayed when the user clicks on the notification icon in the header:
// Note that for each type of notification you must *also* create email templates. See documentation for details: https://remoteservices.invisionpower.com/docs/devdocs-notifications
@@ -47,6 +98,7 @@ class _{class}
* Parse notification: key
*
* @param \IPS\Notification\Inline $notification The notification
* @param bool $htmlEscape TRUE to escape HTML in title
* @return array
* @code
return array(
@@ -59,7 +111,7 @@ class _{class}
);
* @endcode
*/
public function parse_key( \IPS\Notification\Inline $notification )
public function parse_key( \IPS\Notification\Inline $notification, $htmlEscape=TRUE )
{
return array(
'title' => "Mark has replied to A Topic", // The notification title
@@ -43,18 +43,6 @@ class _{class}
{
}
/**
* Code to execute when other applications are uninstalled
*
* @param string $application Application directory
* @return void
* @deprecated This is here for backwards-compatibility - all new code should go in onOtherUninstall
*/
public function onOtherAppUninstall( $application )
{
return $this->onOtherUninstall( $application );
}
/**
* Code to execute when other applications or plugins are uninstalled
*