<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
protected $_ppDAO;
- function preProcess() {
- if(!CRM_Core_Permission::check('administer payment processors')) {
+ public function preProcess() {
+ if (!CRM_Core_Permission::check('administer payment processors')) {
CRM_Core_Error::statusBounce('The \'administer payment processors\' permission is required to add or edit a payment processor.');
}
parent::preProcess();
if ($this->_id) {
$this->_ppType = CRM_Utils_Request::retrieve('pp', 'String', $this, FALSE, NULL);
if (!$this->_ppType) {
- $this->_ppType = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_PaymentProcessor',
+ $this->_ppType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor',
$this->_id,
'payment_processor_type_id'
);
}
$this->assign('ppType', $this->_ppType);
- $ppTypeName = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_PaymentProcessorType',
+ $ppTypeName = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType',
$this->_ppType,
'name'
);
- $this->assign('ppTypeName', $ppTypeName );
+ $this->assign('ppTypeName', $ppTypeName);
- $this->_ppDAO = new CRM_Financial_DAO_PaymentProcessorType( );
+ $this->_ppDAO = new CRM_Financial_DAO_PaymentProcessorType();
$this->_ppDAO->id = $this->_ppType;
if (!$this->_ppDAO->find(TRUE)) {
* @param bool $check
*
* @return void
- * @access public
*/
public function buildQuickForm($check = FALSE) {
parent::buildQuickForm();
$attributes['name'], TRUE
);
- $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Financial_DAO_PaymentProcessor', $this->_id));
+ $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
+ 'CRM_Financial_DAO_PaymentProcessor',
+ $this->_id,
+ ));
$this->add('text', 'description', ts('Description'),
$attributes['description']
);
$types = CRM_Core_PseudoConstant::paymentProcessorType();
- $this->add( 'select', 'payment_processor_type_id', ts('Payment Processor Type'), $types, true,
+ $this->add('select', 'payment_processor_type_id', ts('Payment Processor Type'), $types, TRUE,
array('onchange' => "reload(true)")
);
}
$this->add('select', 'financial_account_id', ts('Financial Account'),
array('' => ts('- select -')) + $financialAccount,
- true
+ TRUE
);
// is this processor active ?
$this->add('checkbox', 'is_active', ts('Is this Payment Processor active?'));
$this->add('checkbox', 'is_default', ts('Is this Payment Processor the default?'));
-
foreach ($this->_fields as $field) {
if (empty($field['label'])) {
continue;
*
* @return array|bool
*/
- static function formRule($fields) {
+ public static function formRule($fields) {
// make sure that at least one of live or test is present
// and we have at least name and url_site
$errors = array();
if (!(self::checkSection($fields, $errors) ||
- self::checkSection($fields, $errors, 'test')
- )) {
+ self::checkSection($fields, $errors, 'test')
+ )
+ ) {
$errors['_qf_default'] = ts('You must have at least the test or live section filled');
}
*
* @return bool
*/
- static function checkSection(&$fields, &$errors, $section = NULL) {
+ public static function checkSection(&$fields, &$errors, $section = NULL) {
$names = array('user_name');
$present = FALSE;
/**
* @return array
*/
- function setDefaultValues() {
+ public function setDefaultValues() {
$defaults = array();
if ($this->_ppType) {
- $defaults['payment_processor_type_id'] = $this->_ppType;
+ $defaults['payment_processor_type_id'] = $this->_ppType;
}
if (!$this->_id) {
$defaults['is_active'] = $defaults['is_default'] = 1;
}
$domainID = CRM_Core_Config::domainID();
- $dao = new CRM_Financial_DAO_PaymentProcessor( );
- $dao->id = $this->_id;
+ $dao = new CRM_Financial_DAO_PaymentProcessor();
+ $dao->id = $this->_id;
$dao->domain_id = $domainID;
if (!$dao->find(TRUE)) {
return $defaults;
// now get testID
$testDAO = new CRM_Financial_DAO_PaymentProcessor();
- $testDAO->name = $dao->name;
- $testDAO->is_test = 1;
+ $testDAO->name = $dao->name;
+ $testDAO->is_test = 1;
$testDAO->domain_id = $domainID;
if ($testDAO->find(TRUE)) {
$this->_testID = $testDAO->id;
/**
* Process the form submission
*
- * @access public
*
* @return Void
*/
public function postProcess() {
- CRM_Utils_System::flushCache( 'CRM_Financial_DAO_PaymentProcessor' );
+ CRM_Utils_System::flushCache('CRM_Financial_DAO_PaymentProcessor');
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Financial_BAO_PaymentProcessor::del($this->_id);
CRM_Core_Session::setStatus("", ts('Payment Processor Deleted.'), "success");
- return;
+ return NULL;
}
$values = $this->controller->exportValues($this->_name);
* @param int $domainID
* @param $test
*
- * @return Void
+ * @return void
*/
- function updatePaymentProcessor(&$values, $domainID, $test) {
- $dao = new CRM_Financial_DAO_PaymentProcessor( );
+ public function updatePaymentProcessor(&$values, $domainID, $test) {
+ $dao = new CRM_Financial_DAO_PaymentProcessor();
- $dao->id = $test ? $this->_testID : $this->_id;
- $dao->domain_id = $domainID;
- $dao->is_test = $test;
+ $dao->id = $test ? $this->_testID : $this->_id;
+ $dao->domain_id = $domainID;
+ $dao->is_test = $test;
$dao->is_default = CRM_Utils_Array::value('is_default', $values, 0);
$dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
}
// also copy meta fields from the info DAO
- $dao->is_recur = $this->_ppDAO->is_recur;
+ $dao->is_recur = $this->_ppDAO->is_recur;
$dao->billing_mode = $this->_ppDAO->billing_mode;
- $dao->class_name = $this->_ppDAO->class_name;
+ $dao->class_name = $this->_ppDAO->class_name;
$dao->payment_type = $this->_ppDAO->payment_type;
$dao->save();
'entity_table' => 'civicrm_payment_processor',
'entity_id' => $dao->id,
'account_relationship' => $relationTypeId,
- 'financial_account_id' => $values['financial_account_id']
+ 'financial_account_id' => $values['financial_account_id'],
);
CRM_Financial_BAO_FinancialTypeAccount::add($params);
}
+
}