Ejemplo n.º 1
0
/**
 * Uninstall an extension.
 *
 * @param array $params
 *   Input parameters.
 *    - key: string, eg "com.example.myextension"
 *    - keys: array of string, eg array("com.example.myextension1", "com.example.myextension2")
 *
 * Using 'keys' should be more performant than making multiple API calls with 'key'
 *
 * @todo: removeFiles as optional param
 *
 * @return array
 */
function civicrm_api3_extension_uninstall($params)
{
    $keys = _civicrm_api3_getKeys($params);
    if (count($keys) == 0) {
        return civicrm_api3_create_success();
    }
    CRM_Extension_System::singleton()->getManager()->uninstall($keys);
    return civicrm_api3_create_success();
}
Ejemplo n.º 2
0
/**
 * Uninstall an extension.
 *
 * @param array $params
 *   Input parameters.
 *                          - key: string, eg "com.example.myextension"
 *                          - keys: array of string, eg array("com.example.myextension1", "com.example.myextension2")
 *                            using 'keys' should be more performant than making multiple API calls with 'key'
 *                          - removeFiles: bool, whether to remove source tree; default: FALSE
 *
 * @return array
 *   API result
 */
function civicrm_api3_extension_uninstall($params)
{
    $keys = _civicrm_api3_getKeys($params);
    if (count($keys) == 0) {
        return civicrm_api3_create_success();
    }
    // TODO // $removeFiles = CRM_Utils_Array::value('removeFiles', $params, FALSE);
    CRM_Extension_System::singleton()->getManager()->uninstall($keys);
    return civicrm_api3_create_success();
}
/**
 * Uninstall an extension
 *
 * @param  array   	  $params input parameters
 *                          - key: string, eg "com.example.myextension"
 *                          - keys: array of string, eg array("com.example.myextension1", "com.example.myextension2")
 *                            using 'keys' should be more performant than making multiple API calls with 'key'
 *                          - removeFiles: bool, whether to remove source tree; default: FALSE
 *
 * @return array API result
 * @static void
 * @access public
 * @example ExtensionUninstall.php
 *
 */
function civicrm_api3_extension_uninstall($params)
{
    $keys = _civicrm_api3_getKeys($params);
    if (count($keys) == 0) {
        return civicrm_api3_create_success();
    }
    $ext = new CRM_Core_Extensions();
    $exts = $ext->getExtensions();
    foreach ($keys as $key) {
        if (!$ext->isEnabled()) {
            return civicrm_api3_create_error('Extension support is not enabled');
        } elseif (!$ext->isExtensionKey($key) || !array_key_exists($key, $exts)) {
            // FIXME: is this necesary? if $key is not in $exts, can't we assume it's uninstalled
            return civicrm_api3_create_error('Invalid extension key: ' . $key);
        } elseif ($exts[$key]->status != 'installed') {
            return civicrm_api3_create_error('Can only uninstall extensions which have been previously installed');
        } elseif ($exts[$key]->is_active == TRUE) {
            return civicrm_api3_create_error('Extension must be disabled before uninstalling');
        } else {
            // pre-condition: installed and inactive
            $removeFiles = CRM_Utils_Array::value('removeFiles', $params, FALSE);
            $ext->uninstall(NULL, $key, $removeFiles);
            // FIXME: only rebuild cache one time
        }
    }
    return civicrm_api3_create_success();
}