Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -13,9 +13,14 @@ namespace IPS\core\Achievements\Actions;
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\cloud\Quest;
|
||||
use IPS\core\Achievements\Rule;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function get_called_class;
|
||||
|
||||
@@ -42,6 +47,17 @@ abstract class AchievementActionAbstract
|
||||
return Application::appIsEnabled( $exploded[1] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this should be displayed in the ACP list.
|
||||
* We need to override this for some rules that should remain hidden
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function showInAcp() : bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filter form elements
|
||||
*
|
||||
@@ -51,7 +67,22 @@ abstract class AchievementActionAbstract
|
||||
*/
|
||||
public function filters( ?array $filters, Url $url ): array
|
||||
{
|
||||
return [];
|
||||
$return = [];
|
||||
|
||||
if( Bridge::i()->featureIsEnabled( 'quests' ) )
|
||||
{
|
||||
$classKey = explode( '\\', get_called_class() )[5];
|
||||
$questField = new Node( 'achievement_filter_quest_' . $classKey, $filters['quest'] ?? null, false, [
|
||||
'class' => Quest::class,
|
||||
'subnodes' => false,
|
||||
'multiple' => false,
|
||||
'showAllNodes' => true
|
||||
], null, Member::loggedIn()->language()->addToStack( 'achievement_filter_quest_prefix' ), null, 'achievement_filter_quest_' . $classKey );
|
||||
$questField->label = Member::loggedIn()->language()->addToStack( 'achievement_filter_quest' );
|
||||
$return['quest'] = $questField;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,6 +93,17 @@ abstract class AchievementActionAbstract
|
||||
*/
|
||||
public function formatFilterValues( array $values ): array
|
||||
{
|
||||
if( Bridge::i()->featureIsEnabled( 'quests' ) )
|
||||
{
|
||||
$classKey = explode( '\\', get_called_class() )[5];
|
||||
if( isset( $values['achievement_filter_quest_' . $classKey ] ) and $values['achievement_filter_quest_' . $classKey ] instanceof Quest )
|
||||
{
|
||||
return [
|
||||
'quest' => $values['achievement_filter_quest_' . $classKey ]->_id
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -81,6 +123,31 @@ abstract class AchievementActionAbstract
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get "description" for rule (usually a description of the rule's filters)
|
||||
*
|
||||
* @param Rule $rule The rule
|
||||
* @return string|NULL
|
||||
*/
|
||||
protected function _questFilterDescription( Rule $rule ): ?string
|
||||
{
|
||||
if ( isset( $rule->filters['quest'] ) and Bridge::i()->featureIsEnabled( 'quests' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$quest = Quest::load( $rule->filters['quest'] );
|
||||
return Member::loggedIn()->language()->addToStack( 'achievements_title_filter_quest', false, [
|
||||
'htmlsprintf' => [
|
||||
Theme::i()->getTemplate( 'achievements', 'core' )->ruleDescriptionBadge( 'quest', $quest->_title )
|
||||
]
|
||||
]);
|
||||
}
|
||||
catch( OutOfRangeException ){}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the labels for the people this action might give awards to
|
||||
@@ -107,6 +174,21 @@ abstract class AchievementActionAbstract
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the member has already completed this rule.
|
||||
* Used for retroactive rule completion.
|
||||
* So far, this is only used in Quests, but may be used elsewhere at a later point.
|
||||
*
|
||||
* @param Member $member
|
||||
* @param array $filters
|
||||
* @return bool
|
||||
*/
|
||||
public function isRuleCompleted( Member $member, array $filters ) : bool
|
||||
{
|
||||
/* Default to false, so that any other rules would have to be completed again. */
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier to prevent the member being awarded points for the same action twice
|
||||
|
||||
Reference in new issue
Block a user