diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-05-31 16:35:51 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-05-31 16:35:51 +0200 |
commit | 542bcf915680fb9942057dc0c3c9f7b0eb59f3a5 (patch) | |
tree | ebdf2628928482737d00e2654cc3ff5a044075f0 /lib | |
parent | 8320f41dbe463020423c3fe8d2368bc8d415750a (diff) | |
parent | d636e168a6c043ddae730f7cdaaee772b1067793 (diff) | |
download | nextcloud-server-542bcf915680fb9942057dc0c3c9f7b0eb59f3a5.tar.gz nextcloud-server-542bcf915680fb9942057dc0c3c9f7b0eb59f3a5.zip |
Merge branch 'master' into user
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 3 | ||||
-rw-r--r-- | lib/files/cache/permissions.php | 20 | ||||
-rw-r--r-- | lib/files/cache/scanner.php | 15 | ||||
-rw-r--r-- | lib/files/view.php | 22 | ||||
-rw-r--r-- | lib/helper.php | 42 | ||||
-rw-r--r-- | lib/l10n/pt_PT.php | 1 | ||||
-rw-r--r-- | lib/l10n/sk_SK.php | 1 | ||||
-rw-r--r-- | lib/mail.php | 2 | ||||
-rw-r--r-- | lib/public/share.php | 84 |
9 files changed, 119 insertions, 71 deletions
diff --git a/lib/base.php b/lib/base.php index f1145b651ae..9d1d4b5e058 100644 --- a/lib/base.php +++ b/lib/base.php @@ -258,7 +258,8 @@ class OC { public static function initTemplateEngine() { // Add the stuff we need always - OC_Util::addScript("jquery-1.7.2.min"); + OC_Util::addScript("jquery-1.10.0.min"); + OC_Util::addScript("jquery-migrate-1.2.1.min"); OC_Util::addScript("jquery-ui-1.10.0.custom"); OC_Util::addScript("jquery-showpassword"); OC_Util::addScript("jquery.infieldlabel"); diff --git a/lib/files/cache/permissions.php b/lib/files/cache/permissions.php index faa5ff5eacc..29c30b0f36c 100644 --- a/lib/files/cache/permissions.php +++ b/lib/files/cache/permissions.php @@ -86,6 +86,26 @@ class Permissions { } /** + * get the permissions for all files in a folder + * + * @param int $parentId + * @param string $user + * @return int[] + */ + public function getDirectoryPermissions($parentId, $user) { + $query = \OC_DB::prepare('SELECT `*PREFIX*permissions`.`fileid`, `permissions` + FROM `*PREFIX*permissions` INNER JOIN `*PREFIX*filecache` ON `*PREFIX*permissions`.`fileid` = `*PREFIX*filecache`.`fileid` + WHERE `*PREFIX*filecache`.`parent` = ? AND `*PREFIX*permissions`.`user` = ?'); + + $result = $query->execute(array($parentId, $user)); + $filePermissions = array(); + while ($row = $result->fetchRow()) { + $filePermissions[$row['fileid']] = $row['permissions']; + } + return $filePermissions; + } + + /** * remove the permissions for a file * * @param int $fileId diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index 46122221dc2..8f9a7921956 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -78,18 +78,21 @@ class Scanner { $this->scanFile($parent); } } - if($cacheData = $this->cache->get($file)) { + $newData = $data; + if ($cacheData = $this->cache->get($file)) { + if ($checkExisting && $data['size'] === -1) { + $data['size'] = $cacheData['size']; + } if ($data['mtime'] === $cacheData['mtime'] && $data['size'] === $cacheData['size']) { $data['etag'] = $cacheData['etag']; } + // Only update metadata that has changed + $newData = array_diff($data, $cacheData); } - if ($checkExisting and $cacheData) { - if ($data['size'] === -1) { - $data['size'] = $cacheData['size']; - } + if (!empty($newData)) { + $this->cache->put($file, $newData); } - $this->cache->put($file, $data); } return $data; } diff --git a/lib/files/view.php b/lib/files/view.php index 8e7727d335c..ecb0f30400a 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -267,7 +267,7 @@ class View { $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); if (\OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) and Filesystem::isValidPath($path) - and ! Filesystem::isFileBlacklisted($path) + and !Filesystem::isFileBlacklisted($path) ) { $path = $this->getRelativePath($absolutePath); $exists = $this->file_exists($path); @@ -344,7 +344,7 @@ class View { \OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2) and Filesystem::isValidPath($path2) and Filesystem::isValidPath($path1) - and ! Filesystem::isFileBlacklisted($path2) + and !Filesystem::isFileBlacklisted($path2) ) { $path1 = $this->getRelativePath($absolutePath1); $path2 = $this->getRelativePath($absolutePath2); @@ -371,7 +371,7 @@ class View { list(, $internalPath2) = Filesystem::resolvePath($absolutePath2 . $postFix2); if ($storage) { $result = $storage->rename($internalPath1, $internalPath2); - \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2); + \OC_FileProxy::runPostProxies('rename', $absolutePath1, $absolutePath2); } else { $result = false; } @@ -418,7 +418,7 @@ class View { \OC_FileProxy::runPreProxies('copy', $absolutePath1, $absolutePath2) and Filesystem::isValidPath($path2) and Filesystem::isValidPath($path1) - and ! Filesystem::isFileBlacklisted($path2) + and !Filesystem::isFileBlacklisted($path2) ) { $path1 = $this->getRelativePath($absolutePath1); $path2 = $this->getRelativePath($absolutePath2); @@ -632,7 +632,7 @@ class View { $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); if (\OC_FileProxy::runPreProxies($operation, $absolutePath, $extraParam) and Filesystem::isValidPath($path) - and ! Filesystem::isFileBlacklisted($path) + and !Filesystem::isFileBlacklisted($path) ) { $path = $this->getRelativePath($absolutePath); if ($path == null) { @@ -760,7 +760,7 @@ class View { } } - $data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data); + $data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data); return $data; } @@ -797,18 +797,18 @@ class View { } $files = $cache->getFolderContents($internalPath); //TODO: mimetype_filter + $permissions = $permissionsCache->getDirectoryPermissions($cache->getId($internalPath), $user); $ids = array(); foreach ($files as $i => $file) { $files[$i]['type'] = $file['mimetype'] === 'httpd/unix-directory' ? 'dir' : 'file'; $ids[] = $file['fileid']; - $permissions = $permissionsCache->get($file['fileid'], $user); - if ($permissions === -1) { - $permissions = $storage->getPermissions($file['path']); - $permissionsCache->set($file['fileid'], $user, $permissions); + if (!isset($permissions[$file['fileid']])) { + $permissions[$file['fileid']] = $storage->getPermissions($file['path']); + $permissionsCache->set($file['fileid'], $user, $permissions[$file['fileid']]); } - $files[$i]['permissions'] = $permissions; + $files[$i]['permissions'] = $permissions[$file['fileid']]; } //add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders diff --git a/lib/helper.php b/lib/helper.php index c69445ed788..225e9fd2a9a 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -27,6 +27,7 @@ class OC_Helper { private static $mimetypes=array(); private static $tmpFiles=array(); + private static $mimetypeIcons = array(); /** * @brief Creates an url using a defined route @@ -187,31 +188,38 @@ class OC_Helper { * * Returns the path to the image of this file type. */ - public static function mimetypeIcon( $mimetype ) { - $alias=array('application/xml'=>'code/xml'); - if(isset($alias[$mimetype])) { - $mimetype=$alias[$mimetype]; + public static function mimetypeIcon($mimetype) { + $alias = array('application/xml' => 'code/xml'); + if (isset($alias[$mimetype])) { + $mimetype = $alias[$mimetype]; + } + if (isset(self::$mimetypeIcons[$mimetype])) { + return self::$mimetypeIcons[$mimetype]; } // Replace slash and backslash with a minus - $mimetype = str_replace( "/", "-", $mimetype ); - $mimetype = str_replace( "\\", "-", $mimetype ); + $icon = str_replace('/', '-', $mimetype); + $icon = str_replace( '\\', '-', $icon); // Is it a dir? - if( $mimetype == "dir" ) { - return OC::$WEBROOT."/core/img/filetypes/folder.png"; + if ($mimetype === 'dir') { + self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/folder.png'; + return OC::$WEBROOT.'/core/img/filetypes/folder.png'; } // Icon exists? - if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { - return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; - } - //try only the first part of the filetype - $mimetype=substr($mimetype, 0, strpos($mimetype, '-')); - if( file_exists( OC::$SERVERROOT."/core/img/filetypes/$mimetype.png" )) { - return OC::$WEBROOT."/core/img/filetypes/$mimetype.png"; + if (file_exists(OC::$SERVERROOT.'/core/img/filetypes/'.$icon.'.png')) { + self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/'.$icon.'.png'; + return OC::$WEBROOT.'/core/img/filetypes/'.$icon.'.png'; } - else{ - return OC::$WEBROOT."/core/img/filetypes/file.png"; + + // Try only the first part of the filetype + $mimePart = substr($icon, 0, strpos($icon, '-')); + if (file_exists(OC::$SERVERROOT.'/core/img/filetypes/'.$mimePart.'.png')) { + self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/'.$mimePart.'.png'; + return OC::$WEBROOT.'/core/img/filetypes/'.$mimePart.'.png'; + } else { + self::$mimetypeIcons[$mimetype] = OC::$WEBROOT.'/core/img/filetypes/file.png'; + return OC::$WEBROOT.'/core/img/filetypes/file.png'; } } diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php index 176f4286c9d..f49258157ed 100644 --- a/lib/l10n/pt_PT.php +++ b/lib/l10n/pt_PT.php @@ -24,6 +24,7 @@ "%s set the database host." => "%s defina o servidor da base de dados (geralmente localhost)", "PostgreSQL username and/or password not valid" => "Nome de utilizador/password do PostgreSQL inválido", "You need to enter either an existing account or the administrator." => "Precisa de introduzir uma conta existente ou de administrador", +"Oracle connection could not be established" => "Não foi possível estabelecer a ligação Oracle", "MySQL username and/or password not valid" => "Nome de utilizador/password do MySQL inválida", "DB Error: \"%s\"" => "Erro na BD: \"%s\"", "Offending command was: \"%s\"" => "O comando gerador de erro foi: \"%s\"", diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php index 121b2405dcf..c1ec2470b46 100644 --- a/lib/l10n/sk_SK.php +++ b/lib/l10n/sk_SK.php @@ -24,6 +24,7 @@ "%s set the database host." => "Zadajte názov počítača s databázou %s.", "PostgreSQL username and/or password not valid" => "Používateľské meno a/alebo heslo pre PostgreSQL databázu je neplatné", "You need to enter either an existing account or the administrator." => "Musíte zadať jestvujúci účet alebo administrátora.", +"Oracle connection could not be established" => "Nie je možné pripojiť sa k Oracle", "MySQL username and/or password not valid" => "Používateľské meno a/alebo heslo pre MySQL databázu je neplatné", "DB Error: \"%s\"" => "Chyba DB: \"%s\"", "Offending command was: \"%s\"" => "Podozrivý príkaz bol: \"%s\"", diff --git a/lib/mail.php b/lib/mail.php index 61634632efc..e15af277a64 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -113,7 +113,7 @@ class OC_Mail { */ public static function getfooter() { - $txt="\n--\n"; + $txt="\n-- \n"; $txt.="ownCloud\n"; $txt.="Your Cloud, Your Data, Your Way!\n"; return($txt); diff --git a/lib/public/share.php b/lib/public/share.php index 03d662676c6..6c93139b107 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -123,27 +123,32 @@ class Share { return $path; } - + /** * @brief Find which users can access a shared item * @param $path to the file * @param $user owner of the file * @param include owner to the list of users with access to the file * @return array - * @note $path needs to be relative to user data dir, e.g. 'file.txt' + * @note $path needs to be relative to user data dir, e.g. 'file.txt' * not '/admin/data/file.txt' */ - public static function getUsersSharingFile($path, $user, $includeOwner = false, $removeDuplicates = true) { + public static function getUsersSharingFile($path, $user, $includeOwner = false) { - $path_parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR)); - $path = ''; $shares = array(); $publicShare = false; + $source = -1; + $cache = false; + $view = new \OC\Files\View('/' . $user . '/files/'); - foreach ($path_parts as $p) { - $path .= '/' . $p; - $meta = $view->getFileInfo(\OC_Filesystem::normalizePath($path)); + $meta = $view->getFileInfo(\OC\Files\Filesystem::normalizePath($path)); + + if($meta !== false) { $source = $meta['fileid']; + $cache = new \OC\Files\Cache\Cache($meta['storage']); + } + + while ($source !== -1) { // Fetch all shares of this file path from DB $query = \OC_DB::prepare( @@ -156,14 +161,13 @@ class Share { $result = $query->execute(array($source, self::SHARE_TYPE_USER)); - if (\OC_DB::isError($result)) { - \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); - } - - while ($row = $result->fetchRow()) { - $shares[] = $row['share_with']; + if (\OCP\DB::isError($result)) { + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + } else { + while ($row = $result->fetchRow()) { + $shares[] = $row['share_with']; + } } - // We also need to take group shares into account $query = \OC_DB::prepare( @@ -176,32 +180,42 @@ class Share { $result = $query->execute(array($source, self::SHARE_TYPE_GROUP)); - if (\OC_DB::isError($result)) { - \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); - } - - while ($row = $result->fetchRow()) { - $usersInGroup = \OC_Group::usersInGroup($row['share_with']); - $shares = array_merge($shares, $usersInGroup); + if (\OCP\DB::isError($result)) { + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + } else { + while ($row = $result->fetchRow()) { + $usersInGroup = \OC_Group::usersInGroup($row['share_with']); + $shares = array_merge($shares, $usersInGroup); + } } //check for public link shares - $query = \OC_DB::prepare( - 'SELECT share_with - FROM - `*PREFIX*share` - WHERE - item_source = ? AND share_type = ?' - ); + if (!$publicShare) { + $query = \OC_DB::prepare( + 'SELECT share_with + FROM + `*PREFIX*share` + WHERE + item_source = ? AND share_type = ?' + ); - $result = $query->execute(array($source, self::SHARE_TYPE_LINK)); + $result = $query->execute(array($source, self::SHARE_TYPE_LINK)); - if (\OC_DB::isError($result)) { - \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + if (\OCP\DB::isError($result)) { + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + } else { + if ($result->fetchRow()) { + $publicShare = true; + } + } } - - if ($result->fetchRow()) { - $publicShare = true; + + // let's get the parent for the next round + $meta = $cache->get((int)$source); + if($meta !== false) { + $source = (int)$meta['parent']; + } else { + $source = -1; } } // Include owner in list of users, if requested |