summaryrefslogtreecommitdiffstats
path: root/lib/private/Share
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 09:30:18 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 16:34:56 +0100
commitb80ebc96748b45fd2e0ba9323308657c4b00b7ec (patch)
treeec20e0ffa2f86b9b54939a83a785407319f94559 /lib/private/Share
parent62403d0932be7d620c7bdadc6b4e13eb496fcd6f (diff)
downloadnextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.tar.gz
nextcloud-server-b80ebc96748b45fd2e0ba9323308657c4b00b7ec.zip
Use the short array syntax, everywhere
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Share')
-rw-r--r--lib/private/Share/Constants.php4
-rw-r--r--lib/private/Share/Helper.php24
-rw-r--r--lib/private/Share/SearchResultSorter.php2
-rw-r--r--lib/private/Share/Share.php84
4 files changed, 57 insertions, 57 deletions
diff --git a/lib/private/Share/Constants.php b/lib/private/Share/Constants.php
index 4ad9c71b511..4ec0a306a9a 100644
--- a/lib/private/Share/Constants.php
+++ b/lib/private/Share/Constants.php
@@ -83,7 +83,7 @@ class Constants {
protected static $shareTypeUserAndGroups = -1;
protected static $shareTypeGroupUserUnique = 2;
- protected static $backends = array();
- protected static $backendTypes = array();
+ protected static $backends = [];
+ protected static $backendTypes = [];
protected static $isResharingAllowed;
}
diff --git a/lib/private/Share/Helper.php b/lib/private/Share/Helper.php
index 2dd91613cbd..ef37b3b3427 100644
--- a/lib/private/Share/Helper.php
+++ b/lib/private/Share/Helper.php
@@ -82,15 +82,15 @@ class Helper extends \OC\Share\Constants {
* @param bool $excludeGroupChildren exclude group children elements
*/
public static function delete($parent, $excludeParent = false, $uidOwner = null, $newParent = null, $excludeGroupChildren = false) {
- $ids = array($parent);
- $deletedItems = array();
- $changeParent = array();
- $parents = array($parent);
+ $ids = [$parent];
+ $deletedItems = [];
+ $changeParent = [];
+ $parents = [$parent];
while (!empty($parents)) {
$parents = "'".implode("','", $parents)."'";
// Check the owner on the first search of reshares, useful for
// finding and deleting the reshares by a single user of a group share
- $params = array();
+ $params = [];
if (count($ids) == 1 && isset($uidOwner)) {
// FIXME: don't concat $parents, use Docrine's PARAM_INT_ARRAY approach
$queryString = 'SELECT `id`, `share_with`, `item_type`, `share_type`, ' .
@@ -110,15 +110,15 @@ class Helper extends \OC\Share\Constants {
$query = \OC_DB::prepare($queryString);
$result = $query->execute($params);
// Reset parents array, only go through loop again if items are found
- $parents = array();
+ $parents = [];
while ($item = $result->fetchRow()) {
- $tmpItem = array(
+ $tmpItem = [
'id' => $item['id'],
'shareWith' => $item['share_with'],
'itemTarget' => $item['item_target'],
'itemType' => $item['item_type'],
'shareType' => (int)$item['share_type'],
- );
+ ];
if (isset($item['file_target'])) {
$tmpItem['fileTarget'] = $item['file_target'];
}
@@ -141,7 +141,7 @@ class Helper extends \OC\Share\Constants {
if (!empty($changeParent)) {
$idList = "'".implode("','", $changeParent)."'";
$query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `parent` = ? WHERE `id` IN ('.$idList.')');
- $query->execute(array($newParent));
+ $query->execute([$newParent]);
}
if (!empty($ids)) {
@@ -161,7 +161,7 @@ class Helper extends \OC\Share\Constants {
$config = \OC::$server->getConfig();
- $defaultExpireSettings = array('defaultExpireDateSet' => false);
+ $defaultExpireSettings = ['defaultExpireDateSet' => false];
// get default expire settings
$defaultExpireDate = $config->getAppValue('core', 'shareapi_default_expire_date', 'no');
@@ -277,12 +277,12 @@ class Helper extends \OC\Share\Constants {
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
- array('uid' => &$user1)
+ ['uid' => &$user1]
);
\OCP\Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
'preLoginNameUsedAsUserName',
- array('uid' => &$user2)
+ ['uid' => &$user2]
);
if ($user1 === $user2) {
diff --git a/lib/private/Share/SearchResultSorter.php b/lib/private/Share/SearchResultSorter.php
index 452b7a4849c..e16150b8e6f 100644
--- a/lib/private/Share/SearchResultSorter.php
+++ b/lib/private/Share/SearchResultSorter.php
@@ -56,7 +56,7 @@ class SearchResultSorter {
if(!isset($a[$this->key]) || !isset($b[$this->key])) {
if(!is_null($this->log)) {
$this->log->error('Sharing dialogue: cannot sort due to ' .
- 'missing array key', array('app' => 'core'));
+ 'missing array key', ['app' => 'core']);
}
return 0;
}
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);