Listen to post_deleteGroup hook in Share API
This commit is contained in:
parent
dc569ea300
commit
4c065deb55
2 changed files with 13 additions and 0 deletions
|
@ -23,6 +23,7 @@ namespace OCP;
|
|||
\OC_Hook::connect('OC_User', 'post_deleteUser', 'OCP\Share', 'post_deleteUser');
|
||||
\OC_Hook::connect('OC_User', 'post_addToGroup', 'OCP\Share', 'post_addToGroup');
|
||||
\OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OCP\Share', 'post_removeFromGroup');
|
||||
\OC_Hook::connect('OC_User', 'post_deleteGroup', 'OCP\Share', 'post_deleteGroup');
|
||||
|
||||
/**
|
||||
* This class provides the ability for apps to share their content between users.
|
||||
|
@ -1069,6 +1070,14 @@ class Share {
|
|||
}
|
||||
}
|
||||
|
||||
public static function post_deleteGroup($arguments) {
|
||||
$query = \OC_DB::prepare('SELECT id FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?');
|
||||
$result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid']));
|
||||
while ($item = $result->fetchRow()) {
|
||||
self::delete($item['id']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -384,6 +384,10 @@ class Test_Share extends UnitTestCase {
|
|||
$this->assertEqual(OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET), array('test.txt'));
|
||||
|
||||
// Remove group
|
||||
OC_Group::deleteGroup($this->group1);
|
||||
$this->assertEqual(OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET), array());
|
||||
OC_User::setUserId($this->user3);
|
||||
$this->assertEqual(OCP\Share::getItemsShared('test'), array());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue