@@ -41,6 +41,9 @@ public function __construct()
41
41
*/
42
42
public function getGroupRolesByUser (int $ userId , false |string $ moduleName = false ): array
43
43
{
44
+ if ($ userId == 0 )
45
+ return [];
46
+
44
47
$ query = $ this ->db ->table ('acl_group_roles agr ' )
45
48
->select ('agr.role_name, agr.module ' )
46
49
->join ('acl_account_groups aag ' , 'aag.group_id = agr.group_id ' , 'inner ' )
@@ -116,6 +119,9 @@ public function getAccountRolesPermissions(int $userId = 0, int $default_group =
116
119
*/
117
120
public function getAccountPermissions (int $ userId ): array
118
121
{
122
+ if ($ userId == 0 )
123
+ return [];
124
+
119
125
$ query = $ this ->db ->table ('acl_account_permissions ' )->select ("account_id, permission_name, module, value " )->where ("account_id " , $ userId )->get ();
120
126
121
127
return $ query ->getResultArray () ?? [];
@@ -130,6 +136,9 @@ public function getAccountPermissions(int $userId): array
130
136
*/
131
137
public function getAccountRoles (int $ userId , false |string $ module = false ): array
132
138
{
139
+ if ($ userId == 0 )
140
+ return [];
141
+
133
142
$ builder = $ this ->db ->table ('acl_account_roles ' )->select ("role_name " )->where ("account_id " , $ userId );
134
143
135
144
if ($ module ) {
@@ -151,6 +160,9 @@ public function getGroupsByUser(false|int $accountId = false): array
151
160
$ accountId = $ this ->user ->getId ();
152
161
}
153
162
163
+ if ($ accountId == 0 )
164
+ return [];
165
+
154
166
$ builder = $ this ->db ->table ("acl_account_groups aag, acl_groups ag " );
155
167
$ builder ->select ("ag.id, ag.priority, ag.name, ag.color, ag.color " );
156
168
$ builder ->where ("aag.account_id " , $ accountId );
0 commit comments