don't handle public share keys in lib/public/share.php but in apps/files_encryption/lib/util.php instead

This commit is contained in:
Björn Schießle 2013-05-13 17:40:57 +02:00
parent 517efdf952
commit aa3eb6bb5b
2 changed files with 20 additions and 16 deletions

View File

@ -109,6 +109,7 @@ class Util {
private $publicKeyPath; // Path to user's public key
private $privateKeyPath; // Path to user's private key
private $publicShareKeyId;
private $recoveryKeyId;
public function __construct( \OC_FilesystemView $view, $userId, $client = false ) {
@ -125,6 +126,7 @@ class Util {
$this->publicKeyPath = $this->publicKeyDir . '/' . $this->userId . '.public.key'; // e.g. data/public-keys/admin.public.key
$this->privateKeyPath = $this->encryptionDir . '/' . $this->userId . '.private.key'; // e.g. data/admin/admin.private.key
$this->publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId');
$this->recoveryKeyId = \OC_Appconfig::getValue('files_encryption', 'recoveryKeyId');
}
public function ready() {
@ -798,6 +800,7 @@ class Util {
// public system user 'ownCloud' (for public shares)
if (
$user == $this->publicShareKeyId
or $user == $this->recoveryKeyId
or $util->ready()
) {
@ -949,7 +952,11 @@ class Util {
if ( $sharingEnabled ) {
// Find out who, if anyone, is sharing the file
$userIds = \OCP\Share::getUsersSharingFile( $ownerPath, $owner,true, true, true );
$result = \OCP\Share::getUsersSharingFile( $ownerPath, $owner,true, true, true );
$userIds = $result['users'];
if ( $result['public'] ) {
$userIds[] = $this->publicShareKeyId;
}
}

View File

@ -138,6 +138,7 @@ class Share {
$path_parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
$path = '';
$shares = array();
$publicShare = false;
$view = new \OC\Files\View('/' . $user . '/files/');
foreach ($path_parts as $p) {
$path .= '/' . $p;
@ -184,27 +185,23 @@ class Share {
$shares = array_merge($shares, $usersInGroup);
}
$publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId');
if ($publicShareKeyId) {
//check for public link shares
$query = \OC_DB::prepare(
'SELECT share_with
//check for public link shares
$query = \OC_DB::prepare(
'SELECT share_with
FROM
`*PREFIX*share`
WHERE
item_source = ? AND share_type = ?'
);
);
$result = $query->execute(array($source, self::SHARE_TYPE_LINK));
$result = $query->execute(array($source, self::SHARE_TYPE_LINK));
if (\OC_DB::isError($result)) {
\OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
}
if (\OC_DB::isError($result)) {
\OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
}
if ($result->fetchRow()) {
$shares[] = $publicShareKeyId;
}
if ($result->fetchRow()) {
$publicShare = true;
}
}
// Include owner in list of users, if requested
@ -212,7 +209,7 @@ class Share {
$shares[] = $user;
}
return array_unique($shares);
return array("users" => array_unique($shares), "public" => $publicShare);
}
/**