本文整理汇总了PHP中CRM_Utils_Date::checkBirthDateFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Date::checkBirthDateFormat方法的具体用法?PHP CRM_Utils_Date::checkBirthDateFormat怎么用?PHP CRM_Utils_Date::checkBirthDateFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Date
的用法示例。
在下文中一共展示了CRM_Utils_Date::checkBirthDateFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 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);
$params = array('id' => $contactId);
$defaults = array();
CRM_Contact_BAO_Contact::getValues($params, $defaults);
if (!empty($defaults['gender_id'])) {
$gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
$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();
}
示例2: 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();
//.........这里部分代码省略.........
示例3: 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;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, true);
$communicationType = array('phone' => array('type' => 'phoneType', 'id' => 'phone_type'), 'im' => array('type' => 'IMProvider', 'id' => 'provider'), 'address' => array('skip' => true), '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 (CRM_Utils_Array::value('gender_id', $defaults)) {
$gender = CRM_Core_PseudoConstant::gender();
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
if (CRM_Utils_Array::value('contact_sub_type', $defaults)) {
$defaults['contact_sub_type'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $defaults['contact_sub_type'], 'label', 'name');
}
// get the list of all the categories
$tag =& CRM_Core_PseudoConstant::tag();
// get categories for the contact id
require_once 'CRM/Core/BAO/EntityTag.php';
$entityTag =& CRM_Core_BAO_EntityTag::getTag($this->_contactId);
if ($entityTag) {
$categories = array();
foreach ($entityTag as $key) {
$categories[] = $tag[$key];
}
$defaults['contactTag'] = implode(', ', $categories);
}
$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 the householdname
if (isset($defaults['mail_to_household_id'])) {
$HouseholdName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $defaults['mail_to_household_id'], 'display_name', 'id');
$this->assign('HouseholdName', $HouseholdName);
}
//get the current employer name
if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
require_once 'CRM/Contact/BAO/Relationship.php';
$currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
$defaults['current_employer'] = $currentEmployer[$this->_contactId]['org_name'];
$defaults['current_employer_id'] = $currentEmployer[$this->_contactId]['org_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();
}
$u = $elem['url'];
//appending isTest to url for test soft credit CRM-3891.
//FIXME: hack ajax url.
$q = "reset=1&snippet=1&force=1&cid={$this->_contactId}";
if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
$q = $q . "&isTest=1";
}
//.........这里部分代码省略.........
示例4: view
/**
* View summary details of a contact.
*/
public function view()
{
// Add js for tabs, in-place editing, and jstree for tags
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js', 2, 'html-header')->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')->addSetting(array('summaryPrint' => array('mode' => $this->_print), 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary'))));
$this->assign('summaryPrint', $this->_print);
$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);
// Let summary page know if outbound mail is disabled so email links can be built conditionally
$mailingBackend = Civi::settings()->get('mailing_backend');
$this->assign('mailingOutboundOption', $mailingBackend['outBound_option']);
$communicationType = array('phone' => array('type' => 'phoneType', 'id' => 'phone_type', 'daoName' => 'CRM_Core_DAO_Phone', 'fieldName' => 'phone_type_id'), 'im' => array('type' => 'IMProvider', 'id' => 'provider', 'daoName' => 'CRM_Core_DAO_IM', 'fieldName' => 'provider_id'), 'website' => array('type' => 'websiteType', 'id' => 'website_type', 'daoName' => 'CRM_Core_DAO_Website', 'fieldName' => 'website_type_id'), 'address' => array('skip' => TRUE, 'customData' => 1), 'email' => array('skip' => TRUE), 'openid' => array('skip' => TRUE));
foreach ($communicationType as $key => $value) {
if (!empty($defaults[$key])) {
foreach ($defaults[$key] as &$val) {
CRM_Utils_Array::lookupValue($val, 'location_type', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')), FALSE);
if (empty($value['skip'])) {
$daoName = $value['daoName'];
$pseudoConst = $daoName::buildOptions($value['fieldName'], 'get');
CRM_Utils_Array::lookupValue($val, $value['id'], $pseudoConst, FALSE);
}
}
if (isset($value['customData'])) {
foreach ($defaults[$key] as $blockId => $blockVal) {
$idValue = $blockVal['id'];
if ($key == 'address') {
if (!empty($blockVal['master_id'])) {
$idValue = $blockVal['master_id'];
}
}
$groupTree = CRM_Core_BAO_CustomGroup::getTree(ucfirst($key), $this, $idValue);
// 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 (!empty($defaults['gender_id'])) {
$defaults['gender_display'] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'gender_id', $defaults['gender_id']);
}
$communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id');
if (!empty($communicationStyle)) {
if (!empty($defaults['communication_style_id'])) {
$defaults['communication_style_display'] = $communicationStyle[CRM_Utils_Array::value('communication_style_id', $defaults)];
} else {
// Make sure the field is displayed as long as it is active, even if it is unset for this contact.
$defaults['communication_style_display'] = '';
}
}
// 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
$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
$this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options');
foreach ($this->_editOptions as $blockName => $value) {
$varName = '_show' . $blockName;
$this->{$varName} = $value;
$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 (!empty($addressValue['master_id']) && !$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()));
}
$defaults['external_identifier'] = $contact->external_identifier;
$this->assign($defaults);
// FIXME: when we sort out TZ isssues with DATETIME/TIMESTAMP, we can skip next query
// also assign the last modifed details
$lastModified = CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact');
$this->assign_by_ref('lastModified', $lastModified);
//.........这里部分代码省略.........
示例5: array
/**
* compose the parameters for a date select object
*
* @param $type the type of date
*
* @return array the date array
* @static
*/
static function &date($type = 'birth', $min = null, $max = null, $dateParts = null)
{
static $_date = null;
static $config = null;
if (!$config) {
$config =& CRM_Core_Config::singleton();
}
if (!$_date) {
require_once 'CRM/Utils/Date.php';
$_date = array('format' => 'M d Y', 'addEmptyOption' => true, 'emptyOptionText' => ts('- select -'), 'emptyOptionValue' => '');
}
$newDate = $_date;
require_once 'CRM/Core/DAO/PreferencesDate.php';
$dao = new CRM_Core_DAO_PreferencesDate();
$dao->name = $type;
if (!$dao->find(true)) {
CRM_Core_Error::fatal();
}
if ($type == 'birth') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
// support for birthdate format, CRM-3090
$format = trim($dao->format);
$birthDateFormat = CRM_Utils_Date::checkBirthDateFormat($format);
if ($birthDateFormat) {
$formatParts = $birthDateFormat['dateParts'];
if (in_array('M', $formatParts)) {
$formatParts[array_search('M', $formatParts)] = $config->dateformatMonthVar;
}
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDate, $formatParts);
} else {
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDate);
}
} elseif ($type == 'relative') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'custom') {
$minOffset = $min;
$maxOffset = $max;
if ($dateParts) {
require_once 'CRM/Core/BAO/CustomOption.php';
$filter = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dateParts);
$format = $config->dateformatQfDate;
foreach ($filter as $val) {
switch ($val) {
case 'M':
$filter[] = 'F';
$filter[] = 'm';
break;
case 'd':
$filter[] = 'j';
break;
case 'h':
$filter[] = 'H';
$filter[] = 'G';
$filter[] = 'g';
case 'i':
$format = $config->dateformatQfDatetime;
break;
}
}
$newDate['format'] = CRM_Utils_Date::posixToPhp($format, $filter);
}
} elseif ($type == 'activityDate') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'fixed') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'manual') {
$minOffset = $min;
$maxOffset = $max;
} elseif ($type == 'creditCard') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
$newDate['format'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PreferencesDate', 'creditCard', 'date_format', 'name');
} elseif ($type == 'mailing') {
$minOffset = $dao->start;
$maxOffset = $dao->end;
$format = explode(' ', trim($dao->format));
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDatetime, $format);
$newDate['optionIncrement']['i'] = $dao->minute_increment;
} elseif ($type == 'activityDatetime') {
require_once 'CRM/Utils/Date.php';
//for datetime use datetime format from config
$newDate['format'] = CRM_Utils_Date::posixToPhp($config->dateformatQfDatetime);
$newDate['optionIncrement']['i'] = $dao->minute_increment;
$minOffset = $dao->start;
$maxOffset = $dao->end;
} elseif ($type == 'datetime') {
require_once 'CRM/Utils/Date.php';
//for datetime use datetime format from config
//.........这里部分代码省略.........