CRM-12882 - Allow all admins to view payment processors page. Clarify error message...
[civicrm-core.git] / CRM / Admin / Form / PaymentProcessor.php
index 39832402c93f417ae4782d6bf1d2743f873cd2b4..8453954760ec318cfc69c13dd397b538399123ae 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id: PaymentProcessor.php 9702 2007-05-29 23:57:16Z lobo $
  *
  */
@@ -48,7 +48,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
 
   function preProcess() {
     if(!CRM_Core_Permission::check('administer payment processors')) {
-      CRM_Core_Error::fatal('You do not have permission to administer payment processors');
+      CRM_Core_Error::fatal('The \'administer payment processors\' permission is required to add or edit a payment processor.');
     }
     parent::preProcess();
 
@@ -164,6 +164,8 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
   /**
    * Function to build the form
    *
+   * @param bool $check
+   *
    * @return void
    * @access public
    */
@@ -217,7 +219,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
       $this->add('text', "test_{$field['name']}",
         $field['label'], $attributes[$field['name']]
       );
-      if (CRM_Utils_Array::value('rule', $field)) {
+      if (!empty($field['rule'])) {
         $this->addRule($field['name'], $field['msg'], $field['rule']);
         $this->addRule("test_{$field['name']}", $field['msg'], $field['rule']);
       }
@@ -336,7 +338,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
     $values = $this->controller->exportValues($this->_name);
     $domainID = CRM_Core_Config::domainID();
 
-    if (CRM_Utils_Array::value('is_default', $values)) {
+    if (!empty($values['is_default'])) {
       $query = "UPDATE civicrm_payment_processor SET is_default = 0 WHERE domain_id = $domainID";
       CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
@@ -349,6 +351,10 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form {
   /**
    * Save a payment processor
    *
+   * @param $values
+   * @param $domainID
+   * @param $test
+   *
    * @return Void
    */
   function updatePaymentProcessor(&$values, $domainID, $test) {