CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • AJAX API - is an extension installed???
Pages: [1]

Author Topic: AJAX API - is an extension installed???  (Read 532 times)

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
AJAX API - is an extension installed???
December 01, 2013, 09:08:37 am
Hi gang,

I need to use AJAX API to find out if a civicrm extension is installed.

A small, virtual, prize to the submitter of the successful answer!

Thanks,
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: AJAX API - is an extension installed???
December 01, 2013, 10:06:16 am
Use entity "Extension" and action "get" to retrieve a list of all extensions. It includes the status for each. (This applies to Civi 4.4+ and probably 4.3. Haven't checked 4.2.)

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Re: AJAX API - is an extension installed???
December 01, 2013, 11:24:48 am
Hi, thanks for responding

Regrettably, in 4.2 I just get invited to the API team to implement it!
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: AJAX API - is an extension installed???
December 01, 2013, 12:23:09 pm
I should have written you're warmly invited...and you're going to take on this invitation, aren't you?

Try to backport the API first, if you're lucky, most of the underlying BAO/stuff are there and ready to be called
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: AJAX API - is an extension installed???
December 01, 2013, 01:11:10 pm
In this case, I think he's unlucky. :( The internals of the extension system were significantly reworked between 4.2 and 4.3. To write a similar API for 4.2, you might be able to call CRM_Core_Extensions->getExtensionsByKey() and then check the "$status" property on each. Those statuses won't match-up 1:1 with the statuses in 4.3:

 * The statuses in 4.2 are "installed", "missing", "local", "remote". (IIRC, "local" means "uninstalled in DB but installed on local filesystem" and "remote" means "uninstalled in DB and uninstalled in local filesystem".)
 * The statuses in 4.3 are "installed", "disabled", "uninstalled", "installed-missing", "disabled-missing", and "unknown".

To provide better compatibility, I'd suggest the 4.2 API try to map statuses to 4.3 names:

 * 4.2 installed ==> 4.3 installed
 * 4.2 missing ==> 4.3 unknown
 * 4.2 local ==> 4.3 uninstalled
 * 4.2 remote ==> omit from listing

(I'm not 100% on those mappings -- in particular, I don't remember how 4.2 distinguished "disabled" from other statuses... you'd need to study it...)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • AJAX API - is an extension installed???

This forum was archived on 2017-11-26.