summaryrefslogtreecommitdiffstats
path: root/lib/public/contacts.php
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2012-12-02 11:54:30 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2012-12-02 11:54:30 +0100
commit35e55214e24116a4501260ff4ce94c171404737b (patch)
treec8a1270233430a7ac44695e589ad42c69c5eef39 /lib/public/contacts.php
parentf99497a05a14ccf3c96ece71ae963a2eb482f4b6 (diff)
downloadnextcloud-server-35e55214e24116a4501260ff4ce94c171404737b.tar.gz
nextcloud-server-35e55214e24116a4501260ff4ce94c171404737b.zip
[Contacts API] example for searching added
Diffstat (limited to 'lib/public/contacts.php')
-rw-r--r--lib/public/contacts.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/public/contacts.php b/lib/public/contacts.php
index 412600dd7f6..6842f40f1b3 100644
--- a/lib/public/contacts.php
+++ b/lib/public/contacts.php
@@ -102,6 +102,38 @@ namespace OCP {
* 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!