本文整理汇总了PHP中CRM_Core_PseudoConstant::gender方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::gender方法的具体用法?PHP CRM_Core_PseudoConstant::gender怎么用?PHP CRM_Core_PseudoConstant::gender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::gender方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Contact Name'), 'required' => true, 'no_repeat' => true), 'gender_id' => array('title' => ts('Gender'), 'default' => true), 'birth_date' => array('title' => ts('Birthdate'), 'default' => false), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name' => array('title' => ts('Contact Name')), 'contact_type' => array('title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => ts('-select-'), 'Individual' => ts('Individual'), 'Organization' => ts('Organization'), 'Household' => ts('Household')), 'default' => 'Individual'), 'id' => array('title' => ts('Contact ID'), 'no_display' => true)), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email' => array('title' => ts('Email'), 'no_repeat' => true)), 'grouping' => 'contact-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', 'fields' => array('street_address' => array('default' => false), 'city' => array('default' => true), 'postal_code' => null, 'state_province_id' => array('title' => ts('State/Province')), 'country_id' => array('title' => ts('Country'), 'default' => false))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('phone' => null), 'grouping' => 'contact-fields'), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('title' => ts('Activity ID'), 'no_display' => true, 'required' => true))), 'civicrm_case' => array('dao' => 'CRM_Case_DAO_Case', 'fields' => array('id' => array('title' => ts('Case ID'), 'required' => true), 'start_date' => array('title' => ts('Case Start'), 'required' => true), 'end_date' => array('title' => ts('Case End'), 'required' => true)), 'filters' => array('case_id_filter' => array('name' => 'id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both')), 'default' => 3), 'start_date' => array('title' => ts('Case Start'), 'operatorType' => CRM_Report_Form::OP_DATE), 'end_date' => array('title' => ts('Case End'), 'operatorType' => CRM_Report_Form::OP_DATE))), '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()))));
$open_case_val = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
$crmDAO =& CRM_Core_DAO::executeQuery("SELECT cg.table_name, cg.extends AS ext, cf.label, cf.column_name FROM civicrm_custom_group cg INNER JOIN civicrm_custom_field cf ON cg.id = cf.custom_group_id\nwhere (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_column_value='{$open_case_val}') AND cg.is_active=1 AND cf.is_active=1 ORDER BY cg.table_name");
$curTable = '';
$curExt = '';
$curFields = array();
while ($crmDAO->fetch()) {
if ($curTable == '') {
$curTable = $crmDAO->table_name;
$curExt = $crmDAO->ext;
} elseif ($curTable != $crmDAO->table_name) {
$this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt);
$curTable = $crmDAO->table_name;
$curExt = $crmDAO->ext;
$curFields = array();
}
$curFields[$crmDAO->column_name] = array('title' => $crmDAO->label);
}
if (!empty($curFields)) {
$this->_columns[$curTable] = array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt);
}
$this->_genders = CRM_Core_PseudoConstant::gender();
parent::__construct();
}
示例2: buildQuickForm
/**
* 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', '', '');
}
示例3: civicrm_api3_contact_create
/**
* Create or update a contact (note you should always call this via civicrm_api() & never directly)
*
* @param array $params input parameters
*
* Allowed @params array keys are:
* {@getfields contact_create}
*
*
* @example ContactCreate.php Example of Create Call
*
* @return array API Result Array
*
* @static void
* @access public
*/
function civicrm_api3_contact_create($params)
{
$contactID = CRM_Utils_Array::value('contact_id', $params, CRM_Utils_Array::value('id', $params));
$dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
$values = _civicrm_api3_contact_check_params($params, $dupeCheck);
if ($values) {
return $values;
}
if (empty($contactID)) {
// If we get here, we're ready to create a new contact
if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
require_once 'CRM/Core/BAO/LocationType.php';
$defLocType = CRM_Core_BAO_LocationType::getDefault();
$params['email'] = array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => $defLocType->id ? $defLocType->id : 1));
}
}
if (CRM_Utils_Array::value('home_url', $params)) {
require_once 'CRM/Core/PseudoConstant.php';
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
}
if (isset($params['suffix_id']) && !is_numeric($params['suffix_id'])) {
$params['suffix_id'] = array_search($params['suffix_id'], CRM_Core_PseudoConstant::individualSuffix());
}
if (isset($params['prefix_id']) && !is_numeric($params['prefix_id'])) {
$params['prefix_id'] = array_search($params['prefix_id'], CRM_Core_PseudoConstant::individualPrefix());
}
if (isset($params['gender_id']) && !is_numeric($params['gender_id'])) {
$params['gender_id'] = array_search($params['gender_id'], CRM_Core_PseudoConstant::gender());
}
$error = _civicrm_api3_greeting_format_params($params);
if (civicrm_error($error)) {
return $error;
}
$values = array();
$entityId = $contactID;
if (!CRM_Utils_Array::value('contact_type', $params) && $entityId) {
$params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($entityId);
}
if (!isset($params['contact_sub_type']) && $entityId) {
require_once 'CRM/Contact/BAO/Contact.php';
$params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($entityId);
}
_civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $entityId);
$params = array_merge($params, $values);
$contact = _civicrm_api3_contact_update($params, $contactID);
if (is_a($contact, 'CRM_Core_Error')) {
return civicrm_api3_create_error($contact->_errors[0]['message']);
} else {
$values = array();
_civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]);
}
return civicrm_api3_create_success($values, $params, 'Contact', 'create');
}
示例4: buildQuickForm
/**
* build the form elements for Demographics object
*
* @param CRM_Core_Form $form reference to the form object
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form)
{
// radio button for gender
$genderOptions = array();
$gender = CRM_Core_PseudoConstant::gender(TRUE);
foreach ($gender as $key => $var) {
$genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key, array('id' => "civicrm_gender_{$var}_{$key}"));
}
$form->addGroup($genderOptions, 'gender_id', ts('Gender'));
$form->addDate('birth_date', ts('Date of birth'), FALSE, array('formatType' => 'birth'));
$form->addElement('checkbox', 'is_deceased', NULL, ts('Contact is deceased'), array('onclick' => "showDeceasedDate()"));
$form->addDate('deceased_date', ts('Deceased date'), FALSE, array('formatType' => 'birth'));
}
示例5: buildQuickForm
/**
* build the form elements for Demographics object
*
* @param CRM_Core_Form $form reference to the form object
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form)
{
// 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->addDate('birth_date', ts('Date of birth'), false, array('formatType' => 'birth'));
$form->addElement('checkbox', 'is_deceased', null, ts('Contact is deceased'), array('onclick' => "showDeceasedDate()"));
$form->addDate('deceased_date', ts('Deceased date'), false, array('formatType' => 'birth'));
}
示例6: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$params = array('id' => $contactId);
$defaults = array();
CRM_Contact_BAO_Contact::getValues($params, $defaults);
if (CRM_Utils_Array::value('gender_id', $defaults)) {
$gender = CRM_Core_PseudoConstant::gender();
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
$this->assign('contactId', $contactId);
$this->assign($defaults);
//for birthdate format with respect to birth format set
$this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例7: buildQuickForm
/**
* build a form for the given UF group
*
* @param int $id the group id
* @param CRM_Core_Form $form the form element
* @param string $name the name that we should store the fields as
* @param array $allFields reference to the array where all the fields are stored
*
* @return void
* @static
* @access public
*/
function buildQuickForm($id, &$form, $name, &$allFields)
{
$fields =& CRM_Core_BAO_UFGroup::getFields($id, false, $action);
foreach ($fields as $n => $fld) {
if (!array_key_exists($n, $allFields)) {
$allFields[$n] = $fld;
}
}
$form->assign($name, $fields);
foreach ($fields as $name => $field) {
$required = $field['is_required'];
if (substr($field['name'], 0, 14) === 'state_province') {
$form->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(), $required);
} else {
if (substr($field['name'], 0, 7) === 'country') {
$form->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required);
} else {
if ($field['name'] === 'birth_date') {
$form->add('date', $field['name'], $field['title'], CRM_Core_SelectValues::date('birth'));
} else {
if ($field['name'] === '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, $field['name'], $field['title']);
} else {
if ($field['name'] === 'individual_prefix') {
$form->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualPrefix());
} else {
if ($field['name'] === 'individual_suffix') {
$form->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualSuffix());
} else {
if ($field['name'] === 'group') {
require_once 'CRM/Contact/Form/GroupTag.php';
CRM_Contact_Form_GroupTag::buildGroupTagBlock($form, 0, CRM_CONTACT_FORM_GROUPTAG_GROUP);
} else {
if ($field['name'] === 'tag') {
require_once 'CRM/Contact/Form/GroupTag.php';
CRM_Contact_Form_GroupTag::buildGroupTagBlock($form, 0, CRM_CONTACT_FORM_GROUPTAG_TAG);
} else {
if (substr($field['name'], 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name']);
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, $inactiveNeeded, false);
if ($required) {
$form->addRule($name, ts('%1 is a required field.', array(1 => $field['title'])), 'required');
}
} else {
$form->add('text', $name, $field['title'], $field['attributes'], $required);
}
}
}
}
}
}
}
}
}
if ($field['rule']) {
$form->addRule($name, ts('Please enter a valid %1', array(1 => $field['title'])), $field['rule']);
}
}
}
示例8: __construct
function __construct()
{
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name' => array('title' => ts('Contact Name'), 'required' => true, 'no_repeat' => true)), 'grouping' => 'contact-fields', 'filters' => array('display_name' => array('title' => ts('Contact Name'), 'operator' => 'like'), 'gender_id' => array('title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::gender()))), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince()))), 'civicrm_grant' => array('dao' => 'CRM_Grant_DAO_Grant', 'fields' => array('grant_type_id' => array('name' => 'grant_type_id', 'title' => ts('Grant Type')), 'status_id' => array('name' => 'status_id', 'title' => ts('Grant Status')), 'amount_requested' => array('name' => 'amount_requested', 'title' => ts('Amount Requested'), 'type' => CRM_Utils_Type::T_MONEY), 'amount_granted' => array('name' => 'amount_granted', 'title' => ts('Amount Granted')), 'application_received_date' => array('name' => 'application_received_date', 'title' => ts('Application Received Date'), 'default' => true), 'money_transfer_date' => array('name' => 'money_transfer_date', 'title' => ts('Money Transfer Date'), 'type' => CRM_Utils_Type::T_DATE), 'grant_due_date' => array('name' => 'grant_due_date', 'title' => ts('Grant Due Date'), 'type' => CRM_Utils_Type::T_DATE), 'rationale' => array('name' => 'rationale', 'title' => ts('Rationale')), 'grant_report_received' => array('name' => 'grant_report_received', 'title' => ts('Grant Report Received'))), 'filters' => array('grant_type' => array('name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Grant_PseudoConstant::grantType()), 'status_id' => array('name' => 'status_id', 'title' => ts('Grant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Grant_PseudoConstant::grantStatus()), 'amount_granted' => array('title' => ts('Amount Granted'), 'operatorType' => CRM_Report_Form::OP_INT), 'amount_requested' => array('title' => ts('Amount Requested'), 'operatorType' => CRM_Report_Form::OP_INT), 'application_received_date' => array('title' => ts('Application Received Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'money_transfer_date' => array('title' => ts('Money Transfer Date'), 'operatorType' => CRM_Report_Form::OP_DATE), 'grant_due_date' => array('title' => ts('Grant Due Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Report_Form::OP_DATE)), 'group_bys' => array('grant_type_id' => array('title' => ts('Grant Type')), 'status_id' => array('title' => ts('Grant Status')), 'amount_requested' => array('title' => ts('Amount Requested')), 'amount_granted' => array('title' => ts('Amount Granted')), 'application_received_date' => array('title' => ts('Application Received Date')), 'money_transfer_date' => array('title' => ts('Money Transfer Date')))));
parent::__construct();
}
示例9: view
/**
* View summary details of a contact
*
* @return void
* @access public
*/
function view()
{
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
$session->pushUserContext($url);
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = true;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, true);
$communicationType = array('phone' => array('type' => 'phoneType', 'id' => 'phone_type'), 'im' => array('type' => 'IMProvider', 'id' => 'provider'), 'website' => array('type' => 'websiteType', 'id' => 'website_type'), 'address' => array('skip' => true, 'customData' => 1), 'email' => array('skip' => true), 'openid' => array('skip' => true));
foreach ($communicationType as $key => $value) {
if (CRM_Utils_Array::value($key, $defaults)) {
foreach ($defaults[$key] as &$val) {
CRM_Utils_Array::lookupValue($val, 'location_type', CRM_Core_PseudoConstant::locationType(), false);
if (!CRM_Utils_Array::value('skip', $value)) {
eval('$pseudoConst = CRM_Core_PseudoConstant::' . $value['type'] . '( );');
CRM_Utils_Array::lookupValue($val, $value['id'], $pseudoConst, false);
}
}
if (isset($value['customData'])) {
foreach ($defaults[$key] as $blockId => $blockVal) {
$groupTree = CRM_Core_BAO_CustomGroup::getTree(ucfirst($key), $this, $blockVal['id']);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$defaults[$key][$blockId]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, false, null, "dnc_");
}
// reset template variable since that won't be of any use, and could be misleading
$this->assign("dnc_viewCustomData", null);
}
}
}
if (CRM_Utils_Array::value('gender_id', $defaults)) {
$gender = CRM_Core_PseudoConstant::gender();
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
// to make contact type label available in the template -
$contactType = array_key_exists('contact_sub_type', $defaults) ? $defaults['contact_sub_type'] : $defaults['contact_type'];
$defaults['contact_type_label'] = CRM_Contact_BAO_ContactType::contactTypePairs(true, $contactType);
// get contact tags
require_once 'CRM/Core/BAO/EntityTag.php';
$contactTags = CRM_Core_BAO_EntityTag::getContactTags($this->_contactId);
if (!empty($contactTags)) {
$defaults['contactTag'] = implode(', ', $contactTags);
}
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
//Show blocks only if they are visible in edit form
require_once 'CRM/Core/BAO/Preferences.php';
$this->_editOptions = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options');
$configItems = array('CommBlock' => 'Communication Preferences', 'Demographics' => 'Demographics', 'TagsAndGroups' => 'Tags and Groups', 'Notes' => 'Notes');
foreach ($configItems as $c => $t) {
$varName = '_show' . $c;
$this->{$varName} = CRM_Utils_Array::value($c, $this->_editOptions);
$this->assign(substr($varName, 1), $this->{$varName});
}
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']);
foreach ($defaults['address'] as $key => $addressValue) {
if (CRM_Utils_Array::value('master_id', $addressValue) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
}
}
$this->assign('sharedAddresses', $sharedAddresses);
//get the current employer name
if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
if ($contact->employer_id && $contact->organization_name) {
$defaults['current_employer'] = $contact->organization_name;
$defaults['current_employer_id'] = $contact->employer_id;
}
//for birthdate format with respect to birth format set
$this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
}
$this->assign($defaults);
// also assign the last modifed details
require_once 'CRM/Core/BAO/Log.php';
$lastModified =& CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact');
$this->assign_by_ref('lastModified', $lastModified);
$allTabs = array();
$weight = 10;
$this->_viewOptions = CRM_Core_BAO_Preferences::valueOptions('contact_view_options', true);
$changeLog = $this->_viewOptions['log'];
$this->assign_by_ref('changeLog', $changeLog);
require_once 'CRM/Core/Component.php';
$components = CRM_Core_Component::getEnabledComponents();
foreach ($components as $name => $component) {
if (CRM_Utils_Array::value($name, $this->_viewOptions) && CRM_Core_Permission::access($component->name)) {
$elem = $component->registerTab();
// FIXME: not very elegant, probably needs better approach
// allow explicit id, if not defined, use keyword instead
if (array_key_exists('id', $elem)) {
$i = $elem['id'];
} else {
$i = $component->getKeyword();
//.........这里部分代码省略.........
示例10:
/**
* Get all Gender.
*
* The static array gender is returned
*
* @access public
* @static
*
* @param boolean $all - get All Gender - default is to get only active ones.
*
* @return array - array reference of all gender.
*
*/
public static function &gender()
{
if (!self::$gender) {
require_once 'CRM/Core/OptionGroup.php';
self::$gender = CRM_Core_OptionGroup::values('gender');
}
return self::$gender;
}
示例11: demographics
static function demographics(&$form)
{
$form->add('hidden', 'hidden_demographics', 1);
// 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', ts('Gender'));
$form->addDate('birth_date_low', ts('Birth Dates - From'), false, array('formatType' => 'searchDate'));
$form->addDate('birth_date_high', ts('To'), false, array('formatType' => 'searchDate'));
$form->addDate('deceased_date_low', ts('Deceased Dates - From'), false, array('formatType' => 'searchDate'));
$form->addDate('deceased_date_high', ts('To'), false, array('formatType' => 'searchDate'));
}
示例12: whereClause
//.........这里部分代码省略.........
if (is_numeric($value)) {
$value = $states[(int) $value];
}
$this->_where[] = 'LOWER(' . $field['where'] . ') = "' . strtolower(addslashes($value)) . '"';
if (!$lType) {
$this->_qill[] = ts('State - "%1"', array(1 => $value));
} else {
$this->_qill[] = ts('State (%2) - "%1"', array(1 => $value, 2 => $lType));
}
} else {
if (substr($name, 0, 7) === 'country') {
$countries =& CRM_Core_PseudoConstant::country();
if (is_numeric($value)) {
$value = $countries[(int) $value];
}
$this->_where[] = 'LOWER(' . $field['where'] . ') = "' . strtolower(addslashes($value)) . '"';
if (!$lType) {
$this->_qill[] = ts('Country - "%1"', array(1 => $value));
} else {
$this->_qill[] = ts('Country (%2) - "%1"', array(1 => $value, 2 => $lType));
}
} else {
if ($name === 'individual_prefix') {
$individualPrefixs =& CRM_Core_PseudoConstant::individualPrefix();
if (is_numeric($value)) {
$value = $individualPrefixs[(int) $value];
}
$this->_where[] = 'LOWER(' . $field['where'] . ') = "' . strtolower(addslashes($value)) . '"';
$this->_qill[] = ts('Individual Prefix - "%1"', array(1 => $value));
} else {
if ($name === 'individual_suffix') {
$individualSuffixs =& CRM_Core_PseudoConstant::individualsuffix();
if (is_numeric($value)) {
$value = $individualSuffixs[(int) $value];
}
$this->_where[] = 'LOWER(' . $field['where'] . ') = "' . strtolower(addslashes($value)) . '"';
$this->_qill[] = ts('Individual Suffix - "%1"', array(1 => $value));
} else {
if ($name === 'gender') {
$genders =& CRM_Core_PseudoConstant::gender();
if (is_numeric($value)) {
$value = $genders[(int) $value];
}
$this->_where[] = 'LOWER(' . $field['where'] . ') = "' . strtolower(addslashes($value)) . '"';
$this->_qill[] = ts('Gender - "%1"', array(1 => $value));
} else {
if ($name === 'birth_date') {
$date = CRM_Utils_Date::format($value);
if (!$date) {
continue;
}
$this->_where[] = $field['where'] . " = {$date}";
$date = CRM_Utils_Date::customFormat($value);
$this->_qill[] = "{$field['title']} \"{$date}\"";
} else {
if ($name === 'contact_id') {
if (is_int($value)) {
$this->_where[] = $field['where'] . " = {$value}";
$this->_qill[] = ts('%1 is equal to %2', array(1 => $field['title'], 2 => $value));
}
} else {
if ($name === 'name') {
$this->_where[] = 'LOWER(' . $field['where'] . ') LIKE "%' . strtolower(addslashes($value)) . '%"';
$this->_qill[] = ts('%1 like "%2"', array(1 => $field['title'], 2 => $value));
} else {
// sometime the value is an array, need to investigate and fix
if (is_array($value)) {
$value = $value[0];
}
if (!empty($field['where'])) {
if ($this->_strict) {
$this->_where[] = 'LOWER(' . $field['where'] . ') = "' . strtolower(str_replace("\"", "", $value)) . '"';
$this->_qill[] = ts('%1 = "%2"', array(1 => $field['title'], 2 => $value));
} else {
$this->_where[] = 'LOWER(' . $field['where'] . ') LIKE "%' . strtolower(addslashes($value)) . '%"';
$this->_qill[] = ts('%1 like "%2"', array(1 => $field['title'], 2 => $value));
}
}
}
}
}
}
}
}
}
}
list($tableName, $fieldName) = explode('.', $field['where'], 2);
if (isset($tableName)) {
$this->_tables[$tableName] = 1;
$this->_whereTables[$tableName] = 1;
}
// CRM_Core_Error::debug( 'f', $field );
// CRM_Core_Error::debug( $value, $this->_qill );
}
if ($this->_customQuery) {
$this->_where = array_merge($this->_where, $this->_customQuery->_where);
$this->_qill = array_merge($this->_qill, $this->_customQuery->_qill);
}
return implode(' AND ', $this->_where);
}
示例13: isErrorInCoreData
/**
* function to check if an error in Core( non-custom fields ) field
*
* @param String $errorMessage A string containing all the error-fields.
*
* @access public
*/
function isErrorInCoreData($params, &$errorMessage)
{
foreach ($params as $key => $value) {
if ($value) {
switch ($key) {
case 'birth_date':
if (!CRM_Utils_Rule::date($value)) {
//return _crm_error('Birth Date');
CRM_Import_Parser_Contact::addToErrorMsg('Birth Date', $errorMessage);
}
break;
case 'gender':
if (!CRM_Import_Parser_Contact::in_value($value, CRM_Core_PseudoConstant::gender(true))) {
//return _crm_error('Invalid value for field : Gender');
CRM_Import_Parser_Contact::addToErrorMsg('Gender', $errorMessage);
}
break;
case 'preferred_communication_method':
if (!array_key_exists(strtolower($value), array_change_key_case(CRM_Core_SelectValues::pcm(), CASE_LOWER))) {
//return _crm_error('Invalid value for field : Preferred Communication Method');
CRM_Import_Parser_Contact::addToErrorMsg('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))) {
//return _crm_error('Invalid value for field : Preferred Communication Method');
CRM_Import_Parser_Contact::addToErrorMsg('Preferred Mail Format', $errorMessage);
}
break;
case 'individual_prefix':
if (!CRM_Import_Parser_Contact::in_value($value, CRM_Core_PseudoConstant::individualPrefix(true))) {
//return _crm_error('Invalid value for field : Individual Prefix');
CRM_Import_Parser_Contact::addToErrorMsg('Individual Prefix', $errorMessage);
}
break;
case 'individual_suffix':
if (!CRM_Import_Parser_Contact::in_value($value, CRM_Core_PseudoConstant::individualSuffix(true))) {
//return _crm_error('Invalid value for field : Individual Suffix');
CRM_Import_Parser_Contact::addToErrorMsg('Individual Suffix', $errorMessage);
}
break;
case 'state_province':
if (!empty($value)) {
foreach ($value as $stateValue) {
if ($stateValue['state_province']) {
if (CRM_Import_Parser_Contact::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvinceAbbreviation()) || CRM_Import_Parser_Contact::in_value($stateValue['state_province'], CRM_Core_PseudoConstant::stateProvince())) {
continue;
} else {
//return _crm_error('Invalid value for field : State Province ');
CRM_Import_Parser_Contact::addToErrorMsg('State Province', $errorMessage);
}
}
}
}
break;
case 'country':
if (!empty($value)) {
foreach ($value as $stateValue) {
if ($stateValue['country']) {
if (CRM_Import_Parser_Contact::in_value($stateValue['country'], CRM_Core_PseudoConstant::countryIsoCode()) || CRM_Import_Parser_Contact::in_value($stateValue['country'], CRM_Core_PseudoConstant::country())) {
continue;
} else {
//return _crm_error('Invalid value for field : Country');
CRM_Import_Parser_Contact::addToErrorMsg('Country', $errorMessage);
}
}
}
}
break;
case 'geo_code_1':
if (!empty($value)) {
foreach ($value as $codeValue) {
if ($codeValue['geo_code_1']) {
if (CRM_Utils_Rule::numeric($codeValue['geo_code_1'])) {
continue;
} else {
//return _crm_error('Invalid value for field : geo_code_1');
CRM_Import_Parser_Contact::addToErrorMsg('geo_code_1', $errorMessage);
}
}
}
}
break;
case 'geo_code_2':
if (!empty($value)) {
foreach ($value as $codeValue) {
if ($codeValue['geo_code_2']) {
if (CRM_Utils_Rule::numeric($codeValue['geo_code_2'])) {
continue;
} else {
//return _crm_error('Invalid value for field : geo_code_2');
CRM_Import_Parser_Contact::addToErrorMsg('geo_code_2', $errorMessage);
}
//.........这里部分代码省略.........
示例14: restWhere
//.........这里部分代码省略.........
} else {
$wc = $op != 'LIKE' ? "LOWER({$where})" : $where;
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
}
if (!$lType) {
$this->_qill[$grouping][] = ts('County') . " {$op} '{$value}'";
} else {
$this->_qill[$grouping][] = ts('County') . " ({$lType}) {$op} '{$value}'";
}
} elseif ($name === 'world_region') {
$worldRegions = CRM_Core_PseudoConstant::worldRegion();
if (is_numeric($value)) {
$value = $worldRegions[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('World Region') . " {$op} '{$value}'";
} elseif ($name === 'individual_prefix') {
$individualPrefixs = CRM_Core_PseudoConstant::individualPrefix();
if (is_numeric($value)) {
$value = $individualPrefixs[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Individual Prefix') . " {$op} '{$value}'";
} elseif ($name === 'individual_suffix') {
$individualSuffixs = CRM_Core_PseudoConstant::individualsuffix();
if (is_numeric($value)) {
$value = $individualSuffixs[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Individual Suffix') . " {$op} '{$value}'";
} elseif ($name === 'gender') {
$genders = CRM_Core_PseudoConstant::gender();
if (is_numeric($value)) {
$value = $genders[(int) $value];
}
$wc = $op != 'LIKE' ? "LOWER({$field['where']})" : "{$field['where']}";
$this->_where[$grouping][] = self::buildClause($wc, $op, $value, 'String');
$this->_qill[$grouping][] = ts('Gender') . " {$op} '{$value}'";
self::$_openedPanes['Demographics'] = TRUE;
} elseif ($name === 'birth_date') {
$date = CRM_Utils_Date::processDate($value);
$this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $date);
if ($date) {
$date = CRM_Utils_Date::customFormat($date);
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$date}\"";
} else {
$this->_qill[$grouping][] = "{$field['title']} {$op}";
}
self::$_openedPanes['Demographics'] = TRUE;
} elseif ($name === 'deceased_date') {
$date = CRM_Utils_Date::processDate($value);
$this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $date);
if ($date) {
$date = CRM_Utils_Date::customFormat($date);
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$date}\"";
} else {
$this->_qill[$grouping][] = "{$field['title']} {$op}";
}
self::$_openedPanes['Demographics'] = TRUE;
} elseif ($name === 'is_deceased') {
$this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value);
$this->_qill[$grouping][] = "{$field['title']} {$op} \"{$value}\"";
self::$_openedPanes['Demographics'] = TRUE;
示例15: executePrintmode
function executePrintmode($rows)
{
//only get these last contribution related variables in print mode if selected on previous form
if (array_key_exists('civicrm_contribution_cont_receive_date', $rows[0])) {
$receiveDate = ', date_received DATE';
}
if (array_key_exists('civicrm_contribution_cont_total_amount', $rows[0])) {
$contAmount = ' , total_amount INT';
}
// Separate out fields and build a temporary table
$tempTable = "WalkList_" . uniqid();
$sql = "CREATE TEMPORARY TABLE {$tempTable}" . " ( id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,\n street_name VARCHAR(255),\n s_street_number VARCHAR(32),\n i_street_number INT,\n odd TINYINT,\n apt_number VARCHAR(32),\n city VARCHAR(64),\n state VARCHAR(32),\n zip VARCHAR(32),\n name VARCHAR(255),\n phone VARCHAR(255),\n age INT,\n sex VARCHAR(16),\n lang CHAR(2),\n party CHAR(1),\n vh CHAR(1),\n contact_type VARCHAR(32),\n other_name VARCHAR(128),\n contact_id INT \n {$receiveDate} {$contAmount}\n )\n ENGINE=HEAP\n DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci";
CRM_Core_DAO::executeQuery($sql);
$gender = CRM_Core_PseudoConstant::gender();
foreach ($rows as $key => $value) {
$dob = $value['civicrm_contact_birth_date'];
$age = empty($dob) ? 0 : $this->dob2age($dob);
$sex = $gender[CRM_Utils_Array::value('civicrm_contact_gender_id', $value)];
$sex = is_null($sex) ? '' : $sex;
$lang = strtoupper(substr($value[$this->_demoTable . '_' . $this->_demoLangCol], 0, 2));
$party = substr($value["{$this->_voterInfoTable}_{$this->_partyCol}"], 0, 1);
$vh = substr($value["{$this->_voterInfoTable}_{$this->_vhCol}"], 0, 1);
$contactType = $value[$this->_coreInfoTable . '_' . $this->_coreTypeCol];
$on = $value[$this->_coreInfoTable . '_' . $this->_coreOtherCol];
$otherName = empty($on) ? 0 : "'{$on}'";
$type = '';
if (!empty($contactType)) {
$type = $this->hexOne2str($contactType);
}
$contact_id = (int) $value['civicrm_contact_id'];
$state = '';
if (!empty($value['civicrm_address_state_province_id'])) {
$state = CRM_Core_PseudoConstant::stateProvince($value['civicrm_address_state_province_id']);
}
$sStreetNumber = $value['civicrm_address_street_number'];
$iStreetNumber = $value['civicrm_address_street_number'] ? (int) $value['civicrm_address_street_number'] : 0;
$odd = $value['civicrm_address_street_number'] ? (int) $value['civicrm_address_street_number'] % 2 : 0;
$apt_number = $value['civicrm_address_street_number'] ? $value['civicrm_address_street_number'] : '';
$phone_number = $value['civicrm_phone_phone'] ? $value['civicrm_phone_phone'] : '';
$query = "INSERT INTO {$tempTable} SET\n street_name = %1,\n s_street_number = %2,\n i_street_number = %3,\n odd = %4, \n apt_number = %5,\n city = %6,\n state = %7,\n zip = %8,\n name = %9,\n phone = %10,\n age = %11,\n sex = %12,\n lang = %13,\n party = %14,\n vh = %15,\n contact_type = %16,\n other_name = %17,\n contact_id = %18";
$params = array(1 => array($value['civicrm_address_street_name'] ? $value['civicrm_address_street_name'] : '', 'String'), 2 => array((string) $sStreetNumber, 'String'), 3 => array($iStreetNumber, 'Integer'), 4 => array($odd, 'Integer'), 5 => array($apt_number, 'String'), 6 => array($value['civicrm_address_city'] ? $value['civicrm_address_city'] : '', 'String'), 7 => array($state, 'String'), 8 => array($value['civicrm_address_postal_code'] ? $value['civicrm_address_postal_code'] : '', 'String'), 9 => array($value['civicrm_contact_display_name'] ? $value['civicrm_contact_display_name'] : '', 'String'), 10 => array($phone_number, 'String'), 11 => array($age, 'Integer'), 12 => array($sex, 'String'), 13 => array($lang, 'String'), 14 => array($party, 'String'), 15 => array($vh, 'String'), 16 => array($type, 'String'), 17 => array($otherName, 'String'), 18 => array($contact_id, 'Integer'));
if (!empty($contAmount)) {
$query .= ",total_amount = %19";
$total_amount = $value['civicrm_contribution_cont_total_amount'] ? $value['civicrm_contribution_cont_total_amount'] : '';
$params[19] = array($total_amount, 'String');
}
if (!empty($receiveDate)) {
$query .= ",date_received = %20";
$date_received = $value['civicrm_contribution_cont_receive_date'] ? $value['civicrm_contribution_cont_receive_date'] : '';
$params[20] = array($date_received, 'String');
}
CRM_Core_DAO::executeQuery($query, $params);
}
// With the data normalized and in a table, we can
// retrieve it in the order we need to present it
$query = "SELECT * FROM {$tempTable} ORDER BY state, city, zip,\n street_name, odd, i_street_number, apt_number";
$dao = CRM_Core_DAO::executeQuery($query);
// Initialize output state
$first = TRUE;
$state = '';
$city = '';
$zip = '';
$street_name = '';
$odd = '';
$pageRow = 0;
$reportDate = date('F j, Y');
$pdfRows = array();
$groupRows = array();
$groupCounts = 0;
$pdfHeaders = array('s_street_number' => array('title' => 'STREET#'), 'apt_number' => array('title' => 'APT'), 'name' => array('title' => 'Name'), 'phone' => array('title' => 'PHONE'), 'age' => array('title' => 'AGE'), 'sex' => array('title' => 'SEX'), 'lang' => array('title' => 'Lang'), 'party' => array('title' => 'Party'), 'vh' => array('title' => 'VH'), 'contact_type' => array('title' => 'Constituent Type'), 'note' => array('title' => 'NOTES'), 'rcode' => array('title' => 'RESPONSE CODES'), 'status' => array('title' => 'STATUS'), 'contact_id' => array('title' => 'ID', 'class' => 'width=7%'));
if (variable_get('civicrm_engage_groupbreak_street', "1") != 1) {
$pdfHeaders['street_name']['title'] = 'Street';
}
if ($receiveDate) {
$pdfHeaders['date_received'] = array('title' => 'Last donation Date');
}
if ($contAmount) {
$pdfHeaders['total_amount'] = array('title' => 'Last donation');
}
$groupInfo = array('date' => $reportDate, 'descr' => empty($this->_groupDescr) ? '' : "<br>Group {$this->_groupDescr}");
while ($dao->fetch()) {
if (strtolower($state) != strtolower($dao->state) || variable_get('civicrm_engage_groupbreak_city', "1") == 1 && strtolower($city) != strtolower($dao->city) || variable_get('civicrm_engage_groupbreak_zip', "1") == 1 && strtolower($zip) != strtolower($dao->zip) || variable_get('civicrm_engage_groupbreak_street', "1") == 1 && strtolower($street_name) != strtolower($dao->street_name) || variable_get('civicrm_engage_groupbreak_odd_even', "1") == 1 && $odd != $dao->odd || $pageRow > variable_get('civicrm_engage_lines_per_group', "6") - 1) {
$state = $dao->state;
$city = $dao->city;
$zip = $dao->zip;
$street_name = $dao->street_name;
$odd = $dao->odd;
$pageRow = 0;
unset($groupRow['city_zip']);
$groupRow['org'] = $this->_orgName;
if (variable_get('civicrm_engage_groupbreak_street', "1") == 1) {
$groupRow['street_name'] = $street_name;
}
if (variable_get('civicrm_engage_groupbreak_city', "1") == 1) {
$groupRow['city_zip'] .= $city . ', ';
}
$groupRow['city_zip'] .= $state;
//don't give zip or odd-even if not grouped on
if (variable_get('civicrm_engage_groupbreak_zip', "1") == 1) {
$groupRow['city_zip'] .= ' ' . $zip;
//.........这里部分代码省略.........