diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-03-17 13:25:28 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-03-17 13:25:28 +0100 |
commit | ed642d1038f34a334cf011cf54dce7dc4976fba7 (patch) | |
tree | 90d0362d685cdc03dcc4a1b8cea86fcc5cb83492 /lib | |
parent | 34e4e490b863f0628868fd50eed98573f1673f6f (diff) | |
parent | 7f1ff3e9e1253dd6c3be658d139db1c87104be3c (diff) | |
download | nextcloud-server-ed642d1038f34a334cf011cf54dce7dc4976fba7.tar.gz nextcloud-server-ed642d1038f34a334cf011cf54dce7dc4976fba7.zip |
Merge branch 'master' into doctrine
Diffstat (limited to 'lib')
-rw-r--r-- | lib/config.php | 6 | ||||
-rw-r--r-- | lib/db.php | 1 | ||||
-rw-r--r-- | lib/files.php | 2 | ||||
-rw-r--r-- | lib/files/cache/cache.php | 5 | ||||
-rw-r--r-- | lib/files/cache/scanner.php | 1 | ||||
-rw-r--r-- | lib/files/cache/updater.php | 43 | ||||
-rw-r--r-- | lib/files/cache/upgrade.php | 40 | ||||
-rw-r--r-- | lib/files/filesystem.php | 2 | ||||
-rw-r--r-- | lib/files/mapper.php | 18 | ||||
-rw-r--r-- | lib/files/storage/local.php | 6 | ||||
-rw-r--r-- | lib/files/storage/mappedlocal.php | 9 | ||||
-rw-r--r-- | lib/l10n/fa.php | 1 | ||||
-rw-r--r-- | lib/l10n/sl.php | 4 | ||||
-rw-r--r-- | lib/l10n/tr.php | 1 | ||||
-rw-r--r-- | lib/l10n/zh_CN.php | 34 | ||||
-rw-r--r-- | lib/l10n/zh_HK.php | 13 | ||||
-rw-r--r-- | lib/migrate.php | 9 | ||||
-rw-r--r-- | lib/public/share.php | 77 | ||||
-rwxr-xr-x | lib/util.php | 4 |
19 files changed, 199 insertions, 77 deletions
diff --git a/lib/config.php b/lib/config.php index 0bd497b8e50..c94eb278159 100644 --- a/lib/config.php +++ b/lib/config.php @@ -155,7 +155,11 @@ class OC_Config{ */ public static function writeData() { // Create a php file ... - $content = "<?php\n\$CONFIG = "; + $content = "<?php\n "; + if (defined('DEBUG') && DEBUG) { + $content .= "define('DEBUG',true);\n"; + } + $content .= "\$CONFIG = "; $content .= var_export(self::$cache, true); $content .= ";\n"; diff --git a/lib/db.php b/lib/db.php index 4a956674d12..518fcc56a09 100644 --- a/lib/db.php +++ b/lib/db.php @@ -168,6 +168,7 @@ class OC_DB { 'host' => $host, 'port' => $port, 'dbname' => $name, + 'charset' => 'UTF8', 'driver' => 'pdo_sqlsrv', ); break; diff --git a/lib/files.php b/lib/files.php index 2433502444c..04ba51d9d24 100644 --- a/lib/files.php +++ b/lib/files.php @@ -50,7 +50,7 @@ class OC_Files { $xsendfile = true; } - if (count($files) == 1) { + if (is_array($files) && count($files) == 1) { $files = $files[0]; } diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index f288919df74..91bcb73a55d 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -203,7 +203,10 @@ class Cache { $query = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`(' . implode(', ', $queryParts) . ')' . ' VALUES(' . implode(', ', $valuesPlaceholder) . ')'); - $query->execute($params); + $result = $query->execute($params); + if (\OC_DB::isError($result)) { + \OCP\Util::writeLog('cache', 'Insert to cache failed: '.$result, \OCP\Util::ERROR); + } return (int)\OC_DB::insertid('*PREFIX*filecache'); } diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index 88f208547f6..f285f3bed11 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -151,6 +151,7 @@ class Scanner { private function isIgnoredFile($file) { if ($file === '.' || $file === '..' || pathinfo($file, PATHINFO_EXTENSION) === 'part' + || \OC\Files\Filesystem::isFileBlacklisted($file) ) { return true; } diff --git a/lib/files/cache/updater.php b/lib/files/cache/updater.php index d04541c219f..e760ba71bc6 100644 --- a/lib/files/cache/updater.php +++ b/lib/files/cache/updater.php @@ -53,12 +53,36 @@ class Updater { } } + static public function renameUpdate($from, $to) { + /** + * @var \OC\Files\Storage\Storage $storageFrom + * @var \OC\Files\Storage\Storage $storageTo + * @var string $internalFrom + * @var string $internalTo + */ + list($storageFrom, $internalFrom) = self::resolvePath($from); + list($storageTo, $internalTo) = self::resolvePath($to); + if ($storageFrom && $storageTo) { + if ($storageFrom === $storageTo) { + $cache = $storageFrom->getCache($internalFrom); + $cache->move($internalFrom, $internalTo); + $cache->correctFolderSize($internalFrom); + $cache->correctFolderSize($internalTo); + self::correctFolder($from, time()); + self::correctFolder($to, time()); + } else { + self::deleteUpdate($from); + self::writeUpdate($to); + } + } + } + /** - * Update the mtime and ETag of all parent folders - * - * @param string $path - * @param string $time - */ + * Update the mtime and ETag of all parent folders + * + * @param string $path + * @param string $time + */ static public function correctFolder($path, $time) { if ($path !== '' && $path !== '/') { $parent = dirname($path); @@ -66,9 +90,9 @@ class Updater { $parent = ''; } /** - * @var \OC\Files\Storage\Storage $storage - * @var string $internalPath - */ + * @var \OC\Files\Storage\Storage $storage + * @var string $internalPath + */ list($storage, $internalPath) = self::resolvePath($parent); if ($storage) { $cache = $storage->getCache(); @@ -92,8 +116,7 @@ class Updater { * @param array $params */ static public function renameHook($params) { - self::deleteUpdate($params['oldpath']); - self::writeUpdate($params['newpath']); + self::renameUpdate($params['oldpath'], $params['newpath']); } /** diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php index 811d82d7437..230690d35c3 100644 --- a/lib/files/cache/upgrade.php +++ b/lib/files/cache/upgrade.php @@ -39,9 +39,10 @@ class Upgrade { if ($row = $this->legacy->get($path)) { $data = $this->getNewData($row); - $this->insert($data); - - $this->upgradeChilds($data['id'], $mode); + if ($data) { + $this->insert($data); + $this->upgradeChilds($data['id'], $mode); + } } } @@ -53,9 +54,11 @@ class Upgrade { foreach ($children as $child) { $childData = $this->getNewData($child); \OC_Hook::emit('\OC\Files\Cache\Upgrade', 'migrate_path', $child['path']); - $this->insert($childData); - if ($mode == Scanner::SCAN_RECURSIVE) { - $this->upgradeChilds($child['id']); + if ($childData) { + $this->insert($childData); + if ($mode == Scanner::SCAN_RECURSIVE) { + $this->upgradeChilds($child['id']); + } } } } @@ -95,20 +98,25 @@ class Upgrade { */ function getNewData($data) { $newData = $data; - list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($data['path']); /** * @var \OC\Files\Storage\Storage $storage * @var string $internalPath; */ - $newData['path_hash'] = md5($internalPath); - $newData['path'] = $internalPath; - $newData['storage'] = $this->getNumericId($storage); - $newData['parent'] = ($internalPath === '') ? -1 : $data['parent']; - $newData['permissions'] = ($data['writable']) ? \OCP\PERMISSION_ALL : \OCP\PERMISSION_READ; - $newData['storage_object'] = $storage; - $newData['mimetype'] = $this->getMimetypeId($newData['mimetype'], $storage); - $newData['mimepart'] = $this->getMimetypeId($newData['mimepart'], $storage); - return $newData; + list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($data['path']); + if ($storage) { + $newData['path_hash'] = md5($internalPath); + $newData['path'] = $internalPath; + $newData['storage'] = $this->getNumericId($storage); + $newData['parent'] = ($internalPath === '') ? -1 : $data['parent']; + $newData['permissions'] = ($data['writable']) ? \OCP\PERMISSION_ALL : \OCP\PERMISSION_READ; + $newData['storage_object'] = $storage; + $newData['mimetype'] = $this->getMimetypeId($newData['mimetype'], $storage); + $newData['mimepart'] = $this->getMimetypeId($newData['mimepart'], $storage); + return $newData; + } else { + \OC_Log::write('core', 'Unable to migrate data from old cache for '.$data['path'].' because the storage was not found', \OC_Log::ERROR); + return false; + } } /** diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index 40fef674a00..d32e082ade9 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -254,7 +254,7 @@ class Filesystem { } if (isset($mountConfig['user'])) { foreach ($mountConfig['user'] as $mountUser => $mounts) { - if ($user === 'all' or strtolower($mountUser) === strtolower($user)) { + if ($mountUser === 'all' or strtolower($mountUser) === strtolower($user)) { foreach ($mounts as $mountPoint => $options) { $mountPoint = self::setUserVars($user, $mountPoint); foreach ($options as &$option) { diff --git a/lib/files/mapper.php b/lib/files/mapper.php index 520fadbd8c6..179e28e5e76 100644 --- a/lib/files/mapper.php +++ b/lib/files/mapper.php @@ -77,7 +77,9 @@ class Mapper $result = $query->execute(array($path1.'%')); $updateQuery = \OC_DB::prepare('UPDATE `*PREFIX*file_map`' .' SET `logic_path` = ?' - .' AND `physic_path` = ?' + .' , `logic_path_hash` = ?' + .' , `physic_path` = ?' + .' , `physic_path_hash` = ?' .' WHERE `logic_path` = ?'); while( $row = $result->fetchRow()) { $currentLogic = $row['logic_path']; @@ -86,7 +88,7 @@ class Mapper $newPhysic = $physicPath2.$this->stripRootFolder($currentPhysic, $physicPath1); if ($path1 !== $currentLogic) { try { - $updateQuery->execute(array($newLogic, $newPhysic, $currentLogic)); + $updateQuery->execute(array($newLogic, md5($newLogic), $newPhysic, md5($newPhysic), $currentLogic)); } catch (\Exception $e) { error_log('Mapper::Copy failed '.$currentLogic.' -> '.$newLogic.'\n'.$e); throw $e; @@ -149,7 +151,7 @@ class Mapper // detect duplicates while ($this->resolvePhysicalPath($physicalPath) !== null) { - $physicalPath = $this->slugifyPath($physicalPath, $index++); + $physicalPath = $this->slugifyPath($logicPath, $index++); } // insert the new path mapping if requested @@ -190,7 +192,7 @@ class Mapper array_push($sluggedElements, $last.'-'.$index); } - $sluggedPath = $this->unchangedPhysicalRoot.implode(DIRECTORY_SEPARATOR, $sluggedElements); + $sluggedPath = $this->unchangedPhysicalRoot.implode('/', $sluggedElements); return $this->stripLast($sluggedPath); } @@ -210,7 +212,7 @@ class Mapper // transliterate if (function_exists('iconv')) { - $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); + $text = iconv('utf-8', 'us-ascii//TRANSLIT//IGNORE', $text); } // lowercase @@ -219,10 +221,8 @@ class Mapper // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); - if (empty($text)) - { - // TODO: we better generate a guid in this case - return 'n-a'; + if (empty($text)) { + return uniqid(); } return $text; diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index da6597c8057..7b637a97059 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -218,7 +218,11 @@ class Local extends \OC\Files\Storage\Common{ } public function free_space($path) { - return @disk_free_space($this->datadir.$path); + $space = @disk_free_space($this->datadir.$path); + if($space === false){ + return \OC\Files\FREE_SPACE_UNKNOWN; + } + return $space; } public function search($query) { diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index 434c10bcbf7..ba3fcdc5c9e 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -50,7 +50,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ continue; } - $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.DIRECTORY_SEPARATOR.$file); + $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file); $file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath); $file = $this->stripLeading($file); @@ -130,7 +130,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ public function file_get_contents($path) { return file_get_contents($this->buildPath($path)); } - public function file_put_contents($path, $data) {//trigger_error("$path = ".var_export($path, 1)); + public function file_put_contents($path, $data) { return file_put_contents($this->buildPath($path), $data); } public function unlink($path) { @@ -280,7 +280,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ foreach (scandir($physicalDir) as $item) { if ($item == '.' || $item == '..') continue; - $physicalItem = $this->mapper->physicalToLogic($physicalDir.DIRECTORY_SEPARATOR.$item); + $physicalItem = $this->mapper->physicalToLogic($physicalDir.'/'.$item); $item = substr($physicalItem, strlen($physicalDir)+1); if(strstr(strtolower($item), strtolower($query)) !== false) { @@ -331,6 +331,9 @@ class MappedLocal extends \OC\Files\Storage\Common{ if(strpos($path, '/') === 0) { $path = substr($path, 1); } + if(strpos($path, '\\') === 0) { + $path = substr($path, 1); + } if ($path === false) { return ''; } diff --git a/lib/l10n/fa.php b/lib/l10n/fa.php index bbb04290a5c..282a8a56cdc 100644 --- a/lib/l10n/fa.php +++ b/lib/l10n/fa.php @@ -14,6 +14,7 @@ "Files" => "پروندهها", "Text" => "متن", "Images" => "تصاویر", +"Specify a data folder." => "پوشه ای برای داده ها مشخص کنید.", "seconds ago" => "ثانیهها پیش", "1 minute ago" => "1 دقیقه پیش", "%d minutes ago" => "%d دقیقه پیش", diff --git a/lib/l10n/sl.php b/lib/l10n/sl.php index 58c3ddf141d..c0363031979 100644 --- a/lib/l10n/sl.php +++ b/lib/l10n/sl.php @@ -5,7 +5,7 @@ "Users" => "Uporabniki", "Apps" => "Programi", "Admin" => "Skrbništvo", -"ZIP download is turned off." => "Prejem datotek ZIP je onemogočen.", +"ZIP download is turned off." => "Prejemanje datotek v paketu ZIP je onemogočeno.", "Files need to be downloaded one by one." => "Datoteke je mogoče prejeti le posamično.", "Back to Files" => "Nazaj na datoteke", "Selected files too large to generate zip file." => "Izbrane datoteke so prevelike za ustvarjanje datoteke arhiva zip.", @@ -47,7 +47,7 @@ "%d days ago" => "pred %d dnevi", "last month" => "prejšnji mesec", "%d months ago" => "Pred %d meseci", -"last year" => "lani", +"last year" => "lansko leto", "years ago" => "pred nekaj leti", "%s is available. Get <a href=\"%s\">more information</a>" => "%s je na voljo. <a href=\"%s\">Več podrobnosti.</a>", "up to date" => "posodobljeno", diff --git a/lib/l10n/tr.php b/lib/l10n/tr.php index e55caa15972..ab237cfe2e7 100644 --- a/lib/l10n/tr.php +++ b/lib/l10n/tr.php @@ -16,6 +16,7 @@ "Files" => "Dosyalar", "Text" => "Metin", "Images" => "Resimler", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Web sunucunuz dosya transferi için düzgün bir şekilde yapılandırılmamış. WevDAV arabirimini sorunlu gözüküyor.", "seconds ago" => "saniye önce", "1 minute ago" => "1 dakika önce", "%d minutes ago" => "%d dakika önce", diff --git a/lib/l10n/zh_CN.php b/lib/l10n/zh_CN.php index c3af288b727..b79fdfcca1d 100644 --- a/lib/l10n/zh_CN.php +++ b/lib/l10n/zh_CN.php @@ -9,12 +9,34 @@ "Files need to be downloaded one by one." => "需要逐一下载文件", "Back to Files" => "回到文件", "Selected files too large to generate zip file." => "选择的文件太大,无法生成 zip 文件。", -"Application is not enabled" => "不需要程序", -"Authentication error" => "认证错误", +"couldn't be determined" => "无法确定", +"Application is not enabled" => "应用程序未启用", +"Authentication error" => "认证出错", "Token expired. Please reload page." => "Token 过期,请刷新页面。", "Files" => "文件", "Text" => "文本", -"Images" => "图像", +"Images" => "图片", +"Set an admin username." => "请设置一个管理员用户名。", +"Set an admin password." => "请设置一个管理员密码。", +"Specify a data folder." => "请指定一个数据目录。", +"%s enter the database username." => "%s 输入数据库用户名。", +"%s enter the database name." => "%s 输入数据库名称。", +"%s you may not use dots in the database name" => "%s 您不能在数据库名称中使用英文句号。", +"%s set the database host." => "%s 设置数据库所在主机。", +"PostgreSQL username and/or password not valid" => "PostgreSQL 数据库用户名和/或密码无效", +"You need to enter either an existing account or the administrator." => "你需要输入一个数据库中已有的账户或管理员账户。", +"Oracle username and/or password not valid" => "Oracle 数据库用户名和/或密码无效", +"MySQL username and/or password not valid" => "MySQL 数据库用户名和/或密码无效", +"DB Error: \"%s\"" => "数据库错误:\"%s\"", +"Offending command was: \"%s\"" => "冲突命令为:\"%s\"", +"MySQL user '%s'@'localhost' exists already." => "MySQL 用户 '%s'@'localhost' 已存在。", +"Drop this user from MySQL" => "建议从 MySQL 数据库中丢弃 Drop 此用户", +"MySQL user '%s'@'%%' already exists" => "MySQL 用户 '%s'@'%%' 已存在", +"Drop this user from MySQL." => "建议从 MySQL 数据库中丢弃 Drop 此用户。", +"Offending command was: \"%s\", name: %s, password: %s" => "冲突命令为:\"%s\",名称:%s,密码:%s", +"MS SQL username and/or password not valid: %s" => "MS SQL 用户名和/或密码无效:%s", +"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "您的Web服务器尚未正确设置以允许文件同步, 因为WebDAV的接口似乎已损坏.", +"Please double check the <a href='%s'>installation guides</a>." => "请认真检查<a href='%s'>安装指南</a>.", "seconds ago" => "几秒前", "1 minute ago" => "1分钟前", "%d minutes ago" => "%d 分钟前", @@ -25,10 +47,10 @@ "%d days ago" => "%d 天前", "last month" => "上月", "%d months ago" => "%d 月前", -"last year" => "上年", +"last year" => "去年", "years ago" => "几年前", -"%s is available. Get <a href=\"%s\">more information</a>" => "%s 已存在. 点此 <a href=\"%s\">获取更多信息</a>", +"%s is available. Get <a href=\"%s\">more information</a>" => "%s 已存在。点此 <a href=\"%s\">获取更多信息</a>", "up to date" => "已更新。", -"updates check is disabled" => "检查更新功能被关闭。", +"updates check is disabled" => "更新检查功能被禁用。", "Could not find category \"%s\"" => "无法找到分类 \"%s\"" ); diff --git a/lib/l10n/zh_HK.php b/lib/l10n/zh_HK.php new file mode 100644 index 00000000000..cfa33ec36f5 --- /dev/null +++ b/lib/l10n/zh_HK.php @@ -0,0 +1,13 @@ +<?php $TRANSLATIONS = array( +"Help" => "幫助", +"Personal" => "個人", +"Settings" => "設定", +"Users" => "用戶", +"Apps" => "軟件", +"Admin" => "管理", +"Files" => "文件", +"Text" => "文字", +"today" => "今日", +"yesterday" => "昨日", +"last month" => "前一月" +); diff --git a/lib/migrate.php b/lib/migrate.php index a0a329705a3..0b319177400 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -246,11 +246,20 @@ class OC_Migrate{ OC_Log::write( 'migration', 'User doesn\'t exist', OC_Log::ERROR ); return json_encode( array( 'success' => false ) ); } + + // Check if the username is valid + if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $json->exporteduser )) { + OC_Log::write( 'migration', 'Username is not valid', OC_Log::ERROR ); + return json_encode( array( 'success' => false ) ); + } + // Copy data $userfolder = $extractpath . $json->exporteduser; $newuserfolder = $datadir . '/' . self::$uid; foreach(scandir($userfolder) as $file){ if($file !== '.' && $file !== '..' && is_dir($file)) { + $file = str_replace(array('/', '\\'), '', $file); + // Then copy the folder over OC_Helper::copyr($userfolder.'/'.$file, $newuserfolder.'/'.$file); } diff --git a/lib/public/share.php b/lib/public/share.php index 59f41a9bfd6..8b8a41d47c0 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -199,6 +199,29 @@ class Share { } /** + * Get all users an item is shared with + * @param string Item type + * @param string Item source + * @param string Owner + * @param bool Include collections + * @return Return array of users + */ + public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false) { + $users = array(); + $items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections); + if ($items) { + foreach ($items as $item) { + if ((int)$item['share_type'] === self::SHARE_TYPE_USER) { + $users[] = $item['share_with']; + } else if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) { + $users = array_merge($users, \OC_Group::usersInGroup($item['share_with'])); + } + } + } + return $users; + } + + /** * @brief Share an item with a user, group, or via private link * @param string Item type * @param string Item source @@ -383,6 +406,7 @@ class Share { \OC_Hook::emit('OCP\Share', 'pre_unshare', array( 'itemType' => $itemType, 'itemSource' => $itemSource, + 'fileSource' => $item['file_source'], 'shareType' => $shareType, 'shareWith' => $shareWith, )); @@ -759,7 +783,7 @@ class Share { if ($format == self::FORMAT_STATUSES) { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' - .' `share_type`, `file_source`, `path`, `expiration`'; + .' `share_type`, `file_source`, `path`, `expiration`, `storage`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`'; } @@ -768,7 +792,7 @@ class Share { if ($itemType == 'file' || $itemType == 'folder') { $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' .' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,' - .' `expiration`, `token`'; + .' `expiration`, `token`, `storage`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' .' `stime`, `file_source`, `expiration`, `token`'; @@ -804,6 +828,7 @@ class Share { $items = array(); $targets = array(); $switchedItems = array(); + $mounts = array(); while ($row = $result->fetchRow()) { // Filter out duplicate group shares for users with unique targets if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) { @@ -848,8 +873,13 @@ class Share { if (isset($row['parent'])) { $row['path'] = '/Shared/'.basename($row['path']); } else { - // Strip 'files' from path - $row['path'] = substr($row['path'], 5); + if (!isset($mounts[$row['storage']])) { + $mounts[$row['storage']] = \OC\Files\Mount::findByNumericId($row['storage']); + } + if ($mounts[$row['storage']]) { + $path = $mounts[$row['storage']]->getMountPoint().$row['path']; + $row['path'] = substr($path, $root); + } } } if (isset($row['expiration'])) { @@ -957,15 +987,14 @@ class Share { return $items; } else if ($format == self::FORMAT_STATUSES) { $statuses = array(); - // Switch column to path for files and folders, used for determining statuses inside of folders - if ($itemType == 'file' || $itemType == 'folder') { - $column = 'path'; - } foreach ($items as $item) { if ($item['share_type'] == self::SHARE_TYPE_LINK) { - $statuses[$item[$column]] = true; + $statuses[$item[$column]]['link'] = true; } else if (!isset($statuses[$item[$column]])) { - $statuses[$item[$column]] = false; + $statuses[$item[$column]]['link'] = false; + } + if ($itemType == 'file' || $itemType == 'folder') { + $statuses[$item[$column]]['path'] = $item['path']; } } return $statuses; @@ -1102,20 +1131,6 @@ class Share { } else { $fileTarget = null; } - \OC_Hook::emit('OCP\Share', 'post_shared', array( - 'itemType' => $itemType, - 'itemSource' => $itemSource, - 'itemTarget' => $itemTarget, - 'parent' => $parent, - 'shareType' => self::$shareTypeGroupUserUnique, - 'shareWith' => $uid, - 'uidOwner' => $uidOwner, - 'permissions' => $permissions, - 'fileSource' => $fileSource, - 'fileTarget' => $fileTarget, - 'id' => $parent, - 'token' => $token - )); // Insert an extra row for the group share if the item or file target is unique for this user if ($itemTarget != $groupItemTarget || (isset($fileSource) && $fileTarget != $groupFileTarget)) { $query->execute(array($itemType, $itemSource, $itemTarget, $parent, @@ -1124,6 +1139,20 @@ class Share { $id = \OC_DB::insertid('*PREFIX*share'); } } + \OC_Hook::emit('OCP\Share', 'post_shared', array( + 'itemType' => $itemType, + 'itemSource' => $itemSource, + 'itemTarget' => $groupItemTarget, + 'parent' => $parent, + 'shareType' => $shareType, + 'shareWith' => $uid, + 'uidOwner' => $uidOwner, + 'permissions' => $permissions, + 'fileSource' => $fileSource, + 'fileTarget' => $groupFileTarget, + 'id' => $parent, + 'token' => $token + )); if ($parentFolder === true) { // Return parent folders to preserve file target paths for potential children return $parentFolders; diff --git a/lib/util.php b/lib/util.php index d8adfd99a47..e79daae8a0a 100755 --- a/lib/util.php +++ b/lib/util.php @@ -75,7 +75,7 @@ class OC_Util { public static function getVersion() { // hint: We only can count up. Reset minor/patchlevel when // updating major/minor version number. - return array(4, 97, 10); + return array(5, 80, 00); } /** @@ -83,7 +83,7 @@ class OC_Util { * @return string */ public static function getVersionString() { - return '5.0 RC 3'; + return '6.0 pre alpha'; } /** |