1 | <?php |
||
8 | class PermissionsFaction { |
||
9 | //-------------------------- BUILDER ----------------------------------------------------------------------------// |
||
10 | //-------------------------- END BUILDER ----------------------------------------------------------------------------// |
||
11 | |||
12 | |||
13 | //-------------------------- GETTER ----------------------------------------------------------------------------// |
||
14 | /** |
||
15 | * @param $id_identite |
||
16 | * @param $id_faction |
||
17 | * @return bool |
||
18 | * permet de savoir si le joueur en question est le chef de la faction |
||
19 | */ |
||
20 | protected function getTestChefFaction($id_identite, $id_faction) { |
||
21 | $dbc = App::getDb(); |
||
22 | |||
23 | $query = $dbc->select("ID_identite")->from("_bataille_faction") |
||
24 | ->where("ID_identite", "=", $id_identite, "AND") |
||
25 | ->where("ID_faction", "=", $id_faction) |
||
26 | ->get(); |
||
27 | |||
28 | if (count($query) > 0) { |
||
29 | return true; |
||
30 | } |
||
31 | |||
32 | return false; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return int |
||
37 | * fonction qui renvoi le nombre de permissions |
||
38 | */ |
||
39 | private function getNombrePermissions() { |
||
40 | $dbc = App::getDb(); |
||
41 | |||
42 | $query = $dbc->select()->from("_bataille_faction_permissions")->get(); |
||
43 | |||
44 | return count($query); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return array |
||
49 | * fonction qui liste toutes les permissions |
||
50 | */ |
||
51 | public function getListPermissions() { |
||
52 | $dbc = App::getDb(); |
||
53 | |||
54 | $query = $dbc->select()->from("_bataille_faction_permissions")->get(); |
||
55 | |||
56 | $permissions = []; |
||
57 | if (count($query) > 0) { |
||
58 | foreach ($query as $obj) { |
||
59 | $permissions[] = str_replace("_", " ", $obj->permission); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | Bataille::setValues(["liste_permissions" => $permissions]); |
||
64 | return $permissions; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param $id_identite |
||
69 | * @param $id_faction |
||
70 | * @return array|string |
||
71 | * permet de récupérer les permissions d'un membre de la faction |
||
72 | */ |
||
73 | protected function getMembrePermissions($id_identite, $id_faction) { |
||
105 | |||
106 | /** |
||
107 | * @param $id_faction |
||
108 | * @return bool |
||
109 | * fonction qui renvoi les permission du membre connecté |
||
110 | */ |
||
111 | public function getPermissionsMembre($id_faction) { |
||
136 | //-------------------------- END GETTER ----------------------------------------------------------------------------// |
||
137 | |||
138 | |||
139 | //-------------------------- SETTER ----------------------------------------------------------------------------// |
||
140 | //-------------------------- END SETTER ----------------------------------------------------------------------------// |
||
141 | } |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.