rolePerm ( $id )

Source file: app/functions/person-function.php

View source


Used by


Source

function rolePerm($id)
{
    $app = \Liten\Liten::getInstance();
    try {
        $role = $app->db->role()
            ->select('permission')
            ->where('id = ?', $id);
        $q1 = $role->find(function ($data) {
            $array = [];
            foreach ($data as $d) {
                $array[] = $d;
            }
            return $array;
        });
        foreach ($q1 as $v) {
            $perm = maybe_unserialize(_escape($v['permission']));
        }
        $sql = $app->db->permission();
        $q2 = $sql->find(function ($data) {
            $array = [];
            foreach ($data as $d) {
                $array[] = $d;
            }
            return $array;
        });
        foreach ($q2 as $r) {
            echo '
				<tr>
					<td>' . _h($r['permName']) . '</td>
					<td class="text-center">';
            if (is_array($perm) && in_array(_h($r['permKey']), $perm)) {
                echo '<input type="checkbox" name="permission[]" value="' . _h($r['permKey']) . '" checked="checked" />';
            } else {
                echo '<input type="checkbox" name="permission[]" value="' . _h($r['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));
    }
}


User Contributed Notes

You must log in before being able to contribute a note.