nextcloud/apps/files_sharing/lib/external/cache.php

51 lines
1.3 KiB
PHP
Raw Normal View History

2014-04-29 17:14:48 +04:00
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
2014-04-29 17:14:48 +04:00
*/
2014-04-29 17:14:48 +04:00
namespace OCA\Files_Sharing\External;
class Cache extends \OC\Files\Cache\Cache {
private $remote;
private $remoteUser;
private $storage;
/**
* @param \OCA\Files_Sharing\External\Storage $storage
* @param string $remote
* @param string $remoteUser
*/
public function __construct($storage, $remote, $remoteUser) {
$this->storage = $storage;
list(, $remote) = explode('://', $remote, 2);
$this->remote = $remote;
$this->remoteUser = $remoteUser;
parent::__construct($storage);
}
public function get($file) {
$result = parent::get($file);
2015-01-21 17:13:37 +03:00
if (!$result) {
return false;
}
2014-04-29 17:14:48 +04:00
$result['displayname_owner'] = $this->remoteUser . '@' . $this->remote;
if (!$file || $file === '') {
$result['is_share_mount_point'] = true;
$mountPoint = rtrim($this->storage->getMountPoint());
$result['name'] = basename($mountPoint);
}
return $result;
}
public function getFolderContentsById($id) {
$results = parent::getFolderContentsById($id);
foreach ($results as &$file) {
$file['displayname_owner'] = $this->remoteUser . '@' . $this->remote;
}
return $results;
}
}