From d666725fa783c21235eec79fa6dbe8ba1881fec3 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 19 May 2016 08:00:09 +0200 Subject: Move \OCP to PSR-4 --- lib/base.php | 2 +- lib/public/API.php | 75 +++ lib/public/App.php | 153 ++++++ lib/public/AutoloadNotAllowedException.php | 37 ++ lib/public/BackgroundJob.php | 184 ++++++++ lib/public/Config.php | 163 +++++++ lib/public/Constants.php | 76 +++ lib/public/Contacts.php | 184 ++++++++ lib/public/DB.php | 145 ++++++ lib/public/Defaults.php | 173 +++++++ lib/public/Files.php | 134 ++++++ lib/public/GroupInterface.php | 106 +++++ lib/public/IAddressBook.php | 93 ++++ lib/public/IAppConfig.php | 120 +++++ lib/public/IAvatar.php | 79 ++++ lib/public/IAvatarManager.php | 45 ++ lib/public/ICache.php | 82 ++++ lib/public/ICacheFactory.php | 50 ++ lib/public/ICertificate.php | 79 ++++ lib/public/ICertificateManager.php | 71 +++ lib/public/IConfig.php | 225 +++++++++ lib/public/IContainer.php | 102 ++++ lib/public/IDBConnection.php | 234 ++++++++++ lib/public/IDateTimeFormatter.php | 144 ++++++ lib/public/IDateTimeZone.php | 38 ++ lib/public/IDb.php | 53 +++ lib/public/IEventSource.php | 51 ++ lib/public/IGroup.php | 109 +++++ lib/public/IGroupManager.php | 139 ++++++ lib/public/IHelper.php | 49 ++ lib/public/IImage.php | 185 ++++++++ lib/public/IL10N.php | 110 +++++ lib/public/ILogger.php | 144 ++++++ lib/public/IMemcache.php | 90 ++++ lib/public/IMemcacheTTL.php | 39 ++ lib/public/INavigationManager.php | 59 +++ lib/public/IPreview.php | 95 ++++ lib/public/IRequest.php | 245 ++++++++++ lib/public/ISearch.php | 77 +++ lib/public/ISession.php | 107 +++++ lib/public/ITagManager.php | 61 +++ lib/public/ITags.php | 227 +++++++++ lib/public/ITempManager.php | 70 +++ lib/public/IURLGenerator.php | 93 ++++ lib/public/IUser.php | 202 ++++++++ lib/public/IUserBackend.php | 47 ++ lib/public/IUserManager.php | 152 ++++++ lib/public/IUserSession.php | 82 ++++ lib/public/Image.php | 39 ++ lib/public/JSON.php | 196 ++++++++ lib/public/PreConditionNotMetException.php | 30 ++ lib/public/Response.php | 134 ++++++ lib/public/SabrePluginEvent.php | 96 ++++ lib/public/SabrePluginException.php | 41 ++ lib/public/Share.php | 401 ++++++++++++++++ lib/public/Share_Backend.php | 96 ++++ lib/public/Share_Backend_Collection.php | 40 ++ lib/public/Share_Backend_File_Dependent.php | 42 ++ lib/public/User.php | 155 +++++++ lib/public/UserInterface.php | 106 +++++ lib/public/Util.php | 697 ++++++++++++++++++++++++++++ lib/public/api.php | 75 --- lib/public/app.php | 153 ------ lib/public/autoloadnotallowedexception.php | 37 -- lib/public/backgroundjob.php | 184 -------- lib/public/config.php | 163 ------- lib/public/constants.php | 76 --- lib/public/contacts.php | 184 -------- lib/public/db.php | 145 ------ lib/public/defaults.php | 173 ------- lib/public/files.php | 134 ------ lib/public/groupinterface.php | 106 ----- lib/public/iaddressbook.php | 93 ---- lib/public/iappconfig.php | 120 ----- lib/public/iavatar.php | 79 ---- lib/public/iavatarmanager.php | 45 -- lib/public/icache.php | 82 ---- lib/public/icachefactory.php | 50 -- lib/public/icertificate.php | 79 ---- lib/public/icertificatemanager.php | 71 --- lib/public/iconfig.php | 225 --------- lib/public/icontainer.php | 102 ---- lib/public/idatetimeformatter.php | 144 ------ lib/public/idatetimezone.php | 38 -- lib/public/idb.php | 53 --- lib/public/idbconnection.php | 234 ---------- lib/public/ieventsource.php | 51 -- lib/public/igroup.php | 109 ----- lib/public/igroupmanager.php | 139 ------ lib/public/ihelper.php | 49 -- lib/public/iimage.php | 185 -------- lib/public/il10n.php | 110 ----- lib/public/ilogger.php | 144 ------ lib/public/image.php | 39 -- lib/public/imemcache.php | 90 ---- lib/public/imemcachettl.php | 39 -- lib/public/inavigationmanager.php | 59 --- lib/public/ipreview.php | 95 ---- lib/public/irequest.php | 245 ---------- lib/public/isearch.php | 77 --- lib/public/isession.php | 107 ----- lib/public/itagmanager.php | 61 --- lib/public/itags.php | 227 --------- lib/public/itempmanager.php | 70 --- lib/public/iurlgenerator.php | 93 ---- lib/public/iuser.php | 202 -------- lib/public/iuserbackend.php | 47 -- lib/public/iusermanager.php | 152 ------ lib/public/iusersession.php | 82 ---- lib/public/json.php | 196 -------- lib/public/preconditionnotmetexception.php | 30 -- lib/public/response.php | 134 ------ lib/public/sabrepluginevent.php | 96 ---- lib/public/sabrepluginexception.php | 41 -- lib/public/share.php | 401 ---------------- lib/public/share_backend.php | 96 ---- lib/public/share_backend_collection.php | 40 -- lib/public/share_backend_file_dependent.php | 42 -- lib/public/user.php | 155 ------- lib/public/userinterface.php | 106 ----- lib/public/util.php | 697 ---------------------------- 121 files changed, 7352 insertions(+), 7352 deletions(-) create mode 100644 lib/public/API.php create mode 100644 lib/public/App.php create mode 100644 lib/public/AutoloadNotAllowedException.php create mode 100644 lib/public/BackgroundJob.php create mode 100644 lib/public/Config.php create mode 100644 lib/public/Constants.php create mode 100644 lib/public/Contacts.php create mode 100644 lib/public/DB.php create mode 100644 lib/public/Defaults.php create mode 100644 lib/public/Files.php create mode 100644 lib/public/GroupInterface.php create mode 100644 lib/public/IAddressBook.php create mode 100644 lib/public/IAppConfig.php create mode 100644 lib/public/IAvatar.php create mode 100644 lib/public/IAvatarManager.php create mode 100644 lib/public/ICache.php create mode 100644 lib/public/ICacheFactory.php create mode 100644 lib/public/ICertificate.php create mode 100644 lib/public/ICertificateManager.php create mode 100644 lib/public/IConfig.php create mode 100644 lib/public/IContainer.php create mode 100644 lib/public/IDBConnection.php create mode 100644 lib/public/IDateTimeFormatter.php create mode 100644 lib/public/IDateTimeZone.php create mode 100644 lib/public/IDb.php create mode 100644 lib/public/IEventSource.php create mode 100644 lib/public/IGroup.php create mode 100644 lib/public/IGroupManager.php create mode 100644 lib/public/IHelper.php create mode 100644 lib/public/IImage.php create mode 100644 lib/public/IL10N.php create mode 100644 lib/public/ILogger.php create mode 100644 lib/public/IMemcache.php create mode 100644 lib/public/IMemcacheTTL.php create mode 100644 lib/public/INavigationManager.php create mode 100644 lib/public/IPreview.php create mode 100644 lib/public/IRequest.php create mode 100644 lib/public/ISearch.php create mode 100644 lib/public/ISession.php create mode 100644 lib/public/ITagManager.php create mode 100644 lib/public/ITags.php create mode 100644 lib/public/ITempManager.php create mode 100644 lib/public/IURLGenerator.php create mode 100644 lib/public/IUser.php create mode 100644 lib/public/IUserBackend.php create mode 100644 lib/public/IUserManager.php create mode 100644 lib/public/IUserSession.php create mode 100644 lib/public/Image.php create mode 100644 lib/public/JSON.php create mode 100644 lib/public/PreConditionNotMetException.php create mode 100644 lib/public/Response.php create mode 100644 lib/public/SabrePluginEvent.php create mode 100644 lib/public/SabrePluginException.php create mode 100644 lib/public/Share.php create mode 100644 lib/public/Share_Backend.php create mode 100644 lib/public/Share_Backend_Collection.php create mode 100644 lib/public/Share_Backend_File_Dependent.php create mode 100644 lib/public/User.php create mode 100644 lib/public/UserInterface.php create mode 100644 lib/public/Util.php delete mode 100644 lib/public/api.php delete mode 100644 lib/public/app.php delete mode 100644 lib/public/autoloadnotallowedexception.php delete mode 100644 lib/public/backgroundjob.php delete mode 100644 lib/public/config.php delete mode 100644 lib/public/constants.php delete mode 100644 lib/public/contacts.php delete mode 100644 lib/public/db.php delete mode 100644 lib/public/defaults.php delete mode 100644 lib/public/files.php delete mode 100644 lib/public/groupinterface.php delete mode 100644 lib/public/iaddressbook.php delete mode 100644 lib/public/iappconfig.php delete mode 100644 lib/public/iavatar.php delete mode 100644 lib/public/iavatarmanager.php delete mode 100644 lib/public/icache.php delete mode 100644 lib/public/icachefactory.php delete mode 100644 lib/public/icertificate.php delete mode 100644 lib/public/icertificatemanager.php delete mode 100644 lib/public/iconfig.php delete mode 100644 lib/public/icontainer.php delete mode 100644 lib/public/idatetimeformatter.php delete mode 100644 lib/public/idatetimezone.php delete mode 100644 lib/public/idb.php delete mode 100644 lib/public/idbconnection.php delete mode 100644 lib/public/ieventsource.php delete mode 100644 lib/public/igroup.php delete mode 100644 lib/public/igroupmanager.php delete mode 100644 lib/public/ihelper.php delete mode 100644 lib/public/iimage.php delete mode 100644 lib/public/il10n.php delete mode 100644 lib/public/ilogger.php delete mode 100644 lib/public/image.php delete mode 100644 lib/public/imemcache.php delete mode 100644 lib/public/imemcachettl.php delete mode 100644 lib/public/inavigationmanager.php delete mode 100644 lib/public/ipreview.php delete mode 100644 lib/public/irequest.php delete mode 100644 lib/public/isearch.php delete mode 100644 lib/public/isession.php delete mode 100644 lib/public/itagmanager.php delete mode 100644 lib/public/itags.php delete mode 100644 lib/public/itempmanager.php delete mode 100644 lib/public/iurlgenerator.php delete mode 100644 lib/public/iuser.php delete mode 100644 lib/public/iuserbackend.php delete mode 100644 lib/public/iusermanager.php delete mode 100644 lib/public/iusersession.php delete mode 100644 lib/public/json.php delete mode 100644 lib/public/preconditionnotmetexception.php delete mode 100644 lib/public/response.php delete mode 100644 lib/public/sabrepluginevent.php delete mode 100644 lib/public/sabrepluginexception.php delete mode 100644 lib/public/share.php delete mode 100644 lib/public/share_backend.php delete mode 100644 lib/public/share_backend_collection.php delete mode 100644 lib/public/share_backend_file_dependent.php delete mode 100644 lib/public/user.php delete mode 100644 lib/public/userinterface.php delete mode 100644 lib/public/util.php (limited to 'lib') diff --git a/lib/base.php b/lib/base.php index 1fdcf44f4d0..eddcec97b1f 100644 --- a/lib/base.php +++ b/lib/base.php @@ -53,7 +53,7 @@ * */ -require_once 'public/constants.php'; +require_once 'public/Constants.php'; /** * Class that is a namespace for all global OC variables diff --git a/lib/public/API.php b/lib/public/API.php new file mode 100644 index 00000000000..4d68bef6f29 --- /dev/null +++ b/lib/public/API.php @@ -0,0 +1,75 @@ + + * @author Joas Schilling + * @author Morris Jobke + * @author Tom Needham + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * API Class + * + */ + +// 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; + +/** + * This class provides functions to manage apps in ownCloud + * @since 5.0.0 + */ +class API { + + /** + * API authentication levels + * @since 8.1.0 + */ + const GUEST_AUTH = 0; + const USER_AUTH = 1; + const SUBADMIN_AUTH = 2; + const ADMIN_AUTH = 3; + + /** + * API Response Codes + * @since 8.1.0 + */ + const RESPOND_UNAUTHORISED = 997; + const RESPOND_SERVER_ERROR = 996; + const RESPOND_NOT_FOUND = 998; + const RESPOND_UNKNOWN_ERROR = 999; + + /** + * registers an api call + * @param string $method the http method + * @param string $url the url to match + * @param callable $action the function to run + * @param string $app the id of the app registering the call + * @param int $authLevel the level of authentication required for the call (See `self::*_AUTH` constants) + * @param array $defaults + * @param array $requirements + * @since 5.0.0 + */ + public static function register($method, $url, $action, $app, $authLevel = self::USER_AUTH, + $defaults = array(), $requirements = array()){ + \OC_API::register($method, $url, $action, $app, $authLevel, $defaults, $requirements); + } + +} diff --git a/lib/public/App.php b/lib/public/App.php new file mode 100644 index 00000000000..c3ba90cea41 --- /dev/null +++ b/lib/public/App.php @@ -0,0 +1,153 @@ + + * @author Frank Karlitschek + * @author Georg Ehrke + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * @author Robin McCorkell + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * App Class + * + */ + +// 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; + +/** + * This class provides functions to manage apps in ownCloud + * @since 4.0.0 + */ +class App { + + /** + * Adds an entry to the navigation + * + * This function adds a new entry to the navigation visible to users. $data + * is an associative array. + * The following keys are required: + * - id: unique id for this entry ('addressbook_index') + * - href: link to the page + * - name: Human readable name ('Addressbook') + * + * The following keys are optional: + * - icon: path to the icon of the app + * - order: integer, that influences the position of your application in + * the navigation. Lower values come first. + * + * @param array $data containing the data + * @return boolean + * + * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->add() instead to + * register a closure, this helps to speed up all requests against ownCloud + * @since 4.0.0 + */ + public static function addNavigationEntry($data) { + \OC::$server->getNavigationManager()->add($data); + return true; + } + + /** + * Marks a navigation entry as active + * @param string $id id of the entry + * @return boolean + * + * This function sets a navigation entry as active and removes the 'active' + * property from all other entries. The templates can use this for + * highlighting the current position of the user. + * + * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->setActiveEntry() instead + * @since 4.0.0 + */ + public static function setActiveNavigationEntry( $id ) { + \OC::$server->getNavigationManager()->setActiveEntry($id); + return true; + } + + /** + * Register a Configuration Screen that should appear in the personal settings section. + * @param string $app appid + * @param string $page page to be included + * @return void + * @since 4.0.0 + */ + public static function registerPersonal( $app, $page ) { + \OC_App::registerPersonal( $app, $page ); + } + + /** + * Register a Configuration Screen that should appear in the Admin section. + * @param string $app string appid + * @param string $page string page to be included + * @return void + * @since 4.0.0 + */ + public static function registerAdmin( $app, $page ) { + \OC_App::registerAdmin( $app, $page ); + } + + /** + * Read app metadata from the info.xml file + * @param string $app id of the app or the path of the info.xml file + * @param boolean $path (optional) + * @return array|null + * @since 4.0.0 + */ + public static function getAppInfo( $app, $path=false ) { + return \OC_App::getAppInfo( $app, $path); + } + + /** + * checks whether or not an app is enabled + * @param string $app + * @return boolean + * + * This function checks whether or not an app is enabled. + * @since 4.0.0 + */ + public static function isEnabled( $app ) { + return \OC_App::isEnabled( $app ); + } + + /** + * Check if the app is enabled, redirects to home if not + * @param string $app + * @return void + * @since 4.0.0 + * @deprecated 9.0.0 ownCloud core will handle disabled apps and redirects to valid URLs + */ + public static function checkAppEnabled( $app ) { + } + + /** + * Get the last version of the app from appinfo/info.xml + * @param string $app + * @return string + * @since 4.0.0 + */ + public static function getAppVersion( $app ) { + return \OC_App::getAppVersion( $app ); + } +} diff --git a/lib/public/AutoloadNotAllowedException.php b/lib/public/AutoloadNotAllowedException.php new file mode 100644 index 00000000000..f0028b7d49d --- /dev/null +++ b/lib/public/AutoloadNotAllowedException.php @@ -0,0 +1,37 @@ + + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Exception for when a not allowed path is attempted to be autoloaded + * @since 8.2.0 + */ +class AutoloadNotAllowedException extends \DomainException { + /** + * @param string $path + * @since 8.2.0 + */ + public function __construct($path) { + parent::__construct('Autoload path not allowed: '.$path); + } +} + diff --git a/lib/public/BackgroundJob.php b/lib/public/BackgroundJob.php new file mode 100644 index 00000000000..f532a97c747 --- /dev/null +++ b/lib/public/BackgroundJob.php @@ -0,0 +1,184 @@ + + * @author Felix Moeller + * @author Jakob Sack + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * @author Robin Appelman + * @author Robin McCorkell + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for background jobs. + */ + +// 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; + + +/** + * This class provides functions to register backgroundjobs in ownCloud + * + * To create a new backgroundjob create a new class that inherits from either \OC\BackgroundJob\Job, + * \OC\BackgroundJob\QueuedJob or \OC\BackgroundJob\TimedJob and register it using + * \OCP\BackgroundJob->registerJob($job, $argument), $argument will be passed to the run() function + * of the job when the job is executed. + * + * A regular Job will be executed every time cron.php is run, a QueuedJob will only run once and a TimedJob + * will only run at a specific interval which is to be specified in the constructor of the job by calling + * $this->setInterval($interval) with $interval in seconds. + * @since 4.5.0 + */ +class BackgroundJob { + /** + * get the execution type of background jobs + * + * @return string + * + * This method returns the type how background jobs are executed. If the user + * did not select something, the type is ajax. + * @since 5.0.0 + */ + public static function getExecutionType() { + return \OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax'); + } + + /** + * sets the background jobs execution type + * + * @param string $type execution type + * @return false|null + * + * This method sets the execution type of the background jobs. Possible types + * are "none", "ajax", "webcron", "cron" + * @since 5.0.0 + */ + public static function setExecutionType($type) { + if( !in_array( $type, array('none', 'ajax', 'webcron', 'cron'))) { + return false; + } + \OC::$server->getConfig()->setAppValue('core', 'backgroundjobs_mode', $type); + } + + /** + * @param string $job + * @param mixed $argument + * @deprecated 8.1.0 Use \OC::$server->getJobList()->add() instead + * @since 6.0.0 + */ + public static function registerJob($job, $argument = null) { + $jobList = \OC::$server->getJobList(); + $jobList->add($job, $argument); + } + + /** + * @deprecated 6.0.0 + * creates a regular task + * @param string $klass class name + * @param string $method method name + * @return boolean|null + * @since 4.5.0 + */ + public static function addRegularTask($klass, $method) { + if (!\OCP\Util::needUpgrade()) { + self::registerJob('OC\BackgroundJob\Legacy\RegularJob', array($klass, $method)); + return true; + } + } + + /** + * @deprecated 6.0.0 + * gets all regular tasks + * @return array + * + * key is string "$klass-$method", value is array( $klass, $method ) + * @since 4.5.0 + */ + static public function allRegularTasks() { + return []; + } + + /** + * @deprecated 6.0.0 + * Gets one queued task + * @param int $id ID of the task + * @return BackgroundJob\IJob|null + * @since 4.5.0 + */ + public static function findQueuedTask($id) { + $jobList = \OC::$server->getJobList(); + return $jobList->getById($id); + } + + /** + * @deprecated 6.0.0 + * Gets all queued tasks + * @return array an array of associative arrays + * @since 4.5.0 + */ + public static function allQueuedTasks() { + return []; + } + + /** + * @deprecated 6.0.0 + * Gets all queued tasks of a specific app + * @param string $app app name + * @return array an array of associative arrays + * @since 4.5.0 + */ + public static function queuedTaskWhereAppIs($app) { + return []; + } + + /** + * @deprecated 6.0.0 + * queues a task + * @param string $app app name + * @param string $class class name + * @param string $method method name + * @param string $parameters all useful data as text + * @return boolean id of task + * @since 4.5.0 + */ + public static function addQueuedTask($app, $class, $method, $parameters) { + self::registerJob('OC\BackgroundJob\Legacy\QueuedJob', array('app' => $app, 'klass' => $class, 'method' => $method, 'parameters' => $parameters)); + return true; + } + + /** + * @deprecated 6.0.0 + * deletes a queued task + * @param int $id id of task + * @return boolean|null + * + * Deletes a report + * @since 4.5.0 + */ + public static function deleteQueuedTask($id) { + $jobList = \OC::$server->getJobList(); + $job = $jobList->getById($id); + if ($job) { + $jobList->remove($job); + } + } +} diff --git a/lib/public/Config.php b/lib/public/Config.php new file mode 100644 index 00000000000..5b5dcb0e78e --- /dev/null +++ b/lib/public/Config.php @@ -0,0 +1,163 @@ + + * @author Frank Karlitschek + * @author Georg Ehrke + * @author Jörn Friedrich Dreyer + * @author Lukas Reschke + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Config Class + * + */ + +/** + * Use OCP namespace for all classes that are considered public. + * + * Classes that use this namespace are for use by apps, and not for use by internal + * OC classes + */ +namespace OCP; + +/** + * This class provides functions to read and write configuration data. + * configuration can be on a system, application or user level + * @deprecated 8.0.0 use methods of \OCP\IConfig + */ +class Config { + /** + * Gets a value from config.php + * @param string $key key + * @param mixed $default = null default value + * @return mixed the value or $default + * @deprecated 8.0.0 use method getSystemValue of \OCP\IConfig + * + * This function gets the value from config.php. If it does not exist, + * $default will be returned. + */ + public static function getSystemValue( $key, $default = null ) { + return \OC::$server->getConfig()->getSystemValue( $key, $default ); + } + + /** + * Sets a value + * @param string $key key + * @param mixed $value value + * @return bool + * @deprecated 8.0.0 use method setSystemValue of \OCP\IConfig + * + * This function sets the value and writes the config.php. If the file can + * not be written, false will be returned. + */ + public static function setSystemValue( $key, $value ) { + try { + \OC::$server->getConfig()->setSystemValue( $key, $value ); + } catch (\Exception $e) { + return false; + } + return true; + } + + /** + * Deletes a value from config.php + * @param string $key key + * @deprecated 8.0.0 use method deleteSystemValue of \OCP\IConfig + * + * This function deletes the value from config.php. + */ + public static function deleteSystemValue( $key ) { + \OC::$server->getConfig()->deleteSystemValue( $key ); + } + + /** + * Gets the config value + * @param string $app app + * @param string $key key + * @param string $default = null, default value if the key does not exist + * @return string the value or $default + * @deprecated 8.0.0 use method getAppValue of \OCP\IConfig + * + * This function gets a value from the appconfig table. If the key does + * not exist the default value will be returned + */ + public static function getAppValue( $app, $key, $default = null ) { + return \OC::$server->getConfig()->getAppValue( $app, $key, $default ); + } + + /** + * Sets a value in the appconfig + * @param string $app app + * @param string $key key + * @param string $value value + * @return boolean true/false + * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig + * + * Sets a value. If the key did not exist before it will be created. + */ + public static function setAppValue( $app, $key, $value ) { + try { + \OC::$server->getConfig()->setAppValue( $app, $key, $value ); + } catch (\Exception $e) { + return false; + } + return true; + } + + /** + * Gets the preference + * @param string $user user + * @param string $app app + * @param string $key key + * @param string $default = null, default value if the key does not exist + * @return string the value or $default + * @deprecated 8.0.0 use method getUserValue of \OCP\IConfig + * + * This function gets a value from the preferences table. If the key does + * not exist the default value will be returned + */ + public static function getUserValue( $user, $app, $key, $default = null ) { + return \OC::$server->getConfig()->getUserValue( $user, $app, $key, $default ); + } + + /** + * Sets a value in the preferences + * @param string $user user + * @param string $app app + * @param string $key key + * @param string $value value + * @return bool + * @deprecated 8.0.0 use method setUserValue of \OCP\IConfig + * + * Adds a value to the preferences. If the key did not exist before, it + * will be added automagically. + */ + public static function setUserValue( $user, $app, $key, $value ) { + try { + \OC::$server->getConfig()->setUserValue( $user, $app, $key, $value ); + } catch (\Exception $e) { + return false; + } + return true; + } +} diff --git a/lib/public/Constants.php b/lib/public/Constants.php new file mode 100644 index 00000000000..abf5f95eb96 --- /dev/null +++ b/lib/public/Constants.php @@ -0,0 +1,76 @@ + + * @author Morris Jobke + * @author Roeland Jago Douma + * @author Thomas Tanghus + * @author Vincent Petry + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * This file defines common constants used in ownCloud + */ + +namespace OCP; + +/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_CREATE instead */ +const PERMISSION_CREATE = 4; + +/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_READ instead */ +const PERMISSION_READ = 1; + +/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_UPDATE instead */ +const PERMISSION_UPDATE = 2; + +/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_DELETE instead */ +const PERMISSION_DELETE = 8; + +/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_SHARE instead */ +const PERMISSION_SHARE = 16; + +/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_ALL instead */ +const PERMISSION_ALL = 31; + +/** @deprecated 8.0.0 Use \OCP\Constants::FILENAME_INVALID_CHARS instead */ +const FILENAME_INVALID_CHARS = "\\/<>:\"|?*\n"; + +/** + * Class Constants + * + * @package OCP + * @since 8.0.0 + */ +class Constants { + /** + * CRUDS permissions. + * @since 8.0.0 + */ + const PERMISSION_CREATE = 4; + const PERMISSION_READ = 1; + const PERMISSION_UPDATE = 2; + const PERMISSION_DELETE = 8; + const PERMISSION_SHARE = 16; + const PERMISSION_ALL = 31; + + /** + * @since 8.0.0 - Updated in 9.0.0 to allow all POSIX chars since we no + * longer support windows as server platform. + */ + const FILENAME_INVALID_CHARS = "\\/"; +} diff --git a/lib/public/Contacts.php b/lib/public/Contacts.php new file mode 100644 index 00000000000..590fd9af1bd --- /dev/null +++ b/lib/public/Contacts.php @@ -0,0 +1,184 @@ + + * @author Morris Jobke + * @author Robin McCorkell + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Contacts Class + * + */ + +// 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 { + + /** + * This class provides access to the contacts app. Use this class exclusively if you want to access contacts. + * + * Contacts in general will be expressed as an array of key-value-pairs. + * The keys will match the property names defined in https://tools.ietf.org/html/rfc2426#section-1 + * + * Proposed workflow for working with contacts: + * - search for the contacts + * - manipulate the results array + * - createOrUpdate will save the given contacts overwriting the existing data + * + * For updating it is mandatory to keep the id. + * Without an id a new contact will be created. + * + * @deprecated 8.1.0 use methods of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + class Contacts { + + /** + * This function is used to search and find contacts within the users address books. + * In case $pattern is empty all contacts will be returned. + * + * Example: + * Following function shows how to search for contacts for the name and the email address. + * + * public static function getMatchingRecipient($term) { + * // The API is not active -> nothing to do + * if (!\OCP\Contacts::isEnabled()) { + * return array(); + * } + * + * $result = \OCP\Contacts::search($term, array('FN', 'EMAIL')); + * $receivers = array(); + * foreach ($result as $r) { + * $id = $r['id']; + * $fn = $r['FN']; + * $email = $r['EMAIL']; + * if (!is_array($email)) { + * $email = array($email); + * } + * + * // loop through all email addresses of this contact + * foreach ($email as $e) { + * $displayName = $fn . " <$e>"; + * $receivers[] = array( + * 'id' => $id, + * 'label' => $displayName, + * 'value' => $displayName); + * } + * } + * + * return $receivers; + * } + * + * + * @param string $pattern which should match within the $searchProperties + * @param array $searchProperties defines the properties within the query pattern should match + * @param array $options - for future use. One should always have options! + * @return array an array of contacts which are arrays of key-value-pairs + * @deprecated 8.1.0 use search() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function search($pattern, $searchProperties = array(), $options = array()) { + $cm = \OC::$server->getContactsManager(); + return $cm->search($pattern, $searchProperties, $options); + } + + /** + * This function can be used to delete the contact identified by the given id + * + * @param object $id the unique identifier to a contact + * @param string $address_book_key + * @return bool successful or not + * @deprecated 8.1.0 use delete() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function delete($id, $address_book_key) { + $cm = \OC::$server->getContactsManager(); + return $cm->delete($id, $address_book_key); + } + + /** + * This function is used to create a new contact if 'id' is not given or not present. + * Otherwise the contact will be updated by replacing the entire data set. + * + * @param array $properties this array if key-value-pairs defines a contact + * @param string $address_book_key identifier of the address book in which the contact shall be created or updated + * @return array an array representing the contact just created or updated + * @deprecated 8.1.0 use createOrUpdate() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function createOrUpdate($properties, $address_book_key) { + $cm = \OC::$server->getContactsManager(); + return $cm->createOrUpdate($properties, $address_book_key); + } + + /** + * Check if contacts are available (e.g. contacts app enabled) + * + * @return bool true if enabled, false if not + * @deprecated 8.1.0 use isEnabled() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function isEnabled() { + $cm = \OC::$server->getContactsManager(); + return $cm->isEnabled(); + } + + /** + * @param \OCP\IAddressBook $address_book + * @deprecated 8.1.0 use registerAddressBook() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function registerAddressBook(\OCP\IAddressBook $address_book) { + $cm = \OC::$server->getContactsManager(); + $cm->registerAddressBook($address_book); + } + + /** + * @param \OCP\IAddressBook $address_book + * @deprecated 8.1.0 use unregisterAddressBook() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function unregisterAddressBook(\OCP\IAddressBook $address_book) { + $cm = \OC::$server->getContactsManager(); + $cm->unregisterAddressBook($address_book); + } + + /** + * @return array + * @deprecated 8.1.0 use getAddressBooks() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function getAddressBooks() { + $cm = \OC::$server->getContactsManager(); + return $cm->getAddressBooks(); + } + + /** + * removes all registered address book instances + * @deprecated 8.1.0 use clear() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); + * @since 5.0.0 + */ + public static function clear() { + $cm = \OC::$server->getContactsManager(); + $cm->clear(); + } + } +} diff --git a/lib/public/DB.php b/lib/public/DB.php new file mode 100644 index 00000000000..4706c5e95ee --- /dev/null +++ b/lib/public/DB.php @@ -0,0 +1,145 @@ + + * @author Dan Bartram + * @author Felix Moeller + * @author Frank Karlitschek + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * @author Thomas Tanghus + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * DB Class + * + */ + +// 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; + +/** + * This class provides access to the internal database system. Use this class exlusively if you want to access databases + * @deprecated 8.1.0 use methods of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 4.5.0 + */ +class DB { + /** + * Prepare a SQL query + * @param string $query Query string + * @param int $limit Limit of the SQL statement + * @param int $offset Offset of the SQL statement + * @return \OC_DB_StatementWrapper prepared SQL query + * + * SQL query via Doctrine prepare(), needs to be execute()'d! + * @deprecated 8.1.0 use prepare() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 4.5.0 + */ + static public function prepare( $query, $limit=null, $offset=null ) { + return(\OC_DB::prepare($query, $limit, $offset)); + } + + /** + * Insert a row if the matching row does not exists. + * + * @param string $table The table name (will replace *PREFIX* with the actual prefix) + * @param array $input data that should be inserted into the table (column name => value) + * @param array|null $compare List of values that should be checked for "if not exists" + * If this is null or an empty array, all keys of $input will be compared + * @return int number of inserted rows + * @throws \Doctrine\DBAL\DBALException + * @deprecated 8.1.0 use insertIfNotExist() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 5.0.0 - parameter $compare was added in 8.1.0 + * + */ + public static function insertIfNotExist($table, $input, array $compare = null) { + return \OC::$server->getDatabaseConnection()->insertIfNotExist($table, $input, $compare); + } + + /** + * Gets last value of autoincrement + * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix + * @return string + * + * \Doctrine\DBAL\Connection lastInsertID() + * + * Call this method right after the insert command or other functions may + * cause trouble! + * @deprecated 8.1.0 use lastInsertId() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 4.5.0 + */ + public static function insertid($table=null) { + return \OC::$server->getDatabaseConnection()->lastInsertId($table); + } + + /** + * Start a transaction + * @deprecated 8.1.0 use beginTransaction() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 4.5.0 + */ + public static function beginTransaction() { + \OC::$server->getDatabaseConnection()->beginTransaction(); + } + + /** + * Commit the database changes done during a transaction that is in progress + * @deprecated 8.1.0 use commit() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 4.5.0 + */ + public static function commit() { + \OC::$server->getDatabaseConnection()->commit(); + } + + /** + * Rollback the database changes done during a transaction that is in progress + * @deprecated 8.1.0 use rollback() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 8.0.0 + */ + public static function rollback() { + \OC::$server->getDatabaseConnection()->rollback(); + } + + /** + * Check if a result is an error, works with Doctrine + * @param mixed $result + * @return bool + * @deprecated 8.1.0 Doctrine returns false on error (and throws an exception) + * @since 4.5.0 + */ + public static function isError($result) { + // Doctrine returns false on error (and throws an exception) + return $result === false; + } + + /** + * returns the error code and message as a string for logging + * works with DoctrineException + * @return string + * @deprecated 8.1.0 use getError() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() + * @since 6.0.0 + */ + public static function getErrorMessage() { + return \OC::$server->getDatabaseConnection()->getError(); + } + +} diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php new file mode 100644 index 00000000000..58b25d5914a --- /dev/null +++ b/lib/public/Defaults.php @@ -0,0 +1,173 @@ + + * @author Lukas Reschke + * @author Morris Jobke + * @author scolebrook + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Defaults Class + * + */ + +// 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; + +/** + * public api to access default strings and urls for your templates + * @since 6.0.0 + */ +class Defaults { + + /** + * \OC_Defaults instance to retrieve the defaults + * @return string + * @since 6.0.0 + */ + private $defaults; + + /** + * creates a \OC_Defaults instance which is used in all methods to retrieve the + * actual defaults + * @since 6.0.0 + */ + function __construct() { + $this->defaults = new \OC_Defaults(); + } + + /** + * get base URL for the organisation behind your ownCloud instance + * @return string + * @since 6.0.0 + */ + public function getBaseUrl() { + return $this->defaults->getBaseUrl(); + } + + /** + * link to the desktop sync client + * @return string + * @since 6.0.0 + */ + public function getSyncClientUrl() { + return $this->defaults->getSyncClientUrl(); + } + + /** + * link to the iOS client + * @return string + * @since 8.0.0 + */ + public function getiOSClientUrl() { + return $this->defaults->getiOSClientUrl(); + } + + /** + * link to the Android client + * @return string + * @since 8.0.0 + */ + public function getAndroidClientUrl() { + return $this->defaults->getAndroidClientUrl(); + } + + /** + * base URL to the documentation of your ownCloud instance + * @return string + * @since 6.0.0 + */ + public function getDocBaseUrl() { + return $this->defaults->getDocBaseUrl(); + } + + /** + * name of your ownCloud instance + * @return string + * @since 6.0.0 + */ + public function getName() { + return $this->defaults->getName(); + } + + /** + * name of your ownCloud instance containing HTML styles + * @return string + * @since 8.0.0 + */ + public function getHTMLName() { + return $this->defaults->getHTMLName(); + } + + /** + * Entity behind your onwCloud instance + * @return string + * @since 6.0.0 + */ + public function getEntity() { + return $this->defaults->getEntity(); + } + + /** + * ownCloud slogan + * @return string + * @since 6.0.0 + */ + public function getSlogan() { + return $this->defaults->getSlogan(); + } + + /** + * logo claim + * @return string + * @since 6.0.0 + */ + public function getLogoClaim() { + return $this->defaults->getLogoClaim(); + } + + /** + * footer, short version + * @return string + * @since 6.0.0 + */ + public function getShortFooter() { + return $this->defaults->getShortFooter(); + } + + /** + * footer, long version + * @return string + * @since 6.0.0 + */ + public function getLongFooter() { + return $this->defaults->getLongFooter(); + } + + /** + * Returns the AppId for the App Store for the iOS Client + * @return string AppId + * @since 8.0.0 + */ + public function getiTunesAppId() { + return $this->defaults->getiTunesAppId(); + } +} diff --git a/lib/public/Files.php b/lib/public/Files.php new file mode 100644 index 00000000000..f7f0b30bf86 --- /dev/null +++ b/lib/public/Files.php @@ -0,0 +1,134 @@ + + * @author Björn Schießle + * @author Frank Karlitschek + * @author Georg Ehrke + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Files Class + * + */ + +// 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; + +/** + * This class provides access to the internal filesystem abstraction layer. Use + * this class exlusively if you want to access files + * @since 5.0.0 + */ +class Files { + /** + * Recusive deletion of folders + * @return bool + * @since 5.0.0 + */ + static function rmdirr( $dir ) { + return \OC_Helper::rmdirr( $dir ); + } + + /** + * Get the mimetype form a local file + * @param string $path + * @return string + * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead + * @since 5.0.0 + */ + static function getMimeType( $path ) { + return \OC::$server->getMimeTypeDetector()->detect($path); + } + + /** + * Search for files by mimetype + * @param string $mimetype + * @return array + * @since 6.0.0 + */ + static public function searchByMime( $mimetype ) { + return(\OC\Files\Filesystem::searchByMime( $mimetype )); + } + + /** + * Copy the contents of one stream to another + * @param resource $source + * @param resource $target + * @return int the number of bytes copied + * @since 5.0.0 + */ + public static function streamCopy( $source, $target ) { + list($count, ) = \OC_Helper::streamCopy( $source, $target ); + return $count; + } + + /** + * Create a temporary file with an unique filename + * @param string $postfix + * @return string + * + * temporary files are automatically cleaned up after the script is finished + * @deprecated 8.1.0 use getTemporaryFile() of \OCP\ITempManager - \OC::$server->getTempManager() + * @since 5.0.0 + */ + public static function tmpFile( $postfix='' ) { + return \OC::$server->getTempManager()->getTemporaryFile($postfix); + } + + /** + * Create a temporary folder with an unique filename + * @return string + * + * temporary files are automatically cleaned up after the script is finished + * @deprecated 8.1.0 use getTemporaryFolder() of \OCP\ITempManager - \OC::$server->getTempManager() + * @since 5.0.0 + */ + public static function tmpFolder() { + return \OC::$server->getTempManager()->getTemporaryFolder(); + } + + /** + * Adds a suffix to the name in case the file exists + * @param string $path + * @param string $filename + * @return string + * @since 5.0.0 + */ + public static function buildNotExistingFileName( $path, $filename ) { + return(\OC_Helper::buildNotExistingFileName( $path, $filename )); + } + + /** + * Gets the Storage for an app - creates the needed folder if they are not + * existent + * @param string $app + * @return \OC\Files\View + * @since 5.0.0 + */ + public static function getStorage( $app ) { + return \OC_App::getStorage( $app ); + } +} diff --git a/lib/public/GroupInterface.php b/lib/public/GroupInterface.php new file mode 100644 index 00000000000..628bc2f42ef --- /dev/null +++ b/lib/public/GroupInterface.php @@ -0,0 +1,106 @@ + + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Group Class. + * + */ + +// 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; + +/** + * TODO actually this is a IGroupBackend + * + * @package OCP + * @since 4.5.0 + */ +interface GroupInterface { + + /** + * Check if backend implements actions + * @param int $actions bitwise-or'ed actions + * @return boolean + * @since 4.5.0 + * + * Returns the supported actions as int to be + * compared with \OC_Group_Backend::CREATE_GROUP etc. + */ + public function implementsActions($actions); + + /** + * is user in group? + * @param string $uid uid of the user + * @param string $gid gid of the group + * @return bool + * @since 4.5.0 + * + * Checks whether the user is member of a group or not. + */ + public function inGroup($uid, $gid); + + /** + * Get all groups a user belongs to + * @param string $uid Name of the user + * @return array an array of group names + * @since 4.5.0 + * + * This function fetches all groups a user belongs to. It does not check + * if the user exists at all. + */ + public function getUserGroups($uid); + + /** + * get a list of all groups + * @param string $search + * @param int $limit + * @param int $offset + * @return array an array of group names + * @since 4.5.0 + * + * Returns a list with all groups + */ + public function getGroups($search = '', $limit = -1, $offset = 0); + + /** + * check if a group exists + * @param string $gid + * @return bool + * @since 4.5.0 + */ + public function 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 + * @since 4.5.0 + */ + public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0); + +} diff --git a/lib/public/IAddressBook.php b/lib/public/IAddressBook.php new file mode 100644 index 00000000000..63e7e061448 --- /dev/null +++ b/lib/public/IAddressBook.php @@ -0,0 +1,93 @@ + + * @author Morris Jobke + * @author Robin McCorkell + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * IAddressBook interface + */ + +// 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 { + /** + * Interface IAddressBook + * + * @package OCP + * @since 5.0.0 + */ + interface IAddressBook { + + /** + * @return string defining the technical unique key + * @since 5.0.0 + */ + public function getKey(); + + /** + * In comparison to getKey() this function returns a human readable (maybe translated) name + * @return mixed + * @since 5.0.0 + */ + public function getDisplayName(); + + /** + * @param string $pattern which should match within the $searchProperties + * @param array $searchProperties defines the properties within the query pattern should match + * @param array $options - for future use. One should always have options! + * @return array an array of contacts which are arrays of key-value-pairs + * @since 5.0.0 + */ + public function search($pattern, $searchProperties, $options); + // // dummy results + // return array( + // array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), + // array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), + // ); + + /** + * @param array $properties this array if key-value-pairs defines a contact + * @return array an array representing the contact just created or updated + * @since 5.0.0 + */ + public function createOrUpdate($properties); + // // dummy + // return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', + // 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', + // 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' + // ); + + /** + * @return mixed + * @since 5.0.0 + */ + public function getPermissions(); + + /** + * @param object $id the unique identifier to a contact + * @return bool successful or not + * @since 5.0.0 + */ + public function delete($id); + } +} diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php new file mode 100644 index 00000000000..1406e8a56d6 --- /dev/null +++ b/lib/public/IAppConfig.php @@ -0,0 +1,120 @@ + + * @author Morris Jobke + * @author Robin Appelman + * @author Robin McCorkell + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ +namespace OCP; + +/** + * This class provides an easy way for apps to store config values in the + * database. + * @since 7.0.0 + */ +interface IAppConfig { + /** + * check if a key is set in the appconfig + * @param string $app + * @param string $key + * @return bool + * @since 7.0.0 + */ + public function hasKey($app, $key); + + /** + * Gets the config value + * @param string $app app + * @param string $key key + * @param string $default = null, default value if the key does not exist + * @return string the value or $default + * @deprecated 8.0.0 use method getAppValue of \OCP\IConfig + * + * This function gets a value from the appconfig table. If the key does + * not exist the default value will be returned + * @since 7.0.0 + */ + public function getValue($app, $key, $default = null); + + /** + * Deletes a key + * @param string $app app + * @param string $key key + * @return bool + * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig + * @since 7.0.0 + */ + public function deleteKey($app, $key); + + /** + * Get the available keys for an app + * @param string $app the app we are looking for + * @return array an array of key names + * @deprecated 8.0.0 use method getAppKeys of \OCP\IConfig + * + * This function gets all keys of an app. Please note that the values are + * not returned. + * @since 7.0.0 + */ + public function getKeys($app); + + /** + * get multiply values, either the app or key can be used as wildcard by setting it to false + * + * @param string|false $key + * @param string|false $app + * @return array|false + * @since 7.0.0 + */ + public function getValues($app, $key); + + /** + * sets a value in the appconfig + * @param string $app app + * @param string $key key + * @param string $value value + * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig + * + * Sets a value. If the key did not exist before it will be created. + * @return void + * @since 7.0.0 + */ + public function setValue($app, $key, $value); + + /** + * Get all apps using the config + * @return array an array of app ids + * + * This function returns a list of all apps that have at least one + * entry in the appconfig table. + * @since 7.0.0 + */ + public function getApps(); + + /** + * Remove app from appconfig + * @param string $app app + * @return bool + * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig + * + * Removes all keys in appconfig belonging to the app. + * @since 7.0.0 + */ + public function deleteApp($app); +} diff --git a/lib/public/IAvatar.php b/lib/public/IAvatar.php new file mode 100644 index 00000000000..7b811b26b68 --- /dev/null +++ b/lib/public/IAvatar.php @@ -0,0 +1,79 @@ + + * @author Joas Schilling + * @author Morris Jobke + * @author Robin Appelman + * @author Roeland Jago Douma + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; +use OCP\Files\File; +use OCP\Files\NotFoundException; + +/** + * This class provides avatar functionality + * @since 6.0.0 + */ +interface IAvatar { + + /** + * get the users avatar + * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image + * @return boolean|\OCP\IImage containing the avatar or false if there's no image + * @since 6.0.0 - size of -1 was added in 9.0.0 + */ + public function get($size = 64); + + /** + * Check if an avatar exists for the user + * + * @return bool + * @since 8.1.0 + */ + public function exists(); + + /** + * sets the users avatar + * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar + * @throws \Exception if the provided file is not a jpg or png image + * @throws \Exception if the provided image is not valid + * @throws \OC\NotSquareException if the image is not square + * @return void + * @since 6.0.0 + */ + public function set($data); + + /** + * remove the users avatar + * @return void + * @since 6.0.0 + */ + public function remove(); + + /** + * Get the file of the avatar + * @param int $size -1 can be used to not scale the image + * @return File + * @throws NotFoundException + * @since 9.0.0 + */ + public function getFile($size); +} diff --git a/lib/public/IAvatarManager.php b/lib/public/IAvatarManager.php new file mode 100644 index 00000000000..ef6b00ffd13 --- /dev/null +++ b/lib/public/IAvatarManager.php @@ -0,0 +1,45 @@ + + * @author Christopher Schäpers + * @author Morris Jobke + * @author Robin McCorkell + * @author Roeland Jago Douma + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * This class provides avatar functionality + * @since 6.0.0 + */ + +interface IAvatarManager { + + /** + * return a user specific instance of \OCP\IAvatar + * @see \OCP\IAvatar + * @param string $user the ownCloud user id + * @return \OCP\IAvatar + * @throws \Exception In case the username is potentially dangerous + * @throws \OCP\Files\NotFoundException In case there is no user folder yet + * @since 6.0.0 + */ + public function getAvatar($user); +} diff --git a/lib/public/ICache.php b/lib/public/ICache.php new file mode 100644 index 00000000000..a1ce068d819 --- /dev/null +++ b/lib/public/ICache.php @@ -0,0 +1,82 @@ + + * @author Thomas Müller + * @author Thomas Tanghus + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Cache interface + * + */ + +// 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; + +/** + * This interface defines method for accessing the file based user cache. + * @since 6.0.0 + */ +interface ICache { + + /** + * Get a value from the user cache + * @param string $key + * @return mixed + * @since 6.0.0 + */ + public function get($key); + + /** + * Set a value in the user cache + * @param string $key + * @param mixed $value + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 + * @return bool + * @since 6.0.0 + */ + public function set($key, $value, $ttl = 0); + + /** + * Check if a value is set in the user cache + * @param string $key + * @return bool + * @since 6.0.0 + * @deprecated 9.1.0 Directly read from GET to prevent race conditions + */ + public function hasKey($key); + + /** + * Remove an item from the user cache + * @param string $key + * @return bool + * @since 6.0.0 + */ + public function remove($key); + + /** + * Clear the user cache of all entries starting with a prefix + * @param string $prefix (optional) + * @return bool + * @since 6.0.0 + */ + public function clear($prefix = ''); +} diff --git a/lib/public/ICacheFactory.php b/lib/public/ICacheFactory.php new file mode 100644 index 00000000000..233a4f5525d --- /dev/null +++ b/lib/public/ICacheFactory.php @@ -0,0 +1,50 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface ICacheFactory + * + * @package OCP + * @since 7.0.0 + */ +interface ICacheFactory{ + /** + * Get a memory cache instance + * + * All entries added trough the cache instance will be namespaced by $prefix to prevent collisions between apps + * + * @param string $prefix + * @return \OCP\ICache + * @since 7.0.0 + */ + public function create($prefix = ''); + + /** + * Check if any memory cache backend is available + * + * @return bool + * @since 7.0.0 + */ + public function isAvailable(); +} diff --git a/lib/public/ICertificate.php b/lib/public/ICertificate.php new file mode 100644 index 00000000000..c3a003fbf0a --- /dev/null +++ b/lib/public/ICertificate.php @@ -0,0 +1,79 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface ICertificate + * + * @package OCP + * @since 8.0.0 + */ +interface ICertificate { + /** + * @return string + * @since 8.0.0 + */ + public function getName(); + + /** + * @return string + * @since 8.0.0 + */ + public function getCommonName(); + + /** + * @return string + * @since 8.0.0 + */ + public function getOrganization(); + + /** + * @return \DateTime + * @since 8.0.0 + */ + public function getIssueDate(); + + /** + * @return \DateTime + * @since 8.0.0 + */ + public function getExpireDate(); + + /** + * @return bool + * @since 8.0.0 + */ + public function isExpired(); + + /** + * @return string + * @since 8.0.0 + */ + public function getIssuerName(); + + /** + * @return string + * @since 8.0.0 + */ + public function getIssuerOrganization(); +} diff --git a/lib/public/ICertificateManager.php b/lib/public/ICertificateManager.php new file mode 100644 index 00000000000..27eebcf0491 --- /dev/null +++ b/lib/public/ICertificateManager.php @@ -0,0 +1,71 @@ + + * @author Morris Jobke + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Manage trusted certificates for users + * @since 8.0.0 + */ +interface ICertificateManager { + /** + * Returns all certificates trusted by the user + * + * @return \OCP\ICertificate[] + * @since 8.0.0 + */ + public function listCertificates(); + + /** + * @param string $certificate the certificate data + * @param string $name the filename for the certificate + * @return \OCP\ICertificate + * @throws \Exception If the certificate could not get added + * @since 8.0.0 - since 8.1.0 throws exception instead of returning false + */ + public function addCertificate($certificate, $name); + + /** + * @param string $name + * @since 8.0.0 + */ + public function removeCertificate($name); + + /** + * Get the path to the certificate bundle for this user + * + * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle (since 9.0.0) + * @return string + * @since 8.0.0 + */ + public function getCertificateBundle($uid = ''); + + /** + * Get the full local path to the certificate bundle for this user + * + * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle + * @return string + * @since 9.0.0 + */ + public function getAbsoluteBundlePath($uid = ''); +} diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php new file mode 100644 index 00000000000..8dac390a99c --- /dev/null +++ b/lib/public/IConfig.php @@ -0,0 +1,225 @@ + + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Lukas Reschke + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Config interface + * + */ + +// 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; + +/** + * Access to all the configuration options ownCloud offers + * @since 6.0.0 + */ +interface IConfig { + /** + * @since 8.2.0 + */ + const SENSITIVE_VALUE = '***REMOVED SENSITIVE VALUE***'; + + /** + * Sets and deletes system wide values + * + * @param array $configs Associative array with `key => value` pairs + * If value is null, the config key will be deleted + * @since 8.0.0 + */ + public function setSystemValues(array $configs); + + /** + * Sets a new system wide value + * + * @param string $key the key of the value, under which will be saved + * @param mixed $value the value that should be stored + * @since 8.0.0 + */ + public function setSystemValue($key, $value); + + /** + * Looks up a system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @param mixed $default the default value to be returned if the value isn't set + * @return mixed the value or $default + * @since 6.0.0 - parameter $default was added in 7.0.0 + */ + public function getSystemValue($key, $default = ''); + + /** + * Looks up a system wide defined value and filters out sensitive data + * + * @param string $key the key of the value, under which it was saved + * @param mixed $default the default value to be returned if the value isn't set + * @return mixed the value or $default + * @since 8.2.0 + */ + public function getFilteredSystemValue($key, $default = ''); + + /** + * Delete a system wide defined value + * + * @param string $key the key of the value, under which it was saved + * @since 8.0.0 + */ + public function deleteSystemValue($key); + + /** + * Get all keys stored for an app + * + * @param string $appName the appName that we stored the value under + * @return string[] the keys stored for the app + * @since 8.0.0 + */ + public function getAppKeys($appName); + + /** + * Writes a new app wide value + * + * @param string $appName the appName that we want to store the value under + * @param string $key the key of the value, under which will be saved + * @param string $value the value that should be stored + * @return void + * @since 6.0.0 + */ + public function setAppValue($appName, $key, $value); + + /** + * Looks up an app wide defined value + * + * @param string $appName the appName that we stored the value under + * @param string $key the key of the value, under which it was saved + * @param string $default the default value to be returned if the value isn't set + * @return string the saved value + * @since 6.0.0 - parameter $default was added in 7.0.0 + */ + public function getAppValue($appName, $key, $default = ''); + + /** + * Delete an app wide defined value + * + * @param string $appName the appName that we stored the value under + * @param string $key the key of the value, under which it was saved + * @since 8.0.0 + */ + public function deleteAppValue($appName, $key); + + /** + * Removes all keys in appconfig belonging to the app + * + * @param string $appName the appName the configs are stored under + * @since 8.0.0 + */ + public function deleteAppValues($appName); + + + /** + * Set a user defined value + * + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we want to store the value under + * @param string $key the key under which the value is being stored + * @param string $value the value that you want to store + * @param string $preCondition only update if the config value was previously the value passed as $preCondition + * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met + * @since 6.0.0 - parameter $precondition was added in 8.0.0 + */ + public function setUserValue($userId, $appName, $key, $value, $preCondition = null); + + /** + * Shortcut for getting a user defined value + * + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we stored the value under + * @param string $key the key under which the value is being stored + * @param mixed $default the default value to be returned if the value isn't set + * @return string + * @since 6.0.0 - parameter $default was added in 7.0.0 + */ + public function getUserValue($userId, $appName, $key, $default = ''); + + /** + * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs. + * + * @param string $appName app to get the value for + * @param string $key the key to get the value for + * @param array $userIds the user IDs to fetch the values for + * @return array Mapped values: userId => value + * @since 8.0.0 + */ + public function getUserValueForUsers($appName, $key, $userIds); + + /** + * Get the keys of all stored by an app for the user + * + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we stored the value under + * @return string[] + * @since 8.0.0 + */ + public function getUserKeys($userId, $appName); + + /** + * Delete a user value + * + * @param string $userId the userId of the user that we want to store the value under + * @param string $appName the appName that we stored the value under + * @param string $key the key under which the value is being stored + * @since 8.0.0 + */ + public function deleteUserValue($userId, $appName, $key); + + /** + * Delete all user values + * + * @param string $userId the userId of the user that we want to remove all values from + * @since 8.0.0 + */ + public function deleteAllUserValues($userId); + + /** + * Delete all user related values of one app + * + * @param string $appName the appName of the app that we want to remove all values from + * @since 8.0.0 + */ + public function deleteAppFromAllUsers($appName); + + /** + * Determines the users that have the given value set for a specific app-key-pair + * + * @param string $appName the app to get the user for + * @param string $key the key to get the user for + * @param string $value the value to get the user for + * @return array of user IDs + * @since 8.0.0 + */ + public function getUsersForUserValue($appName, $key, $value); +} diff --git a/lib/public/IContainer.php b/lib/public/IContainer.php new file mode 100644 index 00000000000..d23ee5ea3b5 --- /dev/null +++ b/lib/public/IContainer.php @@ -0,0 +1,102 @@ + + * @author Joas Schilling + * @author Morris Jobke + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Container interface + * + */ + +// 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; + +use Closure; +use OCP\AppFramework\QueryException; + + +/** + * Class IContainer + * + * IContainer is the basic interface to be used for any internal dependency injection mechanism + * + * @package OCP + * @since 6.0.0 + */ +interface IContainer { + + /** + * If a parameter is not registered in the container try to instantiate it + * by using reflection to find out how to build the class + * @param string $name the class name to resolve + * @return \stdClass + * @since 8.2.0 + * @throws QueryException if the class could not be found or instantiated + */ + public function resolve($name); + + /** + * Look up a service for a given name in the container. + * + * @param string $name + * @return mixed + * @since 6.0.0 + */ + public function query($name); + + /** + * A value is stored in the container with it's corresponding name + * + * @param string $name + * @param mixed $value + * @return void + * @since 6.0.0 + */ + public function registerParameter($name, $value); + + /** + * A service is registered in the container where a closure is passed in which will actually + * create the service on demand. + * In case the parameter $shared is set to true (the default usage) the once created service will remain in + * memory and be reused on subsequent calls. + * In case the parameter is false the service will be recreated on every call. + * + * @param string $name + * @param \Closure $closure + * @param bool $shared + * @return void + * @since 6.0.0 + */ + public function registerService($name, Closure $closure, $shared = true); + + /** + * Shortcut for returning a service from a service under a different key, + * e.g. to tell the container to return a class when queried for an + * interface + * @param string $alias the alias that should be registered + * @param string $target the target that should be resolved instead + * @since 8.2.0 + */ + public function registerAlias($alias, $target); +} diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php new file mode 100644 index 00000000000..780fcd26364 --- /dev/null +++ b/lib/public/IDBConnection.php @@ -0,0 +1,234 @@ + + * @author Joas Schilling + * @author Morris Jobke + * @author Robin Appelman + * @author Robin McCorkell + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * DBConnection interface + * + */ + +// 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; +use OCP\DB\QueryBuilder\IQueryBuilder; + +/** + * Interface IDBConnection + * + * @package OCP + * @since 6.0.0 + */ +interface IDBConnection { + /** + * Gets the QueryBuilder for the connection. + * + * @return \OCP\DB\QueryBuilder\IQueryBuilder + * @since 8.2.0 + */ + public function getQueryBuilder(); + + /** + * Used to abstract the ownCloud database access away + * @param string $sql the sql query with ? placeholder for params + * @param int $limit the maximum number of rows + * @param int $offset from which row we want to start + * @return \Doctrine\DBAL\Driver\Statement The prepared statement. + * @since 6.0.0 + */ + public function prepare($sql, $limit=null, $offset=null); + + /** + * Executes an, optionally parameterized, SQL query. + * + * If the query is parameterized, a prepared statement is used. + * If an SQLLogger is configured, the execution is logged. + * + * @param string $query The SQL query to execute. + * @param string[] $params The parameters to bind to the query, if any. + * @param array $types The types the previous parameters are in. + * @return \Doctrine\DBAL\Driver\Statement The executed statement. + * @since 8.0.0 + */ + public function executeQuery($query, array $params = array(), $types = array()); + + /** + * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters + * and returns the number of affected rows. + * + * This method supports PDO binding types as well as DBAL mapping types. + * + * @param string $query The SQL query. + * @param array $params The query parameters. + * @param array $types The parameter types. + * @return integer The number of affected rows. + * @since 8.0.0 + */ + public function executeUpdate($query, array $params = array(), array $types = array()); + + /** + * Used to get the id of the just inserted element + * @param string $table the name of the table where we inserted the item + * @return int the id of the inserted element + * @since 6.0.0 + */ + public function lastInsertId($table = null); + + /** + * Insert a row if the matching row does not exists. + * + * @param string $table The table name (will replace *PREFIX* with the actual prefix) + * @param array $input data that should be inserted into the table (column name => value) + * @param array|null $compare List of values that should be checked for "if not exists" + * If this is null or an empty array, all keys of $input will be compared + * Please note: text fields (clob) must not be used in the compare array + * @return int number of inserted rows + * @throws \Doctrine\DBAL\DBALException + * @since 6.0.0 - parameter $compare was added in 8.1.0, return type changed from boolean in 8.1.0 + */ + public function insertIfNotExist($table, $input, array $compare = null); + + /** + * Insert or update a row value + * + * @param string $table + * @param array $keys (column name => value) + * @param array $values (column name => value) + * @param array $updatePreconditionValues ensure values match preconditions (column name => value) + * @return int number of new rows + * @throws \Doctrine\DBAL\DBALException + * @throws PreconditionNotMetException + * @since 9.0.0 + */ + public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []); + + /** + * Start a transaction + * @since 6.0.0 + */ + public function beginTransaction(); + + /** + * Check if a transaction is active + * + * @return bool + * @since 8.2.0 + */ + public function inTransaction(); + + /** + * Commit the database changes done during a transaction that is in progress + * @since 6.0.0 + */ + public function commit(); + + /** + * Rollback the database changes done during a transaction that is in progress + * @since 6.0.0 + */ + public function rollBack(); + + /** + * Gets the error code and message as a string for logging + * @return string + * @since 6.0.0 + */ + public function getError(); + + /** + * Fetch the SQLSTATE associated with the last database operation. + * + * @return integer The last error code. + * @since 8.0.0 + */ + public function errorCode(); + + /** + * Fetch extended error information associated with the last database operation. + * + * @return array The last error information. + * @since 8.0.0 + */ + public function errorInfo(); + + /** + * Establishes the connection with the database. + * + * @return bool + * @since 8.0.0 + */ + public function connect(); + + /** + * Close the database connection + * @since 8.0.0 + */ + public function close(); + + /** + * Quotes a given input parameter. + * + * @param mixed $input Parameter to be quoted. + * @param int $type Type of the parameter. + * @return string The quoted parameter. + * @since 8.0.0 + */ + public function quote($input, $type = IQueryBuilder::PARAM_STR); + + /** + * Gets the DatabasePlatform instance that provides all the metadata about + * the platform this driver connects to. + * + * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. + * @since 8.0.0 + */ + public function getDatabasePlatform(); + + /** + * Drop a table from the database if it exists + * + * @param string $table table name without the prefix + * @since 8.0.0 + */ + public function dropTable($table); + + /** + * Check if a table exists + * + * @param string $table table name without the prefix + * @return bool + * @since 8.0.0 + */ + public function tableExists($table); + + /** + * Escape a parameter to be used in a LIKE query + * + * @param string $param + * @return string + * @since 9.0.0 + */ + public function escapeLikeParameter($param); +} diff --git a/lib/public/IDateTimeFormatter.php b/lib/public/IDateTimeFormatter.php new file mode 100644 index 00000000000..e8d357ae50f --- /dev/null +++ b/lib/public/IDateTimeFormatter.php @@ -0,0 +1,144 @@ + + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface IDateTimeFormatter + * + * @package OCP + * @since 8.0.0 + */ +interface IDateTimeFormatter { + /** + * Formats the date of the given timestamp + * + * @param int|\DateTime $timestamp + * @param string $format Either 'full', 'long', 'medium' or 'short' + * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' + * long: e.g. 'MMMM d, y' => 'August 20, 2014' + * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' + * short: e.g. 'M/d/yy' => '8/20/14' + * The exact format is dependent on the language + * @param \DateTimeZone $timeZone The timezone to use + * @param \OCP\IL10N $l The locale to use + * @return string Formatted date string + * @since 8.0.0 + */ + public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); + + /** + * Formats the date of the given timestamp + * + * @param int|\DateTime $timestamp + * @param string $format Either 'full', 'long', 'medium' or 'short' + * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' + * long: e.g. 'MMMM d, y' => 'August 20, 2014' + * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' + * short: e.g. 'M/d/yy' => '8/20/14' + * The exact format is dependent on the language + * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable + * @param \DateTimeZone $timeZone The timezone to use + * @param \OCP\IL10N $l The locale to use + * @return string Formatted relative date string + * @since 8.0.0 + */ + public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); + + /** + * Gives the relative date of the timestamp + * Only works for past dates + * + * @param int|\DateTime $timestamp + * @param int|\DateTime $baseTimestamp Timestamp to compare $timestamp against, defaults to current time + * @return string Dates returned are: + * < 1 month => Today, Yesterday, n days ago + * < 13 month => last month, n months ago + * >= 13 month => last year, n years ago + * @param \OCP\IL10N $l The locale to use + * @return string Formatted date span + * @since 8.0.0 + */ + public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); + + /** + * Formats the time of the given timestamp + * + * @param int|\DateTime $timestamp + * @param string $format Either 'full', 'long', 'medium' or 'short' + * full: e.g. 'h:mm:ss a zzzz' => '11:42:13 AM GMT+0:00' + * long: e.g. 'h:mm:ss a z' => '11:42:13 AM GMT' + * medium: e.g. 'h:mm:ss a' => '11:42:13 AM' + * short: e.g. 'h:mm a' => '11:42 AM' + * The exact format is dependent on the language + * @param \DateTimeZone $timeZone The timezone to use + * @param \OCP\IL10N $l The locale to use + * @return string Formatted time string + * @since 8.0.0 + */ + public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); + + /** + * Gives the relative past time of the timestamp + * + * @param int|\DateTime $timestamp + * @param int|\DateTime $baseTimestamp Timestamp to compare $timestamp against, defaults to current time + * @return string Dates returned are: + * < 60 sec => seconds ago + * < 1 hour => n minutes ago + * < 1 day => n hours ago + * < 1 month => Yesterday, n days ago + * < 13 month => last month, n months ago + * >= 13 month => last year, n years ago + * @param \OCP\IL10N $l The locale to use + * @return string Formatted time span + * @since 8.0.0 + */ + public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); + + /** + * Formats the date and time of the given timestamp + * + * @param int|\DateTime $timestamp + * @param string $formatDate See formatDate() for description + * @param string $formatTime See formatTime() for description + * @param \DateTimeZone $timeZone The timezone to use + * @param \OCP\IL10N $l The locale to use + * @return string Formatted date and time string + * @since 8.0.0 + */ + public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); + + /** + * Formats the date and time of the given timestamp + * + * @param int|\DateTime $timestamp + * @param string $formatDate See formatDate() for description + * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable + * @param string $formatTime See formatTime() for description + * @param \DateTimeZone $timeZone The timezone to use + * @param \OCP\IL10N $l The locale to use + * @return string Formatted relative date and time string + * @since 8.0.0 + */ + public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); +} diff --git a/lib/public/IDateTimeZone.php b/lib/public/IDateTimeZone.php new file mode 100644 index 00000000000..3df705a2413 --- /dev/null +++ b/lib/public/IDateTimeZone.php @@ -0,0 +1,38 @@ + + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface IDateTimeZone + * + * @package OCP + * @since 8.0.0 + */ +interface IDateTimeZone { + /** + * @param bool|int $timestamp + * @return \DateTimeZone + * @since 8.0.0 - parameter $timestamp was added in 8.1.0 + */ + public function getTimeZone($timestamp = false); +} diff --git a/lib/public/IDb.php b/lib/public/IDb.php new file mode 100644 index 00000000000..f21fedd1f54 --- /dev/null +++ b/lib/public/IDb.php @@ -0,0 +1,53 @@ + + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + + +/** + * Small Facade for being able to inject the database connection for tests + * @since 7.0.0 - extends IDBConnection was added in 8.1.0 + */ +interface IDb extends IDBConnection { + + + /** + * Used to abstract the owncloud database access away + * @param string $sql the sql query with ? placeholder for params + * @param int $limit the maximum number of rows + * @param int $offset from which row we want to start + * @return \OC_DB_StatementWrapper prepared SQL query + * @since 7.0.0 + */ + public function prepareQuery($sql, $limit=null, $offset=null); + + + /** + * Used to get the id of the just inserted element + * @param string $tableName the name of the table where we inserted the item + * @return int the id of the inserted element + * @since 7.0.0 + */ + public function getInsertId($tableName); + + +} diff --git a/lib/public/IEventSource.php b/lib/public/IEventSource.php new file mode 100644 index 00000000000..b643d1c9da7 --- /dev/null +++ b/lib/public/IEventSource.php @@ -0,0 +1,51 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * wrapper for server side events (http://en.wikipedia.org/wiki/Server-sent_events) + * includes a fallback for older browsers and IE + * + * use server side events with caution, to many open requests can hang the server + * + * The event source will initialize the connection to the client when the first data is sent + * @since 8.0.0 + */ +interface IEventSource { + /** + * send a message to the client + * + * @param string $type + * @param mixed $data + * + * if only one parameter is given, a typeless message will be send with that parameter as data + * @since 8.0.0 + */ + public function send($type, $data = null); + + /** + * close the connection of the event source + * @since 8.0.0 + */ + public function close(); +} diff --git a/lib/public/IGroup.php b/lib/public/IGroup.php new file mode 100644 index 00000000000..02f2ef201fd --- /dev/null +++ b/lib/public/IGroup.php @@ -0,0 +1,109 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface IGroup + * + * @package OCP + * @since 8.0.0 + */ +interface IGroup { + /** + * @return string + * @since 8.0.0 + */ + public function getGID(); + + /** + * get all users in the group + * + * @return \OCP\IUser[] + * @since 8.0.0 + */ + public function getUsers(); + + /** + * check if a user is in the group + * + * @param \OCP\IUser $user + * @return bool + * @since 8.0.0 + */ + public function inGroup($user); + + /** + * add a user to the group + * + * @param \OCP\IUser $user + * @since 8.0.0 + */ + public function addUser($user); + + /** + * remove a user from the group + * + * @param \OCP\IUser $user + * @since 8.0.0 + */ + public function removeUser($user); + + /** + * search for users in the group by userid + * + * @param string $search + * @param int $limit + * @param int $offset + * @return \OCP\IUser[] + * @since 8.0.0 + */ + public function searchUsers($search, $limit = null, $offset = null); + + /** + * returns the number of users matching the search string + * + * @param string $search + * @return int|bool + * @since 8.0.0 + */ + public function count($search = ''); + + /** + * search for users in the group by displayname + * + * @param string $search + * @param int $limit + * @param int $offset + * @return \OCP\IUser[] + * @since 8.0.0 + */ + public function searchDisplayName($search, $limit = null, $offset = null); + + /** + * delete the group + * + * @return bool + * @since 8.0.0 + */ + public function delete(); +} diff --git a/lib/public/IGroupManager.php b/lib/public/IGroupManager.php new file mode 100644 index 00000000000..cda40606f9d --- /dev/null +++ b/lib/public/IGroupManager.php @@ -0,0 +1,139 @@ + + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Lukas Reschke + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Class Manager + * + * Hooks available in scope \OC\Group: + * - preAddUser(\OC\Group\Group $group, \OC\User\User $user) + * - postAddUser(\OC\Group\Group $group, \OC\User\User $user) + * - preRemoveUser(\OC\Group\Group $group, \OC\User\User $user) + * - postRemoveUser(\OC\Group\Group $group, \OC\User\User $user) + * - preDelete(\OC\Group\Group $group) + * - postDelete(\OC\Group\Group $group) + * - preCreate(string $groupId) + * - postCreate(\OC\Group\Group $group) + * + * @package OC\Group + * @since 8.0.0 + */ +interface IGroupManager { + /** + * Checks whether a given backend is used + * + * @param string $backendClass Full classname including complete namespace + * @return bool + * @since 8.1.0 + */ + public function isBackendUsed($backendClass); + + /** + * @param \OCP\GroupInterface $backend + * @since 8.0.0 + */ + public function addBackend($backend); + + /** + * @since 8.0.0 + */ + public function clearBackends(); + + /** + * @param string $gid + * @return \OCP\IGroup + * @since 8.0.0 + */ + public function get($gid); + + /** + * @param string $gid + * @return bool + * @since 8.0.0 + */ + public function groupExists($gid); + + /** + * @param string $gid + * @return \OCP\IGroup + * @since 8.0.0 + */ + public function createGroup($gid); + + /** + * @param string $search + * @param int $limit + * @param int $offset + * @return \OCP\IGroup[] + * @since 8.0.0 + */ + public function search($search, $limit = null, $offset = null); + + /** + * @param \OCP\IUser|null $user + * @return \OCP\IGroup[] + * @since 8.0.0 + */ + public function getUserGroups($user); + + /** + * @param \OCP\IUser $user + * @return array with group names + * @since 8.0.0 + */ + public function getUserGroupIds($user); + + /** + * 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) + * @since 8.0.0 + */ + public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0); + + /** + * Checks if a userId is in the admin group + * @param string $userId + * @return bool if admin + * @since 8.0.0 + */ + public function isAdmin($userId); + + /** + * Checks if a userId is in a group + * @param string $userId + * @param string $group + * @return bool if in group + * @since 8.0.0 + */ + public function isInGroup($userId, $group); +} diff --git a/lib/public/IHelper.php b/lib/public/IHelper.php new file mode 100644 index 00000000000..4ad1d5704fd --- /dev/null +++ b/lib/public/IHelper.php @@ -0,0 +1,49 @@ + + * @author Lukas Reschke + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Helper interface + * + */ + +// 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; + +/** + * Functions that don't have any specific interface to place + * @since 6.0.0 + * @deprecated 8.1.0 + */ +interface IHelper { + /** + * Gets the content of an URL by using CURL or a fallback if it is not + * installed + * @param string $url the url that should be fetched + * @return string the content of the webpage + * @since 6.0.0 + * @deprecated 8.1.0 Use \OCP\IServerContainer::getHTTPClientService + */ + public function getUrlContent($url); +} diff --git a/lib/public/IImage.php b/lib/public/IImage.php new file mode 100644 index 00000000000..db0ca0f93be --- /dev/null +++ b/lib/public/IImage.php @@ -0,0 +1,185 @@ + + * @author Morris Jobke + * @author Olivier Paroz + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Class for basic image manipulation + * @since 8.1.0 + */ +interface IImage { + /** + * Determine whether the object contains an image resource. + * + * @return bool + * @since 8.1.0 + */ + public function valid(); + + /** + * Returns the MIME type of the image or an empty string if no image is loaded. + * + * @return string + * @since 8.1.0 + */ + public function mimeType(); + + /** + * Returns the width of the image or -1 if no image is loaded. + * + * @return int + * @since 8.1.0 + */ + public function width(); + + /** + * Returns the height of the image or -1 if no image is loaded. + * + * @return int + * @since 8.1.0 + */ + public function height(); + + /** + * Returns the width when the image orientation is top-left. + * + * @return int + * @since 8.1.0 + */ + public function widthTopLeft(); + + /** + * Returns the height when the image orientation is top-left. + * + * @return int + * @since 8.1.0 + */ + public function heightTopLeft(); + + /** + * Outputs the image. + * + * @param string $mimeType + * @return bool + * @since 8.1.0 + */ + public function show($mimeType = null); + + /** + * Saves the image. + * + * @param string $filePath + * @param string $mimeType + * @return bool + * @since 8.1.0 + */ + public function save($filePath = null, $mimeType = null); + + /** + * @return resource Returns the image resource in any. + * @since 8.1.0 + */ + public function resource(); + + /** + * @return string Returns the raw image data. + * @since 8.1.0 + */ + public function data(); + + /** + * (I'm open for suggestions on better method name ;) + * Get the orientation based on EXIF data. + * + * @return int The orientation or -1 if no EXIF data is available. + * @since 8.1.0 + */ + public function getOrientation(); + + /** + * (I'm open for suggestions on better method name ;) + * Fixes orientation based on EXIF data. + * + * @return bool + * @since 8.1.0 + */ + public function fixOrientation(); + + /** + * Resizes the image preserving ratio. + * + * @param integer $maxSize The maximum size of either the width or height. + * @return bool + * @since 8.1.0 + */ + public function resize($maxSize); + + /** + * @param int $width + * @param int $height + * @return bool + * @since 8.1.0 + */ + public function preciseResize($width, $height); + + /** + * Crops the image to the middle square. If the image is already square it just returns. + * + * @param int $size maximum size for the result (optional) + * @return bool for success or failure + * @since 8.1.0 + */ + public function centerCrop($size = 0); + + /** + * Crops the image from point $x$y with dimension $wx$h. + * + * @param int $x Horizontal position + * @param int $y Vertical position + * @param int $w Width + * @param int $h Height + * @return bool for success or failure + * @since 8.1.0 + */ + public function crop($x, $y, $w, $h); + + /** + * Resizes the image to fit within a boundary while preserving ratio. + * + * @param integer $maxWidth + * @param integer $maxHeight + * @return bool + * @since 8.1.0 + */ + public function fitIn($maxWidth, $maxHeight); + + /** + * Shrinks the image to fit within a boundary while preserving ratio. + * + * @param integer $maxWidth + * @param integer $maxHeight + * @return bool + * @since 8.1.0 + */ + public function scaleDownToFit($maxWidth, $maxHeight); +} diff --git a/lib/public/IL10N.php b/lib/public/IL10N.php new file mode 100644 index 00000000000..f1954eeb4b9 --- /dev/null +++ b/lib/public/IL10N.php @@ -0,0 +1,110 @@ + + * @author Bernhard Posselt + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * @author Robin McCorkell + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * L10n interface + * + */ + +// 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; + +/** + * Interface IL10N + * + * @package OCP + * @since 6.0.0 + */ +interface IL10N { + /** + * Translating + * @param string $text The text we need a translation for + * @param array $parameters default:array() Parameters for sprintf + * @return \OC_L10N_String Translation or the same text + * + * Returns the translation. If no translation is found, $text will be + * returned. + * @since 6.0.0 + */ + public function t($text, $parameters = array()); + + /** + * Translating + * @param string $text_singular the string to translate for exactly one object + * @param string $text_plural the string to translate for n objects + * @param integer $count Number of objects + * @param array $parameters default:array() Parameters for sprintf + * @return \OC_L10N_String Translation or the same text + * + * Returns the translation. If no translation is found, $text will be + * returned. %n will be replaced with the number of objects. + * + * The correct plural is determined by the plural_forms-function + * provided by the po file. + * @since 6.0.0 + * + */ + public function n($text_singular, $text_plural, $count, $parameters = array()); + + /** + * Localization + * @param string $type Type of localization + * @param int|string $data parameters for this localization + * @param array $options currently supports following options: + * - 'width': handed into \Punic\Calendar::formatDate as second parameter + * @return string|false + * + * Returns the localized data. + * + * Implemented types: + * - date + * - Creates a date + * - l10n-field: date + * - params: timestamp (int/string) + * - datetime + * - Creates date and time + * - l10n-field: datetime + * - params: timestamp (int/string) + * - time + * - Creates a time + * - l10n-field: time + * - params: timestamp (int/string) + * @since 6.0.0 - parameter $options was added in 8.0.0 + */ + public function l($type, $data, $options = array()); + + + /** + * The code (en, de, ...) of the language that is used for this IL10N object + * + * @return string language + * @since 7.0.0 + */ + public function getLanguageCode(); +} diff --git a/lib/public/ILogger.php b/lib/public/ILogger.php new file mode 100644 index 00000000000..fa947612fcd --- /dev/null +++ b/lib/public/ILogger.php @@ -0,0 +1,144 @@ + + * @author Morris Jobke + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface ILogger + * @package OCP + * @since 7.0.0 + * + * This logger interface follows the design guidelines of PSR-3 + * https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#3-psrlogloggerinterface + */ +interface ILogger { + /** + * System is unusable. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function emergency($message, array $context = array()); + + /** + * Action must be taken immediately. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function alert($message, array $context = array()); + + /** + * Critical conditions. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function critical($message, array $context = array()); + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function error($message, array $context = array()); + + /** + * Exceptional occurrences that are not errors. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function warning($message, array $context = array()); + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function notice($message, array $context = array()); + + /** + * Interesting events. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function info($message, array $context = array()); + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + * @return null + * @since 7.0.0 + */ + public function debug($message, array $context = array()); + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * @return mixed + * @since 7.0.0 + */ + public function log($level, $message, array $context = array()); + + /** + * Logs an exception very detailed + * An additional message can we written to the log by adding it to the + * context. + * + * + * $logger->logException($ex, [ + * 'message' => 'Exception during cron job execution' + * ]); + * + * + * @param \Exception | \Throwable $exception + * @param array $context + * @return void + * @since 8.2.0 + */ + public function logException($exception, array $context = array()); +} diff --git a/lib/public/IMemcache.php b/lib/public/IMemcache.php new file mode 100644 index 00000000000..b5c0cef923d --- /dev/null +++ b/lib/public/IMemcache.php @@ -0,0 +1,90 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Cache interface + * + */ + +// 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; + +/** + * This interface defines method for accessing the file based user cache. + * + * @since 8.1.0 + */ +interface IMemcache extends ICache { + /** + * Set a value in the cache if it's not already stored + * + * @param string $key + * @param mixed $value + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 + * @return bool + * @since 8.1.0 + */ + public function add($key, $value, $ttl = 0); + + /** + * Increase a stored number + * + * @param string $key + * @param int $step + * @return int | bool + * @since 8.1.0 + */ + public function inc($key, $step = 1); + + /** + * Decrease a stored number + * + * @param string $key + * @param int $step + * @return int | bool + * @since 8.1.0 + */ + public function dec($key, $step = 1); + + /** + * Compare and set + * + * @param string $key + * @param mixed $old + * @param mixed $new + * @return bool + * @since 8.1.0 + */ + public function cas($key, $old, $new); + + /** + * Compare and delete + * + * @param string $key + * @param mixed $old + * @return bool + * @since 8.1.0 + */ + public function cad($key, $old); +} diff --git a/lib/public/IMemcacheTTL.php b/lib/public/IMemcacheTTL.php new file mode 100644 index 00000000000..f2d03dcdf40 --- /dev/null +++ b/lib/public/IMemcacheTTL.php @@ -0,0 +1,39 @@ + + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface for memcache backends that support setting ttl after the value is set + * + * @since 8.2.2 + */ +interface IMemcacheTTL extends IMemcache { + /** + * Set the ttl for an existing value + * + * @param string $key + * @param int $ttl time to live in seconds + * @since 8.2.2 + */ + public function setTTL($key, $ttl); +} diff --git a/lib/public/INavigationManager.php b/lib/public/INavigationManager.php new file mode 100644 index 00000000000..243f6ea3eea --- /dev/null +++ b/lib/public/INavigationManager.php @@ -0,0 +1,59 @@ + + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Navigation manager interface + * + */ + +// 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; + +/** + * Manages the ownCloud navigation + * @since 6.0.0 + */ +interface INavigationManager { + /** + * Creates a new navigation entry + * + * @param array|\Closure $entry Array containing: id, name, order, icon and href key + * The use of a closure is preferred, because it will avoid + * loading the routing of your app, unless required. + * @return void + * @since 6.0.0 + */ + public function add($entry); + + /** + * Sets the current navigation entry of the currently running app + * @param string $appId id of the app entry to activate (from added $entry) + * @return void + * @since 6.0.0 + */ + public function setActiveEntry($appId); +} diff --git a/lib/public/IPreview.php b/lib/public/IPreview.php new file mode 100644 index 00000000000..cfcbebd8639 --- /dev/null +++ b/lib/public/IPreview.php @@ -0,0 +1,95 @@ + + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Preview interface + * + */ + +// 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; + +/** + * This class provides functions to render and show thumbnails and previews of files + * @since 6.0.0 + */ +interface IPreview { + /** + * In order to improve lazy loading a closure can be registered which will be + * called in case preview providers are actually requested + * + * $callable has to return an instance of \OCP\Preview\IProvider + * + * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider + * @param \Closure $callable + * @return void + * @since 8.1.0 + */ + public function registerProvider($mimeTypeRegex, \Closure $callable); + + /** + * Get all providers + * @return array + * @since 8.1.0 + */ + public function getProviders(); + + /** + * Does the manager have any providers + * @return bool + * @since 8.1.0 + */ + public function hasProviders(); + + /** + * Return a preview of a file + * @param string $file The path to the file where you want a thumbnail from + * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image + * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image + * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly + * @return \OCP\IImage + * @since 6.0.0 + */ + public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false); + + + /** + * Returns true if the passed mime type is supported + * @param string $mimeType + * @return boolean + * @since 6.0.0 + */ + public function isMimeSupported($mimeType = '*'); + + /** + * Check if a preview can be generated for a file + * + * @param \OCP\Files\FileInfo $file + * @return bool + * @since 8.0.0 + */ + public function isAvailable(\OCP\Files\FileInfo $file); +} diff --git a/lib/public/IRequest.php b/lib/public/IRequest.php new file mode 100644 index 00000000000..296c70f4ecc --- /dev/null +++ b/lib/public/IRequest.php @@ -0,0 +1,245 @@ + + * @author Jörn Friedrich Dreyer + * @author Lukas Reschke + * @author Morris Jobke + * @author Thomas Müller + * @author Thomas Tanghus + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Request interface + * + */ + +// 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; + +/** + * This interface provides an immutable object with with accessors to + * request variables and headers. + * + * Access request variables by method and name. + * + * Examples: + * + * $request->post['myvar']; // Only look for POST variables + * $request->myvar; or $request->{'myvar'}; or $request->{$myvar} + * Looks in the combined GET, POST and urlParams array. + * + * If you access e.g. ->post but the current HTTP request method + * is GET a \LogicException will be thrown. + * + * NOTE: + * - When accessing ->put a stream resource is returned and the accessor + * will return false on subsequent access to ->put or ->patch. + * - When accessing ->patch and the Content-Type is either application/json + * or application/x-www-form-urlencoded (most cases) it will act like ->get + * and ->post and return an array. Otherwise the raw data will be returned. + * + * @property-read string[] $server + * @property-read string[] $urlParams + * @since 6.0.0 + */ +interface IRequest { + + /** + * @param string $name + * + * @return string + * @since 6.0.0 + */ + public function getHeader($name); + + /** + * Lets you access post and get parameters by the index + * In case of json requests the encoded json body is accessed + * + * @param string $key the key which you want to access in the URL Parameter + * placeholder, $_POST or $_GET array. + * The priority how they're returned is the following: + * 1. URL parameters + * 2. POST parameters + * 3. GET parameters + * @param mixed $default If the key is not found, this value will be returned + * @return mixed the content of the array + * @since 6.0.0 + */ + public function getParam($key, $default = null); + + + /** + * Returns all params that were received, be it from the request + * + * (as GET or POST) or through the URL by the route + * + * @return array the array with all parameters + * @since 6.0.0 + */ + public function getParams(); + + /** + * Returns the method of the request + * + * @return string the method of the request (POST, GET, etc) + * @since 6.0.0 + */ + public function getMethod(); + + /** + * Shortcut for accessing an uploaded file through the $_FILES array + * + * @param string $key the key that will be taken from the $_FILES array + * @return array the file in the $_FILES element + * @since 6.0.0 + */ + public function getUploadedFile($key); + + + /** + * Shortcut for getting env variables + * + * @param string $key the key that will be taken from the $_ENV array + * @return array the value in the $_ENV element + * @since 6.0.0 + */ + public function getEnv($key); + + + /** + * Shortcut for getting cookie variables + * + * @param string $key the key that will be taken from the $_COOKIE array + * @return string the value in the $_COOKIE element + * @since 6.0.0 + */ + public function getCookie($key); + + + /** + * Checks if the CSRF check was correct + * + * @return bool true if CSRF check passed + * @since 6.0.0 + */ + public function passesCSRFCheck(); + + /** + * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging + * If `mod_unique_id` is installed this value will be taken. + * + * @return string + * @since 8.1.0 + */ + public function getId(); + + /** + * Returns the remote address, if the connection came from a trusted proxy + * and `forwarded_for_headers` has been configured then the IP address + * specified in this header will be returned instead. + * Do always use this instead of $_SERVER['REMOTE_ADDR'] + * + * @return string IP address + * @since 8.1.0 + */ + public function getRemoteAddress(); + + /** + * Returns the server protocol. It respects reverse proxy servers and load + * balancers. + * + * @return string Server protocol (http or https) + * @since 8.1.0 + */ + public function getServerProtocol(); + + /** + * Returns the used HTTP protocol. + * + * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. + * @since 8.2.0 + */ + public function getHttpProtocol(); + + /** + * Returns the request uri, even if the website uses one or more + * reverse proxies + * + * @return string + * @since 8.1.0 + */ + public function getRequestUri(); + + /** + * Get raw PathInfo from request (not urldecoded) + * + * @throws \Exception + * @return string Path info + * @since 8.1.0 + */ + public function getRawPathInfo(); + + /** + * Get PathInfo from request + * + * @throws \Exception + * @return string|false Path info or false when not found + * @since 8.1.0 + */ + public function getPathInfo(); + + /** + * Returns the script name, even if the website uses one or more + * reverse proxies + * + * @return string the script name + * @since 8.1.0 + */ + public function getScriptName(); + + /** + * Checks whether the user agent matches a given regex + * + * @param array $agent array of agent names + * @return bool true if at least one of the given agent matches, false otherwise + * @since 8.1.0 + */ + public function isUserAgent(array $agent); + + /** + * Returns the unverified server host from the headers without checking + * whether it is a trusted domain + * + * @return string Server host + * @since 8.1.0 + */ + public function getInsecureServerHost(); + + /** + * Returns the server host from the headers, or the first configured + * trusted domain if the host isn't in the trusted list + * + * @return string Server host + * @since 8.1.0 + */ + public function getServerHost(); +} diff --git a/lib/public/ISearch.php b/lib/public/ISearch.php new file mode 100644 index 00000000000..ec6673dabbd --- /dev/null +++ b/lib/public/ISearch.php @@ -0,0 +1,77 @@ + + * @author Bart Visscher + * @author Jakob Sack + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + + +/** + * Small Interface for Search + * @since 7.0.0 + */ +interface ISearch { + + /** + * Search all providers for $query + * @param string $query + * @param string[] $inApps optionally limit results to the given apps + * @return array An array of OCP\Search\Result's + * @deprecated 8.0.0 use searchPaged() with page and size + * @since 7.0.0 - parameter $inApps was added in 8.0.0 + */ + public function search($query, array $inApps = array()); + + /** + * Search all providers for $query + * @param string $query + * @param string[] $inApps optionally limit results to the given apps + * @param int $page pages start at page 1 + * @param int $size + * @return array An array of OCP\Search\Result's + * @since 8.0.0 + */ + public function searchPaged($query, array $inApps = array(), $page = 1, $size = 30); + + /** + * Register a new search provider to search with + * @param string $class class name of a OCP\Search\Provider + * @param array $options optional + * @since 7.0.0 + */ + public function registerProvider($class, array $options = array()); + + /** + * Remove one existing search provider + * @param string $provider class name of a OCP\Search\Provider + * @since 7.0.0 + */ + public function removeProvider($provider); + + /** + * Remove all registered search providers + * @since 7.0.0 + */ + public function clearProviders(); + +} diff --git a/lib/public/ISession.php b/lib/public/ISession.php new file mode 100644 index 00000000000..7bc8654a1b9 --- /dev/null +++ b/lib/public/ISession.php @@ -0,0 +1,107 @@ + + * @author Morris Jobke + * @author Thomas Müller + * @author Thomas Tanghus + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Session interface + * + */ + +// 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; + +/** + * Interface ISession + * + * wrap PHP's internal session handling into the ISession interface + * @since 6.0.0 + */ +interface ISession { + + /** + * Set a value in the session + * + * @param string $key + * @param mixed $value + * @since 6.0.0 + */ + public function set($key, $value); + + /** + * Get a value from the session + * + * @param string $key + * @return mixed should return null if $key does not exist + * @since 6.0.0 + */ + public function get($key); + + /** + * Check if a named key exists in the session + * + * @param string $key + * @return bool + * @since 6.0.0 + */ + public function exists($key); + + /** + * Remove a $key/$value pair from the session + * + * @param string $key + * @since 6.0.0 + */ + public function remove($key); + + /** + * Reset and recreate the session + * @since 6.0.0 + */ + public function clear(); + + /** + * Close the session and release the lock + * @since 7.0.0 + */ + public function close(); + + /** + * Wrapper around session_regenerate_id + * + * @param bool $deleteOldSession Whether to delete the old associated session file or not. + * @return void + * @since 9.0.0 + */ + public function regenerateId($deleteOldSession = true); + + /** + * Wrapper around session_id + * + * @return string + * @throws SessionNotAvailableException + * @since 9.1.0 + */ + public function getId(); +} diff --git a/lib/public/ITagManager.php b/lib/public/ITagManager.php new file mode 100644 index 00000000000..e6d67ddd02c --- /dev/null +++ b/lib/public/ITagManager.php @@ -0,0 +1,61 @@ + + * @author Morris Jobke + * @author Thomas Tanghus + * @author Vincent Petry + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Tag manager interface + * + */ + +// 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; + +/** + * Factory class creating instances of \OCP\ITags + * + * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or + * anything else that is either parsed from a vobject or that the user chooses + * to add. + * Tag names are not case-sensitive, but will be saved with the case they + * are entered in. If a user already has a tag 'family' for a type, and + * tries to add a tag named 'Family' it will be silently ignored. + * @since 6.0.0 + */ +interface ITagManager { + + /** + * Create a new \OCP\ITags instance and load tags from db for the current user. + * + * @see \OCP\ITags + * @param string $type The type identifier e.g. 'contact' or 'event'. + * @param array $defaultTags An array of default tags to be used if none are stored. + * @param boolean $includeShared Whether to include tags for items shared with this user by others. + * @param string $userId user for which to retrieve the tags, defaults to the currently + * logged in user + * @return \OCP\ITags + * @since 6.0.0 - parameter $includeShared and $userId were added in 8.0.0 + */ + public function load($type, $defaultTags = array(), $includeShared = false, $userId = null); +} diff --git a/lib/public/ITags.php b/lib/public/ITags.php new file mode 100644 index 00000000000..cbc178c37bf --- /dev/null +++ b/lib/public/ITags.php @@ -0,0 +1,227 @@ + + * @author Morris Jobke + * @author Thomas Tanghus + * @author Vincent Petry + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Tags interface + * + */ + +// 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; + +// FIXME: Where should I put this? Or should it be implemented as a Listener? +\OC_Hook::connect('OC_User', 'post_deleteUser', 'OC\Tags', 'post_deleteUser'); + +/** + * Class for easily tagging objects by their id + * + * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or + * anything else that is either parsed from a vobject or that the user chooses + * to add. + * Tag names are not case-sensitive, but will be saved with the case they + * are entered in. If a user already has a tag 'family' for a type, and + * tries to add a tag named 'Family' it will be silently ignored. + * @since 6.0.0 + */ + +interface ITags { + + /** + * Check if any tags are saved for this type and user. + * + * @return boolean + * @since 6.0.0 + */ + public function isEmpty(); + + /** + * Returns an array mapping a given tag's properties to its values: + * ['id' => 0, 'name' = 'Tag', 'owner' = 'User', 'type' => 'tagtype'] + * + * @param string $id The ID of the tag that is going to be mapped + * @return array|false + * @since 8.0.0 + */ + public function getTag($id); + + /** + * Get the tags for a specific user. + * + * This returns an array with id/name maps: + * [ + * ['id' => 0, 'name' = 'First tag'], + * ['id' => 1, 'name' = 'Second tag'], + * ] + * + * @return array + * @since 6.0.0 + */ + public function getTags(); + + /** + * Get a list of tags for the given item ids. + * + * This returns an array with object id / tag names: + * [ + * 1 => array('First tag', 'Second tag'), + * 2 => array('Second tag'), + * 3 => array('Second tag', 'Third tag'), + * ] + * + * @param array $objIds item ids + * @return array|boolean with object id as key and an array + * of tag names as value or false if an error occurred + * @since 8.0.0 + */ + public function getTagsForObjects(array $objIds); + + /** + * Get a list of items tagged with $tag. + * + * Throws an exception if the tag could not be found. + * + * @param string|integer $tag Tag id or name. + * @return array|false An array of object ids or false on error. + * @since 6.0.0 + */ + public function getIdsForTag($tag); + + /** + * Checks whether a tag is already saved. + * + * @param string $name The name to check for. + * @return bool + * @since 6.0.0 + */ + public function hasTag($name); + + /** + * Checks whether a tag is saved for the given user, + * disregarding the ones shared with him or her. + * + * @param string $name The tag name to check for. + * @param string $user The user whose tags are to be checked. + * @return bool + * @since 8.0.0 + */ + public function userHasTag($name, $user); + + /** + * Add a new tag. + * + * @param string $name A string with a name of the tag + * @return int|false the id of the added tag or false if it already exists. + * @since 6.0.0 + */ + public function add($name); + + /** + * Rename tag. + * + * @param string|integer $from The name or ID of the existing tag + * @param string $to The new name of the tag. + * @return bool + * @since 6.0.0 + */ + public function rename($from, $to); + + /** + * Add a list of new tags. + * + * @param string[] $names A string with a name or an array of strings containing + * the name(s) of the to add. + * @param bool $sync When true, save the tags + * @param int|null $id int Optional object id to add to this|these tag(s) + * @return bool Returns false on error. + * @since 6.0.0 + */ + public function addMultiple($names, $sync=false, $id = null); + + /** + * Delete tag/object relations from the db + * + * @param array $ids The ids of the objects + * @return boolean Returns false on error. + * @since 6.0.0 + */ + public function purgeObjects(array $ids); + + /** + * Get favorites for an object type + * + * @return array|false An array of object ids. + * @since 6.0.0 + */ + public function getFavorites(); + + /** + * Add an object to favorites + * + * @param int $objid The id of the object + * @return boolean + * @since 6.0.0 + */ + public function addToFavorites($objid); + + /** + * Remove an object from favorites + * + * @param int $objid The id of the object + * @return boolean + * @since 6.0.0 + */ + public function removeFromFavorites($objid); + + /** + * Creates a tag/object relation. + * + * @param int $objid The id of the object + * @param string $tag The id or name of the tag + * @return boolean Returns false on database error. + * @since 6.0.0 + */ + public function tagAs($objid, $tag); + + /** + * Delete single tag/object relation from the db + * + * @param int $objid The id of the object + * @param string $tag The id or name of the tag + * @return boolean + * @since 6.0.0 + */ + public function unTag($objid, $tag); + + /** + * Delete tags from the database + * + * @param string[]|integer[] $names An array of tags (names or IDs) to delete + * @return bool Returns false on error + * @since 6.0.0 + */ + public function delete($names); + +} diff --git a/lib/public/ITempManager.php b/lib/public/ITempManager.php new file mode 100644 index 00000000000..025e43d8563 --- /dev/null +++ b/lib/public/ITempManager.php @@ -0,0 +1,70 @@ + + * @author Robin Appelman + * @author Robin McCorkell + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface ITempManager + * + * @package OCP + * @since 8.0.0 + */ +interface ITempManager { + /** + * Create a temporary file and return the path + * + * @param string $postFix + * @return string + * @since 8.0.0 + */ + public function getTemporaryFile($postFix = ''); + + /** + * Create a temporary folder and return the path + * + * @param string $postFix + * @return string + * @since 8.0.0 + */ + public function getTemporaryFolder($postFix = ''); + + /** + * Remove the temporary files and folders generated during this request + * @since 8.0.0 + */ + public function clean(); + + /** + * Remove old temporary files and folders that were failed to be cleaned + * @since 8.0.0 + */ + public function cleanOld(); + + /** + * Get the temporary base directory + * + * @return string + * @since 8.2.0 + */ + public function getTempBaseDir(); +} diff --git a/lib/public/IURLGenerator.php b/lib/public/IURLGenerator.php new file mode 100644 index 00000000000..a702ca47bfc --- /dev/null +++ b/lib/public/IURLGenerator.php @@ -0,0 +1,93 @@ + + * @author Joas Schilling + * @author Morris Jobke + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * URL generator interface + * + */ + +// 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; + +/** + * Class to generate URLs + * @since 6.0.0 + */ +interface IURLGenerator { + /** + * Returns the URL for a route + * @param string $routeName the name of the route + * @param array $arguments an array with arguments which will be filled into the url + * @return string the url + * @since 6.0.0 + */ + public function linkToRoute($routeName, $arguments = array()); + + /** + * Returns the absolute URL for a route + * @param string $routeName the name of the route + * @param array $arguments an array with arguments which will be filled into the url + * @return string the absolute url + * @since 8.0.0 + */ + public function linkToRouteAbsolute($routeName, $arguments = array()); + + /** + * Returns an URL for an image or file + * @param string $appName the name of the app + * @param string $file the name of the file + * @param array $args array with param=>value, will be appended to the returned url + * The value of $args will be urlencoded + * @return string the url + * @since 6.0.0 + */ + public function linkTo($appName, $file, $args = array()); + + /** + * Returns the link to an image, like linkTo but only with prepending img/ + * @param string $appName the name of the app + * @param string $file the name of the file + * @return string the url + * @since 6.0.0 + */ + public function imagePath($appName, $file); + + + /** + * Makes an URL absolute + * @param string $url the url in the ownCloud host + * @return string the absolute version of the url + * @since 6.0.0 + */ + public function getAbsoluteURL($url); + + /** + * @param string $key + * @return string url to the online documentation + * @since 8.0.0 + */ + public function linkToDocs($key); +} diff --git a/lib/public/IUser.php b/lib/public/IUser.php new file mode 100644 index 00000000000..16617a2f2f6 --- /dev/null +++ b/lib/public/IUser.php @@ -0,0 +1,202 @@ + + * @author Lukas Reschke + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + +/** + * Interface IUser + * + * @package OCP + * @since 8.0.0 + */ +interface IUser { + + /** + * get the user id + * + * @return string + * @since 8.0.0 + */ + public function getUID(); + + /** + * get the display name for the user, if no specific display name is set it will fallback to the user id + * + * @return string + * @since 8.0.0 + */ + public function getDisplayName(); + + /** + * set the display name for the user + * + * @param string $displayName + * @return bool + * @since 8.0.0 + */ + public function setDisplayName($displayName); + + /** + * returns the timestamp of the user's last login or 0 if the user did never + * login + * + * @return int + * @since 8.0.0 + */ + public function getLastLogin(); + + /** + * updates the timestamp of the most recent login of this user + * @since 8.0.0 + */ + public function updateLastLoginTimestamp(); + + /** + * Delete the user + * + * @return bool + * @since 8.0.0 + */ + public function delete(); + + /** + * Set the password of the user + * + * @param string $password + * @param string $recoveryPassword for the encryption app to reset encryption keys + * @return bool + * @since 8.0.0 + */ + public function setPassword($password, $recoveryPassword = null); + + /** + * get the users home folder to mount + * + * @return string + * @since 8.0.0 + */ + public function getHome(); + + /** + * Get the name of the backend class the user is connected with + * + * @return string + * @since 8.0.0 + */ + public function getBackendClassName(); + + /** + * check if the backend allows the user to change his avatar on Personal page + * + * @return bool + * @since 8.0.0 + */ + public function canChangeAvatar(); + + /** + * check if the backend supports changing passwords + * + * @return bool + * @since 8.0.0 + */ + public function canChangePassword(); + + /** + * check if the backend supports changing display names + * + * @return bool + * @since 8.0.0 + */ + public function canChangeDisplayName(); + + /** + * check if the user is enabled + * + * @return bool + * @since 8.0.0 + */ + public function isEnabled(); + + /** + * set the enabled status for the user + * + * @param bool $enabled + * @since 8.0.0 + */ + public function setEnabled($enabled); + + /** + * get the users email address + * + * @return string|null + * @since 9.0.0 + */ + public function getEMailAddress(); + + /** + * get the avatar image if it exists + * + * @param int $size + * @return IImage|null + * @since 9.0.0 + */ + public function getAvatarImage($size); + + /** + * get the federation cloud id + * + * @return string + * @since 9.0.0 + */ + public function getCloudId(); + + /** + * set the email address of the user + * + * @param string|null $mailAddress + * @return void + * @since 9.0.0 + */ + public function setEMailAddress($mailAddress); + + /** + * get the users' quota in human readable form. If a specific quota is not + * set for the user, the default value is returned. If a default setting + * was not set otherwise, it is return as 'none', i.e. quota is not limited. + * + * @return string + * @since 9.0.0 + */ + public function getQuota(); + + /** + * set the users' quota + * + * @param string $quota + * @return void + * @since 9.0.0 + */ + public function setQuota($quota); +} diff --git a/lib/public/IUserBackend.php b/lib/public/IUserBackend.php new file mode 100644 index 00000000000..5cd7945dd7a --- /dev/null +++ b/lib/public/IUserBackend.php @@ -0,0 +1,47 @@ + + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * User Interface version 2 + * + */ + +// 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; + +/** + * Interface IUserBackend + * + * @package OCP + * @since 8.0.0 + */ +interface IUserBackend { + + /** + * Backend name to be shown in user management + * @return string the name of the backend to be shown + * @since 8.0.0 + */ + public function getBackendName(); + +} diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php new file mode 100644 index 00000000000..00c0bbc8721 --- /dev/null +++ b/lib/public/IUserManager.php @@ -0,0 +1,152 @@ + + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + + +/** + * Class Manager + * + * Hooks available in scope \OC\User: + * - preSetPassword(\OC\User\User $user, string $password, string $recoverPassword) + * - postSetPassword(\OC\User\User $user, string $password, string $recoverPassword) + * - preDelete(\OC\User\User $user) + * - postDelete(\OC\User\User $user) + * - preCreateUser(string $uid, string $password) + * - postCreateUser(\OC\User\User $user, string $password) + * + * @package OC\User + * @since 8.0.0 + */ +interface IUserManager { + /** + * register a user backend + * + * @param \OCP\UserInterface $backend + * @since 8.0.0 + */ + public function registerBackend($backend); + + /** + * Get the active backends + * @return \OCP\UserInterface[] + * @since 8.0.0 + */ + public function getBackends(); + + /** + * remove a user backend + * + * @param \OCP\UserInterface $backend + * @since 8.0.0 + */ + public function removeBackend($backend); + + /** + * remove all user backends + * @since 8.0.0 + */ + public function clearBackends() ; + + /** + * get a user by user id + * + * @param string $uid + * @return \OCP\IUser|null Either the user or null if the specified user does not exist + * @since 8.0.0 + */ + public function get($uid); + + /** + * check if a user exists + * + * @param string $uid + * @return bool + * @since 8.0.0 + */ + public function userExists($uid); + + /** + * Check if the password is valid for the user + * + * @param string $loginName + * @param string $password + * @return mixed the User object on success, false otherwise + * @since 8.0.0 + */ + public function checkPassword($loginName, $password); + + /** + * search by user id + * + * @param string $pattern + * @param int $limit + * @param int $offset + * @return \OCP\IUser[] + * @since 8.0.0 + */ + public function search($pattern, $limit = null, $offset = null); + + /** + * search by displayName + * + * @param string $pattern + * @param int $limit + * @param int $offset + * @return \OCP\IUser[] + * @since 8.0.0 + */ + public function searchDisplayName($pattern, $limit = null, $offset = null); + + /** + * @param string $uid + * @param string $password + * @throws \Exception + * @return bool|\OCP\IUser the created user of false + * @since 8.0.0 + */ + public function createUser($uid, $password); + + /** + * returns how many users per backend exist (if supported by backend) + * + * @return array an array of backend class as key and count number as value + * @since 8.0.0 + */ + public function countUsers(); + + /** + * @param \Closure $callback + * @param string $search + * @since 9.0.0 + */ + public function callForAllUsers (\Closure $callback, $search = ''); + + /** + * @param string $email + * @return IUser[] + * @since 9.1.0 + */ + public function getByEmail($email); +} diff --git a/lib/public/IUserSession.php b/lib/public/IUserSession.php new file mode 100644 index 00000000000..2196f2c8ce0 --- /dev/null +++ b/lib/public/IUserSession.php @@ -0,0 +1,82 @@ + + * @author Bernhard Posselt + * @author Jörn Friedrich Dreyer + * @author Lukas Reschke + * @author Morris Jobke + * @author Robin Appelman + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * User session interface + * + */ + +// 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; + +/** + * User session + * @since 6.0.0 + */ +interface IUserSession { + /** + * Do a user login + * @param string $user the username + * @param string $password the password + * @return bool true if successful + * @since 6.0.0 + */ + public function login($user, $password); + + /** + * Logs the user out including all the session data + * Logout, destroys session + * @return void + * @since 6.0.0 + */ + public function logout(); + + /** + * set the currently active user + * + * @param \OCP\IUser|null $user + * @since 8.0.0 + */ + public function setUser($user); + + /** + * get the current active user + * + * @return \OCP\IUser|null Current user, otherwise null + * @since 8.0.0 + */ + public function getUser(); + + /** + * Checks whether the user is logged in + * + * @return bool if logged in + * @since 8.0.0 + */ + public function isLoggedIn(); +} diff --git a/lib/public/Image.php b/lib/public/Image.php new file mode 100644 index 00000000000..4a7ffe8bc9a --- /dev/null +++ b/lib/public/Image.php @@ -0,0 +1,39 @@ + + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Image class + * + */ + +// 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; + +/** + * This class provides functions to handle images + * @since 6.0.0 + */ +class Image extends \OC_Image { +} diff --git a/lib/public/JSON.php b/lib/public/JSON.php new file mode 100644 index 00000000000..fceffa0001e --- /dev/null +++ b/lib/public/JSON.php @@ -0,0 +1,196 @@ + + * @author Frank Karlitschek + * @author Lukas Reschke + * @author Morris Jobke + * @author Thomas Müller + * @author Thomas Tanghus + * @author Vincent Petry + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * JSON Class + */ + +// 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; + +/** + * This class provides convenient functions to generate and send JSON data. Useful for Ajax calls + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead + */ +class JSON { + /** + * Encode and print $data in JSON format + * @param array $data The data to use + * @param bool $setContentType the optional content type + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead + */ + public static function encodedPrint( $data, $setContentType=true ) { + \OC_JSON::encodedPrint($data, $setContentType); + } + + /** + * Check if the user is logged in, send json error msg if not. + * + * This method checks if a user is logged in. If not, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Authentication error."}} + * + * Add this call to the start of all ajax method files that requires + * an authenticated user. + * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead + */ + public static function checkLoggedIn() { + \OC_JSON::checkLoggedIn(); + } + + /** + * Check an ajax get/post call if the request token is valid. + * + * This method checks for a valid variable 'requesttoken' in $_GET, + * $_POST and $_SERVER. If a valid token is not found, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Token expired. Please reload page."}} + * + * Add this call to the start of all ajax method files that creates, + * updates or deletes anything. + * In cases where you e.g. use an ajax call to load a dialog containing + * a submittable form, you will need to add the requesttoken first as a + * parameter to the ajax call, then assign it to the template and finally + * add a hidden input field also named 'requesttoken' containing the value. + * @deprecated 8.1.0 Use annotation based CSRF checks from the AppFramework instead + */ + public static function callCheck() { + \OC_JSON::callCheck(); + } + + /** + * Send json success msg + * + * Return a json success message with optional extra data. + * @see OCP\JSON::error() for the format to use. + * + * @param array $data The data to use + * @return string json formatted string. + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead + */ + public static function success( $data = array() ) { + \OC_JSON::success($data); + } + + /** + * Send json error msg + * + * Return a json error message with optional extra data for + * error message or app specific data. + * + * Example use: + * + * $id = [some value] + * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id))); + * + * Will return the json formatted string: + * + * {"status":"error","data":{"message":"An error happened", "id":[some value]}} + * + * @param array $data The data to use + * @return string json formatted error string. + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead + */ + public static function error( $data = array() ) { + \OC_JSON::error( $data ); + } + + /** + * Set Content-Type header to jsonrequest + * @param string $type The content type header + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead + */ + public static function setContentTypeHeader( $type='application/json' ) { + \OC_JSON::setContentTypeHeader($type); + } + + /** + * Check if the App is enabled and send JSON error message instead + * + * This method checks if a specific app is enabled. If not, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Application is not enabled."}} + * + * Add this call to the start of all ajax method files that requires + * a specific app to be enabled. + * + * @param string $app The app to check + * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled. + */ + public static function checkAppEnabled( $app ) { + \OC_JSON::checkAppEnabled($app); + } + + /** + * Check if the user is a admin, send json error msg if not + * + * This method checks if the current user has admin rights. If not, a json error + * response will be return and the method will exit from execution + * of the script. + * The returned json will be in the format: + * + * {"status":"error","data":{"message":"Authentication error."}} + * + * Add this call to the start of all ajax method files that requires + * administrative rights. + * + * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead + */ + public static function checkAdminUser() { + \OC_JSON::checkAdminUser(); + } + + /** + * Encode JSON + * @param array $data + * @return string + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead + */ + public static function encode($data) { + return \OC_JSON::encode($data); + } + + /** + * Check is a given user exists - send json error msg if not + * @param string $user + * @deprecated 8.1.0 Use a AppFramework JSONResponse instead + */ + public static function checkUserExists($user) { + \OC_JSON::checkUserExists($user); + } +} diff --git a/lib/public/PreConditionNotMetException.php b/lib/public/PreConditionNotMetException.php new file mode 100644 index 00000000000..212efc08ded --- /dev/null +++ b/lib/public/PreConditionNotMetException.php @@ -0,0 +1,30 @@ + + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +// 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; + +/** + * Exception if the precondition of the config update method isn't met + * @since 8.0.0 + */ +class PreConditionNotMetException extends \Exception {} diff --git a/lib/public/Response.php b/lib/public/Response.php new file mode 100644 index 00000000000..a2a7667684a --- /dev/null +++ b/lib/public/Response.php @@ -0,0 +1,134 @@ + + * @author Bart Visscher + * @author Frank Karlitschek + * @author Lukas Reschke + * @author Morris Jobke + * @author Robin Appelman + * @author Thomas Müller + * @author Vincent Petry + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Response Class. + * + */ + +// 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; + +/** + * This class provides convenient functions to send the correct http response headers + * @since 4.0.0 + * @deprecated 8.1.0 - Use AppFramework controllers instead and modify the response object + */ +class Response { + /** + * Enable response caching by sending correct HTTP headers + * @param int $cache_time time to cache the response + * >0 cache time in seconds + * 0 and <0 enable default browser caching + * null cache indefinitely + * @since 4.0.0 + */ + static public function enableCaching( $cache_time = null ) { + \OC_Response::enableCaching( $cache_time ); + } + + /** + * Checks and set Last-Modified header, when the request matches sends a + * 'not modified' response + * @param string $lastModified time when the response was last modified + * @since 4.0.0 + */ + static public function setLastModifiedHeader( $lastModified ) { + \OC_Response::setLastModifiedHeader( $lastModified ); + } + + /** + * Sets the content disposition header (with possible workarounds) + * @param string $filename file name + * @param string $type disposition type, either 'attachment' or 'inline' + * @since 7.0.0 + */ + static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { + \OC_Response::setContentDispositionHeader( $filename, $type ); + } + + /** + * Sets the content length header (with possible workarounds) + * @param string|int|float $length Length to be sent + * @since 8.1.0 + */ + static public function setContentLengthHeader($length) { + \OC_Response::setContentLengthHeader($length); + } + + /** + * Disable browser caching + * @see enableCaching with cache_time = 0 + * @since 4.0.0 + */ + static public function disableCaching() { + \OC_Response::disableCaching(); + } + + /** + * Checks and set ETag header, when the request matches sends a + * 'not modified' response + * @param string $etag token to use for modification check + * @since 4.0.0 + */ + static public function setETagHeader( $etag ) { + \OC_Response::setETagHeader( $etag ); + } + + /** + * Send file as response, checking and setting caching headers + * @param string $filepath of file to send + * @since 4.0.0 + * @deprecated 8.1.0 - Use \OCP\AppFramework\Http\StreamResponse or another AppFramework controller instead + */ + static public function sendFile( $filepath ) { + \OC_Response::sendFile( $filepath ); + } + + /** + * Set response expire time + * @param string|\DateTime $expires date-time when the response expires + * string for DateInterval from now + * DateTime object when to expire response + * @since 4.0.0 + */ + static public function setExpiresHeader( $expires ) { + \OC_Response::setExpiresHeader( $expires ); + } + + /** + * Send redirect response + * @param string $location to redirect to + * @since 4.0.0 + */ + static public function redirect( $location ) { + \OC_Response::redirect( $location ); + } +} diff --git a/lib/public/SabrePluginEvent.php b/lib/public/SabrePluginEvent.php new file mode 100644 index 00000000000..11d939aee47 --- /dev/null +++ b/lib/public/SabrePluginEvent.php @@ -0,0 +1,96 @@ + + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + + +use OCP\AppFramework\Http; +use Sabre\DAV\Server; +use Symfony\Component\EventDispatcher\Event; + +/** + * @since 8.2.0 + */ +class SabrePluginEvent extends Event { + + /** @var int */ + protected $statusCode; + + /** @var string */ + protected $message; + + /** @var Server */ + protected $server; + + /** + * @since 8.2.0 + */ + public function __construct($server = null) { + $this->message = ''; + $this->statusCode = Http::STATUS_OK; + $this->server = $server; + } + + /** + * @param int $statusCode + * @return self + * @since 8.2.0 + */ + public function setStatusCode($statusCode) { + $this->statusCode = (int) $statusCode; + return $this; + } + + /** + * @param string $message + * @return self + * @since 8.2.0 + */ + public function setMessage($message) { + $this->message = (string) $message; + return $this; + } + + /** + * @return int + * @since 8.2.0 + */ + public function getStatusCode() { + return $this->statusCode; + } + + /** + * @return string + * @since 8.2.0 + */ + public function getMessage() { + return $this->message; + } + + /** + * @return null|Server + * @since 9.0.0 + */ + public function getServer() { + return $this->server; + } +} diff --git a/lib/public/SabrePluginException.php b/lib/public/SabrePluginException.php new file mode 100644 index 00000000000..2c5a799c4f7 --- /dev/null +++ b/lib/public/SabrePluginException.php @@ -0,0 +1,41 @@ + + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +namespace OCP; + + +use Sabre\DAV\Exception; + +/** + * @since 8.2.0 + */ +class SabrePluginException extends Exception { + + /** + * Returns the HTTP statuscode for this exception + * + * @return int + * @since 8.2.0 + */ + public function getHTTPCode() { + return $this->code; + } +} diff --git a/lib/public/Share.php b/lib/public/Share.php new file mode 100644 index 00000000000..9c62ec703e4 --- /dev/null +++ b/lib/public/Share.php @@ -0,0 +1,401 @@ + + * @author Bart Visscher + * @author Björn Schießle + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Michael Gapczynski + * @author Michael Kuhn + * @author Morris Jobke + * @author Robin McCorkell + * @author Roeland Jago Douma + * @author Sam Tuke + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Share Class + * + */ + +// 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; + +/** + * This class provides the ability for apps to share their content between users. + * Apps must create a backend class that implements OCP\Share_Backend and register it with this class. + * + * It provides the following hooks: + * - post_shared + * @since 5.0.0 + */ +class Share extends \OC\Share\Constants { + + /** + * Register a sharing backend class that implements OCP\Share_Backend for an item type + * @param string $itemType Item type + * @param string $class Backend class + * @param string $collectionOf (optional) Depends on item type + * @param array $supportedFileExtensions (optional) List of supported file extensions if this item type depends on files + * @return boolean true if backend is registered or false if error + * @since 5.0.0 + */ + public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) { + return \OC\Share\Share::registerBackend($itemType, $class, $collectionOf, $supportedFileExtensions); + } + + /** + * Check if the Share API is enabled + * @return boolean true if enabled or false + * + * The Share API is enabled by default if not configured + * @since 5.0.0 + */ + public static function isEnabled() { + return \OC\Share\Share::isEnabled(); + } + + /** + * Find which users can access a shared item + * @param string $path to the file + * @param string $ownerUser owner of the file + * @param bool $includeOwner include owner to the list of users with access to the file + * @param bool $returnUserPaths Return an array with the user => path map + * @param bool $recursive take parent folders into account + * @return array + * @note $path needs to be relative to user data dir, e.g. 'file.txt' + * not '/admin/files/file.txt' + * @since 5.0.0 - $recursive was added in 9.0.0 + */ + public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false, $recursive = true) { + return \OC\Share\Share::getUsersSharingFile($path, $ownerUser, $includeOwner, $returnUserPaths, $recursive); + } + + /** + * Get the items of item type shared with the current user + * @param string $itemType + * @param int $format (optional) Format type must be defined by the backend + * @param mixed $parameters (optional) + * @param int $limit Number of items to return (optional) Returns all by default + * @param bool $includeCollections (optional) + * @return mixed Return depends on format + * @since 5.0.0 + */ + public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE, + $parameters = null, $limit = -1, $includeCollections = false) { + + return \OC\Share\Share::getItemsSharedWith($itemType, $format, $parameters, $limit, $includeCollections); + } + + /** + * Get the items of item type shared with a user + * @param string $itemType + * @param string $user for which user we want the shares + * @param int $format (optional) Format type must be defined by the backend + * @param mixed $parameters (optional) + * @param int $limit Number of items to return (optional) Returns all by default + * @param bool $includeCollections (optional) + * @return mixed Return depends on format + * @since 7.0.0 + */ + public static function getItemsSharedWithUser($itemType, $user, $format = self::FORMAT_NONE, + $parameters = null, $limit = -1, $includeCollections = false) { + + return \OC\Share\Share::getItemsSharedWithUser($itemType, $user, $format, $parameters, $limit, $includeCollections); + } + + /** + * Get the item of item type shared with the current user + * @param string $itemType + * @param string $itemTarget + * @param int $format (optional) Format type must be defined by the backend + * @param mixed $parameters (optional) + * @param bool $includeCollections (optional) + * @return mixed Return depends on format + * @since 5.0.0 + */ + public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, + $parameters = null, $includeCollections = false) { + + return \OC\Share\Share::getItemSharedWith($itemType, $itemTarget, $format, $parameters, $includeCollections); + } + + /** + * Get the item of item type shared with a given user by source + * @param string $itemType + * @param string $itemSource + * @param string $user User to whom the item was shared + * @param string $owner Owner of the share + * @return array Return list of items with file_target, permissions and expiration + * @since 6.0.0 - parameter $owner was added in 8.0.0 + */ + public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null) { + return \OC\Share\Share::getItemSharedWithUser($itemType, $itemSource, $user, $owner); + } + + /** + * Get the item of item type shared with the current user by source + * @param string $itemType + * @param string $itemSource + * @param int $format (optional) Format type must be defined by the backend + * @param mixed $parameters + * @param bool $includeCollections + * @return array + * @since 5.0.0 + */ + public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE, + $parameters = null, $includeCollections = false) { + return \OC\Share\Share::getItemSharedWithBySource($itemType, $itemSource, $format, $parameters, $includeCollections); + } + + /** + * Get the item of item type shared by a link + * @param string $itemType + * @param string $itemSource + * @param string $uidOwner Owner of link + * @return array + * @since 5.0.0 + */ + public static function getItemSharedWithByLink($itemType, $itemSource, $uidOwner) { + return \OC\Share\Share::getItemSharedWithByLink($itemType, $itemSource, $uidOwner); + } + + /** + * Based on the given token the share information will be returned - password protected shares will be verified + * @param string $token + * @param bool $checkPasswordProtection + * @return array|bool false will be returned in case the token is unknown or unauthorized + * @since 5.0.0 - parameter $checkPasswordProtection was added in 7.0.0 + */ + public static function getShareByToken($token, $checkPasswordProtection = true) { + return \OC\Share\Share::getShareByToken($token, $checkPasswordProtection); + } + + /** + * resolves reshares down to the last real share + * @param array $linkItem + * @return array file owner + * @since 6.0.0 + */ + public static function resolveReShare($linkItem) { + return \OC\Share\Share::resolveReShare($linkItem); + } + + + /** + * Get the shared items of item type owned by the current user + * @param string $itemType + * @param int $format (optional) Format type must be defined by the backend + * @param mixed $parameters + * @param int $limit Number of items to return (optional) Returns all by default + * @param bool $includeCollections + * @return mixed Return depends on format + * @since 5.0.0 + */ + public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null, + $limit = -1, $includeCollections = false) { + + return \OC\Share\Share::getItemsShared($itemType, $format, $parameters, $limit, $includeCollections); + } + + /** + * Get the shared item of item type owned by the current user + * @param string $itemType + * @param string $itemSource + * @param int $format (optional) Format type must be defined by the backend + * @param mixed $parameters + * @param bool $includeCollections + * @return mixed Return depends on format + * @since 5.0.0 + */ + public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE, + $parameters = null, $includeCollections = false) { + + return \OC\Share\Share::getItemShared($itemType, $itemSource, $format, $parameters, $includeCollections); + } + + /** + * Get all users an item is shared with + * @param string $itemType + * @param string $itemSource + * @param string $uidOwner + * @param bool $includeCollections + * @param bool $checkExpireDate + * @return array Return array of users + * @since 5.0.0 - parameter $checkExpireDate was added in 7.0.0 + */ + public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false, $checkExpireDate = true) { + return \OC\Share\Share::getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections, $checkExpireDate); + } + + /** + * Share an item with a user, group, or via private link + * @param string $itemType + * @param string $itemSource + * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param string $shareWith User or group the item is being shared with + * @param int $permissions CRUDS + * @param string $itemSourceName + * @param \DateTime $expirationDate + * @param bool $passwordChanged + * @return bool|string Returns true on success or false on failure, Returns token on success for links + * @throws \OC\HintException when the share type is remote and the shareWith is invalid + * @throws \Exception + * @since 5.0.0 - parameter $itemSourceName was added in 6.0.0, parameter $expirationDate was added in 7.0.0, parameter $passwordChanged added in 9.0.0 + */ + public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null, $passwordChanged = null) { + return \OC\Share\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName, $expirationDate, $passwordChanged); + } + + /** + * Unshare an item from a user, group, or delete a private link + * @param string $itemType + * @param string $itemSource + * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param string $shareWith User or group the item is being shared with + * @param string $owner owner of the share, if null the current user is used + * @return boolean true on success or false on failure + * @since 5.0.0 - parameter $owner was added in 8.0.0 + */ + public static function unshare($itemType, $itemSource, $shareType, $shareWith, $owner = null) { + return \OC\Share\Share::unshare($itemType, $itemSource, $shareType, $shareWith, $owner); + } + + /** + * Unshare an item from all users, groups, and remove all links + * @param string $itemType + * @param string $itemSource + * @return boolean true on success or false on failure + * @since 5.0.0 + */ + public static function unshareAll($itemType, $itemSource) { + return \OC\Share\Share::unshareAll($itemType, $itemSource); + } + + /** + * Unshare an item shared with the current user + * @param string $itemType + * @param string $itemOrigin Item target or source + * @param boolean $originIsSource true if $itemOrigin is the source, false if $itemOrigin is the target (optional) + * @return boolean true on success or false on failure + * + * Unsharing from self is not allowed for items inside collections + * @since 5.0.0 - parameter $originIsSource was added in 8.0.0 + */ + public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) { + return \OC\Share\Share::unshareFromSelf($itemType, $itemOrigin, $originIsSource); + } + + /** + * sent status if users got informed by mail about share + * @param string $itemType + * @param string $itemSource + * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param string $recipient with whom was the item shared + * @param bool $status + * @since 6.0.0 - parameter $originIsSource was added in 8.0.0 + */ + public static function setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status) { + return \OC\Share\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status); + } + + /** + * Set the permissions of an item for a specific user or group + * @param string $itemType + * @param string $itemSource + * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param string $shareWith User or group the item is being shared with + * @param int $permissions CRUDS permissions + * @return boolean true on success or false on failure + * @since 5.0.0 + */ + public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) { + return \OC\Share\Share::setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions); + } + + /** + * Set expiration date for a share + * @param string $itemType + * @param string $itemSource + * @param string $date expiration date + * @param int $shareTime timestamp from when the file was shared + * @return boolean + * @since 5.0.0 - parameter $shareTime was added in 8.0.0 + */ + public static function setExpirationDate($itemType, $itemSource, $date, $shareTime = null) { + return \OC\Share\Share::setExpirationDate($itemType, $itemSource, $date, $shareTime); + } + + /** + * Set password for a public link share + * @param int $shareId + * @param string $password + * @return boolean + * @since 8.1.0 + */ + public static function setPassword($shareId, $password) { + $userSession = \OC::$server->getUserSession(); + $connection = \OC::$server->getDatabaseConnection(); + $config = \OC::$server->getConfig(); + return \OC\Share\Share::setPassword($userSession, $connection, $config, $shareId, $password); + } + + + /** + * Get the backend class for the specified item type + * @param string $itemType + * @return Share_Backend + * @since 5.0.0 + */ + public static function getBackend($itemType) { + return \OC\Share\Share::getBackend($itemType); + } + + /** + * Delete all shares with type SHARE_TYPE_LINK + * @since 6.0.0 + */ + public static function removeAllLinkShares() { + return \OC\Share\Share::removeAllLinkShares(); + } + + /** + * In case a password protected link is not yet authenticated this function will return false + * + * @param array $linkItem + * @return bool + * @since 7.0.0 + */ + public static function checkPasswordProtectedShare(array $linkItem) { + return \OC\Share\Share::checkPasswordProtectedShare($linkItem); + } + + /** + * Check if resharing is allowed + * + * @return boolean true if allowed or false + * @since 5.0.0 + */ + public static function isResharingAllowed() { + return \OC\Share\Share::isResharingAllowed(); + } +} diff --git a/lib/public/Share_Backend.php b/lib/public/Share_Backend.php new file mode 100644 index 00000000000..110403c1f49 --- /dev/null +++ b/lib/public/Share_Backend.php @@ -0,0 +1,96 @@ + + * @author Joas Schilling + * @author Morris Jobke + * @author Robin McCorkell + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +// 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; + +/** + * Interface that apps must implement to share content. + * @since 5.0.0 + */ +interface Share_Backend { + + /** + * Check if this $itemSource exist for the user + * @param string $itemSource + * @param string $uidOwner Owner of the item + * @return boolean|null Source + * + * Return false if the item does not exist for the user + * @since 5.0.0 + */ + public function isValidSource($itemSource, $uidOwner); + + /** + * Get a unique name of the item for the specified user + * @param string $itemSource + * @param string|false $shareWith User the item is being shared with + * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7 + * @return string Target name + * + * This function needs to verify that the user does not already have an item with this name. + * If it does generate a new name e.g. name_# + * @since 5.0.0 + */ + public function generateTarget($itemSource, $shareWith, $exclude = null); + + /** + * Converts the shared item sources back into the item in the specified format + * @param array $items Shared items + * @param int $format + * @return array + * + * The items array is a 3-dimensional array with the item_source as the + * first key and the share id as the second key to an array with the share + * info. + * + * The key/value pairs included in the share info depend on the function originally called: + * If called by getItem(s)Shared: id, item_type, item, item_source, + * share_type, share_with, permissions, stime, file_source + * + * If called by getItem(s)SharedWith: id, item_type, item, item_source, + * item_target, share_type, share_with, permissions, stime, file_source, + * file_target + * + * This function allows the backend to control the output of shared items with custom formats. + * It is only called through calls to the public getItem(s)Shared(With) functions. + * @since 5.0.0 + */ + public function formatItems($items, $format, $parameters = null); + + /** + * Check if a given share type is allowd by the back-end + * + * @param int $shareType share type + * @return boolean + * + * The back-end can enable/disable specific share types. Just return true if + * the back-end doesn't provide any specific settings for it and want to allow + * all share types defined by the share API + * @since 8.0.0 + */ + public function isShareTypeAllowed($shareType); + +} diff --git a/lib/public/Share_Backend_Collection.php b/lib/public/Share_Backend_Collection.php new file mode 100644 index 00000000000..185cf32ce3e --- /dev/null +++ b/lib/public/Share_Backend_Collection.php @@ -0,0 +1,40 @@ + + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +// 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; + +/** + * Interface for collections of of items implemented by another share backend. + * Extends the Share_Backend interface. + * @since 5.0.0 + */ +interface Share_Backend_Collection extends Share_Backend { + /** + * Get the sources of the children of the item + * @param string $itemSource + * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable + * @since 5.0.0 + */ + public function getChildren($itemSource); +} diff --git a/lib/public/Share_Backend_File_Dependent.php b/lib/public/Share_Backend_File_Dependent.php new file mode 100644 index 00000000000..64b3bf43319 --- /dev/null +++ b/lib/public/Share_Backend_File_Dependent.php @@ -0,0 +1,42 @@ + + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +// 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; + +/** + * Interface for share backends that share content that is dependent on files. + * Extends the Share_Backend interface. + * @since 5.0.0 + */ +interface Share_Backend_File_Dependent extends Share_Backend { + /** + * Get the file path of the item + * @param string $itemSource + * @param string $uidOwner User that is the owner of shared item + * @return string|false + * @since 5.0.0 + */ + public function getFilePath($itemSource, $uidOwner); + +} diff --git a/lib/public/User.php b/lib/public/User.php new file mode 100644 index 00000000000..64ac92d2100 --- /dev/null +++ b/lib/public/User.php @@ -0,0 +1,155 @@ + + * @author Björn Schießle + * @author Frank Karlitschek + * @author Georg Ehrke + * @author Joas Schilling + * @author Jörn Friedrich Dreyer + * @author Lorenzo M. Catucci + * @author Morris Jobke + * @author Robin McCorkell + * @author Thomas Müller + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * User Class + * + */ + +// 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; + +/** + * This class provides access to the user management. You can get information + * about the currently logged in user and the permissions for example + * @since 5.0.0 + */ +class User { + /** + * Get the user id of the user currently logged in. + * @return string uid or false + * @deprecated 8.0.0 Use \OC::$server->getUserSession()->getUser()->getUID() + * @since 5.0.0 + */ + public static function getUser() { + return \OC_User::getUser(); + } + + /** + * Get a list of all users + * @param string $search search pattern + * @param int|null $limit + * @param int|null $offset + * @return array an array of all uids + * @deprecated 8.1.0 use method search() of \OCP\IUserManager - \OC::$server->getUserManager() + * @since 5.0.0 + */ + public static function getUsers( $search = '', $limit = null, $offset = null ) { + return \OC_User::getUsers( $search, $limit, $offset ); + } + + /** + * Get the user display name of the user currently logged in. + * @param string|null $user user id or null for current user + * @return string display name + * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method + * get() of \OCP\IUserManager - \OC::$server->getUserManager() + * @since 5.0.0 + */ + public static function getDisplayName( $user = null ) { + return \OC_User::getDisplayName( $user ); + } + + /** + * Get a list of all display names and user ids. + * @param string $search search pattern + * @param int|null $limit + * @param int|null $offset + * @return array an array of all display names (value) and the correspondig uids (key) + * @deprecated 8.1.0 use method searchDisplayName() of \OCP\IUserManager - \OC::$server->getUserManager() + * @since 5.0.0 + */ + public static function getDisplayNames( $search = '', $limit = null, $offset = null ) { + return \OC_User::getDisplayNames( $search, $limit, $offset ); + } + + /** + * Check if the user is logged in + * @return boolean + * @since 5.0.0 + */ + public static function isLoggedIn() { + return \OC_User::isLoggedIn(); + } + + /** + * Check if a user exists + * @param string $uid the username + * @param string $excludingBackend (default none) + * @return boolean + * @deprecated 8.1.0 use method userExists() of \OCP\IUserManager - \OC::$server->getUserManager() + * @since 5.0.0 + */ + public static function userExists( $uid, $excludingBackend = null ) { + return \OC_User::userExists( $uid, $excludingBackend ); + } + /** + * Logs the user out including all the session data + * Logout, destroys session + * @deprecated 8.0.0 Use \OC::$server->getUserSession()->logout(); + * @since 5.0.0 + */ + public static function logout() { + \OC::$server->getUserSession()->logout(); + } + + /** + * Check if the password is correct + * @param string $uid The username + * @param string $password The password + * @return string|false username on success, false otherwise + * + * Check if the password is correct without logging in the user + * @deprecated 8.0.0 Use \OC::$server->getUserManager()->checkPassword(); + * @since 5.0.0 + */ + public static function checkPassword( $uid, $password ) { + return \OC_User::checkPassword( $uid, $password ); + } + + /** + * Check if the user is a admin, redirects to home if not + * @since 5.0.0 + */ + public static function checkAdminUser() { + \OC_Util::checkAdminUser(); + } + + /** + * Check if the user is logged in, redirects to home if not. With + * redirect URL parameter to the request URI. + * @since 5.0.0 + */ + public static function checkLoggedIn() { + \OC_Util::checkLoggedIn(); + } +} diff --git a/lib/public/UserInterface.php b/lib/public/UserInterface.php new file mode 100644 index 00000000000..954c2d68133 --- /dev/null +++ b/lib/public/UserInterface.php @@ -0,0 +1,106 @@ + + * @author Jörn Friedrich Dreyer + * @author Morris Jobke + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * User Interface + * + */ + +// 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; + +/** + * TODO actually this is a IUserBackend + * + * @package OCP + * @since 4.5.0 + */ +interface UserInterface { + + /** + * Check if backend implements actions + * @param int $actions bitwise-or'ed actions + * @return boolean + * + * Returns the supported actions as int to be + * compared with \OC_User_Backend::CREATE_USER etc. + * @since 4.5.0 + */ + public function implementsActions($actions); + + /** + * delete a user + * @param string $uid The username of the user to delete + * @return bool + * @since 4.5.0 + */ + public function deleteUser($uid); + + /** + * Get a list of all users + * + * @param string $search + * @param null|int $limit + * @param null|int $offset + * @return string[] an array of all uids + * @since 4.5.0 + */ + public function getUsers($search = '', $limit = null, $offset = null); + + /** + * check if a user exists + * @param string $uid the username + * @return boolean + * @since 4.5.0 + */ + public function userExists($uid); + + /** + * get display name of the user + * @param string $uid user ID of the user + * @return string display name + * @since 4.5.0 + */ + public function getDisplayName($uid); + + /** + * Get a list of all display names and user ids. + * + * @param string $search + * @param string|null $limit + * @param string|null $offset + * @return array an array of all displayNames (value) and the corresponding uids (key) + * @since 4.5.0 + */ + public function getDisplayNames($search = '', $limit = null, $offset = null); + + /** + * Check if a user list is available or not + * @return boolean if users can be listed or not + * @since 4.5.0 + */ + public function hasUserListings(); + +} diff --git a/lib/public/Util.php b/lib/public/Util.php new file mode 100644 index 00000000000..45df62ac735 --- /dev/null +++ b/lib/public/Util.php @@ -0,0 +1,697 @@ + + * @author Bart Visscher + * @author Björn Schießle + * @author Frank Karlitschek + * @author Georg Ehrke + * @author Individual IT Services + * @author Jens-Christian Fischer + * @author Joas Schilling + * @author Lukas Reschke + * @author Michael Gapczynski + * @author Morris Jobke + * @author Nicolas Grekas + * @author Pellaeon Lin + * @author Randolph Carter + * @author Robin Appelman + * @author Robin McCorkell + * @author Roeland Jago Douma + * @author Stefan Herbrechtsmeier + * @author Thomas Müller + * @author Thomas Tanghus + * @author Victor Dubiniuk + * @author Vincent Petry + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @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 + * + */ + +/** + * Public interface of ownCloud for apps to use. + * Utility Class. + * + */ + +// 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; +use DateTimeZone; + +/** + * This class provides different helper functions to make the life of a developer easier + * @since 4.0.0 + */ +class Util { + // consts for Logging + const DEBUG=0; + const INFO=1; + const WARN=2; + const ERROR=3; + const FATAL=4; + + /** + * get the current installed version of ownCloud + * @return array + * @since 4.0.0 + */ + public static function getVersion() { + return(\OC_Util::getVersion()); + } + + /** + * Set current update channel + * @param string $channel + * @since 8.1.0 + */ + public static function setChannel($channel) { + //Flush timestamp to reload version.php + \OC::$server->getSession()->set('OC_Version_Timestamp', 0); + \OC::$server->getAppConfig()->setValue('core', 'OC_Channel', $channel); + } + + /** + * Get current update channel + * @return string + * @since 8.1.0 + */ + public static function getChannel() { + return \OC_Util::getChannel(); + } + + /** + * send an email + * @param string $toaddress + * @param string $toname + * @param string $subject + * @param string $mailtext + * @param string $fromaddress + * @param string $fromname + * @param int $html + * @param string $altbody + * @param string $ccaddress + * @param string $ccname + * @param string $bcc + * @deprecated 8.1.0 Use \OCP\Mail\IMailer instead + * @since 4.0.0 + */ + public static function sendMail($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, + $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { + $mailer = \OC::$server->getMailer(); + $message = $mailer->createMessage(); + $message->setTo([$toaddress => $toname]); + $message->setSubject($subject); + $message->setPlainBody($mailtext); + $message->setFrom([$fromaddress => $fromname]); + if($html === 1) { + $message->setHTMLBody($altbody); + } + + if($altbody === '') { + $message->setHTMLBody($mailtext); + $message->setPlainBody(''); + } else { + $message->setHtmlBody($mailtext); + $message->setPlainBody($altbody); + } + + if(!empty($ccaddress)) { + if(!empty($ccname)) { + $message->setCc([$ccaddress => $ccname]); + } else { + $message->setCc([$ccaddress]); + } + } + if(!empty($bcc)) { + $message->setBcc([$bcc]); + } + + $mailer->send($message); + } + + /** + * write a message in the log + * @param string $app + * @param string $message + * @param int $level + * @since 4.0.0 + */ + public static function writeLog( $app, $message, $level ) { + $context = ['app' => $app]; + \OC::$server->getLogger()->log($level, $message, $context); + } + + /** + * write exception into the log + * @param string $app app name + * @param \Exception $ex exception to log + * @param int $level log level, defaults to \OCP\Util::FATAL + * @since ....0.0 - parameter $level was added in 7.0.0 + * @deprecated 8.2.0 use logException of \OCP\ILogger + */ + public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) { + \OC::$server->getLogger()->logException($ex, ['app' => $app]); + } + + /** + * check if sharing is disabled for the current user + * + * @return boolean + * @since 7.0.0 + */ + public static function isSharingDisabledForUser() { + return \OC_Util::isSharingDisabledForUser( + \OC::$server->getConfig(), + \OC::$server->getGroupManager(), + \OC::$server->getUserSession()->getUser() + ); + } + + /** + * get l10n object + * @param string $application + * @param string|null $language + * @return \OC_L10N + * @since 6.0.0 - parameter $language was added in 8.0.0 + */ + public static function getL10N($application, $language = null) { + return \OC::$server->getL10N($application, $language); + } + + /** + * add a css file + * @param string $application + * @param string $file + * @since 4.0.0 + */ + public static function addStyle( $application, $file = null ) { + \OC_Util::addStyle( $application, $file ); + } + + /** + * add a javascript file + * @param string $application + * @param string $file + * @since 4.0.0 + */ + public static function addScript( $application, $file = null ) { + \OC_Util::addScript( $application, $file ); + } + + /** + * Add a translation JS file + * @param string $application application id + * @param string $languageCode language code, defaults to the current locale + * @since 8.0.0 + */ + public static function addTranslations($application, $languageCode = null) { + \OC_Util::addTranslations($application, $languageCode); + } + + /** + * Add a custom element to the header + * If $text is null then the element will be written as empty element. + * So use "" to get a closing tag. + * @param string $tag tag name of the element + * @param array $attributes array of attributes for the element + * @param string $text the text content for the element + * @since 4.0.0 + */ + public static function addHeader($tag, $attributes, $text=null) { + \OC_Util::addHeader($tag, $attributes, $text); + } + + /** + * formats a timestamp in the "right" way + * @param int $timestamp $timestamp + * @param bool $dateOnly option to omit time from the result + * @param DateTimeZone|string $timeZone where the given timestamp shall be converted to + * @return string timestamp + * + * @deprecated 8.0.0 Use \OC::$server->query('DateTimeFormatter') instead + * @since 4.0.0 + */ + public static function formatDate($timestamp, $dateOnly=false, $timeZone = null) { + return(\OC_Util::formatDate($timestamp, $dateOnly, $timeZone)); + } + + /** + * check if some encrypted files are stored + * @return bool + * + * @deprecated 8.1.0 No longer required + * @since 6.0.0 + */ + public static function encryptedFiles() { + return false; + } + + /** + * Creates an absolute url to the given app and file. + * @param string $app app + * @param string $file file + * @param array $args array with param=>value, will be appended to the returned url + * The value of $args will be urlencoded + * @return string the url + * @since 4.0.0 - parameter $args was added in 4.5.0 + */ + public static function linkToAbsolute( $app, $file, $args = array() ) { + $urlGenerator = \OC::$server->getURLGenerator(); + return $urlGenerator->getAbsoluteURL( + $urlGenerator->linkTo($app, $file, $args) + ); + } + + /** + * Creates an absolute url for remote use. + * @param string $service id + * @return string the url + * @since 4.0.0 + */ + public static function linkToRemote( $service ) { + $urlGenerator = \OC::$server->getURLGenerator(); + $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; + return $urlGenerator->getAbsoluteURL( + $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') + ); + } + + /** + * Creates an absolute url for public use + * @param string $service id + * @return string the url + * @since 4.5.0 + */ + public static function linkToPublic($service) { + return \OC_Helper::linkToPublic($service); + } + + /** + * Creates an url using a defined route + * @param string $route + * @param array $parameters + * @internal param array $args with param=>value, will be appended to the returned url + * @return string the url + * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkToRoute($route, $parameters) + * @since 5.0.0 + */ + public static function linkToRoute( $route, $parameters = array() ) { + return \OC::$server->getURLGenerator()->linkToRoute($route, $parameters); + } + + /** + * Creates an url to the given app and file + * @param string $app app + * @param string $file file + * @param array $args array with param=>value, will be appended to the returned url + * The value of $args will be urlencoded + * @return string the url + * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkTo($app, $file, $args) + * @since 4.0.0 - parameter $args was added in 4.5.0 + */ + public static function linkTo( $app, $file, $args = array() ) { + return \OC::$server->getURLGenerator()->linkTo($app, $file, $args); + } + + /** + * Returns the server host, even if the website uses one or more reverse proxy + * @return string the server host + * @deprecated 8.1.0 Use \OCP\IRequest::getServerHost + * @since 4.0.0 + */ + public static function getServerHost() { + return \OC::$server->getRequest()->getServerHost(); + } + + /** + * Returns the server host name without an eventual port number + * @return string the server hostname + * @since 5.0.0 + */ + public static function getServerHostName() { + $host_name = self::getServerHost(); + // strip away port number (if existing) + $colon_pos = strpos($host_name, ':'); + if ($colon_pos != FALSE) { + $host_name = substr($host_name, 0, $colon_pos); + } + return $host_name; + } + + /** + * Returns the default email address + * @param string $user_part the user part of the address + * @return string the default email address + * + * Assembles a default email address (using the server hostname + * and the given user part, and returns it + * Example: when given lostpassword-noreply as $user_part param, + * and is currently accessed via http(s)://example.com/, + * it would return 'lostpassword-noreply@example.com' + * + * If the configuration value 'mail_from_address' is set in + * config.php, this value will override the $user_part that + * is passed to this function + * @since 5.0.0 + */ + public static function getDefaultEmailAddress($user_part) { + $config = \OC::$server->getConfig(); + $user_part = $config->getSystemValue('mail_from_address', $user_part); + $host_name = self::getServerHostName(); + $host_name = $config->getSystemValue('mail_domain', $host_name); + $defaultEmailAddress = $user_part.'@'.$host_name; + + $mailer = \OC::$server->getMailer(); + if ($mailer->validateMailAddress($defaultEmailAddress)) { + return $defaultEmailAddress; + } + + // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' + return $user_part.'@localhost.localdomain'; + } + + /** + * Returns the server protocol. It respects reverse proxy servers and load balancers + * @return string the server protocol + * @deprecated 8.1.0 Use \OCP\IRequest::getServerProtocol + * @since 4.5.0 + */ + public static function getServerProtocol() { + return \OC::$server->getRequest()->getServerProtocol(); + } + + /** + * Returns the request uri, even if the website uses one or more reverse proxies + * @return string the request uri + * @deprecated 8.1.0 Use \OCP\IRequest::getRequestUri + * @since 5.0.0 + */ + public static function getRequestUri() { + return \OC::$server->getRequest()->getRequestUri(); + } + + /** + * Returns the script name, even if the website uses one or more reverse proxies + * @return string the script name + * @deprecated 8.1.0 Use \OCP\IRequest::getScriptName + * @since 5.0.0 + */ + public static function getScriptName() { + return \OC::$server->getRequest()->getScriptName(); + } + + /** + * Creates path to an image + * @param string $app app + * @param string $image image name + * @return string the url + * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->imagePath($app, $image) + * @since 4.0.0 + */ + public static function imagePath( $app, $image ) { + return \OC::$server->getURLGenerator()->imagePath($app, $image); + } + + /** + * Make a human file size (2048 to 2 kB) + * @param int $bytes file size in bytes + * @return string a human readable file size + * @since 4.0.0 + */ + public static function humanFileSize( $bytes ) { + return(\OC_Helper::humanFileSize( $bytes )); + } + + /** + * Make a computer file size (2 kB to 2048) + * @param string $str file size in a fancy format + * @return int a file size in bytes + * + * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 + * @since 4.0.0 + */ + public static function computerFileSize( $str ) { + return(\OC_Helper::computerFileSize( $str )); + } + + /** + * connects a function to a hook + * + * @param string $signalClass class name of emitter + * @param string $signalName name of signal + * @param string|object $slotClass class name of slot + * @param string $slotName name of slot + * @return bool + * + * This function makes it very easy to connect to use hooks. + * + * TODO: write example + * @since 4.0.0 + */ + static public function connectHook($signalClass, $signalName, $slotClass, $slotName ) { + return(\OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName )); + } + + /** + * Emits a signal. To get data from the slot use references! + * @param string $signalclass class name of emitter + * @param string $signalname name of signal + * @param array $params default: array() array with additional data + * @return bool true if slots exists or false if not + * + * TODO: write example + * @since 4.0.0 + */ + static public function emitHook( $signalclass, $signalname, $params = array()) { + return(\OC_Hook::emit( $signalclass, $signalname, $params )); + } + + /** + * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare + * multiple OC_Template elements which invoke `callRegister`. If the value + * would not be cached these unit-tests would fail. + * @var string + */ + private static $token = ''; + + /** + * Register an get/post call. This is important to prevent CSRF attacks + * @since 4.5.0 + */ + public static function callRegister() { + if(self::$token === '') { + self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); + } + return self::$token; + } + + /** + * Check an ajax get/post call if the request token is valid. exit if not. + * @since 4.5.0 + * @deprecated 9.0.0 Use annotations based on the app framework. + */ + public static function callCheck() { + if (!(\OC::$server->getRequest()->passesCSRFCheck())) { + exit(); + } + } + + /** + * Used to sanitize HTML + * + * This function is used to sanitize HTML and should be applied on any + * string or array of strings before displaying it on a web page. + * + * @param string|array $value + * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter. + * @since 4.5.0 + */ + public static function sanitizeHTML($value) { + return \OC_Util::sanitizeHTML($value); + } + + /** + * Public function to encode url parameters + * + * This function is used to encode path to file before output. + * Encoding is done according to RFC 3986 with one exception: + * Character '/' is preserved as is. + * + * @param string $component part of URI to encode + * @return string + * @since 6.0.0 + */ + public static function encodePath($component) { + return(\OC_Util::encodePath($component)); + } + + /** + * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. + * + * @param array $input The array to work on + * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default) + * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 + * @return array + * @since 4.5.0 + */ + public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { + return(\OC_Helper::mb_array_change_key_case($input, $case, $encoding)); + } + + /** + * replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. + * + * @param string $string The input string. Opposite to the PHP build-in function does not accept an array. + * @param string $replacement The replacement string. + * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string. + * @param int $length Length of the part to be replaced + * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 + * @return string + * @since 4.5.0 + * @deprecated 8.2.0 Use substr_replace() instead. + */ + public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') { + return substr_replace($string, $replacement, $start, $length); + } + + /** + * Replace all occurrences of the search string with the replacement string + * + * @param string $search The value being searched for, otherwise known as the needle. String. + * @param string $replace The replacement string. + * @param string $subject The string or array being searched and replaced on, otherwise known as the haystack. + * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 + * @param int $count If passed, this will be set to the number of replacements performed. + * @return string + * @since 4.5.0 + * @deprecated 8.2.0 Use str_replace() instead. + */ + public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) { + return str_replace($search, $replace, $subject, $count); + } + + /** + * performs a search in a nested array + * + * @param array $haystack the array to be searched + * @param string $needle the search string + * @param int $index optional, only search this key name + * @return mixed the key of the matching field, otherwise false + * @since 4.5.0 + */ + public static function recursiveArraySearch($haystack, $needle, $index = null) { + return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index)); + } + + /** + * calculates the maximum upload size respecting system settings, free space and user quota + * + * @param string $dir the current folder where the user currently operates + * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly + * @return int number of bytes representing + * @since 5.0.0 + */ + public static function maxUploadFilesize($dir, $free = null) { + return \OC_Helper::maxUploadFilesize($dir, $free); + } + + /** + * Calculate free space left within user quota + * @param string $dir the current folder where the user currently operates + * @return int number of bytes representing + * @since 7.0.0 + */ + public static function freeSpace($dir) { + return \OC_Helper::freeSpace($dir); + } + + /** + * Calculate PHP upload limit + * + * @return int number of bytes representing + * @since 7.0.0 + */ + public static function uploadLimit() { + return \OC_Helper::uploadLimit(); + } + + /** + * Returns whether the given file name is valid + * @param string $file file name to check + * @return bool true if the file name is valid, false otherwise + * @deprecated 8.1.0 use \OC\Files\View::verifyPath() + * @since 7.0.0 + */ + public static function isValidFileName($file) { + return \OC_Util::isValidFileName($file); + } + + /** + * Generates a cryptographic secure pseudo-random string + * @param int $length of the random string + * @return string + * @deprecated 8.0.0 Use \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($length); instead + * @since 7.0.0 + */ + public static function generateRandomBytes($length = 30) { + return \OC::$server->getSecureRandom()->generate($length, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); + } + + /** + * Compare two strings to provide a natural sort + * @param string $a first string to compare + * @param string $b second string to compare + * @return -1 if $b comes before $a, 1 if $a comes before $b + * or 0 if the strings are identical + * @since 7.0.0 + */ + public static function naturalSortCompare($a, $b) { + return \OC\NaturalSort::getInstance()->compare($a, $b); + } + + /** + * check if a password is required for each public link + * @return boolean + * @since 7.0.0 + */ + public static function isPublicLinkPasswordRequired() { + return \OC_Util::isPublicLinkPasswordRequired(); + } + + /** + * check if share API enforces a default expire date + * @return boolean + * @since 8.0.0 + */ + public static function isDefaultExpireDateEnforced() { + return \OC_Util::isDefaultExpireDateEnforced(); + } + + protected static $needUpgradeCache = null; + + /** + * Checks whether the current version needs upgrade. + * + * @return bool true if upgrade is needed, false otherwise + * @since 7.0.0 + */ + public static function needUpgrade() { + if (!isset(self::$needUpgradeCache)) { + self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getConfig()); + } + return self::$needUpgradeCache; + } +} diff --git a/lib/public/api.php b/lib/public/api.php deleted file mode 100644 index 4d68bef6f29..00000000000 --- a/lib/public/api.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @author Joas Schilling - * @author Morris Jobke - * @author Tom Needham - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * API Class - * - */ - -// 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; - -/** - * This class provides functions to manage apps in ownCloud - * @since 5.0.0 - */ -class API { - - /** - * API authentication levels - * @since 8.1.0 - */ - const GUEST_AUTH = 0; - const USER_AUTH = 1; - const SUBADMIN_AUTH = 2; - const ADMIN_AUTH = 3; - - /** - * API Response Codes - * @since 8.1.0 - */ - const RESPOND_UNAUTHORISED = 997; - const RESPOND_SERVER_ERROR = 996; - const RESPOND_NOT_FOUND = 998; - const RESPOND_UNKNOWN_ERROR = 999; - - /** - * registers an api call - * @param string $method the http method - * @param string $url the url to match - * @param callable $action the function to run - * @param string $app the id of the app registering the call - * @param int $authLevel the level of authentication required for the call (See `self::*_AUTH` constants) - * @param array $defaults - * @param array $requirements - * @since 5.0.0 - */ - public static function register($method, $url, $action, $app, $authLevel = self::USER_AUTH, - $defaults = array(), $requirements = array()){ - \OC_API::register($method, $url, $action, $app, $authLevel, $defaults, $requirements); - } - -} diff --git a/lib/public/app.php b/lib/public/app.php deleted file mode 100644 index c3ba90cea41..00000000000 --- a/lib/public/app.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @author Frank Karlitschek - * @author Georg Ehrke - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * @author Robin McCorkell - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * App Class - * - */ - -// 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; - -/** - * This class provides functions to manage apps in ownCloud - * @since 4.0.0 - */ -class App { - - /** - * Adds an entry to the navigation - * - * This function adds a new entry to the navigation visible to users. $data - * is an associative array. - * The following keys are required: - * - id: unique id for this entry ('addressbook_index') - * - href: link to the page - * - name: Human readable name ('Addressbook') - * - * The following keys are optional: - * - icon: path to the icon of the app - * - order: integer, that influences the position of your application in - * the navigation. Lower values come first. - * - * @param array $data containing the data - * @return boolean - * - * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->add() instead to - * register a closure, this helps to speed up all requests against ownCloud - * @since 4.0.0 - */ - public static function addNavigationEntry($data) { - \OC::$server->getNavigationManager()->add($data); - return true; - } - - /** - * Marks a navigation entry as active - * @param string $id id of the entry - * @return boolean - * - * This function sets a navigation entry as active and removes the 'active' - * property from all other entries. The templates can use this for - * highlighting the current position of the user. - * - * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->setActiveEntry() instead - * @since 4.0.0 - */ - public static function setActiveNavigationEntry( $id ) { - \OC::$server->getNavigationManager()->setActiveEntry($id); - return true; - } - - /** - * Register a Configuration Screen that should appear in the personal settings section. - * @param string $app appid - * @param string $page page to be included - * @return void - * @since 4.0.0 - */ - public static function registerPersonal( $app, $page ) { - \OC_App::registerPersonal( $app, $page ); - } - - /** - * Register a Configuration Screen that should appear in the Admin section. - * @param string $app string appid - * @param string $page string page to be included - * @return void - * @since 4.0.0 - */ - public static function registerAdmin( $app, $page ) { - \OC_App::registerAdmin( $app, $page ); - } - - /** - * Read app metadata from the info.xml file - * @param string $app id of the app or the path of the info.xml file - * @param boolean $path (optional) - * @return array|null - * @since 4.0.0 - */ - public static function getAppInfo( $app, $path=false ) { - return \OC_App::getAppInfo( $app, $path); - } - - /** - * checks whether or not an app is enabled - * @param string $app - * @return boolean - * - * This function checks whether or not an app is enabled. - * @since 4.0.0 - */ - public static function isEnabled( $app ) { - return \OC_App::isEnabled( $app ); - } - - /** - * Check if the app is enabled, redirects to home if not - * @param string $app - * @return void - * @since 4.0.0 - * @deprecated 9.0.0 ownCloud core will handle disabled apps and redirects to valid URLs - */ - public static function checkAppEnabled( $app ) { - } - - /** - * Get the last version of the app from appinfo/info.xml - * @param string $app - * @return string - * @since 4.0.0 - */ - public static function getAppVersion( $app ) { - return \OC_App::getAppVersion( $app ); - } -} diff --git a/lib/public/autoloadnotallowedexception.php b/lib/public/autoloadnotallowedexception.php deleted file mode 100644 index f0028b7d49d..00000000000 --- a/lib/public/autoloadnotallowedexception.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Exception for when a not allowed path is attempted to be autoloaded - * @since 8.2.0 - */ -class AutoloadNotAllowedException extends \DomainException { - /** - * @param string $path - * @since 8.2.0 - */ - public function __construct($path) { - parent::__construct('Autoload path not allowed: '.$path); - } -} - diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php deleted file mode 100644 index f532a97c747..00000000000 --- a/lib/public/backgroundjob.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @author Felix Moeller - * @author Jakob Sack - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * @author Robin Appelman - * @author Robin McCorkell - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for background jobs. - */ - -// 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; - - -/** - * This class provides functions to register backgroundjobs in ownCloud - * - * To create a new backgroundjob create a new class that inherits from either \OC\BackgroundJob\Job, - * \OC\BackgroundJob\QueuedJob or \OC\BackgroundJob\TimedJob and register it using - * \OCP\BackgroundJob->registerJob($job, $argument), $argument will be passed to the run() function - * of the job when the job is executed. - * - * A regular Job will be executed every time cron.php is run, a QueuedJob will only run once and a TimedJob - * will only run at a specific interval which is to be specified in the constructor of the job by calling - * $this->setInterval($interval) with $interval in seconds. - * @since 4.5.0 - */ -class BackgroundJob { - /** - * get the execution type of background jobs - * - * @return string - * - * This method returns the type how background jobs are executed. If the user - * did not select something, the type is ajax. - * @since 5.0.0 - */ - public static function getExecutionType() { - return \OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax'); - } - - /** - * sets the background jobs execution type - * - * @param string $type execution type - * @return false|null - * - * This method sets the execution type of the background jobs. Possible types - * are "none", "ajax", "webcron", "cron" - * @since 5.0.0 - */ - public static function setExecutionType($type) { - if( !in_array( $type, array('none', 'ajax', 'webcron', 'cron'))) { - return false; - } - \OC::$server->getConfig()->setAppValue('core', 'backgroundjobs_mode', $type); - } - - /** - * @param string $job - * @param mixed $argument - * @deprecated 8.1.0 Use \OC::$server->getJobList()->add() instead - * @since 6.0.0 - */ - public static function registerJob($job, $argument = null) { - $jobList = \OC::$server->getJobList(); - $jobList->add($job, $argument); - } - - /** - * @deprecated 6.0.0 - * creates a regular task - * @param string $klass class name - * @param string $method method name - * @return boolean|null - * @since 4.5.0 - */ - public static function addRegularTask($klass, $method) { - if (!\OCP\Util::needUpgrade()) { - self::registerJob('OC\BackgroundJob\Legacy\RegularJob', array($klass, $method)); - return true; - } - } - - /** - * @deprecated 6.0.0 - * gets all regular tasks - * @return array - * - * key is string "$klass-$method", value is array( $klass, $method ) - * @since 4.5.0 - */ - static public function allRegularTasks() { - return []; - } - - /** - * @deprecated 6.0.0 - * Gets one queued task - * @param int $id ID of the task - * @return BackgroundJob\IJob|null - * @since 4.5.0 - */ - public static function findQueuedTask($id) { - $jobList = \OC::$server->getJobList(); - return $jobList->getById($id); - } - - /** - * @deprecated 6.0.0 - * Gets all queued tasks - * @return array an array of associative arrays - * @since 4.5.0 - */ - public static function allQueuedTasks() { - return []; - } - - /** - * @deprecated 6.0.0 - * Gets all queued tasks of a specific app - * @param string $app app name - * @return array an array of associative arrays - * @since 4.5.0 - */ - public static function queuedTaskWhereAppIs($app) { - return []; - } - - /** - * @deprecated 6.0.0 - * queues a task - * @param string $app app name - * @param string $class class name - * @param string $method method name - * @param string $parameters all useful data as text - * @return boolean id of task - * @since 4.5.0 - */ - public static function addQueuedTask($app, $class, $method, $parameters) { - self::registerJob('OC\BackgroundJob\Legacy\QueuedJob', array('app' => $app, 'klass' => $class, 'method' => $method, 'parameters' => $parameters)); - return true; - } - - /** - * @deprecated 6.0.0 - * deletes a queued task - * @param int $id id of task - * @return boolean|null - * - * Deletes a report - * @since 4.5.0 - */ - public static function deleteQueuedTask($id) { - $jobList = \OC::$server->getJobList(); - $job = $jobList->getById($id); - if ($job) { - $jobList->remove($job); - } - } -} diff --git a/lib/public/config.php b/lib/public/config.php deleted file mode 100644 index 5b5dcb0e78e..00000000000 --- a/lib/public/config.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @author Frank Karlitschek - * @author Georg Ehrke - * @author Jörn Friedrich Dreyer - * @author Lukas Reschke - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Config Class - * - */ - -/** - * Use OCP namespace for all classes that are considered public. - * - * Classes that use this namespace are for use by apps, and not for use by internal - * OC classes - */ -namespace OCP; - -/** - * This class provides functions to read and write configuration data. - * configuration can be on a system, application or user level - * @deprecated 8.0.0 use methods of \OCP\IConfig - */ -class Config { - /** - * Gets a value from config.php - * @param string $key key - * @param mixed $default = null default value - * @return mixed the value or $default - * @deprecated 8.0.0 use method getSystemValue of \OCP\IConfig - * - * This function gets the value from config.php. If it does not exist, - * $default will be returned. - */ - public static function getSystemValue( $key, $default = null ) { - return \OC::$server->getConfig()->getSystemValue( $key, $default ); - } - - /** - * Sets a value - * @param string $key key - * @param mixed $value value - * @return bool - * @deprecated 8.0.0 use method setSystemValue of \OCP\IConfig - * - * This function sets the value and writes the config.php. If the file can - * not be written, false will be returned. - */ - public static function setSystemValue( $key, $value ) { - try { - \OC::$server->getConfig()->setSystemValue( $key, $value ); - } catch (\Exception $e) { - return false; - } - return true; - } - - /** - * Deletes a value from config.php - * @param string $key key - * @deprecated 8.0.0 use method deleteSystemValue of \OCP\IConfig - * - * This function deletes the value from config.php. - */ - public static function deleteSystemValue( $key ) { - \OC::$server->getConfig()->deleteSystemValue( $key ); - } - - /** - * Gets the config value - * @param string $app app - * @param string $key key - * @param string $default = null, default value if the key does not exist - * @return string the value or $default - * @deprecated 8.0.0 use method getAppValue of \OCP\IConfig - * - * This function gets a value from the appconfig table. If the key does - * not exist the default value will be returned - */ - public static function getAppValue( $app, $key, $default = null ) { - return \OC::$server->getConfig()->getAppValue( $app, $key, $default ); - } - - /** - * Sets a value in the appconfig - * @param string $app app - * @param string $key key - * @param string $value value - * @return boolean true/false - * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig - * - * Sets a value. If the key did not exist before it will be created. - */ - public static function setAppValue( $app, $key, $value ) { - try { - \OC::$server->getConfig()->setAppValue( $app, $key, $value ); - } catch (\Exception $e) { - return false; - } - return true; - } - - /** - * Gets the preference - * @param string $user user - * @param string $app app - * @param string $key key - * @param string $default = null, default value if the key does not exist - * @return string the value or $default - * @deprecated 8.0.0 use method getUserValue of \OCP\IConfig - * - * This function gets a value from the preferences table. If the key does - * not exist the default value will be returned - */ - public static function getUserValue( $user, $app, $key, $default = null ) { - return \OC::$server->getConfig()->getUserValue( $user, $app, $key, $default ); - } - - /** - * Sets a value in the preferences - * @param string $user user - * @param string $app app - * @param string $key key - * @param string $value value - * @return bool - * @deprecated 8.0.0 use method setUserValue of \OCP\IConfig - * - * Adds a value to the preferences. If the key did not exist before, it - * will be added automagically. - */ - public static function setUserValue( $user, $app, $key, $value ) { - try { - \OC::$server->getConfig()->setUserValue( $user, $app, $key, $value ); - } catch (\Exception $e) { - return false; - } - return true; - } -} diff --git a/lib/public/constants.php b/lib/public/constants.php deleted file mode 100644 index abf5f95eb96..00000000000 --- a/lib/public/constants.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @author Morris Jobke - * @author Roeland Jago Douma - * @author Thomas Tanghus - * @author Vincent Petry - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * This file defines common constants used in ownCloud - */ - -namespace OCP; - -/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_CREATE instead */ -const PERMISSION_CREATE = 4; - -/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_READ instead */ -const PERMISSION_READ = 1; - -/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_UPDATE instead */ -const PERMISSION_UPDATE = 2; - -/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_DELETE instead */ -const PERMISSION_DELETE = 8; - -/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_SHARE instead */ -const PERMISSION_SHARE = 16; - -/** @deprecated 8.0.0 Use \OCP\Constants::PERMISSION_ALL instead */ -const PERMISSION_ALL = 31; - -/** @deprecated 8.0.0 Use \OCP\Constants::FILENAME_INVALID_CHARS instead */ -const FILENAME_INVALID_CHARS = "\\/<>:\"|?*\n"; - -/** - * Class Constants - * - * @package OCP - * @since 8.0.0 - */ -class Constants { - /** - * CRUDS permissions. - * @since 8.0.0 - */ - const PERMISSION_CREATE = 4; - const PERMISSION_READ = 1; - const PERMISSION_UPDATE = 2; - const PERMISSION_DELETE = 8; - const PERMISSION_SHARE = 16; - const PERMISSION_ALL = 31; - - /** - * @since 8.0.0 - Updated in 9.0.0 to allow all POSIX chars since we no - * longer support windows as server platform. - */ - const FILENAME_INVALID_CHARS = "\\/"; -} diff --git a/lib/public/contacts.php b/lib/public/contacts.php deleted file mode 100644 index 590fd9af1bd..00000000000 --- a/lib/public/contacts.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @author Morris Jobke - * @author Robin McCorkell - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Contacts Class - * - */ - -// 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 { - - /** - * This class provides access to the contacts app. Use this class exclusively if you want to access contacts. - * - * Contacts in general will be expressed as an array of key-value-pairs. - * The keys will match the property names defined in https://tools.ietf.org/html/rfc2426#section-1 - * - * Proposed workflow for working with contacts: - * - search for the contacts - * - manipulate the results array - * - createOrUpdate will save the given contacts overwriting the existing data - * - * For updating it is mandatory to keep the id. - * Without an id a new contact will be created. - * - * @deprecated 8.1.0 use methods of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - class Contacts { - - /** - * This function is used to search and find contacts within the users address books. - * In case $pattern is empty all contacts will be returned. - * - * Example: - * Following function shows how to search for contacts for the name and the email address. - * - * public static function getMatchingRecipient($term) { - * // The API is not active -> nothing to do - * if (!\OCP\Contacts::isEnabled()) { - * return array(); - * } - * - * $result = \OCP\Contacts::search($term, array('FN', 'EMAIL')); - * $receivers = array(); - * foreach ($result as $r) { - * $id = $r['id']; - * $fn = $r['FN']; - * $email = $r['EMAIL']; - * if (!is_array($email)) { - * $email = array($email); - * } - * - * // loop through all email addresses of this contact - * foreach ($email as $e) { - * $displayName = $fn . " <$e>"; - * $receivers[] = array( - * 'id' => $id, - * 'label' => $displayName, - * 'value' => $displayName); - * } - * } - * - * return $receivers; - * } - * - * - * @param string $pattern which should match within the $searchProperties - * @param array $searchProperties defines the properties within the query pattern should match - * @param array $options - for future use. One should always have options! - * @return array an array of contacts which are arrays of key-value-pairs - * @deprecated 8.1.0 use search() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function search($pattern, $searchProperties = array(), $options = array()) { - $cm = \OC::$server->getContactsManager(); - return $cm->search($pattern, $searchProperties, $options); - } - - /** - * This function can be used to delete the contact identified by the given id - * - * @param object $id the unique identifier to a contact - * @param string $address_book_key - * @return bool successful or not - * @deprecated 8.1.0 use delete() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function delete($id, $address_book_key) { - $cm = \OC::$server->getContactsManager(); - return $cm->delete($id, $address_book_key); - } - - /** - * This function is used to create a new contact if 'id' is not given or not present. - * Otherwise the contact will be updated by replacing the entire data set. - * - * @param array $properties this array if key-value-pairs defines a contact - * @param string $address_book_key identifier of the address book in which the contact shall be created or updated - * @return array an array representing the contact just created or updated - * @deprecated 8.1.0 use createOrUpdate() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function createOrUpdate($properties, $address_book_key) { - $cm = \OC::$server->getContactsManager(); - return $cm->createOrUpdate($properties, $address_book_key); - } - - /** - * Check if contacts are available (e.g. contacts app enabled) - * - * @return bool true if enabled, false if not - * @deprecated 8.1.0 use isEnabled() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function isEnabled() { - $cm = \OC::$server->getContactsManager(); - return $cm->isEnabled(); - } - - /** - * @param \OCP\IAddressBook $address_book - * @deprecated 8.1.0 use registerAddressBook() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function registerAddressBook(\OCP\IAddressBook $address_book) { - $cm = \OC::$server->getContactsManager(); - $cm->registerAddressBook($address_book); - } - - /** - * @param \OCP\IAddressBook $address_book - * @deprecated 8.1.0 use unregisterAddressBook() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function unregisterAddressBook(\OCP\IAddressBook $address_book) { - $cm = \OC::$server->getContactsManager(); - $cm->unregisterAddressBook($address_book); - } - - /** - * @return array - * @deprecated 8.1.0 use getAddressBooks() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function getAddressBooks() { - $cm = \OC::$server->getContactsManager(); - return $cm->getAddressBooks(); - } - - /** - * removes all registered address book instances - * @deprecated 8.1.0 use clear() of \OCP\Contacts\IManager - \OC::$server->getContactsManager(); - * @since 5.0.0 - */ - public static function clear() { - $cm = \OC::$server->getContactsManager(); - $cm->clear(); - } - } -} diff --git a/lib/public/db.php b/lib/public/db.php deleted file mode 100644 index 4706c5e95ee..00000000000 --- a/lib/public/db.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @author Dan Bartram - * @author Felix Moeller - * @author Frank Karlitschek - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * @author Thomas Tanghus - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * DB Class - * - */ - -// 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; - -/** - * This class provides access to the internal database system. Use this class exlusively if you want to access databases - * @deprecated 8.1.0 use methods of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 4.5.0 - */ -class DB { - /** - * Prepare a SQL query - * @param string $query Query string - * @param int $limit Limit of the SQL statement - * @param int $offset Offset of the SQL statement - * @return \OC_DB_StatementWrapper prepared SQL query - * - * SQL query via Doctrine prepare(), needs to be execute()'d! - * @deprecated 8.1.0 use prepare() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 4.5.0 - */ - static public function prepare( $query, $limit=null, $offset=null ) { - return(\OC_DB::prepare($query, $limit, $offset)); - } - - /** - * Insert a row if the matching row does not exists. - * - * @param string $table The table name (will replace *PREFIX* with the actual prefix) - * @param array $input data that should be inserted into the table (column name => value) - * @param array|null $compare List of values that should be checked for "if not exists" - * If this is null or an empty array, all keys of $input will be compared - * @return int number of inserted rows - * @throws \Doctrine\DBAL\DBALException - * @deprecated 8.1.0 use insertIfNotExist() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 5.0.0 - parameter $compare was added in 8.1.0 - * - */ - public static function insertIfNotExist($table, $input, array $compare = null) { - return \OC::$server->getDatabaseConnection()->insertIfNotExist($table, $input, $compare); - } - - /** - * Gets last value of autoincrement - * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix - * @return string - * - * \Doctrine\DBAL\Connection lastInsertID() - * - * Call this method right after the insert command or other functions may - * cause trouble! - * @deprecated 8.1.0 use lastInsertId() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 4.5.0 - */ - public static function insertid($table=null) { - return \OC::$server->getDatabaseConnection()->lastInsertId($table); - } - - /** - * Start a transaction - * @deprecated 8.1.0 use beginTransaction() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 4.5.0 - */ - public static function beginTransaction() { - \OC::$server->getDatabaseConnection()->beginTransaction(); - } - - /** - * Commit the database changes done during a transaction that is in progress - * @deprecated 8.1.0 use commit() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 4.5.0 - */ - public static function commit() { - \OC::$server->getDatabaseConnection()->commit(); - } - - /** - * Rollback the database changes done during a transaction that is in progress - * @deprecated 8.1.0 use rollback() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 8.0.0 - */ - public static function rollback() { - \OC::$server->getDatabaseConnection()->rollback(); - } - - /** - * Check if a result is an error, works with Doctrine - * @param mixed $result - * @return bool - * @deprecated 8.1.0 Doctrine returns false on error (and throws an exception) - * @since 4.5.0 - */ - public static function isError($result) { - // Doctrine returns false on error (and throws an exception) - return $result === false; - } - - /** - * returns the error code and message as a string for logging - * works with DoctrineException - * @return string - * @deprecated 8.1.0 use getError() of \OCP\IDBConnection - \OC::$server->getDatabaseConnection() - * @since 6.0.0 - */ - public static function getErrorMessage() { - return \OC::$server->getDatabaseConnection()->getError(); - } - -} diff --git a/lib/public/defaults.php b/lib/public/defaults.php deleted file mode 100644 index 58b25d5914a..00000000000 --- a/lib/public/defaults.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @author Lukas Reschke - * @author Morris Jobke - * @author scolebrook - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Defaults Class - * - */ - -// 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; - -/** - * public api to access default strings and urls for your templates - * @since 6.0.0 - */ -class Defaults { - - /** - * \OC_Defaults instance to retrieve the defaults - * @return string - * @since 6.0.0 - */ - private $defaults; - - /** - * creates a \OC_Defaults instance which is used in all methods to retrieve the - * actual defaults - * @since 6.0.0 - */ - function __construct() { - $this->defaults = new \OC_Defaults(); - } - - /** - * get base URL for the organisation behind your ownCloud instance - * @return string - * @since 6.0.0 - */ - public function getBaseUrl() { - return $this->defaults->getBaseUrl(); - } - - /** - * link to the desktop sync client - * @return string - * @since 6.0.0 - */ - public function getSyncClientUrl() { - return $this->defaults->getSyncClientUrl(); - } - - /** - * link to the iOS client - * @return string - * @since 8.0.0 - */ - public function getiOSClientUrl() { - return $this->defaults->getiOSClientUrl(); - } - - /** - * link to the Android client - * @return string - * @since 8.0.0 - */ - public function getAndroidClientUrl() { - return $this->defaults->getAndroidClientUrl(); - } - - /** - * base URL to the documentation of your ownCloud instance - * @return string - * @since 6.0.0 - */ - public function getDocBaseUrl() { - return $this->defaults->getDocBaseUrl(); - } - - /** - * name of your ownCloud instance - * @return string - * @since 6.0.0 - */ - public function getName() { - return $this->defaults->getName(); - } - - /** - * name of your ownCloud instance containing HTML styles - * @return string - * @since 8.0.0 - */ - public function getHTMLName() { - return $this->defaults->getHTMLName(); - } - - /** - * Entity behind your onwCloud instance - * @return string - * @since 6.0.0 - */ - public function getEntity() { - return $this->defaults->getEntity(); - } - - /** - * ownCloud slogan - * @return string - * @since 6.0.0 - */ - public function getSlogan() { - return $this->defaults->getSlogan(); - } - - /** - * logo claim - * @return string - * @since 6.0.0 - */ - public function getLogoClaim() { - return $this->defaults->getLogoClaim(); - } - - /** - * footer, short version - * @return string - * @since 6.0.0 - */ - public function getShortFooter() { - return $this->defaults->getShortFooter(); - } - - /** - * footer, long version - * @return string - * @since 6.0.0 - */ - public function getLongFooter() { - return $this->defaults->getLongFooter(); - } - - /** - * Returns the AppId for the App Store for the iOS Client - * @return string AppId - * @since 8.0.0 - */ - public function getiTunesAppId() { - return $this->defaults->getiTunesAppId(); - } -} diff --git a/lib/public/files.php b/lib/public/files.php deleted file mode 100644 index f7f0b30bf86..00000000000 --- a/lib/public/files.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @author Björn Schießle - * @author Frank Karlitschek - * @author Georg Ehrke - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Files Class - * - */ - -// 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; - -/** - * This class provides access to the internal filesystem abstraction layer. Use - * this class exlusively if you want to access files - * @since 5.0.0 - */ -class Files { - /** - * Recusive deletion of folders - * @return bool - * @since 5.0.0 - */ - static function rmdirr( $dir ) { - return \OC_Helper::rmdirr( $dir ); - } - - /** - * Get the mimetype form a local file - * @param string $path - * @return string - * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead - * @since 5.0.0 - */ - static function getMimeType( $path ) { - return \OC::$server->getMimeTypeDetector()->detect($path); - } - - /** - * Search for files by mimetype - * @param string $mimetype - * @return array - * @since 6.0.0 - */ - static public function searchByMime( $mimetype ) { - return(\OC\Files\Filesystem::searchByMime( $mimetype )); - } - - /** - * Copy the contents of one stream to another - * @param resource $source - * @param resource $target - * @return int the number of bytes copied - * @since 5.0.0 - */ - public static function streamCopy( $source, $target ) { - list($count, ) = \OC_Helper::streamCopy( $source, $target ); - return $count; - } - - /** - * Create a temporary file with an unique filename - * @param string $postfix - * @return string - * - * temporary files are automatically cleaned up after the script is finished - * @deprecated 8.1.0 use getTemporaryFile() of \OCP\ITempManager - \OC::$server->getTempManager() - * @since 5.0.0 - */ - public static function tmpFile( $postfix='' ) { - return \OC::$server->getTempManager()->getTemporaryFile($postfix); - } - - /** - * Create a temporary folder with an unique filename - * @return string - * - * temporary files are automatically cleaned up after the script is finished - * @deprecated 8.1.0 use getTemporaryFolder() of \OCP\ITempManager - \OC::$server->getTempManager() - * @since 5.0.0 - */ - public static function tmpFolder() { - return \OC::$server->getTempManager()->getTemporaryFolder(); - } - - /** - * Adds a suffix to the name in case the file exists - * @param string $path - * @param string $filename - * @return string - * @since 5.0.0 - */ - public static function buildNotExistingFileName( $path, $filename ) { - return(\OC_Helper::buildNotExistingFileName( $path, $filename )); - } - - /** - * Gets the Storage for an app - creates the needed folder if they are not - * existent - * @param string $app - * @return \OC\Files\View - * @since 5.0.0 - */ - public static function getStorage( $app ) { - return \OC_App::getStorage( $app ); - } -} diff --git a/lib/public/groupinterface.php b/lib/public/groupinterface.php deleted file mode 100644 index 628bc2f42ef..00000000000 --- a/lib/public/groupinterface.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Group Class. - * - */ - -// 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; - -/** - * TODO actually this is a IGroupBackend - * - * @package OCP - * @since 4.5.0 - */ -interface GroupInterface { - - /** - * Check if backend implements actions - * @param int $actions bitwise-or'ed actions - * @return boolean - * @since 4.5.0 - * - * Returns the supported actions as int to be - * compared with \OC_Group_Backend::CREATE_GROUP etc. - */ - public function implementsActions($actions); - - /** - * is user in group? - * @param string $uid uid of the user - * @param string $gid gid of the group - * @return bool - * @since 4.5.0 - * - * Checks whether the user is member of a group or not. - */ - public function inGroup($uid, $gid); - - /** - * Get all groups a user belongs to - * @param string $uid Name of the user - * @return array an array of group names - * @since 4.5.0 - * - * This function fetches all groups a user belongs to. It does not check - * if the user exists at all. - */ - public function getUserGroups($uid); - - /** - * get a list of all groups - * @param string $search - * @param int $limit - * @param int $offset - * @return array an array of group names - * @since 4.5.0 - * - * Returns a list with all groups - */ - public function getGroups($search = '', $limit = -1, $offset = 0); - - /** - * check if a group exists - * @param string $gid - * @return bool - * @since 4.5.0 - */ - public function 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 - * @since 4.5.0 - */ - public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0); - -} diff --git a/lib/public/iaddressbook.php b/lib/public/iaddressbook.php deleted file mode 100644 index 63e7e061448..00000000000 --- a/lib/public/iaddressbook.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @author Morris Jobke - * @author Robin McCorkell - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * IAddressBook interface - */ - -// 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 { - /** - * Interface IAddressBook - * - * @package OCP - * @since 5.0.0 - */ - interface IAddressBook { - - /** - * @return string defining the technical unique key - * @since 5.0.0 - */ - public function getKey(); - - /** - * In comparison to getKey() this function returns a human readable (maybe translated) name - * @return mixed - * @since 5.0.0 - */ - public function getDisplayName(); - - /** - * @param string $pattern which should match within the $searchProperties - * @param array $searchProperties defines the properties within the query pattern should match - * @param array $options - for future use. One should always have options! - * @return array an array of contacts which are arrays of key-value-pairs - * @since 5.0.0 - */ - public function search($pattern, $searchProperties, $options); - // // dummy results - // return array( - // array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), - // array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), - // ); - - /** - * @param array $properties this array if key-value-pairs defines a contact - * @return array an array representing the contact just created or updated - * @since 5.0.0 - */ - public function createOrUpdate($properties); - // // dummy - // return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', - // 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', - // 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' - // ); - - /** - * @return mixed - * @since 5.0.0 - */ - public function getPermissions(); - - /** - * @param object $id the unique identifier to a contact - * @return bool successful or not - * @since 5.0.0 - */ - public function delete($id); - } -} diff --git a/lib/public/iappconfig.php b/lib/public/iappconfig.php deleted file mode 100644 index 1406e8a56d6..00000000000 --- a/lib/public/iappconfig.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @author Morris Jobke - * @author Robin Appelman - * @author Robin McCorkell - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ -namespace OCP; - -/** - * This class provides an easy way for apps to store config values in the - * database. - * @since 7.0.0 - */ -interface IAppConfig { - /** - * check if a key is set in the appconfig - * @param string $app - * @param string $key - * @return bool - * @since 7.0.0 - */ - public function hasKey($app, $key); - - /** - * Gets the config value - * @param string $app app - * @param string $key key - * @param string $default = null, default value if the key does not exist - * @return string the value or $default - * @deprecated 8.0.0 use method getAppValue of \OCP\IConfig - * - * This function gets a value from the appconfig table. If the key does - * not exist the default value will be returned - * @since 7.0.0 - */ - public function getValue($app, $key, $default = null); - - /** - * Deletes a key - * @param string $app app - * @param string $key key - * @return bool - * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig - * @since 7.0.0 - */ - public function deleteKey($app, $key); - - /** - * Get the available keys for an app - * @param string $app the app we are looking for - * @return array an array of key names - * @deprecated 8.0.0 use method getAppKeys of \OCP\IConfig - * - * This function gets all keys of an app. Please note that the values are - * not returned. - * @since 7.0.0 - */ - public function getKeys($app); - - /** - * get multiply values, either the app or key can be used as wildcard by setting it to false - * - * @param string|false $key - * @param string|false $app - * @return array|false - * @since 7.0.0 - */ - public function getValues($app, $key); - - /** - * sets a value in the appconfig - * @param string $app app - * @param string $key key - * @param string $value value - * @deprecated 8.0.0 use method setAppValue of \OCP\IConfig - * - * Sets a value. If the key did not exist before it will be created. - * @return void - * @since 7.0.0 - */ - public function setValue($app, $key, $value); - - /** - * Get all apps using the config - * @return array an array of app ids - * - * This function returns a list of all apps that have at least one - * entry in the appconfig table. - * @since 7.0.0 - */ - public function getApps(); - - /** - * Remove app from appconfig - * @param string $app app - * @return bool - * @deprecated 8.0.0 use method deleteAppValue of \OCP\IConfig - * - * Removes all keys in appconfig belonging to the app. - * @since 7.0.0 - */ - public function deleteApp($app); -} diff --git a/lib/public/iavatar.php b/lib/public/iavatar.php deleted file mode 100644 index 7b811b26b68..00000000000 --- a/lib/public/iavatar.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @author Joas Schilling - * @author Morris Jobke - * @author Robin Appelman - * @author Roeland Jago Douma - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; -use OCP\Files\File; -use OCP\Files\NotFoundException; - -/** - * This class provides avatar functionality - * @since 6.0.0 - */ -interface IAvatar { - - /** - * get the users avatar - * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image - * @return boolean|\OCP\IImage containing the avatar or false if there's no image - * @since 6.0.0 - size of -1 was added in 9.0.0 - */ - public function get($size = 64); - - /** - * Check if an avatar exists for the user - * - * @return bool - * @since 8.1.0 - */ - public function exists(); - - /** - * sets the users avatar - * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar - * @throws \Exception if the provided file is not a jpg or png image - * @throws \Exception if the provided image is not valid - * @throws \OC\NotSquareException if the image is not square - * @return void - * @since 6.0.0 - */ - public function set($data); - - /** - * remove the users avatar - * @return void - * @since 6.0.0 - */ - public function remove(); - - /** - * Get the file of the avatar - * @param int $size -1 can be used to not scale the image - * @return File - * @throws NotFoundException - * @since 9.0.0 - */ - public function getFile($size); -} diff --git a/lib/public/iavatarmanager.php b/lib/public/iavatarmanager.php deleted file mode 100644 index ef6b00ffd13..00000000000 --- a/lib/public/iavatarmanager.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @author Christopher Schäpers - * @author Morris Jobke - * @author Robin McCorkell - * @author Roeland Jago Douma - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * This class provides avatar functionality - * @since 6.0.0 - */ - -interface IAvatarManager { - - /** - * return a user specific instance of \OCP\IAvatar - * @see \OCP\IAvatar - * @param string $user the ownCloud user id - * @return \OCP\IAvatar - * @throws \Exception In case the username is potentially dangerous - * @throws \OCP\Files\NotFoundException In case there is no user folder yet - * @since 6.0.0 - */ - public function getAvatar($user); -} diff --git a/lib/public/icache.php b/lib/public/icache.php deleted file mode 100644 index a1ce068d819..00000000000 --- a/lib/public/icache.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @author Thomas Müller - * @author Thomas Tanghus - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Cache interface - * - */ - -// 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; - -/** - * This interface defines method for accessing the file based user cache. - * @since 6.0.0 - */ -interface ICache { - - /** - * Get a value from the user cache - * @param string $key - * @return mixed - * @since 6.0.0 - */ - public function get($key); - - /** - * Set a value in the user cache - * @param string $key - * @param mixed $value - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 - * @return bool - * @since 6.0.0 - */ - public function set($key, $value, $ttl = 0); - - /** - * Check if a value is set in the user cache - * @param string $key - * @return bool - * @since 6.0.0 - * @deprecated 9.1.0 Directly read from GET to prevent race conditions - */ - public function hasKey($key); - - /** - * Remove an item from the user cache - * @param string $key - * @return bool - * @since 6.0.0 - */ - public function remove($key); - - /** - * Clear the user cache of all entries starting with a prefix - * @param string $prefix (optional) - * @return bool - * @since 6.0.0 - */ - public function clear($prefix = ''); -} diff --git a/lib/public/icachefactory.php b/lib/public/icachefactory.php deleted file mode 100644 index 233a4f5525d..00000000000 --- a/lib/public/icachefactory.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface ICacheFactory - * - * @package OCP - * @since 7.0.0 - */ -interface ICacheFactory{ - /** - * Get a memory cache instance - * - * All entries added trough the cache instance will be namespaced by $prefix to prevent collisions between apps - * - * @param string $prefix - * @return \OCP\ICache - * @since 7.0.0 - */ - public function create($prefix = ''); - - /** - * Check if any memory cache backend is available - * - * @return bool - * @since 7.0.0 - */ - public function isAvailable(); -} diff --git a/lib/public/icertificate.php b/lib/public/icertificate.php deleted file mode 100644 index c3a003fbf0a..00000000000 --- a/lib/public/icertificate.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface ICertificate - * - * @package OCP - * @since 8.0.0 - */ -interface ICertificate { - /** - * @return string - * @since 8.0.0 - */ - public function getName(); - - /** - * @return string - * @since 8.0.0 - */ - public function getCommonName(); - - /** - * @return string - * @since 8.0.0 - */ - public function getOrganization(); - - /** - * @return \DateTime - * @since 8.0.0 - */ - public function getIssueDate(); - - /** - * @return \DateTime - * @since 8.0.0 - */ - public function getExpireDate(); - - /** - * @return bool - * @since 8.0.0 - */ - public function isExpired(); - - /** - * @return string - * @since 8.0.0 - */ - public function getIssuerName(); - - /** - * @return string - * @since 8.0.0 - */ - public function getIssuerOrganization(); -} diff --git a/lib/public/icertificatemanager.php b/lib/public/icertificatemanager.php deleted file mode 100644 index 27eebcf0491..00000000000 --- a/lib/public/icertificatemanager.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @author Morris Jobke - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Manage trusted certificates for users - * @since 8.0.0 - */ -interface ICertificateManager { - /** - * Returns all certificates trusted by the user - * - * @return \OCP\ICertificate[] - * @since 8.0.0 - */ - public function listCertificates(); - - /** - * @param string $certificate the certificate data - * @param string $name the filename for the certificate - * @return \OCP\ICertificate - * @throws \Exception If the certificate could not get added - * @since 8.0.0 - since 8.1.0 throws exception instead of returning false - */ - public function addCertificate($certificate, $name); - - /** - * @param string $name - * @since 8.0.0 - */ - public function removeCertificate($name); - - /** - * Get the path to the certificate bundle for this user - * - * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle (since 9.0.0) - * @return string - * @since 8.0.0 - */ - public function getCertificateBundle($uid = ''); - - /** - * Get the full local path to the certificate bundle for this user - * - * @param string $uid (optional) user to get the certificate bundle for, use `null` to get the system bundle - * @return string - * @since 9.0.0 - */ - public function getAbsoluteBundlePath($uid = ''); -} diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php deleted file mode 100644 index 8dac390a99c..00000000000 --- a/lib/public/iconfig.php +++ /dev/null @@ -1,225 +0,0 @@ - - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Lukas Reschke - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Config interface - * - */ - -// 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; - -/** - * Access to all the configuration options ownCloud offers - * @since 6.0.0 - */ -interface IConfig { - /** - * @since 8.2.0 - */ - const SENSITIVE_VALUE = '***REMOVED SENSITIVE VALUE***'; - - /** - * Sets and deletes system wide values - * - * @param array $configs Associative array with `key => value` pairs - * If value is null, the config key will be deleted - * @since 8.0.0 - */ - public function setSystemValues(array $configs); - - /** - * Sets a new system wide value - * - * @param string $key the key of the value, under which will be saved - * @param mixed $value the value that should be stored - * @since 8.0.0 - */ - public function setSystemValue($key, $value); - - /** - * Looks up a system wide defined value - * - * @param string $key the key of the value, under which it was saved - * @param mixed $default the default value to be returned if the value isn't set - * @return mixed the value or $default - * @since 6.0.0 - parameter $default was added in 7.0.0 - */ - public function getSystemValue($key, $default = ''); - - /** - * Looks up a system wide defined value and filters out sensitive data - * - * @param string $key the key of the value, under which it was saved - * @param mixed $default the default value to be returned if the value isn't set - * @return mixed the value or $default - * @since 8.2.0 - */ - public function getFilteredSystemValue($key, $default = ''); - - /** - * Delete a system wide defined value - * - * @param string $key the key of the value, under which it was saved - * @since 8.0.0 - */ - public function deleteSystemValue($key); - - /** - * Get all keys stored for an app - * - * @param string $appName the appName that we stored the value under - * @return string[] the keys stored for the app - * @since 8.0.0 - */ - public function getAppKeys($appName); - - /** - * Writes a new app wide value - * - * @param string $appName the appName that we want to store the value under - * @param string $key the key of the value, under which will be saved - * @param string $value the value that should be stored - * @return void - * @since 6.0.0 - */ - public function setAppValue($appName, $key, $value); - - /** - * Looks up an app wide defined value - * - * @param string $appName the appName that we stored the value under - * @param string $key the key of the value, under which it was saved - * @param string $default the default value to be returned if the value isn't set - * @return string the saved value - * @since 6.0.0 - parameter $default was added in 7.0.0 - */ - public function getAppValue($appName, $key, $default = ''); - - /** - * Delete an app wide defined value - * - * @param string $appName the appName that we stored the value under - * @param string $key the key of the value, under which it was saved - * @since 8.0.0 - */ - public function deleteAppValue($appName, $key); - - /** - * Removes all keys in appconfig belonging to the app - * - * @param string $appName the appName the configs are stored under - * @since 8.0.0 - */ - public function deleteAppValues($appName); - - - /** - * Set a user defined value - * - * @param string $userId the userId of the user that we want to store the value under - * @param string $appName the appName that we want to store the value under - * @param string $key the key under which the value is being stored - * @param string $value the value that you want to store - * @param string $preCondition only update if the config value was previously the value passed as $preCondition - * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met - * @since 6.0.0 - parameter $precondition was added in 8.0.0 - */ - public function setUserValue($userId, $appName, $key, $value, $preCondition = null); - - /** - * Shortcut for getting a user defined value - * - * @param string $userId the userId of the user that we want to store the value under - * @param string $appName the appName that we stored the value under - * @param string $key the key under which the value is being stored - * @param mixed $default the default value to be returned if the value isn't set - * @return string - * @since 6.0.0 - parameter $default was added in 7.0.0 - */ - public function getUserValue($userId, $appName, $key, $default = ''); - - /** - * Fetches a mapped list of userId -> value, for a specified app and key and a list of user IDs. - * - * @param string $appName app to get the value for - * @param string $key the key to get the value for - * @param array $userIds the user IDs to fetch the values for - * @return array Mapped values: userId => value - * @since 8.0.0 - */ - public function getUserValueForUsers($appName, $key, $userIds); - - /** - * Get the keys of all stored by an app for the user - * - * @param string $userId the userId of the user that we want to store the value under - * @param string $appName the appName that we stored the value under - * @return string[] - * @since 8.0.0 - */ - public function getUserKeys($userId, $appName); - - /** - * Delete a user value - * - * @param string $userId the userId of the user that we want to store the value under - * @param string $appName the appName that we stored the value under - * @param string $key the key under which the value is being stored - * @since 8.0.0 - */ - public function deleteUserValue($userId, $appName, $key); - - /** - * Delete all user values - * - * @param string $userId the userId of the user that we want to remove all values from - * @since 8.0.0 - */ - public function deleteAllUserValues($userId); - - /** - * Delete all user related values of one app - * - * @param string $appName the appName of the app that we want to remove all values from - * @since 8.0.0 - */ - public function deleteAppFromAllUsers($appName); - - /** - * Determines the users that have the given value set for a specific app-key-pair - * - * @param string $appName the app to get the user for - * @param string $key the key to get the user for - * @param string $value the value to get the user for - * @return array of user IDs - * @since 8.0.0 - */ - public function getUsersForUserValue($appName, $key, $value); -} diff --git a/lib/public/icontainer.php b/lib/public/icontainer.php deleted file mode 100644 index d23ee5ea3b5..00000000000 --- a/lib/public/icontainer.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @author Joas Schilling - * @author Morris Jobke - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Container interface - * - */ - -// 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; - -use Closure; -use OCP\AppFramework\QueryException; - - -/** - * Class IContainer - * - * IContainer is the basic interface to be used for any internal dependency injection mechanism - * - * @package OCP - * @since 6.0.0 - */ -interface IContainer { - - /** - * If a parameter is not registered in the container try to instantiate it - * by using reflection to find out how to build the class - * @param string $name the class name to resolve - * @return \stdClass - * @since 8.2.0 - * @throws QueryException if the class could not be found or instantiated - */ - public function resolve($name); - - /** - * Look up a service for a given name in the container. - * - * @param string $name - * @return mixed - * @since 6.0.0 - */ - public function query($name); - - /** - * A value is stored in the container with it's corresponding name - * - * @param string $name - * @param mixed $value - * @return void - * @since 6.0.0 - */ - public function registerParameter($name, $value); - - /** - * A service is registered in the container where a closure is passed in which will actually - * create the service on demand. - * In case the parameter $shared is set to true (the default usage) the once created service will remain in - * memory and be reused on subsequent calls. - * In case the parameter is false the service will be recreated on every call. - * - * @param string $name - * @param \Closure $closure - * @param bool $shared - * @return void - * @since 6.0.0 - */ - public function registerService($name, Closure $closure, $shared = true); - - /** - * Shortcut for returning a service from a service under a different key, - * e.g. to tell the container to return a class when queried for an - * interface - * @param string $alias the alias that should be registered - * @param string $target the target that should be resolved instead - * @since 8.2.0 - */ - public function registerAlias($alias, $target); -} diff --git a/lib/public/idatetimeformatter.php b/lib/public/idatetimeformatter.php deleted file mode 100644 index e8d357ae50f..00000000000 --- a/lib/public/idatetimeformatter.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface IDateTimeFormatter - * - * @package OCP - * @since 8.0.0 - */ -interface IDateTimeFormatter { - /** - * Formats the date of the given timestamp - * - * @param int|\DateTime $timestamp - * @param string $format Either 'full', 'long', 'medium' or 'short' - * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' - * long: e.g. 'MMMM d, y' => 'August 20, 2014' - * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' - * short: e.g. 'M/d/yy' => '8/20/14' - * The exact format is dependent on the language - * @param \DateTimeZone $timeZone The timezone to use - * @param \OCP\IL10N $l The locale to use - * @return string Formatted date string - * @since 8.0.0 - */ - public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); - - /** - * Formats the date of the given timestamp - * - * @param int|\DateTime $timestamp - * @param string $format Either 'full', 'long', 'medium' or 'short' - * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' - * long: e.g. 'MMMM d, y' => 'August 20, 2014' - * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' - * short: e.g. 'M/d/yy' => '8/20/14' - * The exact format is dependent on the language - * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable - * @param \DateTimeZone $timeZone The timezone to use - * @param \OCP\IL10N $l The locale to use - * @return string Formatted relative date string - * @since 8.0.0 - */ - public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); - - /** - * Gives the relative date of the timestamp - * Only works for past dates - * - * @param int|\DateTime $timestamp - * @param int|\DateTime $baseTimestamp Timestamp to compare $timestamp against, defaults to current time - * @return string Dates returned are: - * < 1 month => Today, Yesterday, n days ago - * < 13 month => last month, n months ago - * >= 13 month => last year, n years ago - * @param \OCP\IL10N $l The locale to use - * @return string Formatted date span - * @since 8.0.0 - */ - public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); - - /** - * Formats the time of the given timestamp - * - * @param int|\DateTime $timestamp - * @param string $format Either 'full', 'long', 'medium' or 'short' - * full: e.g. 'h:mm:ss a zzzz' => '11:42:13 AM GMT+0:00' - * long: e.g. 'h:mm:ss a z' => '11:42:13 AM GMT' - * medium: e.g. 'h:mm:ss a' => '11:42:13 AM' - * short: e.g. 'h:mm a' => '11:42 AM' - * The exact format is dependent on the language - * @param \DateTimeZone $timeZone The timezone to use - * @param \OCP\IL10N $l The locale to use - * @return string Formatted time string - * @since 8.0.0 - */ - public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); - - /** - * Gives the relative past time of the timestamp - * - * @param int|\DateTime $timestamp - * @param int|\DateTime $baseTimestamp Timestamp to compare $timestamp against, defaults to current time - * @return string Dates returned are: - * < 60 sec => seconds ago - * < 1 hour => n minutes ago - * < 1 day => n hours ago - * < 1 month => Yesterday, n days ago - * < 13 month => last month, n months ago - * >= 13 month => last year, n years ago - * @param \OCP\IL10N $l The locale to use - * @return string Formatted time span - * @since 8.0.0 - */ - public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); - - /** - * Formats the date and time of the given timestamp - * - * @param int|\DateTime $timestamp - * @param string $formatDate See formatDate() for description - * @param string $formatTime See formatTime() for description - * @param \DateTimeZone $timeZone The timezone to use - * @param \OCP\IL10N $l The locale to use - * @return string Formatted date and time string - * @since 8.0.0 - */ - public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); - - /** - * Formats the date and time of the given timestamp - * - * @param int|\DateTime $timestamp - * @param string $formatDate See formatDate() for description - * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable - * @param string $formatTime See formatTime() for description - * @param \DateTimeZone $timeZone The timezone to use - * @param \OCP\IL10N $l The locale to use - * @return string Formatted relative date and time string - * @since 8.0.0 - */ - public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); -} diff --git a/lib/public/idatetimezone.php b/lib/public/idatetimezone.php deleted file mode 100644 index 3df705a2413..00000000000 --- a/lib/public/idatetimezone.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface IDateTimeZone - * - * @package OCP - * @since 8.0.0 - */ -interface IDateTimeZone { - /** - * @param bool|int $timestamp - * @return \DateTimeZone - * @since 8.0.0 - parameter $timestamp was added in 8.1.0 - */ - public function getTimeZone($timestamp = false); -} diff --git a/lib/public/idb.php b/lib/public/idb.php deleted file mode 100644 index f21fedd1f54..00000000000 --- a/lib/public/idb.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - - -/** - * Small Facade for being able to inject the database connection for tests - * @since 7.0.0 - extends IDBConnection was added in 8.1.0 - */ -interface IDb extends IDBConnection { - - - /** - * Used to abstract the owncloud database access away - * @param string $sql the sql query with ? placeholder for params - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start - * @return \OC_DB_StatementWrapper prepared SQL query - * @since 7.0.0 - */ - public function prepareQuery($sql, $limit=null, $offset=null); - - - /** - * Used to get the id of the just inserted element - * @param string $tableName the name of the table where we inserted the item - * @return int the id of the inserted element - * @since 7.0.0 - */ - public function getInsertId($tableName); - - -} diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php deleted file mode 100644 index 780fcd26364..00000000000 --- a/lib/public/idbconnection.php +++ /dev/null @@ -1,234 +0,0 @@ - - * @author Joas Schilling - * @author Morris Jobke - * @author Robin Appelman - * @author Robin McCorkell - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * DBConnection interface - * - */ - -// 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; -use OCP\DB\QueryBuilder\IQueryBuilder; - -/** - * Interface IDBConnection - * - * @package OCP - * @since 6.0.0 - */ -interface IDBConnection { - /** - * Gets the QueryBuilder for the connection. - * - * @return \OCP\DB\QueryBuilder\IQueryBuilder - * @since 8.2.0 - */ - public function getQueryBuilder(); - - /** - * Used to abstract the ownCloud database access away - * @param string $sql the sql query with ? placeholder for params - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start - * @return \Doctrine\DBAL\Driver\Statement The prepared statement. - * @since 6.0.0 - */ - public function prepare($sql, $limit=null, $offset=null); - - /** - * Executes an, optionally parameterized, SQL query. - * - * If the query is parameterized, a prepared statement is used. - * If an SQLLogger is configured, the execution is logged. - * - * @param string $query The SQL query to execute. - * @param string[] $params The parameters to bind to the query, if any. - * @param array $types The types the previous parameters are in. - * @return \Doctrine\DBAL\Driver\Statement The executed statement. - * @since 8.0.0 - */ - public function executeQuery($query, array $params = array(), $types = array()); - - /** - * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters - * and returns the number of affected rows. - * - * This method supports PDO binding types as well as DBAL mapping types. - * - * @param string $query The SQL query. - * @param array $params The query parameters. - * @param array $types The parameter types. - * @return integer The number of affected rows. - * @since 8.0.0 - */ - public function executeUpdate($query, array $params = array(), array $types = array()); - - /** - * Used to get the id of the just inserted element - * @param string $table the name of the table where we inserted the item - * @return int the id of the inserted element - * @since 6.0.0 - */ - public function lastInsertId($table = null); - - /** - * Insert a row if the matching row does not exists. - * - * @param string $table The table name (will replace *PREFIX* with the actual prefix) - * @param array $input data that should be inserted into the table (column name => value) - * @param array|null $compare List of values that should be checked for "if not exists" - * If this is null or an empty array, all keys of $input will be compared - * Please note: text fields (clob) must not be used in the compare array - * @return int number of inserted rows - * @throws \Doctrine\DBAL\DBALException - * @since 6.0.0 - parameter $compare was added in 8.1.0, return type changed from boolean in 8.1.0 - */ - public function insertIfNotExist($table, $input, array $compare = null); - - /** - * Insert or update a row value - * - * @param string $table - * @param array $keys (column name => value) - * @param array $values (column name => value) - * @param array $updatePreconditionValues ensure values match preconditions (column name => value) - * @return int number of new rows - * @throws \Doctrine\DBAL\DBALException - * @throws PreconditionNotMetException - * @since 9.0.0 - */ - public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []); - - /** - * Start a transaction - * @since 6.0.0 - */ - public function beginTransaction(); - - /** - * Check if a transaction is active - * - * @return bool - * @since 8.2.0 - */ - public function inTransaction(); - - /** - * Commit the database changes done during a transaction that is in progress - * @since 6.0.0 - */ - public function commit(); - - /** - * Rollback the database changes done during a transaction that is in progress - * @since 6.0.0 - */ - public function rollBack(); - - /** - * Gets the error code and message as a string for logging - * @return string - * @since 6.0.0 - */ - public function getError(); - - /** - * Fetch the SQLSTATE associated with the last database operation. - * - * @return integer The last error code. - * @since 8.0.0 - */ - public function errorCode(); - - /** - * Fetch extended error information associated with the last database operation. - * - * @return array The last error information. - * @since 8.0.0 - */ - public function errorInfo(); - - /** - * Establishes the connection with the database. - * - * @return bool - * @since 8.0.0 - */ - public function connect(); - - /** - * Close the database connection - * @since 8.0.0 - */ - public function close(); - - /** - * Quotes a given input parameter. - * - * @param mixed $input Parameter to be quoted. - * @param int $type Type of the parameter. - * @return string The quoted parameter. - * @since 8.0.0 - */ - public function quote($input, $type = IQueryBuilder::PARAM_STR); - - /** - * Gets the DatabasePlatform instance that provides all the metadata about - * the platform this driver connects to. - * - * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. - * @since 8.0.0 - */ - public function getDatabasePlatform(); - - /** - * Drop a table from the database if it exists - * - * @param string $table table name without the prefix - * @since 8.0.0 - */ - public function dropTable($table); - - /** - * Check if a table exists - * - * @param string $table table name without the prefix - * @return bool - * @since 8.0.0 - */ - public function tableExists($table); - - /** - * Escape a parameter to be used in a LIKE query - * - * @param string $param - * @return string - * @since 9.0.0 - */ - public function escapeLikeParameter($param); -} diff --git a/lib/public/ieventsource.php b/lib/public/ieventsource.php deleted file mode 100644 index b643d1c9da7..00000000000 --- a/lib/public/ieventsource.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * wrapper for server side events (http://en.wikipedia.org/wiki/Server-sent_events) - * includes a fallback for older browsers and IE - * - * use server side events with caution, to many open requests can hang the server - * - * The event source will initialize the connection to the client when the first data is sent - * @since 8.0.0 - */ -interface IEventSource { - /** - * send a message to the client - * - * @param string $type - * @param mixed $data - * - * if only one parameter is given, a typeless message will be send with that parameter as data - * @since 8.0.0 - */ - public function send($type, $data = null); - - /** - * close the connection of the event source - * @since 8.0.0 - */ - public function close(); -} diff --git a/lib/public/igroup.php b/lib/public/igroup.php deleted file mode 100644 index 02f2ef201fd..00000000000 --- a/lib/public/igroup.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface IGroup - * - * @package OCP - * @since 8.0.0 - */ -interface IGroup { - /** - * @return string - * @since 8.0.0 - */ - public function getGID(); - - /** - * get all users in the group - * - * @return \OCP\IUser[] - * @since 8.0.0 - */ - public function getUsers(); - - /** - * check if a user is in the group - * - * @param \OCP\IUser $user - * @return bool - * @since 8.0.0 - */ - public function inGroup($user); - - /** - * add a user to the group - * - * @param \OCP\IUser $user - * @since 8.0.0 - */ - public function addUser($user); - - /** - * remove a user from the group - * - * @param \OCP\IUser $user - * @since 8.0.0 - */ - public function removeUser($user); - - /** - * search for users in the group by userid - * - * @param string $search - * @param int $limit - * @param int $offset - * @return \OCP\IUser[] - * @since 8.0.0 - */ - public function searchUsers($search, $limit = null, $offset = null); - - /** - * returns the number of users matching the search string - * - * @param string $search - * @return int|bool - * @since 8.0.0 - */ - public function count($search = ''); - - /** - * search for users in the group by displayname - * - * @param string $search - * @param int $limit - * @param int $offset - * @return \OCP\IUser[] - * @since 8.0.0 - */ - public function searchDisplayName($search, $limit = null, $offset = null); - - /** - * delete the group - * - * @return bool - * @since 8.0.0 - */ - public function delete(); -} diff --git a/lib/public/igroupmanager.php b/lib/public/igroupmanager.php deleted file mode 100644 index cda40606f9d..00000000000 --- a/lib/public/igroupmanager.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Lukas Reschke - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Class Manager - * - * Hooks available in scope \OC\Group: - * - preAddUser(\OC\Group\Group $group, \OC\User\User $user) - * - postAddUser(\OC\Group\Group $group, \OC\User\User $user) - * - preRemoveUser(\OC\Group\Group $group, \OC\User\User $user) - * - postRemoveUser(\OC\Group\Group $group, \OC\User\User $user) - * - preDelete(\OC\Group\Group $group) - * - postDelete(\OC\Group\Group $group) - * - preCreate(string $groupId) - * - postCreate(\OC\Group\Group $group) - * - * @package OC\Group - * @since 8.0.0 - */ -interface IGroupManager { - /** - * Checks whether a given backend is used - * - * @param string $backendClass Full classname including complete namespace - * @return bool - * @since 8.1.0 - */ - public function isBackendUsed($backendClass); - - /** - * @param \OCP\GroupInterface $backend - * @since 8.0.0 - */ - public function addBackend($backend); - - /** - * @since 8.0.0 - */ - public function clearBackends(); - - /** - * @param string $gid - * @return \OCP\IGroup - * @since 8.0.0 - */ - public function get($gid); - - /** - * @param string $gid - * @return bool - * @since 8.0.0 - */ - public function groupExists($gid); - - /** - * @param string $gid - * @return \OCP\IGroup - * @since 8.0.0 - */ - public function createGroup($gid); - - /** - * @param string $search - * @param int $limit - * @param int $offset - * @return \OCP\IGroup[] - * @since 8.0.0 - */ - public function search($search, $limit = null, $offset = null); - - /** - * @param \OCP\IUser|null $user - * @return \OCP\IGroup[] - * @since 8.0.0 - */ - public function getUserGroups($user); - - /** - * @param \OCP\IUser $user - * @return array with group names - * @since 8.0.0 - */ - public function getUserGroupIds($user); - - /** - * 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) - * @since 8.0.0 - */ - public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0); - - /** - * Checks if a userId is in the admin group - * @param string $userId - * @return bool if admin - * @since 8.0.0 - */ - public function isAdmin($userId); - - /** - * Checks if a userId is in a group - * @param string $userId - * @param string $group - * @return bool if in group - * @since 8.0.0 - */ - public function isInGroup($userId, $group); -} diff --git a/lib/public/ihelper.php b/lib/public/ihelper.php deleted file mode 100644 index 4ad1d5704fd..00000000000 --- a/lib/public/ihelper.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @author Lukas Reschke - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Helper interface - * - */ - -// 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; - -/** - * Functions that don't have any specific interface to place - * @since 6.0.0 - * @deprecated 8.1.0 - */ -interface IHelper { - /** - * Gets the content of an URL by using CURL or a fallback if it is not - * installed - * @param string $url the url that should be fetched - * @return string the content of the webpage - * @since 6.0.0 - * @deprecated 8.1.0 Use \OCP\IServerContainer::getHTTPClientService - */ - public function getUrlContent($url); -} diff --git a/lib/public/iimage.php b/lib/public/iimage.php deleted file mode 100644 index db0ca0f93be..00000000000 --- a/lib/public/iimage.php +++ /dev/null @@ -1,185 +0,0 @@ - - * @author Morris Jobke - * @author Olivier Paroz - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Class for basic image manipulation - * @since 8.1.0 - */ -interface IImage { - /** - * Determine whether the object contains an image resource. - * - * @return bool - * @since 8.1.0 - */ - public function valid(); - - /** - * Returns the MIME type of the image or an empty string if no image is loaded. - * - * @return string - * @since 8.1.0 - */ - public function mimeType(); - - /** - * Returns the width of the image or -1 if no image is loaded. - * - * @return int - * @since 8.1.0 - */ - public function width(); - - /** - * Returns the height of the image or -1 if no image is loaded. - * - * @return int - * @since 8.1.0 - */ - public function height(); - - /** - * Returns the width when the image orientation is top-left. - * - * @return int - * @since 8.1.0 - */ - public function widthTopLeft(); - - /** - * Returns the height when the image orientation is top-left. - * - * @return int - * @since 8.1.0 - */ - public function heightTopLeft(); - - /** - * Outputs the image. - * - * @param string $mimeType - * @return bool - * @since 8.1.0 - */ - public function show($mimeType = null); - - /** - * Saves the image. - * - * @param string $filePath - * @param string $mimeType - * @return bool - * @since 8.1.0 - */ - public function save($filePath = null, $mimeType = null); - - /** - * @return resource Returns the image resource in any. - * @since 8.1.0 - */ - public function resource(); - - /** - * @return string Returns the raw image data. - * @since 8.1.0 - */ - public function data(); - - /** - * (I'm open for suggestions on better method name ;) - * Get the orientation based on EXIF data. - * - * @return int The orientation or -1 if no EXIF data is available. - * @since 8.1.0 - */ - public function getOrientation(); - - /** - * (I'm open for suggestions on better method name ;) - * Fixes orientation based on EXIF data. - * - * @return bool - * @since 8.1.0 - */ - public function fixOrientation(); - - /** - * Resizes the image preserving ratio. - * - * @param integer $maxSize The maximum size of either the width or height. - * @return bool - * @since 8.1.0 - */ - public function resize($maxSize); - - /** - * @param int $width - * @param int $height - * @return bool - * @since 8.1.0 - */ - public function preciseResize($width, $height); - - /** - * Crops the image to the middle square. If the image is already square it just returns. - * - * @param int $size maximum size for the result (optional) - * @return bool for success or failure - * @since 8.1.0 - */ - public function centerCrop($size = 0); - - /** - * Crops the image from point $x$y with dimension $wx$h. - * - * @param int $x Horizontal position - * @param int $y Vertical position - * @param int $w Width - * @param int $h Height - * @return bool for success or failure - * @since 8.1.0 - */ - public function crop($x, $y, $w, $h); - - /** - * Resizes the image to fit within a boundary while preserving ratio. - * - * @param integer $maxWidth - * @param integer $maxHeight - * @return bool - * @since 8.1.0 - */ - public function fitIn($maxWidth, $maxHeight); - - /** - * Shrinks the image to fit within a boundary while preserving ratio. - * - * @param integer $maxWidth - * @param integer $maxHeight - * @return bool - * @since 8.1.0 - */ - public function scaleDownToFit($maxWidth, $maxHeight); -} diff --git a/lib/public/il10n.php b/lib/public/il10n.php deleted file mode 100644 index f1954eeb4b9..00000000000 --- a/lib/public/il10n.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @author Bernhard Posselt - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * @author Robin McCorkell - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * L10n interface - * - */ - -// 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; - -/** - * Interface IL10N - * - * @package OCP - * @since 6.0.0 - */ -interface IL10N { - /** - * Translating - * @param string $text The text we need a translation for - * @param array $parameters default:array() Parameters for sprintf - * @return \OC_L10N_String Translation or the same text - * - * Returns the translation. If no translation is found, $text will be - * returned. - * @since 6.0.0 - */ - public function t($text, $parameters = array()); - - /** - * Translating - * @param string $text_singular the string to translate for exactly one object - * @param string $text_plural the string to translate for n objects - * @param integer $count Number of objects - * @param array $parameters default:array() Parameters for sprintf - * @return \OC_L10N_String Translation or the same text - * - * Returns the translation. If no translation is found, $text will be - * returned. %n will be replaced with the number of objects. - * - * The correct plural is determined by the plural_forms-function - * provided by the po file. - * @since 6.0.0 - * - */ - public function n($text_singular, $text_plural, $count, $parameters = array()); - - /** - * Localization - * @param string $type Type of localization - * @param int|string $data parameters for this localization - * @param array $options currently supports following options: - * - 'width': handed into \Punic\Calendar::formatDate as second parameter - * @return string|false - * - * Returns the localized data. - * - * Implemented types: - * - date - * - Creates a date - * - l10n-field: date - * - params: timestamp (int/string) - * - datetime - * - Creates date and time - * - l10n-field: datetime - * - params: timestamp (int/string) - * - time - * - Creates a time - * - l10n-field: time - * - params: timestamp (int/string) - * @since 6.0.0 - parameter $options was added in 8.0.0 - */ - public function l($type, $data, $options = array()); - - - /** - * The code (en, de, ...) of the language that is used for this IL10N object - * - * @return string language - * @since 7.0.0 - */ - public function getLanguageCode(); -} diff --git a/lib/public/ilogger.php b/lib/public/ilogger.php deleted file mode 100644 index fa947612fcd..00000000000 --- a/lib/public/ilogger.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @author Morris Jobke - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface ILogger - * @package OCP - * @since 7.0.0 - * - * This logger interface follows the design guidelines of PSR-3 - * https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#3-psrlogloggerinterface - */ -interface ILogger { - /** - * System is unusable. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function emergency($message, array $context = array()); - - /** - * Action must be taken immediately. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function alert($message, array $context = array()); - - /** - * Critical conditions. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function critical($message, array $context = array()); - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function error($message, array $context = array()); - - /** - * Exceptional occurrences that are not errors. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function warning($message, array $context = array()); - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function notice($message, array $context = array()); - - /** - * Interesting events. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function info($message, array $context = array()); - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * @return null - * @since 7.0.0 - */ - public function debug($message, array $context = array()); - - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - * @return mixed - * @since 7.0.0 - */ - public function log($level, $message, array $context = array()); - - /** - * Logs an exception very detailed - * An additional message can we written to the log by adding it to the - * context. - * - * - * $logger->logException($ex, [ - * 'message' => 'Exception during cron job execution' - * ]); - * - * - * @param \Exception | \Throwable $exception - * @param array $context - * @return void - * @since 8.2.0 - */ - public function logException($exception, array $context = array()); -} diff --git a/lib/public/image.php b/lib/public/image.php deleted file mode 100644 index 4a7ffe8bc9a..00000000000 --- a/lib/public/image.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Image class - * - */ - -// 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; - -/** - * This class provides functions to handle images - * @since 6.0.0 - */ -class Image extends \OC_Image { -} diff --git a/lib/public/imemcache.php b/lib/public/imemcache.php deleted file mode 100644 index b5c0cef923d..00000000000 --- a/lib/public/imemcache.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Cache interface - * - */ - -// 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; - -/** - * This interface defines method for accessing the file based user cache. - * - * @since 8.1.0 - */ -interface IMemcache extends ICache { - /** - * Set a value in the cache if it's not already stored - * - * @param string $key - * @param mixed $value - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 - * @return bool - * @since 8.1.0 - */ - public function add($key, $value, $ttl = 0); - - /** - * Increase a stored number - * - * @param string $key - * @param int $step - * @return int | bool - * @since 8.1.0 - */ - public function inc($key, $step = 1); - - /** - * Decrease a stored number - * - * @param string $key - * @param int $step - * @return int | bool - * @since 8.1.0 - */ - public function dec($key, $step = 1); - - /** - * Compare and set - * - * @param string $key - * @param mixed $old - * @param mixed $new - * @return bool - * @since 8.1.0 - */ - public function cas($key, $old, $new); - - /** - * Compare and delete - * - * @param string $key - * @param mixed $old - * @return bool - * @since 8.1.0 - */ - public function cad($key, $old); -} diff --git a/lib/public/imemcachettl.php b/lib/public/imemcachettl.php deleted file mode 100644 index f2d03dcdf40..00000000000 --- a/lib/public/imemcachettl.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface for memcache backends that support setting ttl after the value is set - * - * @since 8.2.2 - */ -interface IMemcacheTTL extends IMemcache { - /** - * Set the ttl for an existing value - * - * @param string $key - * @param int $ttl time to live in seconds - * @since 8.2.2 - */ - public function setTTL($key, $ttl); -} diff --git a/lib/public/inavigationmanager.php b/lib/public/inavigationmanager.php deleted file mode 100644 index 243f6ea3eea..00000000000 --- a/lib/public/inavigationmanager.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Navigation manager interface - * - */ - -// 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; - -/** - * Manages the ownCloud navigation - * @since 6.0.0 - */ -interface INavigationManager { - /** - * Creates a new navigation entry - * - * @param array|\Closure $entry Array containing: id, name, order, icon and href key - * The use of a closure is preferred, because it will avoid - * loading the routing of your app, unless required. - * @return void - * @since 6.0.0 - */ - public function add($entry); - - /** - * Sets the current navigation entry of the currently running app - * @param string $appId id of the app entry to activate (from added $entry) - * @return void - * @since 6.0.0 - */ - public function setActiveEntry($appId); -} diff --git a/lib/public/ipreview.php b/lib/public/ipreview.php deleted file mode 100644 index cfcbebd8639..00000000000 --- a/lib/public/ipreview.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Preview interface - * - */ - -// 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; - -/** - * This class provides functions to render and show thumbnails and previews of files - * @since 6.0.0 - */ -interface IPreview { - /** - * In order to improve lazy loading a closure can be registered which will be - * called in case preview providers are actually requested - * - * $callable has to return an instance of \OCP\Preview\IProvider - * - * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider - * @param \Closure $callable - * @return void - * @since 8.1.0 - */ - public function registerProvider($mimeTypeRegex, \Closure $callable); - - /** - * Get all providers - * @return array - * @since 8.1.0 - */ - public function getProviders(); - - /** - * Does the manager have any providers - * @return bool - * @since 8.1.0 - */ - public function hasProviders(); - - /** - * Return a preview of a file - * @param string $file The path to the file where you want a thumbnail from - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image - * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly - * @return \OCP\IImage - * @since 6.0.0 - */ - public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false); - - - /** - * Returns true if the passed mime type is supported - * @param string $mimeType - * @return boolean - * @since 6.0.0 - */ - public function isMimeSupported($mimeType = '*'); - - /** - * Check if a preview can be generated for a file - * - * @param \OCP\Files\FileInfo $file - * @return bool - * @since 8.0.0 - */ - public function isAvailable(\OCP\Files\FileInfo $file); -} diff --git a/lib/public/irequest.php b/lib/public/irequest.php deleted file mode 100644 index 296c70f4ecc..00000000000 --- a/lib/public/irequest.php +++ /dev/null @@ -1,245 +0,0 @@ - - * @author Jörn Friedrich Dreyer - * @author Lukas Reschke - * @author Morris Jobke - * @author Thomas Müller - * @author Thomas Tanghus - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Request interface - * - */ - -// 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; - -/** - * This interface provides an immutable object with with accessors to - * request variables and headers. - * - * Access request variables by method and name. - * - * Examples: - * - * $request->post['myvar']; // Only look for POST variables - * $request->myvar; or $request->{'myvar'}; or $request->{$myvar} - * Looks in the combined GET, POST and urlParams array. - * - * If you access e.g. ->post but the current HTTP request method - * is GET a \LogicException will be thrown. - * - * NOTE: - * - When accessing ->put a stream resource is returned and the accessor - * will return false on subsequent access to ->put or ->patch. - * - When accessing ->patch and the Content-Type is either application/json - * or application/x-www-form-urlencoded (most cases) it will act like ->get - * and ->post and return an array. Otherwise the raw data will be returned. - * - * @property-read string[] $server - * @property-read string[] $urlParams - * @since 6.0.0 - */ -interface IRequest { - - /** - * @param string $name - * - * @return string - * @since 6.0.0 - */ - public function getHeader($name); - - /** - * Lets you access post and get parameters by the index - * In case of json requests the encoded json body is accessed - * - * @param string $key the key which you want to access in the URL Parameter - * placeholder, $_POST or $_GET array. - * The priority how they're returned is the following: - * 1. URL parameters - * 2. POST parameters - * 3. GET parameters - * @param mixed $default If the key is not found, this value will be returned - * @return mixed the content of the array - * @since 6.0.0 - */ - public function getParam($key, $default = null); - - - /** - * Returns all params that were received, be it from the request - * - * (as GET or POST) or through the URL by the route - * - * @return array the array with all parameters - * @since 6.0.0 - */ - public function getParams(); - - /** - * Returns the method of the request - * - * @return string the method of the request (POST, GET, etc) - * @since 6.0.0 - */ - public function getMethod(); - - /** - * Shortcut for accessing an uploaded file through the $_FILES array - * - * @param string $key the key that will be taken from the $_FILES array - * @return array the file in the $_FILES element - * @since 6.0.0 - */ - public function getUploadedFile($key); - - - /** - * Shortcut for getting env variables - * - * @param string $key the key that will be taken from the $_ENV array - * @return array the value in the $_ENV element - * @since 6.0.0 - */ - public function getEnv($key); - - - /** - * Shortcut for getting cookie variables - * - * @param string $key the key that will be taken from the $_COOKIE array - * @return string the value in the $_COOKIE element - * @since 6.0.0 - */ - public function getCookie($key); - - - /** - * Checks if the CSRF check was correct - * - * @return bool true if CSRF check passed - * @since 6.0.0 - */ - public function passesCSRFCheck(); - - /** - * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging - * If `mod_unique_id` is installed this value will be taken. - * - * @return string - * @since 8.1.0 - */ - public function getId(); - - /** - * Returns the remote address, if the connection came from a trusted proxy - * and `forwarded_for_headers` has been configured then the IP address - * specified in this header will be returned instead. - * Do always use this instead of $_SERVER['REMOTE_ADDR'] - * - * @return string IP address - * @since 8.1.0 - */ - public function getRemoteAddress(); - - /** - * Returns the server protocol. It respects reverse proxy servers and load - * balancers. - * - * @return string Server protocol (http or https) - * @since 8.1.0 - */ - public function getServerProtocol(); - - /** - * Returns the used HTTP protocol. - * - * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. - * @since 8.2.0 - */ - public function getHttpProtocol(); - - /** - * Returns the request uri, even if the website uses one or more - * reverse proxies - * - * @return string - * @since 8.1.0 - */ - public function getRequestUri(); - - /** - * Get raw PathInfo from request (not urldecoded) - * - * @throws \Exception - * @return string Path info - * @since 8.1.0 - */ - public function getRawPathInfo(); - - /** - * Get PathInfo from request - * - * @throws \Exception - * @return string|false Path info or false when not found - * @since 8.1.0 - */ - public function getPathInfo(); - - /** - * Returns the script name, even if the website uses one or more - * reverse proxies - * - * @return string the script name - * @since 8.1.0 - */ - public function getScriptName(); - - /** - * Checks whether the user agent matches a given regex - * - * @param array $agent array of agent names - * @return bool true if at least one of the given agent matches, false otherwise - * @since 8.1.0 - */ - public function isUserAgent(array $agent); - - /** - * Returns the unverified server host from the headers without checking - * whether it is a trusted domain - * - * @return string Server host - * @since 8.1.0 - */ - public function getInsecureServerHost(); - - /** - * Returns the server host from the headers, or the first configured - * trusted domain if the host isn't in the trusted list - * - * @return string Server host - * @since 8.1.0 - */ - public function getServerHost(); -} diff --git a/lib/public/isearch.php b/lib/public/isearch.php deleted file mode 100644 index ec6673dabbd..00000000000 --- a/lib/public/isearch.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @author Bart Visscher - * @author Jakob Sack - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - - -/** - * Small Interface for Search - * @since 7.0.0 - */ -interface ISearch { - - /** - * Search all providers for $query - * @param string $query - * @param string[] $inApps optionally limit results to the given apps - * @return array An array of OCP\Search\Result's - * @deprecated 8.0.0 use searchPaged() with page and size - * @since 7.0.0 - parameter $inApps was added in 8.0.0 - */ - public function search($query, array $inApps = array()); - - /** - * Search all providers for $query - * @param string $query - * @param string[] $inApps optionally limit results to the given apps - * @param int $page pages start at page 1 - * @param int $size - * @return array An array of OCP\Search\Result's - * @since 8.0.0 - */ - public function searchPaged($query, array $inApps = array(), $page = 1, $size = 30); - - /** - * Register a new search provider to search with - * @param string $class class name of a OCP\Search\Provider - * @param array $options optional - * @since 7.0.0 - */ - public function registerProvider($class, array $options = array()); - - /** - * Remove one existing search provider - * @param string $provider class name of a OCP\Search\Provider - * @since 7.0.0 - */ - public function removeProvider($provider); - - /** - * Remove all registered search providers - * @since 7.0.0 - */ - public function clearProviders(); - -} diff --git a/lib/public/isession.php b/lib/public/isession.php deleted file mode 100644 index 7bc8654a1b9..00000000000 --- a/lib/public/isession.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @author Morris Jobke - * @author Thomas Müller - * @author Thomas Tanghus - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Session interface - * - */ - -// 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; - -/** - * Interface ISession - * - * wrap PHP's internal session handling into the ISession interface - * @since 6.0.0 - */ -interface ISession { - - /** - * Set a value in the session - * - * @param string $key - * @param mixed $value - * @since 6.0.0 - */ - public function set($key, $value); - - /** - * Get a value from the session - * - * @param string $key - * @return mixed should return null if $key does not exist - * @since 6.0.0 - */ - public function get($key); - - /** - * Check if a named key exists in the session - * - * @param string $key - * @return bool - * @since 6.0.0 - */ - public function exists($key); - - /** - * Remove a $key/$value pair from the session - * - * @param string $key - * @since 6.0.0 - */ - public function remove($key); - - /** - * Reset and recreate the session - * @since 6.0.0 - */ - public function clear(); - - /** - * Close the session and release the lock - * @since 7.0.0 - */ - public function close(); - - /** - * Wrapper around session_regenerate_id - * - * @param bool $deleteOldSession Whether to delete the old associated session file or not. - * @return void - * @since 9.0.0 - */ - public function regenerateId($deleteOldSession = true); - - /** - * Wrapper around session_id - * - * @return string - * @throws SessionNotAvailableException - * @since 9.1.0 - */ - public function getId(); -} diff --git a/lib/public/itagmanager.php b/lib/public/itagmanager.php deleted file mode 100644 index e6d67ddd02c..00000000000 --- a/lib/public/itagmanager.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @author Morris Jobke - * @author Thomas Tanghus - * @author Vincent Petry - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Tag manager interface - * - */ - -// 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; - -/** - * Factory class creating instances of \OCP\ITags - * - * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or - * anything else that is either parsed from a vobject or that the user chooses - * to add. - * Tag names are not case-sensitive, but will be saved with the case they - * are entered in. If a user already has a tag 'family' for a type, and - * tries to add a tag named 'Family' it will be silently ignored. - * @since 6.0.0 - */ -interface ITagManager { - - /** - * Create a new \OCP\ITags instance and load tags from db for the current user. - * - * @see \OCP\ITags - * @param string $type The type identifier e.g. 'contact' or 'event'. - * @param array $defaultTags An array of default tags to be used if none are stored. - * @param boolean $includeShared Whether to include tags for items shared with this user by others. - * @param string $userId user for which to retrieve the tags, defaults to the currently - * logged in user - * @return \OCP\ITags - * @since 6.0.0 - parameter $includeShared and $userId were added in 8.0.0 - */ - public function load($type, $defaultTags = array(), $includeShared = false, $userId = null); -} diff --git a/lib/public/itags.php b/lib/public/itags.php deleted file mode 100644 index cbc178c37bf..00000000000 --- a/lib/public/itags.php +++ /dev/null @@ -1,227 +0,0 @@ - - * @author Morris Jobke - * @author Thomas Tanghus - * @author Vincent Petry - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Tags interface - * - */ - -// 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; - -// FIXME: Where should I put this? Or should it be implemented as a Listener? -\OC_Hook::connect('OC_User', 'post_deleteUser', 'OC\Tags', 'post_deleteUser'); - -/** - * Class for easily tagging objects by their id - * - * A tag can be e.g. 'Family', 'Work', 'Chore', 'Special Occation' or - * anything else that is either parsed from a vobject or that the user chooses - * to add. - * Tag names are not case-sensitive, but will be saved with the case they - * are entered in. If a user already has a tag 'family' for a type, and - * tries to add a tag named 'Family' it will be silently ignored. - * @since 6.0.0 - */ - -interface ITags { - - /** - * Check if any tags are saved for this type and user. - * - * @return boolean - * @since 6.0.0 - */ - public function isEmpty(); - - /** - * Returns an array mapping a given tag's properties to its values: - * ['id' => 0, 'name' = 'Tag', 'owner' = 'User', 'type' => 'tagtype'] - * - * @param string $id The ID of the tag that is going to be mapped - * @return array|false - * @since 8.0.0 - */ - public function getTag($id); - - /** - * Get the tags for a specific user. - * - * This returns an array with id/name maps: - * [ - * ['id' => 0, 'name' = 'First tag'], - * ['id' => 1, 'name' = 'Second tag'], - * ] - * - * @return array - * @since 6.0.0 - */ - public function getTags(); - - /** - * Get a list of tags for the given item ids. - * - * This returns an array with object id / tag names: - * [ - * 1 => array('First tag', 'Second tag'), - * 2 => array('Second tag'), - * 3 => array('Second tag', 'Third tag'), - * ] - * - * @param array $objIds item ids - * @return array|boolean with object id as key and an array - * of tag names as value or false if an error occurred - * @since 8.0.0 - */ - public function getTagsForObjects(array $objIds); - - /** - * Get a list of items tagged with $tag. - * - * Throws an exception if the tag could not be found. - * - * @param string|integer $tag Tag id or name. - * @return array|false An array of object ids or false on error. - * @since 6.0.0 - */ - public function getIdsForTag($tag); - - /** - * Checks whether a tag is already saved. - * - * @param string $name The name to check for. - * @return bool - * @since 6.0.0 - */ - public function hasTag($name); - - /** - * Checks whether a tag is saved for the given user, - * disregarding the ones shared with him or her. - * - * @param string $name The tag name to check for. - * @param string $user The user whose tags are to be checked. - * @return bool - * @since 8.0.0 - */ - public function userHasTag($name, $user); - - /** - * Add a new tag. - * - * @param string $name A string with a name of the tag - * @return int|false the id of the added tag or false if it already exists. - * @since 6.0.0 - */ - public function add($name); - - /** - * Rename tag. - * - * @param string|integer $from The name or ID of the existing tag - * @param string $to The new name of the tag. - * @return bool - * @since 6.0.0 - */ - public function rename($from, $to); - - /** - * Add a list of new tags. - * - * @param string[] $names A string with a name or an array of strings containing - * the name(s) of the to add. - * @param bool $sync When true, save the tags - * @param int|null $id int Optional object id to add to this|these tag(s) - * @return bool Returns false on error. - * @since 6.0.0 - */ - public function addMultiple($names, $sync=false, $id = null); - - /** - * Delete tag/object relations from the db - * - * @param array $ids The ids of the objects - * @return boolean Returns false on error. - * @since 6.0.0 - */ - public function purgeObjects(array $ids); - - /** - * Get favorites for an object type - * - * @return array|false An array of object ids. - * @since 6.0.0 - */ - public function getFavorites(); - - /** - * Add an object to favorites - * - * @param int $objid The id of the object - * @return boolean - * @since 6.0.0 - */ - public function addToFavorites($objid); - - /** - * Remove an object from favorites - * - * @param int $objid The id of the object - * @return boolean - * @since 6.0.0 - */ - public function removeFromFavorites($objid); - - /** - * Creates a tag/object relation. - * - * @param int $objid The id of the object - * @param string $tag The id or name of the tag - * @return boolean Returns false on database error. - * @since 6.0.0 - */ - public function tagAs($objid, $tag); - - /** - * Delete single tag/object relation from the db - * - * @param int $objid The id of the object - * @param string $tag The id or name of the tag - * @return boolean - * @since 6.0.0 - */ - public function unTag($objid, $tag); - - /** - * Delete tags from the database - * - * @param string[]|integer[] $names An array of tags (names or IDs) to delete - * @return bool Returns false on error - * @since 6.0.0 - */ - public function delete($names); - -} diff --git a/lib/public/itempmanager.php b/lib/public/itempmanager.php deleted file mode 100644 index 025e43d8563..00000000000 --- a/lib/public/itempmanager.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @author Robin Appelman - * @author Robin McCorkell - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface ITempManager - * - * @package OCP - * @since 8.0.0 - */ -interface ITempManager { - /** - * Create a temporary file and return the path - * - * @param string $postFix - * @return string - * @since 8.0.0 - */ - public function getTemporaryFile($postFix = ''); - - /** - * Create a temporary folder and return the path - * - * @param string $postFix - * @return string - * @since 8.0.0 - */ - public function getTemporaryFolder($postFix = ''); - - /** - * Remove the temporary files and folders generated during this request - * @since 8.0.0 - */ - public function clean(); - - /** - * Remove old temporary files and folders that were failed to be cleaned - * @since 8.0.0 - */ - public function cleanOld(); - - /** - * Get the temporary base directory - * - * @return string - * @since 8.2.0 - */ - public function getTempBaseDir(); -} diff --git a/lib/public/iurlgenerator.php b/lib/public/iurlgenerator.php deleted file mode 100644 index a702ca47bfc..00000000000 --- a/lib/public/iurlgenerator.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @author Joas Schilling - * @author Morris Jobke - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * URL generator interface - * - */ - -// 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; - -/** - * Class to generate URLs - * @since 6.0.0 - */ -interface IURLGenerator { - /** - * Returns the URL for a route - * @param string $routeName the name of the route - * @param array $arguments an array with arguments which will be filled into the url - * @return string the url - * @since 6.0.0 - */ - public function linkToRoute($routeName, $arguments = array()); - - /** - * Returns the absolute URL for a route - * @param string $routeName the name of the route - * @param array $arguments an array with arguments which will be filled into the url - * @return string the absolute url - * @since 8.0.0 - */ - public function linkToRouteAbsolute($routeName, $arguments = array()); - - /** - * Returns an URL for an image or file - * @param string $appName the name of the app - * @param string $file the name of the file - * @param array $args array with param=>value, will be appended to the returned url - * The value of $args will be urlencoded - * @return string the url - * @since 6.0.0 - */ - public function linkTo($appName, $file, $args = array()); - - /** - * Returns the link to an image, like linkTo but only with prepending img/ - * @param string $appName the name of the app - * @param string $file the name of the file - * @return string the url - * @since 6.0.0 - */ - public function imagePath($appName, $file); - - - /** - * Makes an URL absolute - * @param string $url the url in the ownCloud host - * @return string the absolute version of the url - * @since 6.0.0 - */ - public function getAbsoluteURL($url); - - /** - * @param string $key - * @return string url to the online documentation - * @since 8.0.0 - */ - public function linkToDocs($key); -} diff --git a/lib/public/iuser.php b/lib/public/iuser.php deleted file mode 100644 index 16617a2f2f6..00000000000 --- a/lib/public/iuser.php +++ /dev/null @@ -1,202 +0,0 @@ - - * @author Lukas Reschke - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - -/** - * Interface IUser - * - * @package OCP - * @since 8.0.0 - */ -interface IUser { - - /** - * get the user id - * - * @return string - * @since 8.0.0 - */ - public function getUID(); - - /** - * get the display name for the user, if no specific display name is set it will fallback to the user id - * - * @return string - * @since 8.0.0 - */ - public function getDisplayName(); - - /** - * set the display name for the user - * - * @param string $displayName - * @return bool - * @since 8.0.0 - */ - public function setDisplayName($displayName); - - /** - * returns the timestamp of the user's last login or 0 if the user did never - * login - * - * @return int - * @since 8.0.0 - */ - public function getLastLogin(); - - /** - * updates the timestamp of the most recent login of this user - * @since 8.0.0 - */ - public function updateLastLoginTimestamp(); - - /** - * Delete the user - * - * @return bool - * @since 8.0.0 - */ - public function delete(); - - /** - * Set the password of the user - * - * @param string $password - * @param string $recoveryPassword for the encryption app to reset encryption keys - * @return bool - * @since 8.0.0 - */ - public function setPassword($password, $recoveryPassword = null); - - /** - * get the users home folder to mount - * - * @return string - * @since 8.0.0 - */ - public function getHome(); - - /** - * Get the name of the backend class the user is connected with - * - * @return string - * @since 8.0.0 - */ - public function getBackendClassName(); - - /** - * check if the backend allows the user to change his avatar on Personal page - * - * @return bool - * @since 8.0.0 - */ - public function canChangeAvatar(); - - /** - * check if the backend supports changing passwords - * - * @return bool - * @since 8.0.0 - */ - public function canChangePassword(); - - /** - * check if the backend supports changing display names - * - * @return bool - * @since 8.0.0 - */ - public function canChangeDisplayName(); - - /** - * check if the user is enabled - * - * @return bool - * @since 8.0.0 - */ - public function isEnabled(); - - /** - * set the enabled status for the user - * - * @param bool $enabled - * @since 8.0.0 - */ - public function setEnabled($enabled); - - /** - * get the users email address - * - * @return string|null - * @since 9.0.0 - */ - public function getEMailAddress(); - - /** - * get the avatar image if it exists - * - * @param int $size - * @return IImage|null - * @since 9.0.0 - */ - public function getAvatarImage($size); - - /** - * get the federation cloud id - * - * @return string - * @since 9.0.0 - */ - public function getCloudId(); - - /** - * set the email address of the user - * - * @param string|null $mailAddress - * @return void - * @since 9.0.0 - */ - public function setEMailAddress($mailAddress); - - /** - * get the users' quota in human readable form. If a specific quota is not - * set for the user, the default value is returned. If a default setting - * was not set otherwise, it is return as 'none', i.e. quota is not limited. - * - * @return string - * @since 9.0.0 - */ - public function getQuota(); - - /** - * set the users' quota - * - * @param string $quota - * @return void - * @since 9.0.0 - */ - public function setQuota($quota); -} diff --git a/lib/public/iuserbackend.php b/lib/public/iuserbackend.php deleted file mode 100644 index 5cd7945dd7a..00000000000 --- a/lib/public/iuserbackend.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * User Interface version 2 - * - */ - -// 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; - -/** - * Interface IUserBackend - * - * @package OCP - * @since 8.0.0 - */ -interface IUserBackend { - - /** - * Backend name to be shown in user management - * @return string the name of the backend to be shown - * @since 8.0.0 - */ - public function getBackendName(); - -} diff --git a/lib/public/iusermanager.php b/lib/public/iusermanager.php deleted file mode 100644 index 00c0bbc8721..00000000000 --- a/lib/public/iusermanager.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - - -/** - * Class Manager - * - * Hooks available in scope \OC\User: - * - preSetPassword(\OC\User\User $user, string $password, string $recoverPassword) - * - postSetPassword(\OC\User\User $user, string $password, string $recoverPassword) - * - preDelete(\OC\User\User $user) - * - postDelete(\OC\User\User $user) - * - preCreateUser(string $uid, string $password) - * - postCreateUser(\OC\User\User $user, string $password) - * - * @package OC\User - * @since 8.0.0 - */ -interface IUserManager { - /** - * register a user backend - * - * @param \OCP\UserInterface $backend - * @since 8.0.0 - */ - public function registerBackend($backend); - - /** - * Get the active backends - * @return \OCP\UserInterface[] - * @since 8.0.0 - */ - public function getBackends(); - - /** - * remove a user backend - * - * @param \OCP\UserInterface $backend - * @since 8.0.0 - */ - public function removeBackend($backend); - - /** - * remove all user backends - * @since 8.0.0 - */ - public function clearBackends() ; - - /** - * get a user by user id - * - * @param string $uid - * @return \OCP\IUser|null Either the user or null if the specified user does not exist - * @since 8.0.0 - */ - public function get($uid); - - /** - * check if a user exists - * - * @param string $uid - * @return bool - * @since 8.0.0 - */ - public function userExists($uid); - - /** - * Check if the password is valid for the user - * - * @param string $loginName - * @param string $password - * @return mixed the User object on success, false otherwise - * @since 8.0.0 - */ - public function checkPassword($loginName, $password); - - /** - * search by user id - * - * @param string $pattern - * @param int $limit - * @param int $offset - * @return \OCP\IUser[] - * @since 8.0.0 - */ - public function search($pattern, $limit = null, $offset = null); - - /** - * search by displayName - * - * @param string $pattern - * @param int $limit - * @param int $offset - * @return \OCP\IUser[] - * @since 8.0.0 - */ - public function searchDisplayName($pattern, $limit = null, $offset = null); - - /** - * @param string $uid - * @param string $password - * @throws \Exception - * @return bool|\OCP\IUser the created user of false - * @since 8.0.0 - */ - public function createUser($uid, $password); - - /** - * returns how many users per backend exist (if supported by backend) - * - * @return array an array of backend class as key and count number as value - * @since 8.0.0 - */ - public function countUsers(); - - /** - * @param \Closure $callback - * @param string $search - * @since 9.0.0 - */ - public function callForAllUsers (\Closure $callback, $search = ''); - - /** - * @param string $email - * @return IUser[] - * @since 9.1.0 - */ - public function getByEmail($email); -} diff --git a/lib/public/iusersession.php b/lib/public/iusersession.php deleted file mode 100644 index 2196f2c8ce0..00000000000 --- a/lib/public/iusersession.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @author Bernhard Posselt - * @author Jörn Friedrich Dreyer - * @author Lukas Reschke - * @author Morris Jobke - * @author Robin Appelman - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * User session interface - * - */ - -// 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; - -/** - * User session - * @since 6.0.0 - */ -interface IUserSession { - /** - * Do a user login - * @param string $user the username - * @param string $password the password - * @return bool true if successful - * @since 6.0.0 - */ - public function login($user, $password); - - /** - * Logs the user out including all the session data - * Logout, destroys session - * @return void - * @since 6.0.0 - */ - public function logout(); - - /** - * set the currently active user - * - * @param \OCP\IUser|null $user - * @since 8.0.0 - */ - public function setUser($user); - - /** - * get the current active user - * - * @return \OCP\IUser|null Current user, otherwise null - * @since 8.0.0 - */ - public function getUser(); - - /** - * Checks whether the user is logged in - * - * @return bool if logged in - * @since 8.0.0 - */ - public function isLoggedIn(); -} diff --git a/lib/public/json.php b/lib/public/json.php deleted file mode 100644 index fceffa0001e..00000000000 --- a/lib/public/json.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @author Frank Karlitschek - * @author Lukas Reschke - * @author Morris Jobke - * @author Thomas Müller - * @author Thomas Tanghus - * @author Vincent Petry - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * JSON Class - */ - -// 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; - -/** - * This class provides convenient functions to generate and send JSON data. Useful for Ajax calls - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ -class JSON { - /** - * Encode and print $data in JSON format - * @param array $data The data to use - * @param bool $setContentType the optional content type - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ - public static function encodedPrint( $data, $setContentType=true ) { - \OC_JSON::encodedPrint($data, $setContentType); - } - - /** - * Check if the user is logged in, send json error msg if not. - * - * This method checks if a user is logged in. If not, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Authentication error."}} - * - * Add this call to the start of all ajax method files that requires - * an authenticated user. - * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead - */ - public static function checkLoggedIn() { - \OC_JSON::checkLoggedIn(); - } - - /** - * Check an ajax get/post call if the request token is valid. - * - * This method checks for a valid variable 'requesttoken' in $_GET, - * $_POST and $_SERVER. If a valid token is not found, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Token expired. Please reload page."}} - * - * Add this call to the start of all ajax method files that creates, - * updates or deletes anything. - * In cases where you e.g. use an ajax call to load a dialog containing - * a submittable form, you will need to add the requesttoken first as a - * parameter to the ajax call, then assign it to the template and finally - * add a hidden input field also named 'requesttoken' containing the value. - * @deprecated 8.1.0 Use annotation based CSRF checks from the AppFramework instead - */ - public static function callCheck() { - \OC_JSON::callCheck(); - } - - /** - * Send json success msg - * - * Return a json success message with optional extra data. - * @see OCP\JSON::error() for the format to use. - * - * @param array $data The data to use - * @return string json formatted string. - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ - public static function success( $data = array() ) { - \OC_JSON::success($data); - } - - /** - * Send json error msg - * - * Return a json error message with optional extra data for - * error message or app specific data. - * - * Example use: - * - * $id = [some value] - * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id))); - * - * Will return the json formatted string: - * - * {"status":"error","data":{"message":"An error happened", "id":[some value]}} - * - * @param array $data The data to use - * @return string json formatted error string. - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ - public static function error( $data = array() ) { - \OC_JSON::error( $data ); - } - - /** - * Set Content-Type header to jsonrequest - * @param string $type The content type header - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ - public static function setContentTypeHeader( $type='application/json' ) { - \OC_JSON::setContentTypeHeader($type); - } - - /** - * Check if the App is enabled and send JSON error message instead - * - * This method checks if a specific app is enabled. If not, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Application is not enabled."}} - * - * Add this call to the start of all ajax method files that requires - * a specific app to be enabled. - * - * @param string $app The app to check - * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled. - */ - public static function checkAppEnabled( $app ) { - \OC_JSON::checkAppEnabled($app); - } - - /** - * Check if the user is a admin, send json error msg if not - * - * This method checks if the current user has admin rights. If not, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Authentication error."}} - * - * Add this call to the start of all ajax method files that requires - * administrative rights. - * - * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead - */ - public static function checkAdminUser() { - \OC_JSON::checkAdminUser(); - } - - /** - * Encode JSON - * @param array $data - * @return string - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ - public static function encode($data) { - return \OC_JSON::encode($data); - } - - /** - * Check is a given user exists - send json error msg if not - * @param string $user - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ - public static function checkUserExists($user) { - \OC_JSON::checkUserExists($user); - } -} diff --git a/lib/public/preconditionnotmetexception.php b/lib/public/preconditionnotmetexception.php deleted file mode 100644 index 212efc08ded..00000000000 --- a/lib/public/preconditionnotmetexception.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -// 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; - -/** - * Exception if the precondition of the config update method isn't met - * @since 8.0.0 - */ -class PreConditionNotMetException extends \Exception {} diff --git a/lib/public/response.php b/lib/public/response.php deleted file mode 100644 index a2a7667684a..00000000000 --- a/lib/public/response.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @author Bart Visscher - * @author Frank Karlitschek - * @author Lukas Reschke - * @author Morris Jobke - * @author Robin Appelman - * @author Thomas Müller - * @author Vincent Petry - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Response Class. - * - */ - -// 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; - -/** - * This class provides convenient functions to send the correct http response headers - * @since 4.0.0 - * @deprecated 8.1.0 - Use AppFramework controllers instead and modify the response object - */ -class Response { - /** - * Enable response caching by sending correct HTTP headers - * @param int $cache_time time to cache the response - * >0 cache time in seconds - * 0 and <0 enable default browser caching - * null cache indefinitely - * @since 4.0.0 - */ - static public function enableCaching( $cache_time = null ) { - \OC_Response::enableCaching( $cache_time ); - } - - /** - * Checks and set Last-Modified header, when the request matches sends a - * 'not modified' response - * @param string $lastModified time when the response was last modified - * @since 4.0.0 - */ - static public function setLastModifiedHeader( $lastModified ) { - \OC_Response::setLastModifiedHeader( $lastModified ); - } - - /** - * Sets the content disposition header (with possible workarounds) - * @param string $filename file name - * @param string $type disposition type, either 'attachment' or 'inline' - * @since 7.0.0 - */ - static public function setContentDispositionHeader( $filename, $type = 'attachment' ) { - \OC_Response::setContentDispositionHeader( $filename, $type ); - } - - /** - * Sets the content length header (with possible workarounds) - * @param string|int|float $length Length to be sent - * @since 8.1.0 - */ - static public function setContentLengthHeader($length) { - \OC_Response::setContentLengthHeader($length); - } - - /** - * Disable browser caching - * @see enableCaching with cache_time = 0 - * @since 4.0.0 - */ - static public function disableCaching() { - \OC_Response::disableCaching(); - } - - /** - * Checks and set ETag header, when the request matches sends a - * 'not modified' response - * @param string $etag token to use for modification check - * @since 4.0.0 - */ - static public function setETagHeader( $etag ) { - \OC_Response::setETagHeader( $etag ); - } - - /** - * Send file as response, checking and setting caching headers - * @param string $filepath of file to send - * @since 4.0.0 - * @deprecated 8.1.0 - Use \OCP\AppFramework\Http\StreamResponse or another AppFramework controller instead - */ - static public function sendFile( $filepath ) { - \OC_Response::sendFile( $filepath ); - } - - /** - * Set response expire time - * @param string|\DateTime $expires date-time when the response expires - * string for DateInterval from now - * DateTime object when to expire response - * @since 4.0.0 - */ - static public function setExpiresHeader( $expires ) { - \OC_Response::setExpiresHeader( $expires ); - } - - /** - * Send redirect response - * @param string $location to redirect to - * @since 4.0.0 - */ - static public function redirect( $location ) { - \OC_Response::redirect( $location ); - } -} diff --git a/lib/public/sabrepluginevent.php b/lib/public/sabrepluginevent.php deleted file mode 100644 index 11d939aee47..00000000000 --- a/lib/public/sabrepluginevent.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - - -use OCP\AppFramework\Http; -use Sabre\DAV\Server; -use Symfony\Component\EventDispatcher\Event; - -/** - * @since 8.2.0 - */ -class SabrePluginEvent extends Event { - - /** @var int */ - protected $statusCode; - - /** @var string */ - protected $message; - - /** @var Server */ - protected $server; - - /** - * @since 8.2.0 - */ - public function __construct($server = null) { - $this->message = ''; - $this->statusCode = Http::STATUS_OK; - $this->server = $server; - } - - /** - * @param int $statusCode - * @return self - * @since 8.2.0 - */ - public function setStatusCode($statusCode) { - $this->statusCode = (int) $statusCode; - return $this; - } - - /** - * @param string $message - * @return self - * @since 8.2.0 - */ - public function setMessage($message) { - $this->message = (string) $message; - return $this; - } - - /** - * @return int - * @since 8.2.0 - */ - public function getStatusCode() { - return $this->statusCode; - } - - /** - * @return string - * @since 8.2.0 - */ - public function getMessage() { - return $this->message; - } - - /** - * @return null|Server - * @since 9.0.0 - */ - public function getServer() { - return $this->server; - } -} diff --git a/lib/public/sabrepluginexception.php b/lib/public/sabrepluginexception.php deleted file mode 100644 index 2c5a799c4f7..00000000000 --- a/lib/public/sabrepluginexception.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -namespace OCP; - - -use Sabre\DAV\Exception; - -/** - * @since 8.2.0 - */ -class SabrePluginException extends Exception { - - /** - * Returns the HTTP statuscode for this exception - * - * @return int - * @since 8.2.0 - */ - public function getHTTPCode() { - return $this->code; - } -} diff --git a/lib/public/share.php b/lib/public/share.php deleted file mode 100644 index 9c62ec703e4..00000000000 --- a/lib/public/share.php +++ /dev/null @@ -1,401 +0,0 @@ - - * @author Bart Visscher - * @author Björn Schießle - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Michael Gapczynski - * @author Michael Kuhn - * @author Morris Jobke - * @author Robin McCorkell - * @author Roeland Jago Douma - * @author Sam Tuke - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Share Class - * - */ - -// 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; - -/** - * This class provides the ability for apps to share their content between users. - * Apps must create a backend class that implements OCP\Share_Backend and register it with this class. - * - * It provides the following hooks: - * - post_shared - * @since 5.0.0 - */ -class Share extends \OC\Share\Constants { - - /** - * Register a sharing backend class that implements OCP\Share_Backend for an item type - * @param string $itemType Item type - * @param string $class Backend class - * @param string $collectionOf (optional) Depends on item type - * @param array $supportedFileExtensions (optional) List of supported file extensions if this item type depends on files - * @return boolean true if backend is registered or false if error - * @since 5.0.0 - */ - public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) { - return \OC\Share\Share::registerBackend($itemType, $class, $collectionOf, $supportedFileExtensions); - } - - /** - * Check if the Share API is enabled - * @return boolean true if enabled or false - * - * The Share API is enabled by default if not configured - * @since 5.0.0 - */ - public static function isEnabled() { - return \OC\Share\Share::isEnabled(); - } - - /** - * Find which users can access a shared item - * @param string $path to the file - * @param string $ownerUser owner of the file - * @param bool $includeOwner include owner to the list of users with access to the file - * @param bool $returnUserPaths Return an array with the user => path map - * @param bool $recursive take parent folders into account - * @return array - * @note $path needs to be relative to user data dir, e.g. 'file.txt' - * not '/admin/files/file.txt' - * @since 5.0.0 - $recursive was added in 9.0.0 - */ - public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false, $recursive = true) { - return \OC\Share\Share::getUsersSharingFile($path, $ownerUser, $includeOwner, $returnUserPaths, $recursive); - } - - /** - * Get the items of item type shared with the current user - * @param string $itemType - * @param int $format (optional) Format type must be defined by the backend - * @param mixed $parameters (optional) - * @param int $limit Number of items to return (optional) Returns all by default - * @param bool $includeCollections (optional) - * @return mixed Return depends on format - * @since 5.0.0 - */ - public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE, - $parameters = null, $limit = -1, $includeCollections = false) { - - return \OC\Share\Share::getItemsSharedWith($itemType, $format, $parameters, $limit, $includeCollections); - } - - /** - * Get the items of item type shared with a user - * @param string $itemType - * @param string $user for which user we want the shares - * @param int $format (optional) Format type must be defined by the backend - * @param mixed $parameters (optional) - * @param int $limit Number of items to return (optional) Returns all by default - * @param bool $includeCollections (optional) - * @return mixed Return depends on format - * @since 7.0.0 - */ - public static function getItemsSharedWithUser($itemType, $user, $format = self::FORMAT_NONE, - $parameters = null, $limit = -1, $includeCollections = false) { - - return \OC\Share\Share::getItemsSharedWithUser($itemType, $user, $format, $parameters, $limit, $includeCollections); - } - - /** - * Get the item of item type shared with the current user - * @param string $itemType - * @param string $itemTarget - * @param int $format (optional) Format type must be defined by the backend - * @param mixed $parameters (optional) - * @param bool $includeCollections (optional) - * @return mixed Return depends on format - * @since 5.0.0 - */ - public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, - $parameters = null, $includeCollections = false) { - - return \OC\Share\Share::getItemSharedWith($itemType, $itemTarget, $format, $parameters, $includeCollections); - } - - /** - * Get the item of item type shared with a given user by source - * @param string $itemType - * @param string $itemSource - * @param string $user User to whom the item was shared - * @param string $owner Owner of the share - * @return array Return list of items with file_target, permissions and expiration - * @since 6.0.0 - parameter $owner was added in 8.0.0 - */ - public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null) { - return \OC\Share\Share::getItemSharedWithUser($itemType, $itemSource, $user, $owner); - } - - /** - * Get the item of item type shared with the current user by source - * @param string $itemType - * @param string $itemSource - * @param int $format (optional) Format type must be defined by the backend - * @param mixed $parameters - * @param bool $includeCollections - * @return array - * @since 5.0.0 - */ - public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE, - $parameters = null, $includeCollections = false) { - return \OC\Share\Share::getItemSharedWithBySource($itemType, $itemSource, $format, $parameters, $includeCollections); - } - - /** - * Get the item of item type shared by a link - * @param string $itemType - * @param string $itemSource - * @param string $uidOwner Owner of link - * @return array - * @since 5.0.0 - */ - public static function getItemSharedWithByLink($itemType, $itemSource, $uidOwner) { - return \OC\Share\Share::getItemSharedWithByLink($itemType, $itemSource, $uidOwner); - } - - /** - * Based on the given token the share information will be returned - password protected shares will be verified - * @param string $token - * @param bool $checkPasswordProtection - * @return array|bool false will be returned in case the token is unknown or unauthorized - * @since 5.0.0 - parameter $checkPasswordProtection was added in 7.0.0 - */ - public static function getShareByToken($token, $checkPasswordProtection = true) { - return \OC\Share\Share::getShareByToken($token, $checkPasswordProtection); - } - - /** - * resolves reshares down to the last real share - * @param array $linkItem - * @return array file owner - * @since 6.0.0 - */ - public static function resolveReShare($linkItem) { - return \OC\Share\Share::resolveReShare($linkItem); - } - - - /** - * Get the shared items of item type owned by the current user - * @param string $itemType - * @param int $format (optional) Format type must be defined by the backend - * @param mixed $parameters - * @param int $limit Number of items to return (optional) Returns all by default - * @param bool $includeCollections - * @return mixed Return depends on format - * @since 5.0.0 - */ - public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null, - $limit = -1, $includeCollections = false) { - - return \OC\Share\Share::getItemsShared($itemType, $format, $parameters, $limit, $includeCollections); - } - - /** - * Get the shared item of item type owned by the current user - * @param string $itemType - * @param string $itemSource - * @param int $format (optional) Format type must be defined by the backend - * @param mixed $parameters - * @param bool $includeCollections - * @return mixed Return depends on format - * @since 5.0.0 - */ - public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE, - $parameters = null, $includeCollections = false) { - - return \OC\Share\Share::getItemShared($itemType, $itemSource, $format, $parameters, $includeCollections); - } - - /** - * Get all users an item is shared with - * @param string $itemType - * @param string $itemSource - * @param string $uidOwner - * @param bool $includeCollections - * @param bool $checkExpireDate - * @return array Return array of users - * @since 5.0.0 - parameter $checkExpireDate was added in 7.0.0 - */ - public static function getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections = false, $checkExpireDate = true) { - return \OC\Share\Share::getUsersItemShared($itemType, $itemSource, $uidOwner, $includeCollections, $checkExpireDate); - } - - /** - * Share an item with a user, group, or via private link - * @param string $itemType - * @param string $itemSource - * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK - * @param string $shareWith User or group the item is being shared with - * @param int $permissions CRUDS - * @param string $itemSourceName - * @param \DateTime $expirationDate - * @param bool $passwordChanged - * @return bool|string Returns true on success or false on failure, Returns token on success for links - * @throws \OC\HintException when the share type is remote and the shareWith is invalid - * @throws \Exception - * @since 5.0.0 - parameter $itemSourceName was added in 6.0.0, parameter $expirationDate was added in 7.0.0, parameter $passwordChanged added in 9.0.0 - */ - public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null, $passwordChanged = null) { - return \OC\Share\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName, $expirationDate, $passwordChanged); - } - - /** - * Unshare an item from a user, group, or delete a private link - * @param string $itemType - * @param string $itemSource - * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK - * @param string $shareWith User or group the item is being shared with - * @param string $owner owner of the share, if null the current user is used - * @return boolean true on success or false on failure - * @since 5.0.0 - parameter $owner was added in 8.0.0 - */ - public static function unshare($itemType, $itemSource, $shareType, $shareWith, $owner = null) { - return \OC\Share\Share::unshare($itemType, $itemSource, $shareType, $shareWith, $owner); - } - - /** - * Unshare an item from all users, groups, and remove all links - * @param string $itemType - * @param string $itemSource - * @return boolean true on success or false on failure - * @since 5.0.0 - */ - public static function unshareAll($itemType, $itemSource) { - return \OC\Share\Share::unshareAll($itemType, $itemSource); - } - - /** - * Unshare an item shared with the current user - * @param string $itemType - * @param string $itemOrigin Item target or source - * @param boolean $originIsSource true if $itemOrigin is the source, false if $itemOrigin is the target (optional) - * @return boolean true on success or false on failure - * - * Unsharing from self is not allowed for items inside collections - * @since 5.0.0 - parameter $originIsSource was added in 8.0.0 - */ - public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) { - return \OC\Share\Share::unshareFromSelf($itemType, $itemOrigin, $originIsSource); - } - - /** - * sent status if users got informed by mail about share - * @param string $itemType - * @param string $itemSource - * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK - * @param string $recipient with whom was the item shared - * @param bool $status - * @since 6.0.0 - parameter $originIsSource was added in 8.0.0 - */ - public static function setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status) { - return \OC\Share\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status); - } - - /** - * Set the permissions of an item for a specific user or group - * @param string $itemType - * @param string $itemSource - * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK - * @param string $shareWith User or group the item is being shared with - * @param int $permissions CRUDS permissions - * @return boolean true on success or false on failure - * @since 5.0.0 - */ - public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) { - return \OC\Share\Share::setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions); - } - - /** - * Set expiration date for a share - * @param string $itemType - * @param string $itemSource - * @param string $date expiration date - * @param int $shareTime timestamp from when the file was shared - * @return boolean - * @since 5.0.0 - parameter $shareTime was added in 8.0.0 - */ - public static function setExpirationDate($itemType, $itemSource, $date, $shareTime = null) { - return \OC\Share\Share::setExpirationDate($itemType, $itemSource, $date, $shareTime); - } - - /** - * Set password for a public link share - * @param int $shareId - * @param string $password - * @return boolean - * @since 8.1.0 - */ - public static function setPassword($shareId, $password) { - $userSession = \OC::$server->getUserSession(); - $connection = \OC::$server->getDatabaseConnection(); - $config = \OC::$server->getConfig(); - return \OC\Share\Share::setPassword($userSession, $connection, $config, $shareId, $password); - } - - - /** - * Get the backend class for the specified item type - * @param string $itemType - * @return Share_Backend - * @since 5.0.0 - */ - public static function getBackend($itemType) { - return \OC\Share\Share::getBackend($itemType); - } - - /** - * Delete all shares with type SHARE_TYPE_LINK - * @since 6.0.0 - */ - public static function removeAllLinkShares() { - return \OC\Share\Share::removeAllLinkShares(); - } - - /** - * In case a password protected link is not yet authenticated this function will return false - * - * @param array $linkItem - * @return bool - * @since 7.0.0 - */ - public static function checkPasswordProtectedShare(array $linkItem) { - return \OC\Share\Share::checkPasswordProtectedShare($linkItem); - } - - /** - * Check if resharing is allowed - * - * @return boolean true if allowed or false - * @since 5.0.0 - */ - public static function isResharingAllowed() { - return \OC\Share\Share::isResharingAllowed(); - } -} diff --git a/lib/public/share_backend.php b/lib/public/share_backend.php deleted file mode 100644 index 110403c1f49..00000000000 --- a/lib/public/share_backend.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @author Joas Schilling - * @author Morris Jobke - * @author Robin McCorkell - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -// 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; - -/** - * Interface that apps must implement to share content. - * @since 5.0.0 - */ -interface Share_Backend { - - /** - * Check if this $itemSource exist for the user - * @param string $itemSource - * @param string $uidOwner Owner of the item - * @return boolean|null Source - * - * Return false if the item does not exist for the user - * @since 5.0.0 - */ - public function isValidSource($itemSource, $uidOwner); - - /** - * Get a unique name of the item for the specified user - * @param string $itemSource - * @param string|false $shareWith User the item is being shared with - * @param array|null $exclude List of similar item names already existing as shared items @deprecated since version OC7 - * @return string Target name - * - * This function needs to verify that the user does not already have an item with this name. - * If it does generate a new name e.g. name_# - * @since 5.0.0 - */ - public function generateTarget($itemSource, $shareWith, $exclude = null); - - /** - * Converts the shared item sources back into the item in the specified format - * @param array $items Shared items - * @param int $format - * @return array - * - * The items array is a 3-dimensional array with the item_source as the - * first key and the share id as the second key to an array with the share - * info. - * - * The key/value pairs included in the share info depend on the function originally called: - * If called by getItem(s)Shared: id, item_type, item, item_source, - * share_type, share_with, permissions, stime, file_source - * - * If called by getItem(s)SharedWith: id, item_type, item, item_source, - * item_target, share_type, share_with, permissions, stime, file_source, - * file_target - * - * This function allows the backend to control the output of shared items with custom formats. - * It is only called through calls to the public getItem(s)Shared(With) functions. - * @since 5.0.0 - */ - public function formatItems($items, $format, $parameters = null); - - /** - * Check if a given share type is allowd by the back-end - * - * @param int $shareType share type - * @return boolean - * - * The back-end can enable/disable specific share types. Just return true if - * the back-end doesn't provide any specific settings for it and want to allow - * all share types defined by the share API - * @since 8.0.0 - */ - public function isShareTypeAllowed($shareType); - -} diff --git a/lib/public/share_backend_collection.php b/lib/public/share_backend_collection.php deleted file mode 100644 index 185cf32ce3e..00000000000 --- a/lib/public/share_backend_collection.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -// 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; - -/** - * Interface for collections of of items implemented by another share backend. - * Extends the Share_Backend interface. - * @since 5.0.0 - */ -interface Share_Backend_Collection extends Share_Backend { - /** - * Get the sources of the children of the item - * @param string $itemSource - * @return array Returns an array of children each inside an array with the keys: source, target, and file_path if applicable - * @since 5.0.0 - */ - public function getChildren($itemSource); -} diff --git a/lib/public/share_backend_file_dependent.php b/lib/public/share_backend_file_dependent.php deleted file mode 100644 index 64b3bf43319..00000000000 --- a/lib/public/share_backend_file_dependent.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -// 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; - -/** - * Interface for share backends that share content that is dependent on files. - * Extends the Share_Backend interface. - * @since 5.0.0 - */ -interface Share_Backend_File_Dependent extends Share_Backend { - /** - * Get the file path of the item - * @param string $itemSource - * @param string $uidOwner User that is the owner of shared item - * @return string|false - * @since 5.0.0 - */ - public function getFilePath($itemSource, $uidOwner); - -} diff --git a/lib/public/user.php b/lib/public/user.php deleted file mode 100644 index 64ac92d2100..00000000000 --- a/lib/public/user.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @author Björn Schießle - * @author Frank Karlitschek - * @author Georg Ehrke - * @author Joas Schilling - * @author Jörn Friedrich Dreyer - * @author Lorenzo M. Catucci - * @author Morris Jobke - * @author Robin McCorkell - * @author Thomas Müller - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * User Class - * - */ - -// 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; - -/** - * This class provides access to the user management. You can get information - * about the currently logged in user and the permissions for example - * @since 5.0.0 - */ -class User { - /** - * Get the user id of the user currently logged in. - * @return string uid or false - * @deprecated 8.0.0 Use \OC::$server->getUserSession()->getUser()->getUID() - * @since 5.0.0 - */ - public static function getUser() { - return \OC_User::getUser(); - } - - /** - * Get a list of all users - * @param string $search search pattern - * @param int|null $limit - * @param int|null $offset - * @return array an array of all uids - * @deprecated 8.1.0 use method search() of \OCP\IUserManager - \OC::$server->getUserManager() - * @since 5.0.0 - */ - public static function getUsers( $search = '', $limit = null, $offset = null ) { - return \OC_User::getUsers( $search, $limit, $offset ); - } - - /** - * Get the user display name of the user currently logged in. - * @param string|null $user user id or null for current user - * @return string display name - * @deprecated 8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method - * get() of \OCP\IUserManager - \OC::$server->getUserManager() - * @since 5.0.0 - */ - public static function getDisplayName( $user = null ) { - return \OC_User::getDisplayName( $user ); - } - - /** - * Get a list of all display names and user ids. - * @param string $search search pattern - * @param int|null $limit - * @param int|null $offset - * @return array an array of all display names (value) and the correspondig uids (key) - * @deprecated 8.1.0 use method searchDisplayName() of \OCP\IUserManager - \OC::$server->getUserManager() - * @since 5.0.0 - */ - public static function getDisplayNames( $search = '', $limit = null, $offset = null ) { - return \OC_User::getDisplayNames( $search, $limit, $offset ); - } - - /** - * Check if the user is logged in - * @return boolean - * @since 5.0.0 - */ - public static function isLoggedIn() { - return \OC_User::isLoggedIn(); - } - - /** - * Check if a user exists - * @param string $uid the username - * @param string $excludingBackend (default none) - * @return boolean - * @deprecated 8.1.0 use method userExists() of \OCP\IUserManager - \OC::$server->getUserManager() - * @since 5.0.0 - */ - public static function userExists( $uid, $excludingBackend = null ) { - return \OC_User::userExists( $uid, $excludingBackend ); - } - /** - * Logs the user out including all the session data - * Logout, destroys session - * @deprecated 8.0.0 Use \OC::$server->getUserSession()->logout(); - * @since 5.0.0 - */ - public static function logout() { - \OC::$server->getUserSession()->logout(); - } - - /** - * Check if the password is correct - * @param string $uid The username - * @param string $password The password - * @return string|false username on success, false otherwise - * - * Check if the password is correct without logging in the user - * @deprecated 8.0.0 Use \OC::$server->getUserManager()->checkPassword(); - * @since 5.0.0 - */ - public static function checkPassword( $uid, $password ) { - return \OC_User::checkPassword( $uid, $password ); - } - - /** - * Check if the user is a admin, redirects to home if not - * @since 5.0.0 - */ - public static function checkAdminUser() { - \OC_Util::checkAdminUser(); - } - - /** - * Check if the user is logged in, redirects to home if not. With - * redirect URL parameter to the request URI. - * @since 5.0.0 - */ - public static function checkLoggedIn() { - \OC_Util::checkLoggedIn(); - } -} diff --git a/lib/public/userinterface.php b/lib/public/userinterface.php deleted file mode 100644 index 954c2d68133..00000000000 --- a/lib/public/userinterface.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @author Jörn Friedrich Dreyer - * @author Morris Jobke - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * User Interface - * - */ - -// 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; - -/** - * TODO actually this is a IUserBackend - * - * @package OCP - * @since 4.5.0 - */ -interface UserInterface { - - /** - * Check if backend implements actions - * @param int $actions bitwise-or'ed actions - * @return boolean - * - * Returns the supported actions as int to be - * compared with \OC_User_Backend::CREATE_USER etc. - * @since 4.5.0 - */ - public function implementsActions($actions); - - /** - * delete a user - * @param string $uid The username of the user to delete - * @return bool - * @since 4.5.0 - */ - public function deleteUser($uid); - - /** - * Get a list of all users - * - * @param string $search - * @param null|int $limit - * @param null|int $offset - * @return string[] an array of all uids - * @since 4.5.0 - */ - public function getUsers($search = '', $limit = null, $offset = null); - - /** - * check if a user exists - * @param string $uid the username - * @return boolean - * @since 4.5.0 - */ - public function userExists($uid); - - /** - * get display name of the user - * @param string $uid user ID of the user - * @return string display name - * @since 4.5.0 - */ - public function getDisplayName($uid); - - /** - * Get a list of all display names and user ids. - * - * @param string $search - * @param string|null $limit - * @param string|null $offset - * @return array an array of all displayNames (value) and the corresponding uids (key) - * @since 4.5.0 - */ - public function getDisplayNames($search = '', $limit = null, $offset = null); - - /** - * Check if a user list is available or not - * @return boolean if users can be listed or not - * @since 4.5.0 - */ - public function hasUserListings(); - -} diff --git a/lib/public/util.php b/lib/public/util.php deleted file mode 100644 index 45df62ac735..00000000000 --- a/lib/public/util.php +++ /dev/null @@ -1,697 +0,0 @@ - - * @author Bart Visscher - * @author Björn Schießle - * @author Frank Karlitschek - * @author Georg Ehrke - * @author Individual IT Services - * @author Jens-Christian Fischer - * @author Joas Schilling - * @author Lukas Reschke - * @author Michael Gapczynski - * @author Morris Jobke - * @author Nicolas Grekas - * @author Pellaeon Lin - * @author Randolph Carter - * @author Robin Appelman - * @author Robin McCorkell - * @author Roeland Jago Douma - * @author Stefan Herbrechtsmeier - * @author Thomas Müller - * @author Thomas Tanghus - * @author Victor Dubiniuk - * @author Vincent Petry - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @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 - * - */ - -/** - * Public interface of ownCloud for apps to use. - * Utility Class. - * - */ - -// 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; -use DateTimeZone; - -/** - * This class provides different helper functions to make the life of a developer easier - * @since 4.0.0 - */ -class Util { - // consts for Logging - const DEBUG=0; - const INFO=1; - const WARN=2; - const ERROR=3; - const FATAL=4; - - /** - * get the current installed version of ownCloud - * @return array - * @since 4.0.0 - */ - public static function getVersion() { - return(\OC_Util::getVersion()); - } - - /** - * Set current update channel - * @param string $channel - * @since 8.1.0 - */ - public static function setChannel($channel) { - //Flush timestamp to reload version.php - \OC::$server->getSession()->set('OC_Version_Timestamp', 0); - \OC::$server->getAppConfig()->setValue('core', 'OC_Channel', $channel); - } - - /** - * Get current update channel - * @return string - * @since 8.1.0 - */ - public static function getChannel() { - return \OC_Util::getChannel(); - } - - /** - * send an email - * @param string $toaddress - * @param string $toname - * @param string $subject - * @param string $mailtext - * @param string $fromaddress - * @param string $fromname - * @param int $html - * @param string $altbody - * @param string $ccaddress - * @param string $ccname - * @param string $bcc - * @deprecated 8.1.0 Use \OCP\Mail\IMailer instead - * @since 4.0.0 - */ - public static function sendMail($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, - $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { - $mailer = \OC::$server->getMailer(); - $message = $mailer->createMessage(); - $message->setTo([$toaddress => $toname]); - $message->setSubject($subject); - $message->setPlainBody($mailtext); - $message->setFrom([$fromaddress => $fromname]); - if($html === 1) { - $message->setHTMLBody($altbody); - } - - if($altbody === '') { - $message->setHTMLBody($mailtext); - $message->setPlainBody(''); - } else { - $message->setHtmlBody($mailtext); - $message->setPlainBody($altbody); - } - - if(!empty($ccaddress)) { - if(!empty($ccname)) { - $message->setCc([$ccaddress => $ccname]); - } else { - $message->setCc([$ccaddress]); - } - } - if(!empty($bcc)) { - $message->setBcc([$bcc]); - } - - $mailer->send($message); - } - - /** - * write a message in the log - * @param string $app - * @param string $message - * @param int $level - * @since 4.0.0 - */ - public static function writeLog( $app, $message, $level ) { - $context = ['app' => $app]; - \OC::$server->getLogger()->log($level, $message, $context); - } - - /** - * write exception into the log - * @param string $app app name - * @param \Exception $ex exception to log - * @param int $level log level, defaults to \OCP\Util::FATAL - * @since ....0.0 - parameter $level was added in 7.0.0 - * @deprecated 8.2.0 use logException of \OCP\ILogger - */ - public static function logException( $app, \Exception $ex, $level = \OCP\Util::FATAL ) { - \OC::$server->getLogger()->logException($ex, ['app' => $app]); - } - - /** - * check if sharing is disabled for the current user - * - * @return boolean - * @since 7.0.0 - */ - public static function isSharingDisabledForUser() { - return \OC_Util::isSharingDisabledForUser( - \OC::$server->getConfig(), - \OC::$server->getGroupManager(), - \OC::$server->getUserSession()->getUser() - ); - } - - /** - * get l10n object - * @param string $application - * @param string|null $language - * @return \OC_L10N - * @since 6.0.0 - parameter $language was added in 8.0.0 - */ - public static function getL10N($application, $language = null) { - return \OC::$server->getL10N($application, $language); - } - - /** - * add a css file - * @param string $application - * @param string $file - * @since 4.0.0 - */ - public static function addStyle( $application, $file = null ) { - \OC_Util::addStyle( $application, $file ); - } - - /** - * add a javascript file - * @param string $application - * @param string $file - * @since 4.0.0 - */ - public static function addScript( $application, $file = null ) { - \OC_Util::addScript( $application, $file ); - } - - /** - * Add a translation JS file - * @param string $application application id - * @param string $languageCode language code, defaults to the current locale - * @since 8.0.0 - */ - public static function addTranslations($application, $languageCode = null) { - \OC_Util::addTranslations($application, $languageCode); - } - - /** - * Add a custom element to the header - * If $text is null then the element will be written as empty element. - * So use "" to get a closing tag. - * @param string $tag tag name of the element - * @param array $attributes array of attributes for the element - * @param string $text the text content for the element - * @since 4.0.0 - */ - public static function addHeader($tag, $attributes, $text=null) { - \OC_Util::addHeader($tag, $attributes, $text); - } - - /** - * formats a timestamp in the "right" way - * @param int $timestamp $timestamp - * @param bool $dateOnly option to omit time from the result - * @param DateTimeZone|string $timeZone where the given timestamp shall be converted to - * @return string timestamp - * - * @deprecated 8.0.0 Use \OC::$server->query('DateTimeFormatter') instead - * @since 4.0.0 - */ - public static function formatDate($timestamp, $dateOnly=false, $timeZone = null) { - return(\OC_Util::formatDate($timestamp, $dateOnly, $timeZone)); - } - - /** - * check if some encrypted files are stored - * @return bool - * - * @deprecated 8.1.0 No longer required - * @since 6.0.0 - */ - public static function encryptedFiles() { - return false; - } - - /** - * Creates an absolute url to the given app and file. - * @param string $app app - * @param string $file file - * @param array $args array with param=>value, will be appended to the returned url - * The value of $args will be urlencoded - * @return string the url - * @since 4.0.0 - parameter $args was added in 4.5.0 - */ - public static function linkToAbsolute( $app, $file, $args = array() ) { - $urlGenerator = \OC::$server->getURLGenerator(); - return $urlGenerator->getAbsoluteURL( - $urlGenerator->linkTo($app, $file, $args) - ); - } - - /** - * Creates an absolute url for remote use. - * @param string $service id - * @return string the url - * @since 4.0.0 - */ - public static function linkToRemote( $service ) { - $urlGenerator = \OC::$server->getURLGenerator(); - $remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service; - return $urlGenerator->getAbsoluteURL( - $remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '') - ); - } - - /** - * Creates an absolute url for public use - * @param string $service id - * @return string the url - * @since 4.5.0 - */ - public static function linkToPublic($service) { - return \OC_Helper::linkToPublic($service); - } - - /** - * Creates an url using a defined route - * @param string $route - * @param array $parameters - * @internal param array $args with param=>value, will be appended to the returned url - * @return string the url - * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkToRoute($route, $parameters) - * @since 5.0.0 - */ - public static function linkToRoute( $route, $parameters = array() ) { - return \OC::$server->getURLGenerator()->linkToRoute($route, $parameters); - } - - /** - * Creates an url to the given app and file - * @param string $app app - * @param string $file file - * @param array $args array with param=>value, will be appended to the returned url - * The value of $args will be urlencoded - * @return string the url - * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->linkTo($app, $file, $args) - * @since 4.0.0 - parameter $args was added in 4.5.0 - */ - public static function linkTo( $app, $file, $args = array() ) { - return \OC::$server->getURLGenerator()->linkTo($app, $file, $args); - } - - /** - * Returns the server host, even if the website uses one or more reverse proxy - * @return string the server host - * @deprecated 8.1.0 Use \OCP\IRequest::getServerHost - * @since 4.0.0 - */ - public static function getServerHost() { - return \OC::$server->getRequest()->getServerHost(); - } - - /** - * Returns the server host name without an eventual port number - * @return string the server hostname - * @since 5.0.0 - */ - public static function getServerHostName() { - $host_name = self::getServerHost(); - // strip away port number (if existing) - $colon_pos = strpos($host_name, ':'); - if ($colon_pos != FALSE) { - $host_name = substr($host_name, 0, $colon_pos); - } - return $host_name; - } - - /** - * Returns the default email address - * @param string $user_part the user part of the address - * @return string the default email address - * - * Assembles a default email address (using the server hostname - * and the given user part, and returns it - * Example: when given lostpassword-noreply as $user_part param, - * and is currently accessed via http(s)://example.com/, - * it would return 'lostpassword-noreply@example.com' - * - * If the configuration value 'mail_from_address' is set in - * config.php, this value will override the $user_part that - * is passed to this function - * @since 5.0.0 - */ - public static function getDefaultEmailAddress($user_part) { - $config = \OC::$server->getConfig(); - $user_part = $config->getSystemValue('mail_from_address', $user_part); - $host_name = self::getServerHostName(); - $host_name = $config->getSystemValue('mail_domain', $host_name); - $defaultEmailAddress = $user_part.'@'.$host_name; - - $mailer = \OC::$server->getMailer(); - if ($mailer->validateMailAddress($defaultEmailAddress)) { - return $defaultEmailAddress; - } - - // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain' - return $user_part.'@localhost.localdomain'; - } - - /** - * Returns the server protocol. It respects reverse proxy servers and load balancers - * @return string the server protocol - * @deprecated 8.1.0 Use \OCP\IRequest::getServerProtocol - * @since 4.5.0 - */ - public static function getServerProtocol() { - return \OC::$server->getRequest()->getServerProtocol(); - } - - /** - * Returns the request uri, even if the website uses one or more reverse proxies - * @return string the request uri - * @deprecated 8.1.0 Use \OCP\IRequest::getRequestUri - * @since 5.0.0 - */ - public static function getRequestUri() { - return \OC::$server->getRequest()->getRequestUri(); - } - - /** - * Returns the script name, even if the website uses one or more reverse proxies - * @return string the script name - * @deprecated 8.1.0 Use \OCP\IRequest::getScriptName - * @since 5.0.0 - */ - public static function getScriptName() { - return \OC::$server->getRequest()->getScriptName(); - } - - /** - * Creates path to an image - * @param string $app app - * @param string $image image name - * @return string the url - * @deprecated 8.1.0 Use \OC::$server->getURLGenerator()->imagePath($app, $image) - * @since 4.0.0 - */ - public static function imagePath( $app, $image ) { - return \OC::$server->getURLGenerator()->imagePath($app, $image); - } - - /** - * Make a human file size (2048 to 2 kB) - * @param int $bytes file size in bytes - * @return string a human readable file size - * @since 4.0.0 - */ - public static function humanFileSize( $bytes ) { - return(\OC_Helper::humanFileSize( $bytes )); - } - - /** - * Make a computer file size (2 kB to 2048) - * @param string $str file size in a fancy format - * @return int a file size in bytes - * - * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418 - * @since 4.0.0 - */ - public static function computerFileSize( $str ) { - return(\OC_Helper::computerFileSize( $str )); - } - - /** - * connects a function to a hook - * - * @param string $signalClass class name of emitter - * @param string $signalName name of signal - * @param string|object $slotClass class name of slot - * @param string $slotName name of slot - * @return bool - * - * This function makes it very easy to connect to use hooks. - * - * TODO: write example - * @since 4.0.0 - */ - static public function connectHook($signalClass, $signalName, $slotClass, $slotName ) { - return(\OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName )); - } - - /** - * Emits a signal. To get data from the slot use references! - * @param string $signalclass class name of emitter - * @param string $signalname name of signal - * @param array $params default: array() array with additional data - * @return bool true if slots exists or false if not - * - * TODO: write example - * @since 4.0.0 - */ - static public function emitHook( $signalclass, $signalname, $params = array()) { - return(\OC_Hook::emit( $signalclass, $signalname, $params )); - } - - /** - * Cached encrypted CSRF token. Some static unit-tests of ownCloud compare - * multiple OC_Template elements which invoke `callRegister`. If the value - * would not be cached these unit-tests would fail. - * @var string - */ - private static $token = ''; - - /** - * Register an get/post call. This is important to prevent CSRF attacks - * @since 4.5.0 - */ - public static function callRegister() { - if(self::$token === '') { - self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); - } - return self::$token; - } - - /** - * Check an ajax get/post call if the request token is valid. exit if not. - * @since 4.5.0 - * @deprecated 9.0.0 Use annotations based on the app framework. - */ - public static function callCheck() { - if (!(\OC::$server->getRequest()->passesCSRFCheck())) { - exit(); - } - } - - /** - * Used to sanitize HTML - * - * This function is used to sanitize HTML and should be applied on any - * string or array of strings before displaying it on a web page. - * - * @param string|array $value - * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter. - * @since 4.5.0 - */ - public static function sanitizeHTML($value) { - return \OC_Util::sanitizeHTML($value); - } - - /** - * Public function to encode url parameters - * - * This function is used to encode path to file before output. - * Encoding is done according to RFC 3986 with one exception: - * Character '/' is preserved as is. - * - * @param string $component part of URI to encode - * @return string - * @since 6.0.0 - */ - public static function encodePath($component) { - return(\OC_Util::encodePath($component)); - } - - /** - * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is. - * - * @param array $input The array to work on - * @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default) - * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 - * @return array - * @since 4.5.0 - */ - public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') { - return(\OC_Helper::mb_array_change_key_case($input, $case, $encoding)); - } - - /** - * replaces a copy of string delimited by the start and (optionally) length parameters with the string given in replacement. - * - * @param string $string The input string. Opposite to the PHP build-in function does not accept an array. - * @param string $replacement The replacement string. - * @param int $start If start is positive, the replacing will begin at the start'th offset into string. If start is negative, the replacing will begin at the start'th character from the end of string. - * @param int $length Length of the part to be replaced - * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 - * @return string - * @since 4.5.0 - * @deprecated 8.2.0 Use substr_replace() instead. - */ - public static function mb_substr_replace($string, $replacement, $start, $length = null, $encoding = 'UTF-8') { - return substr_replace($string, $replacement, $start, $length); - } - - /** - * Replace all occurrences of the search string with the replacement string - * - * @param string $search The value being searched for, otherwise known as the needle. String. - * @param string $replace The replacement string. - * @param string $subject The string or array being searched and replaced on, otherwise known as the haystack. - * @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8 - * @param int $count If passed, this will be set to the number of replacements performed. - * @return string - * @since 4.5.0 - * @deprecated 8.2.0 Use str_replace() instead. - */ - public static function mb_str_replace($search, $replace, $subject, $encoding = 'UTF-8', &$count = null) { - return str_replace($search, $replace, $subject, $count); - } - - /** - * performs a search in a nested array - * - * @param array $haystack the array to be searched - * @param string $needle the search string - * @param int $index optional, only search this key name - * @return mixed the key of the matching field, otherwise false - * @since 4.5.0 - */ - public static function recursiveArraySearch($haystack, $needle, $index = null) { - return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index)); - } - - /** - * calculates the maximum upload size respecting system settings, free space and user quota - * - * @param string $dir the current folder where the user currently operates - * @param int $free the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly - * @return int number of bytes representing - * @since 5.0.0 - */ - public static function maxUploadFilesize($dir, $free = null) { - return \OC_Helper::maxUploadFilesize($dir, $free); - } - - /** - * Calculate free space left within user quota - * @param string $dir the current folder where the user currently operates - * @return int number of bytes representing - * @since 7.0.0 - */ - public static function freeSpace($dir) { - return \OC_Helper::freeSpace($dir); - } - - /** - * Calculate PHP upload limit - * - * @return int number of bytes representing - * @since 7.0.0 - */ - public static function uploadLimit() { - return \OC_Helper::uploadLimit(); - } - - /** - * Returns whether the given file name is valid - * @param string $file file name to check - * @return bool true if the file name is valid, false otherwise - * @deprecated 8.1.0 use \OC\Files\View::verifyPath() - * @since 7.0.0 - */ - public static function isValidFileName($file) { - return \OC_Util::isValidFileName($file); - } - - /** - * Generates a cryptographic secure pseudo-random string - * @param int $length of the random string - * @return string - * @deprecated 8.0.0 Use \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($length); instead - * @since 7.0.0 - */ - public static function generateRandomBytes($length = 30) { - return \OC::$server->getSecureRandom()->generate($length, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS); - } - - /** - * Compare two strings to provide a natural sort - * @param string $a first string to compare - * @param string $b second string to compare - * @return -1 if $b comes before $a, 1 if $a comes before $b - * or 0 if the strings are identical - * @since 7.0.0 - */ - public static function naturalSortCompare($a, $b) { - return \OC\NaturalSort::getInstance()->compare($a, $b); - } - - /** - * check if a password is required for each public link - * @return boolean - * @since 7.0.0 - */ - public static function isPublicLinkPasswordRequired() { - return \OC_Util::isPublicLinkPasswordRequired(); - } - - /** - * check if share API enforces a default expire date - * @return boolean - * @since 8.0.0 - */ - public static function isDefaultExpireDateEnforced() { - return \OC_Util::isDefaultExpireDateEnforced(); - } - - protected static $needUpgradeCache = null; - - /** - * Checks whether the current version needs upgrade. - * - * @return bool true if upgrade is needed, false otherwise - * @since 7.0.0 - */ - public static function needUpgrade() { - if (!isset(self::$needUpgradeCache)) { - self::$needUpgradeCache=\OC_Util::needUpgrade(\OC::$server->getConfig()); - } - return self::$needUpgradeCache; - } -} -- cgit v1.2.3