Get shared items working

This commit is contained in:
brantje 2016-10-02 19:29:06 +02:00
parent a4c1185fe8
commit 2baae50691
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
5 changed files with 11 additions and 7 deletions

View file

@ -211,7 +211,7 @@ class ShareController extends ApiController {
* @NoAdminRequired
*/
public function getVaultItems($vault_guid){
$this->shareService->getSharedItems($this->userId->getUID(), $vault_guid);
return new JSONResponse($this->shareService->getSharedItems($this->userId->getUID(), $vault_guid));
}
public function deleteShareRequest($share_request_id){

View file

@ -48,8 +48,12 @@ class CredentialMapper extends Mapper {
$sql = 'SELECT * FROM `*PREFIX*passman_credentials` ' .
'WHERE `id` = ?';
// If we want to check the owner, add it to the query
if ($user_id !== null) $sql .= ' and `user_id` = ? ';
return $this->findEntity($sql,[$credential_id, $user_id]);
$params = [$credential_id];
if ($user_id !== null){
$sql .= ' and `user_id` = ? ';
array_push($params, $user_id);
}
return $this->findEntity($sql,$params);
}
public function getCredentialLabelById($credential_id){

View file

@ -18,7 +18,7 @@ use OCP\AppFramework\Db\Entity;
* @method void setItemGuid(string $value)
* @method string getItemGuid()
* @method void setUserId(string $value)
* @method string getUserid()
* @method string getUserId()
* @method void setCreated(integer $value)
* @method integer getCreated()
* @method void setExpire(integer $value)
@ -69,8 +69,7 @@ class SharingACL extends PermissionEntity implements \JsonSerializable
'acl_id' => $this->getId(),
'item_id' => $this->getItemId(),
'item_guid' => $this->getItemGuid(),
'user_id' => $this->getUserid(),
'group_id' => $this->getGroupId(),
'user_id' => $this->getUserId(),
'created' => $this->getCreated(),
'expire' => $this->getExpire(),
'permissions' => $this->getPermissions(),

View file

@ -42,7 +42,7 @@ class SharingACLMapper extends Mapper {
* Gets the currently accepted share requests from the given user for the given vault guid
* @param $user_id
* @param $vault_id
* @return SharingACL[]
*
*/
public function getVaultEntries($user_id, $vault_id) {
$q = "SELECT * FROM ". self::TABLE_NAME ." WHERE user_id = ? AND vault_guid = ?";

View file

@ -95,6 +95,7 @@ class ShareService {
public function getSharedItems($user_id, $vault_guid){
$entries = $this->sharingACL->getVaultEntries($user_id, $vault_guid);
$return = [];
foreach ($entries as $entry){
$tmp = $entry->jsonSerialize();