Answers.Body: <p>Looking at the Civi API Explorer, you could reference the Extension entity.</p>
  
  <p>The help text for the Key parameter (API explorer uses full_name in the code) says "Fully qualified extension name". If you got the Key parameter <code>full_name="eu.tttp.civisualize"</code>, you could load your dashlets conditionally based on whether CiviVisualize is enabled.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-11T22:23:43.077Z
Answers.Text: Yes, I can use that  during the install or enabling of my extension and then use "Dashboard - Create" api call to add the dashlet. But when should I check it if Civisualize is not active during install of my extension and I want to make my dashlets available when it becomes active? (Or worse, when Civisualize gets disabled after my dashlets are added to the system). Maybe the answer has to be: I  just give a warning when the dashlet is shown and Civisualize is not enabled, but I'd prefer  they are not shown in that case.
Answers.UserDisplayName: Catorghans
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-11T21:36:45.340Z
Answers.LastActivityDate: 2016-02-11T21:47:05.300Z
Answers.LastEditDate: 2016-02-11T21:47:05.300Z
Answers.UserDisplayName: Allen Hutchison
Answers.Body: <p>An alternate approach to checking for the enable/disable status is to use <a href="http://php.net/manual/en/function.function-exists.php" rel="nofollow"><code>function_exists()</code></a> to check if any of the functions CiviVisualize defines are in PHP's list of defined functions, which implies that CiviVisualize is installed and enabled.</p>
  
  <pre><code>if (function_exists('civisualize_civicrm_config')) {
    // Yay! Provide dashlets.
  }
  else {
    // Recommend installing CiviVisualize
  }
  </code></pre>
  
  <p>If the extension isn't enabled, you can still provide placeholder content that will be replaced when the extension is enabled.</p>
  
  <p>Using <code>function_exists()</code> should have relatively little performance impact and therefore may allow you to check the currently enabled status of that extension, rather than watch for enable/disable "events".</p>
  
  <p>This also has the benefit of not failing when (e.g) the other extension is removed from the filesystem without being disabled first. It also has an issue of being sensitive to function naming within the other extension, but if  <code>civisualize_civicrm_config</code> was renamed you'd probably be looking at a whole new version of the extension you integrate with.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-12T01:56:10.760Z
Answers.LastActivityDate: 2016-02-12T03:19:18.397Z
Answers.LastEditDate: 2016-02-12T03:19:18.397Z
Answers.UserDisplayName: Chris Burgess
Body: <p>My extension makes reports based on the Civisualize extension. I'd like to make dashlets out of the reports, but I only want it to be available when Civisualize is also enabled.</p>
  
  <p>It's easy to see if Civisualize is already enabled when my extension becomes enabled, but I don't see a way to find out when Civisualize becomes enabled or disabled after my extension has become active.</p>
  
  <p>My extension does not depend on Civisualize, it works perfectly without, but it only gives some extra nice reports.</p>
  
  <p>So I would like to use some kind of hook_extension_enabled which will be fired when other extensions become enabled so I can add my dashlets to the system when Civisualize becomes active and remove the dashlets when it gets inactive.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-11T21:47:57.710Z
Comments.Text: What do you mean exactly by "It's easy to see if Civisualize is enabled when my extension is enabled,"?  How are you verifying that?
Comments.UserDisplayName: Allen Hutchison
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-11T22:08:30.670Z
Comments.Text: I edited my question, think it is more clear now what I want.
Comments.UserDisplayName: Catorghans
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-12T10:18:33.250Z
Comments.Text: Hi, I think we should be able to flag dependencies between extensions. GSoC project?
Comments.UserDisplayName: Xavier
Tags: <extension><hooks><civisualize>
Title: Can my extension know when other extensions become enabled or disabled?
ThreadText: # Can my extension know when other extensions become enabled or disabled?
  
  (Asked by: username_0 on 2016-02-11)
  
  My extension makes reports based on the Civisualize extension. I'd like to make dashlets out of the reports, but I only want it to be available when Civisualize is also enabled.
  
  It's easy to see if Civisualize is already enabled when my extension becomes enabled, but I don't see a way to find out when Civisualize becomes enabled or disabled after my extension has become active.
  
  My extension does not depend on Civisualize, it works perfectly without, but it only gives some extra nice reports.
  
  So I would like to use some kind of hook\_extension\_enabled which will be fired when other extensions become enabled so I can add my dashlets to the system when Civisualize becomes active and remove the dashlets when it gets inactive.
  
  **Tags:** extension, hooks, civisualize
  
  > **Comments:**
  > **username_1**: What do you mean exactly by "It's easy to see if Civisualize is enabled when my extension is enabled,"?  How are you verifying that?  
  > **username_0**: I edited my question, think it is more clear now what I want.  
  > **username_2**: Hi, I think we should be able to flag dependencies between extensions. GSoC project?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-02-11. Score: 2
  
  Looking at the Civi API Explorer, you could reference the Extension entity.
  
  The help text for the Key parameter (API explorer uses full\_name in the code) says "Fully qualified extension name". If you got the Key parameter `full_name="eu.tttp.civisualize"`, you could load your dashlets conditionally based on whether CiviVisualize is enabled.
  
  > **Comments:**
  > **username_0**: Yes, I can use that  during the install or enabling of my extension and then use "Dashboard - Create" api call to add the dashlet. But when should I check it if Civisualize is not active during install of my extension and I want to make my dashlets available when it becomes active? (Or worse, when Civisualize gets disabled after my dashlets are added to the system). Maybe the answer has to be: I  just give a warning when the dashlet is shown and Civisualize is not enabled, but I'd prefer  they are not shown in that case.  
  
  ---
  
  ### Answer by username_3 on 2016-02-12. Score: 2
  
  An alternate approach to checking for the enable/disable status is to use [`function_exists()`](http://php.net/manual/en/function.function-exists.php) to check if any of the functions CiviVisualize defines are in PHP's list of defined functions, which implies that CiviVisualize is installed and enabled.
  
  ```
  if (function_exists('civisualize_civicrm_config')) {
    // Yay! Provide dashlets.
  }
  else {
    // Recommend installing CiviVisualize
  }
  
  ```
  
  If the extension isn't enabled, you can still provide placeholder content that will be replaced when the extension is enabled.
  
  Using `function_exists()` should have relatively little performance impact and therefore may allow you to check the currently enabled status of that extension, rather than watch for enable/disable "events".
  
  This also has the benefit of not failing when (e.g) the other extension is removed from the filesystem without being disabled first. It also has an issue of being sensitive to function naming within the other extension, but if `civisualize_civicrm_config` was renamed you'd probably be looking at a whole new version of the extension you integrate with.
  
  
  ---
  
  