function __construct() { static $_events; if (!isset($_events['all'])) { CRM_Core_PseudoConstant::populate($_events['all'], 'CRM_Event_DAO_Event', FALSE, 'title', 'is_active', "is_template IS NULL OR is_template = 0", 'end_date DESC'); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name_linked' => array('title' => ts('Participant Name'), 'required' => TRUE, 'no_repeat' => TRUE, 'dbAlias' => 'contact_civireport.sort_name'), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'employer_id' => array('title' => ts('Organization'))), 'grouping' => 'contact-fields', 'filters' => array('sort_name' => array('title' => ts('Participant Name'), 'operator' => 'like')), 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => TRUE)), 'grouping' => 'contact-fields', 'filters' => array('email' => array('title' => ts('Participant E-mail'), 'operator' => 'like'))), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'fields' => array('street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'))), 'grouping' => 'contact-fields'), 'civicrm_participant' => array('dao' => 'CRM_Event_DAO_Participant', 'fields' => array('participant_id' => array('title' => 'Participant ID'), 'participant_record' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE), 'event_id' => array('default' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'status_id' => array('title' => ts('Status'), 'default' => TRUE), 'role_id' => array('title' => ts('Role'), 'default' => TRUE), 'participant_fee_level' => NULL, 'participant_fee_amount' => NULL, 'participant_register_date' => array('title' => ts('Registration Date'))), 'grouping' => 'event-fields', 'filters' => array('event_id' => array('name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $_events['all']), 'sid' => array('name' => 'status_id', 'title' => ts('Participant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label')), 'rid' => array('name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole()), 'participant_register_date' => array('title' => ' Registration Date', 'operatorType' => CRM_Report_Form::OP_DATE)), 'order_bys' => array('event_id' => array('title' => ts('Event'), 'default_weight' => '1', 'default_order' => 'ASC'))), 'civicrm_event' => array('dao' => 'CRM_Event_DAO_Event', 'fields' => array('event_type_id' => array('title' => ts('Event Type'))), 'grouping' => 'event-fields', 'filters' => array('eid' => array('name' => 'event_type_id', 'title' => ts('Event Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'))), 'order_bys' => array('event_type_id' => array('title' => ts('Event Type'), 'default_weight' => '2', 'default_order' => 'ASC')))); $this->_options = array('blank_column_begin' => array('title' => ts('Blank column at the Begining'), 'type' => 'checkbox'), 'blank_column_end' => array('title' => ts('Blank column at the End'), 'type' => 'select', 'options' => array('' => '-select-', 1 => ts('One'), 2 => ts('Two'), 3 => ts('Three')))); parent::__construct(); }
static function recordBounce($params) { $isSpam = CRM_Utils_Array::value('is_spam', $params); $mailingId = CRM_Utils_Array::value('mailing_id', $params); //CiviCRM mailling ID $contactId = CRM_Utils_Array::value('contact_id', $params); $emailId = CRM_Utils_Array::value('email_id', $params); $email = CRM_Utils_Array::value('email', $params); $jobId = CRM_Utils_Array::value('job_id', $params); $eqParams = array('job_id' => $jobId, 'contact_id' => $contactId, 'email_id' => $emailId); $eventQueue = CRM_Mailing_Event_BAO_Queue::create($eqParams); $time = date('YmdHis', CRM_Utils_Array::value('date_ts', $params)); $bounceType = array(); CRM_Core_PseudoConstant::populate($bounceType, 'CRM_Mailing_DAO_BounceType', TRUE, 'id', NULL, NULL, NULL, 'name'); $bounce = new CRM_Mailing_Event_BAO_Bounce(); $bounce->time_stamp = $time; $bounce->event_queue_id = $eventQueue->id; if ($isSpam) { $bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::SPAM]; $bounce->bounce_reason = CRM_Utils_Array::value('source', $params); //bounce reason when spam occured } else { $hardBounce = CRM_Utils_Array::value('hard_bounce', $params); $blocked = CRM_Utils_Array::value('blocked', $params); // blocked : true if this bounce leads to recipient being blocked if ($hardBounce && $blocked) { $bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::BLOCKED]; } elseif ($hardBounce && !$blocked) { $bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::HARD_BOUNCE]; } else { $bounce->bounce_type_id = $bounceType[CRM_Mailjet_Upgrader::SOFT_BOUNCE]; } $bounce->bounce_reason = $params['error_related_to'] . " - " . $params['error']; } $bounce->save(); if ($bounce->bounce_type_id != $bounceType[CRM_Mailjet_Upgrader::SOFT_BOUNCE]) { $params = array('id' => $contactId, 'do_not_email' => 1); civicrm_api3('Contact', 'create', $params); } return TRUE; }
function alterRow(&$row) { foreach ($this->_options as $fieldID => $values) { $customVal = $valueSeparatedArray = array(); if (in_array($values['attributes']['html_type'], array('Radio', 'Select', 'Autocomplete-Select'))) { if ($values['attributes']['data_type'] == 'ContactReference' && $row["custom_{$fieldID}"]) { $row["custom_{$fieldID}"] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', (int) $row["custom_{$fieldID}"], 'display_name'); } elseif ($row["custom_{$fieldID}"] && array_key_exists($row["custom_{$fieldID}"], $values)) { $row["custom_{$fieldID}"] = $values[$row["custom_{$fieldID}"]]; } } elseif (in_array($values['attributes']['html_type'], array('CheckBox', 'Multi-Select', 'AdvMulti-Select'))) { $valueSeparatedArray = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $row["custom_{$fieldID}"])); foreach ($valueSeparatedArray as $val) { $customVal[] = $values[$val]; } $row["custom_{$fieldID}"] = implode(', ', $customVal); } elseif (in_array($values['attributes']['html_type'], array('Multi-Select State/Province', 'Select State/Province'))) { $valueSeparatedArray = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $row["custom_{$fieldID}"])); $stateName = CRM_Core_PseudoConstant::stateProvince(); foreach ($valueSeparatedArray as $val) { $customVal[] = $stateName[$val]; } $row["custom_{$fieldID}"] = implode(', ', $customVal); } elseif (in_array($values['attributes']['html_type'], array('Multi-Select Country', 'Select Country'))) { $valueSeparatedArray = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $row["custom_{$fieldID}"])); CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active'); foreach ($valueSeparatedArray as $val) { $customVal[] = $countryNames[$val]; } $row["custom_{$fieldID}"] = implode(', ', $customVal); } } }
/** * Get all the case type. * * * @param string $column * @param bool $onlyActive * * @return array * array reference of all case type */ public static function caseType($column = 'title', $onlyActive = TRUE) { if ($onlyActive) { $condition = " is_active = 1 "; } else { $condition = NULL; } $caseType = NULL; // FIXME: deprecated? CRM_Core_PseudoConstant::populate($caseType, 'CRM_Case_DAO_CaseType', TRUE, $column, '', $condition, 'weight', 'id'); return $caseType; }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { $ufGroupId = $this->get('ufGroupId'); if (!$ufGroupId) { CRM_Core_Error::fatal('ufGroupId is missing'); } $this->_title = ts('Batch Update for Events') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId); CRM_Utils_System::setTitle($this->_title); $this->addDefaultButtons(ts('Save')); $this->_fields = array(); $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW); // remove file type field and then limit fields $suppressFields = FALSE; $removehtmlTypes = array('File', 'Autocomplete-Select'); foreach ($this->_fields as $name => $field) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) { $suppressFields = TRUE; unset($this->_fields[$name]); } //fix to reduce size as we are using this field in grid if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) { //shrink class to "form-text-medium" $this->_fields[$name]['attributes']['size'] = 19; } } $this->_fields = array_slice($this->_fields, 0, $this->_maxFields); $this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Participant(s)'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); $this->assign('profileTitle', $this->_title); $this->assign('componentIds', $this->_participantIds); $fileFieldExists = FALSE; //load all campaigns. if (array_key_exists('participant_campaign_id', $this->_fields)) { $this->_componentCampaigns = array(); CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Event_DAO_Participant', TRUE, 'campaign_id', 'id', ' id IN (' . implode(' , ', array_values($this->_participantIds)) . ' ) '); } //fix for CRM-2752 // get the option value for custom data type $this->_roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name'); $this->_eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name'); // build custom data getFields array $customFieldsRole = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, $this->_roleCustomDataTypeID); $customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, $this->_eventNameCustomDataTypeID); $customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, TRUE)); $this->_customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields); foreach ($this->_participantIds as $participantId) { $roleId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participantId, 'role_id'); $eventId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $participantId, 'event_id'); foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { $customValue = CRM_Utils_Array::value($customFieldID, $this->_customFields); $entityColumnValue = array(); if (CRM_Utils_Array::value('extends_entity_column_value', $customValue)) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value']); } $entityColumnValueRole = CRM_Utils_Array::value($roleId, $entityColumnValue); if ($this->_roleCustomDataTypeID == $customValue['extends_entity_column_id'] && $entityColumnValueRole) { CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId); } elseif ($this->_eventNameCustomDataTypeID == $customValue['extends_entity_column_id'] && $eventId == $entityColumnValueRole) { CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId); } elseif (CRM_Utils_System::isNull($entityColumnValueRole)) { CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId); } } else { if ($field['name'] == 'participant_role_id') { $field['is_multiple'] = TRUE; } // handle non custom fields CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $participantId); } } } $this->assign('fields', $this->_fields); // don't set the status message when form is submitted. $buttonName = $this->controller->getButtonName('submit'); if ($suppressFields && $buttonName != '_qf_Batch_next') { CRM_Core_Session::setStatus("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update and have been excluded."); } $this->addDefaultButtons(ts('Update Participant(s)')); }
function getParticipantColumns() { static $_events = array(); if (!isset($_events['all'])) { CRM_Core_PseudoConstant::populate($_events['all'], 'CRM_Event_DAO_Event', FALSE, 'title', 'is_active', "is_template IS NULL OR is_template = 0", 'end_date DESC'); } return array('civicrm_participant' => array('dao' => 'CRM_Event_DAO_Participant', 'fields' => array('participant_id' => array('title' => 'Participant ID'), 'participant_record' => array('name' => 'id', 'title' => 'Participant Id'), 'event_id' => array('title' => ts('Event ID'), 'type' => CRM_Utils_Type::T_STRING, 'alter_display' => 'alterEventID'), 'status_id' => array('title' => ts('Status'), 'alter_display' => 'alterParticipantStatus'), 'role_id' => array('title' => ts('Role'), 'alter_display' => 'alterParticipantRole'), 'participant_fee_level' => NULL, 'participant_fee_amount' => NULL, 'participant_register_date' => array('title' => ts('Registration Date'))), 'grouping' => 'event-fields', 'filters' => array('event_id' => array('name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $_events['all']), 'sid' => array('name' => 'status_id', 'title' => ts('Participant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label')), 'rid' => array('name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole()), 'participant_register_date' => array('title' => ' Registration Date', 'operatorType' => CRM_Report_Form::OP_DATE)), 'order_bys' => array('event_id' => array('title' => ts('Event'), 'default_weight' => '1', 'default_order' => 'ASC')), 'group_bys' => array('event_id' => array('title' => ts('Event'))))); }
/** * @return array */ public static function getAvailableCountries() { $i18n = CRM_Core_I18n::singleton(); $country = array(); CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active'); $i18n->localizeArray($country, array('context' => 'country')); asort($country); return $country; }
/** * Process the form. * * @return void */ public function postProcess() { // get the submitted form values. $params = $this->controller->exportValues($this->_name); $deletePriceSet = 0; if ($params['membership_type']) { // we do this in case the user has hit the forward/back button $dao = new CRM_Member_DAO_MembershipBlock(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $this->_id; $dao->find(TRUE); $membershipID = $dao->id; if ($membershipID) { $params['id'] = $membershipID; } $membershipTypes = array(); if (is_array($params['membership_type'])) { foreach ($params['membership_type'] as $k => $v) { if ($v) { $membershipTypes[$k] = CRM_Utils_Array::value("auto_renew_{$k}", $params); } } } if ($this->_id && !empty($params['member_price_set_id'])) { CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'amount_block_is_active', 0); } // check for price set. $priceSetID = CRM_Utils_Array::value('member_price_set_id', $params); if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) { $usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 2); if (empty($params['mem_price_field_id']) && !$usedPriceSetId) { $pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245)); $setParams['title'] = $this->_values['title']; if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle, 'id', 'name')) { $setParams['name'] = $pageTitle; } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle . '_' . $this->_id, 'id', 'name')) { $setParams['name'] = $pageTitle . '_' . $this->_id; } else { $timeSec = explode(".", microtime(TRUE)); $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1]; } $setParams['is_quick_config'] = 1; $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember'); $setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values); $priceSet = CRM_Price_BAO_PriceSet::create($setParams); $priceSetID = $priceSet->id; $fieldParams['price_set_id'] = $priceSet->id; } elseif ($usedPriceSetId) { $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember'); $setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values); $setParams['id'] = $usedPriceSetId; $priceSet = CRM_Price_BAO_PriceSet::create($setParams); $priceSetID = $priceSet->id; $fieldParams['price_set_id'] = $priceSet->id; } else { $fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params); $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id'); } $editedFieldParams = array('price_set_id' => $priceSetID, 'name' => 'membership_amount'); $editedResults = array(); CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults); if (empty($editedResults['id'])) { $fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245)); if (empty($params['mem_price_field_id'])) { CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, array('price_set_id' => $priceSetID)); } $fieldParams['weight'] = 1; } else { $fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults); } $fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership'); $fieldParams['is_active'] = 1; $fieldParams['html_type'] = 'Radio'; $fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0; $fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0; $rowCount = 1; $options = array(); if (!empty($fieldParams['id'])) { CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} "); } foreach ($membershipTypes as $memType => $memAutoRenew) { if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) { $fieldParams['option_id'][$rowCount] = $priceFieldID; unset($options[$priceFieldID]); } $membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType); $fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype); $fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0); $fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype); $fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype); $fieldParams['default_option'] = CRM_Utils_Array::value('membership_type_default', $params); $fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype); $fieldParams['membership_type_id'][$rowCount] = $memType; // [$rowCount] = $membetype['']; $rowCount++; } foreach ($options as $priceFieldID => $memType) { CRM_Price_BAO_PriceFieldValue::setIsActive($priceFieldID, '0'); } $priceField = CRM_Price_BAO_PriceField::create($fieldParams); } elseif (!$priceSetID) { $deletePriceSet = 1; } $params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE); $params['is_active'] = CRM_Utils_Array::value('member_is_active', $params, FALSE); if ($priceSetID) { $params['membership_types'] = 'null'; $params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null'); $params['membership_types'] = serialize($membershipTypes); $params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, FALSE); $params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, FALSE); } $params['entity_table'] = 'civicrm_contribution_page'; $params['entity_id'] = $this->_id; $dao = new CRM_Member_DAO_MembershipBlock(); $dao->copyValues($params); $dao->save(); if ($priceSetID && $params['is_active']) { CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $this->_id, $priceSetID); } if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) { if ($this->_memPriceSetId) { $pFIDs = array(); $conditionParams = array('price_set_id' => $this->_memPriceSetId, 'html_type' => 'radio', 'name' => 'contribution_amount'); CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $conditionParams, $pFIDs); if (empty($pFIDs['id'])) { CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution_page', $this->_id); CRM_Price_BAO_PriceSet::setIsQuickConfig($this->_memPriceSetId, '0'); } else { CRM_Price_BAO_PriceField::setIsActive($params['mem_price_field_id'], '0'); } } } } parent::endPostProcess(); }
/** * get event template titles * * @return array of event id → template title pairs */ public static function &eventTemplates($id = null) { if (!self::$eventTemplates) { CRM_Core_PseudoConstant::populate(self::$eventTemplates, 'CRM_Event_DAO_Event', false, 'template_title', 'is_template'); } if ($id) { return self::$eventTemplates[$id]; } return self::$eventTemplates; }
public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Sepa Direct Debit - Settings')); $customFields = CRM_Core_BAO_CustomField::getFields(); $cf = array(); foreach ($customFields as $k => $v) { $cf[$k] = $v['label']; } // add all form elements and validation rules foreach ($this->config_fields as $key => $value) { $elementName = $this->domainToString($value[0]); $elem = $this->addElement('text', $elementName, $value[1], isset($value[2]) ? $value[2] : array()); if (!in_array($elementName, array('cycledays', 'custom_txmsg'))) { // integer only rules, except for cycledays (list) $this->addRule($this->domainToString($value[0]), sprintf(ts("Please enter the %s as number (integers only)."), $value[1]), 'positiveInteger'); $this->addRule($this->domainToString($value[0]), sprintf(ts("Please enter the %s as number (integers only)."), $value[1]), 'required'); } } // country drop down field $config = CRM_Core_Config::singleton(); $i18n = CRM_Core_I18n::singleton(); $climit = array(); $cnames = array(); $ciso = array(); $filtered = array(); $climit = $config->countryLimit(); CRM_Core_PseudoConstant::populate($cnames, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active'); CRM_Core_PseudoConstant::populate($ciso, 'CRM_Core_DAO_Country', TRUE, 'iso_code'); foreach ($ciso as $key => $value) { foreach ($climit as $active_country) { if ($active_country == $value) { $filtered[$key] = $cnames[$key]; } } } $i18n->localizeArray($filtered, array('context' => 'country')); asort($filtered); // do not use array_merge() because it discards the original indizes $country_ids = array('' => ts('- select -')) + $filtered; $exw = CRM_Core_BAO_Setting::getItem('SEPA Direct Debit Preferences', 'exclude_weekends'); if ($exw) { $exw = array('checked' => 'checked'); } else { $exw = array(); } // add creditor form elements $this->addElement('text', 'addcreditor_creditor_id', ts("Creditor Contact")); $this->addElement('text', 'addcreditor_name', ts("Name")); $this->addElement('text', 'addcreditor_id', ts("Identifier")); $this->addElement('text', 'addcreditor_address', ts("Address")); $this->addElement('select', 'addcreditor_country_id', ts("Country"), $country_ids); $this->addElement('text', 'addcreditor_bic', ts("BIC")); $this->addElement('text', 'addcreditor_iban', ts("IBAN")); $this->addElement('select', 'addcreditor_pain_version', ts("PAIN Version"), array('' => ts('- select -')) + CRM_Core_OptionGroup::values('sepa_file_format')); $this->addElement('checkbox', 'is_test_creditor', ts("Is a Test Creditor"), "", array('value' => '0')); $this->addElement('checkbox', 'exclude_weekends', ts("Exclude Weekends"), "", $exw); $this->addElement('hidden', 'edit_creditor_id', '', array('id' => 'edit_creditor_id')); $this->addElement('hidden', 'add_creditor_id', '', array('id' => 'add_creditor_id')); // add custom form elements and validation rules $index = 0; foreach ($this->custom_fields as $key => $value) { $this->addElement('text', $this->domainToString($value[0]), $value[1], array('placeholder' => CRM_Core_BAO_Setting::getItem('SEPA Direct Debit Preferences', $this->domainToString($this->config_fields[$index][0])))); $elementName = $this->domainToString($value[0]); if (!in_array($elementName, array('custom_cycledays', 'custom_txmsg'))) { // integer only rules, except for cycledays (list) $this->addRule($elementName, sprintf(ts("Please enter the %s as number (integers only)."), $value[1]), 'positiveInteger'); } $index++; } // register and add extra validation rules $this->registerRule('sepa_cycle_day_list', 'callback', 'sepa_cycle_day_list', 'CRM_Sepa_Logic_Settings'); $this->addRule('cycledays', ts('Please give a comma separated list of valid days.'), 'sepa_cycle_day_list'); $this->addRule('custom_cycledays', ts('Please give a comma separated list of valid days.'), 'sepa_cycle_day_list'); // get creditor list $creditors_default_list = array(); $creditor_query = civicrm_api('SepaCreditor', 'get', array('version' => 3, 'option.limit' => 99999)); if (!empty($creditor_query['is_error'])) { return civicrm_api3_create_error("Cannot get creditor list: " . $creditor_query['error_message']); } else { $creditors = array(); foreach ($creditor_query['values'] as $creditor) { $creditors[] = $creditor; $creditors_default_list[$creditor['id']] = $creditor['name']; } } $this->assign('creditors', $creditors); $default_creditors = $this->addElement('select', 'batching_default_creditor', ts("Default Creditor"), array('' => ts('- select -')) + $creditors_default_list); $default_creditors->setSelected(CRM_Sepa_Logic_Settings::getSetting('batching.default.creditor')); // add general config options $amm_options = CRM_Sepa_Logic_Settings::getSetting('allow_mandate_modification') ? array('checked' => 'checked') : array(); $this->addElement('checkbox', 'allow_mandate_modification', ts("Mandate Modifications"), NULL, $amm_options); parent::buildQuickForm(); }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); $this->setPageTitle(ts('Premium Product')); if ($this->_action & CRM_Core_Action::PREVIEW) { CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, $this->_id); return; } if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'name'), TRUE); $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', array('CRM_Contribute_DAO_Product', $this->_id)); $this->add('text', 'sku', ts('SKU'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'sku')); $this->add('textarea', 'description', ts('Description'), 'rows=3, cols=60'); $image['image'] = $this->createElement('radio', NULL, NULL, ts('Upload from my computer'), 'image', 'onclick="add_upload_file_block(\'image\');'); $image['thumbnail'] = $this->createElement('radio', NULL, NULL, ts('Display image and thumbnail from these locations on the web:'), 'thumbnail', 'onclick="add_upload_file_block(\'thumbnail\');'); $image['default_image'] = $this->createElement('radio', NULL, NULL, ts('Use default image'), 'default_image', 'onclick="add_upload_file_block(\'default\');'); $image['noImage'] = $this->createElement('radio', NULL, NULL, ts('Do not display an image'), 'noImage', 'onclick="add_upload_file_block(\'noImage\');'); $this->addGroup($image, 'imageOption', ts('Premium Image')); $this->addRule('imageOption', ts('Please select an option for the premium image.'), 'required'); $this->addElement('text', 'imageUrl', ts('Image URL')); $this->addElement('text', 'thumbnailUrl', ts('Thumbnail URL')); $this->add('file', 'uploadFile', ts('Image File Name'), 'onChange="select_option();"'); $this->add('text', 'price', ts('Market Value'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'price'), TRUE); $this->addRule('price', ts('Please enter the Market Value for this product.'), 'money'); $this->add('text', 'cost', ts('Actual Cost of Product'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'cost')); $this->addRule('price', ts('Please enter the Actual Cost of Product.'), 'money'); $this->add('text', 'min_contribution', ts('Minimum Contribution Amount'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'min_contribution'), TRUE); $this->addRule('min_contribution', ts('Please enter a monetary value for the Minimum Contribution Amount.'), 'money'); $this->add('textarea', 'options', ts('Options'), 'rows=3, cols=60'); $this->add('select', 'period_type', ts('Period Type'), array('' => '- select -', 'rolling' => 'Rolling', 'fixed' => 'Fixed')); $this->add('text', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'fixed_period_start_day')); $this->add('Select', 'duration_unit', ts('Duration Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits()); $this->add('text', 'duration_interval', ts('Duration'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'duration_interval')); $this->add('Select', 'frequency_unit', ts('Frequency Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits()); $this->add('text', 'frequency_interval', ts('Frequency'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'frequency_interval')); //Financial Type CRM-11106 $financialType = CRM_Contribute_PseudoConstant::financialType(); $premiumFinancialType = array(); CRM_Core_PseudoConstant::populate($premiumFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 8'); $costFinancialType = array(); CRM_Core_PseudoConstant::populate($costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 7'); $productFinancialType = array_intersect($costFinancialType, $premiumFinancialType); foreach ($financialType as $key => $financialTypeName) { if (!in_array($key, $productFinancialType)) { unset($financialType[$key]); } } if (count($financialType)) { $this->assign('financialType', $financialType); } $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialType); $this->add('checkbox', 'is_active', ts('Enabled?')); $this->addFormRule(array('CRM_Contribute_Form_ManagePremiums', 'formRule')); $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); $this->assign('productId', $this->_id); }
/** * Get all the membership statuss * * @access public * @return array - array reference of all membership statuss if any * @static */ public static function &membershipStatus($id = null, $cond = null) { if (self::$membershipStatus === null) { self::$membershipStatus = array(); } $index = $cond ? $cond : 'No Condition'; if (!CRM_Utils_Array::value($index, self::$membershipStatus)) { CRM_Core_PseudoConstant::populate(self::$membershipStatus[$index], 'CRM_Member_DAO_MembershipStatus', false, 'name', 'is_active', $cond, 'weight'); } if ($id) { if (array_key_exists($id, self::$membershipStatus[$index])) { return self::$membershipStatus[$index][$id]; } else { return null; } } return self::$membershipStatus[$index]; }
/** * Get all the completed mailing * * @access public * @return array - array reference of all mailing templates if any * @static */ public static function &completed() { if (!self::$completed) { require_once 'CRM/Mailing/BAO/Mailing.php'; $mailingACL = CRM_Mailing_BAO_Mailing::mailingACL(); CRM_Core_PseudoConstant::populate(self::$completed, 'CRM_Mailing_DAO_Mailing', false, 'name', 'is_completed', $mailingACL); } return self::$completed; }
/** * Get all the user framework groups * * @access public * @return array - array reference of all groups. * @static */ function &ufGroup() { if (!$GLOBALS['_CRM_CORE_PSEUDOCONSTANT']['ufGroup']) { CRM_Core_PseudoConstant::populate($GLOBALS['_CRM_CORE_PSEUDOCONSTANT']['ufGroup'], 'CRM_Core_DAO_UFGroup', false, 'title', 'is_active', null, 'title'); } return $GLOBALS['_CRM_CORE_PSEUDOCONSTANT']['ufGroup']; }
/** * Get all the Personal campaign pages * * @access public * @return array - array reference of all pcp if any * @static */ public static function &pcPage($id = null) { if (!self::$pcPage) { CRM_Core_PseudoConstant::populate(self::$pcPage, 'CRM_Contribute_DAO_PCP', false, 'title'); } if ($id) { return CRM_Utils_Array::value($id, self::$pcPage); } return self::$pcPage; }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { if ($this->_showFeeBlock) { return CRM_Event_Form_EventFees::buildQuickForm($this); } if ($this->_cdType) { return CRM_Custom_Form_CustomData::buildQuickForm($this); } //need to assign custom data type to the template $this->assign('customDataType', 'Participant'); $this->applyFilter('__ALL__', 'trim'); if ($this->_action & CRM_Core_Action::DELETE) { if ($this->_single) { $additionalParticipant = count(CRM_Event_BAO_Event::buildCustomProfile($this->_id, NULL, $this->_contactId, FALSE, TRUE)) - 1; if ($additionalParticipant) { $deleteParticipants = array(1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.')); $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '<br />'); $this->setDefaults(array('delete_participant' => 1)); $this->assign('additionalParticipant', $additionalParticipant); } } $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_single) { $urlPath = 'civicrm/contact/view/participant'; $urlParams = "reset=1&cid={$this->_contactId}&context=participant"; if ($this->_context == 'standalone') { CRM_Contact_Form_NewContact::buildQuickForm($this); $urlParams = 'reset=1&context=standalone'; $urlPath = 'civicrm/participant/add'; } if ($this->_id) { $urlParams .= "&action=update&id={$this->_id}"; } else { $urlParams .= "&action=add"; } if ($this->_mode) { $urlParams .= "&mode={$this->_mode}"; } $url = CRM_Utils_System::url($urlPath, $urlParams, FALSE, NULL, FALSE); } else { $currentPath = CRM_Utils_System::currentPath(); $url = CRM_Utils_System::url($currentPath, '_qf_Participant_display=true', FALSE, NULL, FALSE); } $this->assign('refreshURL', $url); $this->add('hidden', 'past_event'); $events = array(); if ($this->_eID) { $eventEndDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eID, 'end_date'); } $this->assign('past', 0); if ($this->_action & CRM_Core_Action::UPDATE) { $events = CRM_Event_BAO_Event::getEvents(1, FALSE, FALSE); } elseif ($this->getElementValue('past_event') || isset($eventEndDate) && CRM_Utils_Date::currentDBDate() > CRM_Utils_Date::processDate($eventEndDate)) { $pastval = $this->getElementValue('past_event'); $events = CRM_Event_BAO_Event::getEvents($pastval); $this->assign('past', $pastval); } else { $events = CRM_Event_BAO_Event::getEvents(); } if ($this->_mode) { //unset the event which are not monetary when credit card //event registration is used foreach ($events as $key => $val) { $isPaid = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $key, 'is_monetary'); if (!$isPaid) { unset($events[$key]); } } $this->add('select', 'payment_processor_id', ts('Payment Processor'), $this->_processors, TRUE); } // build array(event -> eventType) mapper $query = "\nSELECT civicrm_event.id as id, civicrm_event.event_type_id as event_type_id\nFROM civicrm_event\nWHERE civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0"; $dao = CRM_Core_DAO::executeQuery($query); $eventAndTypeMapping = array(); while ($dao->fetch()) { $eventAndTypeMapping[$dao->id] = $dao->event_type_id; } $eventAndTypeMapping = json_encode($eventAndTypeMapping); // building of mapping ends -- //inherit the campaign from event. $eventCampaigns = array(); $allEventIds = array_keys($events); if (!empty($allEventIds)) { CRM_Core_PseudoConstant::populate($eventCampaigns, 'CRM_Event_DAO_Event', TRUE, 'campaign_id'); } $eventCampaigns = json_encode($eventCampaigns); $element = $this->add('select', 'event_id', ts('Event'), array('' => ts('- select -')) + $events, TRUE, array('onchange' => "buildFeeBlock( this.value ); CRM.buildCustomData( 'Participant', this.value, {$this->_eventNameCustomDataTypeID} ); buildParticipantRole( this.value ); buildEventTypeCustomData( this.value, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' ); loadCampaign( this.value, {$eventCampaigns} );", 'class' => 'huge')); // CRM-6111 // note that embedding JS within PHP files is quite awful, IMO // but we do the same for the onChange element and this form is complex // and i did not want to break it late in the 3.2 cycle $preloadJSSnippet = NULL; if (CRM_Utils_Array::value('reset', $_GET) && $this->_eID) { $preloadJSSnippet = "\ncj(function() {\ncj('#event_id').val( '{$this->_eID}' );\nbuildFeeBlock( {$this->_eID} );\nCRM.buildCustomData( 'Participant', {$this->_eID}, {$this->_eventNameCustomDataTypeID} );\nbuildEventTypeCustomData( {$this->_eID}, {$this->_eventTypeCustomDataTypeID}, '{$eventAndTypeMapping}' );\nloadCampaign( {$this->_eID}, {$eventCampaigns} );\n});\n"; } $this->assign('preloadJSSnippet', $preloadJSSnippet); //frozen the field fix for CRM-4171 if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) { if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id')) { $element->freeze(); } } //CRM-7362 --add campaigns. $campaignId = NULL; if ($this->_id) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'campaign_id'); } if (!$campaignId) { $eventId = CRM_Utils_Request::retrieve('eid', 'Positive', $this); if ($eventId) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'campaign_id'); } } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); $this->addDateTime('register_date', ts('Registration Date'), TRUE, array('formatType' => 'activityDateTime')); if ($this->_id) { $this->assign('entityID', $this->_id); } $roleids = CRM_Event_PseudoConstant::participantRole(); foreach ($roleids as $rolekey => $rolevalue) { $roleTypes[] = $this->createElement('checkbox', $rolekey, NULL, $rolevalue, array('onclick' => "showCustomData( 'Participant', {$rolekey}, {$this->_roleCustomDataTypeID} );")); } $this->addGroup($roleTypes, 'role_id', ts('Participant Role')); $this->addRule('role_id', ts('Role is required'), 'required'); // CRM-4395 $checkCancelledJs = array('onchange' => "return sendNotification( );"); $confirmJS = NULL; if ($this->_onlinePendingContributionId) { $cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus()); $cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')); $checkCancelledJs = array('onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});"); $participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus()); $contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name')); $confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );"); } // get the participant status names to build special status array which is used to show notification // checkbox below participant status select $participantStatusName = CRM_Event_PseudoConstant::participantStatus(); $notificationStatuses = array('Cancelled', 'Pending from waitlist', 'Pending from approval', 'Expired'); // get the required status and then implode only ids $notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses))); $this->assign('notificationStatusIds', $notificationStatusIds); $this->_participantStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); $this->add('select', 'status_id', ts('Participant Status'), array('' => ts('- select -')) + $this->_participantStatuses, TRUE, $checkCancelledJs); $this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL); $this->add('text', 'source', ts('Event Source')); $noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note'); $this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']); $buttons[] = array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $confirmJS); $path = CRM_Utils_System::currentPath(); $excludeForPaths = array('civicrm/contact/search', 'civicrm/group/search'); if (!in_array($path, $excludeForPaths)) { $buttons[] = array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS); } $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel')); $this->addButtons($buttons); if ($this->_action == CRM_Core_Action::VIEW) { $this->freeze(); } }
/** * Get all the Personal campaign pages * * @access public * * @return array - array reference of all pcp if any * @static */ public static function &pcPage($id = NULL) { if (!self::$pcPage) { CRM_Core_PseudoConstant::populate(self::$pcPage, 'CRM_PCP_DAO_PCP', FALSE, 'title'); } if ($id) { return CRM_Utils_Array::value($id, self::$pcPage); } return self::$pcPage; }
/** * fetch financial type having relationship as Income Account is. * * * @return array * all financial type with income account is relationship */ public static function getIncomeFinancialType() { // Financial Type $financialType = CRM_Contribute_PseudoConstant::financialType(); $revenueFinancialType = array(); $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' ")); CRM_Core_PseudoConstant::populate($revenueFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, "account_relationship = {$relationTypeId} AND entity_table = 'civicrm_financial_type' "); foreach ($financialType as $key => $financialTypeName) { if (!in_array($key, $revenueFinancialType) || CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . $financialTypeName)) { unset($financialType[$key]); } } return $financialType; }
/** * @param int $financialTypeId * * @return array */ public function getFinancialAccounts($financialTypeId) { $financialAccounts = array(); CRM_Core_PseudoConstant::populate($financialAccounts, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'financial_account_id', $filter = NULL, " entity_id = {$financialTypeId} ", NULL, 'account_relationship'); return $financialAccounts; }
/** * Get all batches. * * * @param int $id * @return array * array reference of all batches if any */ public static function &batch($id = NULL) { if (!self::$batch) { $orderBy = " id DESC "; CRM_Core_PseudoConstant::populate(self::$batch, 'CRM_Batch_DAO_Batch', TRUE, 'title', NULL, NULL, $orderBy); } if ($id) { $result = CRM_Utils_Array::value($id, self::$batch); return $result; } return self::$batch; }
/** * Build the form object. * * @return void */ public function buildQuickForm() { $urlParams = 'civicrm/admin/contribute/premium'; if ($this->_action & CRM_Core_Action::DELETE) { $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id); $session->pushUserContext($url); if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject, '', '', 'GET')) { $dao = new CRM_Contribute_DAO_PremiumsProduct(); $dao->id = $this->_pid; $dao->delete(); CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'), ts('Saved'), 'success'); CRM_Utils_System::redirect($url); } $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } if ($this->_action & CRM_Core_Action::PREVIEW) { CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, NULL, $this->_pid); $this->addButtons(array(array('type' => 'next', 'name' => ts('Done with Preview'), 'isDefault' => TRUE))); return; } $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id); $session->pushUserContext($url); $this->add('select', 'product_id', ts('Select the Product') . ' ', $this->_products, TRUE); $this->addElement('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PremiumsProduct', 'weight')); $financialType = CRM_Contribute_PseudoConstant::financialType(); $premiumFinancialType = array(); CRM_Core_PseudoConstant::populate($premiumFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 8'); $costFinancialType = array(); CRM_Core_PseudoConstant::populate($costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 7'); $productFinancialType = array_intersect($costFinancialType, $premiumFinancialType); foreach ($financialType as $key => $financialTypeName) { if (!in_array($key, $productFinancialType)) { unset($financialType[$key]); } } if (count($financialType)) { $this->assign('financialType', $financialType); } $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialType); $this->addRule('weight', ts('Please enter integer value for weight'), 'integer'); $session->pushUserContext(CRM_Utils_System::url($urlParams, 'action=update&reset=1&id=' . $this->_id)); if ($this->_single) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); } else { parent::buildQuickForm(); } }
/** * Check if an error in Core( non-custom fields ) field * * @param array $params * @param string $errorMessage * A string containing all the error-fields. */ public function isErrorInCoreData($params, &$errorMessage) { foreach ($params as $key => $value) { if ($value) { $session = CRM_Core_Session::singleton(); $dateType = $session->get("dateTypes"); switch ($key) { case 'birth_date': if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) { if (!CRM_Utils_Rule::date($params[$key])) { self::addToErrorMsg(ts('Birth Date'), $errorMessage); } } else { self::addToErrorMsg(ts('Birth-Date'), $errorMessage); } break; case 'deceased_date': if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) { if (!CRM_Utils_Rule::date($params[$key])) { self::addToErrorMsg(ts('Deceased Date'), $errorMessage); } } else { self::addToErrorMsg(ts('Deceased Date'), $errorMessage); } break; case 'is_deceased': if (CRM_Utils_String::strtoboolstr($value) === FALSE) { self::addToErrorMsg(ts('Is Deceased'), $errorMessage); } break; case 'gender': case 'gender_id': if (!self::checkGender($value)) { self::addToErrorMsg(ts('Gender'), $errorMessage); } break; case 'preferred_communication_method': $preffComm = array(); $preffComm = explode(',', $value); foreach ($preffComm as $v) { if (!self::in_value(trim($v), CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'))) { self::addToErrorMsg(ts('Preferred Communication Method'), $errorMessage); } } break; case 'preferred_mail_format': if (!array_key_exists(strtolower($value), array_change_key_case(CRM_Core_SelectValues::pmf(), CASE_LOWER))) { self::addToErrorMsg(ts('Preferred Mail Format'), $errorMessage); } break; case 'individual_prefix': case 'prefix_id': if (!self::in_value($value, CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id'))) { self::addToErrorMsg(ts('Individual Prefix'), $errorMessage); } break; case 'individual_suffix': case 'suffix_id': if (!self::in_value($value, CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id'))) { self::addToErrorMsg(ts('Individual Suffix'), $errorMessage); } break; case 'state_province': if (!empty($value)) { foreach ($value as $stateValue) { if ($stateValue['state_province']) { if (self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvinceAbbreviation()) || self::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvince())) { continue; } else { self::addToErrorMsg(ts('State/Province'), $errorMessage); } } } } break; case 'country': if (!empty($value)) { foreach ($value as $stateValue) { if ($stateValue['country']) { CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active'); CRM_Core_PseudoConstant::populate($countryIsoCodes, 'CRM_Core_DAO_Country', TRUE, 'iso_code'); $config = CRM_Core_Config::singleton(); $limitCodes = $config->countryLimit(); //If no country is selected in //localization then take all countries if (empty($limitCodes)) { $limitCodes = $countryIsoCodes; } if (self::in_value($stateValue['country'], $limitCodes) || self::in_value($stateValue['country'], CRM_Core_PseudoConstant::country())) { continue; } else { if (self::in_value($stateValue['country'], $countryIsoCodes) || self::in_value($stateValue['country'], $countryNames)) { self::addToErrorMsg(ts('Country input value is in table but not "available": "This Country is valid but is NOT in the list of Available Countries currently configured for your site. This can be viewed and modifed from Administer > Localization > Languages Currency Locations." '), $errorMessage); } else { self::addToErrorMsg(ts('Country input value not in country table: "The Country value appears to be invalid. It does not match any value in CiviCRM table of countries."'), $errorMessage); } } } } } break; case 'county': if (!empty($value)) { foreach ($value as $county) { if ($county['county']) { $countyNames = CRM_Core_PseudoConstant::county(); if (!empty($county['county']) && !in_array($county['county'], $countyNames)) { self::addToErrorMsg(ts('County input value not in county table: The County value appears to be invalid. It does not match any value in CiviCRM table of counties.'), $errorMessage); } } } } break; case 'geo_code_1': if (!empty($value)) { foreach ($value as $codeValue) { if (!empty($codeValue['geo_code_1'])) { if (CRM_Utils_Rule::numeric($codeValue['geo_code_1'])) { continue; } else { self::addToErrorMsg(ts('Geo code 1'), $errorMessage); } } } } break; case 'geo_code_2': if (!empty($value)) { foreach ($value as $codeValue) { if (!empty($codeValue['geo_code_2'])) { if (CRM_Utils_Rule::numeric($codeValue['geo_code_2'])) { continue; } else { self::addToErrorMsg(ts('Geo code 2'), $errorMessage); } } } } break; //check for any error in email/postal greeting, addressee, //custom email/postal greeting, custom addressee, CRM-4575 //check for any error in email/postal greeting, addressee, //custom email/postal greeting, custom addressee, CRM-4575 case 'email_greeting': $emailGreetingFilter = array('contact_type' => $this->_contactType, 'greeting_type' => 'email_greeting'); if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($emailGreetingFilter))) { self::addToErrorMsg(ts('Email Greeting must be one of the configured format options. Check Administer >> System Settings >> Option Groups >> Email Greetings for valid values'), $errorMessage); } break; case 'postal_greeting': $postalGreetingFilter = array('contact_type' => $this->_contactType, 'greeting_type' => 'postal_greeting'); if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($postalGreetingFilter))) { self::addToErrorMsg(ts('Postal Greeting must be one of the configured format options. Check Administer >> System Settings >> Option Groups >> Postal Greetings for valid values'), $errorMessage); } break; case 'addressee': $addresseeFilter = array('contact_type' => $this->_contactType, 'greeting_type' => 'addressee'); if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($addresseeFilter))) { self::addToErrorMsg(ts('Addressee must be one of the configured format options. Check Administer >> System Settings >> Option Groups >> Addressee for valid values'), $errorMessage); } break; case 'email_greeting_custom': if (array_key_exists('email_greeting', $params)) { $emailGreetingLabel = key(CRM_Core_OptionGroup::values('email_greeting', TRUE, NULL, NULL, 'AND v.name = "Customized"')); if (CRM_Utils_Array::value('email_greeting', $params) != $emailGreetingLabel) { self::addToErrorMsg(ts('Email Greeting - Custom'), $errorMessage); } } break; case 'postal_greeting_custom': if (array_key_exists('postal_greeting', $params)) { $postalGreetingLabel = key(CRM_Core_OptionGroup::values('postal_greeting', TRUE, NULL, NULL, 'AND v.name = "Customized"')); if (CRM_Utils_Array::value('postal_greeting', $params) != $postalGreetingLabel) { self::addToErrorMsg(ts('Postal Greeting - Custom'), $errorMessage); } } break; case 'addressee_custom': if (array_key_exists('addressee', $params)) { $addresseeLabel = key(CRM_Core_OptionGroup::values('addressee', TRUE, NULL, NULL, 'AND v.name = "Customized"')); if (CRM_Utils_Array::value('addressee', $params) != $addresseeLabel) { self::addToErrorMsg(ts('Addressee - Custom'), $errorMessage); } } break; case 'url': if (is_array($value)) { foreach ($value as $values) { if (!empty($values['url']) && !CRM_Utils_Rule::url($values['url'])) { self::addToErrorMsg(ts('Website'), $errorMessage); break; } } } break; case 'do_not_email': case 'do_not_phone': case 'do_not_mail': case 'do_not_sms': case 'do_not_trade': if (CRM_Utils_Rule::boolean($value) == FALSE) { $key = ucwords(str_replace("_", " ", $key)); self::addToErrorMsg($key, $errorMessage); } break; case 'email': if (is_array($value)) { foreach ($value as $values) { if (!empty($values['email']) && !CRM_Utils_Rule::email($values['email'])) { self::addToErrorMsg($key, $errorMessage); break; } } } break; default: if (is_array($params[$key]) && isset($params[$key]["contact_type"])) { //check for any relationship data ,FIX ME self::isErrorInCoreData($params[$key], $errorMessage); } } } } }
/** * to fetch financial type having relationship as Income Account is * * * @return array all financial type with income account is relationship * @static */ static function getIncomeFinancialType() { // Financial Type $financialType = CRM_Contribute_PseudoConstant::financialType(); $revenueFinancialType = array(); $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' ")); CRM_Core_PseudoConstant::populate($revenueFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = True, $retrieve = 'entity_id', $filter = null, "account_relationship = {$relationTypeId} AND entity_table = 'civicrm_financial_type' "); foreach ($financialType as $key => $financialTypeName) { if (!in_array($key, $revenueFinancialType)) { unset($financialType[$key]); } } return $financialType; }
/** * Build the form object. * * @return void */ public function buildQuickForm() { $config = CRM_Core_Config::singleton(); $i18n = CRM_Core_I18n::singleton(); CRM_Utils_System::setTitle(ts('Settings - Localization')); $locales = CRM_Core_I18n::languages(); $warningTitle = json_encode(ts("Warning")); $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); if ($domain->locales) { // for multi-lingual sites, populate default language drop-down with available languages $lcMessages = array(); foreach ($locales as $loc => $lang) { if (substr_count($domain->locales, $loc)) { $lcMessages[$loc] = $lang; } } $this->addElement('select', 'lcMessages', ts('Default Language'), $lcMessages); // add language limiter and language adder $this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($lcMessages), NULL, NULL, NULL, NULL, ' '); $this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff($locales, $lcMessages))); // add the ability to return to single language $warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).'); $this->assign('warning', $warning); $warning = json_encode($warning); $this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})")); } else { // for single-lingual sites, populate default language drop-down with all languages $this->addElement('select', 'lcMessages', ts('Default Language'), $locales); $warning = ts('Enabling multiple languages changes the schema of your database, so make sure you know what you are doing when enabling this function; making a database backup is strongly recommended.'); $this->assign('warning', $warning); $warning = json_encode($warning); $validTriggerPermission = CRM_Core_DAO::checkTriggerViewPermission(TRUE); if ($validTriggerPermission && !$config->logging) { $this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'), NULL, array('onChange' => "if (this.checked) CRM.alert({$warning}, {$warningTitle})")); } } $this->addElement('checkbox', 'inheritLocale', ts('Inherit CMS Language')); $this->addElement('text', 'monetaryThousandSeparator', ts('Thousands Separator'), array('size' => 2)); $this->addElement('text', 'monetaryDecimalPoint', ts('Decimal Delimiter'), array('size' => 2)); $this->addElement('text', 'moneyformat', ts('Monetary Amount Display')); $this->addElement('text', 'moneyvalueformat', ts('Monetary Value Display')); $country = array(); CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active'); $i18n->localizeArray($country, array('context' => 'country')); asort($country); $includeCountry =& $this->addElement('advmultiselect', 'countryLimit', ts('Available Countries') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect')); $includeCountry->setButtonAttributes('add', array('value' => ts('Add >>'))); $includeCountry->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $includeState =& $this->addElement('advmultiselect', 'provinceLimit', ts('Available States and Provinces') . ' ', $country, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect')); $includeState->setButtonAttributes('add', array('value' => ts('Add >>'))); $includeState->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $this->addElement('select', 'defaultContactCountry', ts('Default Country'), array('' => ts('- select -')) + $country); $this->addChainSelect('defaultContactStateProvince', array('label' => ts('Default State/Province'))); // we do this only to initialize currencySymbols, kinda hackish but works! $config->defaultCurrencySymbol(); $symbol = $config->currencySymbols; foreach ($symbol as $key => $value) { $this->_currencySymbols[$key] = "{$key}"; if ($value) { $this->_currencySymbols[$key] .= " ({$value})"; } } $this->addElement('select', 'defaultCurrency', ts('Default Currency'), $this->_currencySymbols); $includeCurrency =& $this->addElement('advmultiselect', 'currencyLimit', ts('Available Currencies') . ' ', $this->_currencySymbols, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect')); $includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>'))); $includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $this->addElement('text', 'legacyEncoding', ts('Legacy Encoding')); $this->addElement('text', 'customTranslateFunction', ts('Custom Translate Function')); $this->addElement('text', 'fieldSeparator', ts('Import / Export Field Separator'), array('size' => 2)); $this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule')); parent::buildQuickForm(); }
/** * format common params data to proper format to store. * * @param array $params contain record values. * @param array $formatted array of formatted data. * @param array $contactFields contact DAO fields. * @static */ function formatCommonData($params, &$formatted, &$contactFields) { $csType = array(CRM_Utils_Array::value('contact_type', $formatted)); //CRM-5125 //add custom fields for contact sub type if (!empty($this->_contactSubType)) { $csType = $this->_contactSubType; } if ($relCsType = CRM_Utils_Array::value('contact_sub_type', $formatted)) { $csType = $relCsType; } $customFields = CRM_Core_BAO_CustomField::getFields($formatted['contact_type'], false, false, $csType); //if a Custom Email Greeting, Custom Postal Greeting or Custom Addressee is mapped, and no "Greeting / Addressee Type ID" is provided, then automatically set the type = Customized, CRM-4575 $elements = array('email_greeting_custom' => 'email_greeting', 'postal_greeting_custom' => 'postal_greeting', 'addressee_custom' => 'addressee'); foreach ($elements as $k => $v) { if (array_key_exists($k, $params) && !array_key_exists($v, $params)) { $label = key(CRM_Core_OptionGroup::values($v, true, null, null, 'AND v.name = "Customized"')); $params[$v] = $label; } } //format date first $session =& CRM_Core_Session::singleton(); $dateType = $session->get("dateTypes"); foreach ($params as $key => $val) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) { //we should not update Date to null, CRM-4062 if ($val && $customFields[$customFieldID]['data_type'] == 'Date') { self::formatCustomDate($params, $formatted, $dateType, $key); unset($params[$key]); } else { if ($customFields[$customFieldID]['data_type'] == 'Boolean') { $params[$key] = CRM_Utils_String::strtoboolstr($val); } } } if ($key == 'birth_date' && $val) { CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key); } else { if ($key == 'deceased_date' && $val) { CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key); } else { if ($key == 'is_deceased' && $val) { $params[$key] = CRM_Utils_String::strtoboolstr($val); } else { if ($key == 'gender') { //CRM-4360 $params[$key] = $this->checkGender($val); } } } } } //now format custom data. foreach ($params as $key => $field) { if ($field == null || $field === '') { continue; } if (is_array($field)) { foreach ($field as $value) { $break = false; if (is_array($value)) { foreach ($value as $name => $testForEmpty) { // check if $value does not contain IM provider or phoneType if (($name !== 'phone_type_id' || $name !== 'provider_id') && ($testForEmpty === '' || $testForEmpty == null)) { $break = true; break; } } } else { $break = true; } if (!$break) { _civicrm_add_formatted_param($value, $formatted); } } continue; } $formatValues = array($key => $field); if ($key !== 'preferred_communication_method' && array_key_exists($key, $contactFields)) { // due to merging of individual table and // contact table, we need to avoid // preferred_communication_method forcefully $formatValues['contact_type'] = $formatted['contact_type']; } if ($key == 'id' && isset($field)) { $formatted[$key] = $field; } _civicrm_add_formatted_param($formatValues, $formatted); //Handling Custom Data if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) && array_key_exists($customFieldID, $customFields)) { //get the html type. $type = $customFields[$customFieldID]['html_type']; switch ($type) { case 'CheckBox': case 'AdvMulti-Select': case 'Multi-Select': $mulValues = explode(',', $field); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true); $formatted[$key] = array(); foreach ($mulValues as $v1) { foreach ($customOption as $v2) { if (strtolower($v2['label']) == strtolower(trim($v1)) || strtolower($v2['value']) == strtolower(trim($v1))) { if ($type == 'CheckBox') { $formatted[$key][$v2['value']] = 1; } else { $formatted[$key][] = $v2['value']; } } } } break; case 'Select': case 'Radio': $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true); foreach ($customOption as $v2) { if (strtolower($v2['label']) == strtolower(trim($field)) || strtolower($v2['value']) == strtolower(trim($field))) { $formatted[$key] = $v2['value']; } } break; case 'Multi-Select State/Province': $mulValues = explode(',', $field); $stateAbbr = CRM_Core_PseudoConstant::stateProvinceAbbreviation(); $stateName = CRM_Core_PseudoConstant::stateProvince(); $formatted[$key] = $stateValues = array(); foreach ($mulValues as $values) { if ($val = CRM_Utils_Array::key($values, $stateAbbr)) { $formatted[$key][] = $val; } else { if ($val = CRM_Utils_Array::key($values, $stateName)) { $formatted[$key][] = $val; } } } break; case 'Multi-Select Country': $config =& CRM_Core_Config::singleton(); $limitCodes = $config->countryLimit(); $mulValues = explode(',', $field); $formatted[$key] = array(); CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', true, 'name', 'is_active'); CRM_Core_PseudoConstant::populate($countryIsoCodes, 'CRM_Core_DAO_Country', true, 'iso_code'); foreach ($mulValues as $values) { if ($val = CRM_Utils_Array::key($values, $countryNames)) { $formatted[$key][] = $val; } else { if ($val = CRM_Utils_Array::key($values, $countryIsoCodes)) { $formatted[$key][] = $val; } else { if ($val = CRM_Utils_Array::key($values, $limitCodes)) { $formatted[$key][] = $val; } } } } break; } } } // check for primary location type, whether it is already present for the contact or not, CRM-4423 if (CRM_Utils_Array::value('id', $formatted) && isset($formatted['location'])) { $primaryLocationTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($formatted['id'], true); if (isset($primaryLocationTypeId)) { foreach ($formatted['location'] as $loc => $details) { if ($primaryLocationTypeId == CRM_Utils_Array::value('location_type_id', $details)) { $formatted['location'][$loc]['is_primary'] = 1; break; } else { $formatted['location'][$loc]['is_primary'] = 0; } } } } // parse street address, CRM-5450 if ($this->_parseStreetAddress) { require_once 'CRM/Core/BAO/Address.php'; if (array_key_exists('address', $formatted) && is_array($formatted['address'])) { foreach ($formatted['address'] as $instance => &$address) { $streetAddress = CRM_Utils_Array::value('street_address', $address); if (empty($streetAddress)) { continue; } // parse address field. $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($streetAddress); //street address consider to be parsed properly, //If we get street_name and street_number. if (!CRM_Utils_Array::value('street_name', $parsedFields) || !CRM_Utils_Array::value('street_number', $parsedFields)) { $parsedFields = array_fill_keys(array_keys($parsedFields), ''); } // merge parse address w/ main address block. $address = array_merge($address, $parsedFields); } } } }
/** * @param array $options * * @return array */ function getParticipantColumns($options = array()) { static $_events = array(); if (!isset($_events['all'])) { CRM_Core_PseudoConstant::populate($_events['all'], 'CRM_Event_DAO_Event', FALSE, 'title', 'is_active', "is_template IS NULL OR is_template = 0", 'title'); } $specs = array( 'participant_id' => array( 'title' => 'Participant ID', 'is_fields' => TRUE, ), 'participant_record' => array( 'name' => 'id', 'title' => 'Participant ID', 'is_fields' => TRUE, ), 'participant_event_id' => array( 'title' => ts('Event ID'), 'name' => 'id', 'type' => CRM_Utils_Type::T_STRING, 'alter_display' => 'alterEventID', 'is_filters' => TRUE, 'is_fields' => TRUE, 'is_order_bys' => TRUE, 'is_group_bys' => TRUE, 'default_weight' => '1', 'default_order' => 'ASC', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $_events['all'], ), 'participant_status_id' => array( 'name' => 'status_id', 'title' => ts('Event Participant Status'), 'alter_display' => 'alterParticipantStatus', 'options' => $this->_getOptions('participant', 'status_id', $action = 'get'), 'is_fields' => TRUE, 'is_filters' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), 'type' => CRM_Utils_Type::T_INT, ), 'participant_role_id' => array( 'name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT_SEPARATOR, 'options' => CRM_Event_PseudoConstant::participantRole(), 'alter_display' => 'alterParticipantRole', 'is_fields' => TRUE, 'is_filters' => TRUE, ), 'participant_fee_level' => array( 'name' => 'fee_level', 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', 'title' => ts('Participant Fee Level'), 'is_fields' => TRUE, ), 'participant_fee_amount' => NULL, 'participant_register_date' => array( 'title' => ' Registration Date', 'operatorType' => CRM_Report_Form::OP_DATE, 'is_fields' => TRUE, 'is_filters' => TRUE, ), ); return $this->buildColumns($specs, 'civicrm_participant', 'CRM_Event_BAO_Participant'); }
/** * Get all the completed mailing. * * * @param null $mode * * @return array * array reference of all mailing templates if any */ public static function &completed($mode = NULL) { if (!self::$completed) { $mailingACL = CRM_Mailing_BAO_Mailing::mailingACL(); $mailingACL .= $mode == 'sms' ? " AND sms_provider_id IS NOT NULL " : ""; CRM_Core_PseudoConstant::populate(self::$completed, 'CRM_Mailing_DAO_Mailing', FALSE, 'name', 'is_completed', $mailingACL); } return self::$completed; }
public static function processMandrillCalls($reponse) { $events = array('open', 'click', 'hard_bounce', 'soft_bounce', 'spam', 'reject'); $bounceType = array(); //MTE-17 $config = CRM_Core_Config::singleton(); if (property_exists($config, 'civiVersion')) { $civiVersion = $config->civiVersion; } else { $civiVersion = CRM_Core_BAO_Domain::version(); } if (version_compare('4.4alpha1', $civiVersion) > 0) { $jobCLassName = 'CRM_Mailing_DAO_Job'; } else { $jobCLassName = 'CRM_Mailing_DAO_MailingJob'; } foreach ($reponse as $value) { //changes done to check if email exists in response array if (in_array($value['event'], $events) && CRM_Utils_Array::value('email', $value['msg'])) { $metaData = CRM_Utils_Array::value('metadata', $value['msg']) ? CRM_Utils_Array::value('CiviCRM_Mandrill_id', $value['msg']['metadata']) : NULL; $header = self::extractHeader($metaData); $mail = self::getMailing($header, $jobCLassName); $contacts = array(); if ($mail->find(TRUE)) { if ($value['event'] == 'click' && $mail->url_tracking === FALSE || $value['event'] == 'open' && $mail->open_tracking === FALSE) { continue; } $emails = self::retrieveEmailContactId($value['msg']['email']); if (!CRM_Utils_Array::value('contact_id', $emails['email'])) { continue; } $value['mailing_id'] = $mail->id; // IF no activity id in header then create new activity if (empty($header[0])) { self::createActivity($value, NULL, $header); } if (empty($header[2])) { $params = array('job_id' => CRM_Core_DAO::getFieldValue($jobCLassName, $mail->id, 'id', 'mailing_id'), 'contact_id' => $emails['email']['contact_id'], 'email_id' => $emails['email']['id']); $eventQueue = CRM_Mailing_Event_BAO_Queue::create($params); $eventQueueID = $eventQueue->id; $hash = $eventQueue->hash; $jobId = $params['job_id']; } else { $eventQueueID = $header[3]; $hash = explode('@', $header[4]); $hash = $hash[0]; $jobId = $header[2]; } if ($eventQueueID) { $mandrillActivtyParams = array('mailing_queue_id' => $eventQueueID, 'activity_id' => $header[0]); CRM_Mte_BAO_MandrillActivity::create($mandrillActivtyParams); } $msgBody = ''; if (!empty($header[0])) { $msgBody = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $header[0], 'details'); } $value['mail_body'] = $msgBody; $bType = ucfirst(preg_replace('/_\\w+/', '', $value['event'])); $assignedContacts = array(); switch ($value['event']) { case 'open': $oe = new CRM_Mailing_Event_BAO_Opened(); $oe->event_queue_id = $eventQueueID; $oe->time_stamp = date('YmdHis', $value['ts']); $oe->save(); break; case 'click': if (CRM_Utils_Array::value(1, $header) == 'b') { break; } $tracker = new CRM_Mailing_BAO_TrackableURL(); $tracker->url = $value['url']; $tracker->mailing_id = $mail->id; if (!$tracker->find(TRUE)) { $tracker->save(); } $open = new CRM_Mailing_Event_BAO_TrackableURLOpen(); $open->event_queue_id = $eventQueueID; $open->trackable_url_id = $tracker->id; $open->time_stamp = date('YmdHis', $value['ts']); $open->save(); break; case 'hard_bounce': case 'soft_bounce': case 'spam': case 'reject': if (empty($bounceType)) { CRM_Core_PseudoConstant::populate($bounceType, 'CRM_Mailing_DAO_BounceType', TRUE, 'id', NULL, NULL, NULL, 'name'); } //Delete queue in delivered since this email is not successfull $delivered = new CRM_Mailing_Event_BAO_Delivered(); $delivered->event_queue_id = $eventQueueID; if ($delivered->find(TRUE)) { $delivered->delete(); } $bounceParams = array('time_stamp' => date('YmdHis', $value['ts']), 'event_queue_id' => $eventQueueID, 'bounce_type_id' => $bounceType["Mandrill {$bType}"], 'job_id' => $jobId, 'hash' => $hash); $bounceParams['bounce_reason'] = CRM_Utils_Array::value('bounce_description', $value['msg']); if (empty($bounceParams['bounce_reason'])) { $bounceParams['bounce_reason'] = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_BounceType', $bounceType["Mandrill {$bType}"], 'description'); } CRM_Mailing_Event_BAO_Bounce::create($bounceParams); if (substr($value['event'], -7) == '_bounce') { $mailingBackend = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mandrill_smtp_settings'); if (CRM_Utils_Array::value('group_id', $mailingBackend)) { list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(); $mailBody = ts('The following email failed to be delivered due to a') . " {$bType} Bounce :</br>\nTo: {$value['msg']['email']} </br>\nFrom: {$value['msg']['sender']} </br>\nSubject: {$value['msg']['subject']}</br>\nMessage Body: {$msgBody}"; $mailParams = array('groupName' => 'Mandrill bounce notification', 'from' => '"' . $domainEmailName . '" <' . $domainEmailAddress . '>', 'subject' => ts('Mandrill Bounce Notification'), 'text' => $mailBody, 'html' => $mailBody); $query = "SELECT ce.email, cc.sort_name, cgc.contact_id FROM civicrm_contact cc\nINNER JOIN civicrm_group_contact cgc ON cgc.contact_id = cc.id\nINNER JOIN civicrm_email ce ON ce.contact_id = cc.id\nWHERE cc.is_deleted = 0 AND cc.is_deceased = 0 AND cgc.group_id = {$mailingBackend['group_id']} AND ce.is_primary = 1 AND ce.email <> %1"; $queryParam = array(1 => array($value['msg']['email'], 'String')); $dao = CRM_Core_DAO::executeQuery($query, $queryParam); while ($dao->fetch()) { $mailParams['toName'] = $dao->sort_name; $mailParams['toEmail'] = $dao->email; CRM_Utils_Mail::send($mailParams); $value['assignee_contact_id'][] = $dao->contact_id; } } } $bType = 'Bounce'; break; } // create activity for click and open event if ($value['event'] == 'open' || $value['event'] == 'click' || $bType == 'Bounce') { self::createActivity($value, $bType, $header); } } } } }
/** * Build the form * * @access public * * @return void */ function buildQuickForm() { $ufGroupId = $this->get('ufGroupId'); if (!$ufGroupId) { CRM_Core_Error::fatal('ufGroupId is missing'); } $this->_title = ts('Batch Update for Activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId); CRM_Utils_System::setTitle($this->_title); $this->addDefaultButtons(ts('Save')); $this->_fields = array(); $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW); // remove file type field and then limit fields $suppressFields = FALSE; $removehtmlTypes = array('File', 'Autocomplete-Select'); foreach ($this->_fields as $name => $field) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) { $suppressFields = TRUE; unset($this->_fields[$name]); } //fix to reduce size as we are using this field in grid if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) { //shrink class to "form-text-medium" $this->_fields[$name]['attributes']['size'] = 19; } } $this->_fields = array_slice($this->_fields, 0, $this->_maxFields); $this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Activities'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); $this->assign('profileTitle', $this->_title); $this->assign('componentIds', $this->_activityHolderIds); $fileFieldExists = FALSE; //load all campaigns. if (array_key_exists('activity_campaign_id', $this->_fields)) { $this->_componentCampaigns = array(); CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Activity_DAO_Activity', TRUE, 'campaign_id', 'id', ' id IN (' . implode(' , ', array_values($this->_activityHolderIds)) . ' ) '); } $customFields = CRM_Core_BAO_CustomField::getFields('Activity'); foreach ($this->_activityHolderIds as $activityId) { $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id'); foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { $customValue = CRM_Utils_Array::value($customFieldID, $customFields); if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value']); } if (!empty($entityColumnValue[$typeId]) || CRM_Utils_System::isNull($entityColumnValue[$typeId])) { CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId); } } else { // handle non custom fields CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId); } } } $this->assign('fields', $this->_fields); // don't set the status message when form is submitted. // $buttonName = $this->controller->getButtonName('submit'); if ($suppressFields) { CRM_Core_Session::setStatus(ts("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update."), ts("Some fields have been excluded"), "info"); } $this->addDefaultButtons(ts('Update Activities')); }
/** * Get all the membership statuss * * @access public * * @return array - array reference of all membership statuss if any * @static */ public static function &membershipStatus($id = NULL, $cond = NULL, $column = 'name', $force = FALSE) { if (self::$membershipStatus === NULL) { self::$membershipStatus = array(); } $cacheKey = $column; if ($cond) { $cacheKey .= "_{$cond}"; } if (!isset(self::$membershipStatus[$cacheKey]) || $force) { CRM_Core_PseudoConstant::populate(self::$membershipStatus[$cacheKey], 'CRM_Member_DAO_MembershipStatus', FALSE, $column, 'is_active', $cond, 'weight'); } $value = NULL; if ($id) { $value = CRM_Utils_Array::value($id, self::$membershipStatus[$cacheKey]); } else { $value = self::$membershipStatus[$cacheKey]; } return $value; }