diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/activitymanager.php | 24 | ||||
-rw-r--r-- | lib/private/appframework/http/request.php | 2 | ||||
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 26 | ||||
-rw-r--r-- | lib/private/helper.php | 8 | ||||
-rw-r--r-- | lib/private/l10n.php | 26 | ||||
-rw-r--r-- | lib/private/preview.php | 27 | ||||
-rw-r--r-- | lib/private/preview/txt.php | 2 | ||||
-rw-r--r-- | lib/private/repair.php | 2 | ||||
-rw-r--r-- | lib/private/util.php | 7 |
9 files changed, 94 insertions, 30 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php index fc250173536..340f3d335e5 100644 --- a/lib/private/activitymanager.php +++ b/lib/private/activitymanager.php @@ -44,6 +44,12 @@ class ActivityManager implements IManager { /** @var IConfig */ protected $config; + /** @var string */ + protected $formattingObjectType; + + /** @var int */ + protected $formattingObjectId; + /** * constructor of the controller * @@ -304,6 +310,24 @@ class ActivityManager implements IManager { } /** + * @param string $type + * @param int $id + */ + public function setFormattingObject($type, $id) { + $this->formattingObjectType = $type; + $this->formattingObjectId = $id; + } + + /** + * @return bool + */ + public function isFormattingFilteredObject() { + return 'filter' === $this->request->getParam('filter') + && $this->formattingObjectType === $this->request->getParam('objecttype') + && $this->formattingObjectId === $this->request->getParam('objectid'); + } + + /** * @param string $app * @param string $text * @param array $params diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php index b430673f9a9..af6015b0eef 100644 --- a/lib/private/appframework/http/request.php +++ b/lib/private/appframework/http/request.php @@ -603,7 +603,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { if (strpos($pathInfo, $name) === 0) { $pathInfo = substr($pathInfo, strlen($name)); } - if($pathInfo === '/'){ + if($pathInfo === false || $pathInfo === '/'){ return ''; } else { return $pathInfo; diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 805a2bc1ad0..c80e935b982 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -232,7 +232,11 @@ class Encryption extends Wrapper { $result = $this->storage->rename($path1, $path2); - if ($result && $this->encryptionManager->isEnabled()) { + if ($result && + // versions always use the keys from the original file, so we can skip + // this step for versions + $this->isVersion($path2) === false && + $this->encryptionManager->isEnabled()) { $source = $this->getFullPath($path1); if (!$this->util->isExcluded($source)) { $target = $this->getFullPath($path2); @@ -449,7 +453,7 @@ class Encryption extends Wrapper { public function copyFromStorage(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) { // TODO clean this up once the underlying moveFromStorage in OC\Files\Storage\Wrapper\Common is fixed: - // - call $this->storage->moveFromStorage() instead of $this->copyBetweenStorage + // - call $this->storage->copyFromStorage() instead of $this->copyBetweenStorage // - copy the file cache update from $this->copyBetweenStorage to this method // - copy the copyKeys() call from $this->copyBetweenStorage to this method // - remove $this->copyBetweenStorage @@ -469,6 +473,13 @@ class Encryption extends Wrapper { */ private function copyBetweenStorage(Storage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, $isRename) { + // for versions we have nothing to do, because versions should always use the + // key from the original file. Just create a 1:1 copy and done + if ($this->isVersion($targetInternalPath) || + $this->isVersion($sourceInternalPath)) { + return $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); + } + // first copy the keys that we reuse the existing file key on the target location // and don't create a new one which would break versions for example. $mount = $this->mountManager->findByStorageId($sourceStorage->getId()); @@ -741,4 +752,15 @@ class Encryption extends Wrapper { return false; } + /** + * check if path points to a files version + * + * @param $path + * @return bool + */ + protected function isVersion($path) { + $normalized = Filesystem::normalizePath($path); + return substr($normalized, 0, strlen('/files_versions/')) === '/files_versions/'; + } + } diff --git a/lib/private/helper.php b/lib/private/helper.php index b8e4b451835..ba1240a5218 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -193,11 +193,11 @@ class OC_Helper { * Returns the path to the preview of the file. */ public static function previewIcon($path) { - return self::linkToRoute( 'core_ajax_preview', array('x' => 36, 'y' => 36, 'file' => $path )); + return self::linkToRoute( 'core_ajax_preview', array('x' => 32, 'y' => 32, 'file' => $path )); } public static function publicPreviewIcon( $path, $token ) { - return self::linkToRoute( 'core_ajax_public_preview', array('x' => 36, 'y' => 36, 'file' => $path, 't' => $token)); + return self::linkToRoute( 'core_ajax_public_preview', array('x' => 32, 'y' => 32, 'file' => $path, 't' => $token)); } /** @@ -274,7 +274,7 @@ class OC_Helper { /** * Make a computer file size * @param string $str file size in human readable format - * @return int a file size in bytes + * @return float a file size in bytes * * Makes 2kB to 2048. * @@ -283,7 +283,7 @@ class OC_Helper { public static function computerFileSize($str) { $str = strtolower($str); if (is_numeric($str)) { - return $str; + return floatval($str); } $bytes_array = array( diff --git a/lib/private/l10n.php b/lib/private/l10n.php index 168011cfcec..89ce2bc8d72 100644 --- a/lib/private/l10n.php +++ b/lib/private/l10n.php @@ -102,16 +102,11 @@ class OC_L10N implements \OCP\IL10N { } /** - * @param $app * @return string */ - public static function setLanguageFromRequest($app = null) { + public static function setLanguageFromRequest() { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { - if (is_array($app)) { - $available = $app; - } else { - $available = self::findAvailableLanguages($app); - } + $available = self::findAvailableLanguages(); // E.g. make sure that 'de' is before 'de_DE'. sort($available); @@ -122,17 +117,13 @@ class OC_L10N implements \OCP\IL10N { $preferred_language = str_replace('-', '_', $preferred_language); foreach ($available as $available_language) { if ($preferred_language === strtolower($available_language)) { - if (!is_array($app)) { - self::$language = $available_language; - } + self::$language = $available_language; return $available_language; } } foreach ($available as $available_language) { if (substr($preferred_language, 0, 2) === $available_language) { - if (!is_array($app)) { - self::$language = $available_language; - } + self::$language = $available_language; return $available_language; } } @@ -469,7 +460,7 @@ class OC_L10N implements \OCP\IL10N { return $default_language; } - $lang = self::setLanguageFromRequest($app); + $lang = self::setLanguageFromRequest(); if($userId && !$config->getUserValue($userId, 'core', 'lang')) { $config->setUserValue($userId, 'core', 'lang', $lang); } @@ -503,8 +494,9 @@ class OC_L10N implements \OCP\IL10N { * @return array an array of available languages */ public static function findAvailableLanguages($app=null) { - if(!empty(self::$availableLanguages)) { - return self::$availableLanguages; + // also works with null as key + if(isset(self::$availableLanguages[$app]) && !empty(self::$availableLanguages[$app])) { + return self::$availableLanguages[$app]; } $available=array('en');//english is always available $dir = self::findI18nDir($app); @@ -518,7 +510,7 @@ class OC_L10N implements \OCP\IL10N { } } - self::$availableLanguages = $available; + self::$availableLanguages[$app] = $available; return $available; } diff --git a/lib/private/preview.php b/lib/private/preview.php index 1127048b7fd..b2accdfd00f 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -252,12 +252,13 @@ class Preview { * Sets the path of the file you want a preview of * * @param string $file + * @param \OCP\Files\FileInfo|null $info * * @return \OC\Preview */ - public function setFile($file) { + public function setFile($file, $info = null) { $this->file = $file; - $this->info = null; + $this->info = $info; if ($file !== '') { $this->getFileInfo(); @@ -374,7 +375,7 @@ class Preview { return false; } - if (!$this->fileView->file_exists($file)) { + if (!$this->getFileInfo() instanceof FileInfo) { \OCP\Util::writeLog('core', 'File:"' . $file . '" not found', \OCP\Util::DEBUG); return false; @@ -478,7 +479,7 @@ class Preview { $preview = $this->buildCachePath($fileId, $previewWidth, $previewHeight); // This checks if we have a preview of those exact dimensions in the cache - if ($this->userView->file_exists($preview)) { + if ($this->thumbnailSizeExists($allThumbnails, basename($preview))) { return $preview; } @@ -524,6 +525,24 @@ class Preview { } /** + * Check if a specific thumbnail size is cached + * + * @param FileInfo[] $allThumbnails the list of all our cached thumbnails + * @param string $name + * @return bool + */ + private function thumbnailSizeExists(array $allThumbnails, $name) { + + foreach ($allThumbnails as $thumbnail) { + if ($name === $thumbnail->getName()) { + return true; + } + } + + return false; + } + + /** * Determines the size of the preview we should be looking for in the cache * * @return int[] diff --git a/lib/private/preview/txt.php b/lib/private/preview/txt.php index 0bba570a8c9..2fdc86d9546 100644 --- a/lib/private/preview/txt.php +++ b/lib/private/preview/txt.php @@ -53,7 +53,7 @@ class TXT extends Provider { $lines = preg_split("/\r\n|\n|\r/", $content); - $fontSize = ($maxX) ? (int) ((5 / 36) * $maxX) : 5; //5px + $fontSize = ($maxX) ? (int) ((5 / 32) * $maxX) : 5; //5px $lineSize = ceil($fontSize * 1.25); $image = imagecreate($maxX, $maxY); diff --git a/lib/private/repair.php b/lib/private/repair.php index 3639440a518..20219e313fd 100644 --- a/lib/private/repair.php +++ b/lib/private/repair.php @@ -44,6 +44,7 @@ use OC\Repair\RepairLegacyStorages; use OC\Repair\RepairMimeTypes; use OC\Repair\SearchLuceneTables; use OC\Repair\UpdateOutdatedOcsIds; +use OC\Repair\RepairInvalidShares; class Repair extends BasicEmitter { /** @@ -113,6 +114,7 @@ class Repair extends BasicEmitter { new DropOldJobs(\OC::$server->getJobList()), new RemoveGetETagEntries(\OC::$server->getDatabaseConnection()), new UpdateOutdatedOcsIds(\OC::$server->getConfig()), + new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), ]; } diff --git a/lib/private/util.php b/lib/private/util.php index 9abaef71a68..746a2e09523 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -223,7 +223,12 @@ class OC_Util { if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes') { $user = \OCP\User::getUser(); $groupsList = \OC::$server->getAppConfig()->getValue('core', 'shareapi_exclude_groups_list', ''); - $excludedGroups = explode(',', $groupsList); + $excludedGroups = json_decode($groupsList); + if (is_null($excludedGroups)) { + $excludedGroups = explode(',', $groupsList); + $newValue = json_encode($excludedGroups); + \OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', $newValue); + } $usersGroups = \OC_Group::getUserGroups($user); if (!empty($usersGroups)) { $remainingGroups = array_diff($usersGroups, $excludedGroups); |