aboutsummaryrefslogtreecommitdiffstats
path: root/php/node.php
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-02-14 11:58:31 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-02-14 11:58:31 +0200
commitcd872e6ed818761fc52a828c3af67ae44cfc9fe1 (patch)
treeb5d571ce5972267ba2edef68b22871fffcdbeebc /php/node.php
parent67a6b658b4ed300743292e99bb8d2a955ced24b3 (diff)
parent8c5e2a88177786da775deb551ea24cca26a686a2 (diff)
downloadfileup-cd872e6ed818761fc52a828c3af67ae44cfc9fe1.tar.gz
Merge branch 'master' of https://github.com/alexvitkov/india
Diffstat (limited to 'php/node.php')
-rw-r--r--php/node.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/php/node.php b/php/node.php
index c86beae..0593211 100644
--- a/php/node.php
+++ b/php/node.php
@@ -76,7 +76,8 @@ require_once "user.php";
$parent_dir_id=get_directory($abstract_path,$user);
$database->unlink_nodes($parent_dir_id,$filename);
}
- function create_share_link(string $abstract_path,string $filename,string $password,User $user,bool $can_read,bool $can_write)
+ function create_share_link(string $abstract_path,string $filename,string $password,
+ User $user,bool $can_read,bool $can_write,$users)
{
global $database;
global $domain_name;
@@ -98,10 +99,27 @@ require_once "user.php";
return NULL;
}
- if($can_read)
- $database->give_view_access($node_id,$user->user_id);
- if($can_write)
- $database->give_edit_access($node_id,$user->user_id);
+ $usernames=explode(',',$users);
+ foreach($usernames as $username)
+ {
+ $usr=$database->get_user($username);
+ if($usr==NULL)
+ continue;
+ error_log("sharing with $usr->username");
+
+ if($can_read)
+ $database->give_view_access($node_id,$usr->user_id);
+ if($can_write)
+ $database->give_edit_access($node_id,$usr->user_id);
+
+ error_log("home directory is $usr->home_directory");
+ $share_id=$database->get_node_id("share",$usr->home_directory);
+ if($share_id==NULL)
+ {
+ error_log("could not find share directory for $username");
+ }
+ $database->link_nodes($share_id,$node_id,$filename,"this was shared to you");
+ }
if($use_https)
{
return "https://".$domain_name."/php/share.php?file=".$shared_node->code;