Airship\Cabin\Bridge\Blueprint\UserAccounts::getUserAccount PHP Method

getUserAccount() public method

Get a user account given a user ID
public getUserAccount ( integer $userId, boolean $includeExtra = false ) : array
$userId integer
$includeExtra boolean
return array
    public function getUserAccount(int $userId, bool $includeExtra = false) : array
    {
        $user = $this->db->row('SELECT
                 *
             FROM
                 airship_users
             WHERE
                 userid = ?
             ', $userId);
        if (empty($user)) {
            return [];
        }
        if ($includeExtra) {
            $user['groups'] = $this->getUsersGroups($userId);
            if (!empty($user['custom_fields'])) {
                $user['custom_fields'] = \json_decode($user['custom_fields'], true);
            }
        }
        return $user;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @route crew/permissions/{string}/context/{id}
  *
  * @param string $cabin
  * @param string $contextId
  */
 public function editContext(string $cabin, string $contextId)
 {
     $contextId = (int) $contextId;
     if (!\in_array($cabin, $this->getCabinNamespaces())) {
         \Airship\redirect($this->airship_cabin_prefix . '/crew/permissions');
     }
     $context = $this->perms->getContext($contextId, $cabin);
     if (empty($context)) {
         \Airship\redirect($this->airship_cabin_prefix . '/crew/permissions' . $cabin);
     }
     // Handle post data
     $post = $this->post(new SaveContextFilter());
     if (!empty($post)) {
         if ($this->perms->saveContext($cabin, $contextId, $post)) {
             \Airship\redirect($this->airship_cabin_prefix . '/crew/permissions/' . $cabin . '/context/' . $contextId, ['msg' => 'saved']);
         }
     }
     // Okay,
     $actions = $this->perms->getActionNames($cabin);
     $groupPerms = $this->perms->buildGroupTree($cabin, $contextId, $actions);
     $userPerms = $this->perms->buildUserList($cabin, $contextId, $actions);
     $users = [];
     foreach ($userPerms as $userid => $userPerm) {
         $userid = (int) $userid;
         $users[$userid] = $this->users->getUserAccount($userid, true);
         unset($users[$userid]['password']);
     }
     if (!empty($_GET['msg'])) {
         if ($_GET['msg'] === 'saved') {
             $this->storeLensVar('message', \__('Your changes have been saved.'));
         }
     }
     $this->lens('perms/context', ['actions' => $actions, 'cabin' => $cabin, 'context' => $context, 'permissions' => $groupPerms, 'userperms' => $userPerms, 'users' => $users]);
 }
All Usage Examples Of Airship\Cabin\Bridge\Blueprint\UserAccounts::getUserAccount