is_active = 1; $dao->orderBy('id'); $dao->find(); while ($dao->fetch()) { $products[$dao->id] = $dao->name; } if ($pageID) { $dao = new CRM_Contribute_DAO_Premium(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $pageID; $dao->find(TRUE); $premiumID = $dao->id; $productID = array(); $dao = new CRM_Contribute_DAO_PremiumsProduct(); $dao->premiums_id = $premiumID; $dao->find(); while ($dao->fetch()) { $productID[$dao->product_id] = $dao->product_id; } $tempProduct = array(); foreach ($products as $key => $value) { if (!array_key_exists($key, $productID)) { $tempProduct[$key] = $value; } } return $tempProduct; } return $products; } /** * Get all the contribution statuses. * * * @param int $id * @param string $columnName * @return array * array reference of all contribution statuses */ public static function &contributionStatus($id = NULL, $columnName = 'label') { $cacheKey = $columnName; if (!isset(self::$contributionStatus[$cacheKey])) { self::$contributionStatus[$cacheKey] = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, $columnName ); } $result = self::$contributionStatus[$cacheKey]; if ($id) { $result = CRM_Utils_Array::value($id, $result); } return $result; } /** * Get all the Personal campaign pages. * * * @param null $pageType * @param int $id * * @return array * array reference of all pcp if any */ public static function &pcPage($pageType = NULL, $id = NULL) { if (!isset(self::$pcPage[$pageType])) { if ($pageType) { $params = "page_type='{$pageType}'"; } else { $params = ''; } CRM_Core_PseudoConstant::populate(self::$pcPage[$pageType], 'CRM_PCP_DAO_PCP', FALSE, 'title', 'is_active', $params ); } $result = self::$pcPage[$pageType]; if ($id) { return $result = CRM_Utils_Array::value($id, $result); } return $result; } /** * Get all PCP Statuses. * * The static array pcpStatus is returned * * * @param string $column * @return array * array reference of all PCP activity statuses */ public static function &pcpStatus($column = 'label') { if (NULL === self::$pcpStatus) { self::$pcpStatus = array(); } if (!array_key_exists($column, self::$pcpStatus)) { self::$pcpStatus[$column] = array(); self::$pcpStatus[$column] = CRM_Core_OptionGroup::values('pcp_status', FALSE, FALSE, FALSE, NULL, $column ); } return self::$pcpStatus[$column]; } /** * Get financial account for a Financial type. * * * @param int $entityId * @param string $accountRelationType * @param string $entityTable * @param string $returnField * @return int */ public static function getRelationalFinancialAccount($entityId, $accountRelationType, $entityTable = 'civicrm_financial_type', $returnField = 'financial_account_id') { $params = array( 'return' => array($returnField), 'entity_table' => $entityTable, 'entity_id' => $entityId, ); if ($accountRelationType) { $params['account_relationship.name'] = $accountRelationType; } $result = civicrm_api3('EntityFinancialAccount', 'get', $params); if (!$result['count']) { return NULL; } return $result['values'][$result['id']][$returnField]; } /** * Get all batches. * * * @param int $id * @return array * array reference of all batches if any */ public static function &batch($id = NULL) { if (!self::$batch) { $orderBy = " id DESC "; CRM_Core_PseudoConstant::populate( self::$batch, 'CRM_Batch_DAO_Batch', TRUE, 'title', NULL, NULL, $orderBy ); } if ($id) { $result = CRM_Utils_Array::value($id, self::$batch); return $result; } return self::$batch; } }