personPerm ( $id )
Source file: app/functions/person-function.php
Used by
Uses
- app/functions/global-function.php: _etsis_flash()
- app/functions/dependency.php: maybe_unserialize()
- app/functions/core-function.php: _escape()
Source
function personPerm($id) { $app = \Liten\Liten::getInstance(); try { $array = []; $pp = $app->db->person_perms() ->select('permission') ->where('personID = ?', $id); $q = $pp->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); foreach ($q as $r) { $array[] = $r; } $personPerm = maybe_unserialize(_escape($r['permission'])); /** * Select the role(s) of the person who's * personID = $id */ $array1 = []; $pr = $app->db->person_roles() ->select('roleID') ->where('personID = ?', $id); $q1 = $pr->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); foreach ($q1 as $r1) { $array1[] = $r1; } /** * Select all the permissions from the role(s) * that are connected to the selected person. */ $array2 = []; $role = $app->db->role() ->select('permission') ->where('id = ?', $r1['roleID']); $q2 = $role->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); foreach ($q2 as $r2) { $array2[] = $r2; } $perm = maybe_unserialize(_escape($r2['permission'])); $permission = $app->db->permission(); $sql = $permission->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); foreach ($sql as $row) { echo ' <tr> <td>' . _h($row['permName']) . '</td> <td class="text-center">'; if (is_array($perm) && in_array(_h($row['permKey']), $perm)) { echo '<input type="checkbox" name="permission[]" value="' . _h($row['permKey']) . '" checked="checked" disabled="disabled" />'; } elseif ($personPerm != '' && in_array(_h($row['permKey']), $personPerm)) { echo '<input type="checkbox" name="permission[]" value="' . _h($row['permKey']) . '" checked="checked" />'; } else { echo '<input type="checkbox" name="permission[]" value="' . _h($row['permKey']) . '" />'; } echo '</td> </tr>'; } } catch (NotFoundException $e) { Cascade::getLogger('error')->error($e->getMessage()); _etsis_flash()->error(_etsis_flash()->notice(409)); } catch (Exception $e) { Cascade::getLogger('error')->error($e->getMessage()); _etsis_flash()->error(_etsis_flash()->notice(409)); } catch (ORMException $e) { Cascade::getLogger('error')->error($e->getMessage()); _etsis_flash()->error(_etsis_flash()->notice(409)); } }
Expand full source code Collapse full source code View on Github