aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php4
-rw-r--r--lib/composer/composer/ClassLoader.php10
-rw-r--r--lib/composer/composer/LICENSE2
-rw-r--r--lib/composer/composer/autoload_classmap.php10
-rw-r--r--lib/composer/composer/autoload_static.php10
-rw-r--r--lib/l10n/ca.js1
-rw-r--r--lib/l10n/ca.json1
-rw-r--r--lib/private/AppFramework/Http/Request.php3
-rw-r--r--lib/private/Encryption/Util.php12
-rw-r--r--lib/private/Files/Cache/Cache.php43
-rw-r--r--lib/private/Files/Cache/FailedCache.php5
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php160
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheJail.php6
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheWrapper.php6
-rw-r--r--lib/private/Files/Node/Folder.php9
-rw-r--r--lib/private/Files/Search/SearchBinaryOperator.php57
-rw-r--r--lib/private/Files/Search/SearchComparison.php67
-rw-r--r--lib/private/Files/Search/SearchOrder.php57
-rw-r--r--lib/private/Files/Search/SearchQuery.php80
-rw-r--r--lib/private/Lockdown/Filesystem/NullCache.php5
-rw-r--r--lib/private/OCS/Provider.php17
-rw-r--r--lib/private/Preview/MP3.php20
-rw-r--r--lib/private/Share/Share.php98
-rw-r--r--lib/private/Template/SCSSCacher.php21
-rw-r--r--lib/private/User/User.php10
-rw-r--r--lib/private/legacy/group.php302
-rw-r--r--lib/private/legacy/image.php6
-rw-r--r--lib/private/legacy/template.php12
-rw-r--r--lib/private/legacy/user.php4
-rw-r--r--lib/public/Files/Cache/ICache.php12
-rw-r--r--lib/public/Files/Folder.php3
-rw-r--r--lib/public/Files/Search/ISearchBinaryOperator.php51
-rw-r--r--lib/public/Files/Search/ISearchComparison.php60
-rw-r--r--lib/public/Files/Search/ISearchOperator.php29
-rw-r--r--lib/public/Files/Search/ISearchOrder.php46
-rw-r--r--lib/public/Files/Search/ISearchQuery.php57
36 files changed, 926 insertions, 370 deletions
diff --git a/lib/base.php b/lib/base.php
index a4bb4f584f8..68178b06c5b 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -528,7 +528,7 @@ class OC {
//
// Questions about this code? Ask Lukas ;-)
$currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT));
- if($currentUrl === '/index.php/apps/user_saml/saml/acs') {
+ if($currentUrl === '/index.php/apps/user_saml/saml/acs' || $currentUrl === '/apps/user_saml/saml/acs') {
return;
}
// For the "index.php" endpoint only a lax cookie is required.
@@ -698,7 +698,7 @@ class OC {
}
OC_User::useBackend(new \OC\User\Database());
- OC_Group::useBackend(new \OC\Group\Database());
+ \OC::$server->getGroupManager()->addBackend(new \OC\Group\Database());
// Subscribe to the hook
\OCP\Util::connectHook(
diff --git a/lib/composer/composer/ClassLoader.php b/lib/composer/composer/ClassLoader.php
index 4626994fd4d..2c72175e772 100644
--- a/lib/composer/composer/ClassLoader.php
+++ b/lib/composer/composer/ClassLoader.php
@@ -374,9 +374,13 @@ class ClassLoader
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
- foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
- if (0 === strpos($class, $prefix)) {
- foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
+ $subPath = $class;
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
+ $subPath = substr($subPath, 0, $lastPos);
+ $search = $subPath.'\\';
+ if (isset($this->prefixDirsPsr4[$search])) {
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
+ $length = $this->prefixLengthsPsr4[$first][$search];
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
return $file;
}
diff --git a/lib/composer/composer/LICENSE b/lib/composer/composer/LICENSE
index 1a28124886d..f27399a042d 100644
--- a/lib/composer/composer/LICENSE
+++ b/lib/composer/composer/LICENSE
@@ -1,5 +1,5 @@
-Copyright (c) 2016 Nils Adermann, Jordi Boggiano
+Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index a4850fb4b38..c87bcce194f 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -141,6 +141,11 @@ return array(
'OCP\\Files\\Notify\\IRenameChange' => $baseDir . '/lib/public/Files/Notify/IRenameChange.php',
'OCP\\Files\\ObjectStore\\IObjectStore' => $baseDir . '/lib/public/Files/ObjectStore/IObjectStore.php',
'OCP\\Files\\ReservedWordException' => $baseDir . '/lib/public/Files/ReservedWordException.php',
+ 'OCP\\Files\\Search\\ISearchBinaryOperator' => $baseDir . '/lib/public/Files/Search/ISearchBinaryOperator.php',
+ 'OCP\\Files\\Search\\ISearchComparison' => $baseDir . '/lib/public/Files/Search/ISearchComparison.php',
+ 'OCP\\Files\\Search\\ISearchOperator' => $baseDir . '/lib/public/Files/Search/ISearchOperator.php',
+ 'OCP\\Files\\Search\\ISearchOrder' => $baseDir . '/lib/public/Files/Search/ISearchOrder.php',
+ 'OCP\\Files\\Search\\ISearchQuery' => $baseDir . '/lib/public/Files/Search/ISearchQuery.php',
'OCP\\Files\\SimpleFS\\ISimpleFile' => $baseDir . '/lib/public/Files/SimpleFS/ISimpleFile.php',
'OCP\\Files\\SimpleFS\\ISimpleFolder' => $baseDir . '/lib/public/Files/SimpleFS/ISimpleFolder.php',
'OCP\\Files\\SimpleFS\\ISimpleRoot' => $baseDir . '/lib/public/Files/SimpleFS/ISimpleRoot.php',
@@ -509,6 +514,7 @@ return array(
'OC\\Files\\Cache\\HomePropagator' => $baseDir . '/lib/private/Files/Cache/HomePropagator.php',
'OC\\Files\\Cache\\MoveFromCacheTrait' => $baseDir . '/lib/private/Files/Cache/MoveFromCacheTrait.php',
'OC\\Files\\Cache\\Propagator' => $baseDir . '/lib/private/Files/Cache/Propagator.php',
+ 'OC\\Files\\Cache\\QuerySearchHelper' => $baseDir . '/lib/private/Files/Cache/QuerySearchHelper.php',
'OC\\Files\\Cache\\Scanner' => $baseDir . '/lib/private/Files/Cache/Scanner.php',
'OC\\Files\\Cache\\Storage' => $baseDir . '/lib/private/Files/Cache/Storage.php',
'OC\\Files\\Cache\\StorageGlobal' => $baseDir . '/lib/private/Files/Cache/StorageGlobal.php',
@@ -548,6 +554,10 @@ return array(
'OC\\Files\\ObjectStore\\S3ConnectionTrait' => $baseDir . '/lib/private/Files/ObjectStore/S3ConnectionTrait.php',
'OC\\Files\\ObjectStore\\StorageObjectStore' => $baseDir . '/lib/private/Files/ObjectStore/StorageObjectStore.php',
'OC\\Files\\ObjectStore\\Swift' => $baseDir . '/lib/private/Files/ObjectStore/Swift.php',
+ 'OC\\Files\\Search\\SearchBinaryOperator' => $baseDir . '/lib/private/Files/Search/SearchBinaryOperator.php',
+ 'OC\\Files\\Search\\SearchComparison' => $baseDir . '/lib/private/Files/Search/SearchComparison.php',
+ 'OC\\Files\\Search\\SearchOrder' => $baseDir . '/lib/private/Files/Search/SearchOrder.php',
+ 'OC\\Files\\Search\\SearchQuery' => $baseDir . '/lib/private/Files/Search/SearchQuery.php',
'OC\\Files\\SimpleFS\\SimpleFile' => $baseDir . '/lib/private/Files/SimpleFS/SimpleFile.php',
'OC\\Files\\SimpleFS\\SimpleFolder' => $baseDir . '/lib/private/Files/SimpleFS/SimpleFolder.php',
'OC\\Files\\Storage\\Common' => $baseDir . '/lib/private/Files/Storage/Common.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 654161214b2..eb7188b69b3 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -171,6 +171,11 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Files\\Notify\\IRenameChange' => __DIR__ . '/../../..' . '/lib/public/Files/Notify/IRenameChange.php',
'OCP\\Files\\ObjectStore\\IObjectStore' => __DIR__ . '/../../..' . '/lib/public/Files/ObjectStore/IObjectStore.php',
'OCP\\Files\\ReservedWordException' => __DIR__ . '/../../..' . '/lib/public/Files/ReservedWordException.php',
+ 'OCP\\Files\\Search\\ISearchBinaryOperator' => __DIR__ . '/../../..' . '/lib/public/Files/Search/ISearchBinaryOperator.php',
+ 'OCP\\Files\\Search\\ISearchComparison' => __DIR__ . '/../../..' . '/lib/public/Files/Search/ISearchComparison.php',
+ 'OCP\\Files\\Search\\ISearchOperator' => __DIR__ . '/../../..' . '/lib/public/Files/Search/ISearchOperator.php',
+ 'OCP\\Files\\Search\\ISearchOrder' => __DIR__ . '/../../..' . '/lib/public/Files/Search/ISearchOrder.php',
+ 'OCP\\Files\\Search\\ISearchQuery' => __DIR__ . '/../../..' . '/lib/public/Files/Search/ISearchQuery.php',
'OCP\\Files\\SimpleFS\\ISimpleFile' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/ISimpleFile.php',
'OCP\\Files\\SimpleFS\\ISimpleFolder' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/ISimpleFolder.php',
'OCP\\Files\\SimpleFS\\ISimpleRoot' => __DIR__ . '/../../..' . '/lib/public/Files/SimpleFS/ISimpleRoot.php',
@@ -539,6 +544,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Files\\Cache\\HomePropagator' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/HomePropagator.php',
'OC\\Files\\Cache\\MoveFromCacheTrait' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/MoveFromCacheTrait.php',
'OC\\Files\\Cache\\Propagator' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/Propagator.php',
+ 'OC\\Files\\Cache\\QuerySearchHelper' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/QuerySearchHelper.php',
'OC\\Files\\Cache\\Scanner' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/Scanner.php',
'OC\\Files\\Cache\\Storage' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/Storage.php',
'OC\\Files\\Cache\\StorageGlobal' => __DIR__ . '/../../..' . '/lib/private/Files/Cache/StorageGlobal.php',
@@ -578,6 +584,10 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Files\\ObjectStore\\S3ConnectionTrait' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/S3ConnectionTrait.php',
'OC\\Files\\ObjectStore\\StorageObjectStore' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/StorageObjectStore.php',
'OC\\Files\\ObjectStore\\Swift' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/Swift.php',
+ 'OC\\Files\\Search\\SearchBinaryOperator' => __DIR__ . '/../../..' . '/lib/private/Files/Search/SearchBinaryOperator.php',
+ 'OC\\Files\\Search\\SearchComparison' => __DIR__ . '/../../..' . '/lib/private/Files/Search/SearchComparison.php',
+ 'OC\\Files\\Search\\SearchOrder' => __DIR__ . '/../../..' . '/lib/private/Files/Search/SearchOrder.php',
+ 'OC\\Files\\Search\\SearchQuery' => __DIR__ . '/../../..' . '/lib/private/Files/Search/SearchQuery.php',
'OC\\Files\\SimpleFS\\SimpleFile' => __DIR__ . '/../../..' . '/lib/private/Files/SimpleFS/SimpleFile.php',
'OC\\Files\\SimpleFS\\SimpleFolder' => __DIR__ . '/../../..' . '/lib/private/Files/SimpleFS/SimpleFolder.php',
'OC\\Files\\Storage\\Common' => __DIR__ . '/../../..' . '/lib/private/Files/Storage/Common.php',
diff --git a/lib/l10n/ca.js b/lib/l10n/ca.js
index daa9ae7a3d6..fbbf8fdd543 100644
--- a/lib/l10n/ca.js
+++ b/lib/l10n/ca.js
@@ -12,6 +12,7 @@ OC.L10N.register(
"%1$s, %2$s, %3$s and %4$s" : "%1$s, %2$s, %3$s i %4$s",
"%1$s, %2$s, %3$s, %4$s and %5$s" : "%1$s, %2$s, %3$s, %4$s i %5$s",
"PHP %s or higher is required." : "Es requereix PHP %s o superior.",
+ "%sbit or higher PHP required." : "Es requereix PHP %s o superior.",
"Server version %s or higher is required." : "Es requereix una versió de servidor %s o superior",
"Server version %s or lower is required." : "Es requereix una versió de servidor %s o inferior",
"Unknown filetype" : "Tipus de fitxer desconegut",
diff --git a/lib/l10n/ca.json b/lib/l10n/ca.json
index f6c692aef0d..13358e42a4f 100644
--- a/lib/l10n/ca.json
+++ b/lib/l10n/ca.json
@@ -10,6 +10,7 @@
"%1$s, %2$s, %3$s and %4$s" : "%1$s, %2$s, %3$s i %4$s",
"%1$s, %2$s, %3$s, %4$s and %5$s" : "%1$s, %2$s, %3$s, %4$s i %5$s",
"PHP %s or higher is required." : "Es requereix PHP %s o superior.",
+ "%sbit or higher PHP required." : "Es requereix PHP %s o superior.",
"Server version %s or higher is required." : "Es requereix una versió de servidor %s o superior",
"Server version %s or lower is required." : "Es requereix una versió de servidor %s o inferior",
"Unknown filetype" : "Tipus de fitxer desconegut",
diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php
index be35f4d172f..fd43d468568 100644
--- a/lib/private/AppFramework/Http/Request.php
+++ b/lib/private/AppFramework/Http/Request.php
@@ -490,6 +490,9 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @return bool
*/
private function cookieCheckRequired() {
+ if ($this->getHeader('OCS-APIREQUEST')) {
+ return false;
+ }
if($this->getCookie(session_name()) === null && $this->getCookie('nc_token') === null) {
return false;
}
diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php
index 3afa1bb9596..76e1200a1cb 100644
--- a/lib/private/Encryption/Util.php
+++ b/lib/private/Encryption/Util.php
@@ -273,8 +273,18 @@ class Util {
$result = \OCP\User::getUsers();
} else {
$result = array_merge($result, $users);
+
+ $groupManager = \OC::$server->getGroupManager();
foreach ($groups as $group) {
- $result = array_merge($result, \OC_Group::usersInGroup($group));
+ $groupObject = $groupManager->get($group);
+ if ($groupObject) {
+ $foundUsers = $groupObject->searchUsers('', -1, 0);
+ $userIds = [];
+ foreach ($foundUsers as $user) {
+ $userIds[] = $user->getUID();
+ }
+ $result = array_merge($result, $userIds);
+ }
}
}
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 7e7ebd795a0..b0527d801d6 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -36,9 +36,11 @@
namespace OC\Files\Cache;
+use Doctrine\DBAL\Driver\Statement;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use \OCP\Files\IMimeTypeLoader;
+use OCP\Files\Search\ISearchQuery;
use OCP\IDBConnection;
/**
@@ -79,6 +81,9 @@ class Cache implements ICache {
*/
protected $connection;
+ /** @var QuerySearchHelper */
+ protected $querySearchHelper;
+
/**
* @param \OC\Files\Storage\Storage|string $storage
*/
@@ -95,6 +100,7 @@ class Cache implements ICache {
$this->storageCache = new Storage($storage);
$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
$this->connection = \OC::$server->getDatabaseConnection();
+ $this->querySearchHelper = new QuerySearchHelper($this->mimetypeLoader);
}
/**
@@ -350,7 +356,7 @@ class Cache implements ICache {
$queryParts[] = '`mtime`';
}
} elseif ($name === 'encrypted') {
- if(isset($data['encryptedVersion'])) {
+ if (isset($data['encryptedVersion'])) {
$value = $data['encryptedVersion'];
} else {
// Boolean to integer conversion
@@ -599,9 +605,17 @@ class Cache implements ICache {
[$this->getNumericStorageId(), $pattern]
);
+ return $this->searchResultToCacheEntries($result);
+ }
+
+ /**
+ * @param Statement $result
+ * @return CacheEntry[]
+ */
+ private function searchResultToCacheEntries(Statement $result) {
$files = $result->fetchAll();
- return array_map(function(array $data) {
+ return array_map(function (array $data) {
return self::cacheEntryFromData($data, $this->mimetypeLoader);
}, $files);
}
@@ -624,14 +638,29 @@ class Cache implements ICache {
$mimetype = $this->mimetypeLoader->getId($mimetype);
$result = $this->connection->executeQuery($sql, array($mimetype, $this->getNumericStorageId()));
- $files = $result->fetchAll();
+ return $this->searchResultToCacheEntries($result);
+ }
- return array_map(function (array $data) {
- return self::cacheEntryFromData($data, $this->mimetypeLoader);
- }, $files);
+ public function searchQuery(ISearchQuery $searchQuery) {
+ $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+
+ $query = $builder->select(['fileid', 'storage', 'path', 'parent', 'name', 'mimetype', 'mimepart', 'size', 'mtime', 'storage_mtime', 'encrypted', 'etag', 'permissions', 'checksum'])
+ ->from('filecache')
+ ->where($builder->expr()->eq('storage', $builder->createNamedParameter($this->getNumericStorageId())))
+ ->andWhere($this->querySearchHelper->searchOperatorToDBExpr($builder, $searchQuery->getSearchOperation()));
+
+ if ($searchQuery->getLimit()) {
+ $query->setMaxResults($searchQuery->getLimit());
+ }
+ if ($searchQuery->getOffset()) {
+ $query->setFirstResult($searchQuery->getOffset());
+ }
+
+ $result = $query->execute();
+ return $this->searchResultToCacheEntries($result);
}
- /**
+ /**
* Search for files by tag of a given users.
*
* Note that every user can tag files differently.
diff --git a/lib/private/Files/Cache/FailedCache.php b/lib/private/Files/Cache/FailedCache.php
index 3a0424b5e26..932a5e5181a 100644
--- a/lib/private/Files/Cache/FailedCache.php
+++ b/lib/private/Files/Cache/FailedCache.php
@@ -24,6 +24,7 @@ namespace OC\Files\Cache;
use OCP\Constants;
use OCP\Files\Cache\ICache;
+use OCP\Files\Search\ISearchQuery;
/**
* Storage placeholder to represent a missing precondition, storage unavailable
@@ -125,6 +126,10 @@ class FailedCache implements ICache {
return [];
}
+ public function searchQuery(ISearchQuery $query) {
+ return [];
+ }
+
public function getAll() {
return [];
}
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
new file mode 100644
index 00000000000..931f258ec5b
--- /dev/null
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -0,0 +1,160 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Files\Cache;
+
+use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\Files\IMimeTypeLoader;
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchComparison;
+use OCP\Files\Search\ISearchOperator;
+
+/**
+ * Tools for transforming search queries into database queries
+ */
+class QuerySearchHelper {
+ static protected $searchOperatorMap = [
+ ISearchComparison::COMPARE_LIKE => 'iLike',
+ ISearchComparison::COMPARE_EQUAL => 'eq',
+ ISearchComparison::COMPARE_GREATER_THAN => 'gt',
+ ISearchComparison::COMPARE_GREATER_THAN_EQUAL => 'gte',
+ ISearchComparison::COMPARE_LESS_THAN => 'lt',
+ ISearchComparison::COMPARE_LESS_THAN_EQUAL => 'lte'
+ ];
+
+ static protected $searchOperatorNegativeMap = [
+ ISearchComparison::COMPARE_LIKE => 'notLike',
+ ISearchComparison::COMPARE_EQUAL => 'neq',
+ ISearchComparison::COMPARE_GREATER_THAN => 'lte',
+ ISearchComparison::COMPARE_GREATER_THAN_EQUAL => 'lt',
+ ISearchComparison::COMPARE_LESS_THAN => 'gte',
+ ISearchComparison::COMPARE_LESS_THAN_EQUAL => 'lt'
+ ];
+
+ /** @var IMimeTypeLoader */
+ private $mimetypeLoader;
+
+ /**
+ * QuerySearchUtil constructor.
+ *
+ * @param IMimeTypeLoader $mimetypeLoader
+ */
+ public function __construct(IMimeTypeLoader $mimetypeLoader) {
+ $this->mimetypeLoader = $mimetypeLoader;
+ }
+
+ public function searchOperatorToDBExpr(IQueryBuilder $builder, ISearchOperator $operator) {
+ $expr = $builder->expr();
+ if ($operator instanceof ISearchBinaryOperator) {
+ switch ($operator->getType()) {
+ case ISearchBinaryOperator::OPERATOR_NOT:
+ $negativeOperator = $operator->getArguments()[0];
+ if ($negativeOperator instanceof ISearchComparison) {
+ return $this->searchComparisonToDBExpr($builder, $negativeOperator, self::$searchOperatorNegativeMap);
+ } else {
+ throw new \InvalidArgumentException('Binary operators inside "not" is not supported');
+ }
+ case ISearchBinaryOperator::OPERATOR_AND:
+ return $expr->andX($this->searchOperatorToDBExpr($builder, $operator->getArguments()[0]), $this->searchOperatorToDBExpr($builder, $operator->getArguments()[1]));
+ case ISearchBinaryOperator::OPERATOR_OR:
+ return $expr->orX($this->searchOperatorToDBExpr($builder, $operator->getArguments()[0]), $this->searchOperatorToDBExpr($builder, $operator->getArguments()[1]));
+ default:
+ throw new \InvalidArgumentException('Invalid operator type: ' . $operator->getType());
+ }
+ } else if ($operator instanceof ISearchComparison) {
+ return $this->searchComparisonToDBExpr($builder, $operator, self::$searchOperatorMap);
+ } else {
+ throw new \InvalidArgumentException('Invalid operator type: ' . get_class($operator));
+ }
+ }
+
+ private function searchComparisonToDBExpr(IQueryBuilder $builder, ISearchComparison $comparison, array $operatorMap) {
+ $this->validateComparison($comparison);
+
+ list($field, $value, $type) = $this->getOperatorFieldAndValue($comparison);
+ if (isset($operatorMap[$type])) {
+ $queryOperator = $operatorMap[$type];
+ return $builder->expr()->$queryOperator($field, $this->getParameterForValue($builder, $value));
+ } else {
+ throw new \InvalidArgumentException('Invalid operator type: ' . $comparison->getType());
+ }
+ }
+
+ private function getOperatorFieldAndValue(ISearchComparison $operator) {
+ $field = $operator->getField();
+ $value = $operator->getValue();
+ $type = $operator->getType();
+ if ($field === 'mimetype') {
+ if ($operator->getType() === ISearchComparison::COMPARE_EQUAL) {
+ $value = $this->mimetypeLoader->getId($value);
+ } else if ($operator->getType() === ISearchComparison::COMPARE_LIKE) {
+ // transform "mimetype='foo/%'" to "mimepart='foo'"
+ if (preg_match('|(.+)/%|', $value, $matches)) {
+ $field = 'mimepart';
+ $value = $this->mimetypeLoader->getId($matches[1]);
+ $type = ISearchComparison::COMPARE_EQUAL;
+ }
+ if (strpos($value, '%') !== false) {
+ throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported');
+ }
+ }
+ }
+ return [$field, $value, $type];
+ }
+
+ private function validateComparison(ISearchComparison $operator) {
+ $types = [
+ 'mimetype' => 'string',
+ 'mtime' => 'integer',
+ 'name' => 'string',
+ 'size' => 'integer'
+ ];
+ $comparisons = [
+ 'mimetype' => ['eq', 'like'],
+ 'mtime' => ['eq', 'gt', 'lt', 'gte', 'lte'],
+ 'name' => ['eq', 'like'],
+ 'size' => ['eq', 'gt', 'lt', 'gte', 'lte']
+ ];
+
+ if (!isset($types[$operator->getField()])) {
+ throw new \InvalidArgumentException('Unsupported comparison field ' . $operator->getField());
+ }
+ $type = $types[$operator->getField()];
+ if (gettype($operator->getValue()) !== $type) {
+ throw new \InvalidArgumentException('Invalid type for field ' . $operator->getField());
+ }
+ if (!in_array($operator->getType(), $comparisons[$operator->getField()])) {
+ throw new \InvalidArgumentException('Unsupported comparison for field ' . $operator->getField() . ': ' . $operator->getType());
+ }
+ }
+
+ private function getParameterForValue(IQueryBuilder $builder, $value) {
+ if ($value instanceof \DateTime) {
+ $value = $value->getTimestamp();
+ }
+ if (is_numeric($value)) {
+ $type = IQueryBuilder::PARAM_INT;
+ } else {
+ $type = IQueryBuilder::PARAM_STR;
+ }
+ return $builder->createNamedParameter($value, $type);
+ }
+}
diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php
index 894fbcc803d..ebab20fbaed 100644
--- a/lib/private/Files/Cache/Wrapper/CacheJail.php
+++ b/lib/private/Files/Cache/Wrapper/CacheJail.php
@@ -28,6 +28,7 @@
namespace OC\Files\Cache\Wrapper;
use OC\Files\Cache\Cache;
use OCP\Files\Cache\ICacheEntry;
+use OCP\Files\Search\ISearchQuery;
/**
* Jail to a subdirectory of the wrapped cache
@@ -218,6 +219,11 @@ class CacheJail extends CacheWrapper {
return $this->formatSearchResults($results);
}
+ public function searchQuery(ISearchQuery $query) {
+ $results = $this->getCache()->searchQuery($query);
+ return $this->formatSearchResults($results);
+ }
+
/**
* search for files by mimetype
*
diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php
index 83fe7e5f43e..1463d1467b8 100644
--- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php
+++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php
@@ -31,6 +31,7 @@ namespace OC\Files\Cache\Wrapper;
use OC\Files\Cache\Cache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Cache\ICache;
+use OCP\Files\Search\ISearchQuery;
class CacheWrapper extends Cache {
/**
@@ -229,6 +230,11 @@ class CacheWrapper extends Cache {
return array_map(array($this, 'formatCacheEntry'), $results);
}
+ public function searchQuery(ISearchQuery $query) {
+ $results = $this->getCache()->searchQuery($query);
+ return array_map(array($this, 'formatCacheEntry'), $results);
+ }
+
/**
* search for files by tag
*
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index fd907f708f3..45372d0fedf 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -33,6 +33,7 @@ use OCP\Files\FileInfo;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
+use OCP\Files\Search\ISearchOperator;
class Folder extends Node implements \OCP\Files\Folder {
/**
@@ -190,11 +191,15 @@ class Folder extends Node implements \OCP\Files\Folder {
/**
* search for files with the name matching $query
*
- * @param string $query
+ * @param string|ISearchOperator $query
* @return \OC\Files\Node\Node[]
*/
public function search($query) {
- return $this->searchCommon('search', array('%' . $query . '%'));
+ if (is_string($query)) {
+ return $this->searchCommon('search', array('%' . $query . '%'));
+ } else {
+ return $this->searchCommon('searchQuery', array($query));
+ }
}
/**
diff --git a/lib/private/Files/Search/SearchBinaryOperator.php b/lib/private/Files/Search/SearchBinaryOperator.php
new file mode 100644
index 00000000000..c9466d8b9ea
--- /dev/null
+++ b/lib/private/Files/Search/SearchBinaryOperator.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Files\Search;
+
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchOperator;
+
+class SearchBinaryOperator implements ISearchBinaryOperator {
+ /** @var string */
+ private $type;
+ /** @var ISearchOperator[] */
+ private $arguments;
+
+ /**
+ * SearchBinaryOperator constructor.
+ *
+ * @param string $type
+ * @param ISearchOperator[] $arguments
+ */
+ public function __construct($type, array $arguments) {
+ $this->type = $type;
+ $this->arguments = $arguments;
+ }
+
+ /**
+ * @return string
+ */
+ public function getType() {
+ return $this->type;
+ }
+
+ /**
+ * @return ISearchOperator[]
+ */
+ public function getArguments() {
+ return $this->arguments;
+ }
+}
diff --git a/lib/private/Files/Search/SearchComparison.php b/lib/private/Files/Search/SearchComparison.php
new file mode 100644
index 00000000000..32c4ad0e5aa
--- /dev/null
+++ b/lib/private/Files/Search/SearchComparison.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Files\Search;
+
+use OCP\Files\Search\ISearchComparison;
+
+class SearchComparison implements ISearchComparison {
+ /** @var string */
+ private $type;
+ /** @var string */
+ private $field;
+ /** @var string|integer|\DateTime */
+ private $value;
+
+ /**
+ * SearchComparison constructor.
+ *
+ * @param string $type
+ * @param string $field
+ * @param \DateTime|int|string $value
+ */
+ public function __construct($type, $field, $value) {
+ $this->type = $type;
+ $this->field = $field;
+ $this->value = $value;
+ }
+
+ /**
+ * @return string
+ */
+ public function getType() {
+ return $this->type;
+ }
+
+ /**
+ * @return string
+ */
+ public function getField() {
+ return $this->field;
+ }
+
+ /**
+ * @return \DateTime|int|string
+ */
+ public function getValue() {
+ return $this->value;
+ }
+}
diff --git a/lib/private/Files/Search/SearchOrder.php b/lib/private/Files/Search/SearchOrder.php
new file mode 100644
index 00000000000..c76d6f2e25e
--- /dev/null
+++ b/lib/private/Files/Search/SearchOrder.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Files\Search;
+
+
+use OCP\Files\Search\ISearchOrder;
+
+class SearchOrder implements ISearchOrder {
+ /** @var string */
+ private $direction;
+ /** @var string */
+ private $field;
+
+ /**
+ * SearchOrder constructor.
+ *
+ * @param string $direction
+ * @param string $field
+ */
+ public function __construct($direction, $field) {
+ $this->direction = $direction;
+ $this->field = $field;
+ }
+
+ /**
+ * @return string
+ */
+ public function getDirection() {
+ return $this->direction;
+ }
+
+ /**
+ * @return string
+ */
+ public function getField() {
+ return $this->field;
+ }
+}
diff --git a/lib/private/Files/Search/SearchQuery.php b/lib/private/Files/Search/SearchQuery.php
new file mode 100644
index 00000000000..8a0478ae98e
--- /dev/null
+++ b/lib/private/Files/Search/SearchQuery.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Files\Search;
+
+use OCP\Files\Search\ISearchOperator;
+use OCP\Files\Search\ISearchOrder;
+use OCP\Files\Search\ISearchQuery;
+
+class SearchQuery implements ISearchQuery {
+ /** @var ISearchOperator */
+ private $searchOperation;
+ /** @var integer */
+ private $limit;
+ /** @var integer */
+ private $offset;
+ /** @var ISearchOrder[] */
+ private $order;
+
+ /**
+ * SearchQuery constructor.
+ *
+ * @param ISearchOperator $searchOperation
+ * @param int $limit
+ * @param int $offset
+ * @param array $order
+ */
+ public function __construct(ISearchOperator $searchOperation, $limit, $offset, array $order) {
+ $this->searchOperation = $searchOperation;
+ $this->limit = $limit;
+ $this->offset = $offset;
+ $this->order = $order;
+ }
+
+ /**
+ * @return ISearchOperator
+ */
+ public function getSearchOperation() {
+ return $this->searchOperation;
+ }
+
+ /**
+ * @return int
+ */
+ public function getLimit() {
+ return $this->limit;
+ }
+
+ /**
+ * @return int
+ */
+ public function getOffset() {
+ return $this->offset;
+ }
+
+ /**
+ * @return ISearchOrder[]
+ */
+ public function getOrder() {
+ return $this->order;
+ }
+}
diff --git a/lib/private/Lockdown/Filesystem/NullCache.php b/lib/private/Lockdown/Filesystem/NullCache.php
index 8c6b5258aa8..9cb8016194b 100644
--- a/lib/private/Lockdown/Filesystem/NullCache.php
+++ b/lib/private/Lockdown/Filesystem/NullCache.php
@@ -24,6 +24,7 @@ use OCP\Constants;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\FileInfo;
+use OCP\Files\Search\ISearchQuery;
class NullCache implements ICache {
public function getNumericStorageId() {
@@ -103,6 +104,10 @@ class NullCache implements ICache {
return [];
}
+ public function searchQuery(ISearchQuery $query) {
+ return [];
+ }
+
public function searchByTag($tag, $userId) {
return [];
}
diff --git a/lib/private/OCS/Provider.php b/lib/private/OCS/Provider.php
index 7d53479c6e2..2e9ed85b67b 100644
--- a/lib/private/OCS/Provider.php
+++ b/lib/private/OCS/Provider.php
@@ -70,6 +70,23 @@ class Provider extends \OCP\AppFramework\Controller {
];
}
+ if ($this->appManager->isEnabledForUser('federation')) {
+ if (isset($services['FEDERATED_SHARING'])) {
+ $services['FEDERATED_SHARING']['endpoints']['shared-secret'] = '/ocs/v2.php/cloud/shared-secret';
+ $services['FEDERATED_SHARING']['endpoints']['system-address-book'] = '/remote.php/dav/addressbooks/system/system/system';
+ $services['FEDERATED_SHARING']['endpoints']['carddav-user'] = 'system';
+ } else {
+ $services['FEDERATED_SHARING'] = [
+ 'version' => 1,
+ 'endpoints' => [
+ 'shared-secret' => '/ocs/v2.php/cloud/shared-secret',
+ 'system-address-book' => '/remote.php/dav/addressbooks/system/system/system',
+ 'carddav-user' => 'system'
+ ],
+ ];
+ }
+ }
+
if($this->appManager->isEnabledForUser('activity')) {
$services['ACTIVITY'] = [
'version' => 1,
diff --git a/lib/private/Preview/MP3.php b/lib/private/Preview/MP3.php
index 804ec7fbcd9..05cd7c0edb1 100644
--- a/lib/private/Preview/MP3.php
+++ b/lib/private/Preview/MP3.php
@@ -61,24 +61,6 @@ class MP3 extends Provider {
}
}
- return $this->getNoCoverThumbnail();
+ return false;
}
-
- /**
- * Generates a default image when the file has no cover
- *
- * @return bool|\OCP\IImage false if the default image is missing or invalid
- */
- private function getNoCoverThumbnail() {
- $icon = \OC::$SERVERROOT . '/core/img/filetypes/audio.svg';
-
- if(!file_exists($icon)) {
- return false;
- }
-
- $image = new \OC_Image();
- $image->loadFromFile($icon);
- return $image->valid() ? $image : false;
- }
-
}
diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php
index 6abaa7dd413..da4b7dda91c 100644
--- a/lib/private/Share/Share.php
+++ b/lib/private/Share/Share.php
@@ -237,8 +237,19 @@ class Share extends Constants {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
} else {
+ $groupManager = \OC::$server->getGroupManager();
while ($row = $result->fetchRow()) {
- $usersInGroup = \OC_Group::usersInGroup($row['share_with']);
+
+ $usersInGroup = [];
+ $group = $groupManager->get($row['share_with']);
+ if ($group) {
+ $users = $group->searchUsers('', -1, 0);
+ $userIds = array();
+ foreach ($users as $user) {
+ $userIds[] = $user->getUID();
+ }
+ $usersInGroup = $userIds;
+ }
$shares = array_merge($shares, $usersInGroup);
if ($returnUserPaths) {
foreach ($usersInGroup as $user) {
@@ -468,7 +479,11 @@ class Share extends Constants {
//if didn't found a result than let's look for a group share.
if(empty($shares) && $user !== null) {
- $groups = \OC_Group::getUserGroups($user);
+ $userObject = \OC::$server->getUserManager()->get($user);
+ $groups = [];
+ if ($userObject) {
+ $groups = \OC::$server->getGroupManager()->getUserGroupIds($userObject);
+ }
if (!empty($groups)) {
$where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)';
@@ -628,7 +643,18 @@ class Share extends Constants {
if ((int)$item['share_type'] === self::SHARE_TYPE_USER) {
$users[] = $item['share_with'];
} else if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) {
- $users = array_merge($users, \OC_Group::usersInGroup($item['share_with']));
+
+ $group = \OC::$server->getGroupManager()->get($item['share_with']);
+ $userIds = [];
+ if ($group) {
+ $users = $group->searchUsers('', -1, 0);
+ foreach ($users as $user) {
+ $userIds[] = $user->getUID();
+ }
+ return $userIds;
+ }
+
+ $users = array_merge($users, $userIds);
}
}
}
@@ -740,7 +766,19 @@ class Share extends Constants {
throw new \Exception($message_t);
}
if ($shareWithinGroupOnly) {
- $inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
+ $userManager = \OC::$server->getUserManager();
+ $groupManager = \OC::$server->getGroupManager();
+ $userOwner = $userManager->get($uidOwner);
+ $userShareWith = $userManager->get($shareWith);
+ $groupsOwner = [];
+ $groupsShareWith = [];
+ if ($userOwner) {
+ $groupsOwner = $groupManager->getUserGroupIds($userOwner);
+ }
+ if ($userShareWith) {
+ $groupsShareWith = $groupManager->getUserGroupIds($userShareWith);
+ }
+ $inGroup = array_intersect($groupsOwner, $groupsShareWith);
if (empty($inGroup)) {
$message = 'Sharing %s failed, because the user '
.'%s is not a member of any groups that %s is a member of';
@@ -775,18 +813,22 @@ class Share extends Constants {
}
}
} else if ($shareType === self::SHARE_TYPE_GROUP) {
- if (!\OC_Group::groupExists($shareWith)) {
+ if (!\OC::$server->getGroupManager()->groupExists($shareWith)) {
$message = 'Sharing %s failed, because the group %s does not exist';
$message_t = $l->t('Sharing %s failed, because the group %s does not exist', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
throw new \Exception($message_t);
}
if ($shareWithinGroupOnly && !\OC_Group::inGroup($uidOwner, $shareWith)) {
- $message = 'Sharing %s failed, because '
- .'%s is not a member of the group %s';
- $message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith));
- \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::DEBUG);
- throw new \Exception($message_t);
+ $group = \OC::$server->getGroupManager()->get($shareWith);
+ $user = \OC::$server->getUserManager()->get($uidOwner);
+ if (!$group || !$user || !$group->inGroup($user)) {
+ $message = 'Sharing %s failed, because '
+ . '%s is not a member of the group %s';
+ $message_t = $l->t('Sharing %s failed, because %s is not a member of the group %s', array($itemSourceName, $uidOwner, $shareWith));
+ \OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $uidOwner, $shareWith), \OCP\Util::DEBUG);
+ throw new \Exception($message_t);
+ }
}
// Check if the item source is already shared with the group, either from the same owner or a different user
// The check for each user in the group is done inside the put() function
@@ -804,7 +846,18 @@ class Share extends Constants {
$group = $shareWith;
$shareWith = array();
$shareWith['group'] = $group;
- $shareWith['users'] = array_diff(\OC_Group::usersInGroup($group), array($uidOwner));
+
+
+ $groupObject = \OC::$server->getGroupManager()->get($group);
+ $userIds = [];
+ if ($groupObject) {
+ $users = $groupObject->searchUsers('', -1, 0);
+ foreach ($users as $user) {
+ $userIds[] = $user->getUID();
+ }
+ }
+
+ $shareWith['users'] = array_diff($userIds, array($uidOwner));
} else if ($shareType === self::SHARE_TYPE_LINK) {
$updateExistingShare = false;
if (\OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
@@ -1057,7 +1110,9 @@ class Share extends Constants {
$itemUnshared = true;
break;
} elseif ((int)$share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
- if (\OC_Group::inGroup($uid, $share['share_with'])) {
+ $group = \OC::$server->getGroupManager()->get($share['share_with']);
+ $user = \OC::$server->getUserManager()->get($uid);
+ if ($group && $user && $group->inGroup($user)) {
$groupShare = $share;
}
} elseif ((int)$share['share_type'] === self::$shareTypeGroupUserUnique &&
@@ -1746,7 +1801,12 @@ class Share extends Constants {
$queryArgs[] = self::SHARE_TYPE_USER;
$queryArgs[] = self::$shareTypeGroupUserUnique;
$queryArgs[] = $shareWith;
- $groups = \OC_Group::getUserGroups($shareWith);
+
+ $user = \OC::$server->getUserManager()->get($shareWith);
+ $groups = [];
+ if ($user) {
+ $groups = \OC::$server->getGroupManager()->getUserGroupIds($user);
+ }
if (!empty($groups)) {
$placeholders = join(',', array_fill(0, count($groups), '?'));
$where .= ' OR (`share_type` = ? AND `share_with` IN ('.$placeholders.')) ';
@@ -2171,7 +2231,17 @@ class Share extends Constants {
if (isset($shareWith['users'])) {
$users = $shareWith['users'];
} else {
- $users = \OC_Group::usersInGroup($shareWith['group']);
+ $group = \OC::$server->getGroupManager()->get($shareWith['group']);
+ if ($group) {
+ $users = $group->searchUsers('', -1, 0);
+ $userIds = [];
+ foreach ($users as $user) {
+ $userIds[] = $user->getUID();
+ }
+ $users = $userIds;
+ } else {
+ $users = [];
+ }
}
// remove current user from list
if (in_array(\OCP\User::getUser(), $users)) {
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php
index d6f5a2c6fd3..744ea80761e 100644
--- a/lib/private/Template/SCSSCacher.php
+++ b/lib/private/Template/SCSSCacher.php
@@ -103,10 +103,17 @@ class SCSSCacher {
private function isCached($fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $path) {
try{
$cachedFile = $folder->getFile($fileNameCSS);
- if( $cachedFile->getMTime() > filemtime($path.'/'.$fileNameSCSS)
- && $cachedFile->getSize() > 0 ) {
- return true;
+ if ($cachedFile->getSize() > 0) {
+ $depFile = $folder->getFile($fileNameCSS . '.deps');
+ $deps = json_decode($depFile->getContent(), true);
+
+ foreach ($deps as $file=>$mtime) {
+ if (!file_exists($file) || filemtime($file) > $mtime) {
+ return false;
+ }
+ }
}
+ return true;
} catch(NotFoundException $e) {
return false;
}
@@ -140,6 +147,13 @@ class SCSSCacher {
$cachedfile = $folder->newFile($fileNameCSS);
}
+ $depFileName = $fileNameCSS . '.deps';
+ try {
+ $depFile = $folder->getFile($depFileName);
+ } catch (NotFoundException $e) {
+ $depFile = $folder->newFile($depFileName);
+ }
+
// Compile
try {
$compiledScss = $scss->compile('@import "'.$fileNameSCSS.'";');
@@ -150,6 +164,7 @@ class SCSSCacher {
try {
$cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir));
+ $depFile->putContent(json_encode($scss->getParsedFiles()));
$this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
return true;
} catch(NotFoundException $e) {
diff --git a/lib/private/User/User.php b/lib/private/User/User.php
index 961f70f8a8e..bca9c46bfd0 100644
--- a/lib/private/User/User.php
+++ b/lib/private/User/User.php
@@ -204,9 +204,15 @@ class User implements IUser {
// FIXME: Feels like an hack - suggestions?
+ $groupManager = \OC::$server->getGroupManager();
// We have to delete the user from all groups
- foreach (\OC::$server->getGroupManager()->getUserGroupIds($this) as $groupId) {
- \OC_Group::removeFromGroup($this->uid, $groupId);
+ foreach ($groupManager->getUserGroupIds($this) as $groupId) {
+ $group = $groupManager->get($groupId);
+ if ($group) {
+ \OC_Hook::emit("OC_Group", "pre_removeFromGroup", ["run" => true, "uid" => $this->uid, "gid" => $groupId]);
+ $group->removeUser($this);
+ \OC_Hook::emit("OC_User", "post_removeFromGroup", ["uid" => $this->uid, "gid" => $groupId]);
+ }
}
// Delete the user's keys in preferences
\OC::$server->getConfig()->deleteAllUserValues($this->uid);
diff --git a/lib/private/legacy/group.php b/lib/private/legacy/group.php
deleted file mode 100644
index 6b58cb4c834..00000000000
--- a/lib/private/legacy/group.php
+++ /dev/null
@@ -1,302 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Georg Ehrke <georg@owncloud.com>
- * @author goodkiller <markopraakli@gmail.com>
- * @author Jakob Sack <mail@jakobsack.de>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author macjohnny <estebanmarin@gmx.ch>
- * @author Michael Gapczynski <GapczynskiM@gmail.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Qingping Hou <dave2008713@gmail.com>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/**
- * This class provides all methods needed for managing groups.
- *
- * Note that &run is deprecated and won't work anymore.
- * Hooks provided:
- * pre_createGroup(&run, gid)
- * post_createGroup(gid)
- * pre_deleteGroup(&run, gid)
- * post_deleteGroup(gid)
- * pre_addToGroup(&run, uid, gid)
- * post_addToGroup(uid, gid)
- * pre_removeFromGroup(&run, uid, gid)
- * post_removeFromGroup(uid, gid)
- */
-class OC_Group {
-
- /**
- * @return \OC\Group\Manager
- * @deprecated Use \OC::$server->getGroupManager();
- */
- public static function getManager() {
- return \OC::$server->getGroupManager();
- }
-
- /**
- * @return \OC\User\Manager
- * @deprecated Use \OC::$server->getUserManager()
- */
- private static function getUserManager() {
- return \OC::$server->getUserManager();
- }
-
- /**
- * set the group backend
- * @param \OC\Group\Backend $backend The backend to use for user management
- * @return bool
- */
- public static function useBackend($backend) {
- self::getManager()->addBackend($backend);
- return true;
- }
-
- /**
- * remove all used backends
- */
- public static function clearBackends() {
- self::getManager()->clearBackends();
- }
-
- /**
- * Try to create a new group
- * @param string $gid The name of the group to create
- * @return bool
- *
- * Tries to create a new group. If the group name already exists, false will
- * be returned. Basic checking of Group name
- * @deprecated Use \OC::$server->getGroupManager()->createGroup() instead
- */
- public static function createGroup($gid) {
- if (self::getManager()->createGroup($gid)) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * delete a group
- * @param string $gid gid of the group to delete
- * @return bool
- *
- * Deletes a group and removes it from the group_user-table
- * @deprecated Use \OC::$server->getGroupManager()->delete() instead
- */
- public static function deleteGroup($gid) {
- $group = self::getManager()->get($gid);
- if ($group) {
- if ($group->delete()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * is user in group?
- * @param string $uid uid of the user
- * @param string $gid gid of the group
- * @return bool
- *
- * Checks whether the user is member of a group or not.
- * @deprecated Use \OC::$server->getGroupManager->inGroup($user);
- */
- public static function inGroup($uid, $gid) {
- $group = self::getManager()->get($gid);
- $user = self::getUserManager()->get($uid);
- if ($group and $user) {
- return $group->inGroup($user);
- }
- return false;
- }
-
- /**
- * Add a user to a group
- * @param string $uid Name of the user to add to group
- * @param string $gid Name of the group in which add the user
- * @return bool
- *
- * Adds a user to a group.
- * @deprecated Use \OC::$server->getGroupManager->addUser();
- */
- public static function addToGroup($uid, $gid) {
- $group = self::getManager()->get($gid);
- $user = self::getUserManager()->get($uid);
- if ($group and $user) {
- $group->addUser($user);
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Removes a user from a group
- * @param string $uid Name of the user to remove from group
- * @param string $gid Name of the group from which remove the user
- * @return bool
- *
- * removes the user from a group.
- */
- public static function removeFromGroup($uid, $gid) {
- $group = self::getManager()->get($gid);
- $user = self::getUserManager()->get($uid);
- if ($group and $user) {
- OC_Hook::emit("OC_Group", "pre_removeFromGroup", array("run" => true, "uid" => $uid, "gid" => $gid));
- $group->removeUser($user);
- OC_Hook::emit("OC_User", "post_removeFromGroup", array("uid" => $uid, "gid" => $gid));
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get all groups a user belongs to
- * @param string $uid Name of the user
- * @return array an array of group names
- *
- * This function fetches all groups a user belongs to. It does not check
- * if the user exists at all.
- * @deprecated Use \OC::$server->getGroupManager->getUserGroupIds($user)
- */
- public static function getUserGroups($uid) {
- $user = self::getUserManager()->get($uid);
- if ($user) {
- return self::getManager()->getUserGroupIds($user);
- } else {
- return array();
- }
- }
-
- /**
- * get a list of all groups
- * @param string $search
- * @param int|null $limit
- * @param int|null $offset
- * @return array an array of group names
- *
- * Returns a list with all groups
- */
- public static function getGroups($search = '', $limit = null, $offset = null) {
- $groups = self::getManager()->search($search, $limit, $offset);
- $groupIds = array();
- foreach ($groups as $group) {
- $groupIds[] = $group->getGID();
- }
- return $groupIds;
- }
-
- /**
- * check if a group exists
- *
- * @param string $gid
- * @return bool
- * @deprecated Use \OC::$server->getGroupManager->groupExists($gid)
- */
- public static function groupExists($gid) {
- return self::getManager()->groupExists($gid);
- }
-
- /**
- * get a list of all users in a group
- * @param string $gid
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array an array of user ids
- */
- public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- $group = self::getManager()->get($gid);
- if ($group) {
- $users = $group->searchUsers($search, $limit, $offset);
- $userIds = array();
- foreach ($users as $user) {
- $userIds[] = $user->getUID();
- }
- return $userIds;
- } else {
- return array();
- }
- }
-
- /**
- * get a list of all users in several groups
- * @param string[] $gids
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array an array of user ids
- */
- public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) {
- $users = array();
- foreach ($gids as $gid) {
- // TODO Need to apply limits to groups as total
- $users = array_merge(array_diff(self::usersInGroup($gid, $search, $limit, $offset), $users), $users);
- }
- return $users;
- }
-
- /**
- * get a list of all display names in a group
- * @param string $gid
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array an array of display names (value) and user ids(key)
- * @deprecated Use \OC::$server->getGroupManager->displayNamesInGroup($gid, $search, $limit, $offset)
- */
- public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- return self::getManager()->displayNamesInGroup($gid, $search, $limit, $offset);
- }
-
- /**
- * get a list of all display names in several groups
- * @param array $gids
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array an array of display names (Key) user ids (value)
- */
- public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
- $displayNames = array();
- foreach ($gids as $gid) {
- // TODO Need to apply limits to groups as total
- $diff = array_diff(
- self::displayNamesInGroup($gid, $search, $limit, $offset),
- $displayNames
- );
- if ($diff) {
- // A fix for LDAP users. array_merge loses keys...
- $displayNames = $diff + $displayNames;
- }
- }
- return $displayNames;
- }
-}
diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php
index ed7dfce29a6..e26148bdf15 100644
--- a/lib/private/legacy/image.php
+++ b/lib/private/legacy/image.php
@@ -562,7 +562,11 @@ class OC_Image implements \OCP\IImage {
break;
case IMAGETYPE_JPEG:
if (imagetypes() & IMG_JPG) {
- $this->resource = imagecreatefromjpeg($imagePath);
+ if (getimagesize($imagePath) !== false) {
+ $this->resource = imagecreatefromjpeg($imagePath);
+ } else {
+ $this->logger->debug('OC_Image->loadFromFile, JPG image not valid: ' . $imagePath, array('app' => 'core'));
+ }
} else {
$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
}
diff --git a/lib/private/legacy/template.php b/lib/private/legacy/template.php
index 09e3d130f49..8535e018879 100644
--- a/lib/private/legacy/template.php
+++ b/lib/private/legacy/template.php
@@ -106,19 +106,9 @@ class OC_Template extends \OC\Template\Base {
}
}
- OC_Util::addStyle("tooltip",null,true);
OC_Util::addStyle('jquery-ui-fixes',null,true);
OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
- OC_Util::addStyle("mobile",null,true);
- OC_Util::addStyle("multiselect",null,true);
- OC_Util::addStyle("fixes",null,true);
- OC_Util::addStyle("global",null,true);
- OC_Util::addStyle("apps",null,true);
- OC_Util::addStyle("fonts",null,true);
- OC_Util::addStyle("icons",null,true);
- OC_Util::addStyle("header",null,true);
- OC_Util::addStyle("inputs");
- OC_Util::addStyle("styles",null,true);
+ OC_Util::addStyle('server', null, true);
// avatars
\OC_Util::addScript('jquery.avatar', null, true);
diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php
index 661242a659a..621ea3535b1 100644
--- a/lib/private/legacy/user.php
+++ b/lib/private/legacy/user.php
@@ -333,7 +333,9 @@ class OC_User {
* @return bool
*/
public static function isAdminUser($uid) {
- if (OC_Group::inGroup($uid, 'admin') && self::$incognitoMode === false) {
+ $group = \OC::$server->getGroupManager()->get('admin');
+ $user = \OC::$server->getUserManager()->get($uid);
+ if ($group && $user && $group->inGroup($user) && self::$incognitoMode === false) {
return true;
}
return false;
diff --git a/lib/public/Files/Cache/ICache.php b/lib/public/Files/Cache/ICache.php
index 7d01b1a2908..63993d0a8cb 100644
--- a/lib/public/Files/Cache/ICache.php
+++ b/lib/public/Files/Cache/ICache.php
@@ -21,6 +21,8 @@
*/
namespace OCP\Files\Cache;
+use OCP\Files\Search\ISearchOperator;
+use OCP\Files\Search\ISearchQuery;
/**
* Metadata cache for a storage
@@ -213,6 +215,16 @@ interface ICache {
public function searchByMime($mimetype);
/**
+ * Search for files with a flexible query
+ *
+ * @param ISearchQuery $query
+ * @return ICacheEntry[]
+ * @throw \InvalidArgumentException if the cache is unable to perform the query
+ * @since 12.0.0
+ */
+ public function searchQuery(ISearchQuery $query);
+
+ /**
* Search for files by tag of a given users.
*
* Note that every user can tag files differently.
diff --git a/lib/public/Files/Folder.php b/lib/public/Files/Folder.php
index 8f8576d8503..52a4b303196 100644
--- a/lib/public/Files/Folder.php
+++ b/lib/public/Files/Folder.php
@@ -30,6 +30,7 @@
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
+use OCP\Files\Search\ISearchQuery;
/**
* @since 6.0.0
@@ -115,7 +116,7 @@ interface Folder extends Node {
/**
* search for files with the name matching $query
*
- * @param string $query
+ * @param string|ISearchQuery $query
* @return \OCP\Files\Node[]
* @since 6.0.0
*/
diff --git a/lib/public/Files/Search/ISearchBinaryOperator.php b/lib/public/Files/Search/ISearchBinaryOperator.php
new file mode 100644
index 00000000000..d5a2d5dc02d
--- /dev/null
+++ b/lib/public/Files/Search/ISearchBinaryOperator.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchBinaryOperator extends ISearchOperator {
+ const OPERATOR_AND = 'and';
+ const OPERATOR_OR = 'or';
+ const OPERATOR_NOT = 'not';
+
+ /**
+ * The type of binary operator
+ *
+ * One of the ISearchBinaryOperator::OPERATOR_* constants
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getType();
+
+ /**
+ * The arguments for the binary operator
+ *
+ * One argument for the 'not' operator and two for 'and' and 'or'
+ *
+ * @return ISearchOperator[]
+ * @since 12.0.0
+ */
+ public function getArguments();
+}
diff --git a/lib/public/Files/Search/ISearchComparison.php b/lib/public/Files/Search/ISearchComparison.php
new file mode 100644
index 00000000000..5468260f001
--- /dev/null
+++ b/lib/public/Files/Search/ISearchComparison.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchComparison extends ISearchOperator {
+ const COMPARE_EQUAL = 'eq';
+ const COMPARE_GREATER_THAN = 'gt';
+ const COMPARE_GREATER_THAN_EQUAL = 'gte';
+ const COMPARE_LESS_THAN = 'lt';
+ const COMPARE_LESS_THAN_EQUAL = 'lte';
+ const COMPARE_LIKE = 'like';
+
+ /**
+ * Get the type of comparison, one of the ISearchComparison::COMPARE_* constants
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getType();
+
+ /**
+ * Get the name of the field to compare with
+ *
+ * i.e. 'size', 'name' or 'mimetype'
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getField();
+
+ /**
+ * Get the value to compare the field with
+ *
+ * @return string|integer|\DateTime
+ * @since 12.0.0
+ */
+ public function getValue();
+}
diff --git a/lib/public/Files/Search/ISearchOperator.php b/lib/public/Files/Search/ISearchOperator.php
new file mode 100644
index 00000000000..047792bc782
--- /dev/null
+++ b/lib/public/Files/Search/ISearchOperator.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchOperator {
+
+}
diff --git a/lib/public/Files/Search/ISearchOrder.php b/lib/public/Files/Search/ISearchOrder.php
new file mode 100644
index 00000000000..1abfd7506d5
--- /dev/null
+++ b/lib/public/Files/Search/ISearchOrder.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchOrder {
+ const DIRECTION_ASCENDING = 'asc';
+ const DIRECTION_DESCENDING = 'desc';
+
+ /**
+ * The direction to sort in, either ISearchOrder::DIRECTION_ASCENDING or ISearchOrder::DIRECTION_DESCENDING
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getDirection();
+
+ /**
+ * The field to sort on
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getField();
+}
diff --git a/lib/public/Files/Search/ISearchQuery.php b/lib/public/Files/Search/ISearchQuery.php
new file mode 100644
index 00000000000..5a701b321b1
--- /dev/null
+++ b/lib/public/Files/Search/ISearchQuery.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchQuery {
+ /**
+ * @return ISearchOperator
+ * @since 12.0.0
+ */
+ public function getSearchOperation();
+
+ /**
+ * Get the maximum number of results to return
+ *
+ * @return integer
+ * @since 12.0.0
+ */
+ public function getLimit();
+
+ /**
+ * Get the offset for returned results
+ *
+ * @return integer
+ * @since 12.0.0
+ */
+ public function getOffset();
+
+ /**
+ * The fields and directions to order by
+ *
+ * @return ISearchOrder[]
+ * @since 12.0.0
+ */
+ public function getOrder();
+}