本文整理汇总了PHP中CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus方法的具体用法?PHP CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus怎么用?PHP CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Financial_BAO_FinancialType
的用法示例。
在下文中一共展示了CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates a new entry in the database.
*
* @param array $params
* (reference) an assoc array of name/value pairs.
*
* @return CRM_Price_DAO_LineItem
*/
public static function create(&$params)
{
$id = CRM_Utils_Array::value('id', $params);
if ($id) {
CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params);
$op = CRM_Core_Action::UPDATE;
} else {
CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
$op = CRM_Core_Action::ADD;
}
// unset entity table and entity id in $params
// we never update the entity table and entity id during update mode
if ($id) {
unset($params['entity_id'], $params['entity_table']);
}
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && CRM_Utils_Array::value('check_permissions', $params)) {
if (empty($params['financial_type_id'])) {
throw new Exception('Mandatory key(s) missing from params array: financial_type_id');
}
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op);
if (!in_array($params['financial_type_id'], array_keys($types))) {
throw new Exception('You do not have permission to create this line item');
}
}
$lineItemBAO = new CRM_Price_BAO_LineItem();
$lineItemBAO->copyValues($params);
$return = $lineItemBAO->save();
if ($id) {
CRM_Utils_Hook::post('edit', 'LineItem', $id, $lineItemBAO);
} else {
CRM_Utils_Hook::post('create', 'LineItem', $lineItemBAO->id, $lineItemBAO);
}
return $return;
}
示例2: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$count = 0;
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
foreach ($this->_contributionIds as $key => $id) {
$finTypeID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $id, 'financial_type_id');
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($finTypeID))) {
unset($this->_contributionIds[$key]);
$count++;
}
// Now check for lineItems
if ($lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($id)) {
foreach ($lineItems as $items) {
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($this->_contributionIds[$key]);
$count++;
break;
}
}
}
}
}
if ($count && empty($this->_contributionIds)) {
CRM_Core_Session::setStatus(ts('1 contribution could not be deleted.', array('plural' => '%count contributions could not be deleted.', 'count' => $count)), ts('Error'), 'error');
$this->addButtons(array(array('type' => 'back', 'name' => ts('Cancel'))));
} elseif ($count && !empty($this->_contributionIds)) {
CRM_Core_Session::setStatus(ts('1 contribution will not be deleted.', array('plural' => '%count contributions will not be deleted.', 'count' => $count)), ts('Warning'), 'warning');
$this->addDefaultButtons(ts('Delete Contributions'), 'done');
} else {
$this->addDefaultButtons(ts('Delete Contributions'), 'done');
}
}
示例3: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
// Check permission for Financial Type when ACL-FT is enabled
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('administer CiviCRM Financial Types')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
parent::preProcess();
}
示例4: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return int
* the total number of rows for this action
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
if ($this->_includeSoftCredits) {
// especial sort order when rows include soft credits
$sort = $sort->orderBy() . ", civicrm_contribution.id, civicrm_contribution_soft.id";
}
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_contributionClause);
// process the result of the query
$rows = array();
//CRM-4418 check for view/edit/delete
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit contributions')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviContribute')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$qfKey = $this->_key;
$componentId = $componentContext = NULL;
if ($this->_context != 'contribute') {
// @todo explain the significance of context & why we do not get these i that context.
$qfKey = CRM_Utils_Request::retrieve('key', 'String', CRM_Core_DAO::$_nullObject);
$componentId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject);
$componentAction = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject);
$componentContext = CRM_Utils_Request::retrieve('compContext', 'String', CRM_Core_DAO::$_nullObject);
if (!$componentContext && $this->_compContext) {
// @todo explain when this condition might occur.
$componentContext = $this->_compContext;
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
// CRM-17628 for some reason qfKey is not always set when searching from contribution search.
// as a result if the edit link is opened using right-click + open in new tab
// then the browser is not returned to the search results on save.
// This is an effort to getting the qfKey without, sadly, understanding the intent of those who came before me.
if (empty($qfKey)) {
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
}
}
// get all contribution status
$contributionStatuses = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', FALSE);
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$links = self::links($componentId, $componentAction, $qfKey, $componentContext);
$checkLineItem = FALSE;
$row = array();
// Now check for lineItems
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
$lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($result->id);
foreach ($lineItems as $items) {
if (!CRM_Core_Permission::check('view contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
$checkLineItem = TRUE;
break;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
if ($checkLineItem) {
continue;
}
if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::UPDATE]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
unset($links[CRM_Core_Action::DELETE]);
}
}
// the columns we are interested in
foreach (self::$_properties as $property) {
if (property_exists($result, $property)) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
// @todo - I can't find any evidence that 'carrying' the campaign on selectors actually
// results in it being displayed anywhere so why do we do this???
$row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->contribution_campaign_id;
//.........这里部分代码省略.........
示例5: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = array();
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
// Make sure context is assigned to template for condition where we come here view civicrm/membership/view
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
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 permission to access this page.'));
}
} else {
$this->assign('noACL', TRUE);
}
$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
// Do the action on related Membership if needed
$relAction = CRM_Utils_Request::retrieve('relAction', 'String', $this);
if ($relAction) {
$this->relAction($relAction, $values);
}
// build associated contributions
$this->assign('accessContribution', FALSE);
if (CRM_Core_Permission::access('CiviContribute')) {
$this->assign('accessContribution', TRUE);
CRM_Member_Page_Tab::associatedContribution($values['contact_id'], $id);
}
//Provide information about membership source when it is the result of a relationship (CRM-1901)
$values['owner_membership_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $id, 'owner_membership_id');
if (isset($values['owner_membership_id'])) {
$values['owner_contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $values['owner_membership_id'], 'contact_id', 'id');
$values['owner_display_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['owner_contact_id'], 'display_name', 'id');
$direction = strrev($membershipType['relationship_direction']);
// To display relationship type in view membership page
$relTypeIds = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ",", $membershipType['relationship_type_id']);
$sql = "\nSELECT relationship_type_id,\n CASE\n WHEN contact_id_a = {$values['owner_contact_id']} AND contact_id_b = {$values['contact_id']} THEN 'b_a'\n WHEN contact_id_b = {$values['owner_contact_id']} AND contact_id_a = {$values['contact_id']} THEN 'a_b'\nEND AS 'relType'\n FROM civicrm_relationship\n WHERE relationship_type_id IN ({$relTypeIds})";
$dao = CRM_Core_DAO::executeQuery($sql);
$values['relationship'] = NULL;
while ($dao->fetch()) {
$typeId = $dao->relationship_type_id;
$direction = $dao->relType;
if ($direction && $typeId) {
if ($values['relationship']) {
$values['relationship'] .= ',';
}
$values['relationship'] .= CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $typeId, "name_{$direction}", 'id');
}
}
}
$this->assign('has_related', FALSE);
// if membership can be granted, and we are the owner of the membership
if (!empty($membershipType['relationship_type_id']) && empty($values['owner_membership_id'])) {
// display related contacts/membership block
$this->assign('has_related', TRUE);
$this->assign('max_related', CRM_Utils_Array::value('max_related', $values, ts('Unlimited')));
// split the relations in 2 arrays based on direction
$relTypeId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $membershipType['relationship_type_id']);
$relDirection = explode(CRM_Core_DAO::VALUE_SEPARATOR, $membershipType['relationship_direction']);
foreach ($relTypeId as $rid) {
$dir = each($relDirection);
$relTypeDir[substr($dir['value'], 0, 1)][] = $rid;
}
// build query in 2 parts with a UNION if necessary
// _x and _y are replaced with _a and _b first, then vice-versa
// comment is a qualifier for the relationship - now just job_title
$select = "\nSELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment,\n rt.name_x_y as relation, r.start_date, r.end_date,\n m.id as mid, ms.is_current_member, ms.label as status\n FROM civicrm_relationship r\n LEFT JOIN civicrm_relationship_type rt ON rt.id = r.relationship_type_id\n LEFT JOIN civicrm_contact c ON c.id = r.contact_id_x\n LEFT JOIN civicrm_membership m ON (m.owner_membership_id = {$values['id']}\n AND m.contact_id = r.contact_id_x AND m.is_test = 0)\n LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id\n WHERE r.contact_id_y = {$values['contact_id']} AND r.is_active = 1 AND c.is_deleted = 0";
$query = '';
foreach (array('a', 'b') as $dir) {
if (isset($relTypeDir[$dir])) {
$query .= ($query ? ' UNION ' : '') . str_replace('_y', '_' . $dir, str_replace('_x', '_' . ($dir == 'a' ? 'b' : 'a'), $select)) . ' AND r.relationship_type_id IN (' . implode(',', $relTypeDir[$dir]) . ')';
}
}
$query .= " ORDER BY is_current_member DESC";
$dao = CRM_Core_DAO::executeQuery($query);
$related = array();
$relatedRemaining = CRM_Utils_Array::value('max_related', $values, PHP_INT_MAX);
$rowElememts = array('id', 'cid', 'name', 'comment', 'relation', 'mid', 'start_date', 'end_date', 'is_current_member', 'status');
while ($dao->fetch()) {
$row = array();
foreach ($rowElememts as $field) {
$row[$field] = $dao->{$field};
}
if ($row['mid'] && $row['is_current_member'] == 1) {
$relatedRemaining--;
$row['action'] = CRM_Core_Action::formLink(self::links(), CRM_Core_Action::DELETE, array('id' => CRM_Utils_Request::retrieve('id', 'Positive', $this), 'cid' => $row['cid'], 'mid' => $row['mid']), ts('more'), FALSE, 'membership.relationship.action', 'Relationship', CRM_Utils_Request::retrieve('id', 'Positive', $this));
} else {
if ($relatedRemaining > 0) {
$row['action'] = CRM_Core_Action::formLink(self::links(), CRM_Core_Action::ADD, array('id' => CRM_Utils_Request::retrieve('id', 'Positive', $this), 'cid' => $row['cid'], 'rid' => $row['cid']), ts('more'), FALSE, 'membership.relationship.action', 'Relationship', CRM_Utils_Request::retrieve('id', 'Positive', $this));
}
}
$related[] = $row;
//.........这里部分代码省略.........
示例6: browse
/**
* Browse all financial types.
*/
public function browse()
{
// Check permission for Financial Type when ACL-FT is enabled
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('administer CiviCRM Financial Types')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
// get all financial types sorted by weight
$financialType = array();
$dao = new CRM_Financial_DAO_FinancialType();
$dao->orderBy('name');
$dao->find();
while ($dao->fetch()) {
$financialType[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]);
$defaults = $financialAccountId = array();
$financialAccounts = CRM_Contribute_PseudoConstant::financialAccount();
$financialAccountIds = array();
$params['entity_id'] = $dao->id;
$params['entity_table'] = 'civicrm_financial_type';
CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, CRM_Core_DAO::$_nullArray, $financialAccountIds);
foreach ($financialAccountIds as $key => $values) {
if (!empty($financialAccounts[$values['financial_account_id']])) {
$financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value($values['financial_account_id'], $financialAccounts);
}
}
if (!empty($financialAccountId)) {
$financialType[$dao->id]['financial_account'] = implode(',', $financialAccountId);
}
// form all action links
$action = array_sum(array_keys($this->links()));
// update enable/disable links depending on if it is is_reserved or is_active
if ($dao->is_reserved) {
$action -= CRM_Core_Action::ENABLE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
} else {
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
}
$financialType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'financialType.manage.action', 'FinancialType', $dao->id);
}
$this->assign('rows', $financialType);
}
示例7: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$this->addYesNo('is_monetary', ts('Paid Event'), NULL, NULL, array('onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);"));
//add currency element.
$this->addCurrency('currency', ts('Currency'), FALSE);
$paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor();
$this->assign('paymentProcessor', $paymentProcessor);
$this->addEntityRef('payment_processor', ts('Payment Processor'), array('entity' => 'PaymentProcessor', 'multiple' => TRUE, 'select' => array('minimumInputLength' => 0)));
// financial type
if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() || CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && CRM_Core_Permission::check('administer CiviCRM Financial Types')) {
$this->addSelect('financial_type_id');
} else {
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::ADD);
$this->addSelect('financial_type_id', array('context' => 'search', 'options' => $financialTypes));
}
// add pay later options
$this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL, array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);"));
$this->addElement('textarea', 'pay_later_text', ts('Pay Later Label'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_text'), FALSE);
$this->add('wysiwyg', 'pay_later_receipt', ts('Pay Later Instructions'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_receipt'));
$this->addElement('checkbox', 'is_billing_required', ts('Billing address required'));
$this->add('text', 'fee_label', ts('Fee Label'));
$price = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviEvent');
if (CRM_Utils_System::isNull($price)) {
$this->assign('price', FALSE);
} else {
$this->assign('price', TRUE);
}
$this->add('select', 'price_set_id', ts('Price Set'), array('' => ts('- none -')) + $price, NULL, array('onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);"));
$default = array($this->createElement('radio', NULL, NULL, NULL, 0));
$this->add('hidden', 'price_field_id', '', array('id' => 'price_field_id'));
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
// label
$this->add('text', "label[{$i}]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'));
$this->add('hidden', "price_field_value[{$i}]", '', array('id' => "price_field_value[{$i}]"));
// value
$this->add('text', "value[{$i}]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'));
$this->addRule("value[{$i}]", ts('Please enter a valid money value for this field (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
// default
$default[] = $this->createElement('radio', NULL, NULL, NULL, $i);
}
$this->addGroup($default, 'default');
$this->addElement('checkbox', 'is_discount', ts('Discounts by Signup Date?'), NULL, array('onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);"));
$discountSection = $this->get('discountSection');
$this->assign('discountSection', $discountSection);
// form fields of Discount sets
$defaultOption = array();
$_showHide = new CRM_Core_ShowHideBlocks('', '');
for ($i = 1; $i <= self::NUM_DISCOUNT; $i++) {
//the show hide blocks
$showBlocks = 'discount_' . $i;
if ($i > 2) {
$_showHide->addHide($showBlocks);
} else {
$_showHide->addShow($showBlocks);
}
//Increment by 1 of start date of previous end date.
if (is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i + 1]) && isset($this->_submitValues['discount_end_date']) && isset($this->_submitValues['discount_end_date'][$i]) && $i < self::NUM_DISCOUNT - 1) {
$end_date = CRM_Utils_Date::processDate($this->_submitValues['discount_end_date'][$i]);
if (!empty($this->_submitValues['discount_end_date'][$i + 1]) && empty($this->_submitValues['discount_start_date'][$i + 1])) {
list($this->_submitValues['discount_start_date'][$i + 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("+1 days {$end_date}")));
}
}
//Decrement by 1 of end date from next start date.
if ($i > 1 && is_array($this->_submitValues) && !empty($this->_submitValues['discount_name'][$i]) && !empty($this->_submitValues['discount_name'][$i - 1]) && isset($this->_submitValues['discount_start_date']) && isset($this->_submitValues['discount_start_date'][$i])) {
$start_date = CRM_Utils_Date::processDate($this->_submitValues['discount_start_date'][$i]);
if (!empty($this->_submitValues['discount_start_date'][$i]) && empty($this->_submitValues['discount_end_date'][$i - 1])) {
list($this->_submitValues['discount_end_date'][$i - 1]) = CRM_Utils_Date::setDateDefaults(date('Y-m-d', strtotime("-1 days {$start_date}")));
}
}
//discount name
$this->add('text', 'discount_name[' . $i . ']', ts('Discount Name'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceSet', 'title'));
$this->add('hidden', "discount_price_set[{$i}]", '', array('id' => "discount_price_set[{$i}]"));
//discount start date
$this->addDate('discount_start_date[' . $i . ']', ts('Discount Start Date'), FALSE, array('formatType' => 'activityDate'));
//discount end date
$this->addDate('discount_end_date[' . $i . ']', ts('Discount End Date'), FALSE, array('formatType' => 'activityDate'));
}
$_showHide->addToTemplate();
$this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'), array('class' => 'crm-form-submit cancel'));
$this->buildAmountLabel();
parent::buildQuickForm();
}
示例8: supportsFinancialTypeChange
/**
* Does the recurring contribution support financial type change.
*
* This is conditional on there being only one line item or if there are no contributions as yet.
*
* (This second is a bit of an unusual condition but might occur in the context of a
*
* @param int $id
*
* @return bool
*/
public static function supportsFinancialTypeChange($id)
{
// At this stage only sites with no Financial ACLs will have the opportunity to edit the financial type.
// this is to limit the scope of the change and because financial ACLs are still fairly new & settling down.
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
return FALSE;
}
$contribution = self::getTemplateContribution($id);
return CRM_Contribute_BAO_Contribution::isSingleLineItem($contribution['id']);
}
示例9: preProcess
/**
* Set variables up before form is built.
*
* @throws \CRM_Contribute_Exception_InactiveContributionPageException
* @throws \Exception
*/
public function preProcess()
{
// current contribution page id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (!$this->_id) {
// seems like the session is corrupted and/or we lost the id trail
// lets just bump this to a regular session error and redirect user to main page
$this->controller->invalidKeyRedirect();
}
// this was used prior to the cleverer this_>getContactID - unsure now
$this->_userID = CRM_Core_Session::singleton()->get('userID');
$this->_contactID = $this->_membershipContactID = $this->getContactID();
$this->_mid = NULL;
if ($this->_contactID) {
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
if ($this->_mid) {
$membership = new CRM_Member_DAO_Membership();
$membership->id = $this->_mid;
if ($membership->find(TRUE)) {
$this->_defaultMemTypeId = $membership->membership_type_id;
if ($membership->contact_id != $this->_contactID) {
$validMembership = FALSE;
$organizations = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, NULL, NULL, 'Organization');
if (!empty($organizations) && array_key_exists($membership->contact_id, $organizations)) {
$this->_membershipContactID = $membership->contact_id;
$this->assign('membershipContactID', $this->_membershipContactID);
$this->assign('membershipContactName', $organizations[$this->_membershipContactID]['name']);
$validMembership = TRUE;
} else {
$membershipType = new CRM_Member_BAO_MembershipType();
$membershipType->id = $membership->membership_type_id;
if ($membershipType->find(TRUE)) {
// CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
// Convert to comma separated list.
$inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
$permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
if (array_key_exists($membership->contact_id, $permContacts)) {
$this->_membershipContactID = $membership->contact_id;
$validMembership = TRUE;
}
}
}
if (!$validMembership) {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
}
}
} else {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
}
unset($membership);
}
}
// we do not want to display recently viewed items, so turn off
$this->assign('displayRecent', FALSE);
// Contribution page values are cleared from session, so can't use normal Printer Friendly view.
// Use Browser Print instead.
$this->assign('browserPrint', TRUE);
// action
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
$this->assign('action', $this->_action);
// current mode
$this->_mode = $this->_action == 1024 ? 'test' : 'live';
$this->_values = $this->get('values');
$this->_fields = $this->get('fields');
$this->_bltID = $this->get('bltID');
$this->_paymentProcessor = $this->get('paymentProcessor');
$this->_priceSetId = $this->get('priceSetId');
$this->_priceSet = $this->get('priceSet');
if (!$this->_values) {
// get all the values from the dao object
$this->_values = array();
$this->_fields = array();
CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($this->_values['financial_type_id']))) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
if (empty($this->_values['is_active'])) {
throw new CRM_Contribute_Exception_InactiveContributionPageException(ts('The page you requested is currently unavailable.'), $this->_id);
}
$this->assignBillingType();
// check for is_monetary status
$isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
$isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
if ($isMonetary && (!$isPayLater || !empty($this->_values['payment_processor']))) {
$this->_paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values));
$this->assignPaymentProcessor();
}
// get price info
// CRM-5095
CRM_Price_BAO_PriceSet::initSet($this, $this->_id, 'civicrm_contribution_page');
// this avoids getting E_NOTICE errors in php
$setNullFields = array('amount_block_is_active', 'is_allow_other_amount', 'footer_text');
foreach ($setNullFields as $f) {
if (!isset($this->_values[$f])) {
//.........这里部分代码省略.........
示例10: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
// add a hidden field to remember the price set id
// this get around the browser tab issue
$this->add('hidden', 'sid', $this->_sid);
$this->add('hidden', 'fid', $this->_fid);
// label
$this->add('text', 'label', ts('Field Label'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'label'), TRUE);
// html_type
$javascript = 'onchange="option_html_type(this.form)";';
$htmlTypes = CRM_Price_BAO_PriceField::htmlTypes();
// Text box for Participant Count for a field
// Financial Type
$financialType = CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
foreach ($financialType as $finTypeId => $type) {
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . $type)) {
unset($financialType[$finTypeId]);
}
}
if (count($financialType)) {
$this->assign('financialType', $financialType);
}
$enabledComponents = CRM_Core_Component::getEnabledComponents();
$eventComponentId = $memberComponentId = NULL;
if (array_key_exists('CiviEvent', $enabledComponents)) {
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
}
if (array_key_exists('CiviMember', $enabledComponents)) {
$memberComponentId = CRM_Core_Component::getComponentID('CiviMember');
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceFieldValue');
$this->add('select', 'financial_type_id', ts('Financial Type'), array(' ' => ts('- select -')) + $financialType);
$this->assign('useForMember', FALSE);
if (in_array($eventComponentId, $this->_extendComponentId)) {
$this->add('text', 'count', ts('Participant Count'), $attributes['count']);
$this->addRule('count', ts('Participant Count should be a positive number'), 'positiveInteger');
$this->add('text', 'max_value', ts('Max Participants'), $attributes['max_value']);
$this->addRule('max_value', ts('Please enter a valid Max Participants.'), 'positiveInteger');
$this->assign('useForEvent', TRUE);
} else {
if (in_array($memberComponentId, $this->_extendComponentId)) {
$this->_useForMember = 1;
$this->assign('useForMember', $this->_useForMember);
}
$this->assign('useForEvent', FALSE);
}
$sel = $this->add('select', 'html_type', ts('Input Field Type'), $htmlTypes, TRUE, $javascript);
// price (for text inputs)
$this->add('text', 'price', ts('Price'));
$this->registerRule('price', 'callback', 'money', 'CRM_Utils_Rule');
$this->addRule('price', ts('must be a monetary value'), 'money');
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->freeze('html_type');
}
// form fields of Custom Option rows
$_showHide = new CRM_Core_ShowHideBlocks('', '');
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
//the show hide blocks
$showBlocks = 'optionField_' . $i;
if ($i > 2) {
$_showHide->addHide($showBlocks);
if ($i == self::NUM_OPTION) {
$_showHide->addHide('additionalOption');
}
} else {
$_showHide->addShow($showBlocks);
}
// label
$attributes['label']['size'] = 25;
$this->add('text', 'option_label[' . $i . ']', ts('Label'), $attributes['label']);
// amount
$this->add('text', 'option_amount[' . $i . ']', ts('Amount'), $attributes['amount']);
$this->addRule('option_amount[' . $i . ']', ts('Please enter a valid amount for this field.'), 'money');
//Financial Type
$this->add('select', 'option_financial_type_id[' . $i . ']', ts('Financial Type'), array('' => ts('- select -')) + $financialType);
if (in_array($eventComponentId, $this->_extendComponentId)) {
// count
$this->add('text', 'option_count[' . $i . ']', ts('Participant Count'), $attributes['count']);
$this->addRule('option_count[' . $i . ']', ts('Please enter a valid Participants Count.'), 'positiveInteger');
// max_value
$this->add('text', 'option_max_value[' . $i . ']', ts('Max Participants'), $attributes['max_value']);
$this->addRule('option_max_value[' . $i . ']', ts('Please enter a valid Max Participants.'), 'positiveInteger');
// description
//$this->add('textArea', 'option_description['.$i.']', ts('Description'), array('rows' => 1, 'cols' => 40 ));
} elseif (in_array($memberComponentId, $this->_extendComponentId)) {
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$js = array('onchange' => "calculateRowValues( {$i} );");
$this->add('select', 'membership_type_id[' . $i . ']', ts('Membership Type'), array('' => ' ') + $membershipTypes, FALSE, $js);
$this->add('text', 'membership_num_terms[' . $i . ']', ts('Number of Terms'), CRM_Utils_Array::value('membership_num_terms', $attributes));
}
// weight
$this->add('text', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
// is active ?
$this->add('checkbox', 'option_status[' . $i . ']', ts('Active?'));
$defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
//.........这里部分代码省略.........
示例11: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
// current contribution page id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'REQUEST');
$this->assign('contributionPageID', $this->_id);
// get the requested action
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
// setting title and 3rd level breadcrumb for html page if contrib page exists
if ($this->_id) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->_single = TRUE;
}
}
// CRM-16776 - show edit/copy/create buttons on Profiles Tab if user has required permission.
if (CRM_Core_Permission::check('administer CiviCRM')) {
$this->assign('perm', TRUE);
}
// set up tabs
CRM_Contribute_Form_ContributionPage_TabHeader::build($this);
if ($this->_action == CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Configure Page - %1', array(1 => $title)));
} elseif ($this->_action == CRM_Core_Action::VIEW) {
CRM_Utils_System::setTitle(ts('Preview Page - %1', array(1 => $title)));
} elseif ($this->_action == CRM_Core_Action::DELETE) {
CRM_Utils_System::setTitle(ts('Delete Page - %1', array(1 => $title)));
}
//cache values.
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if (isset($this->_id) && $this->_id) {
$params = array('id' => $this->_id);
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values);
CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
}
$this->set('values', $this->_values);
}
// Check permission to edit contribution page
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && $this->_action & CRM_Core_Action::UPDATE) {
$financialTypeID = CRM_Contribute_PseudoConstant::financialType($this->_values['financial_type_id']);
if (!CRM_Core_Permission::check('edit contributions of type ' . $financialTypeID)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
}
// Preload libraries required by the "Profiles" tab
$schemas = array('IndividualModel', 'OrganizationModel', 'ContributionModel');
if (in_array('CiviMember', CRM_Core_Config::singleton()->enableComponents)) {
$schemas[] = 'MembershipModel';
}
CRM_UF_Page_ProfileEditor::registerProfileScripts();
CRM_UF_Page_ProfileEditor::registerSchemas($schemas);
}
示例12: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
$this->assign('currency', CRM_Core_Config::singleton()->defaultCurrencySymbol);
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
if (isset($invoicing)) {
$this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
}
// build price set form.
$buildPriceSet = FALSE;
if ($this->_priceSetId || !empty($_POST['price_set_id'])) {
if (!empty($_POST['price_set_id'])) {
$buildPriceSet = TRUE;
}
$getOnlyPriceSetElements = TRUE;
if (!$this->_priceSetId) {
$this->_priceSetId = $_POST['price_set_id'];
$getOnlyPriceSetElements = FALSE;
}
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_PriceSet::buildPriceSet($this);
$optionsMembershipTypes = array();
foreach ($this->_priceSet['fields'] as $pField) {
if (empty($pField['options'])) {
continue;
}
foreach ($pField['options'] as $opId => $opValues) {
$optionsMembershipTypes[$opId] = CRM_Utils_Array::value('membership_type_id', $opValues, 0);
}
}
$this->assign('autoRenewOption', CRM_Price_BAO_PriceSet::checkAutoRenewForPriceSet($this->_priceSetId));
$this->assign('optionsMembershipTypes', $optionsMembershipTypes);
$this->assign('contributionType', CRM_Utils_Array::value('financial_type_id', $this->_priceSet));
// get only price set form elements.
if ($getOnlyPriceSetElements) {
return;
}
}
// use to build form during form rule.
$this->assign('buildPriceSet', $buildPriceSet);
if ($this->_action & CRM_Core_Action::ADD) {
$buildPriceSet = FALSE;
$priceSets = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviMember');
if (!empty($priceSets)) {
$buildPriceSet = TRUE;
}
if ($buildPriceSet) {
$this->add('select', 'price_set_id', ts('Choose price set'), array('' => ts('Choose price set')) + $priceSets, NULL, array('onchange' => "buildAmount( this.value );"));
}
$this->assign('hasPriceSets', $buildPriceSet);
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Membership');
$this->assign('customDataSubType', $this->_memType);
$this->assign('entityID', $this->_id);
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_context == 'standalone') {
$this->addEntityRef('contact_id', ts('Contact'), array('create' => TRUE, 'api' => array('extra' => array('email'))), TRUE);
}
$selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -');
// Throw status bounce when no Membership type or priceset is present
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && empty($this->allMembershipTypeDetails) && empty($priceSets)) {
CRM_Core_Error::statusBounce(ts('You do not have all the permissions needed for this page.'));
}
// retrieve all memberships
$allMembershipInfo = array();
foreach ($this->allMembershipTypeDetails as $key => $values) {
if ($this->_mode && empty($values['minimum_fee'])) {
continue;
} else {
$memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values);
if (empty($selMemTypeOrg[$memberOfContactId])) {
$selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, 'display_name', 'id');
$selOrgMemType[$memberOfContactId][0] = ts('- select -');
}
if (empty($selOrgMemType[$memberOfContactId][$key])) {
$selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values);
}
}
$totalAmount = CRM_Utils_Array::value('minimum_fee', $values);
//CRM-18827 - override the default value if total_amount is submitted
if (!empty($this->_submitValues['total_amount'])) {
$totalAmount = $this->_submitValues['total_amount'];
}
// build membership info array, which is used when membership type is selected to:
// - set the payment information block
// - set the max related block
$allMembershipInfo[$key] = array('financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'), 'total_amount_numeric' => $totalAmount, 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values), 'has_related' => isset($values['relationship_type_id']), 'max_related' => CRM_Utils_Array::value('max_related', $values));
}
$this->assign('allMembershipInfo', json_encode($allMembershipInfo));
// show organization by default, if only one organization in
// the list
if (count($selMemTypeOrg) == 2) {
//.........这里部分代码省略.........
示例13: getPermissionedLinks
/**
* Get a list of links based on permissioned FTs.
*
* @param int $memTypeID
* membership type ID
* @param int $links
* (reference ) action links
*/
public static function getPermissionedLinks($memTypeID, &$links)
{
if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
return FALSE;
}
$finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memTypeID, 'financial_type_id');
$finType = CRM_Contribute_PseudoConstant::financialType($finTypeId);
if (!CRM_Core_Permission::check('edit contributions of type ' . $finType)) {
unset($links[CRM_Core_Action::UPDATE]);
unset($links[CRM_Core_Action::RENEW]);
unset($links[CRM_Core_Action::FOLLOWUP]);
}
if (!CRM_Core_Permission::check('delete contributions of type ' . $finType)) {
unset($links[CRM_Core_Action::DELETE]);
}
}
示例14: buildPriceSet
/**
* Build the price set form.
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildPriceSet(&$form)
{
$priceSetId = $form->get('priceSetId');
if (!$priceSetId) {
return;
}
$validFieldsOnly = TRUE;
$className = CRM_Utils_System::getClassName($form);
if (in_array($className, array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'))) {
$validFieldsOnly = FALSE;
}
$priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
$form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
$validPriceFieldIds = array_keys($form->_priceSet['fields']);
$form->_quickConfig = $quickConfig = 0;
if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) {
$quickConfig = 1;
}
$form->assign('quickConfig', $quickConfig);
if ($className == 'CRM_Contribute_Form_Contribution_Main') {
$form->_quickConfig = $quickConfig;
}
// Mark which field should have the auto-renew checkbox, if any. CRM-18305
if (!empty($form->_membershipTypeValues) && is_array($form->_membershipTypeValues)) {
$autoRenewMembershipTypes = array();
foreach ($form->_membershipTypeValues as $membershiptTypeValue) {
if ($membershiptTypeValue['auto_renew']) {
$autoRenewMembershipTypes[] = $membershiptTypeValue['id'];
}
}
foreach ($form->_priceSet['fields'] as &$field) {
if (array_key_exists('options', $field) && is_array($field['options'])) {
foreach ($field['options'] as $option) {
if (!empty($option['membership_type_id'])) {
if (in_array($option['membership_type_id'], $autoRenewMembershipTypes)) {
$form->_priceSet['auto_renew_membership_field'] = $field['id'];
// Only one field can offer auto_renew memberships, so break here.
break;
}
}
}
}
}
}
$form->assign('priceSet', $form->_priceSet);
$component = 'contribution';
if ($className == 'CRM_Member_Form_Membership') {
$component = 'membership';
}
if ($className == 'CRM_Contribute_Form_Contribution_Main') {
$feeBlock =& $form->_values['fee'];
if (!empty($form->_useForMember)) {
$component = 'membership';
}
} else {
$feeBlock =& $form->_priceSet['fields'];
}
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
foreach ($feeBlock as $key => $value) {
foreach ($value['options'] as $k => $options) {
if (!CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($options['financial_type_id']))) {
unset($feeBlock[$key]['options'][$k]);
}
}
if (empty($feeBlock[$key]['options'])) {
unset($feeBlock[$key]);
}
}
}
// call the hook.
CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
// CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
$adminFieldVisible = FALSE;
if (CRM_Core_Permission::check('administer CiviCRM')) {
$adminFieldVisible = TRUE;
}
foreach ($feeBlock as $id => $field) {
if (CRM_Utils_Array::value('visibility', $field) == 'public' || CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE || !$validFieldsOnly) {
$options = CRM_Utils_Array::value('options', $field);
if ($className == 'CRM_Contribute_Form_Contribution_Main' && ($component = 'membership')) {
$userid = $form->getVar('_membershipContactID');
$checklifetime = self::checkCurrentMembership($options, $userid);
if ($checklifetime) {
$form->assign('ispricelifetime', TRUE);
}
}
if (!is_array($options) || !in_array($id, $validPriceFieldIds)) {
continue;
}
CRM_Price_BAO_PriceField::addQuickFormElement($form, 'price_' . $field['id'], $field['id'], FALSE, CRM_Utils_Array::value('is_required', $field, FALSE), NULL, $options);
}
}
}
示例15: browse
/**
* Browse all membership types.
*
*
* @return void
*/
public function browse()
{
// get all membership types sorted by weight
$membershipType = array();
$dao = new CRM_Member_DAO_MembershipType();
$dao->orderBy('weight');
$dao->find();
while ($dao->fetch()) {
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('view contributions of type ' . CRM_Contribute_PseudoConstant::financialType($dao->financial_type_id))) {
continue;
}
$links = self::links();
$membershipType[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $membershipType[$dao->id]);
$membershipType[$dao->id]['period_type'] = CRM_Utils_Array::value($dao->period_type, CRM_Core_SelectValues::periodType(), '');
$membershipType[$dao->id]['visibility'] = CRM_Utils_Array::value($dao->visibility, CRM_Core_SelectValues::memberVisibility(), '');
//adding column for relationship type label. CRM-4178.
if ($dao->relationship_type_id) {
//If membership associated with 2 or more relationship then display all relationship with comma separated
$relTypeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->relationship_type_id);
$relTypeNames = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->relationship_direction);
$membershipType[$dao->id]['relationshipTypeName'] = NULL;
foreach ($relTypeIds as $key => $value) {
$relationshipName = 'label_' . $relTypeNames[$key];
if ($membershipType[$dao->id]['relationshipTypeName']) {
$membershipType[$dao->id]['relationshipTypeName'] .= ", ";
}
$membershipType[$dao->id]['relationshipTypeName'] .= CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $value, $relationshipName);
}
$membershipType[$dao->id]['maxRelated'] = CRM_Utils_Array::value('max_related', $membershipType[$dao->id]);
}
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($dao->financial_type_id))) {
unset($links[CRM_Core_Action::UPDATE], $links[CRM_Core_Action::ENABLE], $links[CRM_Core_Action::DISABLE]);
}
if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($dao->financial_type_id))) {
unset($links[CRM_Core_Action::DELETE]);
}
// form all action links
$action = array_sum(array_keys($this->links()));
// update enable/disable links depending on if it is is_reserved or is_active
if (!isset($dao->is_reserved)) {
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$membershipType[$dao->id]['order'] = $membershipType[$dao->id]['weight'];
$membershipType[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id), ts('more'), FALSE, 'membershipType.manage.action', 'MembershipType', $dao->id);
}
}
$returnURL = CRM_Utils_System::url('civicrm/admin/member/membershipType', "reset=1&action=browse");
CRM_Utils_Weight::addOrder($membershipType, 'CRM_Member_DAO_MembershipType', 'id', $returnURL);
CRM_Member_BAO_MembershipType::convertDayFormat($membershipType);
$this->assign('rows', $membershipType);
}