From 80cd845b8177730a6dae27e847dc8951af3383de Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 12 Feb 2021 22:56:26 +0200 Subject: directory duplication error dealt with --- php/node.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'php/node.php') diff --git a/php/node.php b/php/node.php index b3b2c3f..c2ab5f1 100644 --- a/php/node.php +++ b/php/node.php @@ -43,9 +43,17 @@ require_once "user.php"; function create_directory(string $abstract_path,string $directory_name,string $note,User $user) { global $database; - $dir_id=$database->create_dangling_directory(); + $parent_dir_id=get_directory($abstract_path,$user); - $database->link_nodes($parent_dir_id,$dir_id,$directory_name,$note); + if($database->check_if_name_is_taken($directory_name,$parent_dir_id)) + { + return NULL; + }else + { + $dir_id=$database->create_dangling_directory(); + $database->link_nodes($parent_dir_id,$dir_id,$directory_name,$note); + return $dir_id; + } } ?> -- cgit v1.2.3