本文整理汇总了PHP中CRM_Custom_Form_CustomData::setDefaultValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Custom_Form_CustomData::setDefaultValues方法的具体用法?PHP CRM_Custom_Form_CustomData::setDefaultValues怎么用?PHP CRM_Custom_Form_CustomData::setDefaultValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Custom_Form_CustomData
的用法示例。
在下文中一共展示了CRM_Custom_Form_CustomData::setDefaultValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
if ($this->_surveyId) {
$this->_single = TRUE;
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
$this->_surveyTitle = $surveyInfo['title'];
$this->assign('surveyTitle', $this->_surveyTitle);
CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
$this->set('type', 'Event');
$this->set('entityId', $this->_surveyId);
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
// CRM-11480, CRM-11682
// Preload libraries required by the "Questions" tab
CRM_UF_Page_ProfileEditor::registerProfileScripts();
CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
CRM_Campaign_Form_Survey_TabHeader::build($this);
}
示例2: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Edit Survey'));
} else {
CRM_Utils_System::setTitle(ts('Delete Survey'));
}
}
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
$this->set('type', 'Event');
$this->set('entityId', $this->_surveyId);
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
$session->pushUserContext($url);
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if ($this->_surveyId) {
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
}
$this->set('values', $this->_values);
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// for custom data
$this->assign('entityID', $this->_surveyId);
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Edit Petition'));
} else {
CRM_Utils_System::setTitle(ts('Delete Petition'));
}
}
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition');
$session->pushUserContext($url);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url)));
}
示例3: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
parent::preProcess();
if ($this->_id) {
$this->assign('entityID', $this->_id);
$eventType = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'event_type_id');
} else {
$eventType = 'null';
}
$showLocation = FALSE;
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
$this->set('type', 'Event');
$this->set('subType', CRM_Utils_Array::value('event_type_id', $_POST));
$this->set('entityId', $this->_id);
CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_eventType, 1, 'Event', $this->_id);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
}
示例4: setDefaultValues
/**
* Set default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
*
* @param CRM_Core_Form $form
* @param array $defaults
*/
public static function setDefaultValues(&$form, &$defaults)
{
$defaults += CRM_Custom_Form_CustomData::setDefaultValues($form);
}
示例5: setDefaultValues
/**
* Set default values for the form.
* The default values are retrieved from the database.
*/
public function setDefaultValues()
{
$defaults = $this->_values;
$fields = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if (!empty($defaults['is_test'])) {
$this->assign('is_test', TRUE);
}
if ($this->_id) {
$startDate = CRM_Utils_Array::value('start_date', $this->_values);
$createDate = CRM_Utils_Array::value('create_date', $this->_values);
list($defaults['start_date']) = CRM_Utils_Date::setDateDefaults($startDate);
list($defaults['create_date']) = CRM_Utils_Date::setDateDefaults($createDate);
if ($ackDate = CRM_Utils_Array::value('acknowledge_date', $this->_values)) {
list($defaults['acknowledge_date']) = CRM_Utils_Date::setDateDefaults($ackDate);
}
// check is this pledge pending.
// fix the display of the monetary value, CRM-4038.
if ($this->_isPending) {
$defaults['eachPaymentAmount'] = $this->_values['amount'] / $this->_values['installments'];
$defaults['eachPaymentAmount'] = CRM_Utils_Money::format($defaults['eachPaymentAmount'], NULL, '%a');
} else {
$this->assign('start_date', $startDate);
$this->assign('create_date', $createDate);
}
// fix the display of the monetary value, CRM-4038
if (isset($this->_values['amount'])) {
$defaults['amount'] = CRM_Utils_Money::format($this->_values['amount'], NULL, '%a');
}
$this->assign('amount', $this->_values['amount']);
$this->assign('installments', $defaults['installments']);
} else {
// default values.
list($now) = CRM_Utils_Date::setDateDefaults();
$defaults['create_date'] = $now;
$defaults['start_date'] = $now;
$defaults['installments'] = 12;
$defaults['frequency_interval'] = 1;
$defaults['frequency_day'] = 1;
$defaults['initial_reminder_day'] = 5;
$defaults['max_reminders'] = 1;
$defaults['additional_reminder_day'] = 5;
$defaults['frequency_unit'] = array_search('month', $this->_freqUnits);
$defaults['financial_type_id'] = array_search('Donation', CRM_Contribute_PseudoConstant::financialType());
}
$pledgeStatus = CRM_Contribute_PseudoConstant::contributionStatus();
$pledgeStatusNames = CRM_Core_OptionGroup::values('contribution_status', FALSE, FALSE, FALSE, NULL, 'name', TRUE);
// get default status label (pending)
$defaultPledgeStatus = CRM_Utils_Array::value(array_search('Pending', $pledgeStatusNames), $pledgeStatus);
// assign status.
$this->assign('status', CRM_Utils_Array::value(CRM_Utils_Array::value('status_id', $this->_values), $pledgeStatus, $defaultPledgeStatus));
if (isset($this->userEmail)) {
$this->assign('email', $this->userEmail);
}
// custom data set defaults
$defaults += CRM_Custom_Form_CustomData::setDefaultValues($this);
return $defaults;
}
示例6: setDefaultValues
/**
* This function sets the default values for the form.
* the default values are retrieved from the database
*
* @access public
*
* @return void
*/
public function setDefaultValues()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = array();
$defaults = parent::setDefaultValues();
$this->_memType = $defaults['membership_type_id'];
// set renewal_date and receive_date to today in correct input format (setDateDefaults uses today if no value passed)
list($now, $currentTime) = CRM_Utils_Date::setDateDefaults();
$defaults['renewal_date'] = $now;
$defaults['receive_date'] = $now;
$defaults['receive_date_time'] = $currentTime;
if ($defaults['id']) {
$defaults['record_contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $defaults['id'], 'contribution_id', 'membership_id');
}
if (is_numeric($this->_memType)) {
$defaults['membership_type_id'] = array();
$defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', 'id');
$defaults['membership_type_id'][1] = $this->_memType;
} else {
$defaults['membership_type_id'] = $this->_memType;
}
$defaults['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'financial_type_id');
//CRM-13420
if (empty($defaults['payment_instrument_id'])) {
$defaults['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
}
$defaults['total_amount'] = CRM_Utils_Money::format(CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'minimum_fee'), NULL, '%a');
$defaults['record_contribution'] = 0;
$defaults['num_terms'] = 1;
$defaults['send_receipt'] = 0;
$renewalDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('renewal_date', $defaults), NULL, NULL, 'Y-m-d');
$this->assign('renewalDate', $renewalDate);
$this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults));
if ($this->_mode) {
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$names = array('first_name', 'middle_name', 'last_name', "street_address-{$this->_bltID}", "city-{$this->_bltID}", "postal_code-{$this->_bltID}", "country_id-{$this->_bltID}", "state_province_id-{$this->_bltID}");
foreach ($names as $name) {
$fields[$name] = 1;
}
$fields["state_province-{$this->_bltID}"] = 1;
$fields["country-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$fields['email-Primary'] = 1;
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $this->_defaults);
// use primary email address if billing email address is empty
if (empty($this->_defaults["email-{$this->_bltID}"]) && !empty($this->_defaults['email-Primary'])) {
$defaults["email-{$this->_bltID}"] = $this->_defaults['email-Primary'];
}
foreach ($names as $name) {
if (!empty($this->_defaults[$name])) {
$defaults['billing_' . $name] = $this->_defaults[$name];
}
}
}
return $defaults;
}
示例7: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
$this->_campaignId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$title = NULL;
if ($this->_action & CRM_Core_Action::UPDATE) {
$title = ts('Edit Campaign');
}
if ($this->_action & CRM_Core_Action::DELETE) {
$title = ts('Delete Campaign');
}
if ($title) {
CRM_Utils_System::setTitle($title);
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
$this->assign('action', $this->_action);
//load the values;
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
// if we are editing
if (isset($this->_campaignId) && $this->_campaignId) {
$params = array('id' => $this->_campaignId);
CRM_Campaign_BAO_Campaign::retrieve($params, $this->_values);
}
//lets use current object session.
$this->set('values', $this->_values);
}
// when custom data is included in form.
if (!empty($_POST['hidden_custom'])) {
$campaignTypeId = empty($_POST['campaign_type_id']) ? NULL : $_POST['campaign_type_id'];
$this->set('type', 'Campaign');
$this->set('subType', $campaignTypeId);
$this->set('entityId', $this->_campaignId);
CRM_Custom_Form_CustomData::preProcess($this, NULL, $campaignTypeId, 1, 'Campaign', $this->_campaignId);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
}
示例8: setDefaultValues
/**
* This function sets the default values for the form. For edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return None
*/
function setDefaultValues()
{
if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW || $this->_cdType) {
return TRUE;
}
eval('$defaults = CRM_Case_Form_Activity_' . $this->_activityTypeFile . '::setDefaultValues($this);');
$defaults = array_merge($defaults, CRM_Custom_Form_CustomData::setDefaultValues($this));
return $defaults;
}
示例9: applyCustomData
/**
* @param string $type
* Eg 'Contribution'.
* @param string $subType
* @param int $entityId
*/
public function applyCustomData($type, $subType, $entityId)
{
$this->set('type', $type);
$this->set('subType', $subType);
$this->set('entityId', $entityId);
CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, 1, $type, $entityId);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
示例10: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = $this->_values;
if ($this->_surveyId) {
if (!empty($defaults['result_id']) && !empty($defaults['recontact_interval'])) {
$resultId = $defaults['result_id'];
$recontactInterval = unserialize($defaults['recontact_interval']);
unset($defaults['recontact_interval']);
$defaults['option_group_id'] = $resultId;
}
}
if (!isset($defaults['is_active'])) {
$defaults['is_active'] = 1;
}
$defaultSurveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, TRUE);
if (!isset($defaults['is_default']) && empty($defaultSurveys)) {
$defaults['is_default'] = 1;
}
return $defaults;
}
示例11: setDefaultValues
/**
* This function sets the default values for the form in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
public function setDefaultValues()
{
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::setDefaultValues($this);
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
$defaults = array();
if ($this->_action & CRM_Core_Action::DELETE) {
return $defaults;
}
if ($this->_participantId) {
$ids = array();
$params = array('id' => $this->_participantId);
require_once "CRM/Event/BAO/Participant.php";
CRM_Event_BAO_Participant::getValues($params, $defaults, $ids);
$this->_contactID = $defaults[$this->_participantId]['contact_id'];
$this->_statusId = $defaults[$this->_participantId]['participant_status_id'];
//set defaults for note
$noteDetails = CRM_Core_BAO_Note::getNote($this->_participantId, 'civicrm_participant');
$defaults[$this->_participantId]['note'] = array_pop($noteDetails);
}
if ($this->_action & (CRM_Core_Action::VIEW | CRM_Core_Action::BROWSE)) {
$inactiveNeeded = true;
$viewMode = true;
} else {
$viewMode = false;
$inactiveNeeded = false;
}
//setting default register date
if ($this->_action == CRM_Core_Action::ADD) {
if (CRM_Utils_Array::value('event_id', $defaults[$this->_participantId])) {
$contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_participantId]['event_id'], 'contribution_type_id');
if ($contributionTypeId) {
$defaults[$this->_participantId]['contribution_type_id'] = $contributionTypeId;
}
}
if ($this->_mode) {
$fields["email-{$this->_bltID}"] = 1;
$fields["email-Primary"] = 1;
require_once "CRM/Core/BAO/UFGroup.php";
if ($this->_contactID) {
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactID, $fields, $defaults);
}
if (empty($defaults["email-{$this->_bltID}"]) && !empty($defaults["email-Primary"])) {
$defaults[$this->_participantId]["email-{$this->_bltID}"] = $defaults["email-Primary"];
}
}
$submittedRole = $this->getElementValue('role_id');
if ($submittedRole[0]) {
$roleID = $submittedRole[0];
}
$submittedEvent = $this->getElementValue('event_id');
if ($submittedEvent[0]) {
$eventID = $submittedEvent[0];
}
} else {
$defaults[$this->_participantId]['record_contribution'] = 0;
$recordContribution = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $defaults[$this->_participantId]['id'], 'contribution_id', 'participant_id');
//contribution record exists for this participation
if ($recordContribution) {
foreach (array('contribution_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date') as $field) {
$defaults[$this->_participantId][$field] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $recordContribution, $field);
}
}
if ($defaults[$this->_participantId]['participant_is_pay_later']) {
$this->assign('participant_is_pay_later', true);
}
$this->assign('participant_status_id', $defaults[$this->_participantId]['participant_status_id']);
$roleID = $defaults[$this->_participantId]['participant_role_id'];
$eventID = $defaults[$this->_participantId]['event_id'];
$this->_discountId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'discount_id');
if ($this->_discountId) {
$this->set('discountId', $this->_discountId);
}
}
list($defaults[$this->_participantId]['register_date'], $defaults[$this->_participantId]['register_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('register_date', $defaults[$this->_participantId]));
//assign event and role id, this is needed for Custom data building
if (isset($_POST['role_id'])) {
$roleID = $_POST['role_id'];
}
if (isset($roleID)) {
$this->assign('roleID', $roleID);
}
if (isset($_POST['event_id'])) {
$eventID = $_POST['event_id'];
}
if (isset($eventID)) {
$this->assign('eventID', $eventID);
$this->set('eventId', $eventID);
}
//.........这里部分代码省略.........
示例12: setDefaultValues
/**
* This function sets the default values for the form. For edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
if ($this->_cdType) {
$tempId = (int) CRM_Utils_Request::retrieve('template_id', 'Integer', $this);
// set template custom data as a default for event, CRM-5596
if ($tempId && !$this->_id) {
$defaults = $this->templateCustomDataValues($tempId);
} else {
$defaults = CRM_Custom_Form_CustomData::setDefaultValues($this);
}
return $defaults;
}
$defaults = parent::setDefaultValues();
// in update mode, we need to set custom data subtype to tpl
if (CRM_Utils_Array::value('event_type_id', $defaults)) {
$this->assign('customDataSubType', $defaults["event_type_id"]);
}
require_once 'CRM/Core/ShowHideBlocks.php';
$this->_showHide =& new CRM_Core_ShowHideBlocks();
// Show waitlist features or event_full_text if max participants set
if (CRM_Utils_Array::value('max_participants', $defaults)) {
$this->_showHide->addShow('id-waitlist');
if (CRM_Utils_Array::value('has_waitlist', $defaults)) {
$this->_showHide->addShow('id-waitlist-text');
$this->_showHide->addHide('id-event_full');
} else {
$this->_showHide->addHide('id-waitlist-text');
$this->_showHide->addShow('id-event_full');
}
} else {
$this->_showHide->addHide('id-event_full');
$this->_showHide->addHide('id-waitlist');
$this->_showHide->addHide('id-waitlist-text');
}
$this->_showHide->addToTemplate();
$this->assign('elemType', 'table-row');
$this->assign('description', CRM_Utils_Array::value('description', $defaults));
// Provide suggested text for event full and waitlist messages if they're empty
$defaults['event_full_text'] = CRM_Utils_Array::value('event_full_text', $defaults, ts('This event is currently full.'));
$defaults['waitlist_text'] = CRM_Utils_Array::value('waitlist_text', $defaults, ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.'));
list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(CRM_Utils_Array::value('start_date', $defaults), 'activityDateTime');
if (CRM_Utils_Array::value('end_date', $defaults)) {
list($defaults['end_date'], $defaults['end_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['end_date'], 'activityDateTime');
}
return $defaults;
}
示例13: setDefaultValues
/**
* Set default values for the form.
*
* @return array
*/
public function setDefaultValues()
{
$defaults = array();
if (isset($this->_id)) {
$defaults = $this->_groupValues;
if (!empty($defaults['group_type'])) {
$types = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($defaults['group_type'], 1, -1));
$defaults['group_type'] = array();
foreach ($types as $type) {
$defaults['group_type'][$type] = 1;
}
}
if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) {
CRM_Contact_BAO_GroupOrganization::retrieve($this->_id, $defaults);
}
}
if (!(CRM_Core_Permission::check('access CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings'))) {
$groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
if ($defaults['group_type'][$groupTypes['Mailing List']] == 1) {
$this->assign('freezeMailignList', $groupTypes['Mailing List']);
} else {
$this->assign('hideMailignList', $groupTypes['Mailing List']);
}
}
if (empty($defaults['parents'])) {
$defaults['parents'] = CRM_Core_BAO_Domain::getGroupId();
}
// custom data set defaults
$defaults += CRM_Custom_Form_CustomData::setDefaultValues($this);
return $defaults;
}
示例14: preProcess
/**
* Form preProcess function.
*
* @throws \Exception
*/
public function preProcess()
{
// This string makes up part of the class names, differentiating them (not sure why) from the membership fields.
$this->assign('formClass', 'membership');
parent::preProcess();
// get price set id.
$this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
$this->set('priceSetId', $this->_priceSetId);
$this->assign('priceSetId', $this->_priceSetId);
if ($this->_action & CRM_Core_Action::DELETE) {
$contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id);
// check delete permission for contribution
if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
}
}
if ($this->_action & CRM_Core_Action::ADD) {
if (!CRM_Member_BAO_Membership::statusAvailabilty($this->_contactID)) {
// all possible statuses are disabled - redirect back to contact form
CRM_Core_Error::statusBounce(ts('There are no configured membership statuses. You cannot add this membership until your membership statuses are correctly configured'));
}
if ($this->_contactID) {
//check whether contact has a current membership so we can alert user that they may want to do a renewal instead
$contactMemberships = array();
$memParams = array('contact_id' => $this->_contactID);
CRM_Member_BAO_Membership::getValues($memParams, $contactMemberships, TRUE);
$cMemTypes = array();
foreach ($contactMemberships as $mem) {
$cMemTypes[] = $mem['membership_type_id'];
}
if (count($cMemTypes) > 0) {
$memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes);
$mems_by_org = array();
foreach ($contactMemberships as $mem) {
$mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs);
if (!empty($mem['membership_end_date'])) {
$mem['membership_end_date'] = CRM_Utils_Date::customformat($mem['membership_end_date']);
}
$mem['membership_type'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $mem['membership_type_id'], 'name', 'id');
$mem['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $mem['status_id'], 'label', 'id');
$mem['renewUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$mem['id']}&context=membership&selectedChild=member" . ($this->_mode ? '&mode=live' : ''));
$mem['membershipTab'] = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=member");
$mems_by_org[$mem['member_of_contact_id']] = $mem;
}
$this->assign('existingContactMemberships', $mems_by_org);
}
} else {
// In standalone mode we don't have a contact id yet so lookup will be done client-side with this script:
$resources = CRM_Core_Resources::singleton();
$resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js');
$passthru = array('typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), 'memtypes' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'membership_type_id'), 'statuses' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'status_id'));
$resources->addSetting(array('existingMems' => $passthru));
}
}
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
CRM_Custom_Form_CustomData::preProcess($this);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
// CRM-4395, get the online pending contribution id.
$this->_onlinePendingContributionId = NULL;
if (!$this->_mode && $this->_id && $this->_action & CRM_Core_Action::UPDATE) {
$this->_onlinePendingContributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($this->_id, 'Membership');
}
$this->assign('onlinePendingContributionId', $this->_onlinePendingContributionId);
$this->setPageTitle(ts('Membership'));
}
示例15: array
/**
* Set the default form values
*
* @access protected
* @return array the default array reference
*/
function &setDefaultValues()
{
if ($this->_cdType) {
$customDefaultValue = CRM_Custom_Form_CustomData::setDefaultValues($this);
return $customDefaultValue;
}
$groupTree =& CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this, $this->_tableID, $this->_groupID, $this->_contactSubType);
if (!CRM_Utils_Array::value("hidden_custom_group_count", $_POST)) {
// custom data building in edit mode (required to handle multi-value)
$groupTree =& CRM_Core_BAO_CustomGroup::getTree($this->_contactType, $this, $this->_tableID, $this->_groupID, $this->_contactSubType);
$customValueCount = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, true, $this->_groupID);
} else {
$customValueCount = $_POST['hidden_custom_group_count'][$this->_groupID];
}
$this->assign("customValueCount", $customValueCount);
$defaults = array();
return $defaults;
}