diff options
m--------- | 3rdparty | 0 | ||||
-rw-r--r-- | apps/files_external/lib/google.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/js/authenticate.js | 9 | ||||
-rw-r--r-- | apps/files_sharing/lib/external/storage.php | 54 | ||||
-rw-r--r-- | apps/files_sharing/templates/authenticate.php | 5 | ||||
-rw-r--r-- | build/integration/features/bootstrap/CapabilitiesContext.php | 4 | ||||
-rw-r--r-- | lib/private/share20/defaultshareprovider.php | 61 |
7 files changed, 92 insertions, 44 deletions
diff --git a/3rdparty b/3rdparty -Subproject fc0c1159f4e275186b45f8454aaa89f90718b89 +Subproject c3b4612313742540cdf472a923a0dc6d2d80653 diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 3e8b60d33df..5e5716cf438 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -265,7 +265,8 @@ class Google extends \OC\Files\Storage\Common { foreach ($children->getItems() as $child) { $name = $child->getTitle(); // Check if this is a Google Doc i.e. no extension in name - if (empty($child->getFileExtension()) + $extension = $child->getFileExtension(); + if (empty($extension) && $child->getMimeType() !== self::FOLDER ) { $name .= '.'.$this->getGoogleDocExtension($child->getMimeType()); diff --git a/apps/files_sharing/js/authenticate.js b/apps/files_sharing/js/authenticate.js new file mode 100644 index 00000000000..7f3f0d0a7d4 --- /dev/null +++ b/apps/files_sharing/js/authenticate.js @@ -0,0 +1,9 @@ +$(document).ready(function(){ + $('#password').on('keyup input change', function() { + if ($('#password').val().length > 0) { + $('#password-submit').prop('disabled', false); + } else { + $('#password-submit').prop('disabled', true); + } + }); +}); diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php index 87f5a3598fb..16fd84bdba5 100644 --- a/apps/files_sharing/lib/external/storage.php +++ b/apps/files_sharing/lib/external/storage.php @@ -25,6 +25,8 @@ namespace OCA\Files_Sharing\External; +use GuzzleHttp\Exception\ClientException; +use GuzzleHttp\Exception\ConnectException; use OC\Files\Storage\DAV; use OC\ForbiddenException; use OCA\FederatedFileSharing\DiscoveryManager; @@ -34,36 +36,21 @@ use OCP\Files\StorageInvalidException; use OCP\Files\StorageNotAvailableException; class Storage extends DAV implements ISharedStorage { - /** - * @var string - */ + /** @var string */ private $remoteUser; - - /** - * @var string - */ + /** @var string */ private $remote; - - /** - * @var string - */ + /** @var string */ private $mountPoint; - - /** - * @var string - */ + /** @var string */ private $token; - - /** - * @var \OCP\ICacheFactory - */ + /** @var \OCP\ICacheFactory */ private $memcacheFactory; - - /** - * @var \OCP\ICertificateManager - */ + /** @var \OCP\Http\Client\IClientService */ + private $httpClient; + /** @var \OCP\ICertificateManager */ private $certificateManager; - + /** @var bool */ private $updateChecked = false; /** @@ -73,6 +60,7 @@ class Storage extends DAV implements ISharedStorage { public function __construct($options) { $this->memcacheFactory = \OC::$server->getMemCacheFactory(); + $this->httpClient = \OC::$server->getHTTPClientService(); $discoveryManager = new DiscoveryManager( $this->memcacheFactory, \OC::$server->getHTTPClientService() @@ -253,13 +241,21 @@ class Storage extends DAV implements ISharedStorage { */ private function testRemoteUrl($url) { $cache = $this->memcacheFactory->create('files_sharing_remote_url'); - if($result = $cache->get($url)) { - return (bool)$result; + if($cache->hasKey($url)) { + return (bool)$cache->get($url); + } + + $client = $this->httpClient->newClient(); + try { + $result = $client->get($url)->getBody(); + $data = json_decode($result); + $returnValue = (is_object($data) && !empty($data->version)); + } catch (ConnectException $e) { + $returnValue = false; + } catch (ClientException $e) { + $returnValue = false; } - $result = file_get_contents($url); - $data = json_decode($result); - $returnValue = (is_object($data) and !empty($data->version)); $cache->set($url, $returnValue); return $returnValue; } diff --git a/apps/files_sharing/templates/authenticate.php b/apps/files_sharing/templates/authenticate.php index 72adf0d1674..909e839177c 100644 --- a/apps/files_sharing/templates/authenticate.php +++ b/apps/files_sharing/templates/authenticate.php @@ -2,6 +2,7 @@ /** @var $_ array */ /** @var $l OC_L10N */ style('files_sharing', 'authenticate'); + script('files_sharing', 'authenticate'); ?> <form method="post"> <fieldset> @@ -18,8 +19,8 @@ placeholder="<?php p($l->t('Password')); ?>" value="" autocomplete="off" autocapitalize="off" autocorrect="off" autofocus /> - <input type="submit" value="" - class="svg icon-confirm input-button-inline" /> + <input type="submit" id="password-submit" + class="svg icon-confirm input-button-inline" value="" disabled="disabled" /> </p> </fieldset> </form> diff --git a/build/integration/features/bootstrap/CapabilitiesContext.php b/build/integration/features/bootstrap/CapabilitiesContext.php index d30984f0db7..83d5f5fd2f3 100644 --- a/build/integration/features/bootstrap/CapabilitiesContext.php +++ b/build/integration/features/bootstrap/CapabilitiesContext.php @@ -39,9 +39,9 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext { foreach ($formData->getHash() as $row) { $path_to_element = explode('@@@', $row['path_to_element']); - $answeredValue = $capabilitiesXML->$row['capability']; + $answeredValue = $capabilitiesXML->{$row['capability']}; for ($i = 0; $i < count($path_to_element); $i++){ - $answeredValue = $answeredValue->$path_to_element[$i]; + $answeredValue = $answeredValue->{$path_to_element[$i]}; } $answeredValue = (string)$answeredValue; PHPUnit_Framework_Assert::assertEquals( diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php index dc5b47b0ab0..43dc6090a35 100644 --- a/lib/private/share20/defaultshareprovider.php +++ b/lib/private/share20/defaultshareprovider.php @@ -274,6 +274,10 @@ class DefaultShareProvider implements IShareProvider { ], IQueryBuilder::PARAM_INT_ARRAY) ) ) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) ->orderBy('id'); $cursor = $qb->execute(); @@ -332,6 +336,10 @@ class DefaultShareProvider implements IShareProvider { ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) ->execute(); $data = $stmt->fetch(); @@ -405,6 +413,10 @@ class DefaultShareProvider implements IShareProvider { ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) ->setMaxResults(1) ->execute(); @@ -455,7 +467,11 @@ class DefaultShareProvider implements IShareProvider { public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') - ->from('share'); + ->from('share') + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )); $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter($shareType))); @@ -523,7 +539,11 @@ class DefaultShareProvider implements IShareProvider { \OCP\Share::SHARE_TYPE_LINK, ], IQueryBuilder::PARAM_INT_ARRAY) ) - ); + ) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )); $cursor = $qb->execute(); $data = $cursor->fetch(); @@ -564,7 +584,12 @@ class DefaultShareProvider implements IShareProvider { $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)), $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)) ) - )->execute(); + ) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) + ->execute(); $shares = []; while($data = $cursor->fetch()) { @@ -597,8 +622,12 @@ class DefaultShareProvider implements IShareProvider { } $qb->setFirstResult($offset); - $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER))); - $qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))); + $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )); // Filter by node if provided if ($node !== null) { @@ -645,11 +674,15 @@ class DefaultShareProvider implements IShareProvider { $groups = array_map(function(IGroup $group) { return $group->getGID(); }, $groups); - $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))); - $qb->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter( - $groups, - IQueryBuilder::PARAM_STR_ARRAY - ))); + $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))) + ->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter( + $groups, + IQueryBuilder::PARAM_STR_ARRAY + ))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )); $cursor = $qb->execute(); while($data = $cursor->fetch()) { @@ -691,6 +724,10 @@ class DefaultShareProvider implements IShareProvider { ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))) ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) ->execute(); $data = $cursor->fetch(); @@ -802,6 +839,10 @@ class DefaultShareProvider implements IShareProvider { ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) ->setMaxResults(1) ->execute(); |