Difference between revisions of "AppSuite:Capabilities"

(What are capabilities?)
(What are capabilities?)
Line 11: Line 11:
 
Usecase:  
 
Usecase:  
  
You write a new UI app or plugin for OX AppSuite and want to make sure that only specific OX users or OX contexts can use that app or plugin. For example, after someone purchased it via a web shop or similar. Of course, it is also possible to make a plugin / app available for all users of an OX system.
+
You write a new UI app or plugin (Chat module, for example) for OX AppSuite and want to make sure that only a specific set of OX users or OX contexts within the OX system can use that app or plugin. Of course, it is also possible to make a plugin / app available for all users of an OX system.
 +
 
 +
Example: Your chat app should only be visible/useable after a user has bought it in your online shop + your provisioning has updated the corresponding user/context inside the OX system. Then you need to implement the capabilities logic inside your UI app or plugin, that it only loads and is useable for premium (who paid in your webshop before) users.
  
 
== Set a capability ==
 
== Set a capability ==

Revision as of 14:36, 9 January 2014



Synopsis: How to use capabilities so that your new AppSuite plugin can be enabled or disabled.

What are capabilities?

Usecase:

You write a new UI app or plugin (Chat module, for example) for OX AppSuite and want to make sure that only a specific set of OX users or OX contexts within the OX system can use that app or plugin. Of course, it is also possible to make a plugin / app available for all users of an OX system.

Example: Your chat app should only be visible/useable after a user has bought it in your online shop + your provisioning has updated the corresponding user/context inside the OX system. Then you need to implement the capabilities logic inside your UI app or plugin, that it only loads and is useable for premium (who paid in your webshop before) users.

Set a capability

First, disable it for everyone as default (or enable it for everyone, depending on what your aim is). In /opt/open-xchange/[myproduct].properties:

 com.openexchange.capability.[myproduct]=false # off for everyone

Then enable it only for a specific user:

 changeuser ... --config/com.openexchange.capability.[myproduct]=true

Or for a full context:

 changecontext -c ... --config/com.openexchange.capability.[myproduct]=true


Or give the capability to a context set:

 changecontext -c ... --taxonomy/types=premium

in /opt/open-xchange/etc/contextSets/premium.yml:

 premium:
    com.openexchange.config.capability.[myproduct]: true
    withTags: premium

Query capabilities via the HTTP API

Query:

 GET /appsuite/api/capabilities?action=all&session=991fd40f635b45...

Response:

 {"data":[{"id":"oauth","attributes":{}},{"id":"webmail","attributes":{}},{"id":"document_preview","attributes":{}},{"id":"printing","attributes":{}},{"id":"spreadsheet","attributes":{}},{"id":"gab","attributes":{}},{"id":"multiple_mail_accounts","attributes":{}},{"id":"publication","attributes":{}},{"id":"rss_bookmarks","attributes":{}},{"id":"linkedin","attributes":{}},{"id":"filestore","attributes":{}},{"id":"ical","attributes":{}},{"id":"rt","attributes":{}},{"id":"olox20","attributes":{}},{"id":"forum","attributes":{}},{"id":"active_sync","attributes":{}},{"id":"conflict_handling","attributes":{}},{"id":"rss_portal","attributes":{}},{"id":"oxupdater","attributes":{}},{"id":"infostore","attributes":{}},{"id":"contacts","attributes":{}},{"id":"collect_email_addresses","attributes":{}},{"id":"facebook","attributes":{}},{"id":"drive","attributes":{}},{"id":"rss","attributes":{}},{"id":"pinboard_write_access","attributes":{}},{"id":"mobility","attributes":{}},{"id":"calendar","attributes":{}},{"id":"participants_dialog","attributes":{}},{"id":"edit_public_folders","attributes":{}},{"id":"text","attributes":{}},{"id":"groupware","attributes":{}},{"id":"msisdn","attributes":{}},{"id":"carddav","attributes":{}},{"id":"tasks","attributes":{}},{"id":"portal","attributes":{}},{"id":"mailfilter","attributes":{}},{"id":"read_create_shared_folders","attributes":{}},{"id":"vcard","attributes":{}},{"id":"pim","attributes":{}},{"id":"caldav","attributes":{}},{"id":"projects","attributes":{}},{"id":"usm","attributes":{}},{"id":"webdav","attributes":{}},{"id":"dev","attributes":{}},{"id":"delegate_tasks","attributes":{}},{"id":"freebusy","attributes":{}},{"id":"subscription","attributes":{}},{"id":"linkedinPlus","attributes":{}},{"id":"autologin","attributes":{}},{"id":"webdav_xml","attributes":{}},{"id":"twitter","attributes":{}}]}

Here id is the name of the capability.

Query capabilities in the UI

 require(['io.ox/core/capabilities'], function (cap) { if cap.has('[myproduct]' { ... } );

Require capabilities in a manifest

 {
    namespace: ...
    requires: '[myproduct]'
 }

The plugin will only be loaded if the capability is set for the specific user.


Further notes

  • For testing purposes, you can use the &cap=[myproduct] url parameter to enable a capability. Remember to refresh.
  • Similarly, you can disable a capability with &disableFeature=[myproduct]
  • If you want to know about existing capabilities and the way they are used for upsell, see AppSuite:Upsell#Capabilities_and_Upsell_triggers