go back to preUnshare hooks since sharing doesn't trigger post unshare hooks
This commit is contained in:
parent
9b49832090
commit
5a64c96d06
|
@ -16,8 +16,8 @@ OCP\Util::connectHook( 'OC_User', 'pre_setPassword','OCA\Encryption\Hooks', 'set
|
|||
|
||||
// Sharing-related hooks
|
||||
OCP\Util::connectHook( 'OCP\Share', 'post_shared', 'OCA\Encryption\Hooks', 'postShared' );
|
||||
OCP\Util::connectHook( 'OCP\Share', 'post_unshare', 'OCA\Encryption\Hooks', 'postUnshare' );
|
||||
OCP\Util::connectHook( 'OCP\Share', 'post_unshareAll', 'OCA\Encryption\Hooks', 'postUnshareAll' );
|
||||
OCP\Util::connectHook( 'OCP\Share', 'pre_unshare', 'OCA\Encryption\Hooks', 'preUnshare' );
|
||||
OCP\Util::connectHook( 'OCP\Share', 'pre_unshareAll', 'OCA\Encryption\Hooks', 'preUnshareAll' );
|
||||
|
||||
// Webdav-related hooks
|
||||
OCP\Util::connectHook( 'OC_Webdav_Properties', 'update', 'OCA\Encryption\Hooks', 'updateKeyfile' );
|
||||
|
|
|
@ -157,8 +157,6 @@ class Hooks {
|
|||
, \OC_Log::ERROR
|
||||
);
|
||||
|
||||
error_log( "Client side encryption is enabled but the client doesn't provide an encryption key for the file!" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -169,7 +167,7 @@ class Hooks {
|
|||
* @brief
|
||||
*/
|
||||
public static function postShared( $params ) {
|
||||
|
||||
error_log("post shared triggered!");
|
||||
// NOTE: $params is an array with these keys:
|
||||
// itemSource -> int, filecache file ID
|
||||
// shareWith -> string, uid of user being shared to
|
||||
|
@ -214,22 +212,27 @@ class Hooks {
|
|||
/**
|
||||
* @brief
|
||||
*/
|
||||
public static function postUnshare( $params ) {
|
||||
$shares = \OCP\Share::getUsersSharingFile( $params['fileTarget'], 1 );
|
||||
public static function preUnshare( $params ) {
|
||||
$items = \OCP\Share::getItemSharedWithBySource($params['itemType'], $params['itemSource']);
|
||||
$shares = \OCP\Share::getUsersSharingFile( $item[0]['file_target'], 1 );
|
||||
|
||||
$userIds = array();
|
||||
foreach ( $shares as $share ) {
|
||||
$userIds[] = $share['userId'];
|
||||
}
|
||||
|
||||
return Crypt::encKeyfileToMultipleUsers($userIDs, $params['fileTarget']);
|
||||
// remove the user from the list from which the file will be unshared
|
||||
unset($userIds[$params['shareWith']]);
|
||||
|
||||
return Crypt::encKeyfileToMultipleUsers($userIDs, $item[0]['file_target']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
public static function postUnshareAll( $params ) {
|
||||
return self::postUnshare($params);
|
||||
public static function preUnshareAll( $params ) {
|
||||
$items = \OCP\Share::getItemSharedWithBySource($params['itemType'], $params['itemSource']);
|
||||
return Crypt::encKeyfileToMultipleUsers(array($items[0]['uid_owner']), $items[0]['file_target']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue