ICM-18 Fixed issues that were reported by Jenkins test
[civicrm-core.git] / CRM / Member / Form / MembershipView.php
index 134bfe8a59be3da52b354a8708bbc3180120a2e6..b72fff1a92420b201dbbb96d073552d11d9b262a 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
 class CRM_Member_Form_MembershipView extends CRM_Core_Form {
 
   /**
-   * The action links that we need to display for the browse screen
+   * The action links that we need to display for the browse screen.
    *
    * @var array
    */
   static $_links = NULL;
 
   /**
-   * Add context information at the end of a link
+   * Add context information at the end of a link.
    *
    * @return string
    *   extra query parameters
@@ -63,7 +63,7 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form {
   }
 
   /**
-   * Get action Links
+   * Get action Links.
    *
    * @return array
    *   (reference) of action links
@@ -89,7 +89,7 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form {
   }
 
   /**
-   * Perform create or delete action on related memberships
+   * Perform create or delete action on related memberships.
    *
    * @param string $action
    *   Create or delete.
@@ -143,7 +143,7 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form {
   }
 
   /**
-   * Set variables up before form is built
+   * Set variables up before form is built.
    *
    * @return void
    */
@@ -158,8 +158,15 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form {
 
     if ($id) {
       $params = array('id' => $id);
-
       CRM_Member_BAO_Membership::retrieve($params, $values);
+      if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
+        $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values['membership_type_id'], 'financial_type_id');
+        $finType = CRM_Contribute_PseudoConstant::financialType($finTypeId);
+        if (!CRM_Core_Permission::check('view contributions of type ' . $finType)) {
+          CRM_Core_Error::fatal(ts('You do not have permissionn to access this page.'));
+        }
+      }
+      $this->assign('financialTypeId', $finType);
       $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
 
       // Do the action on related Membership if needed
@@ -393,7 +400,7 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment,
   }
 
   /**
-   * Build the form object
+   * Build the form object.
    *
    * @return void
    */
@@ -408,4 +415,5 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment,
       )
     );
   }
+
 }