summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/appframework/middleware.php (renamed from lib/public/appframework/imiddleware.php)24
-rw-r--r--lib/public/authentication/iapachebackend.php49
-rw-r--r--lib/public/ihelper.php23
-rw-r--r--lib/public/il10n.php67
-rw-r--r--lib/public/irequest.php31
-rw-r--r--lib/public/iservercontainer.php17
-rw-r--r--lib/public/iurlgenerator.php47
-rw-r--r--lib/public/share.php90
-rw-r--r--lib/public/template.php4
9 files changed, 329 insertions, 23 deletions
diff --git a/lib/public/appframework/imiddleware.php b/lib/public/appframework/middleware.php
index 1e76d3bbe49..12776c119c0 100644
--- a/lib/public/appframework/imiddleware.php
+++ b/lib/public/appframework/middleware.php
@@ -23,6 +23,7 @@
namespace OCP\AppFramework;
+
use OCP\AppFramework\Http\Response;
@@ -32,7 +33,7 @@ use OCP\AppFramework\Http\Response;
* They're modeled after Django's middleware system:
* https://docs.djangoproject.com/en/dev/topics/http/middleware/
*/
-interface IMiddleWare {
+abstract class Middleware {
/**
@@ -43,7 +44,9 @@ interface IMiddleWare {
* @param string $methodName the name of the method that will be called on
* the controller
*/
- function beforeController($controller, $methodName);
+ public function beforeController($controller, $methodName){
+
+ }
/**
@@ -60,10 +63,13 @@ interface IMiddleWare {
* @throws \Exception the passed in exception if it cant handle it
* @return Response a Response object in case that the exception was handled
*/
- function afterException($controller, $methodName, \Exception $exception);
+ public function afterException($controller, $methodName, \Exception $exception){
+ throw $exception;
+ }
+
/**
- * This is being run after a successful controller method call and allows
+ * This is being run after a successful controllermethod call and allows
* the manipulation of a Response object. The middleware is run in reverse order
*
* @param Controller $controller the controller that is being called
@@ -72,7 +78,10 @@ interface IMiddleWare {
* @param Response $response the generated response from the controller
* @return Response a Response object
*/
- function afterController($controller, $methodName, Response $response);
+ public function afterController($controller, $methodName, Response $response){
+ return $response;
+ }
+
/**
* This is being run after the response object has been rendered and
@@ -84,5 +93,8 @@ interface IMiddleWare {
* @param string $output the generated output from a response
* @return string the output that should be printed
*/
- function beforeOutput($controller, $methodName, $output);
+ public function beforeOutput($controller, $methodName, $output){
+ return $output;
+ }
+
}
diff --git a/lib/public/authentication/iapachebackend.php b/lib/public/authentication/iapachebackend.php
new file mode 100644
index 00000000000..5376baf525c
--- /dev/null
+++ b/lib/public/authentication/iapachebackend.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * ownCloud - Apache backend
+ *
+ * @author Karl Beecher
+ * @copyright 2013 Karl Beecher - karl@endocode.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\Authentication;
+
+interface IApacheBackend {
+
+ /**
+ * In case the user has been authenticated by Apache true is returned.
+ *
+ * @return boolean whether Apache reports a user as currently logged in.
+ */
+ public function isSessionActive();
+
+ /**
+ * Creates an attribute which is added to the logout hyperlink. It can
+ * supply any attribute(s) which are valid for <a>.
+ *
+ * @return string with one or more HTML attributes.
+ */
+ public function getLogoutAttribute();
+
+ /**
+ * Return the id of the current user
+ * @return string
+ */
+ public function getCurrentUserId();
+
+}
diff --git a/lib/public/ihelper.php b/lib/public/ihelper.php
new file mode 100644
index 00000000000..fad02f7556a
--- /dev/null
+++ b/lib/public/ihelper.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Functions that don't have any specific interface to place
+ */
+interface IHelper {
+ /**
+ * Gets the content of an URL by using CURL or a fallback if it is not
+ * installed
+ * @param string $url the url that should be fetched
+ * @return string the content of the webpage
+ */
+ public function getUrlContent($url);
+}
diff --git a/lib/public/il10n.php b/lib/public/il10n.php
new file mode 100644
index 00000000000..9cf9093d391
--- /dev/null
+++ b/lib/public/il10n.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * TODO: Description
+ */
+interface IL10N {
+ /**
+ * @brief Translating
+ * @param $text String The text we need a translation for
+ * @param array $parameters default:array() Parameters for sprintf
+ * @return \OC_L10N_String|string Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $text will be
+ * returned.
+ */
+ public function t($text, $parameters = array());
+
+ /**
+ * @brief Translating
+ * @param $text_singular String the string to translate for exactly one object
+ * @param $text_plural String the string to translate for n objects
+ * @param $count Integer Number of objects
+ * @param array $parameters default:array() Parameters for sprintf
+ * @return \OC_L10N_String|string Translation or the same text
+ *
+ * Returns the translation. If no translation is found, $text will be
+ * returned. %n will be replaced with the number of objects.
+ *
+ * The correct plural is determined by the plural_forms-function
+ * provided by the po file.
+ *
+ */
+ public function n($text_singular, $text_plural, $count, $parameters = array());
+
+ /**
+ * @brief Localization
+ * @param $type Type of localization
+ * @param $params parameters for this localization
+ * @returns String or false
+ *
+ * Returns the localized data.
+ *
+ * Implemented types:
+ * - date
+ * - Creates a date
+ * - l10n-field: date
+ * - params: timestamp (int/string)
+ * - datetime
+ * - Creates date and time
+ * - l10n-field: datetime
+ * - params: timestamp (int/string)
+ * - time
+ * - Creates a time
+ * - l10n-field: time
+ * - params: timestamp (int/string)
+ */
+ public function l($type, $data);
+}
diff --git a/lib/public/irequest.php b/lib/public/irequest.php
index 9f335b06f2a..45b27868d70 100644
--- a/lib/public/irequest.php
+++ b/lib/public/irequest.php
@@ -22,6 +22,28 @@
namespace OCP;
+/**
+ * This interface provides an immutable object with with accessors to
+ * request variables and headers.
+ *
+ * Access request variables by method and name.
+ *
+ * Examples:
+ *
+ * $request->post['myvar']; // Only look for POST variables
+ * $request->myvar; or $request->{'myvar'}; or $request->{$myvar}
+ * Looks in the combined GET, POST and urlParams array.
+ *
+ * If you access e.g. ->post but the current HTTP request method
+ * is GET a \LogicException will be thrown.
+ *
+ * NOTE:
+ * - When accessing ->put a stream resource is returned and the accessor
+ * will return false on subsequent access to ->put or ->patch.
+ * - When accessing ->patch and the Content-Type is either application/json
+ * or application/x-www-form-urlencoded (most cases) it will act like ->get
+ * and ->post and return an array. Otherwise the raw data will be returned.
+ */
interface IRequest {
@@ -86,11 +108,8 @@ interface IRequest {
/**
- * Returns the request body content.
- *
- * @param Boolean $asResource If true, a resource will be returned
- * @return string|resource The request body content or a resource to read the body stream.
- * @throws \LogicException
+ * Checks if the CSRF check was correct
+ * @return bool true if CSRF check passed
*/
- function getContent($asResource = false);
+ public function passesCSRFCheck();
}
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index 287b8e9d902..cc9436a75c8 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -102,6 +102,23 @@ interface IServerContainer {
function getConfig();
/**
+ * get an L10N instance
+ * @param $app string appid
+ * @return \OCP\IL10N
+ */
+ function getL10N($app);
+
+ /**
+ * @return \OCP\IURLGenerator
+ */
+ function getURLGenerator();
+
+ /**
+ * @return \OCP\IHelper
+ */
+ function getHelper();
+
+ /**
* Returns an ICache instance
*
* @return \OCP\ICache
diff --git a/lib/public/iurlgenerator.php b/lib/public/iurlgenerator.php
new file mode 100644
index 00000000000..4eb4c0f8312
--- /dev/null
+++ b/lib/public/iurlgenerator.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Class to generate URLs
+ */
+interface IURLGenerator {
+ /**
+ * Returns the URL for a route
+ * @param string $routeName the name of the route
+ * @param array $arguments an array with arguments which will be filled into the url
+ * @return string the url
+ */
+ public function linkToRoute($routeName, $arguments = array());
+
+ /**
+ * Returns an URL for an image or file
+ * @param string $appName the name of the app
+ * @param string $file the name of the file
+ * @return string the url
+ */
+ public function linkTo($appName, $file);
+
+ /**
+ * Returns the link to an image, like linkTo but only with prepending img/
+ * @param string $appName the name of the app
+ * @param string $file the name of the file
+ * @return string the url
+ */
+ public function imagePath($appName, $file);
+
+
+ /**
+ * Makes an URL absolute
+ * @param string $url the url in the owncloud host
+ * @return string the absolute version of the url
+ */
+ public function getAbsoluteURL($url);
+}
diff --git a/lib/public/share.php b/lib/public/share.php
index ff11aad1a12..59bda042485 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -246,9 +246,9 @@ class Share {
/**
* @brief Get the item of item type shared with the current user
- * @param string Item type
- * @param string Item target
- * @param int Format (optional) Format type must be defined by the backend
+ * @param string $itemType
+ * @param string $ItemTarget
+ * @param int $format (optional) Format type must be defined by the backend
* @return Return depends on format
*/
public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE,
@@ -258,6 +258,55 @@ class Share {
}
/**
+ * @brief Get the item of item type shared with a given user by source
+ * @param string $ItemType
+ * @param string $ItemSource
+ * @param string $user User user to whom the item was shared
+ * @return array Return list of items with file_target, permissions and expiration
+ */
+ public static function getItemSharedWithUser($itemType, $itemSource, $user) {
+
+ $shares = array();
+
+ // first check if there is a db entry for the specific user
+ $query = \OC_DB::prepare(
+ 'SELECT `file_target`, `permissions`, `expiration`
+ FROM
+ `*PREFIX*share`
+ WHERE
+ `item_source` = ? AND `item_type` = ? AND `share_with` = ?'
+ );
+
+ $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, $user));
+
+ while ($row = $result->fetchRow()) {
+ $shares[] = $row;
+ }
+
+ //if didn't found a result than let's look for a group share.
+ if(empty($shares)) {
+ $groups = \OC_Group::getUserGroups($user);
+
+ $query = \OC_DB::prepare(
+ 'SELECT `file_target`, `permissions`, `expiration`
+ FROM
+ `*PREFIX*share`
+ WHERE
+ `item_source` = ? AND `item_type` = ? AND `share_with` in (?)'
+ );
+
+ $result = \OC_DB::executeAudited($query, array($itemSource, $itemType, implode(',', $groups)));
+
+ while ($row = $result->fetchRow()) {
+ $shares[] = $row;
+ }
+ }
+
+ return $shares;
+
+ }
+
+ /**
* @brief Get the item of item type shared with the current user by source
* @param string Item type
* @param string Item source
@@ -653,6 +702,29 @@ class Share {
}
return false;
}
+ /**
+ * @brief sent status if users got informed by mail about share
+ * @param string $itemType
+ * @param string $itemSource
+ * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
+ * @param bool $status
+ */
+ public static function setSendMailStatus($itemType, $itemSource, $shareType, $status) {
+ $status = $status ? 1 : 0;
+
+ $query = \OC_DB::prepare(
+ 'UPDATE `*PREFIX*share`
+ SET `mail_send` = ?
+ WHERE `item_type` = ? AND `item_source` = ? AND `share_type` = ?');
+
+ $result = $query->execute(array($status, $itemType, $itemSource, $shareType));
+
+ if($result === false) {
+ \OC_Log::write('OCP\Share', 'Couldn\'t set send mail status', \OC_Log::ERROR);
+ }
+
+
+ }
/**
* @brief Set the permissions of an item for a specific user or group
@@ -983,19 +1055,19 @@ 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`, `storage`';
+ .' `share_type`, `file_source`, `path`, `expiration`, `storage`, `mail_send`';
} else {
- $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`';
+ $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`, `mail_send`';
}
} else {
if (isset($uidOwner)) {
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`, `storage`';
+ .' `expiration`, `token`, `storage`, `mail_send`';
} else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,'
- .' `stime`, `file_source`, `expiration`, `token`';
+ .' `stime`, `file_source`, `expiration`, `token`, `mail_send`';
}
} else {
if ($fileDependent) {
@@ -1006,11 +1078,11 @@ class Share {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, '
.'`share_type`, `share_with`, `file_source`, `path`, `file_target`, '
.'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, '
- .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`';
+ .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`, `mail_send`';
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`,
`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,
- `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`';
+ `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`, `mail_send`';
}
} else {
$select = '*';
diff --git a/lib/public/template.php b/lib/public/template.php
index 3b1a4ed4906..a5c500b0e25 100644
--- a/lib/public/template.php
+++ b/lib/public/template.php
@@ -90,8 +90,8 @@ function human_file_size( $bytes ) {
* @param $timestamp unix timestamp
* @returns human readable interpretation of the timestamp
*/
-function relative_modified_date($timestamp) {
- return(\relative_modified_date($timestamp));
+function relative_modified_date($timestamp, $dateOnly = false) {
+ return(\relative_modified_date($timestamp, null, $dateOnly));
}