/** * Set all the permissions on the user */ private function getPermissions() { if (!isset($this->permissions)) { $sql = 'SELECT P.plugin, P.key, P.id FROM ' . RolePermission::getTable() . ' RP INNER JOIN ' . Permission::getTable() . ' P ON RP.permissionId = P.id INNER JOIN ' . self::getTable() . ' U ON U.roleId = RP.roleId WHERE U.id = :id AND RP.value=1'; $permissions = App::db()->query($sql, array('id' => $this->id), array('return' => DB::RETURN_OBJECT)); $this->permissions = array(); foreach ($permissions as $permission) { // Register the permission by it id $this->permissions['byId'][$permission->id] = 1; // Regoster the permission by it name $this->permissions['byName'][$permission->plugin][$permission->key] = 1; } } }