class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_ContributionBase

form to process actions on the group aspect of Custom Data

Constants

ATTR_SPACING

Constants for attributes for various form elements attempt to standardize on the number of variations that we use of the below form elements

CB_PREFIX

All checkboxes are defined with a common prefix. This allows us to have the same javascript to check / clear all the checkboxes etc If u have multiple groups of checkboxes, you will need to give them different ids to avoid potential name collision

CB_PREFIY

All checkboxes are defined with a common prefix. This allows us to have the same javascript to check / clear all the checkboxes etc If u have multiple groups of checkboxes, you will need to give them different ids to avoid potential name collision

CB_PREFIZ

All checkboxes are defined with a common prefix. This allows us to have the same javascript to check / clear all the checkboxes etc If u have multiple groups of checkboxes, you will need to give them different ids to avoid potential name collision

CB_PREFIX_LEN

All checkboxes are defined with a common prefix. This allows us to have the same javascript to check / clear all the checkboxes etc If u have multiple groups of checkboxes, you will need to give them different ids to avoid potential name collision

Properties

protected object $_state The state object that this form belongs to from CRM_Core_Form
protected string $_name The name of this form from CRM_Core_Form
protected string $_title The title of this form from CRM_Core_Form
array $_defaults The default values for the form. from CRM_Core_Form
mixed $_options (QUASI-PROTECTED) The options passed into this form from CRM_Core_Form
$_action from CRM_Contribute_Form_ContributionBase
protected array $_paymentProcessors Available payment processors. from CRM_Core_Form
array $_paymentProcessorIDs Available payment processors (IDS). from CRM_Core_Form
protected int $_paymentProcessorID Default or selected processor id. from CRM_Core_Form
protected int $_is_pay_later_enabled Is pay later enabled for the form. from CRM_Core_Form
protected object $_renderer The renderer used for this form from CRM_Core_Form
protected array $_dateFields An array to hold a list of datefields on the form so that they can be converted to ISO in a consistent manner from CRM_Core_Form
static protected CRM_Core_Smarty $_template Cache the smarty template for efficiency reasons from CRM_Core_Form
protected $unsavedChangesWarn Indicate if this form should warn users of unsaved changes from CRM_Core_Form
array $ajaxResponse What to return to the client if in ajax mode (snippet=json) from CRM_Core_Form
array $urlPath Url path used to reach this page from CRM_Core_Form
CRM_Core_Controller $controller from CRM_Core_Form
static array $html5Types Extra input types we support via the "add" method from CRM_Core_Form
int $_id The id of the contribution page that we are processing. from CRM_Contribute_Form_ContributionBase
string $_mode The mode that we are in from CRM_Contribute_Form_ContributionBase
int $_membershipContactID The contact id related to a membership from CRM_Contribute_Form_ContributionBase
array $_values The values for the contribution db object from CRM_Contribute_Form_ContributionBase
array $_paymentProcessor The paymentProcessor attributes for this page from CRM_Contribute_Form_ContributionBase
$_paymentObject from CRM_Contribute_Form_ContributionBase
array $_membershipBlock The membership block for this page from CRM_Contribute_Form_ContributionBase
protected bool $_separateMembershipPayment Does this form support a separate membership payment from CRM_Contribute_Form_ContributionBase
array $_params The params submitted by the form and computed by the app from CRM_Contribute_Form_ContributionBase
array $_fields The fields involved in this contribution page from CRM_Contribute_Form_ContributionBase
int $_bltID The billing location id for this contribution page. from CRM_Contribute_Form_ContributionBase
float $_amount Cache the amount to make things easier from CRM_Contribute_Form_ContributionBase
integer $_pcpId Pcp id from CRM_Contribute_Form_ContributionBase
array $_pcpBlock Pcp block from CRM_Contribute_Form_ContributionBase
array $_pcpInfo Pcp info from CRM_Contribute_Form_ContributionBase
int $_contactID The id of the contact associated with this contribution.
protected $_userID from CRM_Contribute_Form_ContributionBase
int $_membershipId The Membership ID for membership renewal from CRM_Contribute_Form_ContributionBase
int $_priceSetId Price Set ID, if the new price set method is used from CRM_Contribute_Form_ContributionBase
array $_priceSet Array of fields for the price set from CRM_Contribute_Form_ContributionBase
string $_contributeMode Contribution mode e.g express for payment express, notify for off-site + notification back to CiviCRM from CRM_Contribute_Form_ContributionBase
boolean $_useForMember Contribution page supports memberships from CRM_Contribute_Form_ContributionBase
$_isBillingAddressRequiredForPayLater from CRM_Contribute_Form_ContributionBase
bool $_emailExists Flag if email field exists in embedded profile from CRM_Contribute_Form_ContributionBase
bool $isBackOffice Is this a backoffice form (this will affect whether paypal express code is displayed) from CRM_Contribute_Form_ContributionBase
int $paymentInstrumentID Payment instrument if for the transaction. from CRM_Contribute_Form_ContributionBase
int $_contributionID The id of the contribution object that is created when the form is submitted.

Methods

__construct(object $state = NULL, const|enum|int $action = CRM_Core_Action::NONE, string $method = 'post', string $name = NULL)

Constructor for the basic form page.

addClass(string $className)

Add one or more css classes to the form.

registerRules()

Register all the standard rules that most forms potentially use.

HTML_QuickForm_Element
add(string $type, string $name, string $label = '', string|array $attributes = '', bool $required = FALSE, array $extra = NULL)

Simple easy to use wrapper around addElement.

preProcess()

