static function details($csID, $ssID = null, $gID = null)
 {
     $error = array(null, null, null);
     if (!$csID && !$ssID && !$gID) {
         return $error;
     }
     $customSearchID = $csID;
     $formValues = array();
     if ($ssID || $gID) {
         if ($gID) {
             $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $gID, 'saved_search_id');
         }
         $formValues = CRM_Contact_BAO_SavedSearch::getFormValues($ssID);
         $customSearchID = CRM_Utils_Array::value('customSearchID', $formValues);
     }
     if (!$customSearchID) {
         return $error;
     }
     // check that the csid exists in the db along with the right file
     // and implements the right interface
     require_once 'CRM/Core/OptionGroup.php';
     $customSearchClass = CRM_Core_OptionGroup::getLabel('custom_search', $customSearchID);
     if (!$customSearchClass) {
         return $error;
     }
     require_once 'CRM/Core/Extensions.php';
     $ext = new CRM_Core_Extensions();
     if (!$ext->isExtensionKey($customSearchClass)) {
         $customSearchFile = str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php';
     } else {
         $customSearchFile = $ext->keyToPath($customSearchClass);
         $customSearchClass = $ext->keyToClass($customSearchClass);
     }
     $error = (include_once $customSearchFile);
     if ($error == false) {
         CRM_Core_Error::fatal('Custom search file: ' . $customSearchFile . ' does not exist. Please verify your custom search settings in CiviCRM administrative panel.');
     }
     return array($customSearchID, $customSearchClass, $formValues);
 }
示例#2
0
 /**  
  * singleton function used to manage this object  
  *  
  * @param string $mode the mode of operation: live or test
  *  
  * @return object  
  * @static  
  *  
  */
 static function &singleton($mode = 'test', &$paymentProcessor, &$paymentForm = null, $force = false)
 {
     $cacheKey = "{$mode}_{$paymentProcessor['id']}_" . (int) isset($paymentForm);
     if (!isset(self::$_singleton[$cacheKey]) || $force) {
         $config = CRM_Core_Config::singleton();
         require_once 'CRM/Core/Extensions.php';
         $ext = new CRM_Core_Extensions();
         if ($ext->isExtensionKey($paymentProcessor['class_name'])) {
             $paymentClass = $ext->keyToClass($paymentProcessor['class_name'], 'payment');
             require_once $ext->classToPath($paymentClass);
         } else {
             $paymentClass = "CRM_Core_" . $paymentProcessor['class_name'];
             require_once str_replace('_', DIRECTORY_SEPARATOR, $paymentClass) . '.php';
         }
         //load the object.
         self::$_singleton[$cacheKey] = eval('return ' . $paymentClass . '::singleton( $mode, $paymentProcessor );');
         //load the payment form for required processor.
         if ($paymentForm !== null) {
             self::$_singleton[$cacheKey]->setForm($paymentForm);
         }
     }
     return self::$_singleton[$cacheKey];
 }
示例#3
0
 /**
  * Class constructor
  *
  * @param array $formValues array of form values imported
  * @param array $params     array of parameters for query
  * @param int   $action - action of search basic or advanced.
  *
  * @return CRM_Contact_Selector
  * @access public
  */
 function __construct($customSearchClass, $formValues = null, $params = null, $returnProperties = null, $action = CRM_Core_Action::NONE, $includeContactIds = false, $searchChildGroups = true, $searchContext = 'search')
 {
     $this->_customSearchClass = $customSearchClass;
     $this->_formValues = $formValues;
     $this->_includeContactIds = $includeContactIds;
     require_once 'CRM/Core/Extensions.php';
     $ext = new CRM_Core_Extensions();
     if (!$ext->isExtensionKey($customSearchClass)) {
         if ($ext->isExtensionClass($customSearchClass)) {
             $customSearchFile = $ext->classToPath($customSearchClass);
             require_once $customSearchFile;
         } else {
             require_once str_replace('_', DIRECTORY_SEPARATOR, $customSearchClass) . '.php';
         }
         eval('$this->_search = new ' . $customSearchClass . '( $formValues );');
     } else {
         $customSearchFile = $ext->keyToPath($customSearchClass, 'search');
         require_once $customSearchFile;
         eval('$this->_search = new ' . $ext->keyToClass($customSearchClass, 'search') . '( $formValues );');
     }
 }
 /**
  * Payment callback handler
  * Load requested payment processor and call that processor's handle<$method> method
  *
  * @public
  */
 static function handlePaymentMethod($method, $params = array())
 {
     if (!isset($params['processor_name'])) {
         CRM_Core_Error::fatal("Missing 'processor_name' param for payment callback");
     }
     // Query db for processor ..
     $mode = @$params['mode'];
     $dao = CRM_Core_DAO::executeQuery("\n             SELECT ppt.class_name, ppt.name as processor_name, pp.id AS processor_id\n               FROM civicrm_payment_processor_type ppt\n         INNER JOIN civicrm_payment_processor pp\n                 ON pp.payment_processor_type = ppt.name\n                AND pp.is_active\n                AND pp.is_test = %1\n              WHERE ppt.name = %2 \n        ", array(1 => array($mode == 'test' ? 1 : 0, 'Integer'), 2 => array($params['processor_name'], 'String')));
     // Check whether we found anything at all ..
     if (!$dao->N) {
         CRM_Core_Error::fatal("No active instances of the '{$params['processor_name']}' payment processor were found.");
     }
     $method = 'handle' . $method;
     $extension_instance_found = FALSE;
     // In all likelihood, we'll just end up with the one instance returned here. But it's
     // possible we may get more. Hence, iterate through all instances ..
     while ($dao->fetch()) {
         // Check pp is extension
         $ext = new CRM_Core_Extensions();
         if ($ext->isExtensionKey($dao->class_name)) {
             $extension_instance_found = TRUE;
             $paymentClass = $ext->keyToClass($dao->class_name, 'payment');
             require_once $ext->classToPath($paymentClass);
         } else {
             // Legacy instance - but there may also be an extension instance, so
             // continue on to the next instance and check that one. We'll raise an
             // error later on if none are found.
             continue;
         }
         $paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($dao->processor_id, $mode);
         // Should never be empty - we already established this processor_id exists and is active.
         if (empty($paymentProcessor)) {
             continue;
         }
         // Instantiate PP
         eval('$processorInstance = ' . $paymentClass . '::singleton( $mode, $paymentProcessor );');
         // Does PP implement this method, and can we call it?
         if (!method_exists($processorInstance, $method) || !is_callable(array($processorInstance, $method))) {
             // No? This will be the case in all instances, so let's just die now
             // and not prolong the agony.
             CRM_Core_Error::fatal("Payment processor does not implement a '{$method}' method");
         }
         // Everything, it seems, is ok - execute pp callback handler
         $processorInstance->{$method}();
     }
     if (!$extension_instance_found) {
         CRM_Core_Error::fatal("No extension instances of the '{$params['processor_name']}' payment processor were found.<br />" . "{$method} method is unsupported in legacy payment processors.");
     }
     // Exit here on web requests, allowing just the plain text response to be echoed
     if ($method == 'handlePaymentNotification') {
         CRM_Utils_System::civiExit();
     }
 }
/**
 * 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();
}