Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 22 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| MySqlAuthLoader | |
0.00% |
0 / 22 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| fetchUserAuthHook | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
| fetchGroupAuthHook | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace UserFrosting; |
| 4 | |
| 5 | /* This class is responsible for retrieving user and group authorization object(s) from the database, etc. */ |
| 6 | |
| 7 | class MySqlAuthLoader extends MySqlDatabase { |
| 8 | |
| 9 | public static function fetchUserAuthHook($user_id, $hook){ |
| 10 | $db = static::connection(); |
| 11 | $table = static::getTable('authorize_user')->name; |
| 12 | |
| 13 | $query = "SELECT * FROM `$table` WHERE user_id = :user_id AND hook = :hook LIMIT 1"; |
| 14 | |
| 15 | $stmt = $db->prepare($query); |
| 16 | |
| 17 | $sqlVars[':user_id'] = $user_id; |
| 18 | $sqlVars[':hook'] = $hook; |
| 19 | |
| 20 | $stmt->execute($sqlVars); |
| 21 | |
| 22 | $results = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 23 | |
| 24 | // Return an empty collection if nothing is found |
| 25 | if ($results) |
| 26 | return $results; |
| 27 | else |
| 28 | return []; |
| 29 | } |
| 30 | |
| 31 | public static function fetchGroupAuthHook($group_id, $hook){ |
| 32 | $db = self::connection(); |
| 33 | $table = static::getTable('authorize_group')->name; |
| 34 | |
| 35 | $query = "SELECT * FROM `$table` WHERE group_id = :group_id AND hook = :hook LIMIT 1"; |
| 36 | |
| 37 | $stmt = $db->prepare($query); |
| 38 | |
| 39 | $sqlVars[':group_id'] = $group_id; |
| 40 | $sqlVars[':hook'] = $hook; |
| 41 | |
| 42 | $stmt->execute($sqlVars); |
| 43 | |
| 44 | $results = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 45 | |
| 46 | // Return an empty collection if nothing is found |
| 47 | if ($results) |
| 48 | return $results; |
| 49 | else |
| 50 | return []; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | ?> |