Set variables up before form is built.

postProcess()

Process the form.

mainProcess(bool $allowAjax = TRUE)

Main process wrapper.

postProcessHook()

The postProcess hook is typically called by the framework.

buildQuickForm()

Build the form object.

array|NULL
setDefaultValues()

Set default values for the form.

addRules()

This is a virtual function that adds group and global rules to the form.

bool
validate()

Performs the server side validation.

buildForm()

Core function that builds the form.

addButtons(array $params)

Add default Next / Back buttons.

string
getName()

Getter function for Name.

object
getState()

Getter function for State.

int
getStateType()

Getter function for StateType.

string
getTitle()

Getter function for title.

setTitle(string $title)

Setter function for title.

assignBillingType()

Assign billing type id to bltID.

assignPaymentProcessor(bool $is_pay_later_enabled)

This if a front end form function for setting the payment processor.

array
formatParamsForPaymentProcessor(array $fields)

Format the fields for the payment processor.

preProcessPaymentOptions()

Handle Payment Processor switching for contribution and event registration forms.

handlePreApproval(array $params)

Handle pre approval for processors.

setOptions(mixed $options)

Setter function for options.

string
toSmarty()

Render form and return contents.

object
getRenderer()

Getter function for renderer.

string
getTemplateFileName()

Use the form name to create the tpl file name.

getHookedTemplateFileName()

A wrapper for getTemplateFileName.

error(string $message, int $code = NULL, CRM_Core_DAO $dao = NULL)

Error reporting mechanism.

set(string $name, mixed $value)

Store the variable with the value in the form scope.

mixed
get(string $name)

Get the variable from the form scope.

int
getAction()

Overwrite action.

setAction(int $action)

Setter for action.

assign(string $var, mixed $value = NULL)

Assign value to name in template.

assign_by_ref(string $var, mixed $value)

Assign value to name in template by reference.

append(array|string $tpl_var, mixed $value = NULL, bool $merge = FALSE)

Appends values to template variables.

array
get_template_vars(string $name = NULL)

Returns an array containing template variables.

HTML_QuickForm_group
addRadio(string $name, $title, $values, array $attributes = array(), null $separator = NULL, bool $required = FALSE)

No description

addYesNo(int $id, $title, bool $allowClear = FALSE, null $required = NULL, array $attributes = array())

No description

addCheckBox(int $id, $title, $values, null $other = NULL, null $attributes = NULL, null $required = NULL, null $javascriptMethod = NULL, string $separator = '<br />', bool $flipValues = FALSE)

No description

resetValues()

No description

addDefaultButtons(string $title, string $nextType = 'next', string $backType = 'back', bool|string $submitOnce = FALSE)

Simple shell that derived classes can call to add buttons to the form with a customized title for the main Submit

addDateRange(string $name, string $from = '_from', string $to = '_to', string $label = 'From:', string $dateFormat = 'searchDate', bool $required = FALSE, bool $displayTime = FALSE)

No description

getDefaultEntity()

Classes extending CRM_Core_Form should implement this method.

getDefaultContext()

Classes extending CRM_Core_Form should implement this method.

HTML_QuickForm_Element
addSelect($name, array $props = array(), bool $required = FALSE)

Adds a select based on field metadata.

HTML_QuickForm_Element
addField($name, array $props = array(), bool $required = FALSE, bool $legacyDate = TRUE)

Adds a field based on metadata.

addProfileSelector(string $name, string $label, string $allowCoreTypes, string $allowSubTypes, array $entities, bool $default = FALSE, string $usedFor = NULL)

Add a widget for selecting/editing/creating/copying a profile form

null
getRootTitle()

No description

string
getCompleteTitle()

No description

static CRM_Core_Smarty
getTemplate()

No description

addUploadElement($elementName)

No description

null
getVar($name)

No description

setVar($name, $value)

No description

addDate(string $name, string $label, bool $required = FALSE, array $attributes = NULL) deprecated

Add date.

addDateTime(string $name, string $label, bool $required = FALSE, null $attributes = NULL) deprecated

Function that will add date and time.

HTML_QuickForm_Element
addMoney(string $name, string $label, bool $required = FALSE, null $attributes = NULL, bool $addCurrency = TRUE, string $currencyName = 'currency', null $defaultCurrency = NULL, bool $freezeCurrency = FALSE)

Add a currency and money element to the form.

addCurrency(string $name = 'currency', null $label = NULL, bool $required = TRUE, string $defaultCurrency = NULL, bool $freezeCurrency = FALSE, bool $setDefaultCurrency = TRUE)

Add currency element to the form.

HTML_QuickForm_Element
addEntityRef(string $name, string $label = '', array $props = array(), bool $required = FALSE)

Create a single or multiple entity ref field.

convertDateFieldsToMySQL(array $params)

Convert all date fields within the params to mysql date ready for the BAO layer. In this case fields are checked against the $_datefields defined for the form and if time is defined it is incorporated

removeFileRequiredRules($elementName)

No description

cancelAction()

Function that can be defined in Form to override or.

static 
validateMandatoryFields(array $fields, array $values, array $errors)

Helper function to verify that required fields have been filled.

NULL|int
setContactID()

