mirror of
https://github.com/nextcloud/passman.git
synced 2026-01-09 09:05:21 +08:00
Get shared items working
This commit is contained in:
parent
a4c1185fe8
commit
2baae50691
5 changed files with 11 additions and 7 deletions
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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 = ?";
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue