public function createDir(string $cabin, string $path, array $post = []) : bool
{
if (empty($post['url'])) {
return false;
}
$this->db->beginTransaction();
// Get the ID for the parent directory
if (!empty($path)) {
$directory_id = $this->getParentDirFromStr($path, $cabin);
$count = $this->db->cell('SELECT count(*) FROM airship_custom_dir WHERE cabin = ? AND parent = ? AND url = ?', $cabin, $directory_id, $post['url']);
} else {
$directory_id = null;
$count = $this->db->cell('SELECT count(*) FROM airship_custom_dir WHERE cabin = ? AND parent IS NULL AND url = ?', $cabin, $post['url']);
}
if ($count > 0) {
// already exists
return false;
}
$this->db->insert('airship_custom_dir', ['cabin' => $cabin, 'parent' => $directory_id, 'url' => $post['url'], 'active' => true]);
return $this->db->commit();
}