Get contact if for a form object. Prioritise - cid in URL if 0 (on behalf on someoneelse) (@todo consider setting a variable if onbehalf for clarity of downstream 'if's - logged in user id if it matches the one in the cid in the URL - contact id validated from a checksum from a checksum - cid from the url if the caller has ACL permission to view - fallback is logged in user (or ? NULL if no logged in user) (@todo wouldn't 0 be more intuitive?)

int|NULL
getContactID()

Get the contact id that the form is being submitted for.

getLoggedInUserContactID()

Get the contact id of the logged in user.

addAutoSelector(array $profiles = array(), array $autoCompleteField = array())

Add autoselector field -if user has permission to view contacts If adding this to a form you also need to add to the tpl e.g

canUseAjaxContactLookups()

No description

addCIDZeroOptions($onlinePaymentProcessorEnabled)

Add the options appropriate to cid = zero - ie. autocomplete

array
getProfileDefaults(mixed $profile_id = 'Billing', int $contactID = NULL)

Set default values on form for given contact (or no contact defaults)

preventAjaxSubmit()

Sets form attribute.

allowAjaxSubmit()

Sets form attribute.

setPageTitle(string $entityLabel)

Sets page title based on entity and action.

HTML_QuickForm_Element
addChainSelect(string $elementName, array $settings = array())

Create a chain-select target field. All settings are optional; the defaults usually work.

addTaskMenu(array $tasks)

Add actions menu to results form.

string
assignBillingName(array $params = array())

Assign billing name to the template.

assignToTemplate()

Assign the minimal set of variables to the template.

buildCustom(int $id, string $name, bool $viewOnly = FALSE, null $profileContactType = NULL, array $fieldTypes = NULL)

Add the custom fields.

buildComponentForm(int $id, CRM_Core_Form $form)

Add onbehalf/honoree profile fields and native module fields.

null|string
checkTemplateFileExists(string $suffix = NULL)

Check template file exists.

authenticatePledgeUser()

Authenticate pledge user during online payment.

cancelRecurring()

Cancel recurring contributions.

bool
buildMembershipBlock(int $cid, bool $isContributionMainPage = FALSE, int $selectedMembershipTypeID = NULL, bool $thankPage = FALSE, null $isTest = NULL)

Build Membership Block in Contribution Pages.

setRecurringMembershipParams()

Determine if recurring parameters need to be added to the form parameters.

static mixed
handlePledge($form, $params, $contributionParams, $pledgeID, $contribution, $isEmailReceipt)

No description

static array
getContributionParams(array $params, int $financialTypeID, float $nonDeductibleAmount, bool $pending, array $paymentProcessorOutcome, string $receiptDate, int $recurringContributionID)

Set the parameters to be passed to contribution create function.

static array
getNonDeductibleAmount(array $params, CRM_Financial_BAO_FinancialType $financialType, bool $online, CRM_Contribute_Form_Contribution_Confirm $form)

Get non-deductible amount.

null|string
wrangleFinancialTypeID(int $contributionTypeId)

Wrangle financial type ID.

postProcessPremium(array $premiumParams, CRM_Contribute_BAO_Contribution $contribution)

Process the form.

processFormContribution(CRM_Core_Form $form, array $params, array $result, array $contributionParams, CRM_Financial_DAO_FinancialType $financialType, bool $online, int $billingLocationID, bool $isRecur)

Process the contribution.

static int|null
processRecurringContribution(CRM_Core_Form $form, array $params, int $contactID, string $contributionType)

Create the recurring contribution record.

static 
processOnBehalfOrganization(array $behalfOrganization, int $contactID, array $values, array $params, array $fields = NULL)

Add on behalf of organization and it's location.

static 
pcpNotifyOwner(object $contribution, object $contributionSoft)

Function used to send notification mail to pcp owner.

static array
processPcp(CRM_Core_Form $page, array $params)

Function used to se pcp related defaults / params.

processMembership(array $membershipParams, int $contactID, array $customFieldsFormatted, array $fieldTypes, array $premiumParams, array $membershipLineItems)

Process membership.

postProcessMembership(array $membershipParams, int $contactID, CRM_Contribute_Form_Contribution_Confirm $form, array $premiumParams, null $customFieldsFormatted = NULL, null $includeFieldTypes = NULL, array $membershipDetails, array $membershipTypeIDs, bool $isPaidMembership, array $membershipID, bool $isProcessSeparateMembershipTransaction, int $financialTypeID, array $unprocessedLineItems, bool $isPending)

Process the Memberships.

string
compileErrorMessage(array $errors)

Turn array of errors into message string.

processSecondaryFinancialTransaction(int $contactID, CRM_Contribute_Form_Contribution_Confirm $form, array $tempParams, bool $isTest, array $lineItems, $minimumFee, int $financialTypeID)

Where a second separate financial transaction is supported we will process it here.

bool
getIsPending()

Is the payment a pending payment.

bool
isSeparateMembershipTransaction(int $formID, bool $amountBlockActiveOnForm)

Are we going to do 2 financial transactions.

setFormAmountFields(int $priceSetID)

This function sets the fields.

static 
submit(array $params)

Submit function.

static array
getFormParams(int $id, array $params)

Helper function for static submit function.

array
processFormSubmission(int $contactID)

Post form submission handling.

doMembershipProcessing(int $contactID, array $membershipParams, array $premiumParams, array $formLineItems)

Membership processing section.

completeTransaction(array $result, int $contributionID)

Complete transaction if payment has been processed.

Details

in CRM_Core_Form at line 239
CRM_Core_Form __construct(object $state = NULL, const|enum|int $action = CRM_Core_Action::NONE, string $method = 'post', string $name = NULL)

Constructor for the basic form page.

We should not use QuickForm directly. This class provides a lot of default convenient functions, rules and buttons

Parameters

object $state State associated with this form.
const|enum|int $action The mode the form is operating in (None/Create/View/Update/Delete)
string $method The type of http method used (GET/POST).
string $name The name of the form if different from class name.

Return Value

CRM_Core_Form

in CRM_Core_Form at line 279
addClass(string $className)

Add one or more css classes to the form.

Parameters

string $className

in CRM_Core_Form at line 287
registerRules()

Register all the standard rules that most forms potentially use.

in CRM_Core_Form at line 340
HTML_QuickForm_Element add(string $type, string $name, string $label = '', string|array $attributes = '', bool $required = FALSE, array $extra = NULL)

Simple easy to use wrapper around addElement.

Deal with simple validation rules.

Parameters

string $type
string $name
string $label
string|array $attributes (options for select elements)
bool $required
array $extra (attributes for select elements). For datepicker elements this is consistent with the data from CRM_Utils_Date::getDatePickerExtra

Return Value

HTML_QuickForm_Element Could be an error object

at line 295
preProcess()

Set variables up before form is built.

at line 714
postProcess()

Process the form.

in CRM_Core_Form at line 446
mainProcess(bool $allowAjax = TRUE)

Main process wrapper.

Implemented so that we can call all the hook functions.

Parameters

bool $allowAjax FIXME: This feels kind of hackish, ideally we would take the json-related code from this function. and bury it deeper down in the controller

in CRM_Core_Form at line 473
postProcessHook()

The postProcess hook is typically called by the framework.

However in a few cases, the form exits or redirects early in which case it needs to call this function so other modules can do the needful Calling this function directly should be avoided if possible. In general a better way is to do setUserContext so the framework does the redirect

at line 500
buildQuickForm()

Build the form object.

at line 708
array|NULL setDefaultValues()

Set default values for the form.

Note that in edit/view mode the default values are retrieved from the database

Return Value

array|NULL reference to the array of default values

in CRM_Core_Form at line 502
addRules()

This is a virtual function that adds group and global rules to the form.

Keeping it distinct from the form to keep code small and localized in the form building code

in CRM_Core_Form at line 512
bool validate()

Performs the server side validation.

Return Value

bool true if no error found

Exceptions

HTML_QuickForm_Error

in CRM_Core_Form at line 540
buildForm()

Core function that builds the form.

We redefine this function here and expect all CRM forms to build their form in the function buildQuickForm.

in CRM_Core_Form at line 599
addButtons(array $params)

Add default Next / Back buttons.

Parameters

array $params Array of associative arrays in the order in which the buttons should be displayed. The associate array has 3 fields: 'type', 'name' and 'isDefault' The base form class will define a bunch of static arrays for commonly used formats.

in CRM_Core_Form at line 668
string getName()

Getter function for Name.

Return Value

string

in CRM_Core_Form at line 677
object getState()

Getter function for State.

Return Value

object

in CRM_Core_Form at line 686
int getStateType()

Getter function for StateType.

Return Value

int

in CRM_Core_Form at line 697
string getTitle()

Getter function for title.

Should be over-ridden by derived class.

Return Value

string

in CRM_Core_Form at line 707
setTitle(string $title)

Setter function for title.

Parameters

string $title The title of the form.

in CRM_Core_Form at line 716
assignBillingType()

Assign billing type id to bltID.

Exceptions

CRM_Core_Exception

in CRM_Core_Form at line 731
protected assignPaymentProcessor(bool $is_pay_later_enabled)

This if a front end form function for setting the payment processor.

It would be good to sync it with the back-end function on abstractEditPayment & use one everywhere.

Parameters

bool $is_pay_later_enabled

Exceptions

CRM_Core_Exception

in CRM_Core_Form at line 769
protected array formatParamsForPaymentProcessor(array $fields)

Format the fields for the payment processor.

In order to pass fields to the payment processor in a consistent way we add some renamed parameters.

Parameters

array $fields

Return Value

array

in CRM_Core_Form at line 807
protected preProcessPaymentOptions()

Handle Payment Processor switching for contribution and event registration forms.

This function is shared between contribution & event forms & this is their common class.

However, this should be seen as an in-progress refactor, the end goal being to also align the backoffice forms that action payments.

This function overlaps assignPaymentProcessor, in a bad way.

in CRM_Core_Form at line 860
protected handlePreApproval(array $params)

Handle pre approval for processors.

This fits with the flow where a pre-approval is done and then confirmed in the next stage when confirm is hit.

This function is shared between contribution & event forms & this is their common class.

However, this should be seen as an in-progress refactor, the end goal being to also align the backoffice forms that action payments.

Parameters

array $params

in CRM_Core_Form at line 885
setOptions(mixed $options)

Setter function for options.

Parameters

mixed $options

in CRM_Core_Form at line 894
string toSmarty()

Render form and return contents.

Return Value

string

in CRM_Core_Form at line 912
object getRenderer()

Getter function for renderer.

If renderer is not set create one and initialize it.

Return Value

object

string getTemplateFileName()

Use the form name to create the tpl file name.

Return Value

string

in CRM_Core_Form at line 947
getHookedTemplateFileName()

A wrapper for getTemplateFileName.

This includes calling the hook to prevent us from having to copy & paste the logic of calling the hook.

string overrideExtraTemplateFileName()

Add the extra.tpl in.

Default extra tpl file basically just replaces .tpl with .extra.tpl i.e. we do not override - why isn't this done at the CRM_Core_Form level?

Return Value

string

in CRM_Core_Form at line 974
error(string $message, int $code = NULL, CRM_Core_DAO $dao = NULL)

Error reporting mechanism.

Parameters

string $message Error Message.
int $code Error Code.
CRM_Core_DAO $dao A data access object on which we perform a rollback if non - empty.

in CRM_Core_Form at line 992
set(string $name, mixed $value)

Store the variable with the value in the form scope.

Parameters

string $name Name of the variable.
mixed $value Value of the variable.

in CRM_Core_Form at line 1004
mixed get(string $name)

Get the variable from the form scope.

Parameters

string $name Name of the variable

Return Value

mixed

at line 693
int getAction()

Overwrite action.

Since we are only showing elements in frozen mode no help display needed.

Return Value

int

in CRM_Core_Form at line 1023
setAction(int $action)

Setter for action.

Parameters

int $action The mode we want to set the form.

in CRM_Core_Form at line 1035
assign(string $var, mixed $value = NULL)

Assign value to name in template.

Parameters

string $var Name of variable.
mixed $value Value of variable.

in CRM_Core_Form at line 1047
assign_by_ref(string $var, mixed $value)

Assign value to name in template by reference.

Parameters

string $var Name of variable.
mixed $value Value of variable.

in CRM_Core_Form at line 1059
append(array|string $tpl_var, mixed $value = NULL, bool $merge = FALSE)

Appends values to template variables.

Parameters

array|string $tpl_var the template variable name(s)
mixed $value The value to append.
bool $merge

in CRM_Core_Form at line 1070
array get_template_vars(string $name = NULL)

Returns an array containing template variables.

Parameters

string $name

Return Value

array

in CRM_Core_Form at line 1084
HTML_QuickForm_group addRadio(string $name, $title, $values, array $attributes = array(), null $separator = NULL, bool $required = FALSE)

Parameters

string $name
$title
$values
array $attributes
null $separator
bool $required

Return Value

HTML_QuickForm_group

in CRM_Core_Form at line 1110
addYesNo(int $id, $title, bool $allowClear = FALSE, null $required = NULL, array $attributes = array())

Parameters

int $id
$title
bool $allowClear
null $required
array $attributes

in CRM_Core_Form at line 1136
addCheckBox(int $id, $title, $values, null $other = NULL, null $attributes = NULL, null $required = NULL, null $javascriptMethod = NULL, string $separator = '<br />', bool $flipValues = FALSE)

Parameters

int $id
$title
$values
null $other
null $attributes
null $required
null $javascriptMethod
string $separator
bool $flipValues

in CRM_Core_Form at line 1179
resetValues()

in CRM_Core_Form at line 1195
addDefaultButtons(string $title, string $nextType = 'next', string $backType = 'back', bool|string $submitOnce = FALSE)

Simple shell that derived classes can call to add buttons to the form with a customized title for the main Submit

Parameters

string $title Title of the main button.
string $nextType Button type for the form after processing.
string $backType
bool|string $submitOnce If true, add javascript to next button submit which prevents it from being clicked more than once

in CRM_Core_Form at line 1226
addDateRange(string $name, string $from = '_from', string $to = '_to', string $label = 'From:', string $dateFormat = 'searchDate', bool $required = FALSE, bool $displayTime = FALSE)

Parameters

string $name
string $from
string $to
string $label
string $dateFormat
bool $required
bool $displayTime

in CRM_Core_Form at line 1259
getDefaultEntity()

Classes extending CRM_Core_Form should implement this method.

Exceptions

Exception

in CRM_Core_Form at line 1269
getDefaultContext()

Classes extending CRM_Core_Form should implement this method.

TODO: Merge with CRM_Core_DAO::buildOptionsContext($context) and add validation.

Exceptions

Exception

in CRM_Core_Form at line 1291
HTML_QuickForm_Element addSelect($name, array $props = array(), bool $required = FALSE)

Adds a select based on field metadata.

TODO: This could be even more generic and widget type (select in this case) could also be read from metadata Perhaps a method like $form->bind($name) which would look up all metadata for named field

Parameters

$name Field name to go on the form.
array $props Mix of html attributes and special properties, namely. - entity (api entity name, can usually be inferred automatically from the form class) - field (field name - only needed if different from name used on the form) - option_url - path to edit this option list - usually retrieved automatically - set to NULL to disable link - placeholder - set to NULL to disable - multiple - bool - context - see CRM_Core_DAO::buildOptionsContext
bool $required

Return Value

HTML_QuickForm_Element

Exceptions

CRM_Core_Exception

in CRM_Core_Form at line 1372
HTML_QuickForm_Element addField($name, array $props = array(), bool $required = FALSE, bool $legacyDate = TRUE)

Adds a field based on metadata.

Parameters

$name Field name to go on the form.
array $props Mix of html attributes and special properties, namely. - entity (api entity name, can usually be inferred automatically from the form class) - name (field name - only needed if different from name used on the form) - option_url - path to edit this option list - usually retrieved automatically - set to NULL to disable link - placeholder - set to NULL to disable - multiple - bool - context - see CRM_Core_DAO::buildOptionsContext
bool $required
bool $legacyDate Temporary param to facilitate the conversion of fields to use the datepicker in a controlled way. To convert the field the jcalendar code needs to be removed from the tpl as well. That file is intended to be EOL.

Return Value

HTML_QuickForm_Element

Exceptions

CiviCRM_API3_Exception
Exception

in CRM_Core_Form at line 1553
addProfileSelector(string $name, string $label, string $allowCoreTypes, string $allowSubTypes, array $entities, bool $default = FALSE, string $usedFor = NULL)

Add a widget for selecting/editing/creating/copying a profile form

Parameters

string $name HTML form-element name.
string $label Printable label.
string $allowCoreTypes Only present a UFGroup if its group_type includes a subset of $allowCoreTypes; e.g. 'Individual', 'Activity'.
string $allowSubTypes Only present a UFGroup if its group_type is compatible with $allowSubypes.
array $entities
bool $default //CRM-15427.
string $usedFor

in CRM_Core_Form at line 1572
null getRootTitle()

Return Value

null

in CRM_Core_Form at line 1579
string getCompleteTitle()

Return Value

string

in CRM_Core_Form at line 1586
static CRM_Core_Smarty getTemplate()

Return Value

CRM_Core_Smarty

in CRM_Core_Form at line 1593
addUploadElement($elementName)

Parameters

$elementName

in CRM_Core_Form at line 1623
null getVar($name)

Parameters

$name

Return Value

null

in CRM_Core_Form at line 1631
setVar($name, $value)

Parameters

$name
$value

in CRM_Core_Form at line 1650
addDate(string $name, string $label, bool $required = FALSE, array $attributes = NULL) deprecated

deprecated Use $this->add('datepicker', ...) instead.

Add date.

Parameters

string $name Name of the element.
string $label Label of the element.
bool $required True if required.
array $attributes Key / value pair.

in CRM_Core_Form at line 1739
addDateTime(string $name, string $label, bool $required = FALSE, null $attributes = NULL) deprecated

deprecated Use $this->add('datepicker', ...) instead.

Function that will add date and time.

Parameters

string $name
string $label
bool $required
null $attributes

in CRM_Core_Form at line 1765
HTML_QuickForm_Element addMoney(string $name, string $label, bool $required = FALSE, null $attributes = NULL, bool $addCurrency = TRUE, string $currencyName = 'currency', null $defaultCurrency = NULL, bool $freezeCurrency = FALSE)

Add a currency and money element to the form.

Parameters

string $name
string $label
bool $required
null $attributes
bool $addCurrency
string $currencyName
null $defaultCurrency
bool $freezeCurrency

Return Value

HTML_QuickForm_Element

in CRM_Core_Form at line 1795
addCurrency(string $name = 'currency', null $label = NULL, bool $required = TRUE, string $defaultCurrency = NULL, bool $freezeCurrency = FALSE, bool $setDefaultCurrency = TRUE)

Add currency element to the form.

Parameters

string $name
null $label
bool $required
string $defaultCurrency
bool $freezeCurrency
bool $setDefaultCurrency

in CRM_Core_Form at line 1845
HTML_QuickForm_Element addEntityRef(string $name, string $label = '', array $props = array(), bool $required = FALSE)

Create a single or multiple entity ref field.

Parameters

string $name
string $label
array $props Mix of html and widget properties, including:. - select - params to give to select2 widget - entity - defaults to contact - create - can the user create a new entity on-the-fly? Set to TRUE if entity is contact and you want the default profiles, or pass in your own set of links. see CRM_Core_BAO_UFGroup::getCreateLinks for format note that permissions are checked automatically - api - array of settings for the getlist api wrapper note that it accepts a 'params' setting which will be passed to the underlying api - placeholder - string - multiple - bool - class, etc. - other html properties
bool $required

Return Value

HTML_QuickForm_Element

in CRM_Core_Form at line 1894
convertDateFieldsToMySQL(array $params)

Convert all date fields within the params to mysql date ready for the BAO layer. In this case fields are checked against the $_datefields defined for the form and if time is defined it is incorporated

Parameters

array $params Input params from the form.

in CRM_Core_Form at line 1914
removeFileRequiredRules($elementName)

Parameters

$elementName

in CRM_Core_Form at line 1932
cancelAction()

Function that can be defined in Form to override or.

perform specific action on cancel action

in CRM_Core_Form at line 1944
static validateMandatoryFields(array $fields, array $values, array $errors)

Helper function to verify that required fields have been filled.

Typically called within the scope of a FormRule function

Parameters

array $fields
array $values
array $errors

in CRM_Core_Form at line 1963
protected NULL|int setContactID()

Get contact if for a form object. Prioritise - cid in URL if 0 (on behalf on someoneelse) (@todo consider setting a variable if onbehalf for clarity of downstream 'if's - logged in user id if it matches the one in the cid in the URL - contact id validated from a checksum from a checksum - cid from the url if the caller has ACL permission to view - fallback is logged in user (or ? NULL if no logged in user) (@todo wouldn't 0 be more intuitive?)

Return Value

NULL|int

in CRM_Core_Form at line 2018
int|NULL getContactID()

Get the contact id that the form is being submitted for.

Return Value

int|NULL

in CRM_Core_Form at line 2025
getLoggedInUserContactID()

Get the contact id of the logged in user.

in CRM_Core_Form at line 2054
addAutoSelector(array $profiles = array(), array $autoCompleteField = array())

Add autoselector field -if user has permission to view contacts If adding this to a form you also need to add to the tpl e.g

{if !empty($selectable)}

{$form.select_contact.label}
{$form.select_contact.html}

{/if}

Parameters

array $profiles Ids of profiles that are on the form (to be autofilled).
array $autoCompleteField
  • name_field
    • id_field
    • url (for ajax lookup)

in CRM_Core_Form at line 2079
canUseAjaxContactLookups()

in CRM_Core_Form at line 2097
addCIDZeroOptions($onlinePaymentProcessorEnabled)

Add the options appropriate to cid = zero - ie. autocomplete

Parameters

$onlinePaymentProcessorEnabled

in CRM_Core_Form at line 2123
array getProfileDefaults(mixed $profile_id = 'Billing', int $contactID = NULL)

Set default values on form for given contact (or no contact defaults)

Parameters

mixed $profile_id (can be id, or profile name).
int $contactID

Return Value

array

in CRM_Core_Form at line 2142
preventAjaxSubmit()

Sets form attribute.

See also

CRM.loadForm

in CRM_Core_Form at line 2150
allowAjaxSubmit()

Sets form attribute.

See also

CRM.loadForm

in CRM_Core_Form at line 2158
setPageTitle(string $entityLabel)

Sets page title based on entity and action.

Parameters

string $entityLabel

in CRM_Core_Form at line 2187
HTML_QuickForm_Element addChainSelect(string $elementName, array $settings = array())

Create a chain-select target field. All settings are optional; the defaults usually work.

Parameters

string $elementName
array $settings

Return Value

HTML_QuickForm_Element

in CRM_Core_Form at line 2222
addTaskMenu(array $tasks)

Add actions menu to results form.

Parameters

array $tasks

in CRM_Core_Form at line 2337
string assignBillingName(array $params = array())

Assign billing name to the template.

Parameters

array $params Form input params, default to $this->_params.

Return Value

string

assignToTemplate()

Assign the minimal set of variables to the template.

buildCustom(int $id, string $name, bool $viewOnly = FALSE, null $profileContactType = NULL, array $fieldTypes = NULL)

Add the custom fields.

Parameters

int $id
string $name
bool $viewOnly
null $profileContactType
array $fieldTypes

buildComponentForm(int $id, CRM_Core_Form $form)

Add onbehalf/honoree profile fields and native module fields.

Parameters

int $id
CRM_Core_Form $form

null|string checkTemplateFileExists(string $suffix = NULL)

Check template file exists.

Parameters

string $suffix

Return Value

null|string

authenticatePledgeUser()

Authenticate pledge user during online payment.

cancelRecurring()

Cancel recurring contributions.

In case user cancel recurring contribution, When we get the control back from payment gate way lets delete the recurring and related contribution.

protected bool buildMembershipBlock(int $cid, bool $isContributionMainPage = FALSE, int $selectedMembershipTypeID = NULL, bool $thankPage = FALSE, null $isTest = NULL)

Build Membership Block in Contribution Pages.

Parameters

int $cid Contact checked for having a current membership for a particular membership.
bool $isContributionMainPage Is this the main page? If so add form input fields. (or better yet don't have this functionality in a function shared with forms that don't share it).
int $selectedMembershipTypeID Selected membership id.
bool $thankPage Thank you page.
null $isTest

Return Value

bool Is this a separate membership payment

protected setRecurringMembershipParams()

Determine if recurring parameters need to be added to the form parameters.

  • is_recur
    • frequency_interval
    • frequency_unit

For membership this is based on the membership type.

This needs to be done before processing the pre-approval redirect where relevant on the main page or before any payment processing.

Arguably the form should start to build $this->_params in the pre-process main page & use that array consistently throughout.

at line 63
static mixed handlePledge($form, $params, $contributionParams, $pledgeID, $contribution, $isEmailReceipt)

Parameters

$form
$params
$contributionParams
$pledgeID
$contribution
$isEmailReceipt

Return Value

mixed

at line 169
static array getContributionParams(array $params, int $financialTypeID, float $nonDeductibleAmount, bool $pending, array $paymentProcessorOutcome, string $receiptDate, int $recurringContributionID)

Set the parameters to be passed to contribution create function.

Parameters

array $params
int $financialTypeID
float $nonDeductibleAmount
bool $pending
array $paymentProcessorOutcome
string $receiptDate
int $recurringContributionID

Return Value

array

at line 242
static protected array getNonDeductibleAmount(array $params, CRM_Financial_BAO_FinancialType $financialType, bool $online, CRM_Contribute_Form_Contribution_Confirm $form)

Get non-deductible amount.

This is a bit too much about wierd form interpretation to be this deep.

CRM-11885 if non_deductible_amount exists i.e. Additional Details fieldset was opened [and staff typed something] -> keep it.

Parameters

array $params
CRM_Financial_BAO_FinancialType $financialType
bool $online
CRM_Contribute_Form_Contribution_Confirm $form

Return Value

array

at line 741
null|string wrangleFinancialTypeID(int $contributionTypeId)

Wrangle financial type ID.

This wrangling of the financialType ID was happening in a shared function rather than in the form it relates to & hence has been moved to that form Pledges are not relevant to the membership code so that portion will not go onto the membership form.

Comments from previous refactor indicate doubt as to what was going on.

Parameters

int $contributionTypeId

Return Value

null|string

at line 760
protected postProcessPremium(array $premiumParams, CRM_Contribute_BAO_Contribution $contribution)

Process the form.

Parameters

array $premiumParams
CRM_Contribute_BAO_Contribution $contribution

at line 907
static CRM_Contribute_DAO_Contribution processFormContribution(CRM_Core_Form $form, array $params, array $result, array $contributionParams, CRM_Financial_DAO_FinancialType $financialType, bool $online, int $billingLocationID, bool $isRecur)

Process the contribution.

Parameters

CRM_Core_Form $form
array $params
array $result
array $contributionParams Parameters to be passed to contribution create action. This differs from params in that we are currently adding params to it and 1) ensuring they are being passed consistently & 2) documenting them here. - contact_id - line_item - is_test - campaign_id - contribution_page_id - source - payment_type_id - thankyou_date (not all forms will set this)
CRM_Financial_DAO_FinancialType $financialType
bool $online Is the form a front end form? If so set a bunch of unpredictable things that should be passed in from the form.
int $billingLocationID ID of billing location type.
bool $isRecur Is this recurring?

Return Value

CRM_Contribute_DAO_Contribution

Exceptions

Exception

at line 1075
static int|null processRecurringContribution(CRM_Core_Form $form, array $params, int $contactID, string $contributionType)

Create the recurring contribution record.

Parameters

CRM_Core_Form $form
array $params
int $contactID
string $contributionType

Return Value

int|null

at line 1166
static processOnBehalfOrganization(array $behalfOrganization, int $contactID, array $values, array $params, array $fields = NULL)

Add on behalf of organization and it's location.

This situation occurs when on behalf of is enabled for the contribution page and the person signing up does so on behalf of an organization.

Parameters

array $behalfOrganization array of organization info.
int $contactID individual contact id. One. who is doing the process of signup / contribution.
array $values form values array.
array $params
array $fields Array of fields from the onbehalf profile relevant to the organization.

at line 1272
static pcpNotifyOwner(object $contribution, object $contributionSoft)

Function used to send notification mail to pcp owner.

This is used by contribution and also event PCPs.

Parameters

object $contribution
object $contributionSoft Contribution object.

at line 1332
static array processPcp(CRM_Core_Form $page, array $params)

Function used to se pcp related defaults / params.

This is used by contribution and also event PCPs

Parameters

CRM_Core_Form $page Form object.
array $params

Return Value

array

at line 1367
protected processMembership(array $membershipParams, int $contactID, array $customFieldsFormatted, array $fieldTypes, array $premiumParams, array $membershipLineItems)

Process membership.

Parameters

array $membershipParams
int $contactID
array $customFieldsFormatted
array $fieldTypes
array $premiumParams
array $membershipLineItems Line items specifically relating to memberships.

at line 1437
protected postProcessMembership(array $membershipParams, int $contactID, CRM_Contribute_Form_Contribution_Confirm $form, array $premiumParams, null $customFieldsFormatted = NULL, null $includeFieldTypes = NULL, array $membershipDetails, array $membershipTypeIDs, bool $isPaidMembership, array $membershipID, bool $isProcessSeparateMembershipTransaction, int $financialTypeID, array $unprocessedLineItems, bool $isPending)

Process the Memberships.

Parameters

array $membershipParams Array of membership fields.
int $contactID Contact id.
CRM_Contribute_Form_Contribution_Confirm $form Confirmation form object.
array $premiumParams
null $customFieldsFormatted
null $includeFieldTypes
array $membershipDetails
array $membershipTypeIDs
bool $isPaidMembership
array $membershipID
bool $isProcessSeparateMembershipTransaction
int $financialTypeID
array $unprocessedLineItems Line items for payment options chosen on the form.
bool $isPending

Exceptions

CRM_Core_Exception

at line 1702
protected string compileErrorMessage(array $errors)

Turn array of errors into message string.

Parameters

array $errors

Return Value

string

at line 1726
protected CRM_Contribute_BAO_Contribution processSecondaryFinancialTransaction(int $contactID, CRM_Contribute_Form_Contribution_Confirm $form, array $tempParams, bool $isTest, array $lineItems, $minimumFee, int $financialTypeID)

Where a second separate financial transaction is supported we will process it here.

Parameters

int $contactID
CRM_Contribute_Form_Contribution_Confirm $form
array $tempParams
bool $isTest
array $lineItems
$minimumFee
int $financialTypeID

Return Value

CRM_Contribute_BAO_Contribution

Exceptions

CRM_Core_Exception
Exception

at line 1825
protected bool getIsPending()

Is the payment a pending payment.

We are moving towards always creating as pending and updating at the end (based on payment), so this should be an interim refactoring. It was shared with another unrelated form & some parameters may not apply to this form.

Return Value

bool

at line 1851
bool isSeparateMembershipTransaction(int $formID, bool $amountBlockActiveOnForm)

Are we going to do 2 financial transactions.

Ie the membership block supports a separate transactions AND the contribution form has been configured for a contribution transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style)

Parameters

int $formID
bool $amountBlockActiveOnForm

Return Value

bool

at line 1869
setFormAmountFields(int $priceSetID)

This function sets the fields.

  • $this->_params['amount_level']
  • $this->_params['selectMembership'] And under certain circumstances sets $this->_params['amount'] = null;

Parameters

int $priceSetID

at line 1934
static submit(array $params)

Submit function.

Parameters

array $params

Exceptions

CiviCRM_API3_Exception

at line 2009
static array getFormParams(int $id, array $params)

Helper function for static submit function.

Set relevant params - help us to build up an array that we can pass in.

Parameters

int $id
array $params

Return Value

array

Exceptions

CiviCRM_API3_Exception

at line 2036
protected array processFormSubmission(int $contactID)

Post form submission handling.

This is also called from the test suite.

Parameters

int $contactID

Return Value

array

at line 2343
protected doMembershipProcessing(int $contactID, array $membershipParams, array $premiumParams, array $formLineItems)

Membership processing section.

This is in a separate function as part of a move towards refactoring.

Parameters

int $contactID
array $membershipParams
array $premiumParams
array $formLineItems

at line 2452
protected completeTransaction(array $result, int $contributionID)

Complete transaction if payment has been processed.

Check the result for a success outcome & if paid then complete the transaction.

Completing will trigger update of related entities and emails.

Parameters

array $result
int $contributionID

Exceptions

CiviCRM_API3_Exception
Exception