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

deleteUser() public method

public deleteUser ( integer $userId ) : boolean
$userId integer
return boolean
    public function deleteUser(int $userId) : bool
    {
        $this->db->beginTransaction();
        // To avoid deleting files unnecessarily...
        $this->db->update('airship_files', ['uploaded_by' => null], ['uploaded_by' => $userId]);
        // Cascade-delete all foreign keys:
        $this->deleteUserCascade($userId);
        // Actually delete the user account:
        $this->db->delete('airship_users', ['userid' => $userId]);
        // And finally...
        return $this->db->commit();
    }

Usage Example

コード例 #1
0
ファイル: Crew.php プロジェクト: paragonie/airship
 /**
  * @param string $userId
  * @route crew/users/edit/{id}
  */
 public function deleteUser(string $userId = '')
 {
     $userId = (int) $userId;
     $user = $this->account->getUserAccount($userId, true);
     $post = $this->post(new DeleteUserFilter());
     if ($post) {
         if ($this->account->deleteUser($userId)) {
             \Airship\redirect($this->airship_cabin_prefix . '/crew/users');
         }
     }
     $this->lens('crew/user_delete', ['active_link' => 'bridge-link-admin-crew-users', 'user' => $user]);
 }