diff options
32 files changed, 1361 insertions, 51 deletions
diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml index 9b500c9f300..0f97289ba37 100644 --- a/apps/dav/appinfo/info.xml +++ b/apps/dav/appinfo/info.xml @@ -5,7 +5,7 @@ <description>WebDAV endpoint</description> <licence>AGPL</licence> <author>owncloud.org</author> - <version>1.4.4</version> + <version>1.4.5</version> <default_enable/> <types> <filesystem/> @@ -52,4 +52,8 @@ <provider>OCA\DAV\CalDAV\Activity\Provider\Todo</provider> </providers> </activity> + + <settings> + <admin>OCA\DAV\Settings\CalDAVSettings</admin> + </settings> </info> diff --git a/apps/dav/appinfo/v1/caldav.php b/apps/dav/appinfo/v1/caldav.php index b005ec2fcb8..a103f82a420 100644 --- a/apps/dav/appinfo/v1/caldav.php +++ b/apps/dav/appinfo/v1/caldav.php @@ -52,6 +52,7 @@ $dispatcher = \OC::$server->getEventDispatcher(); $calDavBackend = new CalDavBackend($db, $principalBackend, $userManager, \OC::$server->getGroupManager(), $random, $dispatcher, true); $debugging = \OC::$server->getConfig()->getSystemValue('debug', false); +$sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes'; // Root nodes $principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend); @@ -84,7 +85,11 @@ if ($debugging) { $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); $server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); $server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); -$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin( \OC::$server->getMailer(), \OC::$server->getLogger(), new \OC\AppFramework\Utility\TimeFactory())); + +if ($sendInvitations) { + $server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin( \OC::$server->getMailer(), \OC::$server->getLogger(), new \OC\AppFramework\Utility\TimeFactory())); +} + $server->addPlugin(new ExceptionLoggerPlugin('caldav', \OC::$server->getLogger())); // And off we go! diff --git a/apps/dav/appinfo/v2/remote.php b/apps/dav/appinfo/v2/remote.php index 3a00c8006ec..c1b29a4a177 100644 --- a/apps/dav/appinfo/v2/remote.php +++ b/apps/dav/appinfo/v2/remote.php @@ -3,6 +3,7 @@ * @copyright Copyright (c) 2016, ownCloud, Inc. * * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> * * @license AGPL-3.0 * diff --git a/apps/dav/js/settings-admin-caldav.js b/apps/dav/js/settings-admin-caldav.js new file mode 100644 index 00000000000..10eb89ab61d --- /dev/null +++ b/apps/dav/js/settings-admin-caldav.js @@ -0,0 +1,28 @@ +/** + * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com> + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @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/>. + * + */ +"use strict"; + +$('#caldavSendInvitations').change(function() { + var val = $(this)[0].checked; + + OCP.AppConfig.setValue('dav', 'sendInvitations', val ? 'yes' : 'no'); +}); diff --git a/apps/dav/lib/AppInfo/PluginManager.php b/apps/dav/lib/AppInfo/PluginManager.php new file mode 100644 index 00000000000..9cdf358c80e --- /dev/null +++ b/apps/dav/lib/AppInfo/PluginManager.php @@ -0,0 +1,170 @@ +<?php +/** + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud GmbH. + * @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/> + * + */ +namespace OCA\DAV\AppInfo; + +use OCP\App\IAppManager; +use OC\ServerContainer; +use OCP\AppFramework\QueryException; + +/** + * Manager for DAV plugins from apps, used to register them + * to the Sabre server. + */ +class PluginManager { + + /** + * @var ServerContainer + */ + private $container; + + /** + * @var IAppManager + */ + private $appManager; + + /** + * App plugins + * + * @var array + */ + private $plugins = null; + + /** + * App collections + * + * @var array + */ + private $collections = null; + + /** + * Contstruct a PluginManager + * + * @param ServerContainer $container server container for resolving plugin classes + * @param IAppManager $appManager app manager to loading apps and their info + */ + public function __construct(ServerContainer $container, IAppManager $appManager) { + $this->container = $container; + $this->appManager = $appManager; + } + + /** + * Returns an array of app-registered plugins + * + * @return array + */ + public function getAppPlugins() { + if (null === $this->plugins) { + $this->populate(); + } + return $this->plugins; + } + + /** + * Returns an array of app-registered collections + * + * @return array + */ + public function getAppCollections() { + if (null === $this->collections) { + $this->populate(); + } + return $this->collections; + } + + /** + * Retrieve plugin and collection list and populate attributes + */ + private function populate() { + $this->plugins = []; + $this->collections = []; + foreach ($this->appManager->getInstalledApps() as $app) { + // load plugins and collections from info.xml + $info = $this->appManager->getAppInfo($app); + if (!isset($info['types']) || !in_array('dav', $info['types'], true)) { + continue; + } + // FIXME: switch to public API once available + // load app to make sure its classes are available + \OC_App::loadApp($app); + $this->loadSabrePluginsFromInfoXml($this->extractPluginList($info)); + $this->loadSabreCollectionsFromInfoXml($this->extractCollectionList($info)); + } + } + + private function extractPluginList(array $array) { + if (isset($array['sabre']) && is_array($array['sabre'])) { + if (isset($array['sabre']['plugins']) && is_array($array['sabre']['plugins'])) { + if (isset($array['sabre']['plugins']['plugin'])) { + $items = $array['sabre']['plugins']['plugin']; + if (!is_array($items)) { + $items = [$items]; + } + return $items; + } + } + } + return []; + } + + private function extractCollectionList(array $array) { + if (isset($array['sabre']) && is_array($array['sabre'])) { + if (isset($array['sabre']['collections']) && is_array($array['sabre']['collections'])) { + if (isset($array['sabre']['collections']['collection'])) { + $items = $array['sabre']['collections']['collection']; + if (!is_array($items)) { + $items = [$items]; + } + return $items; + } + } + } + return []; + } + + private function loadSabrePluginsFromInfoXml(array $plugins) { + foreach ($plugins as $plugin) { + try { + $this->plugins[] = $this->container->query($plugin); + } catch (QueryException $e) { + if (class_exists($plugin)) { + $this->plugins[] = new $plugin(); + } else { + throw new \Exception("Sabre plugin class '$plugin' is unknown and could not be loaded"); + } + } + } + } + + private function loadSabreCollectionsFromInfoXml(array $collections) { + foreach ($collections as $collection) { + try { + $this->collections[] = $this->container->query($collection); + } catch (QueryException $e) { + if (class_exists($collection)) { + $this->collections[] = new $collection(); + } else { + throw new \Exception("Sabre collection class '$collection' is unknown and could not be loaded"); + } + } + } + } + +} diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index 6f3ab3971ef..719e4974755 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -55,8 +55,8 @@ use OCP\SabrePluginEvent; use Sabre\CardDAV\VCFExportPlugin; use Sabre\DAV\Auth\Plugin; use OCA\DAV\Connector\Sabre\TagsPlugin; -use Sabre\HTTP\Auth\Bearer; use SearchDAV\DAV\SearchPlugin; +use OCA\DAV\AppInfo\PluginManager; class Server { @@ -76,6 +76,7 @@ class Server { $mailer = \OC::$server->getMailer(); $dispatcher = \OC::$server->getEventDispatcher(); $timezone = new TimeFactory(); + $sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes'; $root = new RootCollection(); $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); @@ -137,7 +138,9 @@ class Server { $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); - $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); + if ($sendInvitations) { + $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); + } $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); @@ -184,7 +187,7 @@ class Server { } // wait with registering these until auth is handled and the filesystem is setup - $this->server->on('beforeMethod', function () { + $this->server->on('beforeMethod', function () use ($root) { // custom properties plugin must be the last one $userSession = \OC::$server->getUserSession(); $user = $userSession->getUser(); @@ -252,6 +255,18 @@ class Server { ))); } } + + // register plugins from apps + $pluginManager = new PluginManager( + \OC::$server, + \OC::$server->getAppManager() + ); + foreach ($pluginManager->getAppPlugins() as $appPlugin) { + $this->server->addPlugin($appPlugin); + } + foreach ($pluginManager->getAppCollections() as $appCollection) { + $root->addChild($appCollection); + } }); } diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php new file mode 100644 index 00000000000..1c85d19432c --- /dev/null +++ b/apps/dav/lib/Settings/CalDAVSettings.php @@ -0,0 +1,68 @@ +<?php +/** + * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com> + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @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 OCA\DAV\Settings; + +use OCP\AppFramework\Http\TemplateResponse; +use OCP\IConfig; +use OCP\Settings\ISettings; + +class CalDAVSettings implements ISettings { + + /** @var IConfig */ + private $config; + + /** + * CalDAVSettings constructor. + * + * @param IConfig $config + */ + public function __construct(IConfig $config) { + $this->config = $config; + } + + /** + * @return TemplateResponse + */ + public function getForm() { + $parameters = [ + 'send_invitations' => $this->config->getAppValue('dav', 'sendInvitations', 'yes'), + ]; + + return new TemplateResponse('dav', 'settings-admin-caldav', $parameters); + } + + /** + * @return string + */ + public function getSection() { + return 'additional'; + } + + /** + * @return int + */ + public function getPriority() { + return 20; + } +} diff --git a/apps/dav/templates/settings-admin-caldav.php b/apps/dav/templates/settings-admin-caldav.php new file mode 100644 index 00000000000..34d3517e8d9 --- /dev/null +++ b/apps/dav/templates/settings-admin-caldav.php @@ -0,0 +1,40 @@ +<?php +/** + * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com> + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @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/>. + * + */ + +script('dav', [ + 'settings-admin-caldav' +]); + +/** @var \OCP\IL10N $l */ +/** @var array $_ */ +?> +<form id="CalDAV" class="section"> + <h2><?php p($l->t('CalDAV server')); ?></h2> + <p> + <input type="checkbox" name="caldav_send_invitations" id="caldavSendInvitations" class="checkbox" + <?php ($_['send_invitations'] === 'yes') ? print_unescaped('checked="checked"') : null ?>/> + <label for="caldavSendInvitations"><?php p($l->t('Send invitations to attendees')); ?></label> + <br> + <em><?php p($l->t('Please make sure to properly setup the email settings above.')); ?></em> + </p> +</form> diff --git a/apps/dav/tests/unit/AppInfo/PluginManagerTest.php b/apps/dav/tests/unit/AppInfo/PluginManagerTest.php new file mode 100644 index 00000000000..5776b939123 --- /dev/null +++ b/apps/dav/tests/unit/AppInfo/PluginManagerTest.php @@ -0,0 +1,104 @@ +<?php +/** + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud GmbH. + * @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/> + * + */ + +namespace OCA\DAV\Tests\unit\AppInfo; + +use Test\TestCase; +use OCP\App\IAppManager; +use OC\ServerContainer; +use OCA\DAV\AppInfo\PluginManager; + +/** + * Class PluginManagerTest + * + * @package OCA\DAV\Tests\Unit\AppInfo + */ +class PluginManagerTest extends TestCase { + public function test() { + $server = $this->createMock(ServerContainer::class); + + + $appManager = $this->createMock(IAppManager::class); + $appManager->method('getInstalledApps') + ->willReturn(['adavapp', 'adavapp2']); + + $appInfo1 = [ + 'types' => ['dav'], + 'sabre' => [ + 'plugins' => [ + 'plugin' => [ + '\OCA\DAV\ADavApp\PluginOne', + '\OCA\DAV\ADavApp\PluginTwo', + ], + ], + 'collections' => [ + 'collection' => [ + '\OCA\DAV\ADavApp\CollectionOne', + '\OCA\DAV\ADavApp\CollectionTwo', + ] + ], + ], + ]; + $appInfo2 = [ + 'types' => ['logging', 'dav'], + 'sabre' => [ + 'plugins' => [ + 'plugin' => '\OCA\DAV\ADavApp2\PluginOne', + ], + 'collections' => [ + 'collection' => '\OCA\DAV\ADavApp2\CollectionOne', + ], + ], + ]; + + $appManager->method('getAppInfo') + ->will($this->returnValueMap([ + ['adavapp', $appInfo1], + ['adavapp2', $appInfo2], + ])); + + $pluginManager = new PluginManager($server, $appManager); + + $server->method('query') + ->will($this->returnValueMap([ + ['\OCA\DAV\ADavApp\PluginOne', 'dummyplugin1'], + ['\OCA\DAV\ADavApp\PluginTwo', 'dummyplugin2'], + ['\OCA\DAV\ADavApp\CollectionOne', 'dummycollection1'], + ['\OCA\DAV\ADavApp\CollectionTwo', 'dummycollection2'], + ['\OCA\DAV\ADavApp2\PluginOne', 'dummy2plugin1'], + ['\OCA\DAV\ADavApp2\CollectionOne', 'dummy2collection1'], + ])); + + $expectedPlugins = [ + 'dummyplugin1', + 'dummyplugin2', + 'dummy2plugin1', + ]; + $expectedCollections = [ + 'dummycollection1', + 'dummycollection2', + 'dummy2collection1', + ]; + + $this->assertEquals($expectedPlugins, $pluginManager->getAppPlugins()); + $this->assertEquals($expectedCollections, $pluginManager->getAppCollections()); + } +} diff --git a/apps/dav/tests/unit/ServerTest.php b/apps/dav/tests/unit/ServerTest.php index 19e75c7b24e..1b430b0f198 100644 --- a/apps/dav/tests/unit/ServerTest.php +++ b/apps/dav/tests/unit/ServerTest.php @@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit; use OCA\DAV\Server; use OCP\IRequest; +use OCA\DAV\AppInfo\PluginManager; /** * Class ServerTest @@ -38,8 +39,7 @@ class ServerTest extends \Test\TestCase { public function test() { /** @var IRequest $r */ - $r = $this->getMockBuilder('\OCP\IRequest') - ->disableOriginalConstructor()->getMock(); + $r = $this->createMock(IRequest::class); $s = new Server($r, '/'); $this->assertInstanceOf('OCA\DAV\Server', $s); } diff --git a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php new file mode 100644 index 00000000000..8ee58107487 --- /dev/null +++ b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php @@ -0,0 +1,58 @@ +<?php +/** + * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com> + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @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 OCA\DAV\Tests\Unit\DAV\Settings; + +use OCA\DAV\Settings\CalDAVSettings; +use OCP\IConfig; +use Test\TestCase; + +class CalDAVSettingsTest extends TestCase { + + /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ + private $config; + + /** @var CalDAVSettings */ + private $settings; + + public function setUp() { + parent::setUp(); + + $this->config = $this->createMock(IConfig::class); + $this->settings = new CalDAVSettings($this->config); + } + + public function testGetForm() { + $result = $this->settings->getForm(); + + $this->assertInstanceOf('OCP\AppFramework\Http\TemplateResponse', $result); + } + + public function testGetSection() { + $this->assertEquals('additional', $this->settings->getSection()); + } + + public function testGetPriority() { + $this->assertEquals(20, $this->settings->getPriority()); + } +} diff --git a/apps/files_sharing/composer/autoload.php b/apps/files_sharing/composer/autoload.php new file mode 100644 index 00000000000..3b046bff7f4 --- /dev/null +++ b/apps/files_sharing/composer/autoload.php @@ -0,0 +1,7 @@ +<?php + +// autoload.php @generated by Composer + +require_once __DIR__ . '/composer/autoload_real.php'; + +return ComposerAutoloaderInitf32f03f7cd82bff20d6a51be16689441::getLoader(); diff --git a/apps/files_sharing/composer/composer.json b/apps/files_sharing/composer/composer.json new file mode 100644 index 00000000000..4d2aae1d6e1 --- /dev/null +++ b/apps/files_sharing/composer/composer.json @@ -0,0 +1,12 @@ +{ + "config" : { + "vendor-dir": ".", + "optimize-autoloader": true, + "authorative-autoloader": true + }, + "autoload" : { + "psr-4": { + "OCA\\Files_Sharing\\": "../lib/" + } + } +} diff --git a/apps/files_sharing/composer/composer/ClassLoader.php b/apps/files_sharing/composer/composer/ClassLoader.php new file mode 100644 index 00000000000..2c72175e772 --- /dev/null +++ b/apps/files_sharing/composer/composer/ClassLoader.php @@ -0,0 +1,445 @@ +<?php + +/* + * This file is part of Composer. + * + * (c) Nils Adermann <naderman@naderman.de> + * Jordi Boggiano <j.boggiano@seld.be> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier <fabien@symfony.com> + * @author Jordi Boggiano <j.boggiano@seld.be> + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $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; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/apps/files_sharing/composer/composer/LICENSE b/apps/files_sharing/composer/composer/LICENSE new file mode 100644 index 00000000000..f27399a042d --- /dev/null +++ b/apps/files_sharing/composer/composer/LICENSE @@ -0,0 +1,21 @@ + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php new file mode 100644 index 00000000000..48b9651a00d --- /dev/null +++ b/apps/files_sharing/composer/composer/autoload_classmap.php @@ -0,0 +1,56 @@ +<?php + +// autoload_classmap.php @generated by Composer + +$vendorDir = dirname(dirname(__FILE__)); +$baseDir = $vendorDir; + +return array( + 'OCA\\Files_Sharing\\Activity\\Filter' => $baseDir . '/../lib/Activity/Filter.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => $baseDir . '/../lib/Activity/Providers/Base.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => $baseDir . '/../lib/Activity/Providers/Downloads.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => $baseDir . '/../lib/Activity/Providers/Groups.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => $baseDir . '/../lib/Activity/Providers/PublicLinks.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => $baseDir . '/../lib/Activity/Providers/RemoteShares.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => $baseDir . '/../lib/Activity/Providers/Users.php', + 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => $baseDir . '/../lib/Activity/Settings/PublicLinks.php', + 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir . '/../lib/Activity/Settings/RemoteShare.php', + 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir . '/../lib/Activity/Settings/Shared.php', + 'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', + 'OCA\\Files_Sharing\\Cache' => $baseDir . '/../lib/Cache.php', + 'OCA\\Files_Sharing\\Capabilities' => $baseDir . '/../lib/Capabilities.php', + 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir . '/../lib/Command/CleanupRemoteStorages.php', + 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir . '/../lib/Controller/ExternalSharesController.php', + 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir . '/../lib/Controller/PublicPreviewController.php', + 'OCA\\Files_Sharing\\Controller\\RemoteController' => $baseDir . '/../lib/Controller/RemoteController.php', + 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => $baseDir . '/../lib/Controller/ShareAPIController.php', + 'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir . '/../lib/Controller/ShareController.php', + 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir . '/../lib/Controller/ShareInfoController.php', + 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir . '/../lib/Controller/ShareesAPIController.php', + 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir . '/../lib/DeleteOrphanedSharesJob.php', + 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => $baseDir . '/../lib/Exceptions/BrokenPath.php', + 'OCA\\Files_Sharing\\Exceptions\\S2SException' => $baseDir . '/../lib/Exceptions/S2SException.php', + 'OCA\\Files_Sharing\\ExpireSharesJob' => $baseDir . '/../lib/ExpireSharesJob.php', + 'OCA\\Files_Sharing\\External\\Cache' => $baseDir . '/../lib/External/Cache.php', + 'OCA\\Files_Sharing\\External\\Manager' => $baseDir . '/../lib/External/Manager.php', + 'OCA\\Files_Sharing\\External\\Mount' => $baseDir . '/../lib/External/Mount.php', + 'OCA\\Files_Sharing\\External\\MountProvider' => $baseDir . '/../lib/External/MountProvider.php', + 'OCA\\Files_Sharing\\External\\Scanner' => $baseDir . '/../lib/External/Scanner.php', + 'OCA\\Files_Sharing\\External\\Storage' => $baseDir . '/../lib/External/Storage.php', + 'OCA\\Files_Sharing\\External\\Watcher' => $baseDir . '/../lib/External/Watcher.php', + 'OCA\\Files_Sharing\\Helper' => $baseDir . '/../lib/Helper.php', + 'OCA\\Files_Sharing\\Hooks' => $baseDir . '/../lib/Hooks.php', + 'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php', + 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir . '/../lib/Middleware/OCSShareAPIMiddleware.php', + 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir . '/../lib/Middleware/ShareInfoMiddleware.php', + 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => $baseDir . '/../lib/Middleware/SharingCheckMiddleware.php', + 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir . '/../lib/Migration/OwncloudGuestShareType.php', + 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php', + 'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php', + 'OCA\\Files_Sharing\\Scanner' => $baseDir . '/../lib/Scanner.php', + 'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir . '/../lib/ShareBackend/File.php', + 'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir . '/../lib/ShareBackend/Folder.php', + 'OCA\\Files_Sharing\\SharedMount' => $baseDir . '/../lib/SharedMount.php', + 'OCA\\Files_Sharing\\SharedStorage' => $baseDir . '/../lib/SharedStorage.php', + 'OCA\\Files_Sharing\\Updater' => $baseDir . '/../lib/Updater.php', +); diff --git a/apps/files_sharing/composer/composer/autoload_namespaces.php b/apps/files_sharing/composer/composer/autoload_namespaces.php new file mode 100644 index 00000000000..71c9e91858d --- /dev/null +++ b/apps/files_sharing/composer/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ +<?php + +// autoload_namespaces.php @generated by Composer + +$vendorDir = dirname(dirname(__FILE__)); +$baseDir = $vendorDir; + +return array( +); diff --git a/apps/files_sharing/composer/composer/autoload_psr4.php b/apps/files_sharing/composer/composer/autoload_psr4.php new file mode 100644 index 00000000000..9fb758e4059 --- /dev/null +++ b/apps/files_sharing/composer/composer/autoload_psr4.php @@ -0,0 +1,10 @@ +<?php + +// autoload_psr4.php @generated by Composer + +$vendorDir = dirname(dirname(__FILE__)); +$baseDir = $vendorDir; + +return array( + 'OCA\\Files_Sharing\\' => array($baseDir . '/../lib'), +); diff --git a/apps/files_sharing/composer/composer/autoload_real.php b/apps/files_sharing/composer/composer/autoload_real.php new file mode 100644 index 00000000000..fc2e3dcfcb0 --- /dev/null +++ b/apps/files_sharing/composer/composer/autoload_real.php @@ -0,0 +1,52 @@ +<?php + +// autoload_real.php @generated by Composer + +class ComposerAutoloaderInitf32f03f7cd82bff20d6a51be16689441 +{ + private static $loader; + + public static function loadClassLoader($class) + { + if ('Composer\Autoload\ClassLoader' === $class) { + require __DIR__ . '/ClassLoader.php'; + } + } + + public static function getLoader() + { + if (null !== self::$loader) { + return self::$loader; + } + + spl_autoload_register(array('ComposerAutoloaderInitf32f03f7cd82bff20d6a51be16689441', 'loadClassLoader'), true, true); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + spl_autoload_unregister(array('ComposerAutoloaderInitf32f03f7cd82bff20d6a51be16689441', 'loadClassLoader')); + + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php new file mode 100644 index 00000000000..caabc5d50a3 --- /dev/null +++ b/apps/files_sharing/composer/composer/autoload_static.php @@ -0,0 +1,82 @@ +<?php + +// autoload_static.php @generated by Composer + +namespace Composer\Autoload; + +class ComposerStaticInitf32f03f7cd82bff20d6a51be16689441 +{ + public static $prefixLengthsPsr4 = array ( + 'O' => + array ( + 'OCA\\Files_Sharing\\' => 18, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'OCA\\Files_Sharing\\' => + array ( + 0 => __DIR__ . '/..' . '/../lib', + ), + ); + + public static $classMap = array ( + 'OCA\\Files_Sharing\\Activity\\Filter' => __DIR__ . '/..' . '/../lib/Activity/Filter.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Base' => __DIR__ . '/..' . '/../lib/Activity/Providers/Base.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Downloads' => __DIR__ . '/..' . '/../lib/Activity/Providers/Downloads.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Groups' => __DIR__ . '/..' . '/../lib/Activity/Providers/Groups.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Providers/PublicLinks.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\RemoteShares' => __DIR__ . '/..' . '/../lib/Activity/Providers/RemoteShares.php', + 'OCA\\Files_Sharing\\Activity\\Providers\\Users' => __DIR__ . '/..' . '/../lib/Activity/Providers/Users.php', + 'OCA\\Files_Sharing\\Activity\\Settings\\PublicLinks' => __DIR__ . '/..' . '/../lib/Activity/Settings/PublicLinks.php', + 'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__ . '/..' . '/../lib/Activity/Settings/RemoteShare.php', + 'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__ . '/..' . '/../lib/Activity/Settings/Shared.php', + 'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', + 'OCA\\Files_Sharing\\Cache' => __DIR__ . '/..' . '/../lib/Cache.php', + 'OCA\\Files_Sharing\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php', + 'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__ . '/..' . '/../lib/Command/CleanupRemoteStorages.php', + 'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__ . '/..' . '/../lib/Controller/ExternalSharesController.php', + 'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__ . '/..' . '/../lib/Controller/PublicPreviewController.php', + 'OCA\\Files_Sharing\\Controller\\RemoteController' => __DIR__ . '/..' . '/../lib/Controller/RemoteController.php', + 'OCA\\Files_Sharing\\Controller\\ShareAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareAPIController.php', + 'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__ . '/..' . '/../lib/Controller/ShareController.php', + 'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__ . '/..' . '/../lib/Controller/ShareInfoController.php', + 'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareesAPIController.php', + 'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__ . '/..' . '/../lib/DeleteOrphanedSharesJob.php', + 'OCA\\Files_Sharing\\Exceptions\\BrokenPath' => __DIR__ . '/..' . '/../lib/Exceptions/BrokenPath.php', + 'OCA\\Files_Sharing\\Exceptions\\S2SException' => __DIR__ . '/..' . '/../lib/Exceptions/S2SException.php', + 'OCA\\Files_Sharing\\ExpireSharesJob' => __DIR__ . '/..' . '/../lib/ExpireSharesJob.php', + 'OCA\\Files_Sharing\\External\\Cache' => __DIR__ . '/..' . '/../lib/External/Cache.php', + 'OCA\\Files_Sharing\\External\\Manager' => __DIR__ . '/..' . '/../lib/External/Manager.php', + 'OCA\\Files_Sharing\\External\\Mount' => __DIR__ . '/..' . '/../lib/External/Mount.php', + 'OCA\\Files_Sharing\\External\\MountProvider' => __DIR__ . '/..' . '/../lib/External/MountProvider.php', + 'OCA\\Files_Sharing\\External\\Scanner' => __DIR__ . '/..' . '/../lib/External/Scanner.php', + 'OCA\\Files_Sharing\\External\\Storage' => __DIR__ . '/..' . '/../lib/External/Storage.php', + 'OCA\\Files_Sharing\\External\\Watcher' => __DIR__ . '/..' . '/../lib/External/Watcher.php', + 'OCA\\Files_Sharing\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', + 'OCA\\Files_Sharing\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', + 'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php', + 'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/OCSShareAPIMiddleware.php', + 'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ShareInfoMiddleware.php', + 'OCA\\Files_Sharing\\Middleware\\SharingCheckMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SharingCheckMiddleware.php', + 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__ . '/..' . '/../lib/Migration/OwncloudGuestShareType.php', + 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php', + 'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php', + 'OCA\\Files_Sharing\\Scanner' => __DIR__ . '/..' . '/../lib/Scanner.php', + 'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__ . '/..' . '/../lib/ShareBackend/File.php', + 'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__ . '/..' . '/../lib/ShareBackend/Folder.php', + 'OCA\\Files_Sharing\\SharedMount' => __DIR__ . '/..' . '/../lib/SharedMount.php', + 'OCA\\Files_Sharing\\SharedStorage' => __DIR__ . '/..' . '/../lib/SharedStorage.php', + 'OCA\\Files_Sharing\\Updater' => __DIR__ . '/..' . '/../lib/Updater.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitf32f03f7cd82bff20d6a51be16689441::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 440f5d2444e..3350dd6a5cd 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -436,8 +436,8 @@ class Connection extends LDAPUtility { || ($agent !== '' && $pwd === '') ) { \OCP\Util::writeLog('user_ldap', - $errorStr.'either no password is given for the'. - 'user agent or a password is given, but not an'. + $errorStr.'either no password is given for the '. + 'user agent or a password is given, but not an '. 'LDAP agent.', \OCP\Util::WARN); $configurationOK = false; diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 5017f35ed0a..a46b0053b40 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -529,7 +529,6 @@ class User { $targetUser->setQuota($quota); } else { $this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', \OCP\Util::WARN); - $targetUser->setQuota('default'); } } else { $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', \OCP\Util::ERROR); diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index 637842d9ac7..5f6148b1332 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -453,9 +453,8 @@ class UserTest extends \Test\TestCase { ->will($this->returnValue(false)); $user = $this->createMock('\OCP\IUser'); - $user->expects($this->once()) - ->method('setQuota') - ->with('default'); + $user->expects($this->never()) + ->method('setQuota'); $userMgr->expects($this->once()) ->method('get') @@ -495,9 +494,8 @@ class UserTest extends \Test\TestCase { ->method('__get'); $user = $this->createMock('\OCP\IUser'); - $user->expects($this->once()) - ->method('setQuota') - ->with('default'); + $user->expects($this->never()) + ->method('setQuota'); $userMgr->expects($this->once()) ->method('get') @@ -633,9 +631,8 @@ class UserTest extends \Test\TestCase { ->will($this->returnValue(false)); $user = $this->createMock('\OCP\IUser'); - $user->expects($this->once()) - ->method('setQuota') - ->with('default'); + $user->expects($this->never()) + ->method('setQuota'); $userMgr->expects($this->once()) ->method('get') @@ -681,9 +678,8 @@ class UserTest extends \Test\TestCase { ->will($this->returnValue(array('23 flush'))); $user = $this->createMock('\OCP\IUser'); - $user->expects($this->once()) - ->method('setQuota') - ->with('default'); + $user->expects($this->never()) + ->method('setQuota'); $userMgr->expects($this->once()) ->method('get') @@ -726,9 +722,8 @@ class UserTest extends \Test\TestCase { ->method('readAttribute'); $user = $this->createMock('\OCP\IUser'); - $user->expects($this->once()) - ->method('setQuota') - ->with('default'); + $user->expects($this->never()) + ->method('setQuota'); $userMgr->expects($this->once()) ->method('get') diff --git a/build/.phan/config.php b/build/.phan/config.php index 26421529433..cdf41630766 100644 --- a/build/.phan/config.php +++ b/build/.phan/config.php @@ -52,6 +52,7 @@ return [ 'apps/files/tests', 'apps/files_external/3rdparty', 'apps/files_external/tests', + 'apps/files_sharing/composer', 'apps/files_sharing/tests', 'apps/files_trashbin/tests', 'apps/files_versions/tests', diff --git a/build/autoloaderchecker.sh b/build/autoloaderchecker.sh index 9b1c30d59cb..ffa157f6c80 100644 --- a/build/autoloaderchecker.sh +++ b/build/autoloaderchecker.sh @@ -24,16 +24,26 @@ $COMPOSER_COMMAND self-update REPODIR=`git rev-parse --show-toplevel` -#Redump the autoloader +#Redump the main autoloader echo -echo "Regenerating autoloader" +echo "Regenerating main autoloader" $COMPOSER_COMMAND dump-autoload -d $REPODIR +for app in ${REPODIR}/apps/*; do + if [[ -d $app ]]; then + if [[ -e ${app}/composer/composer.json ]]; then + echo + echo "Regenerating autoloader for ${app}" + $COMPOSER_COMMAND dump-autoload -d ${app}/composer + fi + fi +done + files=`git diff --name-only` composerfile=false for file in $files do - if [[ $file == lib/composer/* ]] + if [[ $file == *autoload_classmap* ]] then composerfile=true break @@ -43,10 +53,9 @@ done echo if [ $composerfile = true ] then - echo "The autoloader is not up to date" + echo "The autoloaders are not up to date" echo "Please run: bash build/autoloaderchecker.sh" echo "And commit the result" - git diff lib/composer exit 1 else echo "Autoloader up to date. Carry on" diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php new file mode 100644 index 00000000000..75d3a48a5c8 --- /dev/null +++ b/core/Command/Db/ConvertFilecacheBigInt.php @@ -0,0 +1,107 @@ +<?php +/** + * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @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\Core\Command\Db; + +use Doctrine\DBAL\Types\Type; +use OC\DB\SchemaWrapper; +use OCP\IDBConnection; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ConfirmationQuestion; + +class ConvertFilecacheBigInt extends Command { + + /** @var IDBConnection */ + private $connection; + + /** + * @param IDBConnection $connection + */ + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + parent::__construct(); + } + + protected function configure() { + $this + ->setName('db:convert-filecache-bigint') + ->setDescription('Convert the ID columns of the filecache to BigInt'); + } + + protected function getColumnsByTable() { + return [ + 'activity' => ['activity_id', 'object_id'], + 'activity_mq' => ['mail_id'], + 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart'], + 'mimetypes' => ['id'], + 'storages' => ['numeric_id'], + ]; + } + + protected function execute(InputInterface $input, OutputInterface $output) { + + $schema = new SchemaWrapper($this->connection); + $updates = []; + + $tables = $this->getColumnsByTable(); + foreach ($tables as $tableName => $columns) { + if (!$schema->hasTable($tableName)) { + continue; + } + + $table = $schema->getTable($tableName); + + foreach ($columns as $columnName) { + $column = $table->getColumn($columnName); + if ($column->getType()->getName() !== Type::BIGINT) { + $column->setType(Type::getType(Type::BIGINT)); + $column->setOptions(['length' => 20]); + + $updates[] = $tableName . '.' . $columnName; + } + } + } + + if (empty($updates)) { + $output->writeln('<info>All tables already up to date!</info>'); + return 0; + } + + $output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>'); + + if ($input->isInteractive()) { + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false); + + if (!$helper->ask($input, $output, $question)) { + return 1; + } + } + + $this->connection->migrateToSchema($schema->getWrappedSchema()); + + return 0; + } +} diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index d8d66696a14..0ab777f6de2 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -24,6 +24,7 @@ namespace OC\Core\Migrations; use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Types\Type; use OCP\Migration\SimpleMigrationStep; use OCP\Migration\IOutput; @@ -66,10 +67,10 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { 'notnull' => false, 'length' => 64, ]); - $table->addColumn('numeric_id', 'integer', [ + $table->addColumn('numeric_id', Type::BIGINT, [ 'autoincrement' => true, 'notnull' => true, - 'length' => 4, + 'length' => 20, ]); $table->addColumn('available', 'integer', [ 'notnull' => true, @@ -116,10 +117,10 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { if (!$schema->hasTable('mimetypes')) { $table = $schema->createTable('mimetypes'); - $table->addColumn('id', 'integer', [ + $table->addColumn('id', Type::BIGINT, [ 'autoincrement' => true, 'notnull' => true, - 'length' => 4, + 'length' => 20, ]); $table->addColumn('mimetype', 'string', [ 'notnull' => true, @@ -132,14 +133,14 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { if (!$schema->hasTable('filecache')) { $table = $schema->createTable('filecache'); - $table->addColumn('fileid', 'integer', [ + $table->addColumn('fileid', Type::BIGINT, [ 'autoincrement' => true, 'notnull' => true, - 'length' => 4, + 'length' => 20, ]); - $table->addColumn('storage', 'integer', [ + $table->addColumn('storage', Type::BIGINT, [ 'notnull' => true, - 'length' => 4, + 'length' => 20, 'default' => 0, ]); $table->addColumn('path', 'string', [ @@ -151,23 +152,23 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { 'length' => 32, 'default' => '', ]); - $table->addColumn('parent', 'integer', [ + $table->addColumn('parent', Type::BIGINT, [ 'notnull' => true, - 'length' => 4, + 'length' => 20, 'default' => 0, ]); $table->addColumn('name', 'string', [ 'notnull' => false, 'length' => 250, ]); - $table->addColumn('mimetype', 'integer', [ + $table->addColumn('mimetype', Type::BIGINT, [ 'notnull' => true, - 'length' => 4, + 'length' => 20, 'default' => 0, ]); - $table->addColumn('mimepart', 'integer', [ + $table->addColumn('mimepart', Type::BIGINT, [ 'notnull' => true, - 'length' => 4, + 'length' => 20, 'default' => 0, ]); $table->addColumn('size', 'bigint', [ diff --git a/core/Migrations/Version13000Date20170926101637.php b/core/Migrations/Version13000Date20170926101637.php index 3eea8a8a3b9..ded34cedd39 100644 --- a/core/Migrations/Version13000Date20170926101637.php +++ b/core/Migrations/Version13000Date20170926101637.php @@ -22,15 +22,15 @@ class Version13000Date20170926101637 extends BigIntMigration { 'authtoken' => ['id'], 'bruteforce_attempts' => ['id'], 'comments' => ['id', 'parent_id', 'topmost_parent_id'], - 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart'], + // Disabled for now 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart'], 'file_locks' => ['id'], 'jobs' => ['id'], - 'mimetypes' => ['id'], + // Disabled for now 'mimetypes' => ['id'], 'mounts' => ['id'], 'personal_settings' => ['id'], 'properties' => ['id'], 'share' => ['id', 'parent', 'file_source'], - 'storages' => ['numeric_id'], + // Disabled for now 'storages' => ['numeric_id'], 'systemtag' => ['id'], 'systemtag_group' => ['systemtagid'], 'systemtag_object_mapping' => ['systemtagid'], diff --git a/core/register_command.php b/core/register_command.php index 02bdbedc6e0..3cba0565993 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -85,6 +85,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) { $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig()))); $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger())); + $application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection())); $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection())); $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection())); $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection())); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 489b9b3dc14..07f815f85ce 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -440,6 +440,7 @@ return array( 'OC\\Core\\Command\\Config\\System\\DeleteConfig' => $baseDir . '/core/Command/Config/System/DeleteConfig.php', 'OC\\Core\\Command\\Config\\System\\GetConfig' => $baseDir . '/core/Command/Config/System/GetConfig.php', 'OC\\Core\\Command\\Config\\System\\SetConfig' => $baseDir . '/core/Command/Config/System/SetConfig.php', + 'OC\\Core\\Command\\Db\\ConvertFilecacheBigInt' => $baseDir . '/core/Command/Db/ConvertFilecacheBigInt.php', 'OC\\Core\\Command\\Db\\ConvertMysqlToMB4' => $baseDir . '/core/Command/Db/ConvertMysqlToMB4.php', 'OC\\Core\\Command\\Db\\ConvertType' => $baseDir . '/core/Command/Db/ConvertType.php', 'OC\\Core\\Command\\Db\\Migrations\\ExecuteCommand' => $baseDir . '/core/Command/Db/Migrations/ExecuteCommand.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 1297f4606f6..0d327b7267f 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -470,6 +470,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Command\\Config\\System\\DeleteConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/DeleteConfig.php', 'OC\\Core\\Command\\Config\\System\\GetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/GetConfig.php', 'OC\\Core\\Command\\Config\\System\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/SetConfig.php', + 'OC\\Core\\Command\\Db\\ConvertFilecacheBigInt' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertFilecacheBigInt.php', 'OC\\Core\\Command\\Db\\ConvertMysqlToMB4' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertMysqlToMB4.php', 'OC\\Core\\Command\\Db\\ConvertType' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertType.php', 'OC\\Core\\Command\\Db\\Migrations\\ExecuteCommand' => __DIR__ . '/../../..' . '/core/Command/Db/Migrations/ExecuteCommand.php', diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 627107a63a8..bd261b05e51 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -200,17 +200,25 @@ class OC_App { if(isset(self::$alreadyRegistered[$key])) { return; } + self::$alreadyRegistered[$key] = true; + // Register on PSR-4 composer autoloader $appNamespace = \OC\AppFramework\App::buildAppNamespace($app); \OC::$server->registerNamespace($app, $appNamespace); - \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); + + if (file_exists($path . '/composer/autoload.php')) { + require_once $path . '/composer/autoload.php'; + } else { + \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); + // Register on legacy autoloader + \OC::$loader->addValidRoot($path); + } + + // Register Test namespace only when testing if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); } - - // Register on legacy autoloader - \OC::$loader->addValidRoot($path); } /** |