Airship\Cabin\Bridge\Blueprint\Permissions::getActionNames PHP Method

getActionNames() public method

Get all action labels for a particular cabin.
public getActionNames ( string $cabin ) : array
$cabin string
return array
    public function getActionNames(string $cabin) : array
    {
        $return = [];
        $actions = $this->db->run('SELECT actionid, label FROM airship_perm_actions WHERE cabin = ?', $cabin);
        foreach ($actions as $act) {
            $return[(int) $act['actionid']] = $act['label'];
        }
        return $return;
    }

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]);
 }