Browse Source

fix documentation stuff

tags/v6.0.0beta3
Morris Jobke 10 years ago
parent
commit
0dbe90cc9a

+ 9
- 9
lib/public/backgroundjob.php View File

@@ -44,7 +44,7 @@ use \OC\BackgroundJob\JobList;
*/
class BackgroundJob {
/**
* @brief get the execution type of background jobs
* get the execution type of background jobs
* @return string
*
* 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
* @return boolean
*
@@ -77,7 +77,7 @@ class BackgroundJob {

/**
* @deprecated
* @brief creates a regular task
* creates a regular task
* @param string $klass class name
* @param string $method method name
* @return true
@@ -89,7 +89,7 @@ class BackgroundJob {

/**
* @deprecated
* @brief gets all regular tasks
* gets all regular tasks
* @return associative array
*
* key is string "$klass-$method", value is array( $klass, $method )
@@ -109,7 +109,7 @@ class BackgroundJob {

/**
* @deprecated
* @brief Gets one queued task
* Gets one queued task
* @param int $id ID of the task
* @return associative array
*/
@@ -120,7 +120,7 @@ class BackgroundJob {

/**
* @deprecated
* @brief Gets all queued tasks
* Gets all queued tasks
* @return array with associative arrays
*/
public static function allQueuedTasks() {
@@ -139,7 +139,7 @@ class BackgroundJob {

/**
* @deprecated
* @brief Gets all queued tasks of a specific app
* Gets all queued tasks of a specific app
* @param string $app app name
* @return array with associative arrays
*/
@@ -161,7 +161,7 @@ class BackgroundJob {

/**
* @deprecated
* @brief queues a task
* queues a task
* @param string $app app name
* @param string $class class name
* @param string $method method name
@@ -175,7 +175,7 @@ class BackgroundJob {

/**
* @deprecated
* @brief deletes a queued task
* deletes a queued task
* @param int $id id of task
* @return bool
*

+ 1
- 1
lib/public/config.php 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
* OC classes

+ 2
- 2
lib/public/ipreview.php 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 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
@@ -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
* @return boolean
*/

+ 2
- 2
lib/public/iusersession.php View File

@@ -4,7 +4,7 @@
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*
*
*/

namespace OCP;
@@ -22,7 +22,7 @@ interface IUserSession {
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
*/
public function logout();

+ 2
- 2
lib/public/json.php View File

@@ -35,7 +35,7 @@ namespace OCP;
*/
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 string $setContentType the optional content type
* @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
* @return string json formatted string.
*/

+ 47
- 47
lib/public/response.php View File

@@ -1,24 +1,24 @@
<?php
/**
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* 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/>.
*
*/
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2012 Frank Karlitschek frank@owncloud.org
*
* 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/>.
*
*/

/**
* Public interface of ownCloud for apps to use.
@@ -35,64 +35,64 @@ namespace OCP;
*/
class Response {
/**
* Enable response caching by sending correct HTTP headers
* @param int $cache_time time to cache the response
* >0 cache time in seconds
* 0 and <0 enable default browser caching
* null cache indefinitly
*/
* Enable response caching by sending correct HTTP headers
* @param int $cache_time time to cache the response
* >0 cache time in seconds
* 0 and <0 enable default browser caching
* null cache indefinitly
*/
static public function enableCaching( $cache_time = null ) {
\OC_Response::enableCaching( $cache_time );
}

/**
* Checks and set Last-Modified header, when the request matches sends a
* 'not modified' response
* @param string $lastModified time when the reponse was last modified
*/
* Checks and set Last-Modified header, when the request matches sends a
* 'not modified' response
* @param string $lastModified time when the reponse was last modified
*/
static public function setLastModifiedHeader( $lastModified ) {
\OC_Response::setLastModifiedHeader( $lastModified );
}

/**
* Disable browser caching
* @see enableCaching with cache_time = 0
*/
* Disable browser caching
* @see enableCaching with cache_time = 0
*/
static public function disableCaching() {
\OC_Response::disableCaching();
}

/**
* Checks and set ETag header, when the request matches sends a
* 'not modified' response
* @param string $etag token to use for modification check
*/
* Checks and set ETag header, when the request matches sends a
* 'not modified' response
* @param string $etag token to use for modification check
*/
static public function setETagHeader( $etag ) {
\OC_Response::setETagHeader( $etag );
}

/**
* Send file as response, checking and setting caching headers
* @param string $filepath of file to send
*/
* Send file as response, checking and setting caching headers
* @param string $filepath of file to send
*/
static public function sendFile( $filepath ) {
\OC_Response::sendFile( $filepath );
}

/**
* Set response expire time
* @param string|\DateTime $expires date-time when the response expires
* string for DateInterval from now
* DateTime object when to expire response
*/
* Set response expire time
* @param string|\DateTime $expires date-time when the response expires
* string for DateInterval from now
* DateTime object when to expire response
*/
static public function setExpiresHeader( $expires ) {
\OC_Response::setExpiresHeader( $expires );
}

/**
* Send redirect response
* @param string $location to redirect to
*/
* Send redirect response
* @param string $location to redirect to
*/
static public function redirect( $location ) {
\OC_Response::redirect( $location );
}

+ 262
- 240
lib/public/share.php View File

@@ -1,32 +1,32 @@
<?php
/**
* ownCloud
*
* @author Michael Gapczynski
* @copyright 2012 Michael Gapczynski mtgap@owncloud.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/>.
*/
* ownCloud
*
* @author Michael Gapczynski
* @copyright 2012 Michael Gapczynski mtgap@owncloud.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;

/**
* 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.
*
* It provides the following hooks:
* - post_shared
*/
* 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.
*
* It provides the following hooks:
* - post_shared
*/
class Share {

const SHARE_TYPE_USER = 0;
@@ -37,19 +37,19 @@ class Share {
const SHARE_TYPE_REMOTE = 6;

/** CRUDS permissions (Create, Read, Update, Delete, Share) using a bitmask
* Construct permissions for share() and setPermissions with Or (|) e.g.
* Give user read and update permissions: PERMISSION_READ | PERMISSION_UPDATE
*
* Check if permission is granted with And (&) e.g. Check if delete is
* granted: if ($permissions & PERMISSION_DELETE)
*
* Remove permissions with And (&) and Not (~) e.g. Remove the update
* permission: $permissions &= ~PERMISSION_UPDATE
*
* Apps are required to handle permissions on their own, this class only
* stores and manages the permissions of shares
* @see lib/public/constants.php
*/
* Construct permissions for share() and setPermissions with Or (|) e.g.
* Give user read and update permissions: PERMISSION_READ | PERMISSION_UPDATE
*
* Check if permission is granted with And (&) e.g. Check if delete is
* granted: if ($permissions & PERMISSION_DELETE)
*
* Remove permissions with And (&) and Not (~) e.g. Remove the update
* permission: $permissions &= ~PERMISSION_UPDATE
*
* Apps are required to handle permissions on their own, this class only
* stores and manages the permissions of shares
* @see lib/public/constants.php
*/

const FORMAT_NONE = -1;
const FORMAT_STATUSES = -2;
@@ -64,13 +64,13 @@ class Share {
private static $isResharingAllowed;

/**
* Register a sharing backend class that implements OCP\Share_Backend for an item type
* @param string Item type
* @param string Backend class
* @param string (optional) Depends on item type
* @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
*/
* Register a sharing backend class that implements OCP\Share_Backend for an item type
* @param string Item type
* @param string Backend class
* @param string (optional) Depends on item type
* @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
*/
public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) {
if (self::isEnabled()) {
if (!isset(self::$backendTypes[$itemType])) {
@@ -94,11 +94,11 @@ class Share {
}

/**
* Check if the Share API is enabled
* @return Returns true if enabled or false
*
* The Share API is enabled by default if not configured
*/
* Check if the Share API is enabled
* @return Returns true if enabled or false
*
* The Share API is enabled by default if not configured
*/
public static function isEnabled() {
if (\OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes') == 'yes') {
return true;
@@ -107,9 +107,10 @@ class Share {
}

/**
* Prepare a path to be passed to DB as file_target
* @return string Prepared path
*/
* Prepare a path to be passed to DB as file_target
* @param string $path path
* @return string Prepared path
*/
public static function prepFileTarget( $path ) {

// 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
* @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'
* not '/admin/data/file.txt'
*/
* 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'
* not '/admin/data/file.txt'
*/
public static function getUsersSharingFile($path, $user, $includeOwner = false) {

$shares = array();
@@ -231,12 +232,12 @@ class Share {
}

/**
* Get the items of item type shared with the current user
* @param string Item type
* @param int Format (optional) Format type must be defined by the backend
* @param int Number of items to return (optional) Returns all by default
* @return Return depends on format
*/
* Get the items of item type shared with the current user
* @param string Item type
* @param int Format (optional) Format type must be defined by the backend
* @param int Number of items to return (optional) Returns all by default
* @return Return depends on format
*/
public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE,
$parameters = null, $limit = -1, $includeCollections = false) {
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
* @param string $itemType
* @param string $ItemTarget
* @param int $format (optional) Format type must be defined by the backend
* @return Return depends on format
*/
* Get the item of item type shared with the current user
* @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,
$parameters = null, $includeCollections = false) {
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
* @param string Item type
* @param string Item source
* @param int Format (optional) Format type must be defined by the backend
* @return Return depends on format
*/
* Get the item of item type shared with the current user by source
* @param string Item type
* @param string Item source
* @param int Format (optional) Format type must be defined by the backend
* @param mixed Parameters
* @param bool include collections
* @return Return depends on format
*/
public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE,
$parameters = null, $includeCollections = false) {
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
* @param string Item type
* @param string Item source
* @param string Owner of link
* @return Item
*/
* Get the item of item type shared by a link
* @param string Item type
* @param string Item source
* @param string Owner of link
* @return Item
*/
public static function getItemSharedWithByLink($itemType, $itemSource, $uidOwner) {
return self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE,
null, 1);
@@ -379,12 +382,14 @@ class Share {


/**
* Get the shared items of item type owned by the current user
* @param string Item type
* @param int Format (optional) Format type must be defined by the backend
* @param int Number of items to return (optional) Returns all by default
* @return Return depends on format
*/
* Get the shared items of item type owned by the current user
* @param string Item type
* @param int Format (optional) Format type must be defined by the backend
* @param mixed Parameters
* @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,
$limit = -1, $includeCollections = false) {
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
* @param string Item type
* @param string Item source
* @param int Format (optional) Format type must be defined by the backend
* @return Return depends on format
*/
* Get the shared item of item type owned by the current user
* @param string Item type
* @param string Item source
* @param int Format (optional) Format type must be defined by the backend
* @param mixed Parameters
* @param bool include collections
* @return Return depends on format
*/
public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE,
$parameters = null, $includeCollections = false) {
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
* @param string Item type
* @param string Item source
* @param string Owner
* @param bool Include collections
* @return Return array of users
*/
* Get all users an item is shared with
* @param string Item type
* @param string Item source
* @param string Owner
* @param bool Include collections
* @return Return array of users
*/
public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false) {
$users = array();
$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
* @param string Item type
* @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with
* @return Returns true on success or false on failure
*/
* Unshare an item from a user, group, or delete a private link
* @param string Item type
* @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with
* @return Returns true on success or false on failure
*/
public static function unshare($itemType, $itemSource, $shareType, $shareWith) {
if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(),
self::FORMAT_NONE, null, 1)) {
@@ -650,11 +657,11 @@ class Share {
}

/**
* Unshare an item from all users, groups, and remove all links
* @param string Item type
* @param string Item source
* @return Returns true on success or false on failure
*/
* Unshare an item from all users, groups, and remove all links
* @param string Item type
* @param string Item source
* @return Returns true on success or false on failure
*/
public static function unshareAll($itemType, $itemSource) {
if ($shares = self::getItemShared($itemType, $itemSource)) {
// 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
* @param string Item type
* @param string Item target
* @return Returns true on success or false on failure
*
* Unsharing from self is not allowed for items inside collections
*
*/
* Unshare an item shared with the current user
* @param string Item type
* @param string Item target
* @return Returns true on success or false on failure
*
* Unsharing from self is not allowed for items inside collections
*/
public static function unshareFromSelf($itemType, $itemTarget) {
if ($item = self::getItemSharedWith($itemType, $itemTarget)) {
if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) {
@@ -733,19 +739,17 @@ class Share {
if($result === false) {
\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
* @param string Item type
* @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with
* @param int CRUDS permissions
* @return Returns true on success or false on failure
*/
* Set the permissions of an item for a specific user or group
* @param string Item type
* @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with
* @param int CRUDS permissions
* @return Returns true on success or false on failure
*/
public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) {
if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith,
\OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) {
@@ -821,6 +825,13 @@ class Share {
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) {
if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(),
self::FORMAT_NONE, null, -1, false)) {
@@ -842,10 +853,10 @@ class Share {
}

/**
* Get the backend class for the specified item type
* @param string $itemType
* @return Share_Backend
*/
* Get the backend class for the specified item type
* @param string $itemType
* @return Share_Backend
*/
public static function getBackend($itemType) {
if (isset(self::$backends[$itemType])) {
return self::$backends[$itemType];
@@ -871,12 +882,11 @@ class Share {
}

/**
* Check if resharing is allowed
* @return Returns true if allowed or false
*
* Resharing is allowed by default if not configured
*
*/
* Check if resharing is allowed
* @return Returns true if allowed or false
*
* Resharing is allowed by default if not configured
*/
private static function isResharingAllowed() {
if (!isset(self::$isResharingAllowed)) {
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
* @param string Item type
* @return array
*/
* Get a list of collection item types for the specified item type
* @param string Item type
* @return array
*/
private static function getCollectionItemTypes($itemType) {
$collectionTypes = array($itemType);
foreach (self::$backendTypes as $type => $backend) {
@@ -913,21 +923,21 @@ class Share {
}

/**
* Get shared items from the database
* @param string Item type
* @param string Item source or target (optional)
* @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 that is the owner of shared items (optional)
* @param int Format to convert items to with formatItems()
* @param mixed Parameters to pass to formatItems()
* @param int Number of items to return, -1 to return all matches (optional)
* @param bool Include collection item types (optional)
* @return mixed
*
* See public functions getItem(s)... for parameter usage
*
*/
* Get shared items from the database
* @param string Item type
* @param string Item source or target (optional)
* @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 that is the owner of shared items (optional)
* @param int Format to convert items to with formatItems()
* @param mixed Parameters to pass to formatItems()
* @param int Number of items to return, -1 to return all matches (optional)
* @param bool Include collection item types (optional)
* @return mixed
*
* See public functions getItem(s)... for parameter usage
*
*/
private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null,
$uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1,
$includeCollections = false, $itemShareWithBySource = false) {
@@ -1322,15 +1332,15 @@ class Share {
}

/**
* Put shared item into the database
* @param string Item type
* @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with
* @param int CRUDS permissions
* @param bool|array Parent folder target (optional)
* @return bool Returns true on success or false on failure
*/
* Put shared item into the database
* @param string Item type
* @param string Item source
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string User or group the item is being shared with
* @param int CRUDS permissions
* @param bool|array Parent folder target (optional)
* @return bool Returns true on success or false on failure
*/
private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$permissions, $parentFolder = null, $token = null, $itemSourceName = null) {
$backend = self::getBackend($itemType);
@@ -1561,15 +1571,15 @@ class Share {
}

/**
* Generate a unique target for the item
* @param string Item type
* @param string Item source
* @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 The suggested target originating from a reshare (optional)
* @param int The id of the parent group share (optional)
* @return string Item target
*/
* Generate a unique target for the item
* @param string Item type
* @param string Item source
* @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 The suggested target originating from a reshare (optional)
* @param int The id of the parent group share (optional)
* @return string Item target
*/
private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$suggestedTarget = null, $groupParent = null) {
$backend = self::getBackend($itemType);
@@ -1677,11 +1687,11 @@ class Share {
}

/**
* Delete all reshares of an item
* @param int Id of item to delete
* @param bool If true, exclude the parent from the delete (optional)
* @param string The user that the parent was shared with (optinal)
*/
* Delete all reshares of an item
* @param int Id of item to delete
* @param bool If true, exclude the parent from the delete (optional)
* @param string The user that the parent was shared with (optinal)
*/
private static function delete($parent, $excludeParent = false, $uidOwner = null) {
$ids = array($parent);
$parents = array($parent);
@@ -1749,9 +1759,12 @@ class Share {
}

/**
* Hook Listeners
*/
* Hook Listeners
*/

/**
* @param array arguments
*/
public static function post_deleteUser($arguments) {
// Delete any items shared with the deleted user
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*share`'
@@ -1765,6 +1778,9 @@ class Share {
}
}

/**
* @param array arguments
*/
public static function post_addToGroup($arguments) {
// 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` = ?');
@@ -1795,6 +1811,9 @@ class Share {
}
}

/**
* @param array arguments
*/
public static function post_removeFromGroup($arguments) {
// TODO Don't call if user deleted?
$sql = 'SELECT `id`, `share_type` FROM `*PREFIX*share`'
@@ -1811,6 +1830,9 @@ class Share {
}
}

/**
* @param array arguments
*/
public static function post_deleteGroup($arguments) {
$sql = 'SELECT `id` FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?';
$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 {

/**
* Get the source of the item to be stored in the database
* @param string Item source
* @param string Owner of the item
* @return mixed|array|false Source
*
* 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
*
* The formatItems() function will translate the source returned back into the item
*/
* Get the source of the item to be stored in the database
* @param string Item source
* @param string Owner of the item
* @return mixed|array|false Source
*
* 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
*
* The formatItems() function will translate the source returned back into the item
*/
public function isValidSource($itemSource, $uidOwner);

/**
* Get a unique name of the item for the specified user
* @param string Item source
* @param string|false User the item is being shared with
* @param array|null List of similar item names already existing as shared items
* @return string Target 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_#
*/
* Get a unique name of the item for the specified user
* @param string Item source
* @param string|false User the item is being shared with
* @param array|null List of similar item names already existing as shared items
* @return string Target 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_#
*/
public function generateTarget($itemSource, $shareWith, $exclude = null);

/**
* Converts the shared item sources back into the item in the specified format
* @param array Shared items
* @param int Format
* @return ?
*
* 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
* info.
*
* 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,
* share_type, share_with, permissions, stime, file_source
*
* If called by getItem(s)SharedWith: id, item_type, item, item_source,
* item_target, share_type, share_with, permissions, stime, file_source,
* file_target
*
* 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.
*/
* Converts the shared item sources back into the item in the specified format
* @param array Shared items
* @param int Format
* @return ?
*
* 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
* info.
*
* 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,
* share_type, share_with, permissions, stime, file_source
*
* If called by getItem(s)SharedWith: id, item_type, item, item_source,
* item_target, share_type, share_with, permissions, stime, file_source,
* file_target
*
* 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.
*/
public function formatItems($items, $format, $parameters = null);

}

/**
* Interface for share backends that share content that is dependent on files.
* Extends the Share_Backend interface.
*/
* Interface for share backends that share content that is dependent on files.
* Extends the Share_Backend interface.
*/
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);

}

/**
* Interface for collections of of items implemented by another share backend.
* Extends the Share_Backend interface.
*/
* Interface for collections of of items implemented by another share backend.
* Extends the Share_Backend interface.
*/
interface Share_Backend_Collection extends Share_Backend {

/**
* Get the sources of the children of the item
* @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
*/
* Get the sources of the children of the item
* @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
*/
public function getChildren($itemSource);

}

+ 88
- 114
lib/public/util.php View File

@@ -42,7 +42,7 @@ class Util {
const FATAL=4;

/**
* @brief get the current installed version of ownCloud
* get the current installed version of ownCloud
* @return array
*/
public static function getVersion() {
@@ -50,7 +50,7 @@ class Util {
}

/**
* @brief send an email
* send an email
* @param string $toaddress
* @param string $toname
* @param string $subject
@@ -58,6 +58,10 @@ class Util {
* @param string $fromaddress
* @param string $fromname
* @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,
$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 $message
* @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
* @param string $app app name
* @param Exception $ex exception to log
*/
public static function logException( $app, \Exception $ex ) {
@@ -111,8 +116,8 @@ class Util {
}

/**
* @brief get l10n object
* @param string $app
* get l10n object
* @param string $application
* @return OC_L10N
*/
public static function getL10N( $application ) {
@@ -120,24 +125,25 @@ class Util {
}

/**
* @brief add a css file
* @param string $url
* add a css file
* @param string $application
* @param string $file
*/
public static function addStyle( $application, $file = null ) {
\OC_Util::addStyle( $application, $file );
}

/**
* @brief add a javascript file
* add a javascript file
* @param string $application
* @param string $file
* @param string $file
*/
public static function addScript( $application, $file = null ) {
\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 array $attributes array of attributes 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 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
*/
public static function 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 $file file
* @param array $args array with param=>value, will be appended to the returned url
* The value of $args will be urlencoded
* @returns string the url
*
* Returns a absolute url to the given app and file.
* @return string the url
*/
public static function linkToAbsolute( $app, $file, $args = array() ) {
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
* @returns string the url
*
* Returns a absolute url to the given app and file.
* @return string the url
*/
public static function 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
* @returns string the url
*
* Returns a absolute url to the given app and file.
* @return string the url
*/
public static function 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 array $parameters
* @return
* @internal param array $args with param=>value, will be appended to the returned url
* @returns the url
*
* Returns a url to the given app and file.
* @return the url
*/
public static function linkToRoute( $route, $parameters = array() ) {
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 $file file
* @param array $args array with param=>value, will be appended to the returned url
* The value of $args will be urlencoded
* @returns string the url
*
* Returns a url to the given app and file.
* @return string the url
*/
public static function linkTo( $app, $file, $args = array() ) {
return(\OC_Helper::linkTo( $app, $file, $args ));
}

/**
* @brief Returns the server host
* @returns string the server host
*
* Returns the server host, even if the website uses one or more
* reverse proxies
* Returns the server host, even if the website uses one or more reverse proxy
* @return string the server host
*/
public static function getServerHost() {
return(\OC_Request::serverHost());
}

/**
* @brief returns the server hostname
* @returns string the server hostname
*
* Returns the server host name without an eventual port number
* @return string the server hostname
*/
public static function getServerHostName() {
$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
* @returns string the default email address
* @return string the default email address
*
* Assembles a default email address (using the server hostname
* 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
* @return string the server protocol
*/
public static function getServerProtocol() {
return(\OC_Request::serverProtocol());
}

/**
* @brief Returns the request uri
* @returns the request uri
* Returns the request uri, even if the website uses one or more reverse proxies
*
* Returns the request uri, even if the website uses one or more
* reverse proxies
* @return the request uri
*/
public static function getRequestUri() {
return(\OC_Request::requestUri());
}

/**
* @brief Returns the script name
* @returns the script name
* Returns the script name, even if the website uses one or more reverse proxies
*
* Returns the script name, even if the website uses one or more
* reverse proxies
* @return the script name
*/
public static function getScriptName() {
return(\OC_Request::scriptName());
}

/**
* @brief Creates path to an image
* Creates path to an image
* @param string $app app
* @param string $image image name
* @returns string the url
*
* Returns the path to the image.
* @return string the url
*/
public static function 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
* @returns string a human readable file size
*
* Makes 2048 to 2 kB.
* @return string a human readable file size
*/
public static function 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
* @returns int a file size in bytes
*
* Makes 2kB to 2048.
* @return int a file size in bytes
*
* 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 $signalname name of signal
* @param string $slotclass class name of slot
* @param string $slotname name of slot
* @returns bool
* @return bool
*
* 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 $signalname name of signal
* @param string $params defautl: array() array with additional data
* @returns bool true if slots exists or false if not
*
* Emits a signal. To get data from the slot use references!
* @return bool true if slots exists or false if not
*
* 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
* string or array of strings before displaying it on a web page.
@@ -405,78 +382,75 @@ class Util {
public static function 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.
* 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
* @return string
* @return string
*/
public static function 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.
*
* @param array $input The array to work on
* @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
* @return array
*
*
*/
* 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 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
* @return array
*/
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));
}

/**
* @brief 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 $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 $length Length of the part to be replaced
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return string
*
*/
* replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement.
*
* @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 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 string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return string
*/
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));
}

/**
* @brief 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 $replace The replacement string.
* @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 int $count If passed, this will be set to the number of replacements performed.
* @return 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 $replace The replacement string.
* @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 int $count If passed, this will be set to the number of replacements performed.
* @return string
*/
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));
}

/**
* @brief performs a search in a nested array
* @param array $haystack the array to be searched
* @param string $needle the search string
* @param int $index optional, only search this key name
* @return mixed the key of the matching field, otherwise false
*/
* performs a search in a nested array
*
* @param array $haystack the array to be searched
* @param string $needle the search string
* @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) {
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
* @return number of bytes representing

Loading…
Cancel
Save