}
/**
- * @return \OCP\Core\IServerContainer
+ * @return \OCP\IServerContainer
*/
function getServer()
{
namespace OC\AppFramework\Http;
-use OCP\Core\IRequest;
+use OCP\IRequest;
/**
* Class for accessing variables in the request.
*
* SimpleContainer is a simple implementation of IContainer on basis of \Pimple
*/
-class SimpleContainer extends \Pimple implements \OCP\Core\IContainer {
+class SimpleContainer extends \Pimple implements \OCP\IContainer {
/**
* @param string $name name of the service to query for
namespace OC {
- class ContactsManager implements \OCP\Core\Contacts\IManager {
+ class ContactsManager implements \OCP\Contacts\IManager {
/**
* This function is used to search and find contacts within the users address books.
namespace OCP\AppFramework;
use OCP\AppFramework\IApi;
-use OCP\Core\IContainer;
+use OCP\IContainer;
/**
* Class IAppContainer
function getCoreApi();
/**
- * @return \OCP\Core\IServerContainer
+ * @return \OCP\IServerContainer
*/
function getServer();
}
--- /dev/null
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller thomas.mueller@tmit.eu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * 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\Contacts {
+
+ /**
+ * 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.
+ *
+ */
+ interface IManager {
+
+ /**
+ * 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) {
+ * $cm = \OC::$server->getContactsManager();
+ * // The API is not active -> nothing to do
+ * if (!$cm->isEnabled()) {
+ * return array();
+ * }
+ *
+ * $result = $cm->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 of contacts which are arrays of key-value-pairs
+ */
+ function search($pattern, $searchProperties = array(), $options = array());
+
+ /**
+ * This function can be used to delete the contact identified by the given id
+ *
+ * @param object $id the unique identifier to a contact
+ * @param $address_book_key
+ * @return bool successful or not
+ */
+ function 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 $address_book_key string to identify the address book in which the contact shall be created or updated
+ * @return array representing the contact just created or updated
+ */
+ function createOrUpdate($properties, $address_book_key);
+
+ /**
+ * Check if contacts are available (e.g. contacts app enabled)
+ *
+ * @return bool true if enabled, false if not
+ */
+ function isEnabled();
+
+ /**
+ * @param \OCP\IAddressBook $address_book
+ */
+ function registerAddressBook(\OCP\IAddressBook $address_book);
+
+ /**
+ * @param \OCP\IAddressBook $address_book
+ */
+ function unregisterAddressBook(\OCP\IAddressBook $address_book);
+
+ /**
+ * In order to improve lazy loading a closure can be registered which will be called in case
+ * address books are actually requested
+ *
+ * @param string $key
+ * @param \Closure $callable
+ */
+ function register($key, \Closure $callable);
+
+ /**
+ * @return array
+ */
+ function getAddressBooks();
+
+ /**
+ * removes all registered address book instances
+ */
+ function clear();
+ }
+}
+++ /dev/null
-<?php
-/**
- * ownCloud
- *
- * @author Thomas Müller
- * @copyright 2013 Thomas Müller thomas.mueller@tmit.eu
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * 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\Core\Contacts {
-
- /**
- * 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.
- *
- */
- interface IManager {
-
- /**
- * 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) {
- * $cm = \OC::$server->getContactsManager();
- * // The API is not active -> nothing to do
- * if (!$cm->isEnabled()) {
- * return array();
- * }
- *
- * $result = $cm->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 of contacts which are arrays of key-value-pairs
- */
- function search($pattern, $searchProperties = array(), $options = array());
-
- /**
- * This function can be used to delete the contact identified by the given id
- *
- * @param object $id the unique identifier to a contact
- * @param $address_book_key
- * @return bool successful or not
- */
- function 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 $address_book_key string to identify the address book in which the contact shall be created or updated
- * @return array representing the contact just created or updated
- */
- function createOrUpdate($properties, $address_book_key);
-
- /**
- * Check if contacts are available (e.g. contacts app enabled)
- *
- * @return bool true if enabled, false if not
- */
- function isEnabled();
-
- /**
- * @param \OCP\IAddressBook $address_book
- */
- function registerAddressBook(\OCP\IAddressBook $address_book);
-
- /**
- * @param \OCP\IAddressBook $address_book
- */
- function unregisterAddressBook(\OCP\IAddressBook $address_book);
-
- /**
- * In order to improve lazy loading a closure can be registered which will be called in case
- * address books are actually requested
- *
- * @param string $key
- * @param \Closure $callable
- */
- function register($key, \Closure $callable);
-
- /**
- * @return array
- */
- function getAddressBooks();
-
- /**
- * removes all registered address book instances
- */
- function clear();
- }
-}
+++ /dev/null
-<?php
-/**
- * ownCloud
- *
- * @author Thomas Müller
- * @copyright 2013 Thomas Müller deepdiver@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCP\Core;
-
-/**
- * Class IContainer
- *
- * IContainer is the basic interface to be used for any internal dependency injection mechanism
- *
- * @package OCP\Core
- */
-interface IContainer {
-
- /**
- * Look up a service for a given name in the container.
- *
- * @param string $name
- * @return mixed
- */
- function query($name);
-
- /**
- * A value is stored in the container with it's corresponding name
- *
- * @param string $name
- * @param mixed $value
- * @return void
- */
- 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 callable $closure
- * @param bool $shared
- * @return void
- */
- function registerService($name, \Closure $closure, $shared = true);
-}
+++ /dev/null
-<?php
-/**
- * ownCloud
- *
- * @author Thomas Müller
- * @copyright 2013 Thomas Müller deepdiver@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCP\Core;
-
-
-interface IRequest {
-
- 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
- */
- 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
- */
- public function getParams();
-
- /**
- * Returns the method of the request
- *
- * @return string the method of the request (POST, GET, etc)
- */
- 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
- */
- 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
- */
- public function getEnv($key);
-
-
- /**
- * Shortcut for getting session variables
- *
- * @param string $key the key that will be taken from the $_SESSION array
- * @return array the value in the $_SESSION element
- */
- function getSession($key);
-
-
- /**
- * Shortcut for getting cookie variables
- *
- * @param string $key the key that will be taken from the $_COOKIE array
- * @return array the value in the $_COOKIE element
- */
- function getCookie($key);
-
-
- /**
- * Returns the request body content.
- *
- * @param Boolean $asResource If true, a resource will be returned
- * @return string|resource The request body content or a resource to read the body stream.
- * @throws \LogicException
- */
- function getContent($asResource = false);
-}
+++ /dev/null
-<?php
-/**
- * ownCloud
- *
- * @author Thomas Müller
- * @copyright 2013 Thomas Müller deepdiver@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCP\Core;
-
-
-/**
- * Class IServerContainer
- * @package OCP\Core
- *
- * This container holds all ownCloud services
- */
-interface IServerContainer {
-
- /**
- * The contacts manager will act as a broker between consumers for contacts information and
- * providers which actual deliver the contact information.
- *
- * @return \OCP\Core\Contacts\IManager
- */
- function getContactsManager();
-
- /**
- * The current request object holding all information about the request currently being processed
- * is returned from this method.
- * In case the current execution was not initiated by a web request null is returned
- *
- * @return \OCP\Core\IRequest|null
- */
- function getRequest();
-
-}
--- /dev/null
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP;
+
+/**
+ * Class IContainer
+ *
+ * IContainer is the basic interface to be used for any internal dependency injection mechanism
+ *
+ * @package OCP
+ */
+interface IContainer {
+
+ /**
+ * Look up a service for a given name in the container.
+ *
+ * @param string $name
+ * @return mixed
+ */
+ function query($name);
+
+ /**
+ * A value is stored in the container with it's corresponding name
+ *
+ * @param string $name
+ * @param mixed $value
+ * @return void
+ */
+ 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 callable $closure
+ * @param bool $shared
+ * @return void
+ */
+ function registerService($name, \Closure $closure, $shared = true);
+}
--- /dev/null
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP;
+
+
+interface IRequest {
+
+ 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
+ */
+ 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
+ */
+ public function getParams();
+
+ /**
+ * Returns the method of the request
+ *
+ * @return string the method of the request (POST, GET, etc)
+ */
+ 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
+ */
+ 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
+ */
+ public function getEnv($key);
+
+
+ /**
+ * Shortcut for getting session variables
+ *
+ * @param string $key the key that will be taken from the $_SESSION array
+ * @return array the value in the $_SESSION element
+ */
+ function getSession($key);
+
+
+ /**
+ * Shortcut for getting cookie variables
+ *
+ * @param string $key the key that will be taken from the $_COOKIE array
+ * @return array the value in the $_COOKIE element
+ */
+ function getCookie($key);
+
+
+ /**
+ * Returns the request body content.
+ *
+ * @param Boolean $asResource If true, a resource will be returned
+ * @return string|resource The request body content or a resource to read the body stream.
+ * @throws \LogicException
+ */
+ function getContent($asResource = false);
+}
--- /dev/null
+<?php
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2013 Thomas Müller deepdiver@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP;
+
+
+/**
+ * Class IServerContainer
+ * @package OCP
+ *
+ * This container holds all ownCloud services
+ */
+interface IServerContainer {
+
+ /**
+ * The contacts manager will act as a broker between consumers for contacts information and
+ * providers which actual deliver the contact information.
+ *
+ * @return \OCP\Contacts\IManager
+ */
+ function getContactsManager();
+
+ /**
+ * The current request object holding all information about the request currently being processed
+ * is returned from this method.
+ * In case the current execution was not initiated by a web request null is returned
+ *
+ * @return \OCP\IRequest|null
+ */
+ function getRequest();
+
+}
namespace OC;
use OC\AppFramework\Utility\SimpleContainer;
-use OCP\Core\IServerContainer;
+use OCP\IServerContainer;
/**
* Class Server
}
/**
- * @return \OCP\Core\Contacts\IManager
+ * @return \OCP\Contacts\IManager
*/
function getContactsManager() {
return $this->query('ContactsManager');
}
+
+ /**
+ * The current request object holding all information about the request currently being processed
+ * is returned from this method.
+ * In case the current execution was not initiated by a web request null is returned
+ *
+ * @return \OCP\IRequest|null
+ */
+ function getRequest()
+ {
+ return $this->query('Request');
+ }
}