本文整理汇总了PHP中CRM_Member_DAO_MembershipBlock::save方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_DAO_MembershipBlock::save方法的具体用法?PHP CRM_Member_DAO_MembershipBlock::save怎么用?PHP CRM_Member_DAO_MembershipBlock::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_DAO_MembershipBlock
的用法示例。
在下文中一共展示了CRM_Member_DAO_MembershipBlock::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMembershipBlock
/**
* Helper function to create membership block for contribution page.
* @param $membershipType
* @param $contributionPageId
* @return $this
*/
public function createMembershipBlock($membershipType, $contributionPageId)
{
$param = array('is_active' => 1, 'new_title' => 'Membership Fees', 'new_text' => 'text for membership fees', 'renewal_title' => 'Membership Renewal title', 'renewal_text' => 'Membership renewal text', 'is_required' => 1, 'display_min_fee' => 1, 'membership_type' => array($membershipType => 1), 'membership_type_default' => NULL, 'membership_types' => $membershipType, 'is_separate_payment' => 0, 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $contributionPageId);
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->copyValues($param);
return $dao->save();
}
示例2: create
/**
* Add the membership Blocks.
*
* @param array $params
* Reference array contains the values submitted by the form.
*
*
* @return object
*/
public static function create(&$params)
{
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, 'MembershipBlock', CRM_Utils_Array::value('id', $params), $params);
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->copyValues($params);
$dao->id = CRM_Utils_Array::value('id', $params);
$dao->save();
CRM_Utils_Hook::post($hook, 'MembershipBlock', $dao->id, $dao);
return $dao;
}
示例3: postProcess
//.........这里部分代码省略.........
$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++;
}
foreach ($options as $priceFieldID => $memType) {
CRM_Price_BAO_PriceFieldValue::setIsActive($priceFieldID, '0');
}
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
} elseif (!$priceSetID) {
$deletePriceSet = 1;
}
$params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
$params['is_active'] = CRM_Utils_Array::value('member_is_active', $params, FALSE);
if ($priceSetID) {
$params['membership_types'] = 'null';
$params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
$params['membership_types'] = serialize($membershipTypes);
$params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, FALSE);
$params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, FALSE);
}
$params['entity_table'] = 'civicrm_contribution_page';
$params['entity_id'] = $this->_id;
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->copyValues($params);
$dao->save();
if ($priceSetID && $params['is_active']) {
CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $this->_id, $priceSetID);
}
if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) {
if ($this->_memPriceSetId) {
$pFIDs = array();
$conditionParams = array('price_set_id' => $this->_memPriceSetId, 'html_type' => 'radio', 'name' => 'contribution_amount');
CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $conditionParams, $pFIDs);
if (empty($pFIDs['id'])) {
CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution_page', $this->_id);
CRM_Price_BAO_PriceSet::setIsQuickConfig($this->_memPriceSetId, '0');
} else {
CRM_Price_BAO_PriceField::setIsActive($params['mem_price_field_id'], '0');
}
}
}
}
parent::endPostProcess();
}
示例4: while
function upgrade_3_3_2($rev)
{
$dropMailingIndex = FALSE;
$indexes = CRM_Core_DAO::executeQuery('SHOW INDEXES FROM civicrm_mailing_job');
while ($indexes->fetch()) {
if ($indexes->Key_name == 'parent_id') {
$dropMailingIndex = TRUE;
break;
}
}
//CRM-7137
// get membership type for each membership block.
$sql = "SELECT id, membership_types FROM civicrm_membership_block ";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$memType = explode(',', $dao->membership_types);
$memTypeSerialize = array();
foreach ($memType as $k => $v) {
$memTypeSerialize[$v] = 0;
}
// save membership type as an serialized array along w/ auto_renew defalt value zero.
$memBlock = new CRM_Member_DAO_MembershipBlock();
$memBlock->id = $dao->id;
$memBlock->membership_types = serialize($memTypeSerialize);
$memBlock->save();
}
//CRM-7172
if (CRM_Mailing_Info::workflowEnabled()) {
$config = CRM_Core_Config::singleton();
if (is_callable(array($config->userSystem, 'replacePermission'))) {
$config->userSystem->replacePermission('access CiviMail', array('access CiviMail', 'create mailings', 'approve mailings', 'schedule mailings'));
}
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('dropMailingIndex', $dropMailingIndex);
$upgrade->processSQL($rev);
}
示例5: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if ($params['membership_type']) {
// we do this in case the user has hit the forward/back button
require_once 'CRM/Member/DAO/MembershipBlock.php';
$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] = $params["auto_renew_{$k}"];
}
}
}
$params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
$params['membership_types'] = serialize($membershipTypes);
$params['is_required'] = CRM_Utils_Array::value('is_required', $params, false);
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
$params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, false);
$params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, false);
$params['entity_table'] = 'civicrm_contribution_page';
$params['entity_id'] = $this->_id;
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->copyValues($params);
$dao->save();
}
}