本文整理汇总了PHP中CRM_Core_PseudoConstant::websiteType方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::websiteType方法的具体用法?PHP CRM_Core_PseudoConstant::websiteType怎么用?PHP CRM_Core_PseudoConstant::websiteType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::websiteType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* build the form elements for an Website object
*
* @param CRM_Core_Form $form reference to the form object
* @param array $location the location object to store all the form elements in
* @param int $locationId the locationId we are dealing with
* @param int $count the number of blocks to create
*
* @return void
* @access public
* @static
*/
static function buildQuickForm(&$form)
{
$blockId = $form->get('Website_Block_Count') ? $form->get('Website_Block_Count') : 1;
$form->applyFilter('__ALL__', 'trim');
//Website type select
$form->addElement('select', "website[{$blockId}][website_type_id]", '', CRM_Core_PseudoConstant::websiteType());
//Website box
$form->addElement('text', "website[{$blockId}][url]", ts('Website'), array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false")));
$form->addRule("website[{$blockId}][url]", ts('Enter a valid web location beginning with \'http://\' or \'https://\'. EXAMPLE: http://www.mysite.org/'), 'url');
}
示例2: 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');
}
示例3: civicrm_contact_update
/**
* @todo Write sth
* @todo Serious FIXMES in the code! File issues.
*/
function civicrm_contact_update(&$params, $create_new = FALSE)
{
_civicrm_initialize();
try {
civicrm_api_check_permission(__FUNCTION__, $params, TRUE);
} catch (Exception $e) {
return civicrm_create_error($e->getMessage());
}
require_once 'CRM/Utils/Array.php';
$entityId = CRM_Utils_Array::value('contact_id', $params, NULL);
if (!CRM_Utils_Array::value('contact_type', $params) && $entityId) {
$params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($entityId);
}
$dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
$values = civicrm_contact_check_params($params, $dupeCheck);
if ($values) {
return $values;
}
if ($create_new) {
// Make sure nothing is screwed up before we create a new contact
if (!empty($entityId)) {
return civicrm_create_error('Cannot create new contact when contact_id is present');
}
if (empty($params['contact_type'])) {
return civicrm_create_error('Contact Type not specified');
}
// 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 ($homeUrl = 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' => $homeUrl));
}
// FIXME: Some legacy support cruft, should get rid of this in 3.1
$change = array('individual_prefix' => 'prefix', 'prefix' => 'prefix_id', 'individual_suffix' => 'suffix', 'suffix' => 'suffix_id', 'gender' => 'gender_id');
foreach ($change as $field => $changeAs) {
if (array_key_exists($field, $params)) {
$params[$changeAs] = $params[$field];
unset($params[$field]);
}
}
// End legacy support cruft
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_greeting_format_params($params);
if (civicrm_error($error)) {
return $error;
}
$values = array();
if (!($csType = CRM_Utils_Array::value('contact_sub_type', $params)) && $entityId) {
require_once 'CRM/Contact/BAO/Contact.php';
$csType = CRM_Contact_BAO_Contact::getContactSubType($entityId);
}
$customValue = civicrm_contact_check_custom_params($params, $csType);
if ($customValue) {
return $customValue;
}
_civicrm_custom_format_params($params, $values, $params['contact_type'], $entityId);
$params = array_merge($params, $values);
$contact =& _civicrm_contact_update($params, $entityId);
if (is_a($contact, 'CRM_Core_Error')) {
return civicrm_create_error($contact->_errors[0]['message']);
} else {
$values = array();
$values['contact_id'] = $contact->id;
$values['is_error'] = 0;
}
return $values;
}
示例4: postProcess
/**
* Process the mapped fields and map it into the uploaded file
* preview the file and extract some summary statistics
*
* @return void
* @access public
*/
public function postProcess()
{
$params = $this->controller->exportValues('MapField');
//reload the mapfield if load mapping is pressed
if (!empty($params['savedMapping'])) {
$this->set('savedMapping', $params['savedMapping']);
$this->controller->resetPage($this->_name);
return;
}
$mapper = array();
$mapperKeys = array();
$mapperKeys = $this->controller->exportValue($this->_name, 'mapper');
$mapperKeysMain = array();
$phoneTypes = CRM_Core_PseudoConstant::phoneType();
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$locationTypes = CRM_Core_PseudoConstant::locationType();
//these mapper params need to set key as array and val as null.
$mapperParams = array('related' => 'relatedVal', 'locations' => 'locationsVal', 'mapperLocType' => 'mapperLocTypeVal', 'mapperPhoneType' => 'mapperPhoneTypeVal', 'mapperImProvider' => 'mapperImProviderVal', 'mapperWebsiteType' => 'mapperWebsiteTypeVal', 'relatedContactType' => 'relatedContactTypeVal', 'relatedContactDetails' => 'relatedContactDetailsVal', 'relatedContactLocType' => 'relatedContactLocTypeVal', 'relatedContactPhoneType' => 'relatedContactPhoneTypeVal', 'relatedContactImProvider' => 'relatedContactImProviderVal', 'relatedContactWebsiteType' => 'relatedContactWebsiteTypeVal');
//set respective mapper params to array.
foreach (array_keys($mapperParams) as $mapperParam) {
${$mapperParam} = array();
}
for ($i = 0; $i < $this->_columnCount; $i++) {
//set respective mapper value to null
foreach (array_values($mapperParams) as $mapperParam) {
${$mapperParam} = NULL;
}
$fldName = CRM_Utils_Array::value(0, $mapperKeys[$i]);
$selOne = CRM_Utils_Array::value(1, $mapperKeys[$i]);
$selTwo = CRM_Utils_Array::value(2, $mapperKeys[$i]);
$selThree = CRM_Utils_Array::value(3, $mapperKeys[$i]);
$mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]];
$mapperKeysMain[$i] = $fldName;
//need to differentiate non location elements.
if ($selOne && is_numeric($selOne)) {
if ($fldName == 'url') {
$mapperWebsiteTypeVal = $websiteTypes[$selOne];
} else {
$locationsVal = $locationTypes[$selOne];
$mapperLocTypeVal = $selOne;
if ($selTwo && is_numeric($selTwo)) {
if ($fldName == 'phone') {
$mapperPhoneTypeVal = $phoneTypes[$selTwo];
} elseif ($fldName == 'im') {
$mapperImProviderVal = $imProviders[$selTwo];
}
}
}
}
//relationship contact mapper info.
list($id, $first, $second) = CRM_Utils_System::explode('_', $fldName, 3);
if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
$relatedVal = $this->_mapperFields[$fldName];
if ($selOne) {
if ($selOne == 'url') {
$relatedContactWebsiteTypeVal = $websiteTypes[$selTwo];
} else {
$relatedContactLocTypeVal = CRM_Utils_Array::value($selTwo, $locationTypes);
if ($selThree) {
if ($selOne == 'phone') {
$relatedContactPhoneTypeVal = $phoneTypes[$selThree];
} elseif ($selOne == 'im') {
$relatedContactImProviderVal = $imProviders[$selThree];
}
}
}
//get the related contact type.
$relationType = new CRM_Contact_DAO_RelationshipType();
$relationType->id = $id;
$relationType->find(TRUE);
$relatedContactTypeVal = $relationType->{"contact_type_{$second}"};
$relatedContactDetailsVal = $this->_formattedFieldNames[$relatedContactTypeVal][$selOne];
}
}
//set the respective mapper param array values.
foreach ($mapperParams as $mapperParamKey => $mapperParamVal) {
${$mapperParamKey}[$i] = ${$mapperParamVal};
}
}
$this->set('columnNames', $this->_columnNames);
//set main contact properties.
$properties = array('ims' => 'mapperImProvider', 'mapper' => 'mapper', 'phones' => 'mapperPhoneType', 'websites' => 'mapperWebsiteType', 'locations' => 'locations');
foreach ($properties as $propertyName => $propertyVal) {
$this->set($propertyName, ${$propertyVal});
}
//set related contact propeties.
$relProperties = array('related', 'relatedContactType', 'relatedContactDetails', 'relatedContactLocType', 'relatedContactPhoneType', 'relatedContactImProvider', 'relatedContactWebsiteType');
foreach ($relProperties as $relProperty) {
$this->set($relProperty, ${$relProperty});
}
// store mapping Id to display it in the preview page
$this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params));
//.........这里部分代码省略.........
示例5:
/**
* Get all the website types from database.
*
* The static array websiteType is returned, and if it's
* called the first time, the <b>Website DAO</b> is used
* to get all the Website Types.
*
* Note: any database errors will be trapped by the DAO.
*
* @access public
* @static
*
* @return array - array reference of all Website types.
*
*/
public static function &websiteType()
{
if (!self::$websiteType) {
require_once 'CRM/Core/OptionGroup.php';
self::$websiteType = CRM_Core_OptionGroup::values('website_type');
}
return self::$websiteType;
}
示例6: runImport
public function runImport(&$form, $timeout = 55)
{
$mapper = $this->_mapper;
$mapperFields = array();
$phoneTypes = CRM_Core_PseudoConstant::phoneType();
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$locationTypes = CRM_Core_PseudoConstant::locationType();
//initialize mapper perperty value.
$mapperPeroperties = array('mapperRelated' => 'mapperRelatedVal', 'mapperLocTypes' => 'mapperLocTypesVal', 'mapperPhoneTypes' => 'mapperPhoneTypesVal', 'mapperImProviders' => 'mapperImProvidersVal', 'mapperWebsiteTypes' => 'mapperWebsiteTypesVal', 'mapperRelatedContactType' => 'mapperRelatedContactTypeVal', 'mapperRelatedContactDetails' => 'mapperRelatedContactDetailsVal', 'mapperRelatedContactLocType' => 'mapperRelatedContactLocTypeVal', 'mapperRelatedContactPhoneType' => 'mapperRelatedContactPhoneTypeVal', 'mapperRelatedContactImProvider' => 'mapperRelatedContactImProviderVal', 'mapperRelatedContactWebsiteType' => 'mapperRelatedContactWebsiteTypeVal');
foreach ($mapper as $key => $value) {
//set respective mapper value to null.
foreach (array_values($mapperPeroperties) as $perpertyVal) {
${$perpertyVal} = NULL;
}
$header = array();
$fldName = CRM_Utils_Array::value(0, $mapper[$key]);
$selOne = CRM_Utils_Array::value(1, $mapper[$key]);
$selTwo = CRM_Utils_Array::value(2, $mapper[$key]);
$selThree = CRM_Utils_Array::value(3, $mapper[$key]);
$this->_mapperKeys[$key] = $fldName;
//need to differentiate non location elements.
if ($selOne && is_numeric($selOne)) {
if ($fldName == 'url') {
$header[] = $websiteTypes[$selOne];
$mapperWebsiteTypesVal = $selOne;
} else {
$header[] = $locationTypes[$selOne];
$mapperLocTypesVal = $selOne;
if ($selTwo && is_numeric($selTwo)) {
if ($fldName == 'phone') {
$header[] = $phoneTypes[$selTwo];
$mapperPhoneTypesVal = $selTwo;
} elseif ($fldName == 'im') {
$header[] = $imProviders[$selTwo];
$mapperImProvidersVal = $selTwo;
}
}
}
}
$fldNameParts = explode('_', $fldName, 3);
$id = $fldNameParts[0];
$first = isset($fldNameParts[1]) ? $fldNameParts[1] : NULL;
$second = isset($fldNameParts[2]) ? $fldNameParts[2] : NULL;
if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
$header[] = ucwords(str_replace("_", " ", $selOne));
$relationType = new CRM_Contact_DAO_RelationshipType();
$relationType->id = $id;
$relationType->find(TRUE);
$mapperRelatedContactTypeVal = $relationType->{"contact_type_{$second}"};
$mapperRelatedVal = $fldName;
if ($selOne) {
$mapperRelatedContactDetailsVal = $selOne;
if ($selTwo) {
if ($selOne == 'url') {
$header[] = $websiteTypes[$selTwo];
$mapperRelatedContactWebsiteTypeVal = $selTwo;
} else {
$header[] = $locationTypes[$selTwo];
$mapperRelatedContactLocTypeVal = $selTwo;
if ($selThree) {
if ($selOne == 'phone') {
$header[] = $phoneTypes[$selThree];
$mapperRelatedContactPhoneTypeVal = $selThree;
} elseif ($selOne == 'im') {
$header[] = $imProviders[$selThree];
$mapperRelatedContactImProviderVal = $selThree;
}
}
}
}
}
}
$mapperFields[] = implode(' - ', $header);
//set the respective mapper param array values.
foreach ($mapperPeroperties as $mapperProKey => $mapperProVal) {
$this->{"_{$mapperProKey}"}[$key] = ${$mapperProVal};
}
}
$this->_parser = new CRM_Import_Parser_Contact($this->_mapperKeys, $this->_mapperLocTypes, $this->_mapperPhoneTypes, $this->_mapperImProviders, $this->_mapperRelated, $this->_mapperRelatedContactType, $this->_mapperRelatedContactDetails, $this->_mapperRelatedContactLocType, $this->_mapperRelatedContactPhoneType, $this->_mapperRelatedContactImProvider, $this->_mapperWebsiteTypes, $this->_mapperRelatedContactWebsiteType);
$this->_parser->run($this->_tableName, $mapperFields, CRM_Import_Parser::MODE_IMPORT, $this->_contactType, $this->_primaryKeyName, $this->_statusFieldName, $this->_onDuplicate, $this->_statusID, $this->_totalRowCount, $this->_doGeocodeAddress, CRM_Import_Parser::DEFAULT_TIMEOUT, $this->_contactSubType, $this->_dedupe);
$contactIds = $this->_parser->getImportedContacts();
//get the related contactIds. CRM-2926
$relatedContactIds = $this->_parser->getRelatedImportedContacts();
if ($relatedContactIds) {
$contactIds = array_merge($contactIds, $relatedContactIds);
if ($form) {
$form->set('relatedCount', count($relatedContactIds));
}
}
if ($this->_newGroupName || count($this->_groups)) {
$groupAdditions = $this->_addImportedContactsToNewGroup($contactIds, $this->_newGroupName, $this->_newGroupDesc);
if ($form) {
$form->set('groupAdditions', $groupAdditions);
}
}
if ($this->_newTagName || count($this->_tag)) {
$tagAdditions = $this->_tagImportedContactsWithNewTag($contactIds, $this->_newTagName, $this->_newTagDesc);
if ($form) {
$form->set('tagAdditions', $tagAdditions);
//.........这里部分代码省略.........
示例7: buildProfile
//.........这里部分代码省略.........
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::greeting($greeting), $required);
// add custom greeting element
$form->add('text', $fieldName . '_custom', ts('Custom %1', array(1 => ucwords(str_replace('_', ' ', $fieldName)))), NULL, FALSE);
} elseif ($fieldName === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::pcm();
foreach ($communicationFields as $key => $var) {
if ($key == '') {
continue;
}
$communicationOptions[] = $form->createElement('checkbox', $key, NULL, $var);
}
$form->addGroup($communicationOptions, $name, $title, '<br/>');
} elseif ($fieldName === 'preferred_mail_format') {
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
} elseif ($fieldName === 'preferred_language') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::languages());
} elseif ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name, ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $contID, 'external_identifier'));
} elseif ($fieldName === 'group') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, TRUE, $required, $title, NULL, $name);
} elseif ($fieldName === 'tag') {
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::TAG, FALSE, $required, NULL, $title, $name);
} elseif (substr($fieldName, 0, 4) === 'url-') {
$form->addElement('text', $name, $title, array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) { this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') { this.value='';} else return false")));
$form->addRule($name, ts('Enter a valid Website.'), 'url');
//Website type select
if ($onBehalf) {
if (substr($name, -1) == ']') {
$websiteTypeName = substr($name, 0, -1) . '-website_type_id]';
}
$form->addElement('select', $websiteTypeName, NULL, CRM_Core_PseudoConstant::websiteType());
} else {
$form->addElement('select', $name . '-website_type_id', NULL, CRM_Core_PseudoConstant::websiteType());
}
// added because note appeared as a standard text input
} elseif ($fieldName == 'note') {
$form->add('textarea', $name, $title, $attributes, $required);
} elseif (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (substr($fieldName, 0, 14) === 'address_custom') {
list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2);
$customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8));
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, FALSE, $required, $search, $title);
}
} elseif (in_array($fieldName, array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
$form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
} elseif ($fieldName == 'send_receipt') {
$form->addElement('checkbox', $name, $title);
} elseif ($fieldName == 'soft_credit') {
CRM_Contact_Form_NewContact::buildQuickForm($form, $rowNumber, NULL, FALSE, 'soft_credit_');
} elseif ($fieldName == 'product_name') {
list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$sel =& $form->addElement('hierselect', $name, $title);
$products = array('0' => ts('- select -')) + $products;
$sel->setOptions(array($products, $options));
} elseif ($fieldName == 'payment_instrument') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
示例8: array
//.........这里部分代码省略.........
}
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
$row[$key] = $paramsNew[$key];
} elseif (isset($tmfFields) && $tmfFields && array_key_exists($property, $tmfFields) || substr($property, 0, 12) == 'participant_') {
if (substr($property, -3) == '_id') {
$key = substr($property, 0, -3);
$paramsNew = array($key => $result->{$property});
$name = array($key => array('newName' => $key, 'groupName' => $key));
CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
$row[$key] = $paramsNew[$key];
} else {
$row[$property] = $result->{$property};
}
} elseif (strpos($property, '-im')) {
$row[$property] = $result->{$property};
if (!empty($result->{$property})) {
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$providerId = $property . "-provider_id";
$providerName = $imProviders[$result->{$providerId}];
$row[$property] = $result->{$property} . " ({$providerName})";
}
} elseif (in_array($property, array('addressee', 'email_greeting', 'postal_greeting'))) {
$greeting = $property . '_display';
$row[$property] = $result->{$greeting};
} elseif ($property == 'country') {
$row[$property] = CRM_Utils_Array::value($result->country_id, $countries);
} elseif ($property == 'state_province') {
$row[$property] = CRM_Utils_Array::value($result->state_province_id, $provinces);
} elseif ($property == 'world_region') {
$row[$property] = $regions[$result->world_region_id];
} elseif (strpos($property, '-url') !== FALSE) {
$websiteUrl = '';
$websiteKey = 'website-1';
$websiteFld = $websiteKey . '-' . array_pop(explode('-', $property));
if (!empty($result->{$websiteFld})) {
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$websiteType = $websiteTypes[$result->{"{$websiteKey}-website_type_id"}];
$websiteValue = $result->{$websiteFld};
$websiteUrl = "<a href=\"{$websiteValue}\">{$websiteValue} ({$websiteType})</a>";
}
$row[$property] = $websiteUrl;
} else {
$row[$property] = isset($result->{$property}) ? $result->{$property} : NULL;
}
}
if (!empty($result->postal_code_suffix)) {
$row['postal_code'] .= "-" . $result->postal_code_suffix;
}
if ($output != CRM_Core_Selector_Controller::EXPORT && $this->_searchContext == 'smog') {
if (empty($result->status) && $groupID) {
$contactID = $result->contact_id;
if ($contactID) {
$gcParams = array('contact_id' => $contactID, 'group_id' => $groupID);
$gcDefaults = array();
CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_GroupContact', $gcParams, $gcDefaults);
if (empty($gcDefaults)) {
$row['status'] = ts('Smart');
} else {
$row['status'] = $gc[$gcDefaults['status']];
}
} else {
$row['status'] = NULL;
}
} else {
$row['status'] = $gc[$result->status];
}
}
if ($output != CRM_Core_Selector_Controller::EXPORT) {
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contact_id;
if (CRM_Utils_Array::value('deleted_contacts', $this->_formValues) && CRM_Core_Permission::check('access deleted contacts')) {
$links = array(array('name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%id%%', 'title' => ts('View Contact Details')), array('name' => ts('Restore'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&restore=1', 'title' => ts('Restore Contact')));
if (CRM_Core_Permission::check('delete contacts')) {
$links[] = array('name' => ts('Delete Permanently'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&skip_undelete=1', 'title' => ts('Permanently Delete Contact'));
}
$row['action'] = CRM_Core_Action::formLink($links, NULL, array('id' => $result->contact_id));
} elseif (is_numeric(CRM_Utils_Array::value('geo_code_1', $row)) || $config->mapGeoCoding && CRM_Utils_Array::value('city', $row) && CRM_Utils_Array::value('state_province', $row)) {
$row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->contact_id));
} else {
$row['action'] = CRM_Core_Action::formLink($links, $mapMask, array('id' => $result->contact_id));
}
// allow components to add more actions
CRM_Core_Component::searchAction($row, $result->contact_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$row['contact_type_orig'] = $result->contact_type;
$row['contact_sub_type'] = $result->contact_sub_type;
$row['contact_id'] = $result->contact_id;
$row['sort_name'] = $result->sort_name;
if (array_key_exists('id', $row)) {
$row['id'] = $result->contact_id;
}
}
// Dedupe contacts
if (in_array($row['contact_id'], $seenIDs) === FALSE) {
$seenIDs[] = $row['contact_id'];
$rows[] = $row;
}
}
$this->buildPrevNextCache($sort);
return $rows;
}
示例9: array
//.........这里部分代码省略.........
$locationTypeName = 1;
}
}
if (!$locationTypeName) {
continue;
}
$locationTypeName = str_replace(' ', '_', $locationTypeName);
if (in_array($fieldName, array('phone', 'im', 'email'))) {
if ($type) {
$names[] = "{$locationTypeName}-{$fieldName}-{$type}";
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "{$locationTypeName}-{$fieldName}";
}
} else {
$names[] = "website-{$id}-{$fieldName}";
}
} elseif ($field['name'] == 'id') {
$names[] = 'contact_id';
} else {
$names[] = $field['name'];
}
}
}
$multipleSelectFields = array('preferred_communication_method' => 1);
if (CRM_Core_Permission::access('Quest')) {
$multipleSelectFields = CRM_Quest_BAO_Student::$multipleSelectFields;
}
// we need to determine of overlay profile should be shown
$showProfileOverlay = CRM_Core_BAO_UFGroup::showOverlayProfile();
$imProviders = CRM_Core_PseudoConstant::IMProvider();
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$languages = CRM_Core_PseudoConstant::languages();
while ($result->fetch()) {
if (isset($result->country)) {
// the query returns the untranslated country name
$i18n = CRM_Core_I18n::singleton();
$result->country = $i18n->translate($result->country);
}
$row = array();
$empty = TRUE;
$row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id, $showProfileOverlay);
if ($result->sort_name) {
$row['sort_name'] = $result->sort_name;
$empty = FALSE;
} else {
continue;
}
foreach ($names as $name) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$row[] = CRM_Core_BAO_CustomField::getDisplayValue($result->{$name}, $cfID, $this->_options, $result->contact_id);
} elseif (substr($name, -4) == '-url' && !empty($result->{$name})) {
$url = CRM_Utils_System::fixURL($result->{$name});
$typeId = substr($name, 0, -4) . "-website_type_id";
$typeName = $websiteTypes[$result->{$typeId}];
if ($typeName) {
$row[] = "<a href=\"{$url}\">{$result->{$name}} ({$typeName})</a>";
} else {
$row[] = "<a href=\"{$url}\">{$result->{$name}}</a>";
}
} elseif ($name == 'preferred_language') {
$row[] = $languages[$result->{$name}];
} elseif ($multipleSelectFields && array_key_exists($name, $multipleSelectFields)) {
//fix to display student checkboxes
示例10:
/**
* Get all the website types from database.
*
* The static array websiteType is returned, and if it's
* called the first time, the <b>Website DAO</b> is used
* to get all the Website Types.
*
* Note: any database errors will be trapped by the DAO.
*
* @access public
* @static
*
* @return array - array reference of all Website types.
*
*/
public static function &websiteType()
{
if (!self::$websiteType) {
self::$websiteType = CRM_Core_OptionGroup::values('website_type');
}
return self::$websiteType;
}
示例11: titlesAndValuesForTable
function titlesAndValuesForTable($table)
{
// static caches for subsequent calls with the same $table
static $titles = array();
static $values = array();
// FIXME: split off the table → DAO mapping to a GenCode-generated class
static $daos = array('civicrm_address' => 'CRM_Core_DAO_Address', 'civicrm_contact' => 'CRM_Contact_DAO_Contact', 'civicrm_email' => 'CRM_Core_DAO_Email', 'civicrm_im' => 'CRM_Core_DAO_IM', 'civicrm_openid' => 'CRM_Core_DAO_OpenID', 'civicrm_phone' => 'CRM_Core_DAO_Phone', 'civicrm_website' => 'CRM_Core_DAO_Website', 'civicrm_contribution' => 'CRM_Contribute_DAO_Contribution', 'civicrm_note' => 'CRM_Core_DAO_Note', 'civicrm_relationship' => 'CRM_Contact_DAO_Relationship');
if (!isset($titles[$table]) or !isset($values[$table])) {
if (in_array($table, array_keys($daos))) {
// FIXME: these should be populated with pseudo constants as they
// were at the time of logging rather than their current values
$values[$table] = array('contribution_page_id' => CRM_Contribute_PseudoConstant::contributionPage(), 'contribution_status_id' => CRM_Contribute_PseudoConstant::contributionStatus(), 'contribution_type_id' => CRM_Contribute_PseudoConstant::contributionType(), 'country_id' => CRM_Core_PseudoConstant::country(), 'gender_id' => CRM_Core_PseudoConstant::gender(), 'location_type_id' => CRM_Core_PseudoConstant::locationType(), 'payment_instrument_id' => CRM_Contribute_PseudoConstant::paymentInstrument(), 'phone_type_id' => CRM_Core_PseudoConstant::phoneType(), 'preferred_communication_method' => CRM_Core_PseudoConstant::pcm(), 'preferred_language' => CRM_Core_PseudoConstant::languages(), 'prefix_id' => CRM_Core_PseudoConstant::individualPrefix(), 'provider_id' => CRM_Core_PseudoConstant::IMProvider(), 'state_province_id' => CRM_Core_PseudoConstant::stateProvince(), 'suffix_id' => CRM_Core_PseudoConstant::individualSuffix(), 'website_type_id' => CRM_Core_PseudoConstant::websiteType());
require_once str_replace('_', DIRECTORY_SEPARATOR, $daos[$table]) . '.php';
eval("\$dao = new {$daos[$table]};");
foreach ($dao->fields() as $field) {
$titles[$table][$field['name']] = CRM_Utils_Array::value('title', $field);
if ($field['type'] == CRM_Utils_Type::T_BOOLEAN) {
$values[$table][$field['name']] = array('0' => ts('false'), '1' => ts('true'));
}
}
} elseif (substr($table, 0, 14) == 'civicrm_value_') {
list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table);
}
}
return array($titles[$table], $values[$table]);
}
示例12: buildProfile
//.........这里部分代码省略.........
if ($key == '') {
continue;
}
$communicationOptions[] =& HTML_QuickForm::createElement('checkbox', $key, null, $var);
}
$form->addGroup($communicationOptions, $name, $title, '<br/>');
} else {
if ($fieldName === 'preferred_mail_format') {
$form->add('select', $name, $title, CRM_Core_SelectValues::pmf());
} else {
if ($fieldName === 'preferred_language') {
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Core_PseudoConstant::languages());
} else {
if ($fieldName == 'external_identifier') {
$form->add('text', $name, $title, $attributes, $required);
$contID = $contactId;
if (!$contID) {
$contID = $form->get('id');
}
$form->addRule($name, ts('External ID already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Contact', $contID, 'external_identifier'));
} else {
if ($fieldName === 'group') {
require_once 'CRM/Contact/Form/Edit/TagsAndGroups.php';
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::GROUP, true, $required, $title, null, $name);
} else {
if ($fieldName === 'tag') {
require_once 'CRM/Contact/Form/Edit/TagsAndGroups.php';
CRM_Contact_Form_Edit_TagsAndGroups::buildQuickForm($form, $contactId, CRM_Contact_Form_Edit_TagsAndGroups::TAG, false, $required, null, $title, $name);
} else {
if (substr($fieldName, 0, 4) === 'url-') {
$form->addElement('text', $name, $title, array_merge(CRM_Core_DAO::getAttribute('CRM_Core_DAO_Website', 'url'), array('onfocus' => "if (!this.value) this.value='http://'; else return false", 'onblur' => "if ( this.value == 'http://') this.value=''; else return false")));
$form->addRule($name, ts('Enter a valid Website.'), 'url');
//Website type select
$form->addElement('select', $name . '-website_type_id', null, CRM_Core_PseudoConstant::websiteType());
} else {
if ($fieldName == 'note') {
//added because note appeared as a standard text input
$form->add('textarea', $name, $title, $attributes, $required);
} else {
if (substr($fieldName, 0, 6) === 'custom') {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName);
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, false, $required, $search, $title);
}
} else {
if (substr($fieldName, 0, 14) === 'address_custom') {
list($fName, $locTypeId) = CRM_Utils_System::explode('-', $fieldName, 2);
$customFieldID = CRM_Core_BAO_CustomField::getKeyID(substr($fName, 8));
if ($customFieldID) {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, false, $required, $search, $title);
}
} else {
if (in_array($fieldName, array('receive_date', 'receipt_date', 'thankyou_date', 'cancel_date'))) {
$form->addDate($name, $title, $required, array('formatType' => 'custom'));
} else {
if ($fieldName == 'payment_instrument') {
require_once "CRM/Contribute/PseudoConstant.php";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), $required);
} else {
if ($fieldName == 'contribution_type') {
require_once "CRM/Contribute/PseudoConstant.php";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType(), $required);
} else {
if ($fieldName == 'contribution_status_id') {
require_once "CRM/Contribute/PseudoConstant.php";
$form->add('select', $name, $title, array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionStatus(), $required);