/** * Build the form * * @access public * @return void */ function buildQuickForm() { // add select for tag $this->_tags = array('' => ' - select tag - ') + CRM_Core_PseudoConstant::tag(); $this->add('select', 'tag_id', ts('Select Tag'), $this->_tags, true); $this->addDefaultButtons(ts('Tag Contacts')); }
/** * Browse all mail settings. * * @return void */ public function browse() { //get all mail settings. $allMailSettings = array(); $mailSetting = new CRM_Core_DAO_MailSettings(); $allProtocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); //multi-domain support for mail settings. CRM-5244 $mailSetting->domain_id = CRM_Core_Config::domainID(); //find all mail settings. $mailSetting->find(); while ($mailSetting->fetch()) { //replace protocol value with name $mailSetting->protocol = CRM_Utils_Array::value($mailSetting->protocol, $allProtocols); CRM_Core_DAO::storeValues($mailSetting, $allMailSettings[$mailSetting->id]); //form all action links $action = array_sum(array_keys($this->links())); // disallow the DELETE action for the default set of settings if ($mailSetting->is_default) { $action &= ~CRM_Core_Action::DELETE; } //add action links. $allMailSettings[$mailSetting->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $mailSetting->id), ts('more'), FALSE, 'mailSetting.manage.action', 'MailSetting', $mailSetting->id); } $this->assign('rows', $allMailSettings); }
/** */ public function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array_merge(array('sort_name_linked' => array('title' => ts('Participant Name'), 'required' => TRUE, 'no_repeat' => TRUE, 'dbAlias' => 'contact_civireport.sort_name')), $this->getBasicContactFields(), array('age_at_event' => array('title' => ts('Age at Event'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, event_civireport.start_date)'))), 'grouping' => 'contact-fields', 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC'), 'first_name' => array('name' => 'first_name', 'title' => ts('First Name')), 'gender_id' => array('name' => 'gender_id', 'title' => ts('Gender')), 'birth_date' => array('name' => 'birth_date', 'title' => ts('Birth Date')), 'age_at_event' => array('name' => 'age_at_event', 'title' => ts('Age at Event')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype'))), 'filters' => array('sort_name' => array('title' => ts('Participant Name'), 'operator' => 'like'), 'gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id')), 'birth_date' => array('title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact Subtype')))), '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')))); $this->_columns += $this->getAddressColumns(); $this->_columns += array('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), 'fee_currency' => array('required' => TRUE, 'no_display' => TRUE), 'registered_by_id' => array('title' => ts('Registered by Participant ID')), 'source' => array('title' => ts('Source')), 'participant_fee_level' => NULL, 'participant_fee_amount' => array('title' => ts('Participant Fee')), 'participant_register_date' => array('title' => ts('Registration Date')), 'total_paid' => array('title' => ts('Total Paid'), 'dbAlias' => 'SUM(ft.total_amount)', 'type' => 1024), 'balance' => array('title' => ts('Balance'), 'dbAlias' => 'participant_civireport.fee_amount - SUM(ft.total_amount)', 'type' => 1024)), 'grouping' => 'event-fields', 'filters' => array('event_id' => array('name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, 'attributes' => array('entity' => 'event', 'select' => array('minimumInputLength' => 0))), 'sid' => array('name' => 'status_id', 'title' => ts('Participant Status'), 'type' => CRM_Utils_Type::T_INT, '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), 'fee_currency' => array('title' => ts('Fee Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'registered_by_id' => array('title' => ts('Registered by Participant ID'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like'), 'source' => array('title' => ts('Source'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like')), 'order_bys' => array('participant_register_date' => array('title' => ts('Registration Date'), 'default_weight' => '1', 'default_order' => 'ASC'), 'event_id' => array('title' => ts('Event'), 'default_weight' => '1', 'default_order' => 'ASC'))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_event' => array('dao' => 'CRM_Event_DAO_Event', 'fields' => array('event_type_id' => array('title' => ts('Event Type')), 'event_start_date' => array('title' => ts('Event Start Date'))), 'grouping' => 'event-fields', 'filters' => array('eid' => array('name' => 'event_type_id', 'title' => ts('Event Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type')), 'event_start_date' => array('title' => ts('Event Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE)), 'order_bys' => array('event_type_id' => array('title' => ts('Event Type'), 'default_weight' => '2', 'default_order' => 'ASC'), 'event_start_date' => array('title' => ts('Event Start Date')))), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_id' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contribution ID')), 'financial_type_id' => array('title' => ts('Financial Type')), 'receive_date' => array('title' => ts('Payment Date')), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'payment_instrument_id' => array('title' => ts('Payment Type')), 'contribution_source' => array('name' => 'source', 'title' => ts('Contribution Source')), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_id' => NULL, 'fee_amount' => array('title' => ts('Transaction Fee')), 'net_amount' => NULL), 'grouping' => 'contrib-fields', 'filters' => array('receive_date' => array('title' => 'Payment Date', 'operatorType' => CRM_Report_Form::OP_DATE), 'financial_type_id' => array('title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), 'currency' => array('title' => ts('Contribution Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'payment_instrument_id' => array('title' => ts('Payment Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => NULL))), 'civicrm_line_item' => array('dao' => 'CRM_Price_DAO_LineItem', 'grouping' => 'priceset-fields', 'filters' => array('price_field_value_id' => array('name' => 'price_field_value_id', 'title' => ts('Fee Level'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->getPriceLevels())))); $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')))); // CRM-17115 avoid duplication of sort_name - would be better to standardise name // & behaviour across reports but trying for no change at this point. $this->_columns['civicrm_contact']['fields']['sort_name']['no_display'] = TRUE; // If we have active campaigns add those elements to both the fields and filters if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_participant']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_participant']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns, 'type' => CRM_Utils_Type::T_INT); $this->_columns['civicrm_participant']['order_bys']['campaign_id'] = array('title' => ts('Campaign')); } $this->_currencyColumn = 'civicrm_participant_fee_currency'; parent::__construct(); }
/** * Return the proper mail store implementation, based on config settings * * @param string $name name of the settings set from civimail_mail_settings to use (null for default) * @return object mail store implementation for processing CiviMail-bound emails */ function getStore($name = null) { $dao = new CRM_Core_DAO_MailSettings(); $dao->domain_id = CRM_Core_Config::domainID(); $name ? $dao->name = $name : ($dao->is_default = 1); if (!$dao->find(true)) { throw new Exception("Could not find entry named {$name} in civicrm_mail_settings"); } $protocols =& CRM_Core_PseudoConstant::mailProtocol(); switch ($protocols[$dao->protocol]) { case 'IMAP': require_once 'CRM/Mailing/MailStore/Imap.php'; return new CRM_Mailing_MailStore_Imap($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl, $dao->source); case 'POP3': require_once 'CRM/Mailing/MailStore/Pop3.php'; return new CRM_Mailing_MailStore_Pop3($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl); case 'Maildir': require_once 'CRM/Mailing/MailStore/Maildir.php'; return new CRM_Mailing_MailStore_Maildir($dao->source); case 'Localdir': require_once 'CRM/Mailing/MailStore/Localdir.php'; return new CRM_Mailing_MailStore_Localdir($dao->source); // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards case 'mbox': require_once 'CRM/Mailing/MailStore/Mbox.php'; return new CRM_Mailing_MailStore_Mbox($dao->source); default: throw new Exception("Unknown protocol {$dao->protocol}"); } }
function buildForm(&$form) { $this->setTitle(ts('Include / Exclude Search')); $groups = CRM_Core_PseudoConstant::group(); $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); if (count($groups) == 0 || count($tags) == 0) { CRM_Core_Session::setStatus(ts("At least one Group and Tag must be present for Custom Group / Tag search."), ts('Missing Group/Tag')); $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'); CRM_Utils_System::redirect($url); } $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $andOr = array('1' => ts('Show contacts that meet the Groups criteria AND the Tags criteria'), '0' => ts('Show contacts that meet the Groups criteria OR the Tags criteria')); $form->addRadio('andOr', ts('AND/OR'), $andOr, NULL, '<br />', TRUE); $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); //add/remove buttons for groups $inG->setButtonAttributes('add', array('value' => ts('Add >>'))); $outG->setButtonAttributes('add', array('value' => ts('Add >>'))); $inG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); //add/remove buttons for tags $int->setButtonAttributes('add', array('value' => ts('Add >>'))); $outt->setButtonAttributes('add', array('value' => ts('Add >>'))); $int->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outt->setButtonAttributes('remove', array('value' => ts('<< Remove'))); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags')); }
/** * Generate a list of basic XML test cases. Each test case creates a * custom-group and custom-field then compares the output to a pre-defined * XML file. Then, for each test-case, we reverse the process -- we * load the XML into a clean DB and see if it creates matching custom-group * and custom-field. */ function basicXmlTestCases() { // a small library which we use to describe test cases $fixtures = array(); $fixtures['textField'] = array('name' => 'test_textfield', 'label' => 'Name1', 'html_type' => 'Text', 'data_type' => 'String', 'default_value' => 'abc', 'weight' => 4, 'is_required' => 1, 'is_searchable' => 0, 'is_active' => 1); $fixtures['selectField'] = array('label' => 'Our select field', 'html_type' => 'Select', 'data_type' => 'String', 'weight' => 4, 'is_required' => 1, 'is_searchable' => 0, 'is_active' => 1, 'option_values' => array(array('weight' => 1, 'label' => 'Label1', 'value' => 1, 'is_active' => 1), array('weight' => 2, 'label' => 'Label2', 'value' => 2, 'is_active' => 1))); // the actual test cases $cases = array(); $cases[] = array(array('extends' => 'Contact', 'title' => 'example'), $fixtures['textField'], __DIR__ . '/fixtures/Contact-text.xml'); /* $cases[] = array( // CustomGroup params array( 'extends' => 'Contact', 'title' => 'example', ), // CustomField params $fixtures['selectField'], // expectedXmlFilePath __DIR__ . '/fixtures/Contact-select.xml', ); */ $cases[] = array(array('extends' => 'Individual', 'title' => 'example'), $fixtures['textField'], __DIR__ . '/fixtures/Individual-text.xml'); $cases[] = array(array('extends' => 'Individual', 'extends_entity_column_value' => array('Student'), 'title' => 'example'), $fixtures['textField'], __DIR__ . '/fixtures/IndividualStudent-text.xml'); $cases[] = array(array('extends' => 'Activity', 'title' => 'example'), $fixtures['textField'], __DIR__ . '/fixtures/Activity-text.xml'); $cases[] = array(array('extends' => 'Activity', 'extends_entity_column_value' => array(array_search('Meeting', CRM_Core_PseudoConstant::activityType())), 'title' => 'example'), $fixtures['textField'], __DIR__ . '/fixtures/ActivityMeeting-text.xml'); return $cases; }
function __construct() { $yearsInPast = 10; $yearsInFuture = 1; $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, $yearsInFuture); $count = $date['maxYear']; while ($date['minYear'] <= $count) { $optionYear[$date['minYear']] = $date['minYear']; $date['minYear']++; } // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-field', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => TRUE), 'first_name' => array('title' => ts('First Name')), 'last_name' => array('title' => ts('Last Name')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-field', 'fields' => array('email' => array('title' => ts('Email'), 'default' => TRUE))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE)))) + $this->addAddressFields() + array('civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contact_id' => array('title' => ts('contactId'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE), 'total_amount' => array('title' => ts('Total Amount'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE), 'receive_date' => array('title' => ts('Year'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE)), 'filters' => array('yid' => array('name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y')), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array('1')))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group())))); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); } $this->_tagFilter = TRUE; parent::__construct(); }
/** * Evaluate the content of a single token. * * @param \Civi\Token\TokenRow $row * The record for which we want token values. * @param string $field * The name of the token field. * @param mixed $prefetch * Any data that was returned by the prefetch(). * @return mixed */ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) { $actionSearchResult = $row->context['actionSearchResult']; if ($field == 'location') { $loc = array(); $stateProvince = \CRM_Core_PseudoConstant::stateProvince(); $loc['street_address'] = $actionSearchResult->street_address; $loc['city'] = $actionSearchResult->city; $loc['state_province'] = \CRM_Utils_Array::value($actionSearchResult->state_province_id, $stateProvince); $loc['postal_code'] = $actionSearchResult->postal_code; //$entityTokenParams[$tokenEntity][$field] = \CRM_Utils_Address::format($loc); $row->tokens($entity, $field, \CRM_Utils_Address::format($loc)); } elseif ($field == 'info_url') { $row->tokens($entity, $field, \CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $actionSearchResult->event_id, TRUE, NULL, FALSE)); } elseif ($field == 'registration_url') { $row->tokens($entity, $field, \CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $actionSearchResult->event_id, TRUE, NULL, FALSE)); } elseif (in_array($field, array('start_date', 'end_date'))) { $row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->{$field})); } elseif ($field == 'balance') { if ($actionSearchResult->entityTable == 'civicrm_contact') { $balancePay = 'N/A'; } elseif (!empty($actionSearchResult->entityID)) { $info = \CRM_Contribute_BAO_Contribution::getPaymentInfo($actionSearchResult->entityID, 'event'); $balancePay = \CRM_Utils_Array::value('balance', $info); $balancePay = \CRM_Utils_Money::format($balancePay); } $row->tokens($entity, $field, $balancePay); } elseif ($field == 'fee_amount') { $row->tokens($entity, $field, \CRM_Utils_Money::format($actionSearchResult->{$field})); } elseif (isset($actionSearchResult->{$field})) { $row->tokens($entity, $field, $actionSearchResult->{$field}); } else { $row->tokens($entity, $field, ''); } }
/** * Get CiviCRM domain details * {@getfields domain_create} * @example DomainGet.php */ function civicrm_api3_domain_get($params) { $params['version'] = CRM_Utils_Array::value('domain_version', $params); unset($params['version']); $bao = new CRM_Core_BAO_Domain(); if (CRM_Utils_Array::value('current_domain', $params)) { $domainBAO = CRM_Core_Config::domainID(); $params['id'] = $domainBAO; } _civicrm_api3_dao_set_filter($bao, $params, true, 'domain'); $domains = _civicrm_api3_dao_to_array($bao, $params, true, 'domain'); foreach ($domains as $domain) { if (!empty($domain['contact_id'])) { $values = array(); $locparams = array('contact_id' => $domain['contact_id']); $values['location'] = CRM_Core_BAO_Location::getValues($locparams, TRUE); $address_array = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'postal_code', 'country_id', 'geo_code_1', 'geo_code_2'); if (!empty($values['location']['email'])) { $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]); } if (!empty($values['location']['phone'])) { $domain['domain_phone'] = array('phone_type' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', CRM_Utils_Array::value('phone_type_id', $values['location']['phone'][1])), 'phone' => CRM_Utils_Array::value('phone', $values['location']['phone'][1])); } if (!empty($values['location']['address'])) { foreach ($address_array as $value) { $domain['domain_address'][$value] = CRM_Utils_Array::value($value, $values['location']['address'][1]); } } list($domain['from_name'], $domain['from_email']) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE); $domains[$domain['id']] = array_merge($domains[$domain['id']], $domain); } } return civicrm_api3_create_success($domains, $params, 'domain', 'get', $bao); }
function __construct() { $this->activityTypes = CRM_Core_PseudoConstant::activityType(true, true); asort($this->activityTypes); $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Modified By'), 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name' => array('title' => ts('Modified By'))), 'grouping' => 'contact-fields'), 'civicrm_contact_touched' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name_touched' => array('title' => ts('Touched Contact'), 'name' => 'display_name', 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name_touched' => array('title' => ts('Touched Contact'), 'name' => 'sort_name')), 'grouping' => 'contact-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('title' => ts('Activity'), 'no_display' => true, 'required' => true), 'subject' => array('title' => ts('Touched Activity'), 'required' => true), 'activity_type_id' => array('title' => ts('Activity Type'), 'required' => true), 'source_contact_id' => array('no_display' => true, 'required' => true))), 'civicrm_log' => array('dao' => 'CRM_Core_DAO_Log', 'fields' => array('modified_date' => array('title' => ts('Modified Date'), 'required' => true), 'data' => array('title' => ts('Description'))), 'filters' => array('modified_date' => array('title' => ts('Modified Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, 'default' => 'this.week')))); parent::__construct(); }
/** * Get all groups from database, filtered by permissions * for this user * * @param string $groupType type of group(Access/Mailing) * @param boolen $excludeHidden exclude hidden groups. * * @access public * @static * * @return array - array reference of all groups. * */ public static function &group($groupType = NULL, $excludeHidden = TRUE) { if (!isset(self::$_viewPermissionedGroups)) { self::$_viewPermissionedGroups = self::$_editPermissionedGroups = array(); $groups =& CRM_Core_PseudoConstant::allGroup($groupType, $excludeHidden); if (self::check('edit all contacts')) { // this is the most powerful permission, so we return // immediately rather than dilute it further self::$_editAdminUser = self::$_viewAdminUser = TRUE; self::$_editPermission = self::$_viewPermission = TRUE; self::$_editPermissionedGroups = $groups; self::$_viewPermissionedGroups = $groups; return self::$_viewPermissionedGroups; } elseif (self::check('view all contacts')) { self::$_viewAdminUser = TRUE; self::$_viewPermission = TRUE; self::$_viewPermissionedGroups = $groups; } $ids = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_saved_search', $groups); foreach (array_values($ids) as $id) { $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'title'); self::$_viewPermissionedGroups[$id] = $title; self::$_viewPermission = TRUE; } $ids = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_saved_search', $groups); foreach (array_values($ids) as $id) { $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'title'); self::$_editPermissionedGroups[$id] = $title; self::$_viewPermissionedGroups[$id] = $title; self::$_editPermission = TRUE; self::$_viewPermission = TRUE; } } return self::$_viewPermissionedGroups; }
/** * @param \Civi\CCase\Event\CaseChangeEvent $event * * @throws \CiviCRM_API3_Exception */ public function onCaseChange(\Civi\CCase\Event\CaseChangeEvent $event) { /** @var \Civi\CCase\Analyzer $analyzer */ $analyzer = $event->analyzer; $activitySetXML = $this->getSequenceXml($analyzer->getXml()); if (!$activitySetXML) { return; } $actTypes = array_flip(\CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name')); $actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name')); $actIndex = $analyzer->getActivityIndex(array('activity_type_id', 'status_id')); foreach ($activitySetXML->ActivityTypes->ActivityType as $actTypeXML) { $actTypeId = $actTypes[(string) $actTypeXML->name]; if (empty($actIndex[$actTypeId])) { // Haven't tried this step yet! $this->createActivity($analyzer, $actTypeXML); return; } elseif (empty($actIndex[$actTypeId][$actStatuses['Completed']])) { // Haven't gotten past this step yet! return; } } // OK, the activity has completed every step in the sequence! civicrm_api3('Case', 'create', array('id' => $analyzer->getCaseId(), 'status_id' => 'Closed')); $analyzer->flush(); }
function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $campaigns = CRM_Campaign_BAO_Campaign::getCampaignSummary(); if (!empty($campaigns)) { $campaignType = CRM_Core_PseudoConstant::campaignType(); $campaignStatus = CRM_Core_PseudoConstant::campaignStatus(); foreach ($campaigns as $cmpid => $campaign) { $campaigns[$cmpid]['campaign_id'] = $campaign['id']; $campaigns[$cmpid]['title'] = $campaign['title']; $campaigns[$cmpid]['name'] = $campaign['name']; $campaigns[$cmpid]['description'] = $campaign['description']; $campaigns[$cmpid]['campaign_type_id'] = $campaignType[$campaign['campaign_type_id']]; $campaigns[$cmpid]['status_id'] = $campaignStatus[$campaign['status_id']]; $action = array_sum(array_keys($this->actionLinks())); if ($campaign['is_active']) { $action -= CRM_Core_Action::ENABLE; } else { $action -= CRM_Core_Action::DISABLE; } $campaigns[$cmpid]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $campaign['id']), ts('more'), FALSE, 'campaign.selector.row', 'Campaign', $campaign['id']); } } $this->assign('campaigns', $campaigns); $this->assign('addCampaignUrl', CRM_Utils_System::url('civicrm/campaign/add', 'reset=1&action=add')); }
/** * Return the proper mail store implementation, based on config settings * * @param string $name * Name of the settings set from civimail_mail_settings to use (null for default). * * @throws Exception * @return object * mail store implementation for processing CiviMail-bound emails */ public static function getStore($name = NULL) { $dao = new CRM_Core_DAO_MailSettings(); $dao->domain_id = CRM_Core_Config::domainID(); $name ? $dao->name = $name : ($dao->is_default = 1); if (!$dao->find(TRUE)) { throw new Exception("Could not find entry named {$name} in civicrm_mail_settings"); } $protocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); if (empty($protocols[$dao->protocol])) { throw new Exception("Empty mail protocol"); } switch ($protocols[$dao->protocol]) { case 'IMAP': return new CRM_Mailing_MailStore_Imap($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl, $dao->source); case 'POP3': return new CRM_Mailing_MailStore_Pop3($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl); case 'Maildir': return new CRM_Mailing_MailStore_Maildir($dao->source); case 'Localdir': return new CRM_Mailing_MailStore_Localdir($dao->source); // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards case 'mbox': return new CRM_Mailing_MailStore_Mbox($dao->source); default: throw new Exception("Unknown protocol {$dao->protocol}"); } }
public function setUp() { $this->_apiversion = 3; CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name'); parent::setUp(); $this->useTransaction(TRUE); }
/** * Run the page. * * This method is called after the page is created. */ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')); $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); $entityBlock = array('contact_id' => $contactId); $phones = CRM_Core_BAO_Phone::getValues($entityBlock); if (!empty($phones)) { foreach ($phones as $key => &$value) { $value['location_type'] = $locationTypes[$value['location_type_id']]; $value['phone_type'] = $phoneTypes[$value['phone_type_id']]; } } $contact = new CRM_Contact_BAO_Contact(); $contact->id = $contactId; $contact->find(TRUE); $privacy = array(); foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) { if (isset($contact->{$name})) { $privacy[$name] = $contact->{$name}; } } $this->assign('contactId', $contactId); $this->assign('phone', $phones); $this->assign('privacy', $privacy); // check logged in user permission CRM_Contact_Page_View::checkUserPermission($this, $contactId); // finally call parent parent::run(); }
function setUp() { parent::setUp(); // Create Group For Individual Contact Type $groupIndividual = array('title' => 'TestGroup For Indivi' . substr(sha1(rand()), 0, 5), 'extends' => array('Individual'), 'style' => 'Inline', 'is_active' => 1); $this->CustomGroupIndividual = $this->customGroupCreate($groupIndividual); $this->IndividualField = $this->customFieldCreate(array('custom_group_id' => $this->CustomGroupIndividual['id'])); // Create Group For Individual-Student Contact Sub Type $groupIndiStudent = array('title' => 'Student Test' . substr(sha1(rand()), 0, 5), 'extends' => array('Individual', array('Student')), 'style' => 'Inline', 'is_active' => 1); $this->CustomGroupIndiStudent = $this->customGroupCreate($groupIndiStudent); $this->IndiStudentField = $this->customFieldCreate(array('custom_group_id' => $this->CustomGroupIndiStudent['id'])); $params = array('first_name' => 'Mathev', 'last_name' => 'Adison', 'contact_type' => 'Individual'); $this->individual = $this->individualCreate($params); $params = array('first_name' => 'Steve', 'last_name' => 'Tosun', 'contact_type' => 'Individual', 'contact_sub_type' => 'Student'); $this->individualStudent = $this->individualCreate($params); $params = array('first_name' => 'Mark', 'last_name' => 'Dawson', 'contact_type' => 'Individual', 'contact_sub_type' => 'Parent'); $this->individualParent = $this->individualCreate($params); $params = array('organization_name' => 'Wellspring', 'contact_type' => 'Organization'); $this->organization = $this->organizationCreate($params); $params = array('organization_name' => 'SubUrban', 'contact_type' => 'Organization', 'contact_sub_type' => 'Sponsor'); $this->organizationSponsor = $this->organizationCreate($params); //refresh php cached variables CRM_Core_PseudoConstant::flush(); CRM_Core_BAO_CustomField::getTableColumnGroup($this->IndividualField['id'], True); CRM_Core_BAO_CustomField::getTableColumnGroup($this->IndiStudentField['id'], True); }
function __construct() { // Check if CiviCampaign is a) enabled and b) has active campaigns $config = CRM_Core_Config::singleton(); $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); if ($campaignEnabled) { $getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE); $this->activeCampaigns = $getCampaigns['campaigns']; asort($this->activeCampaigns); } $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Donor Name'), 'required' => TRUE), 'first_name' => array('title' => ts('First Name')), 'last_name' => array('title' => ts('Last Name')), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType'))), 'filters' => array('sort_name' => array('title' => ts('Donor Name'), 'operator' => 'like'), 'id' => array('title' => ts('Contact ID'), 'no_display' => TRUE, 'type' => CRM_Utils_Type::T_INT)), 'order_bys' => array('sort_name' => array('title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC')), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Donor Email'), 'default' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Donor Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'contact-fields'), 'civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('contribution_id' => array('name' => 'id', 'no_display' => TRUE, 'required' => TRUE), 'list_contri_id' => array('name' => 'id', 'title' => ts('Contribution ID')), 'contribution_or_soft' => array('title' => ts('Contribution OR Soft Credit?'), 'dbAlias' => "'Contribution'"), 'soft_credits' => array('title' => ts('Soft Credits'), 'dbAlias' => "NULL"), 'soft_credit_for' => array('title' => ts('Soft Credit For'), 'dbAlias' => "NULL"), 'financial_type_id' => array('title' => ts('Financial Type'), 'default' => TRUE), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'contribution_page_id' => array('title' => ts('Contribution Page')), 'source' => array('title' => ts('Source')), 'payment_instrument_id' => array('title' => ts('Payment Type')), 'check_number' => array('title' => ts('Check Number')), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'trxn_id' => NULL, 'receive_date' => array('default' => TRUE), 'receipt_date' => NULL, 'fee_amount' => NULL, 'net_amount' => NULL, 'total_amount' => array('title' => ts('Amount'), 'required' => TRUE, 'statistics' => array('sum' => ts('Amount')))), 'filters' => array('contribution_or_soft' => array('title' => ts('Contribution OR Soft Credit?'), 'clause' => "(1)", 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_STRING, 'options' => array('both' => ts('Both'), 'contributions_only' => ts('Contributions Only'), 'soft_credits_only' => ts('Soft Credits Only'))), 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'financial_type_id' => array('title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), 'type' => CRM_Utils_Type::T_INT), 'contribution_page_id' => array('title' => ts('Contribution Page'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionPage(), 'type' => CRM_Utils_Type::T_INT), 'payment_instrument_id' => array('title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), 'type' => CRM_Utils_Type::T_INT), 'contribution_status_id' => array('title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1), 'type' => CRM_Utils_Type::T_INT), 'total_amount' => array('title' => ts('Contribution Amount'))), 'order_bys' => array('financial_type_id' => array('title' => ts('Financial Type')), 'contribution_status_id' => array('title' => ts('Contribution Status')), 'payment_instrument_id' => array('title' => ts('Payment Instrument'))), 'grouping' => 'contri-fields'), 'civicrm_contribution_soft' => array('dao' => 'CRM_Contribute_DAO_ContributionSoft', 'fields' => array('soft_credit_type_id' => array('title' => ts('Soft Credit Type'))), 'filters' => array('soft_credit_type_id' => array('title' => 'Soft Credit Type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group(), 'type' => CRM_Utils_Type::T_INT))), 'civicrm_contribution_ordinality' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'alias' => 'cordinality', 'filters' => array('ordinality' => array('title' => ts('Contribution Ordinality'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => array(0 => 'First by Contributor', 1 => 'Second or Later by Contributor'), 'type' => CRM_Utils_Type::T_INT))), 'civicrm_note' => array('dao' => 'CRM_Core_DAO_Note', 'fields' => array('contribution_note' => array('name' => 'note', 'title' => ts('Contribution Note'))), 'filters' => array('note' => array('name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING)))) + $this->addAddressFields(FALSE); $this->_tagFilter = TRUE; // Don't show Batch display column and filter unless batches are being used $this->_allBatches = CRM_Batch_BAO_Batch::getBatches(); if (!empty($this->_allBatches)) { $this->_columns['civicrm_batch']['dao'] = 'CRM_Batch_DAO_Batch'; $this->_columns['civicrm_batch']['fields']['batch_id'] = array('name' => 'id', 'title' => ts('Batch Name')); $this->_columns['civicrm_batch']['filters']['bid'] = array('name' => 'id', 'title' => ts('Batch Name'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_allBatches); $this->_columns['civicrm_entity_batch']['dao'] = 'CRM_Batch_DAO_EntityBatch'; $this->_columns['civicrm_entity_batch']['fields']['entity_batch_id'] = array('name' => 'batch_id', 'default' => TRUE, 'no_display' => TRUE); } // If we have active campaigns add those elements to both the fields and filters if ($campaignEnabled && !empty($this->activeCampaigns)) { $this->_columns['civicrm_contribution']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); $this->_columns['civicrm_contribution']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns); $this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign')); } $this->_currencyColumn = 'civicrm_contribution_currency'; parent::__construct(); }
function buildForm(&$form) { $groups =& CRM_Core_PseudoConstant::group(); $tags =& CRM_Core_PseudoConstant::tag(); if (count($groups) == 0 || count($tags) == 0) { CRM_Core_Session::setStatus(ts("Atleast one Group and Tag must be present, for Custom Group / Tag search.")); $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'); CRM_Utils_System::redirect($url); } $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $andOr =& $form->addElement('checkbox', 'andOr', 'Combine With (AND, Uncheck For OR)', null, array('checked' => 'checked')); $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect')); //add/remove buttons for groups $inG->setButtonAttributes('add', array('value' => ts('Add >>'))); $outG->setButtonAttributes('add', array('value' => ts('Add >>'))); $inG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outG->setButtonAttributes('remove', array('value' => ts('<< Remove'))); //add/remove buttons for tags $int->setButtonAttributes('add', array('value' => ts('Add >>'))); $outt->setButtonAttributes('add', array('value' => ts('Add >>'))); $int->setButtonAttributes('remove', array('value' => ts('<< Remove'))); $outt->setButtonAttributes('remove', array('value' => ts('<< Remove'))); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags')); }
/** * This function is the main function that is called when the page loads, it decides the which action has to be taken for the page. * * return null * @access public */ function run() { $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse'); $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this); $this->assign('action', $this->_action); $this->assign('context', $this->_context); $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); CRM_Pledge_Page_Tab::setContext(); if ($this->_action & CRM_Core_Action::UPDATE) { $this->edit(); // set page title CRM_Contact_Page_View::setTitle($this->_contactId); } else { $pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this); $paymentDetails = CRM_Pledge_BAO_PledgePayment::getPledgePayments($pledgeId); $this->assign('rows', $paymentDetails); $this->assign('pledgeId', $pledgeId); $this->assign('contactId', $this->_contactId); // check if we can process credit card contribs $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )"); if (count($processors) > 0) { $this->assign('newCredit', TRUE); } else { $this->assign('newCredit', FALSE); } // check is the user has view/edit signer permission $permission = 'view'; if (CRM_Core_Permission::check('edit pledges')) { $permission = 'edit'; } $this->assign('permission', $permission); } return parent::run(); }
/** * This function provides the HTML form elements that are specific to the Individual Contact Type * * @access public * @return None */ function buildQuickForm(&$form) { $form->applyFilter('__ALL__', 'trim'); // prefix $form->addElement('select', 'prefix_id', ts('Prefix'), array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::individualPrefix()); $attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Individual'); // first_name $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']); //middle_name $form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']); // last_name $form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']); // suffix $form->addElement('select', 'suffix_id', ts('Suffix'), array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::individualSuffix()); // nick_name $form->addElement('text', 'nick_name', ts('Nick Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name')); // greeting type $form->addElement('select', 'greeting_type', ts('Greeting'), CRM_Core_SelectValues::greeting()); // job title $form->addElement('text', 'job_title', ts('Job title'), $attributes['job_title']); // radio button for gender $genderOptions = array(); $gender = CRM_Core_PseudoConstant::gender(); foreach ($gender as $key => $var) { $genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key); } $form->addGroup($genderOptions, 'gender_id', ts('Gender')); $form->addElement('checkbox', 'is_deceased', null, ts('Contact is deceased')); $form->addElement('date', 'birth_date', ts('Date of birth'), CRM_Core_SelectValues::date('birth')); $form->addRule('birth_date', ts('Select a valid date.'), 'qfDate'); $form->addElement('text', 'home_URL', ts('Website'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'home_URL')); $form->addRule('home_URL', ts('Enter a valid Website.'), 'url'); $config =& CRM_Core_Config::singleton(); CRM_Core_ShowHideBlocks::links($this, 'demographics', '', ''); }
function run() { // Prepares variables for being sent to Smarty //Only show countries with attached information $countries = null; $stats = civicrm_api3('Bic', 'stats'); foreach ($stats['values'] as $country => $count) { $countries[] = $country; } // Get country names $country_names = null; if ($countries) { $config = CRM_Core_Config::singleton(); $country_names = array(); $id2code = CRM_Core_PseudoConstant::countryIsoCode(); $default_country = $id2code[$config->defaultContactCountry]; $code2id = array_flip($id2code); $id2country = CRM_Core_PseudoConstant::country(false, false); foreach ($countries as $code) { $country_id = $code2id[$code]; $country_name = $id2country[$country_id]; $country_names[$code] = $country_name; } } // Sends variables to Smarty $this->assign('countries', $countries); $this->assign('country_names', $country_names); $this->assign('default_country', $default_country); $this->assign('show_message', true); parent::run(); }
/** * format a monetary string * * Format a monetary string basing on the amount provided, * ISO currency code provided and a format string consisting of: * * %a - the formatted amount * %C - the currency ISO code (e.g., 'USD') if provided * %c - the currency symbol (e.g., '$') if available * * @param float $amount the monetary amount to display (1234.56) * @param string $currency the three-letter ISO currency code ('USD') * @param string $format the desired currency format * * @return string formatted monetary string * * @static */ static function format($amount, $currency = null, $format = null) { if (CRM_Utils_System::isNull($amount)) { return ''; } $config =& CRM_Core_Config::singleton(); if (!self::$_currencySymbols) { require_once "CRM/Core/PseudoConstant.php"; $currencySymbolName = CRM_Core_PseudoConstant::currencySymbols('name'); $currencySymbol = CRM_Core_PseudoConstant::currencySymbols(); self::$_currencySymbols = array_combine($currencySymbolName, $currencySymbol); } if (!$currency) { $currency = $config->defaultCurrency; } if (!$format) { $format = $config->moneyformat; } // money_format() exists only in certain PHP install (CRM-650) if (is_numeric($amount) and function_exists('money_format')) { $amount = money_format($config->moneyvalueformat, $amount); } $replacements = array('%a' => $amount, '%C' => $currency, '%c' => CRM_Utils_Array::value($currency, self::$_currencySymbols, $currency)); return strtr($format, $replacements); }
/** * build the form elements for a phone object * * @param CRM_Core_Form $form reference to the form object * @param int $addressBlockCount block number to build * @param boolean $blockEdit is it block edit * * @return void * @access public * @static */ static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockEdit = FALSE) { // passing this via the session is AWFUL. we need to fix this if (!$addressBlockCount) { $blockId = $form->get('Phone_Block_Count') ? $form->get('Phone_Block_Count') : 1; } else { $blockId = $addressBlockCount; } $form->applyFilter('__ALL__', 'trim'); //phone type select $form->addElement('select', "phone[{$blockId}][phone_type_id]", ts('Phone'), CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')); //main phone number with crm_phone class $form->addElement('text', "phone[{$blockId}][phone]", ts('Phone'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'), array('class' => 'crm_phone twelve'))); // phone extension $form->addElement('text', "phone[{$blockId}][phone_ext]", ts('Extension'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone_ext')); if (isset($form->_contactType) || $blockEdit) { //Block type select $form->addElement('select', "phone[{$blockId}][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id')); //is_Primary radio $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );'); $form->addElement('radio', "phone[{$blockId}][is_primary]", '', '', '1', $js); } // TODO: set this up as a group, we need a valid phone_type_id if we have a phone number // $form->addRule( "location[$locationId][phone][$locationId][phone]", ts('Phone number is not valid.'), 'phone' ); }
function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name' => array('title' => ts('Contact Name'), 'no_repeat' => TRUE), 'postal_greeting_display' => array('title' => ts('Postal Greeting')), 'id' => array('no_display' => TRUE, 'required' => TRUE)), 'grouping' => 'contact-fields', 'group_bys' => array('id' => array('title' => ts('Contact ID')), 'sort_name' => array('title' => ts('Contact Name')))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('no_repeat' => TRUE, 'title' => ts('email'))), 'grouping' => 'contact-fields'), 'civicrm_pledge' => array('dao' => 'CRM_Pledge_DAO_Pledge', 'fields' => array('id' => array('no_display' => TRUE, 'required' => FALSE), 'currency' => array('required' => TRUE, 'no_display' => TRUE), 'amount' => array('title' => ts('Pledge Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'statistics' => array('sum' => ts('Aggregate Amount Pledged'), 'count' => ts('Pledges'), 'avg' => ts('Average'))), 'frequency_unit' => array('title' => ts('Frequency Unit')), 'installments' => array('title' => ts('Installments')), 'pledge_create_date' => array('title' => ts('Pledge Made Date')), 'start_date' => array('title' => ts('Pledge Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('Pledge End Date'), 'type' => CRM_Utils_Type::T_DATE), 'status_id' => array('title' => ts('Pledge Status'))), 'filters' => array('pledge_create_date' => array('title' => 'Pledge Made Date', 'operatorType' => CRM_Report_Form::OP_DATE), 'pledge_amount' => array('title' => ts('Pledged Amount'), 'operatorType' => CRM_Report_Form::OP_INT), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'sid' => array('name' => 'status_id', 'title' => ts('Pledge Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('contribution_status'))), 'group_bys' => array('pledge_create_date' => array('frequency' => TRUE, 'default' => TRUE, 'chart' => TRUE), 'frequency_unit' => array('title' => ts('Frequency Unit')), 'status_id' => array('title' => ts('Pledge Status')))), 'civicrm_pledge_payment' => array('dao' => 'CRM_Pledge_DAO_PledgePayment', 'fields' => array('total_paid' => array('title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_STRING, 'dbAlias' => 'sum(pledge_payment_civireport.actual_amount)'))), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts(' Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::group())))) + $this->addAddressFields(); $this->_tagFilter = TRUE; $this->_currencyColumn = 'civicrm_pledge_currency'; parent::__construct(); }
function __construct() { $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('id' => array('no_display' => TRUE, 'required' => TRUE), 'display_name' => array('title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE), 'first_name' => array('title' => ts('First Name')), 'last_name' => array('title' => ts('Last Name')), 'contact_type' => array('title' => ts('Contact Type')), 'contact_sub_type' => array('title' => ts('Contact SubType'))))) + $this->getAddressColumns() + array('civicrm_contribution' => array('dao' => 'CRM_Contribute_DAO_Contribution', 'fields' => array('total_amount' => array('title' => ts('Amount Statistics'), 'required' => TRUE, 'statistics' => array('sum' => ts('Aggregate Amount'), 'count' => ts('Donations'), 'avg' => ts('Average'))), 'currency' => array('required' => TRUE, 'no_display' => TRUE)), 'filters' => array('receive_date' => array('default' => 'this.year', 'operatorType' => CRM_Report_Form::OP_DATE), 'currency' => array('title' => 'Currency', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING), 'total_range' => array('title' => ts('Show no. of Top Donors'), 'type' => CRM_Utils_Type::T_INT, 'default_op' => 'eq'), 'financial_type_id' => array('name' => 'financial_type_id', 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType()), 'contribution_status_id' => array('title' => ts('Donation Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'default' => array(1)))), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'email-fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => array('title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE)), 'grouping' => 'phone-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_GroupContact', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::nestedGroup())))); $this->_tagFilter = TRUE; $this->_currencyColumn = 'civicrm_contribution_currency'; parent::__construct(); }
/** * @param $form */ function buildForm(&$form) { /** * You can define a custom title for the search form */ $this->setTitle('Find Latest Activities'); /** * Define the search form fields here */ // Allow user to choose which type of contact to limit search on $form->add('select', 'contact_type', ts('Find...'), CRM_Core_SelectValues::contactType()); // Text box for Activity Subject $form->add('text', 'activity_subject', ts('Activity Subject')); // Select box for Activity Type $activityType = array('' => ' - select activity - ') + CRM_Core_PseudoConstant::activityType(); $form->add('select', 'activity_type_id', ts('Activity Type'), $activityType, FALSE); // textbox for Activity Status $activityStatus = array('' => ' - select status - ') + CRM_Core_PseudoConstant::activityStatus(); $form->add('select', 'activity_status_id', ts('Activity Status'), $activityStatus, FALSE); // Activity Date range $form->addDate('start_date', ts('Activity Date From'), FALSE, array('formatType' => 'custom')); $form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom')); // Contact Name field $form->add('text', 'sort_name', ts('Contact Name')); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ $form->assign('elements', array('contact_type', 'activity_subject', 'activity_type_id', 'activity_status_id', 'start_date', 'end_date', 'sort_name')); }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); $this->setPageTitle(ts('Mail Account')); if ($this->_action & CRM_Core_Action::DELETE) { return; } $this->applyFilter('__ALL__', 'trim'); //get the attributes. $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_MailSettings'); //build setting form $this->add('text', 'name', ts('Name'), $attributes['name'], TRUE); $this->add('text', 'domain', ts('Email Domain'), $attributes['domain'], TRUE); $this->addRule('domain', ts('Email domain must use a valid internet domain format (e.g. \'example.org\').'), 'domain'); $this->add('text', 'localpart', ts('Localpart'), $attributes['localpart']); $this->add('text', 'return_path', ts('Return-Path'), $attributes['return_path']); $this->addRule('return_path', ts('Return-Path must use a valid email address format.'), 'email'); $this->add('select', 'protocol', ts('Protocol'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'), TRUE); $this->add('text', 'server', ts('Server'), $attributes['server']); $this->add('text', 'username', ts('Username'), array('autocomplete' => 'off')); $this->add('password', 'password', ts('Password'), array('autocomplete' => 'off')); $this->add('text', 'source', ts('Source'), $attributes['source']); $this->add('checkbox', 'is_ssl', ts('Use SSL?')); $usedfor = array(1 => ts('Bounce Processing'), 0 => ts('Email-to-Activity Processing')); $this->add('select', 'is_default', ts('Used For?'), $usedfor); }
/** * Class constructor. */ public function __construct() { // don’t display the ‘Add these Contacts to Group’ button $this->_add2groupSupported = FALSE; $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN); $this->loggingDB = $dsn['database']; // used for redirect back to contact summary $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $this->_logTables = array('log_civicrm_contact' => array('fk' => 'id'), 'log_civicrm_email' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_phone' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_address' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_note' => array('fk' => 'entity_id', 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_note_comment' => array('fk' => 'entity_id', 'table_name' => 'log_civicrm_note', 'joins' => array('table' => 'log_civicrm_note', 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'"), 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_group_contact' => array('fk' => 'contact_id', 'bracket_info' => array('entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title'), 'action_column' => 'status', 'log_type' => 'Group'), 'log_civicrm_entity_tag' => array('fk' => 'entity_id', 'bracket_info' => array('entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name'), 'entity_table' => TRUE), 'log_civicrm_relationship' => array('fk' => 'contact_id_a', 'bracket_info' => array('entity_column' => 'relationship_type_id', 'table' => 'log_civicrm_relationship_type', 'column' => 'label_a_b')), 'log_civicrm_activity_for_target' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_assignee' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_source' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_case' => array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_case_contact', 'join' => 'entity_log_civireport.id = fk_table.case_id'), 'bracket_info' => array('entity_column' => 'case_type_id', 'options' => CRM_Case_PseudoConstant::caseType('title', FALSE)))); $logging = new CRM_Logging_Schema(); // build _logTables for contact custom tables $customTables = $logging->entityCustomDataLogTables('Contact'); foreach ($customTables as $table) { $this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact'); } // build _logTables for address custom tables $customTables = $logging->entityCustomDataLogTables('Address'); foreach ($customTables as $table) { $this->_logTables[$table] = array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_address', 'join' => 'entity_log_civireport.entity_id = fk_table.id'), 'log_type' => 'Contact'); } // Allow log tables to be extended via report hooks. CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables); parent::__construct(); }
/** * Get all groups from database, filtered by permissions * for this user * * @access public * @static * * @return array - array reference of all groups. * */ function &group() { if (!isset($GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'])) { $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'] = $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermissionedGroups'] = array(); $groups =& CRM_Core_PseudoConstant::allGroup(); if (CRM_Utils_System::checkPermission('edit all contacts')) { // this is the most powerful permission, so we return // immediately rather than dilute it further $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editAdminUser'] = $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewAdminUser'] = true; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermission'] = $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermission'] = true; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermissionedGroups'] = $groups; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'] = $groups; return $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups']; } else { if (CRM_Utils_System::checkPermission('view all contacts')) { $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewAdminUser'] = true; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermission'] = true; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'] = $groups; } } foreach ($groups as $id => $title) { if (CRM_Utils_System::checkPermission(CRM_CORE_PERMISSION_EDIT_GROUPS . $title)) { $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermissionedGroups'][$id] = $title; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'][$id] = $title; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_editPermission'] = true; } else { if (CRM_Utils_System::checkPermission(CRM_CORE_PERMISSION_VIEW_GROUPS . $title)) { $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups'][$id] = $title; $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermission'] = true; } } } } return $GLOBALS['_CRM_CORE_PERMISSION_DRUPAL']['_viewPermissionedGroups']; }