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

editGroup() public method

Edit a group.
public editGroup ( integer $groupId, array $post = [] ) : boolean
$groupId integer
$post array
return boolean
    public function editGroup(int $groupId, array $post = []) : bool
    {
        if (\in_array($post['parent'], $this->getGroupChildren($groupId))) {
            return false;
        }
        $this->db->beginTransaction();
        $this->db->update('airship_groups', ['name' => $post['name'], 'inherits' => !empty($post['parent']) ? $post['parent'] : null, 'superuser' => !empty($post['superuser'])], ['groupid' => $groupId]);
        return $this->db->commit();
    }

Usage Example

Example #1
0
 /**
  * Edit a group's information
  *
  * @route crew/groups/edit/{id}
  * @param string $groupId
  */
 public function editGroup(string $groupId = '')
 {
     $groupId = (int) $groupId;
     $post = $this->post(new EditGroupFilter());
     if (!empty($post)) {
         if ($this->account->editGroup($groupId, $post)) {
             \Airship\redirect($this->airship_cabin_prefix . '/crew/groups');
         }
     }
     $this->lens('crew/group_edit', ['active_link' => 'bridge-link-admin-crew-groups', 'group' => $this->account->getGroup($groupId), 'allowed_parents' => $this->account->getGroupTree(0, 'children', [$groupId])]);
 }