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

deleteGroup() public method

public deleteGroup ( integer $groupId, integer $newParent ) : boolean
$groupId integer
$newParent integer
return boolean
    public function deleteGroup(int $groupId, int $newParent = 0) : bool
    {
        $this->db->beginTransaction();
        $this->db->update('airship_groups', ['inherits' => $newParent > 0 ? $newParent : null], ['inherits' => $groupId]);
        $this->deleteGroupCascade($groupId);
        $this->db->delete('airship_groups', ['groupid' => $groupId]);
        // And finally...
        return $this->db->commit();
    }

Usage Example

Esempio n. 1
0
 /**
  * @param string $groupId
  * @route crew/groups/edit/{id}
  */
 public function deleteGroup(string $groupId = '')
 {
     $groupId = (int) $groupId;
     $group = $this->account->getGroup($groupId);
     $post = $this->post(new DeleteGroupFilter());
     if ($post) {
         if ($this->account->deleteGroup($groupId, $post['move_children'] ?? 0)) {
             \Airship\redirect($this->airship_cabin_prefix . '/crew/groups');
         }
     }
     $this->lens('crew/group_delete', ['active_link' => 'bridge-link-admin-crew-groups', 'group' => $group, 'allowed_parents' => $this->account->getGroupTree(0, 'children', [$groupId])]);
 }