Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2012-04-26 02:18:19 +0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2012-04-26 02:18:58 +0400
commit32de47d1d91fe95f346c97cf962e10176c1545dc (patch)
tree97a17a3c6437f747eed707fe9df1bb359f01221b /apps/files_sharing
parentde135e3b9bdcb58358b872003fd1e98f51554912 (diff)
Update sharing when users are removed, added to groups, and removed from groups
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/appinfo/app.php3
-rw-r--r--apps/files_sharing/lib_share.php28
2 files changed, 31 insertions, 0 deletions
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 117b65d754f..645f4f5e4f2 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -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");
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index 673984f393b..84def87963a 100644
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -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']));
+ }
+
}
?>