本文整理汇总了PHP中OC\Files\Filesystem::getMountByNumericId方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getMountByNumericId方法的具体用法?PHP Filesystem::getMountByNumericId怎么用?PHP Filesystem::getMountByNumericId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getMountByNumericId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSourceCache
/**
* Get the source cache of a shared file or folder
*
* @param string $target Shared target file path
* @return \OC\Files\Cache\Cache
*/
private function getSourceCache($target)
{
if ($target === false || $target === $this->storage->getMountPoint()) {
$target = '';
}
$source = \OC_Share_Backend_File::getSource($target, $this->storage->getMountPoint(), $this->storage->getItemType());
if (isset($source['path']) && isset($source['fileOwner'])) {
try {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
} catch (NoUserException $e) {
\OC::$server->getLogger()->warning('The user \'' . $source['uid_owner'] . '\' of a share can\'t be retrieved.', array('app' => 'files_sharing'));
return false;
}
$mounts = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
if (is_array($mounts) and !empty($mounts)) {
$fullPath = $mounts[0]->getMountPoint() . $source['path'];
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath);
if ($storage) {
$this->files[$target] = $internalPath;
$cache = $storage->getCache();
$this->storageId = $storage->getId();
$this->numericId = $cache->getNumericStorageId();
return $cache;
}
}
}
return false;
}
示例2: getSourcePath
/**
* @brief Get the source file path for a shared file
* @param string Shared target file path
* @return string source file path or false if not found
*/
public function getSourcePath($target)
{
$source = $this->getFile($target);
if ($source) {
if (!isset($source['fullPath'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
$mount = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
if (is_array($mount)) {
$this->files[$target]['fullPath'] = $mount[key($mount)]->getMountPoint() . $source['path'];
} else {
$this->files[$target]['fullPath'] = false;
}
}
return $this->files[$target]['fullPath'];
}
return false;
}
示例3: getSourceCache
/**
* @brief Get the source cache of a shared file or folder
* @param string $target Shared target file path
* @return \OC\Files\Cache\Cache
*/
private function getSourceCache($target)
{
$source = \OC_Share_Backend_File::getSource($target);
if (isset($source['path']) && isset($source['fileOwner'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
$mount = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
if (is_array($mount)) {
$fullPath = $mount[key($mount)]->getMountPoint() . $source['path'];
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath);
if ($storage) {
$this->files[$target] = $internalPath;
$cache = $storage->getCache();
$this->storageId = $storage->getId();
$this->numericId = $cache->getNumericStorageId();
return $cache;
}
}
}
return false;
}
示例4: getSourcePath
/**
* Get the source file path for a shared file
*
* @param string $target Shared target file path
* @return string|false source file path or false if not found
*/
public function getSourcePath($target)
{
$source = $this->getFile($target);
if ($source) {
if (!isset($source['fullPath'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
$mount = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
if (is_array($mount) && !empty($mount)) {
$this->files[$target]['fullPath'] = $mount[key($mount)]->getMountPoint() . $source['path'];
} else {
$this->files[$target]['fullPath'] = false;
\OCP\Util::writeLog('files_sharing', "Unable to get mount for shared storage '" . $source['storage'] . "' user '" . $source['fileOwner'] . "'", \OCP\Util::ERROR);
}
}
return $this->files[$target]['fullPath'];
}
return false;
}
示例5: getItems
//.........这里部分代码省略.........
$switchedItems[$id] = $row['id'];
unset($items[$id]);
$id = $row['id'];
}
$items[$id]['permissions'] |= (int) $row['permissions'];
}
continue;
} elseif (!empty($row['parent'])) {
$targets[$row['parent']] = $row['id'];
}
}
}
// Remove root from file source paths if retrieving own shared items
if (isset($uidOwner) && isset($row['path'])) {
if (isset($row['parent'])) {
$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
$parentResult = $query->execute(array($row['parent']));
if (\OC_DB::isError($result)) {
\OCP\Util::writeLog('OCP\\Share', 'Can\'t select parent: ' . \OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where, \OCP\Util::ERROR);
} else {
$parentRow = $parentResult->fetchRow();
$tmpPath = $parentRow['file_target'];
// find the right position where the row path continues from the target path
$pos = strrpos($row['path'], $parentRow['file_target']);
$subPath = substr($row['path'], $pos);
$splitPath = explode('/', $subPath);
foreach (array_slice($splitPath, 2) as $pathPart) {
$tmpPath = $tmpPath . '/' . $pathPart;
}
$row['path'] = $tmpPath;
}
} else {
if (!isset($mounts[$row['storage']])) {
$mountPoints = \OC\Files\Filesystem::getMountByNumericId($row['storage']);
if (is_array($mountPoints) && !empty($mountPoints)) {
$mounts[$row['storage']] = current($mountPoints);
}
}
if (!empty($mounts[$row['storage']])) {
$path = $mounts[$row['storage']]->getMountPoint() . $row['path'];
$relPath = substr($path, $root);
// path relative to data/user
$row['path'] = rtrim($relPath, '/');
}
}
}
if ($checkExpireDate) {
if (self::expireItem($row)) {
continue;
}
}
// Check if resharing is allowed, if not remove share permission
if (isset($row['permissions']) && !self::isResharingAllowed() | \OCP\Util::isSharingDisabledForUser()) {
$row['permissions'] &= ~\OCP\Constants::PERMISSION_SHARE;
}
// Add display names to result
$row['share_with_displayname'] = $row['share_with'];
if (isset($row['share_with']) && $row['share_with'] != '' && $row['share_type'] === self::SHARE_TYPE_USER) {
$row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']);
} else {
if (isset($row['share_with']) && $row['share_with'] != '' && $row['share_type'] === self::SHARE_TYPE_REMOTE) {
$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']);
foreach ($addressBookEntries as $entry) {
foreach ($entry['CLOUD'] as $cloudID) {
if ($cloudID === $row['share_with']) {
$row['share_with_displayname'] = $entry['FN'];
示例6: getItems
//.........这里部分代码省略.........
$items[$id]['permissions'] |= (int) $row['permissions'];
continue;
}
} else {
$targets[$row[$column]] = $row['id'];
}
}
}
// Remove root from file source paths if retrieving own shared items
if (isset($uidOwner) && isset($row['path'])) {
if (isset($row['parent'])) {
// FIXME: Doesn't always construct the correct path, example:
// Folder '/a/b', share '/a' and '/a/b' to user2
// user2 reshares /Shared/b and ask for share status of /Shared/a/b
// expected result: path=/Shared/a/b; actual result /Shared/b because of the parent
$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
$parentResult = $query->execute(array($row['parent']));
if (\OC_DB::isError($result)) {
\OC_Log::write('OCP\\Share', 'Can\'t select parent: ' . \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, \OC_Log::ERROR);
} else {
$parentRow = $parentResult->fetchRow();
$tmpPath = '/Shared' . $parentRow['file_target'];
// find the right position where the row path continues from the target path
$pos = strrpos($row['path'], $parentRow['file_target']);
$subPath = substr($row['path'], $pos);
$splitPath = explode('/', $subPath);
foreach (array_slice($splitPath, 2) as $pathPart) {
$tmpPath = $tmpPath . '/' . $pathPart;
}
$row['path'] = $tmpPath;
}
} else {
if (!isset($mounts[$row['storage']])) {
$mountPoints = \OC\Files\Filesystem::getMountByNumericId($row['storage']);
if (is_array($mountPoints)) {
$mounts[$row['storage']] = current($mountPoints);
}
}
if ($mounts[$row['storage']]) {
$path = $mounts[$row['storage']]->getMountPoint() . $row['path'];
$row['path'] = substr($path, $root);
}
}
}
if ($checkExpireDate) {
if (self::expireItem($row)) {
continue;
}
}
// Check if resharing is allowed, if not remove share permission
if (isset($row['permissions']) && !self::isResharingAllowed()) {
$row['permissions'] &= ~PERMISSION_SHARE;
}
// Add display names to result
if (isset($row['share_with']) && $row['share_with'] != '') {
$row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']);
}
if (isset($row['uid_owner']) && $row['uid_owner'] != '') {
$row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']);
}
$items[$row['id']] = $row;
}
if (!empty($items)) {
$collectionItems = array();
foreach ($items as &$row) {
// Return only the item instead of a 2-dimensional array