fix documentation stuff

This commit is contained in:
Morris Jobke 2013-10-31 19:00:53 +01:00
parent be07e828ef
commit 0dbe90cc9a
8 changed files with 413 additions and 417 deletions

View File

@ -44,7 +44,7 @@ use \OC\BackgroundJob\JobList;
*/ */
class BackgroundJob { class BackgroundJob {
/** /**
* @brief get the execution type of background jobs * get the execution type of background jobs
* @return string * @return string
* *
* This method returns the type how background jobs are executed. If the user * This method returns the type how background jobs are executed. If the user
@ -55,7 +55,7 @@ class BackgroundJob {
} }
/** /**
* @brief sets the background jobs execution type * sets the background jobs execution type
* @param string $type execution type * @param string $type execution type
* @return boolean * @return boolean
* *
@ -77,7 +77,7 @@ class BackgroundJob {
/** /**
* @deprecated * @deprecated
* @brief creates a regular task * creates a regular task
* @param string $klass class name * @param string $klass class name
* @param string $method method name * @param string $method method name
* @return true * @return true
@ -89,7 +89,7 @@ class BackgroundJob {
/** /**
* @deprecated * @deprecated
* @brief gets all regular tasks * gets all regular tasks
* @return associative array * @return associative array
* *
* key is string "$klass-$method", value is array( $klass, $method ) * key is string "$klass-$method", value is array( $klass, $method )
@ -109,7 +109,7 @@ class BackgroundJob {
/** /**
* @deprecated * @deprecated
* @brief Gets one queued task * Gets one queued task
* @param int $id ID of the task * @param int $id ID of the task
* @return associative array * @return associative array
*/ */
@ -120,7 +120,7 @@ class BackgroundJob {
/** /**
* @deprecated * @deprecated
* @brief Gets all queued tasks * Gets all queued tasks
* @return array with associative arrays * @return array with associative arrays
*/ */
public static function allQueuedTasks() { public static function allQueuedTasks() {
@ -139,7 +139,7 @@ class BackgroundJob {
/** /**
* @deprecated * @deprecated
* @brief Gets all queued tasks of a specific app * Gets all queued tasks of a specific app
* @param string $app app name * @param string $app app name
* @return array with associative arrays * @return array with associative arrays
*/ */
@ -161,7 +161,7 @@ class BackgroundJob {
/** /**
* @deprecated * @deprecated
* @brief queues a task * queues a task
* @param string $app app name * @param string $app app name
* @param string $class class name * @param string $class class name
* @param string $method method name * @param string $method method name
@ -175,7 +175,7 @@ class BackgroundJob {
/** /**
* @deprecated * @deprecated
* @brief deletes a queued task * deletes a queued task
* @param int $id id of task * @param int $id id of task
* @return bool * @return bool
* *

View File

@ -27,7 +27,7 @@
*/ */
/** /**
* @brief use OCP namespace for all classes that are considered public. * Use OCP namespace for all classes that are considered public.
* *
* Classes that use this namespace are for use by apps, and not for use by internal * Classes that use this namespace are for use by apps, and not for use by internal
* OC classes * OC classes

View File

@ -15,7 +15,7 @@ interface IPreview
{ {
/** /**
* @brief return a preview of a file * Return a preview of a file
* @param string $file The path to the file where you want a thumbnail from * @param string $file The path to the file where you want a thumbnail from
* @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
@ -26,7 +26,7 @@ interface IPreview
/** /**
* @brief returns true if the passed mime type is supported * Returns true if the passed mime type is supported
* @param string $mimeType * @param string $mimeType
* @return boolean * @return boolean
*/ */

View File

@ -4,7 +4,7 @@
* This file is licensed under the Affero General Public License version 3 or * This file is licensed under the Affero General Public License version 3 or
* later. * later.
* See the COPYING-README file. * See the COPYING-README file.
* *
*/ */
namespace OCP; namespace OCP;
@ -22,7 +22,7 @@ interface IUserSession {
public function login($user, $password); public function login($user, $password);
/** /**
* @brief Logs the user out including all the session data * Logs the user out including all the session data
* Logout, destroys session * Logout, destroys session
*/ */
public function logout(); public function logout();

View File

@ -35,7 +35,7 @@ namespace OCP;
*/ */
class JSON { class JSON {
/** /**
* @brief Encode and print $data in JSON format * Encode and print $data in JSON format
* @param array $data The data to use * @param array $data The data to use
* @param string $setContentType the optional content type * @param string $setContentType the optional content type
* @return string json formatted string. * @return string json formatted string.
@ -123,7 +123,7 @@ class JSON {
} }
/** /**
* @brief set Content-Type header to jsonrequest * Set Content-Type header to jsonrequest
* @param array $type The contwnt type header * @param array $type The contwnt type header
* @return string json formatted string. * @return string json formatted string.
*/ */

View File

@ -1,24 +1,24 @@
<?php <?php
/** /**
* ownCloud * ownCloud
* *
* @author Frank Karlitschek * @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org * @copyright 2012 Frank Karlitschek frank@owncloud.org
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 3 of the License, or any later version. * version 3 of the License, or any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* *
* You should have received a copy of the GNU Affero General Public * 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/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
/** /**
* Public interface of ownCloud for apps to use. * Public interface of ownCloud for apps to use.
@ -35,64 +35,64 @@ namespace OCP;
*/ */
class Response { class Response {
/** /**
* Enable response caching by sending correct HTTP headers * Enable response caching by sending correct HTTP headers
* @param int $cache_time time to cache the response * @param int $cache_time time to cache the response
* >0 cache time in seconds * >0 cache time in seconds
* 0 and <0 enable default browser caching * 0 and <0 enable default browser caching
* null cache indefinitly * null cache indefinitly
*/ */
static public function enableCaching( $cache_time = null ) { static public function enableCaching( $cache_time = null ) {
\OC_Response::enableCaching( $cache_time ); \OC_Response::enableCaching( $cache_time );
} }
/** /**
* Checks and set Last-Modified header, when the request matches sends a * Checks and set Last-Modified header, when the request matches sends a
* 'not modified' response * 'not modified' response
* @param string $lastModified time when the reponse was last modified * @param string $lastModified time when the reponse was last modified
*/ */
static public function setLastModifiedHeader( $lastModified ) { static public function setLastModifiedHeader( $lastModified ) {
\OC_Response::setLastModifiedHeader( $lastModified ); \OC_Response::setLastModifiedHeader( $lastModified );
} }
/** /**
* Disable browser caching * Disable browser caching
* @see enableCaching with cache_time = 0 * @see enableCaching with cache_time = 0
*/ */
static public function disableCaching() { static public function disableCaching() {
\OC_Response::disableCaching(); \OC_Response::disableCaching();
} }
/** /**
* Checks and set ETag header, when the request matches sends a * Checks and set ETag header, when the request matches sends a
* 'not modified' response * 'not modified' response
* @param string $etag token to use for modification check * @param string $etag token to use for modification check
*/ */
static public function setETagHeader( $etag ) { static public function setETagHeader( $etag ) {
\OC_Response::setETagHeader( $etag ); \OC_Response::setETagHeader( $etag );
} }
/** /**
* Send file as response, checking and setting caching headers * Send file as response, checking and setting caching headers
* @param string $filepath of file to send * @param string $filepath of file to send
*/ */
static public function sendFile( $filepath ) { static public function sendFile( $filepath ) {
\OC_Response::sendFile( $filepath ); \OC_Response::sendFile( $filepath );
} }
/** /**
* Set response expire time * Set response expire time
* @param string|\DateTime $expires date-time when the response expires * @param string|\DateTime $expires date-time when the response expires
* string for DateInterval from now * string for DateInterval from now
* DateTime object when to expire response * DateTime object when to expire response
*/ */
static public function setExpiresHeader( $expires ) { static public function setExpiresHeader( $expires ) {
\OC_Response::setExpiresHeader( $expires ); \OC_Response::setExpiresHeader( $expires );
} }
/** /**
* Send redirect response * Send redirect response
* @param string $location to redirect to * @param string $location to redirect to
*/ */
static public function redirect( $location ) { static public function redirect( $location ) {
\OC_Response::redirect( $location ); \OC_Response::redirect( $location );
} }

View File

@ -1,32 +1,32 @@
<?php <?php
/** /**
* ownCloud * ownCloud
* *
* @author Michael Gapczynski * @author Michael Gapczynski
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 3 of the License, or any later version. * version 3 of the License, or any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
* *
* You should have received a copy of the GNU Affero General Public * 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/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
namespace OCP; namespace OCP;
/** /**
* This class provides the ability for apps to share their content between users. * This class provides the ability for apps to share their content between users.
* Apps must create a backend class that implements OCP\Share_Backend and register it with this class. * Apps must create a backend class that implements OCP\Share_Backend and register it with this class.
* *
* It provides the following hooks: * It provides the following hooks:
* - post_shared * - post_shared
*/ */
class Share { class Share {
const SHARE_TYPE_USER = 0; const SHARE_TYPE_USER = 0;
@ -37,19 +37,19 @@ class Share {
const SHARE_TYPE_REMOTE = 6; const SHARE_TYPE_REMOTE = 6;
/** CRUDS permissions (Create, Read, Update, Delete, Share) using a bitmask /** CRUDS permissions (Create, Read, Update, Delete, Share) using a bitmask
* Construct permissions for share() and setPermissions with Or (|) e.g. * Construct permissions for share() and setPermissions with Or (|) e.g.
* Give user read and update permissions: PERMISSION_READ | PERMISSION_UPDATE * Give user read and update permissions: PERMISSION_READ | PERMISSION_UPDATE
* *
* Check if permission is granted with And (&) e.g. Check if delete is * Check if permission is granted with And (&) e.g. Check if delete is
* granted: if ($permissions & PERMISSION_DELETE) * granted: if ($permissions & PERMISSION_DELETE)
* *
* Remove permissions with And (&) and Not (~) e.g. Remove the update * Remove permissions with And (&) and Not (~) e.g. Remove the update
* permission: $permissions &= ~PERMISSION_UPDATE * permission: $permissions &= ~PERMISSION_UPDATE
* *
* Apps are required to handle permissions on their own, this class only * Apps are required to handle permissions on their own, this class only
* stores and manages the permissions of shares * stores and manages the permissions of shares
* @see lib/public/constants.php * @see lib/public/constants.php
*/ */
const FORMAT_NONE = -1; const FORMAT_NONE = -1;
const FORMAT_STATUSES = -2; const FORMAT_STATUSES = -2;
@ -64,13 +64,13 @@ class Share {
private static $isResharingAllowed; private static $isResharingAllowed;
/** /**
* Register a sharing backend class that implements OCP\Share_Backend for an item type * Register a sharing backend class that implements OCP\Share_Backend for an item type
* @param string Item type * @param string Item type
* @param string Backend class * @param string Backend class
* @param string (optional) Depends on item type * @param string (optional) Depends on item type
* @param array (optional) List of supported file extensions if this item type depends on files * @param array (optional) List of supported file extensions if this item type depends on files
* @return Returns true if backend is registered or false if error * @return Returns true if backend is registered or false if error
*/ */
public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) { public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) {
if (self::isEnabled()) { if (self::isEnabled()) {
if (!isset(self::$backendTypes[$itemType])) { if (!isset(self::$backendTypes[$itemType])) {
@ -94,11 +94,11 @@ class Share {
} }
/** /**
* Check if the Share API is enabled * Check if the Share API is enabled
* @return Returns true if enabled or false * @return Returns true if enabled or false
* *
* The Share API is enabled by default if not configured * The Share API is enabled by default if not configured
*/ */
public static function isEnabled() { public static function isEnabled() {
if (\OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes') == 'yes') { if (\OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes') == 'yes') {
return true; return true;
@ -107,9 +107,10 @@ class Share {
} }
/** /**
* Prepare a path to be passed to DB as file_target * Prepare a path to be passed to DB as file_target
* @return string Prepared path * @param string $path path
*/ * @return string Prepared path
*/
public static function prepFileTarget( $path ) { public static function prepFileTarget( $path ) {
// Paths in DB are stored with leading slashes, so add one if necessary // Paths in DB are stored with leading slashes, so add one if necessary
@ -124,14 +125,14 @@ class Share {
} }
/** /**
* Find which users can access a shared item * Find which users can access a shared item
* @param $path to the file * @param $path to the file
* @param $user owner of the file * @param $user owner of the file
* @param include owner to the list of users with access to the file * @param include owner to the list of users with access to the file
* @return array * @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' * not '/admin/data/file.txt'
*/ */
public static function getUsersSharingFile($path, $user, $includeOwner = false) { public static function getUsersSharingFile($path, $user, $includeOwner = false) {
$shares = array(); $shares = array();
@ -231,12 +232,12 @@ class Share {
} }
/** /**
* Get the items of item type shared with the current user * Get the items of item type shared with the current user
* @param string Item type * @param string Item type
* @param int Format (optional) Format type must be defined by the backend * @param int Format (optional) Format type must be defined by the backend
* @param int Number of items to return (optional) Returns all by default * @param int Number of items to return (optional) Returns all by default
* @return Return depends on format * @return Return depends on format
*/ */
public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE, public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE,
$parameters = null, $limit = -1, $includeCollections = false) { $parameters = null, $limit = -1, $includeCollections = false) {
return self::getItems($itemType, null, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, return self::getItems($itemType, null, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format,
@ -244,12 +245,12 @@ class Share {
} }
/** /**
* Get the item of item type shared with the current user * Get the item of item type shared with the current user
* @param string $itemType * @param string $itemType
* @param string $ItemTarget * @param string $ItemTarget
* @param int $format (optional) Format type must be defined by the backend * @param int $format (optional) Format type must be defined by the backend
* @return Return depends on format * @return Return depends on format
*/ */
public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE,
$parameters = null, $includeCollections = false) { $parameters = null, $includeCollections = false) {
return self::getItems($itemType, $itemTarget, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, return self::getItems($itemType, $itemTarget, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format,
@ -306,12 +307,14 @@ class Share {
} }
/** /**
* Get the item of item type shared with the current user by source * Get the item of item type shared with the current user by source
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param int Format (optional) Format type must be defined by the backend * @param int Format (optional) Format type must be defined by the backend
* @return Return depends on format * @param mixed Parameters
*/ * @param bool include collections
* @return Return depends on format
*/
public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE, public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE,
$parameters = null, $includeCollections = false) { $parameters = null, $includeCollections = false) {
return self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, return self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format,
@ -319,12 +322,12 @@ class Share {
} }
/** /**
* Get the item of item type shared by a link * Get the item of item type shared by a link
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param string Owner of link * @param string Owner of link
* @return Item * @return Item
*/ */
public static function getItemSharedWithByLink($itemType, $itemSource, $uidOwner) { public static function getItemSharedWithByLink($itemType, $itemSource, $uidOwner) {
return self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE, return self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE,
null, 1); null, 1);
@ -379,12 +382,14 @@ class Share {
/** /**
* Get the shared items of item type owned by the current user * Get the shared items of item type owned by the current user
* @param string Item type * @param string Item type
* @param int Format (optional) Format type must be defined by the backend * @param int Format (optional) Format type must be defined by the backend
* @param int Number of items to return (optional) Returns all by default * @param mixed Parameters
* @return Return depends on format * @param int Number of items to return (optional) Returns all by default
*/ * @param bool include collections
* @return Return depends on format
*/
public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null, public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null,
$limit = -1, $includeCollections = false) { $limit = -1, $includeCollections = false) {
return self::getItems($itemType, null, null, null, \OC_User::getUser(), $format, return self::getItems($itemType, null, null, null, \OC_User::getUser(), $format,
@ -392,12 +397,14 @@ class Share {
} }
/** /**
* Get the shared item of item type owned by the current user * Get the shared item of item type owned by the current user
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param int Format (optional) Format type must be defined by the backend * @param int Format (optional) Format type must be defined by the backend
* @return Return depends on format * @param mixed Parameters
*/ * @param bool include collections
* @return Return depends on format
*/
public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE, public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE,
$parameters = null, $includeCollections = false) { $parameters = null, $includeCollections = false) {
return self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), $format, return self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), $format,
@ -405,13 +412,13 @@ class Share {
} }
/** /**
* Get all users an item is shared with * Get all users an item is shared with
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param string Owner * @param string Owner
* @param bool Include collections * @param bool Include collections
* @return Return array of users * @return Return array of users
*/ */
public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false) { public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false) {
$users = array(); $users = array();
$items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections); $items = self::getItems($itemType, $itemSource, null, null, $uidOwner, self::FORMAT_NONE, null, -1, $includeCollections);
@ -617,13 +624,13 @@ class Share {
} }
/** /**
* Unshare an item from a user, group, or delete a private link * Unshare an item from a user, group, or delete a private link
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with * @param string User or group the item is being shared with
* @return Returns true on success or false on failure * @return Returns true on success or false on failure
*/ */
public static function unshare($itemType, $itemSource, $shareType, $shareWith) { public static function unshare($itemType, $itemSource, $shareType, $shareWith) {
if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(),
self::FORMAT_NONE, null, 1)) { self::FORMAT_NONE, null, 1)) {
@ -650,11 +657,11 @@ class Share {
} }
/** /**
* Unshare an item from all users, groups, and remove all links * Unshare an item from all users, groups, and remove all links
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @return Returns true on success or false on failure * @return Returns true on success or false on failure
*/ */
public static function unshareAll($itemType, $itemSource) { public static function unshareAll($itemType, $itemSource) {
if ($shares = self::getItemShared($itemType, $itemSource)) { if ($shares = self::getItemShared($itemType, $itemSource)) {
// Pass all the vars we have for now, they may be useful // Pass all the vars we have for now, they may be useful
@ -677,14 +684,13 @@ class Share {
} }
/** /**
* Unshare an item shared with the current user * Unshare an item shared with the current user
* @param string Item type * @param string Item type
* @param string Item target * @param string Item target
* @return Returns true on success or false on failure * @return Returns true on success or false on failure
* *
* Unsharing from self is not allowed for items inside collections * Unsharing from self is not allowed for items inside collections
* */
*/
public static function unshareFromSelf($itemType, $itemTarget) { public static function unshareFromSelf($itemType, $itemTarget) {
if ($item = self::getItemSharedWith($itemType, $itemTarget)) { if ($item = self::getItemSharedWith($itemType, $itemTarget)) {
if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) { if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) {
@ -733,19 +739,17 @@ class Share {
if($result === false) { if($result === false) {
\OC_Log::write('OCP\Share', 'Couldn\'t set send mail status', \OC_Log::ERROR); \OC_Log::write('OCP\Share', 'Couldn\'t set send mail status', \OC_Log::ERROR);
} }
} }
/** /**
* Set the permissions of an item for a specific user or group * Set the permissions of an item for a specific user or group
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with * @param string User or group the item is being shared with
* @param int CRUDS permissions * @param int CRUDS permissions
* @return Returns true on success or false on failure * @return Returns true on success or false on failure
*/ */
public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) { public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) {
if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith,
\OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) { \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) {
@ -821,6 +825,13 @@ class Share {
throw new \Exception($message); throw new \Exception($message);
} }
/**
* Set expiration date for a share
* @param string $itemType
* @param string $itemSource
* @param string $date expiration date
* @return Share_Backend
*/
public static function setExpirationDate($itemType, $itemSource, $date) { public static function setExpirationDate($itemType, $itemSource, $date) {
if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(),
self::FORMAT_NONE, null, -1, false)) { self::FORMAT_NONE, null, -1, false)) {
@ -842,10 +853,10 @@ class Share {
} }
/** /**
* Get the backend class for the specified item type * Get the backend class for the specified item type
* @param string $itemType * @param string $itemType
* @return Share_Backend * @return Share_Backend
*/ */
public static function getBackend($itemType) { public static function getBackend($itemType) {
if (isset(self::$backends[$itemType])) { if (isset(self::$backends[$itemType])) {
return self::$backends[$itemType]; return self::$backends[$itemType];
@ -871,12 +882,11 @@ class Share {
} }
/** /**
* Check if resharing is allowed * Check if resharing is allowed
* @return Returns true if allowed or false * @return Returns true if allowed or false
* *
* Resharing is allowed by default if not configured * Resharing is allowed by default if not configured
* */
*/
private static function isResharingAllowed() { private static function isResharingAllowed() {
if (!isset(self::$isResharingAllowed)) { if (!isset(self::$isResharingAllowed)) {
if (\OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') { if (\OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {
@ -889,10 +899,10 @@ class Share {
} }
/** /**
* Get a list of collection item types for the specified item type * Get a list of collection item types for the specified item type
* @param string Item type * @param string Item type
* @return array * @return array
*/ */
private static function getCollectionItemTypes($itemType) { private static function getCollectionItemTypes($itemType) {
$collectionTypes = array($itemType); $collectionTypes = array($itemType);
foreach (self::$backendTypes as $type => $backend) { foreach (self::$backendTypes as $type => $backend) {
@ -913,21 +923,21 @@ class Share {
} }
/** /**
* Get shared items from the database * Get shared items from the database
* @param string Item type * @param string Item type
* @param string Item source or target (optional) * @param string Item source or target (optional)
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, SHARE_TYPE_LINK, $shareTypeUserAndGroups, or $shareTypeGroupUserUnique * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, SHARE_TYPE_LINK, $shareTypeUserAndGroups, or $shareTypeGroupUserUnique
* @param string User or group the item is being shared with * @param string User or group the item is being shared with
* @param string User that is the owner of shared items (optional) * @param string User that is the owner of shared items (optional)
* @param int Format to convert items to with formatItems() * @param int Format to convert items to with formatItems()
* @param mixed Parameters to pass to formatItems() * @param mixed Parameters to pass to formatItems()
* @param int Number of items to return, -1 to return all matches (optional) * @param int Number of items to return, -1 to return all matches (optional)
* @param bool Include collection item types (optional) * @param bool Include collection item types (optional)
* @return mixed * @return mixed
* *
* See public functions getItem(s)... for parameter usage * See public functions getItem(s)... for parameter usage
* *
*/ */
private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null, private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null,
$uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, $uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1,
$includeCollections = false, $itemShareWithBySource = false) { $includeCollections = false, $itemShareWithBySource = false) {
@ -1322,15 +1332,15 @@ class Share {
} }
/** /**
* Put shared item into the database * Put shared item into the database
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with * @param string User or group the item is being shared with
* @param int CRUDS permissions * @param int CRUDS permissions
* @param bool|array Parent folder target (optional) * @param bool|array Parent folder target (optional)
* @return bool Returns true on success or false on failure * @return bool Returns true on success or false on failure
*/ */
private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$permissions, $parentFolder = null, $token = null, $itemSourceName = null) { $permissions, $parentFolder = null, $token = null, $itemSourceName = null) {
$backend = self::getBackend($itemType); $backend = self::getBackend($itemType);
@ -1561,15 +1571,15 @@ class Share {
} }
/** /**
* Generate a unique target for the item * Generate a unique target for the item
* @param string Item type * @param string Item type
* @param string Item source * @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with * @param string User or group the item is being shared with
* @param string The suggested target originating from a reshare (optional) * @param string The suggested target originating from a reshare (optional)
* @param int The id of the parent group share (optional) * @param int The id of the parent group share (optional)
* @return string Item target * @return string Item target
*/ */
private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$suggestedTarget = null, $groupParent = null) { $suggestedTarget = null, $groupParent = null) {
$backend = self::getBackend($itemType); $backend = self::getBackend($itemType);
@ -1677,11 +1687,11 @@ class Share {
} }
/** /**
* Delete all reshares of an item * Delete all reshares of an item
* @param int Id of item to delete * @param int Id of item to delete
* @param bool If true, exclude the parent from the delete (optional) * @param bool If true, exclude the parent from the delete (optional)
* @param string The user that the parent was shared with (optinal) * @param string The user that the parent was shared with (optinal)
*/ */
private static function delete($parent, $excludeParent = false, $uidOwner = null) { private static function delete($parent, $excludeParent = false, $uidOwner = null) {
$ids = array($parent); $ids = array($parent);
$parents = array($parent); $parents = array($parent);
@ -1749,9 +1759,12 @@ class Share {
} }
/** /**
* Hook Listeners * Hook Listeners
*/ */
/**
* @param array arguments
*/
public static function post_deleteUser($arguments) { public static function post_deleteUser($arguments) {
// Delete any items shared with the deleted user // Delete any items shared with the deleted user
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*share`' $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share`'
@ -1765,6 +1778,9 @@ class Share {
} }
} }
/**
* @param array arguments
*/
public static function post_addToGroup($arguments) { public static function post_addToGroup($arguments) {
// Find the group shares and check if the user needs a unique target // Find the group shares and check if the user needs a unique target
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?'); $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?');
@ -1795,6 +1811,9 @@ class Share {
} }
} }
/**
* @param array arguments
*/
public static function post_removeFromGroup($arguments) { public static function post_removeFromGroup($arguments) {
// TODO Don't call if user deleted? // TODO Don't call if user deleted?
$sql = 'SELECT `id`, `share_type` FROM `*PREFIX*share`' $sql = 'SELECT `id`, `share_type` FROM `*PREFIX*share`'
@ -1811,6 +1830,9 @@ class Share {
} }
} }
/**
* @param array arguments
*/
public static function post_deleteGroup($arguments) { public static function post_deleteGroup($arguments) {
$sql = 'SELECT `id` FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?'; $sql = 'SELECT `id` FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?';
$result = \OC_DB::executeAudited($sql, array(self::SHARE_TYPE_GROUP, $arguments['gid'])); $result = \OC_DB::executeAudited($sql, array(self::SHARE_TYPE_GROUP, $arguments['gid']));
@ -1822,84 +1844,84 @@ class Share {
} }
/** /**
* Interface that apps must implement to share content. * Interface that apps must implement to share content.
*/ */
interface Share_Backend { interface Share_Backend {
/** /**
* Get the source of the item to be stored in the database * Get the source of the item to be stored in the database
* @param string Item source * @param string Item source
* @param string Owner of the item * @param string Owner of the item
* @return mixed|array|false Source * @return mixed|array|false Source
* *
* Return an array if the item is file dependent, the array needs two keys: 'item' and 'file' * Return an array if the item is file dependent, the array needs two keys: 'item' and 'file'
* Return false if the item does not exist for the user * Return false if the item does not exist for the user
* *
* The formatItems() function will translate the source returned back into the item * The formatItems() function will translate the source returned back into the item
*/ */
public function isValidSource($itemSource, $uidOwner); public function isValidSource($itemSource, $uidOwner);
/** /**
* Get a unique name of the item for the specified user * Get a unique name of the item for the specified user
* @param string Item source * @param string Item source
* @param string|false User the item is being shared with * @param string|false User the item is being shared with
* @param array|null List of similar item names already existing as shared items * @param array|null List of similar item names already existing as shared items
* @return string Target name * @return string Target name
* *
* This function needs to verify that the user does not already have an item with this name. * This function needs to verify that the user does not already have an item with this name.
* If it does generate a new name e.g. name_# * If it does generate a new name e.g. name_#
*/ */
public function generateTarget($itemSource, $shareWith, $exclude = null); public function generateTarget($itemSource, $shareWith, $exclude = null);
/** /**
* Converts the shared item sources back into the item in the specified format * Converts the shared item sources back into the item in the specified format
* @param array Shared items * @param array Shared items
* @param int Format * @param int Format
* @return ? * @return ?
* *
* The items array is a 3-dimensional array with the item_source as the * The items array is a 3-dimensional array with the item_source as the
* first key and the share id as the second key to an array with the share * first key and the share id as the second key to an array with the share
* info. * info.
* *
* The key/value pairs included in the share info depend on the function originally called: * The key/value pairs included in the share info depend on the function originally called:
* If called by getItem(s)Shared: id, item_type, item, item_source, * If called by getItem(s)Shared: id, item_type, item, item_source,
* share_type, share_with, permissions, stime, file_source * share_type, share_with, permissions, stime, file_source
* *
* If called by getItem(s)SharedWith: id, item_type, item, item_source, * If called by getItem(s)SharedWith: id, item_type, item, item_source,
* item_target, share_type, share_with, permissions, stime, file_source, * item_target, share_type, share_with, permissions, stime, file_source,
* file_target * file_target
* *
* This function allows the backend to control the output of shared items with custom formats. * This function allows the backend to control the output of shared items with custom formats.
* It is only called through calls to the public getItem(s)Shared(With) functions. * It is only called through calls to the public getItem(s)Shared(With) functions.
*/ */
public function formatItems($items, $format, $parameters = null); public function formatItems($items, $format, $parameters = null);
} }
/** /**
* Interface for share backends that share content that is dependent on files. * Interface for share backends that share content that is dependent on files.
* Extends the Share_Backend interface. * Extends the Share_Backend interface.
*/ */
interface Share_Backend_File_Dependent extends Share_Backend { interface Share_Backend_File_Dependent extends Share_Backend {
/** /**
* Get the file path of the item * Get the file path of the item
*/ */
public function getFilePath($itemSource, $uidOwner); public function getFilePath($itemSource, $uidOwner);
} }
/** /**
* Interface for collections of of items implemented by another share backend. * Interface for collections of of items implemented by another share backend.
* Extends the Share_Backend interface. * Extends the Share_Backend interface.
*/ */
interface Share_Backend_Collection extends Share_Backend { interface Share_Backend_Collection extends Share_Backend {
/** /**
* Get the sources of the children of the item * Get the sources of the children of the item
* @param string Item source * @param string Item source
* @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable
*/ */
public function getChildren($itemSource); public function getChildren($itemSource);
} }

View File

@ -42,7 +42,7 @@ class Util {
const FATAL=4; const FATAL=4;
/** /**
* @brief get the current installed version of ownCloud * get the current installed version of ownCloud
* @return array * @return array
*/ */
public static function getVersion() { public static function getVersion() {
@ -50,7 +50,7 @@ class Util {
} }
/** /**
* @brief send an email * send an email
* @param string $toaddress * @param string $toaddress
* @param string $toname * @param string $toname
* @param string $subject * @param string $subject
@ -58,6 +58,10 @@ class Util {
* @param string $fromaddress * @param string $fromaddress
* @param string $fromname * @param string $fromname
* @param bool $html * @param bool $html
* @param string $altbody
* @param string $ccaddress
* @param string $ccname
* @param string $bcc
*/ */
public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname,
$html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') {
@ -67,7 +71,7 @@ class Util {
} }
/** /**
* @brief write a message in the log * write a message in the log
* @param string $app * @param string $app
* @param string $message * @param string $message
* @param int $level * @param int $level
@ -78,8 +82,9 @@ class Util {
} }
/** /**
* @brief write exception into the log. Include the stack trace * write exception into the log. Include the stack trace
* if DEBUG mode is enabled * 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 ) { public static function logException( $app, \Exception $ex ) {
@ -111,8 +116,8 @@ class Util {
} }
/** /**
* @brief get l10n object * get l10n object
* @param string $app * @param string $application
* @return OC_L10N * @return OC_L10N
*/ */
public static function getL10N( $application ) { public static function getL10N( $application ) {
@ -120,24 +125,25 @@ class Util {
} }
/** /**
* @brief add a css file * add a css file
* @param string $url * @param string $application
* @param string $file
*/ */
public static function addStyle( $application, $file = null ) { public static function addStyle( $application, $file = null ) {
\OC_Util::addStyle( $application, $file ); \OC_Util::addStyle( $application, $file );
} }
/** /**
* @brief add a javascript file * add a javascript file
* @param string $application * @param string $application
* @param string $file * @param string $file
*/ */
public static function addScript( $application, $file = null ) { public static function addScript( $application, $file = null ) {
\OC_Util::addScript( $application, $file ); \OC_Util::addScript( $application, $file );
} }
/** /**
* @brief Add a custom element to the header * Add a custom element to the header
* @param string $tag tag name of the element * @param string $tag tag name of the element
* @param array $attributes array of attributes for the element * @param array $attributes array of attributes for the element
* @param string $text the text content for the element * @param string $text the text content for the element
@ -147,7 +153,7 @@ class Util {
} }
/** /**
* @brief formats a timestamp in the "right" way * formats a timestamp in the "right" way
* @param int $timestamp $timestamp * @param int $timestamp $timestamp
* @param bool $dateOnly option to omit time from the result * @param bool $dateOnly option to omit time from the result
*/ */
@ -156,93 +162,78 @@ class Util {
} }
/** /**
* @brief check if some encrypted files are stored * check if some encrypted files are stored
* @return bool * @return bool
*/ */
public static function encryptedFiles() { public static function encryptedFiles() {
return \OC_Util::encryptedFiles(); return \OC_Util::encryptedFiles();
} }
/** /**
* @brief Creates an absolute url * Creates an absolute url to the given app and file.
* @param string $app app * @param string $app app
* @param string $file file * @param string $file file
* @param array $args array with param=>value, will be appended to the returned url * @param array $args array with param=>value, will be appended to the returned url
* The value of $args will be urlencoded * The value of $args will be urlencoded
* @returns string the url * @return string the url
*
* Returns a absolute url to the given app and file.
*/ */
public static function linkToAbsolute( $app, $file, $args = array() ) { public static function linkToAbsolute( $app, $file, $args = array() ) {
return(\OC_Helper::linkToAbsolute( $app, $file, $args )); return(\OC_Helper::linkToAbsolute( $app, $file, $args ));
} }
/** /**
* @brief Creates an absolute url for remote use * Creates an absolute url for remote use.
* @param string $service id * @param string $service id
* @returns string the url * @return string the url
*
* Returns a absolute url to the given app and file.
*/ */
public static function linkToRemote( $service ) { public static function linkToRemote( $service ) {
return(\OC_Helper::linkToRemote( $service )); return(\OC_Helper::linkToRemote( $service ));
} }
/** /**
* @brief Creates an absolute url for public use * Creates an absolute url for public use
* @param string $service id * @param string $service id
* @returns string the url * @return string the url
*
* Returns a absolute url to the given app and file.
*/ */
public static function linkToPublic($service) { public static function linkToPublic($service) {
return \OC_Helper::linkToPublic($service); return \OC_Helper::linkToPublic($service);
} }
/** /**
* @brief Creates an url using a defined route * Creates an url using a defined route
* @param $route * @param $route
* @param array $parameters * @param array $parameters
* @return * @return
* @internal param array $args with param=>value, will be appended to the returned url * @internal param array $args with param=>value, will be appended to the returned url
* @returns the url * @return the url
*
* Returns a url to the given app and file.
*/ */
public static function linkToRoute( $route, $parameters = array() ) { public static function linkToRoute( $route, $parameters = array() ) {
return \OC_Helper::linkToRoute($route, $parameters); return \OC_Helper::linkToRoute($route, $parameters);
} }
/** /**
* @brief Creates an url * Creates an url to the given app and file
* @param string $app app * @param string $app app
* @param string $file file * @param string $file file
* @param array $args array with param=>value, will be appended to the returned url * @param array $args array with param=>value, will be appended to the returned url
* The value of $args will be urlencoded * The value of $args will be urlencoded
* @returns string the url * @return string the url
*
* Returns a url to the given app and file.
*/ */
public static function linkTo( $app, $file, $args = array() ) { public static function linkTo( $app, $file, $args = array() ) {
return(\OC_Helper::linkTo( $app, $file, $args )); return(\OC_Helper::linkTo( $app, $file, $args ));
} }
/** /**
* @brief Returns the server host * Returns the server host, even if the website uses one or more reverse proxy
* @returns string the server host * @return string the server host
*
* Returns the server host, even if the website uses one or more
* reverse proxies
*/ */
public static function getServerHost() { public static function getServerHost() {
return(\OC_Request::serverHost()); return(\OC_Request::serverHost());
} }
/** /**
* @brief returns the server hostname
* @returns string the server hostname
*
* Returns the server host name without an eventual port number * Returns the server host name without an eventual port number
* @return string the server hostname
*/ */
public static function getServerHostName() { public static function getServerHostName() {
$host_name = self::getServerHost(); $host_name = self::getServerHost();
@ -255,9 +246,9 @@ class Util {
} }
/** /**
* @brief Returns the default email address * Returns the default email address
* @param string $user_part the user part of the address * @param string $user_part the user part of the address
* @returns string the default email address * @return string the default email address
* *
* Assembles a default email address (using the server hostname * Assembles a default email address (using the server hostname
* and the given user part, and returns it * and the given user part, and returns it
@ -279,66 +270,54 @@ class Util {
} }
/** /**
* @brief Returns the server protocol
* @returns string the server protocol
*
* Returns the server protocol. It respects reverse proxy servers and load balancers * Returns the server protocol. It respects reverse proxy servers and load balancers
* @return string the server protocol
*/ */
public static function getServerProtocol() { public static function getServerProtocol() {
return(\OC_Request::serverProtocol()); return(\OC_Request::serverProtocol());
} }
/** /**
* @brief Returns the request uri * Returns the request uri, even if the website uses one or more reverse proxies
* @returns the request uri
* *
* Returns the request uri, even if the website uses one or more * @return the request uri
* reverse proxies
*/ */
public static function getRequestUri() { public static function getRequestUri() {
return(\OC_Request::requestUri()); return(\OC_Request::requestUri());
} }
/** /**
* @brief Returns the script name * Returns the script name, even if the website uses one or more reverse proxies
* @returns the script name
* *
* Returns the script name, even if the website uses one or more * @return the script name
* reverse proxies
*/ */
public static function getScriptName() { public static function getScriptName() {
return(\OC_Request::scriptName()); return(\OC_Request::scriptName());
} }
/** /**
* @brief Creates path to an image * Creates path to an image
* @param string $app app * @param string $app app
* @param string $image image name * @param string $image image name
* @returns string the url * @return string the url
*
* Returns the path to the image.
*/ */
public static function imagePath( $app, $image ) { public static function imagePath( $app, $image ) {
return(\OC_Helper::imagePath( $app, $image )); return(\OC_Helper::imagePath( $app, $image ));
} }
/** /**
* @brief Make a human file size * Make a human file size (2048 to 2 kB)
* @param int $bytes file size in bytes * @param int $bytes file size in bytes
* @returns string a human readable file size * @return string a human readable file size
*
* Makes 2048 to 2 kB.
*/ */
public static function humanFileSize( $bytes ) { public static function humanFileSize( $bytes ) {
return(\OC_Helper::humanFileSize( $bytes )); return(\OC_Helper::humanFileSize( $bytes ));
} }
/** /**
* @brief Make a computer file size * Make a computer file size (2 kB to 2048)
* @param string $str file size in a fancy format * @param string $str file size in a fancy format
* @returns int a file size in bytes * @return int a file size in bytes
*
* Makes 2kB to 2048.
* *
* Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
*/ */
@ -347,12 +326,12 @@ class Util {
} }
/** /**
* @brief connects a function to a hook * connects a function to a hook
* @param string $signalclass class name of emitter * @param string $signalclass class name of emitter
* @param string $signalname name of signal * @param string $signalname name of signal
* @param string $slotclass class name of slot * @param string $slotclass class name of slot
* @param string $slotname name of slot * @param string $slotname name of slot
* @returns bool * @return bool
* *
* This function makes it very easy to connect to use hooks. * This function makes it very easy to connect to use hooks.
* *
@ -363,13 +342,11 @@ class Util {
} }
/** /**
* @brief emitts a signal * Emits a signal. To get data from the slot use references!
* @param string $signalclass class name of emitter * @param string $signalclass class name of emitter
* @param string $signalname name of signal * @param string $signalname name of signal
* @param string $params defautl: array() array with additional data * @param string $params defautl: array() array with additional data
* @returns bool true if slots exists or false if not * @return bool true if slots exists or false if not
*
* Emits a signal. To get data from the slot use references!
* *
* TODO: write example * TODO: write example
*/ */
@ -394,7 +371,7 @@ class Util {
} }
/** /**
* @brief Used to sanitize HTML * Used to sanitize HTML
* *
* This function is used to sanitize HTML and should be applied on any * This function is used to sanitize HTML and should be applied on any
* string or array of strings before displaying it on a web page. * string or array of strings before displaying it on a web page.
@ -405,78 +382,75 @@ class Util {
public static function sanitizeHTML( $value ) { public static function sanitizeHTML( $value ) {
return(\OC_Util::sanitizeHTML($value)); return(\OC_Util::sanitizeHTML($value));
} }
/** /**
* @brief Public function to encode url parameters * Public function to encode url parameters
* *
* This function is used to encode path to file before output. * This function is used to encode path to file before output.
* Encoding is done according to RFC 3986 with one exception: * Encoding is done according to RFC 3986 with one exception:
* Character '/' is preserved as is. * Character '/' is preserved as is.
* *
* @param string $component part of URI to encode * @param string $component part of URI to encode
* @return string * @return string
*/ */
public static function encodePath($component) { public static function encodePath($component) {
return(\OC_Util::encodePath($component)); return(\OC_Util::encodePath($component));
} }
/** /**
* @brief Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
* *
* @param array $input The array to work on * @param array $input The array to work on
* @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default) * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return array * @return array
* */
*
*/
public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
return(\OC_Helper::mb_array_change_key_case($input, $case, $encoding)); return(\OC_Helper::mb_array_change_key_case($input, $case, $encoding));
} }
/** /**
* @brief replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. * replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement.
* *
* @param string $input The input string. .Opposite to the PHP build-in function does not accept an array. * @param string $string The input string. Opposite to the PHP build-in function does not accept an array.
* @param string $replacement The replacement string. * @param string $replacement The replacement string.
* @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string. * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string.
* @param int $length Length of the part to be replaced * @param int $length Length of the part to be replaced
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return string * @return string
* */
*/
public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') { public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') {
return(\OC_Helper::mb_substr_replace($string, $replacement, $start, $length, $encoding)); return(\OC_Helper::mb_substr_replace($string, $replacement, $start, $length, $encoding));
} }
/** /**
* @brief Replace all occurrences of the search string with the replacement string * Replace all occurrences of the search string with the replacement string
* *
* @param string $search The value being searched for, otherwise known as the needle. String. * @param string $search The value being searched for, otherwise known as the needle. String.
* @param string $replace The replacement string. * @param string $replace The replacement string.
* @param string $subject The string or array being searched and replaced on, otherwise known as the haystack. * @param string $subject The string or array being searched and replaced on, otherwise known as the haystack.
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @param int $count If passed, this will be set to the number of replacements performed. * @param int $count If passed, this will be set to the number of replacements performed.
* @return string * @return string
* */
*/
public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) { public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) {
return(\OC_Helper::mb_str_replace($search, $replace, $subject, $encoding, $count)); return(\OC_Helper::mb_str_replace($search, $replace, $subject, $encoding, $count));
} }
/** /**
* @brief performs a search in a nested array * performs a search in a nested array
* @param array $haystack the array to be searched *
* @param string $needle the search string * @param array $haystack the array to be searched
* @param int $index optional, only search this key name * @param string $needle the search string
* @return mixed the key of the matching field, otherwise false * @param int $index optional, only search this key name
*/ * @return mixed the key of the matching field, otherwise false
*/
public static function recursiveArraySearch($haystack, $needle, $index = null) { public static function recursiveArraySearch($haystack, $needle, $index = null) {
return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index)); return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index));
} }
/** /**
* @brief calculates the maximum upload size respecting system settings, free space and user quota * calculates the maximum upload size respecting system settings, free space and user quota
* *
* @param $dir the current folder where the user currently operates * @param $dir the current folder where the user currently operates
* @return number of bytes representing * @return number of bytes representing