summaryrefslogtreecommitdiffstats
path: root/lib/private/Share/Share.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share/Share.php')
-rw-r--r--lib/private/Share/Share.php84
1 files changed, 42 insertions, 42 deletions
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index ed876022bdd..d54dcb2e0e2 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -76,11 +76,11 @@ class Share extends Constants {
public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) {
if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_enabled', 'yes') == 'yes') {
if (!isset(self::$backendTypes[$itemType])) {
- self::$backendTypes[$itemType] = array(
+ self::$backendTypes[$itemType] = [
'class' => $class,
'collectionOf' => $collectionOf,
'supportedFileExtensions' => $supportedFileExtensions
- );
+ ];
return true;
}
\OCP\Util::writeLog('OCP\Share',
@@ -134,7 +134,7 @@ class Share extends Constants {
* @return array Return list of items with file_target, permissions and expiration
*/
public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null, $shareType = null) {
- $shares = array();
+ $shares = [];
$fileDependent = false;
$where = 'WHERE';
@@ -151,7 +151,7 @@ class Share extends Constants {
$select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent);
$where .= ' `' . $column . '` = ? AND `item_type` = ? ';
- $arguments = array($itemSource, $itemType);
+ $arguments = [$itemSource, $itemType];
// for link shares $user === null
if ($user !== null) {
$where .= ' AND `share_with` = ? ';
@@ -205,8 +205,8 @@ class Share extends Constants {
if (!empty($groups)) {
$where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)';
- $arguments = array($itemSource, $itemType, $groups);
- $types = array(null, null, IQueryBuilder::PARAM_STR_ARRAY);
+ $arguments = [$itemSource, $itemType, $groups];
+ $types = [null, null, IQueryBuilder::PARAM_STR_ARRAY];
if ($owner !== null) {
$where .= ' AND `uid_owner` = ?';
@@ -347,7 +347,7 @@ class Share extends Constants {
$items = self::getItemSharedWithUser($itemType, $itemSource, $shareWith, $owner, $shareType);
- $toDelete = array();
+ $toDelete = [];
$newParent = null;
$currentUser = $owner ? $owner : \OC_User::getUser();
foreach ($items as $item) {
@@ -423,7 +423,7 @@ class Share extends Constants {
}
// Pass all the vars we have for now, they may be useful
- $hookParams = array(
+ $hookParams = [
'id' => $item['id'],
'itemType' => $item['item_type'],
'itemSource' => $item['item_source'],
@@ -431,7 +431,7 @@ class Share extends Constants {
'shareWith' => $shareWith,
'itemParent' => $item['parent'],
'uidOwner' => $item['uid_owner'],
- );
+ ];
if($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
$hookParams['fileSource'] = $item['file_source'];
$hookParams['fileTarget'] = $item['file_target'];
@@ -464,20 +464,20 @@ class Share extends Constants {
self::$backends[$itemType] = new $class;
if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) {
$message = 'Sharing backend %s must implement the interface OCP\Share_Backend';
- $message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', array($class));
+ $message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', [$class]);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR);
throw new \Exception($message_t);
}
return self::$backends[$itemType];
} else {
$message = 'Sharing backend %s not found';
- $message_t = $l->t('Sharing backend %s not found', array($class));
+ $message_t = $l->t('Sharing backend %s not found', [$class]);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), ILogger::ERROR);
throw new \Exception($message_t);
}
}
$message = 'Sharing backend for %s not found';
- $message_t = $l->t('Sharing backend for %s not found', array($itemType));
+ $message_t = $l->t('Sharing backend for %s not found', [$itemType]);
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemType), ILogger::ERROR);
throw new \Exception($message_t);
}
@@ -505,7 +505,7 @@ class Share extends Constants {
* @return array
*/
private static function getCollectionItemTypes($itemType) {
- $collectionTypes = array($itemType);
+ $collectionTypes = [$itemType];
foreach (self::$backendTypes as $type => $backend) {
if (in_array($backend['collectionOf'], $collectionTypes)) {
$collectionTypes[] = $type;
@@ -538,7 +538,7 @@ class Share extends Constants {
public static function getSharedItemsOwners($user, $type, $includeCollections = false, $includeOwner = false) {
// First, we find out if $type is part of a collection (and if that collection is part of
// another one and so on).
- $collectionTypes = array();
+ $collectionTypes = [];
if (!$includeCollections || !$collectionTypes = self::getCollectionItemTypes($type)) {
$collectionTypes[] = $type;
}
@@ -547,7 +547,7 @@ class Share extends Constants {
// list of the ones for which a sharing backend has been registered.
// FIXME: Ideally, we wouldn't need to nest getItemsSharedWith in this loop but just call it
// with its $includeCollections parameter set to true. Unfortunately, this fails currently.
- $allMaybeSharedItems = array();
+ $allMaybeSharedItems = [];
foreach ($collectionTypes as $collectionType) {
if (isset(self::$backends[$collectionType])) {
$allMaybeSharedItems[$collectionType] = self::getItemsSharedWithUser(
@@ -558,7 +558,7 @@ class Share extends Constants {
}
}
- $owners = array();
+ $owners = [];
if ($includeOwner) {
$owners[] = $user;
}
@@ -599,7 +599,7 @@ class Share extends Constants {
$uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1,
$includeCollections = false, $itemShareWithBySource = false, $checkExpireDate = true) {
if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_enabled', 'yes') != 'yes') {
- return array();
+ return [];
}
$backend = self::getBackend($itemType);
$collectionTypes = false;
@@ -617,7 +617,7 @@ class Share extends Constants {
}
$where .= 'INNER JOIN `*PREFIX*storages` ON `numeric_id` = `*PREFIX*filecache`.`storage` ';
$fileDependent = true;
- $queryArgs = array();
+ $queryArgs = [];
} else {
$fileDependent = false;
$root = '';
@@ -625,7 +625,7 @@ class Share extends Constants {
if ($includeCollections && !isset($item) && $collectionTypes) {
// If includeCollections is true, find collections of this item type, e.g. a music album contains songs
if (!in_array($itemType, $collectionTypes)) {
- $itemTypes = array_merge(array($itemType), $collectionTypes);
+ $itemTypes = array_merge([$itemType], $collectionTypes);
} else {
$itemTypes = $collectionTypes;
}
@@ -634,7 +634,7 @@ class Share extends Constants {
$queryArgs = $itemTypes;
} else {
$where = ' WHERE `item_type` = ?';
- $queryArgs = array($itemType);
+ $queryArgs = [$itemType];
}
}
if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
@@ -754,10 +754,10 @@ class Share extends Constants {
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=',
ILogger::ERROR);
}
- $items = array();
- $targets = array();
- $switchedItems = array();
- $mounts = array();
+ $items = [];
+ $targets = [];
+ $switchedItems = [];
+ $mounts = [];
while ($row = $result->fetchRow()) {
self::transformDBResults($row);
// Filter out duplicate group shares for users with unique targets
@@ -812,7 +812,7 @@ class Share extends Constants {
if (isset($uidOwner) && isset($row['path'])) {
if (isset($row['parent'])) {
$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
- $parentResult = $query->execute(array($row['parent']));
+ $parentResult = $query->execute([$row['parent']]);
if ($result === false) {
\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where,
@@ -887,7 +887,7 @@ class Share extends Constants {
}
if (!empty($items)) {
- $collectionItems = array();
+ $collectionItems = [];
foreach ($items as &$row) {
// Return only the item instead of a 2-dimensional array
if ($limit == 1 && $row[$column] == $item && ($row['item_type'] == $itemType || $itemType == 'file')) {
@@ -905,7 +905,7 @@ class Share extends Constants {
if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) {
$collectionItems[] = $row;
} else {
- $collection = array();
+ $collection = [];
$collection['item_type'] = $row['item_type'];
if ($row['item_type'] == 'file' || $row['item_type'] == 'folder') {
$collection['path'] = basename($row['path']);
@@ -938,7 +938,7 @@ class Share extends Constants {
return $childItem;
} else {
// Unset the items array and break out of both loops
- $items = array();
+ $items = [];
$items[] = $childItem;
break 2;
}
@@ -985,7 +985,7 @@ class Share extends Constants {
// FIXME: Thats a dirty hack to improve file sharing performance,
// see github issue #10588 for more details
// Need to find a solution which works for all back-ends
- $collectionItems = array();
+ $collectionItems = [];
$collectionBackend = self::getBackend('folder');
$sharedParents = $collectionBackend->getParents($item, $shareWith, $uidOwner);
foreach ($sharedParents as $parent) {
@@ -997,7 +997,7 @@ class Share extends Constants {
return self::formatResult($collectionItems, $column, $backend, $format, $parameters);
}
- return array();
+ return [];
}
/**
@@ -1011,7 +1011,7 @@ class Share extends Constants {
$fileSharing = $itemType === 'file' || $itemType === 'folder';
- $result = array();
+ $result = [];
foreach ($items as $item) {
$grouped = false;
@@ -1058,7 +1058,7 @@ class Share extends Constants {
private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$permissions) {
- $queriesToExecute = array();
+ $queriesToExecute = [];
$suggestedItemTarget = null;
$groupFileTarget = $fileTarget = $suggestedFileTarget = $filePath = '';
$groupItemTarget = $itemTarget = $fileSource = $parent = 0;
@@ -1074,13 +1074,13 @@ class Share extends Constants {
}
$isGroupShare = false;
- $users = array($shareWith);
+ $users = [$shareWith];
$itemTarget = Helper::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$suggestedItemTarget);
$run = true;
$error = '';
- $preHookData = array(
+ $preHookData = [
'itemType' => $itemType,
'itemSource' => $itemSource,
'shareType' => $shareType,
@@ -1091,7 +1091,7 @@ class Share extends Constants {
'token' => null,
'run' => &$run,
'error' => &$error
- );
+ ];
$preHookData['itemTarget'] = $itemTarget;
$preHookData['shareWith'] = $shareWith;
@@ -1144,7 +1144,7 @@ class Share extends Constants {
}
}
- $queriesToExecute[] = array(
+ $queriesToExecute[] = [
'itemType' => $itemType,
'itemSource' => $itemSource,
'itemTarget' => $itemTarget,
@@ -1158,7 +1158,7 @@ class Share extends Constants {
'token' => null,
'parent' => $parent,
'expiration' => null,
- );
+ ];
}
@@ -1169,7 +1169,7 @@ class Share extends Constants {
$id = self::insertShare($shareQuery);
}
- $postHookData = array(
+ $postHookData = [
'itemType' => $itemType,
'itemSource' => $itemSource,
'parent' => $parent,
@@ -1180,7 +1180,7 @@ class Share extends Constants {
'id' => $parent,
'token' => null,
'expirationDate' => null,
- );
+ ];
$postHookData['shareWith'] = $isGroupShare ? $shareWith['group'] : $shareWith;
$postHookData['itemTarget'] = $isGroupShare ? $groupItemTarget : $itemTarget;
@@ -1208,7 +1208,7 @@ class Share extends Constants {
private static function checkReshare($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $itemSourceName, $expirationDate) {
$backend = self::getBackend($itemType);
- $result = array();
+ $result = [];
$column = ($itemType === 'file' || $itemType === 'folder') ? 'file_source' : 'item_source';
@@ -1419,7 +1419,7 @@ class Share extends Constants {
if ($format === self::FORMAT_NONE) {
return $items;
} else if ($format === self::FORMAT_STATUSES) {
- $statuses = array();
+ $statuses = [];
foreach ($items as $item) {
if ($item['share_type'] === self::SHARE_TYPE_LINK) {
if ($item['uid_initiator'] !== \OC::$server->getUserSession()->getUser()->getUID()) {
@@ -1507,7 +1507,7 @@ class Share extends Constants {
*/
private static function sendRemoteUnshare($remote, $id, $token) {
$url = rtrim($remote, '/');
- $fields = array('token' => $token, 'format' => 'json');
+ $fields = ['token' => $token, 'format' => 'json'];
$url = self::removeProtocolFromUrl($url);
$result = self::tryHttpPostToShareEndpoint($url, '/'.$id.'/unshare', $fields);
$status = json_decode($result['result'], true);