-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
abstract class Q2A_Plugin_AbstractPointModule implements Q2A_Plugin_IPointModule | ||
{ | ||
/** | ||
* Return the amount of points that the module expects to change for the given user id. This default implementation | ||
* just calls the getPointsForUsers() function wrapping the given user id as the only user in the array. It can be | ||
* overridden in subclasses | ||
* | ||
* @param int|string $userId The user id | ||
* | ||
* @return int The number of points that the module should change for the given user | ||
*/ | ||
public function getPointsForUser($userId) | ||
{ | ||
$userIdPoints = $this->getPointsForUsers(array($userId)); | ||
|
||
return reset($userIdPoints); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
interface Q2A_Plugin_IPointModule | ||
{ | ||
/** | ||
* Return the amount of points that the module expects to change for the given user id | ||
* | ||
* @param int|string $userId The user id | ||
* | ||
* @return int The number of points that the module should change for the given user | ||
*/ | ||
public function getPointsForUser($userId); | ||
|
||
/** | ||
* Return the amount of points that the module expects to change for the given array of user ids | ||
* | ||
* @param array $userIds The array of user ids | ||
* | ||
* @return array The array containing as keys the user ids and as values the amount of points to change | ||
*/ | ||
public function getPointsForUsers($userIds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters