diff options
author | Bart Visscher <bartv@thisnet.nl> | 2014-04-28 17:59:41 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2014-04-28 17:59:41 +0200 |
commit | 66b1ad0a9be76a179155c8ce6a47310f93e8bb42 (patch) | |
tree | c9ba3dfabe91602db2966d187f812bdfcd9dc3da /lib/public | |
parent | a9bf3df82d0c3d0f54c9fe45dbb911756f37b166 (diff) | |
parent | c591cf0836720a4cfc6d441b363ece46ed19eadc (diff) | |
download | nextcloud-server-66b1ad0a9be76a179155c8ce6a47310f93e8bb42.tar.gz nextcloud-server-66b1ad0a9be76a179155c8ce6a47310f93e8bb42.zip |
Merge branch 'master' into type-hinting-sharing
Conflicts:
apps/files_sharing/lib/share/file.php
apps/files_sharing/tests/api.php
lib/private/share/share.php
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/appframework/http/downloadresponse.php | 50 | ||||
-rw-r--r-- | lib/public/appframework/http/jsonresponse.php | 1 | ||||
-rw-r--r-- | lib/public/appframework/http/redirectresponse.php | 57 | ||||
-rw-r--r-- | lib/public/route/iroute.php | 6 | ||||
-rw-r--r-- | lib/public/route/irouter.php | 6 | ||||
-rw-r--r-- | lib/public/share.php | 23 | ||||
-rw-r--r-- | lib/public/template.php | 2 | ||||
-rw-r--r-- | lib/public/util.php | 21 |
8 files changed, 149 insertions, 17 deletions
diff --git a/lib/public/appframework/http/downloadresponse.php b/lib/public/appframework/http/downloadresponse.php new file mode 100644 index 00000000000..d3c2818e828 --- /dev/null +++ b/lib/public/appframework/http/downloadresponse.php @@ -0,0 +1,50 @@ +<?php + +/** + * ownCloud - App Framework + * + * @author Bernhard Posselt + * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +namespace OCP\AppFramework\Http; + + +/** + * Prompts the user to download the a file + */ +class DownloadResponse extends \OCP\AppFramework\Http\Response { + + private $filename; + private $contentType; + + /** + * Creates a response that prompts the user to download the file + * @param string $filename the name that the downloaded file should have + * @param string $contentType the mimetype that the downloaded file should have + */ + public function __construct($filename, $contentType) { + $this->filename = $filename; + $this->contentType = $contentType; + + $this->addHeader('Content-Disposition', 'attachment; filename="' . $filename . '"'); + $this->addHeader('Content-Type', $contentType); + } + + +} diff --git a/lib/public/appframework/http/jsonresponse.php b/lib/public/appframework/http/jsonresponse.php index 6628c4514d9..6d029b7464a 100644 --- a/lib/public/appframework/http/jsonresponse.php +++ b/lib/public/appframework/http/jsonresponse.php @@ -49,7 +49,6 @@ class JSONResponse extends Response { public function __construct($data=array(), $statusCode=Http::STATUS_OK) { $this->data = $data; $this->setStatus($statusCode); - $this->addHeader('X-Content-Type-Options', 'nosniff'); $this->addHeader('Content-type', 'application/json; charset=utf-8'); } diff --git a/lib/public/appframework/http/redirectresponse.php b/lib/public/appframework/http/redirectresponse.php new file mode 100644 index 00000000000..416e1533635 --- /dev/null +++ b/lib/public/appframework/http/redirectresponse.php @@ -0,0 +1,57 @@ +<?php + +/** + * ownCloud - App Framework + * + * @author Bernhard Posselt + * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + + +namespace OCP\AppFramework\Http; + +use OCP\AppFramework\Http\Response; +use OCP\AppFramework\Http; + + +/** + * Redirects to a different URL + */ +class RedirectResponse extends Response { + + private $redirectURL; + + /** + * Creates a response that redirects to a url + * @param string $redirectURL the url to redirect to + */ + public function __construct($redirectURL) { + $this->redirectURL = $redirectURL; + $this->setStatus(Http::STATUS_TEMPORARY_REDIRECT); + $this->addHeader('Location', $redirectURL); + } + + + /** + * @return string the url to redirect + */ + public function getRedirectURL() { + return $this->redirectURL; + } + + +} diff --git a/lib/public/route/iroute.php b/lib/public/route/iroute.php index 66fdb841821..d5610e762a8 100644 --- a/lib/public/route/iroute.php +++ b/lib/public/route/iroute.php @@ -10,6 +10,7 @@ namespace OCP\Route; interface IRoute { /** * Specify PATCH as the method to use with this route + * @return \OCP\Route\IRoute */ public function patch(); @@ -26,21 +27,25 @@ interface IRoute { * it is called directly * * @param $file + * @return void */ public function actionInclude($file); /** * Specify GET as the method to use with this route + * @return \OCP\Route\IRoute */ public function get(); /** * Specify POST as the method to use with this route + * @return \OCP\Route\IRoute */ public function post(); /** * Specify DELETE as the method to use with this route + * @return \OCP\Route\IRoute */ public function delete(); @@ -74,6 +79,7 @@ interface IRoute { /** * Specify PUT as the method to use with this route + * @return \OCP\Route\IRoute */ public function put(); } diff --git a/lib/public/route/irouter.php b/lib/public/route/irouter.php index 125cd29e81b..1c003c7b4b9 100644 --- a/lib/public/route/irouter.php +++ b/lib/public/route/irouter.php @@ -17,10 +17,14 @@ interface IRouter { */ public function getRoutingFiles(); + /** + * @return string + */ public function getCacheKey(); /** * loads the api routes + * @return void */ public function loadRoutes($app = null); @@ -28,6 +32,7 @@ interface IRouter { * Sets the collection to use for adding routes * * @param string $name Name of the collection to use. + * @return void */ public function useCollection($name); @@ -47,6 +52,7 @@ interface IRouter { * * @param string $url The url to find * @throws \Exception + * @return void */ public function match($url); diff --git a/lib/public/share.php b/lib/public/share.php index 4306c1b038f..acda709b552 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -64,14 +64,15 @@ class Share extends \OC\Share\Constants { /** * Find which users can access a shared item * @param string $path to the file - * @param string $user owner of the file + * @param string $ownerUser owner of the file * @param bool $includeOwner include owner to the list of users with access to the file + * @param bool $returnUserPaths Return an array with the user => path map * @return array * @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) { - return \OC\Share\Share::getUsersSharingFile($path, $user, $includeOwner); + public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false) { + return \OC\Share\Share::getUsersSharingFile($path, $ownerUser, $includeOwner, $returnUserPaths); } /** @@ -90,6 +91,22 @@ class Share extends \OC\Share\Constants { } /** + * Get the items of item type shared with a user + * @param string Item type + * @param sting user id for which user we want the shares + * @param int Format (optional) Format type must be defined by the backend + * @param mixed Parameters (optional) + * @param int Number of items to return (optional) Returns all by default + * @param bool include collections (optional) + * @return Return depends on format + */ + public static function getItemsSharedWithUser($itemType, $user, $format = self::FORMAT_NONE, + $parameters = null, $limit = -1, $includeCollections = false) { + + return \OC\Share\Share::getItemsSharedWithUser($itemType, $user, $format, $parameters, $limit, $includeCollections); + } + + /** * Get the item of item type shared with the current user * @param string $itemType * @param string $itemTarget diff --git a/lib/public/template.php b/lib/public/template.php index 9a994c1bea8..6cc984b12d5 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -67,7 +67,7 @@ function preview_icon( $path ) { * Returns the path to the preview of the image. * @param string $path of file * @param string $token - * @return link to the preview + * @return string link to the preview */ function publicPreview_icon ( $path, $token ) { return(\publicPreview_icon( $path, $token )); diff --git a/lib/public/util.php b/lib/public/util.php index f02213f2446..f06ddd66641 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -57,7 +57,7 @@ class Util { * @param string $mailtext * @param string $fromaddress * @param string $fromname - * @param bool $html + * @param int $html * @param string $altbody * @param string $ccaddress * @param string $ccname @@ -85,7 +85,7 @@ class Util { * write exception into the log. Include the stack trace * if DEBUG mode is enabled * @param string $app app name - * @param Exception $ex exception to log + * @param \Exception $ex exception to log */ public static function logException( $app, \Exception $ex ) { $class = get_class($ex); @@ -156,6 +156,7 @@ class Util { * formats a timestamp in the "right" way * @param int $timestamp $timestamp * @param bool $dateOnly option to omit time from the result + * @return string timestamp */ public static function formatDate( $timestamp, $dateOnly=false) { return(\OC_Util::formatDate( $timestamp, $dateOnly )); @@ -203,9 +204,8 @@ class Util { * Creates an url using a defined route * @param $route * @param array $parameters - * @return * @internal param array $args with param=>value, will be appended to the returned url - * @return the url + * @return string the url */ public static function linkToRoute( $route, $parameters = array() ) { return \OC_Helper::linkToRoute($route, $parameters); @@ -284,8 +284,7 @@ class Util { /** * Returns the request uri, even if the website uses one or more reverse proxies - * - * @return the request uri + * @return string the request uri */ public static function getRequestUri() { return(\OC_Request::requestUri()); @@ -293,8 +292,7 @@ class Util { /** * Returns the script name, even if the website uses one or more reverse proxies - * - * @return the script name + * @returns string the script name */ public static function getScriptName() { return(\OC_Request::scriptName()); @@ -350,7 +348,7 @@ class Util { * Emits a signal. To get data from the slot use references! * @param string $signalclass class name of emitter * @param string $signalname name of signal - * @param string $params defautl: array() array with additional data + * @param array $params default: array() array with additional data * @return bool true if slots exists or false if not * * TODO: write example @@ -467,9 +465,8 @@ class Util { /** * Calculate free space left within user quota - * - * @param $dir the current folder where the user currently operates - * @return number of bytes representing + * @param string $dir the current folder where the user currently operates + * @return int number of bytes representing */ public static function freeSpace($dir) { return \OC_Helper::freeSpace($dir); |