1 | <?php |
||
11 | class ThreemaGateway_Model_ActionThrottle extends XenForo_Model |
||
12 | { |
||
13 | /** |
||
14 | * @var string database table name |
||
15 | */ |
||
16 | const DB_TABLE = 'xf_threemagw_action_throttle'; |
||
17 | |||
18 | /** |
||
19 | * Logs the fact that the user executed a particular action. |
||
20 | * |
||
21 | * @param int $userId |
||
22 | * @param string $actionType |
||
23 | */ |
||
24 | public function logAction($userId, $actionType) |
||
32 | |||
33 | /** |
||
34 | * Clears the whole action log for a particular action for a user. |
||
35 | * |
||
36 | * @param int $userId |
||
37 | * @param string $actionType |
||
38 | */ |
||
39 | public function clearActionLogForUser($userId, $actionType) |
||
46 | |||
47 | /** |
||
48 | * Returns the count of a specific action, which was executed by a particular |
||
49 | * user since a specific time. |
||
50 | * |
||
51 | * @param int $userId the affected user |
||
52 | * @param string $actionType describe the action to be count |
||
53 | * @param int $timeLimit the oldest date, where actions should be "cut off" |
||
54 | * |
||
55 | * @return int |
||
56 | */ |
||
57 | public function getActionsInTime($userId, $actionType, $timeLimit) |
||
67 | |||
68 | /** |
||
69 | * Checks whether a user is rate-limited concerning a specific action. |
||
70 | * |
||
71 | * @param int $userId the affected user |
||
72 | * @param string $actionType describe the action to be checked |
||
73 | * |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function isLimited($userId, $actionType) |
||
91 | |||
92 | /** |
||
93 | * Removes old action log entries. |
||
94 | * |
||
95 | * @param int $timeLimit the oldest date, where actions are saved |
||
96 | */ |
||
97 | public function pruneActionLog($timeLimit = null) |
||
107 | |||
108 | /** |
||
109 | * Returns the number of actions a user is allowed to do in an specific time. |
||
110 | * |
||
111 | * THe returned array has the format: |
||
112 | * [time, max number of actions to be executed] |
||
113 | * |
||
114 | * @param string $actionType |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | protected function getActionLimit($actionType) |
||
141 | } |
||
142 |