diff --git a/developer_manual/digging_deeper/groupware/contacts_menu.rst b/developer_manual/digging_deeper/groupware/contacts_menu.rst new file mode 100644 index 00000000000..ed86c71ce39 --- /dev/null +++ b/developer_manual/digging_deeper/groupware/contacts_menu.rst @@ -0,0 +1,89 @@ +============= +Contacts Menu +============= + +Nextcloud shows a *Contacts menu* in the right corner of the header. This menu lists a user's contacts. These contact entries can be extended by apps. + +Apps that extend the contacts menu implement an IProvider. The providers ``process`` method is called for every entry show in the contacts menu. + +.. code-block:: php + :caption: lib/ContactsMenu/MyProvider.php + + + + my_app + My App + + OCA\MyApp\ContactsMenu\LinkActionProvider + + + +Accessing contact info +^^^^^^^^^^^^^^^^^^^^^^ + +The ``IEntry`` objects offer getters to contact infos: + +* ``getFullName()``: Get full name. Falls back to an empty string if no full name is set. +* ``getEMailAddresses()``: Get all email addresses. +* ``getAvatar()``: Get the avatar URI. +* ``getProperty(string $name)``: Read a property of the contact. Return NULL if the property is not set. + +Actions +^^^^^^^ + +Providers can add actions to contact entries. Right now email and link actions are supported. These are created with the help of the ``IActionFactory``. + +.. code-block:: php + :caption: lib/ContactsMenu/LinkProvider.php + + actionFactory = $actionFactory + } + + public function process(IEntry $entry): void { + $emailAction = $this->actionFactory->newEMailAction( + '/apps/myapp/img/link.png', // icon URL + 'Click me', // name + 'user@domain.tld', // email address + 'my_app', // app ID (optional) + ); + $linkAction = $this->actionFactory->newLinkAction( + '/apps/myapp/img/link.png', // icon URL + 'Click me', // name + 'https://.....', // href + 'my_app', // app ID (optional) + ); + + $entry->addAction($emailAction); + $entry->addAction($linkAction); + } + } diff --git a/developer_manual/digging_deeper/groupware/index.rst b/developer_manual/digging_deeper/groupware/index.rst index 6b5fb54d51d..67107d157ce 100644 --- a/developer_manual/digging_deeper/groupware/index.rst +++ b/developer_manual/digging_deeper/groupware/index.rst @@ -7,3 +7,4 @@ Groupware integration calendar calendar_provider + contacts_menu