本文整理汇总了PHP中CRM_Campaign_BAO_Campaign::isCampaignEnable方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Campaign::isCampaignEnable方法的具体用法?PHP CRM_Campaign_BAO_Campaign::isCampaignEnable怎么用?PHP CRM_Campaign_BAO_Campaign::isCampaignEnable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Campaign
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Campaign::isCampaignEnable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildProfile
//.........这里部分代码省略.........
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'financial_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('In Progress', 'Overdue', 'Refunded') as $suppress) {
unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', $name, $title, array('' => ts('- select -')) + $contributionStatuses, $required);
} elseif ($fieldName == 'soft_credit_type') {
$name = "soft_credit_type[{$rowNumber}]";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_OptionGroup::values("soft_credit_type"));
//CRM-15350: choose SCT field default value as 'Gift' for membership use
//else (for contribution), use configured SCT default value
$SCTDefaultValue = CRM_Core_OptionGroup::getDefaultValue("soft_credit_type");
if ($field['field_type'] == 'Membership') {
$SCTDefaultValue = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
$form->addElement('hidden', 'sct_default_id', $SCTDefaultValue, array('id' => 'sct_default_id'));
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
} elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required);
} elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required);
} elseif ($fieldName == 'participant_role') {
if (!empty($field['is_multiple'])) {
$form->addCheckBox($name, $title, CRM_Event_PseudoConstant::participantRole(), NULL, NULL, NULL, NULL, ' ', TRUE);
} else {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);
}
} elseif ($fieldName == 'world_region') {
$form->add('select', $name, $title, CRM_Core_PseudoConstant::worldRegion(), $required, $selectAttributes);
} elseif ($fieldName == 'signature_html') {
$form->add('wysiwyg', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif ($fieldName == 'signature_text') {
$form->add('textarea', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif (substr($fieldName, -11) == 'campaign_id') {
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value($contactId, $form->_componentCampaigns));
$form->add('select', $name, $title, array('' => ts('- select -')) + $campaigns, $required, 'class="crm-select2 big"');
}
} elseif ($fieldName == 'activity_details') {
$form->add('wysiwyg', $fieldName, $title, array('rows' => 4, 'cols' => 60), $required);
} elseif ($fieldName == 'activity_duration') {
$form->add('text', $name, $title, $attributes, $required);
$form->addRule($name, ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
} else {
if (substr($fieldName, 0, 3) === 'is_' or substr($fieldName, 0, 7) === 'do_not_') {
$form->add('advcheckbox', $name, $title, $attributes, $required);
} else {
$form->add('text', $name, $title, $attributes, $required);
}
}
static $hiddenSubtype = FALSE;
if (!$hiddenSubtype && CRM_Contact_BAO_ContactType::isaSubType($field['field_type'])) {
// In registration mode params are submitted via POST and we don't have any clue
// about profile-id or the profile-type (which could be a subtype)
// To generalize the behavior and simplify the process,
// lets always add the hidden
//subtype value if there is any, and we won't have to
// compute it while processing.
if ($usedFor) {
$form->addElement('hidden', $usedFor . '[contact_sub_type]', $field['field_type']);
} else {
$form->addElement('hidden', 'contact_sub_type_hidden', $field['field_type']);
}
$hiddenSubtype = TRUE;
}
if ($view && $mode != CRM_Profile_Form::MODE_SEARCH || $isShared) {
$form->freeze($name);
}
//add the rules
if (in_array($fieldName, array('non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) {
$form->addRule($name, ts('Please enter a valid amount.'), 'money');
}
if ($rule) {
if (!($rule == 'email' && $mode == CRM_Profile_Form::MODE_SEARCH)) {
$form->addRule($name, ts('Please enter a valid %1', array(1 => $title)), $rule);
}
}
}
示例2: buildQuickForm
public function buildQuickForm()
{
if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
$button = ts('Delete');
if ($this->_action & CRM_Core_Action::RENEW) {
$button = ts('Restore');
}
$this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
// Build other activity links.
CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
// Enable form element (ActivityLinks sets this true).
$this->assign('suppressForm', FALSE);
$element =& $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required'));
// Freeze for update mode.
if ($this->_action & CRM_Core_Action::UPDATE) {
$element->freeze();
}
// Call to RecurringEntity buildQuickForm for add/update mode.
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
CRM_Core_Form_RecurringEntity::buildQuickForm($this);
}
foreach ($this->_fields as $field => $values) {
if (!empty($this->_fields[$field])) {
$attribute = CRM_Utils_Array::value('attributes', $values);
$required = !empty($values['required']);
if ($values['type'] == 'select' && empty($attribute)) {
$this->addSelect($field, array('entity' => 'activity'), $required);
} elseif ($values['type'] == 'entityRef') {
$this->addEntityRef($field, $values['label'], $attribute, $required);
} else {
$this->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values));
}
}
}
// CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
// Add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$this->addSelect('engagement_level', array('entity' => 'activity'));
$this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
}
$this->assign('buildEngagementLevel', $buildEngagementLevel);
// check for survey activity
$this->_isSurveyActivity = FALSE;
if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
if ($this->_isSurveyActivity) {
$surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
$responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
if ($responseOptions) {
$this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
}
$surveyTitle = NULL;
if ($surveyId) {
$surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
}
$this->assign('surveyTitle', $surveyTitle);
}
}
$this->assign('surveyActivity', $this->_isSurveyActivity);
// this option should be available only during add mode
if ($this->_action != CRM_Core_Action::UPDATE) {
$this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
}
$this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
$this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
// Add followup date.
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
// Only admins and case-workers can change the activity source
if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') {
$this->getElement('source_contact_id')->freeze();
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Activity');
$this->assign('customDataSubType', $this->_activityTypeId);
$this->assign('entityID', $this->_activityId);
CRM_Core_BAO_Tag::getTags('civicrm_activity', $tags, NULL, ' ', TRUE);
if (!empty($tags)) {
$this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge'));
}
// we need to hide activity tagset for special activities
$specialActivities = array('Open Case');
if (!in_array($this->_activityTypeName, $specialActivities)) {
// build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId);
}
// if we're viewing, we're assigning different buttons than for adding/editing
if ($this->_action & CRM_Core_Action::VIEW) {
if (isset($this->_groupTree)) {
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
}
// form should be frozen for view mode
$this->freeze();
//.........这里部分代码省略.........
示例3: buildSearchForm
/**
* Add all the elements shared between case activity search and advanced search.
*
*
* @param CRM_Core_Form $form
* @return void
*/
public static function buildSearchForm(&$form)
{
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$form->addSelect('activity_type_id', array('entity' => 'activity', 'label' => 'Activity Type(s)', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
$followUpActivity = array(1 => ts('Yes'), 2 => ts('No'));
$form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
$form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
$activityRoles = array(3 => ts('With'), 2 => ts('Assigned to'), 1 => ts('Added by'));
$form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
$form->setDefaults(array('activity_role' => 3));
$activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name'));
$form->addSelect('status_id', array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
$form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled'])));
$form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$form->addYesNo('activity_test', ts('Activity is a Test?'));
$activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
if ($activity_tags) {
foreach ($activity_tags as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
}
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
$surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
if ($surveys) {
$form->add('select', 'activity_survey_id', ts('Survey / Petition'), array('' => ts('- none -')) + $surveys, FALSE, array('class' => 'crm-select2'));
}
$extends = array('Activity');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('activityGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
//add engagement level CRM-7775
$buildEngagementLevel = FALSE;
$buildSurveyResult = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search'));
// Add survey result field.
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
$resultOptions = array();
foreach ($optionGroups as $gid => $name) {
if ($name) {
$value = array();
$value = CRM_Core_OptionGroup::values($name);
if (!empty($value)) {
while (list($k, $v) = each($value)) {
$resultOptions[$v] = $v;
}
}
}
}
// If no survey result options have been created, don't build
// the field to avoid clutter.
if (count($resultOptions) > 0) {
$buildSurveyResult = TRUE;
asort($resultOptions);
$form->add('select', 'activity_result', ts("Survey Result"), $resultOptions, FALSE, array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2'));
}
}
$form->assign('buildEngagementLevel', $buildEngagementLevel);
$form->assign('buildSurveyResult', $buildSurveyResult);
$form->setDefaults(array('activity_test' => 0));
}
示例4: elseif
/**
* Returns the column headers as an array of tuples:
* (name, sortName (key to the sort array))
*
* @param string $action
* The action being performed.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return array
* the column headers that need to be displayed
*/
public function &getColumnHeaders($action = NULL, $output = NULL)
{
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$job = CRM_Mailing_BAO_MailingJob::getTableName();
if (!isset(self::$_columnHeaders)) {
$completedOrder = NULL;
// Set different default sort depending on type of mailings (CRM-7652)
$unscheduledOrder = $scheduledOrder = $archivedOrder = CRM_Utils_Sort::DONTCARE;
if ($this->_parent->get('unscheduled')) {
$unscheduledOrder = CRM_Utils_Sort::DESCENDING;
} elseif ($this->_parent->get('scheduled')) {
$scheduledOrder = CRM_Utils_Sort::DESCENDING;
} else {
// sort by completed date for archived and undefined get
$completedOrder = CRM_Utils_Sort::DESCENDING;
}
$nameHeaderLabel = $this->_parent->get('sms') ? ts('SMS Name') : ts('Mailing Name');
self::$_columnHeaders = array(array('name' => $nameHeaderLabel, 'sort' => 'name', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Status'), 'sort' => 'status', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Created By'), 'sort' => 'created_by', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Created Date'), 'sort' => 'created_date', 'direction' => $unscheduledOrder), array('name' => ts('Sent By'), 'sort' => 'scheduled_by', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Scheduled'), 'sort' => 'scheduled_date', 'direction' => $scheduledOrder), array('name' => ts('Started'), 'sort' => 'start_date', 'direction' => CRM_Utils_Sort::DONTCARE), array('name' => ts('Completed'), 'sort' => 'end_date', 'direction' => $completedOrder));
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
self::$_columnHeaders[] = array('name' => ts('Campaign'), 'sort' => 'campaign_id', 'direction' => CRM_Utils_Sort::DONTCARE);
}
if ($output != CRM_Core_Selector_Controller::EXPORT) {
self::$_columnHeaders[] = array('name' => ts('Action'));
}
}
return self::$_columnHeaders;
}
示例5: buildProfile
//.........这里部分代码省略.........
} elseif ($fieldName == 'soft_credit') {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, 'soft_credit_');
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} elseif ($fieldName == 'contribution_type') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
} elseif ($fieldName == 'contribution_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionStatus(), $required);
} elseif ($fieldName == 'currency') {
$form->addCurrency($name, $title, $required);
} elseif ($fieldName == 'contribution_page_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"');
} elseif ($fieldName == 'participant_register_date') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'activity_status_id') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::activityStatus(), $required);
} elseif ($fieldName == 'activity_engagement_level') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel(), $required);
} elseif ($fieldName == 'activity_date_time') {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'participant_status') {
$cond = NULL;
if ($online == TRUE) {
$cond = 'visibility_id = 1';
}
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantStatus(NULL, $cond, 'label'), $required);
} elseif ($fieldName == 'participant_role') {
if (CRM_Utils_Array::value('is_multiple', $field)) {
$form->addCheckBox($name, $title, CRM_Event_PseudoConstant::participantRole(), NULL, NULL, NULL, NULL, ' ', TRUE);
} else {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Event_PseudoConstant::participantRole(), $required);
}
} elseif ($fieldName == 'scholarship_type_id') {
$form->add('select', $name, $title, array('' => '-- Select -- ') + array_flip(CRM_Core_OptionGroup::values('scholarship_type', TRUE)));
} elseif ($fieldName == 'applicant_status_id') {
$form->add('select', $name, $title, array('' => '-- Select -- ') + array_flip(CRM_Core_OptionGroup::values('applicant_status', TRUE)));
} elseif ($fieldName == 'highschool_gpa_id') {
$form->add('select', $name, $title, array('' => '-- Select -- ') + CRM_Core_OptionGroup::values('highschool_gpa'));
} elseif ($fieldName == 'world_region') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::worldRegion(), $required);
} elseif ($fieldName == 'signature_html') {
$form->addWysiwyg($name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif ($fieldName == 'signature_text') {
$form->add('textarea', $name, $title, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', $fieldName));
} elseif (substr($fieldName, -11) == 'campaign_id') {
if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value($contactId, $form->_componentCampaigns));
$campaign =& $form->add('select', $name, $title, array('' => ts('- select -')) + $campaigns, $required, 'class="big"');
}
} elseif ($fieldName == 'activity_details') {
$form->addWysiwyg($fieldName, $title, array('rows' => 4, 'cols' => 60), $required);
} elseif ($fieldName == 'activity_duration') {
$form->add('text', $fieldName, $title, $attributes, $required);
$form->addRule($name, ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
} else {
$processed = FALSE;
if (CRM_Core_Permission::access('Quest', FALSE)) {
$processed = CRM_Quest_BAO_Student::buildStudentForm($form, $fieldName, $title, $contactId);
}
if (!$processed) {
if (substr($fieldName, 0, 3) === 'is_' or substr($fieldName, 0, 7) === 'do_not_') {
$form->add('advcheckbox', $name, $title, $attributes, $required);
} else {
$form->add('text', $name, $title, $attributes, $required);
}
}
}
static $hiddenSubtype = FALSE;
if (!$hiddenSubtype && CRM_Contact_BAO_ContactType::isaSubType($field['field_type'])) {
// In registration mode params are submitted via POST and we don't have any clue
// about profile-id or the profile-type (which could be a subtype)
// To generalize the behavior and simplify the process,
// lets always add the hidden
//subtype value if there is any, and we won't have to
// compute it while processing.
if ($onBehalf) {
$form->addElement('hidden', 'onbehalf[contact_sub_type]', $field['field_type']);
} else {
$form->addElement('hidden', 'contact_sub_type_hidden', $field['field_type']);
}
$hiddenSubtype = TRUE;
}
if ($view && $mode != CRM_Profile_Form::MODE_SEARCH || $isShared) {
$form->freeze($name);
}
//add the rules
if (in_array($fieldName, array('non_deductible_amount', 'total_amount', 'fee_amount', 'net_amount'))) {
$form->addRule($name, ts('Please enter a valid amount.'), 'money');
}
if ($rule) {
if (!($rule == 'email' && $mode == CRM_Profile_Form::MODE_SEARCH)) {
$form->addRule($name, ts('Please enter a valid %1', array(1 => $title)), $rule);
}
}
}
示例6: buildQuickForm
public function buildQuickForm()
{
if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
$button = ts('Delete');
if ($this->_action & CRM_Core_Action::RENEW) {
$button = ts('Restore');
}
$this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if (!$this->_single && !empty($this->_contactIds)) {
$withArray = array();
foreach ($this->_contactIds as $contactId) {
$withDisplayName = self::_getDisplayNameById($contactId);
$withArray[] = "\"{$withDisplayName}\" ";
}
$this->assign('with', implode(', ', $withArray));
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//build other activity links
CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
$element =& $this->add('select', 'activity_type_id', ts('Activity Type'), $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );"));
//freeze for update mode.
if ($this->_action & CRM_Core_Action::UPDATE) {
$element->freeze();
}
foreach ($this->_fields as $field => $values) {
if (CRM_Utils_Array::value($field, $this->_fields)) {
$attribute = NULL;
if (CRM_Utils_Array::value('attributes', $values)) {
$attribute = $values['attributes'];
}
$required = FALSE;
if (CRM_Utils_Array::value('required', $values)) {
$required = TRUE;
}
if ($values['type'] == 'wysiwyg') {
$this->addWysiwyg($field, $values['label'], $attribute, $required);
} else {
$this->add($values['type'], $field, $values['label'], $attribute, $required);
}
}
}
//CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
//add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$this->add('select', 'engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
$this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
}
$this->assign('buildEngagementLevel', $buildEngagementLevel);
// check for survey activity
$this->_isSurveyActivity = FALSE;
if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
if ($this->_isSurveyActivity) {
$surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
$responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
if ($responseOptions) {
$this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
}
$surveyTitle = NULL;
if ($surveyId) {
$surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
}
$this->assign('surveyTitle', $surveyTitle);
}
}
$this->assign('surveyActivity', $this->_isSurveyActivity);
// this option should be available only during add mode
if ($this->_action != CRM_Core_Action::UPDATE) {
$this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
}
$this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
$this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
//add followup date
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
//autocomplete url
$dataUrl = CRM_Utils_System::url("civicrm/ajax/rest", "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=activity&reset=1", FALSE, NULL, FALSE);
$this->assign('dataUrl', $dataUrl);
//tokeninput url
$tokenUrl = CRM_Utils_System::url("civicrm/ajax/checkemail", "noemail=1", FALSE, NULL, FALSE);
$this->assign('tokenUrl', $tokenUrl);
$admin = CRM_Core_Permission::check('administer CiviCRM');
//allow to edit source contact field field if context is civicase.
if ($this->_context == 'caseActivity') {
$admin = TRUE;
}
$this->assign('admin', $admin);
$sourceContactField =& $this->add($this->_fields['source_contact_id']['type'], 'source_contact_id', $this->_fields['source_contact_id']['label'], NULL, $admin);
$this->add('hidden', 'source_contact_qid', '', array('id' => 'source_contact_qid'));
CRM_Contact_Form_NewContact::buildQuickForm($this);
//.........这里部分代码省略.........
示例7: buildSearchForm
/**
* add all the elements shared between case activity search and advanaced search
*
* @access public
*
* @return void
* @static
*/
static function buildSearchForm(&$form)
{
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
asort($activityOptions);
foreach ($activityOptions as $activityID => $activity) {
$form->_activityElement =& $form->addElement('checkbox', "activity_type_id[{$activityID}]", NULL, $activity, array('onClick' => 'showCustomData( this.id );'));
}
CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
$activityRoles = array(1 => ts('Created by'), 2 => ts('Assigned to'));
$form->addRadio('activity_role', NULL, $activityRoles, NULL, '<br />');
$form->addElement('text', 'activity_contact_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
foreach ($activityStatus as $activityStatusID => $activityStatusName) {
$activity_status[] = $form->createElement('checkbox', $activityStatusID, NULL, $activityStatusName);
}
$form->addGroup($activity_status, 'activity_status', ts('Activity Status'));
$form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1));
$form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$form->addElement('checkbox', 'activity_test', ts('Find Test Activities?'));
$activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
if ($activity_tags) {
foreach ($activity_tags as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
}
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE);
$surveys = CRM_Campaign_BAO_Survey::getSurveys();
if ($surveys) {
$form->add('select', 'activity_survey_id', ts('Survey'), array('' => ts('- none -')) + $surveys, FALSE);
}
$extends = array('Activity');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('activityGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
//add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$form->add('select', 'activity_engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
}
$form->assign('buildEngagementLevel', $buildEngagementLevel);
}