/**
  * Check method testisACLFinancialTypeStatus()
  */
 public function testBuildPermissionedClause()
 {
     $this->setACL();
     $this->setPermissions(array('view contributions of type Donation', 'view contributions of type Member Dues'));
     CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
     $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,2)');
     $this->setPermissions(array('view contributions of type Donation', 'view contributions of type Member Dues', 'view contributions of type Event Fee'));
     $whereClause = NULL;
     CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
     $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,4,2)');
 }
Example #2
0
 /**
  * Function which actually does all the work for the constructor.
  */
 public function initialize()
 {
     $this->_select = array();
     $this->_element = array();
     $this->_tables = array();
     $this->_whereTables = array();
     $this->_where = array();
     $this->_qill = array();
     $this->_options = array();
     $this->_cfIDs = array();
     $this->_paramLookup = array();
     $this->_having = array();
     $this->_customQuery = NULL;
     // reset cached static variables - CRM-5803
     self::$_activityRole = NULL;
     self::$_considerCompActivities = NULL;
     self::$_withContactActivitiesOnly = NULL;
     $this->_select['contact_id'] = 'contact_a.id as contact_id';
     $this->_element['contact_id'] = 1;
     $this->_tables['civicrm_contact'] = 1;
     if (!empty($this->_params)) {
         $this->buildParamsLookup();
     }
     $this->_whereTables = $this->_tables;
     $this->selectClause();
     $this->_whereClause = $this->whereClause();
     if (array_key_exists('civicrm_contribution', $this->_whereTables)) {
         $component = 'contribution';
     }
     if (array_key_exists('civicrm_membership', $this->_whereTables)) {
         $component = 'membership';
     }
     if (isset($component)) {
         CRM_Financial_BAO_FinancialType::buildPermissionedClause($this->_whereClause, $component);
     }
     $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode);
     $this->_simpleFromClause = self::fromClause($this->_whereTables, NULL, NULL, $this->_primaryLocation, $this->_mode);
     $this->openedSearchPanes(TRUE);
 }
 /**
  * Check method testisACLFinancialTypeStatus()
  */
 public function testbuildPermissionedClause()
 {
     $this->setACL();
     $config =& CRM_Core_Config::singleton();
     $config->userPermissionClass->permissions = array('view contributions of type Donation', 'view contributions of type Member Dues');
     CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
     $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,2)');
     $config->userPermissionClass->permissions[] = 'view contributions of type Event Fee';
     $whereClause = NULL;
     CRM_Financial_BAO_FinancialType::$_availableFinancialTypes = array();
     CRM_Financial_BAO_FinancialType::buildPermissionedClause($whereClause, 'contribution');
     $this->assertEquals($whereClause, ' civicrm_contribution.financial_type_id IN (1,4,2)');
 }