本文整理汇总了PHP中CRM_Core_Component::getComponentID方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Component::getComponentID方法的具体用法?PHP CRM_Core_Component::getComponentID怎么用?PHP CRM_Core_Component::getComponentID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Component
的用法示例。
在下文中一共展示了CRM_Core_Component::getComponentID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCreditCardFields
/**
* create all fields needed for a credit card transaction
*
* @return void
* @access public
*/
function setCreditCardFields(&$form)
{
CRM_Core_Payment_Form::_setPaymentFields($form);
$form->_paymentFields['credit_card_number'] = array('htmlType' => 'text', 'name' => 'credit_card_number', 'title' => ts('Card Number'), 'cc_field' => TRUE, 'attributes' => array('size' => 20, 'maxlength' => 20, 'autocomplete' => 'off'), 'is_required' => TRUE);
$form->_paymentFields['cvv2'] = array('htmlType' => 'text', 'name' => 'cvv2', 'title' => ts('Security Code'), 'cc_field' => TRUE, 'attributes' => array('size' => 5, 'maxlength' => 10, 'autocomplete' => 'off'), 'is_required' => CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'cvv_backoffice_required', CRM_Core_Component::getComponentID('CiviContribute'), 1));
$form->_paymentFields['credit_card_exp_date'] = array('htmlType' => 'date', 'name' => 'credit_card_exp_date', 'title' => ts('Expiration Date'), 'cc_field' => TRUE, 'attributes' => CRM_Core_SelectValues::date('creditCard'), 'is_required' => TRUE);
$creditCardType = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::creditCard();
$form->_paymentFields['credit_card_type'] = array('htmlType' => 'select', 'name' => 'credit_card_type', 'title' => ts('Card Type'), 'cc_field' => TRUE, 'attributes' => $creditCardType, 'is_required' => TRUE);
}
示例2: asort
/**
* DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
* Get all the survey activity types
*
*
* @param string $returnColumn
*
* @return array
* array reference of all survey activity types.
*/
public static function &activityType($returnColumn = 'name')
{
$cacheKey = $returnColumn;
if (!isset(self::$activityType[$cacheKey])) {
$campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
if ($campaingCompId) {
self::$activityType[$cacheKey] = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, " AND v.component_id={$campaingCompId}", $returnColumn);
}
}
asort(self::$activityType[$cacheKey]);
return self::$activityType[$cacheKey];
}
示例3:
/**
* Get all the survey activity types
*
* @access public
* @return array - array reference of all survey activity types.
* @static
*/
public static function &activityType($returnColumn = 'name')
{
$cacheKey = $returnColumn;
if (!isset(self::$activityType[$cacheKey])) {
require_once 'CRM/Core/OptionGroup.php';
$campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
if ($campaingCompId) {
self::$activityType[$cacheKey] = CRM_Core_OptionGroup::values('activity_type', false, false, false, " AND v.component_id={$campaingCompId}", $returnColumn);
}
}
return self::$activityType[$cacheKey];
}
示例4: formRule
/**
* Global form rule.
*
* @param array $fields
* The input form values.
* @param array $files
* The uploaded files if any.
* @param array $options
* Additional user data.
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $options)
{
$errors = array();
$count = count(CRM_Utils_Array::value('extends', $fields));
//price sets configured for membership
if ($count && array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $fields['extends'])) {
if ($count > 1) {
$errors['extends'] = ts('If you plan on using this price set for membership signup and renewal, you can not also use it for Events or Contributions. However, a membership price set may include additional fields for non-membership options that require an additional fee (e.g. magazine subscription).');
}
}
//checks the given price set doesnot start with digit
$title = $fields['title'];
// gives the ascii value
$asciiValue = ord($title[0]);
if ($asciiValue >= 48 && $asciiValue <= 57) {
$errors['title'] = ts("Name cannot not start with a digit");
}
return empty($errors) ? TRUE : $errors;
}
示例5: buildQuickForm
/**
* Function to actually build the form
*
* @param null
*
* @return void
* @access public
*/
public function buildQuickForm()
{
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
// label
$this->add('text', 'label', ts('Field Label'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Field', 'label'), true);
// html_type
$javascript = 'onchange="option_html_type(this.form)";';
require_once 'CRM/Price/BAO/Field.php';
$htmlTypes = CRM_Price_BAO_Field::htmlTypes();
$sel = $this->add('select', 'html_type', ts('Input Field Type'), $htmlTypes, true, $javascript);
// Text box for Participant Count for a field
require_once 'CRM/Core/Component.php';
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
$attributes = CRM_Core_DAO::getAttribute('CRM_Price_DAO_FieldValue');
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->add('textArea', 'description', ts('Description'), $attributes['description']);
$this->assign('useForEvent', true);
} else {
$this->assign('useForEvent', false);
}
// 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');
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));
}
// 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);
//for checkbox handling of default option
$this->add('checkbox', "default_checkbox_option[{$i}]", null);
}
//default option selection
$this->addGroup($defaultOption, 'default_option');
$_showHide->addToTemplate();
// is_display_amounts
$this->add('checkbox', 'is_display_amounts', ts('Display Amount?'));
// weight
$this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Field', 'weight'), true);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// checkbox / radio options per line
$this->add('text', 'options_per_line', ts('Options Per Line'));
$this->addRule('options_per_line', ts('must be a numeric value'), 'numeric');
// help post, mask, attributes, javascript ?
$this->add('textarea', 'help_post', ts('Field Help'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Field', 'help_post'));
// active_on
$date_options = array('minYear' => date('Y'), 'maxYear' => date('Y') + 5, 'addEmptyOption' => true);
$this->add('date', 'active_on', ts('Active On'), $date_options);
// expire_on
$this->add('date', 'expire_on', ts('Expire On'), $date_options);
// is required ?
$this->add('checkbox', 'is_required', ts('Required?'));
// is active ?
$this->add('checkbox', 'is_active', ts('Active?'));
// add buttons
//.........这里部分代码省略.........
示例6: simpledonate_civicrm_pageRun
function simpledonate_civicrm_pageRun(&$page)
{
$pageName = $page->getVar('_name');
if ($pageName == 'Civi\\Angular\\Page\\Main' && $page->urlPath[1] == 'simple') {
//Get all contribution page detils and session details to be used in js
$settingVal = simpledonate_getSimpleDonateSetting();
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if ($settingVal['donatePageID']) {
$extends = CRM_Core_Component::getComponentID('CiviContribute');
$priceSetID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $settingVal['donatePageID'], $extends);
$priceField = civicrm_api3('PriceField', 'get', array("price_set_id" => $priceSetID));
//Check for is_quick_config
$isQuickConfig = civicrm_api3('PriceSet', 'getvalue', array('id' => $priceSetID, 'return' => "is_quick_config"));
//Check for Other amount
$otherAmount = FALSE;
foreach ($priceField['values'] as $key => $value) {
if ($value['name'] == 'other_amount') {
$otherAmount = TRUE;
} else {
$priceFieldVal = civicrm_api3('PriceFieldValue', 'get', array('return' => "amount, title, name, is_default", "price_field_id" => $value['id']));
$priceList = $priceFieldVal['values'];
$htmlPriceList[$value['html_type']] = $priceFieldVal['values'];
}
}
//Get donation page details
$donateConfig = $donatePage = civicrm_api3('ContributionPage', 'getsingle', array('id' => $settingVal['donatePageID']));
CRM_Utils_System::setTitle($donateConfig['title']);
// Set the page title
$currencySymbol = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency', $donatePage['currency'], 'symbol', 'name');
$test = !empty($_GET['test']) ? 'test' : 'live';
// Check for test or live donation
//Get payment processor details
if (is_array($donatePage['payment_processor'])) {
$paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPayments($donatePage['payment_processor'], $test);
} else {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($donatePage['payment_processor'], $test);
$paymentProcessors[$paymentProcessor['id']] = $paymentProcessor;
$paymentProcessors[$paymentProcessor['id']]['hide'] = $donateConfig['is_pay_later'] ? FALSE : TRUE;
}
//set Country and State value
$config = CRM_Core_Config::singleton();
$defaultContactCountry = $config->defaultContactCountry;
$stateProvince = array_flip(CRM_Core_PseudoConstant::stateProvinceForCountry($defaultContactCountry));
$countryList = CRM_Core_PseudoConstant::country();
$stateList = array();
foreach ($countryList as $key => $val) {
$stateList[$key] = CRM_Core_PseudoConstant::stateProvinceForCountry($key);
}
CRM_Core_Resources::singleton()->addSetting(array('simpledonate' => array('sessionContact' => $contactID, 'priceSetID' => $priceSetID, 'ziptasticEnable' => $settingVal['ziptasticEnable'], 'countryList' => CRM_Core_PseudoConstant::country(), 'stateList' => $stateList, 'country' => $defaultContactCountry, 'allStates' => $stateProvince, 'currency' => $currencySymbol, 'config' => $donateConfig, 'paymentProcessor' => $paymentProcessors, 'priceList' => $priceList, 'otherAmount' => $otherAmount, 'isTest' => $test == 'test' ? 1 : 0, 'htmlPriceList' => $htmlPriceList, 'isQuickConfig' => $isQuickConfig)));
//Include bootstrap and custom css files to affect this angular page only
CRM_Core_Resources::singleton()->addStyleFile('com.webaccessglobal.simpledonate', 'css/bootstrap.min.css', 103, 'page-header');
CRM_Core_Resources::singleton()->addStyleFile('com.webaccessglobal.simpledonate', 'css/simpledonate.css', 100, 'page-body');
}
if ($contactID) {
$id = array('id' => $contactID);
$result = civicrm_api3('Contact', 'getSingle', $id);
CRM_Core_Resources::singleton()->addSetting(array('simpledonateVal' => $result));
}
}
}
示例7: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
$config = CRM_Core_Config::singleton();
if ($this->_values['is_for_organization'] == 2) {
$this->assign('onBehalfRequired', true);
}
if ($this->_onbehalf) {
$this->assign('onbehalf', true);
return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), true);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
//build pledge block.
$this->_useForMember = 0;
//don't build membership block when pledge_id is passed
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->_separateMembershipPayment = false;
if (in_array('CiviMember', $config->enableComponents)) {
$isTest = 0;
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = 1;
}
if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
$this->_useForMember = 1;
$this->set('useForMember', $this->_useForMember);
}
require_once 'CRM/Member/BAO/Membership.php';
$this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, true, null, false, $isTest, $this->_membershipContactID);
}
$this->set('separateMembershipPayment', $this->_separateMembershipPayment);
}
$this->assign('useForMember', $this->_useForMember);
// If we configured price set for contribution page
// we are not allow membership signup as well as any
// other contribution amount field, CRM-5095
if (isset($this->_priceSetId) && $this->_priceSetId) {
$this->add('hidden', 'priceSetId', $this->_priceSetId);
// build price set form.
$this->set('priceSetId', $this->_priceSetId);
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::buildPriceSet($this);
} else {
if (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->buildAmount($this->_separateMembershipPayment);
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && $this->_paymentProcessor['is_recur']) {
self::buildRecur($this);
}
}
}
if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
$this->buildPayLater();
}
if ($this->_values['is_for_organization']) {
$this->buildOnBehalfOrganization();
}
//we allow premium for pledge during pledge creation only.
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
require_once 'CRM/Contribute/BAO/Premium.php';
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, true);
}
if ($this->_values['honor_block_is_active']) {
$this->buildHonorBlock();
}
//don't build pledge block when mid is passed
if (!$this->_mid) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
require_once 'CRM/Pledge/BAO/PledgeBlock.php';
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
}
$this->buildCustom($this->_values['custom_pre_id'], 'customPre');
$this->buildCustom($this->_values['custom_post_id'], 'customPost');
// doing this later since the express button type depends if there is an upload or not
if ($this->_values['is_monetary']) {
require_once 'CRM/Core/Payment/Form.php';
if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
CRM_Core_Payment_Form::buildDirectDebit($this);
} else {
CRM_Core_Payment_Form::buildCreditCard($this);
}
}
//to create an cms user
if (!$this->_userID) {
$createCMSUser = false;
if ($this->_values['custom_pre_id']) {
$profileID = $this->_values['custom_pre_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
if (!$createCMSUser && $this->_values['custom_post_id']) {
$profileID = $this->_values['custom_post_id'];
$createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
}
//.........这里部分代码省略.........
示例8: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
if ($this->_action == CRM_Core_Action::UPDATE) {
$finTypeId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_oid, 'financial_type_id');
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::UPDATE);
if (!array_key_exists($finTypeId, $financialTypes)) {
CRM_Core_Error::fatal(ts("You do not have permission to access this page"));
}
}
if ($this->_action == CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete')), array('type' => 'cancel', 'name' => ts('Cancel'))));
return NULL;
} else {
$attributes = CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceFieldValue');
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
// hidden Option Id for validation use
$this->add('hidden', 'optionId', $this->_oid);
// Needed for i18n dialog
$this->assign('optionId', $this->_oid);
//hidden field ID for validation use
$this->add('hidden', 'fieldId', $this->_fid);
// label
$this->add('text', 'label', ts('Option Label'), NULL, TRUE);
$memberComponentId = CRM_Core_Component::getComponentID('CiviMember');
if ($this->_action == CRM_Core_Action::UPDATE) {
$this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
} elseif ($this->_action == CRM_Core_Action::ADD || $this->_action == CRM_Core_Action::VIEW) {
$this->_sid = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'price_set_id', 'id');
}
$this->isEvent = FALSE;
$extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id');
$this->assign('showMember', FALSE);
if ($memberComponentId == $extendComponentId) {
$this->assign('showMember', TRUE);
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$this->add('select', 'membership_type_id', ts('Membership Type'), array('' => ' ') + $membershipTypes, FALSE, array('onClick' => "calculateRowValues( );"));
$this->add('text', 'membership_num_terms', ts('Number of Terms'), $attributes['membership_num_terms']);
} else {
$allComponents = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId);
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
if (in_array($eventComponentId, $allComponents)) {
$this->isEvent = TRUE;
// count
$this->add('text', 'count', ts('Participant Count'));
$this->addRule('count', ts('Please enter a valid Max Participants.'), 'positiveInteger');
$this->add('text', 'max_value', ts('Max Participants'));
$this->addRule('max_value', ts('Please enter a valid Max Participants.'), 'positiveInteger');
}
}
//Financial Type
$financialType = CRM_Financial_BAO_FinancialType::getIncomeFinancialType();
if (count($financialType)) {
$this->assign('financialType', $financialType);
}
$this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialType, TRUE);
//CRM_Core_DAO::getFieldValue( 'CRM_Price_DAO_PriceField', $this->_fid, 'weight', 'id' );
// FIX ME: duplicate rule?
/*
$this->addRule( 'label',
ts('Duplicate option label.'),
'optionExists',
array( 'CRM_Core_DAO_OptionValue', $this->_oid, $this->_ogId, 'label' ) );
*/
// value
$this->add('text', 'amount', ts('Option Amount'), NULL, TRUE);
// the above value is used directly by QF, so the value has to be have a rule
// please check with Lobo before u comment this
$this->registerRule('amount', 'callback', 'money', 'CRM_Utils_Rule');
$this->addRule('amount', ts('Please enter a monetary value for this field.'), 'money');
$this->add('textarea', 'description', ts('Description'));
$this->add('textarea', 'help_pre', ts('Pre Option Help'));
$this->add('textarea', 'help_post', ts('Post Option Help'));
// weight
$this->add('text', 'weight', ts('Order'), NULL, TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
// is active ?
$this->add('checkbox', 'is_active', ts('Active?'));
//is default
$this->add('checkbox', 'is_default', ts('Default'));
if ($this->_fid) {
//hide the default checkbox option for text field
$htmlType = CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceField', $this->_fid, 'html_type');
$this->assign('hideDefaultOption', FALSE);
if ($htmlType == 'Text') {
$this->assign('hideDefaultOption', TRUE);
}
}
// add buttons
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save')), array('type' => 'cancel', 'name' => ts('Cancel'))));
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'isDefault' => TRUE)));
}
//.........这里部分代码省略.........
示例9: browse
/**
* Browse all options
*
*
* @return void
* @access public
* @static
*/
function browse()
{
$campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
$groupParams = array('name' => $this->_gName);
$optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
foreach ($optionValues as $key => $optionValue) {
if (CRM_Utils_Array::value('component_id', $optionValue) != $campaingCompId) {
unset($optionValues[$key]);
}
}
$returnURL = CRM_Utils_System::url("civicrm/admin/campaign/surveyType", "reset=1");
$filter = "option_group_id = " . $this->_gid;
CRM_Utils_Weight::addOrder($optionValues, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
$this->assign('rows', $optionValues);
}
示例10: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
$deletePriceSet = 0;
if ($params['membership_type']) {
// we do this in case the user has hit the forward/back button
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $this->_id;
$dao->find(TRUE);
$membershipID = $dao->id;
if ($membershipID) {
$params['id'] = $membershipID;
}
$membershipTypes = array();
if (is_array($params['membership_type'])) {
foreach ($params['membership_type'] as $k => $v) {
if ($v) {
$membershipTypes[$k] = CRM_Utils_Array::value("auto_renew_{$k}", $params);
}
}
}
if ($this->_id && !empty($params['member_price_set_id'])) {
CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'amount_block_is_active', 0);
}
// check for price set.
$priceSetID = CRM_Utils_Array::value('member_price_set_id', $params);
if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) {
$usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 2);
if (empty($params['mem_price_field_id']) && !$usedPriceSetId) {
$pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245));
$setParams['title'] = $this->_values['title'];
if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle, 'id', 'name')) {
$setParams['name'] = $pageTitle;
} elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle . '_' . $this->_id, 'id', 'name')) {
$setParams['name'] = $pageTitle . '_' . $this->_id;
} else {
$timeSec = explode(".", microtime(TRUE));
$setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
}
$setParams['is_quick_config'] = 1;
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
$setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$priceSetID = $priceSet->id;
$fieldParams['price_set_id'] = $priceSet->id;
} elseif ($usedPriceSetId) {
$setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
$setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
$setParams['id'] = $usedPriceSetId;
$priceSet = CRM_Price_BAO_PriceSet::create($setParams);
$priceSetID = $priceSet->id;
$fieldParams['price_set_id'] = $priceSet->id;
} else {
$fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params);
$priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id');
}
$editedFieldParams = array('price_set_id' => $priceSetID, 'name' => 'membership_amount');
$editedResults = array();
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (empty($editedResults['id'])) {
$fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245));
if (empty($params['mem_price_field_id'])) {
CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, array('price_set_id' => $priceSetID));
}
$fieldParams['weight'] = 1;
} else {
$fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults);
}
$fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership');
$fieldParams['is_active'] = 1;
$fieldParams['html_type'] = 'Radio';
$fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0;
$fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0;
$rowCount = 1;
$options = array();
if (!empty($fieldParams['id'])) {
CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} ");
}
foreach ($membershipTypes as $memType => $memAutoRenew) {
if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) {
$fieldParams['option_id'][$rowCount] = $priceFieldID;
unset($options[$priceFieldID]);
}
$membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
$fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype);
$fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0);
$fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype);
$fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype);
$fieldParams['default_option'] = CRM_Utils_Array::value('membership_type_default', $params);
$fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype);
$fieldParams['membership_type_id'][$rowCount] = $memType;
// [$rowCount] = $membetype[''];
$rowCount++;
//.........这里部分代码省略.........
示例11: buildOptions
/**
* Get options for a given field.
* @see CRM_Core_DAO::buildOptions
*
* @param string $fieldName
* @param string $context : @see CRM_Core_DAO::buildOptionsContext
* @param array $props : whatever is known about this dao object
*
* @return array|bool
*/
public static function buildOptions($fieldName, $context = NULL, $props = array())
{
$params = array();
// Special logic for fields whose options depend on context or properties
switch ($fieldName) {
case 'activity_type_id':
$campaignCompId = CRM_Core_Component::getComponentID('CiviCampaign');
if ($campaignCompId) {
$params['condition'] = array("component_id={$campaignCompId}");
}
break;
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
示例12: browse
/**
* Browse all price fields.
*
* @return void
*/
public function browse()
{
$customOption = array();
CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
// CRM-15378 - check if these price options are in an Event price set
$isEvent = FALSE;
$extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id');
$allComponents = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId);
$eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
if (in_array($eventComponentId, $allComponents)) {
$isEvent = TRUE;
}
$config = CRM_Core_Config::singleton();
$financialType = CRM_Contribute_PseudoConstant::financialType();
$taxRate = CRM_Core_PseudoConstant::getTaxRates();
// display taxTerm for priceFields
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$getTaxDetails = FALSE;
foreach ($customOption as $id => $values) {
$action = array_sum(array_keys($this->actionLinks()));
// Adding the required fields in the array
if (isset($taxRate[$values['financial_type_id']])) {
$customOption[$id]['tax_rate'] = $taxRate[$values['financial_type_id']];
if ($invoicing && isset($customOption[$id]['tax_rate'])) {
$getTaxDetails = TRUE;
}
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($customOption[$id]['amount'], $customOption[$id]['tax_rate']);
$customOption[$id]['tax_amount'] = $taxAmount['tax_amount'];
}
if (!empty($values['financial_type_id'])) {
$customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
}
// update enable/disable links depending on price_field properties.
if ($this->_isSetReserved) {
$action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE;
} else {
if ($values['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
}
if (!empty($customOption[$id]['is_default'])) {
$customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
} else {
$customOption[$id]['is_default'] = '';
}
$customOption[$id]['order'] = $customOption[$id]['weight'];
$customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid), ts('more'), FALSE, 'priceFieldValue.row.actions', 'PriceFieldValue', $id);
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field/option', "action=browse&reset=1&fid={$this->_fid}&sid={$this->_sid}");
$filter = "price_field_id = {$this->_fid}";
CRM_Utils_Weight::addOrder($customOption, 'CRM_Price_DAO_PriceFieldValue', 'id', $returnURL, $filter);
$this->assign('taxTerm', $taxTerm);
$this->assign('getTaxDetails', $getTaxDetails);
$this->assign('customOption', $customOption);
$this->assign('sid', $this->_sid);
$this->assign('isEvent', $isEvent);
}
示例13: formRule
/**
* @param $fields
* @param $files
* @param $self
*
* @return array
*/
public static function formRule($fields, $files, $self)
{
$errors = array();
$config = CRM_Core_Config::singleton();
if (in_array("CiviCase", $config->enableComponents)) {
$componentId = CRM_Core_Component::getComponentID('CiviCase');
$caseActivityTypes = CRM_Core_OptionGroup::values('activity_type', TRUE, FALSE, FALSE, " AND v.component_id={$componentId}");
if (!empty($fields['activity_type_id_value']) && is_array($fields['activity_type_id_value']) && empty($fields['include_case_activities_value'])) {
foreach ($fields['activity_type_id_value'] as $activityTypeId) {
if (in_array($activityTypeId, $caseActivityTypes)) {
$errors['fields'] = ts("Please enable 'Include Case Activities' to filter with Case Activity types.");
}
}
}
}
return $errors;
}
示例14: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_ppType) {
return CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
}
$config = CRM_Core_Config::singleton();
if (CRM_Utils_Array::value('is_for_organization', $this->_values) == 2) {
$this->assign('onBehalfRequired', TRUE);
$this->_onBehalfRequired = 1;
}
if ($this->_onbehalf) {
$this->assign('onbehalf', TRUE);
return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), TRUE);
$this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
$this->_paymentProcessors = $this->get('paymentProcessors');
$pps = array();
if (!empty($this->_paymentProcessors)) {
$pps = $this->_paymentProcessors;
foreach ($pps as $key => &$name) {
$pps[$key] = $name['name'];
}
}
if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
$pps[0] = $this->_values['pay_later_text'];
}
if (count($pps) > 1) {
$this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, " ", TRUE);
} elseif (!empty($pps)) {
$key = array_pop(array_keys($pps));
$this->addElement('hidden', 'payment_processor', $key);
if ($key === 0) {
$this->assign('is_pay_later', $this->_values['is_pay_later']);
$this->assign('pay_later_text', $this->_values['pay_later_text']);
}
}
//build pledge block.
$this->_useForMember = 0;
//don't build membership block when pledge_id is passed
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->_separateMembershipPayment = FALSE;
if (in_array('CiviMember', $config->enableComponents)) {
$isTest = 0;
if ($this->_action & CRM_Core_Action::PREVIEW) {
$isTest = 1;
}
if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
$this->_useForMember = 1;
$this->set('useForMember', $this->_useForMember);
}
$this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, TRUE, NULL, FALSE, $isTest, $this->_membershipContactID);
}
$this->set('separateMembershipPayment', $this->_separateMembershipPayment);
}
$this->assign('useForMember', $this->_useForMember);
// If we configured price set for contribution page
// we are not allow membership signup as well as any
// other contribution amount field, CRM-5095
if (isset($this->_priceSetId) && $this->_priceSetId) {
$this->add('hidden', 'priceSetId', $this->_priceSetId);
// build price set form.
$this->set('priceSetId', $this->_priceSetId);
CRM_Price_BAO_Set::buildPriceSet($this);
if ($this->_values['is_monetary'] && $this->_values['is_recur'] && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
self::buildRecur($this);
}
} elseif (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
$this->buildAmount($this->_separateMembershipPayment);
}
if ($this->_priceSetId) {
$is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
if ($is_quick_config) {
$this->_useForMember = 0;
$this->set('useForMember', $this->_useForMember);
}
}
if ($this->_values['is_for_organization']) {
$this->buildOnBehalfOrganization();
}
//we allow premium for pledge during pledge creation only.
if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
}
if ($this->_values['honor_block_is_active']) {
$this->buildHonorBlock();
}
//don't build pledge block when mid is passed
if (!$this->_mid) {
$config = CRM_Core_Config::singleton();
if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
}
//.........这里部分代码省略.........
示例15: validateFinancialType
/**
* Check if financial type has Deferred Revenue Account is relationship
* with Financial Account.
*
* @param int $financialTypeId
* Financial Type Id.
*
* @param int $entityID
* Holds id for PriceSet/PriceField/PriceFieldValue.
*
* @param string $entity
* Entity like PriceSet/PriceField/PriceFieldValue.
*
* @return bool
*
*/
public static function validateFinancialType($financialTypeId, $entityID = NULL, $entity = NULL)
{
if (!CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) {
return FALSE;
}
if ($entityID) {
$query = ' SELECT ps.extends FROM civicrm_price_set ps';
$params = array(1 => array('ps', 'Text'), 2 => array($entityID, 'Integer'));
if ($entity == 'PriceField') {
$params[1] = array('pf', 'Text');
$query .= ' INNER JOIN civicrm_price_field pf ON pf.price_set_id = ps.id ';
}
$query .= ' WHERE %1.id = %2';
$extends = CRM_Core_DAO::singleValueQuery($query, $params);
$extends = explode('', $extends);
if (!(in_array(CRM_Core_Component::getComponentID('CiviEvent'), $extends) || in_array(CRM_Core_Component::getComponentID('CiviMember'), $extends))) {
return FALSE;
}
}
$deferredFinancialType = self::getDeferredFinancialType();
if (!array_key_exists($financialTypeId, $deferredFinancialType)) {
throw new CRM_Core_Exception(ts('Deferred revenue account is not configured for selected financial type. Please have an administrator set up the deferred revenue account at Administer > CiviContribute > Financial Accounts, then configure it for financial types at Administer > CiviContribution > Financial Types, Accounts'));
}
return FALSE;
}