mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Update sharing when users are removed, added to groups, and removed from groups
This commit is contained in:
parent
de135e3b9b
commit
32de47d1d9
2 changed files with 31 additions and 0 deletions
|
|
@ -7,6 +7,9 @@ OC_APP::registerAdmin('files_sharing', 'settings');
|
|||
OC_Hook::connect("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
|
||||
OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
|
||||
OC_Hook::connect("OC_Filesystem", "post_write", "OC_Share", "updateItem");
|
||||
OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_Share', 'removeUser');
|
||||
OC_Hook::connect('OC_User', 'post_addToGroup', 'OC_Share', 'addToGroupShare');
|
||||
OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OC_Share', 'removeFromGroupShare');
|
||||
$dir = isset($_GET['dir']) ? $_GET['dir'] : '/';
|
||||
if ($dir != '/Shared' || OC_Appconfig::getValue('files_sharing', 'resharing', 'yes') == 'yes') {
|
||||
OC_Util::addScript("files_sharing", "share");
|
||||
|
|
|
|||
|
|
@ -436,6 +436,34 @@ class OC_Share {
|
|||
}
|
||||
}
|
||||
|
||||
public static function removeUser($arguments) {
|
||||
$query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_owner = ? OR uid_shared_with '.self::getUsersAndGroups($arguments['uid']));
|
||||
$query->execute(array($arguments['uid']));
|
||||
}
|
||||
|
||||
public static function addToGroupShare($arguments) {
|
||||
$length = -strlen($arguments['gid']) - 1;
|
||||
$query = OC_DB::prepare('SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE SUBSTR(uid_shared_with, '.$length.') = ?');
|
||||
$gid = '@'.$arguments['gid'];
|
||||
$result = $query->execute(array($gid))->fetchAll();
|
||||
if (count($result) > 0) {
|
||||
$query = OC_DB::prepare('INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)');
|
||||
$sharedFolder = '/'.$arguments['uid'].'/files/Shared/';
|
||||
$lastSource = '';
|
||||
for ($i = 0; i < count($result); $i++) {
|
||||
if ($result[$i]['source'] != $lastSource) {
|
||||
$query->execute(array($result[$i]['uid_owner'], $arguments['uid'].'@'.$arguments['gid'], $result[$i]['source'], $sharedFolder.basename($result[$i]['source']), $result[$i]['permissions']));
|
||||
$lastSource = $result[$i]['source'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function removeFromGroupShare($arguments) {
|
||||
$query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_shared_with = ?');
|
||||
$query->execute(array($arguments['uid'].'@'.$arguments['gid']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue