public function __construct($source, $uid_shared_with, $permissions) {
$uid_owner = OCP\USER::getUser();
$query = OCP\DB::prepare("INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)");
+ // Check if this is a reshare and use the original source
+ if ($result = OC_Share::getSource($source)) {
+ $source = $result;
+ }
if ($uid_shared_with == self::PUBLICLINK) {
$token = sha1("$uid_shared_with-$source");
+ OCP\Util::emitHook('OC_Share', 'public', array('source'=>$source, 'token'=>$token, 'permissions'=>$permissions));
$query->execute(array($uid_owner, self::PUBLICLINK, $source, $token, $permissions));
$this->token = $token;
} else {
if (isset($gid)) {
$uid = $uid."@".$gid;
}
+ OCP\Util::emitHook('OC_Share', 'user', array('source'=>$source, 'target'=>$target, 'with'=>$uid, 'permissions'=>$permissions));
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
- // Add file to filesystem cache
- $userDirectory = "/".OCP\USER::getUser()."/files";
- $data = OC_Filecache::get(substr($source, strlen($userDirectory)));
- $parentQuery = OCP\DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?');
- $parentResult = $parentQuery->execute(array($sharedFolder))->fetchRow();
- $parent = $parentResult['id'];
- $is_writeable = $permissions & OC_Share::WRITE;
- $cacheQuery = OCP\DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
- $cacheQuery->execute(array($parent, basename($target), $target, $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], dirname($data['mimetype']), $uid, $is_writeable));
}
}
}