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,32 @@
|
||||
namespace IPS\{app}\extensions\core\AchievementAction;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Achievements\Actions\AchievementActionAbstract;
|
||||
use IPS\core\Achievements\Rule;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member as MemberClass;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
class {class} extends AchievementActionAbstract // 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
|
||||
* @param Url $url The URL the form is being shown on
|
||||
* @return array
|
||||
*/
|
||||
public function filters( ?array $filters, \IPS\Http\Url $url ): array
|
||||
public function filters( ?array $filters, Url $url ): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
@@ -52,12 +59,12 @@ class _{class} extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
* 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 MemberClass $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
|
||||
public function filtersMatch( MemberClass $subject, array $filters, mixed $extra = NULL ): bool
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -80,24 +87,24 @@ class _{class} extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
/**
|
||||
* Get the "other" people we need to award =stuff to
|
||||
*
|
||||
* @param array|NULL $filters Current filter values
|
||||
* @param mixed $extra Any additional information about what is happening (e.g. if a post is being made: the post object)
|
||||
* @param array|NULL $filters Current filter values
|
||||
* @return array
|
||||
*/
|
||||
// public function awardOther(?array $filters, $extra = NULL ): array
|
||||
// public function awardOther( mixed $extra = NULL, ?array $filters = NULL ): array
|
||||
// {
|
||||
// return [ \IPS\Member::loggedIn() ];
|
||||
// return [ MemberClass::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 MemberClass $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
|
||||
public function identifier( MemberClass $subject, mixed $extra = NULL ): string
|
||||
{
|
||||
return (string) $extra->id;
|
||||
}
|
||||
@@ -117,10 +124,10 @@ class _{class} extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
/**
|
||||
* Get "description" for rule
|
||||
*
|
||||
* @param \IPS\core\Achievements\Rule $rule The rule
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function ruleDescription( \IPS\core\Achievements\Rule $rule ): ?string
|
||||
public function ruleDescription( Rule $rule ): ?string
|
||||
{
|
||||
return "{class}";
|
||||
}
|
||||
@@ -130,7 +137,7 @@ class _{class} extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function rebuildData()
|
||||
static public function rebuildData(): array
|
||||
{
|
||||
// This method returns an array of tables that this extension uses to award achievements, so for example
|
||||
// the follow extension uses 'core_follow'.
|
||||
@@ -139,12 +146,12 @@ class _{class} extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
// 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 [ [
|
||||
return [ [
|
||||
// 'table' => 'table_name',
|
||||
// 'pkey' => 'field_id',
|
||||
// 'date' => 'field_date',
|
||||
// 'where' => [ [ 'banned != 1' ] ],
|
||||
//] ];
|
||||
] ];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,11 +161,11 @@ class _{class} extends \IPS\core\Achievements\Actions\AbstractAchievementAction
|
||||
* @param array $data Data collected when starting rebuild [table, pkey...]
|
||||
* @return void
|
||||
*/
|
||||
public static function rebuildRow( $row, $data )
|
||||
public static function rebuildRow( array $row, array $data ) : void
|
||||
{
|
||||
// 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'] ) );
|
||||
//MemberClass::loggedIn()->achievementAction( '{app}', '{class}', $row['field_id'] ), \IPS\DateTime::ts( $row['field_date'] ) );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user