Airship\Cabin\Bridge\Landing\Permissions::editContext PHP Method

editContext() public method

public editContext ( string $cabin, string $contextId )
$cabin string
$contextId string
    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]);
    }