aboutsummaryrefslogtreecommitdiffstats
path: root/php/database.php
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 16:05:31 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 16:05:31 +0200
commit511e0d45c6baf716557bd8cc4e0f1ba0de67953f (patch)
tree768e8b01d1349bd83bb5a805eb313146c5f1e06e /php/database.php
parentd72db6897c4eb6638fc43240181218f124958578 (diff)
parent0de674fabe319de356ee1254cb771ecdd194263b (diff)
downloadfileup-511e0d45c6baf716557bd8cc4e0f1ba0de67953f.tar.gz
Merge branch 'master' of https://github.com/alexvitkov/india
Diffstat (limited to 'php/database.php')
-rw-r--r--php/database.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/php/database.php b/php/database.php
index 668490a..74210eb 100644
--- a/php/database.php
+++ b/php/database.php
@@ -291,6 +291,7 @@ require_once "node.php";
we remove the node and
1. move the file represented by the node to the trash folder
2. remove the file
+ 3. if node is a directory - delete all children nodes
depends on the conf file
*/
function delete_node_by_id(int $node_id)
@@ -375,6 +376,37 @@ require_once "node.php";
}
}
+
+ function unlink_nodes(int $dir_id, int $node_id)
+ {
+ $prep=$this->pdo->prepare("delete from node_links
+ where directory_id=:dir_id and node_id=:node_id
+ ");
+ $prep->bindParam(':dir_id',$dir_id);
+ $prep->bindParam(':node_id',$node_id);
+ if($prep->execute()==false)
+ {
+ error_log("there was an error with the first statement in unlink_nodes");
+ return;
+ }
+ $prep=$this->pdo->prepare("select node_id
+ from node_links
+ where node_id=:id
+ ");
+ $prep->bindParam(':id',$node_id);
+ if($prep->execute()==false)
+ {
+ error_log("there was an error with the second statement in unlink_nodes");
+ return;
+ }
+ if(count($prep->fetchALL(PDO::FETCH_ASSOC))==0)
+ {
+ delete_node_by_id($node_id);
+ }
+
+
+ }
+
function create_home_directory():int
{
$ret=$this->create_dangling_directory();