예제 #1
0
 /**
  * undocumented function
  *
  * @return void
  **/
 public function uninstall()
 {
     if (!array_key_exists($this->ext->key, $this->paymentProcessorTypes)) {
         CRM_Core_Error::fatal('This payment processor type is not registered.');
     }
     require_once 'CRM/Core/PseudoConstant.php';
     $paymentProcessors = CRM_Core_PseudoConstant::paymentProcessor(TRUE);
     require_once "CRM/Core/DAO/PaymentProcessor.php";
     foreach ($paymentProcessors as $id => $name) {
         $dao = new CRM_Core_DAO_PaymentProcessor();
         $dao->id = $id;
         $dao->find();
         while ($dao->fetch()) {
             if ($dao->payment_processor_type == $this->ext->name) {
                 CRM_Core_Error::fatal('Cannot uninstall this extension - there is at least one payment processor using payment processor type provided by it.');
             }
         }
     }
     require_once "CRM/Core/BAO/PaymentProcessorType.php";
     CRM_Core_BAO_PaymentProcessorType::del($this->paymentProcessorTypes[$this->ext->key]);
 }
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_PaymentProcessorType');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_PaymentProcessorType::del($this->_id);
         return;
     }
     $values = $this->controller->exportValues($this->_name);
     if (CRM_Utils_Array::value('is_default', $values)) {
         $query = "\nUPDATE civicrm_payment_processor SET is_default = 0";
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     $dao = new CRM_Core_DAO_PaymentProcessorType();
     $dao->id = $this->_id;
     $dao->is_default = CRM_Utils_Array::value('is_default', $values, 0);
     $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
     $dao->is_recur = CRM_Utils_Array::value('is_recur', $values, 0);
     $dao->name = $values['name'];
     $dao->description = $values['description'];
     foreach ($this->_fields as $field) {
         $dao->{$field['name']} = trim($values[$field['name']]);
         if (empty($dao->{$field['name']})) {
             $dao->{$field['name']} = 'null';
         }
     }
     $dao->save();
 }
/**
 * Delete a payment_processor type delete
 *
 * @param  id of payment_processor type  $id
 *
 * @return array API Result Array
 * {@getfields PaymentProcessorType_delete}
 * @static void
 * @access public
 */
function civicrm_api3_payment_processor_type_delete($params)
{
    require_once 'CRM/Utils/Rule.php';
    if ($params['id'] != NULL && !CRM_Utils_Rule::integer($params['id'])) {
        return civicrm_api3_create_error('Invalid value for payment processor type ID');
    }
    $payProcTypeBAO = new CRM_Core_BAO_PaymentProcessorType();
    $result = $payProcTypeBAO->del($params['id']);
    if (!$result) {
        return civicrm_api3_create_error('Could not delete payment processor type');
    }
    return civicrm_api3_create_success($result, $params, 'payment_processor_type', 'delete', $payProcTypeBAO);
}