utils = $utils; } public function createRequest(ShareRequest $request){ return $this->insert($request); } /** * Obtains a request by the given item and vault GUID pair * @param $item_guid * @param $target_vault_guid * @return ShareRequest */ public function getRequestByGuid($item_guid, $target_vault_guid){ $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . " WHERE item_guid = ? AND target_vault_guid = ?"; return $this->findEntity($q, [$item_guid, $target_vault_guid]); } public function cleanItemRequestsForUser($item_id, $target_user_id){ $q = "DELETE FROM *PREFIX*" . self::TABLE_NAME . " WHERE item_id = ? AND target_user_id = ?"; $this->execute($q, [$item_id, $target_user_id]); return $this->execute($q, [$item_id, $target_user_id]); } /** * Obtains all pending share requests for the given user ID * @param $user_id * @return ShareRequest[] */ public function getUserPendingRequests($user_id){ $q = "SELECT * FROM *PREFIX*". self::TABLE_NAME ." WHERE target_user_id = ?"; return $this->findEntities($q, [$user_id]); } public function deleteShareRequest(ShareRequest $shareRequest){ $this->delete($shareRequest); } public function getShareRequestById($id){ $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . " WHERE id = ?"; return $this->findEntity($q, [$id]); } public function getShareRequestsByGuid($item_guid){ $q = "SELECT * FROM *PREFIX*" . self::TABLE_NAME . " WHERE item_guid = ?"; return $this->findEntities($q, [$item_guid]); } }