本文整理汇总了PHP中CRM_Contact_DAO_Contact::tsEnum方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_Contact::tsEnum方法的具体用法?PHP CRM_Contact_DAO_Contact::tsEnum怎么用?PHP CRM_Contact_DAO_Contact::tsEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_DAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_DAO_Contact::tsEnum方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
function buildQuickForm()
{
if ($this->_action & CRM_CORE_ACTION_DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
$this->addElement('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactId, $this->_rtype, $this->_relationshipId));
$this->addElement('text', 'name', ts('Find Target Contact'));
$this->addElement('date', 'start_date', ts('Start Date'), CRM_Core_SelectValues::date('relative'));
$this->addElement('date', 'end_date', ts('End Date'), CRM_Core_SelectValues::date('relative'));
$searchRows = $this->get('searchRows');
$searchCount = $this->get('searchCount');
$duplicateRelationship = $this->get('duplicateRelationship');
if ($searchRows) {
$checkBoxes = array();
foreach ($searchRows as $id => $row) {
$checkBoxes[$id] = $this->createElement('checkbox', $id, null, '');
}
$this->addGroup($checkBoxes, 'contact_check');
$this->assign('searchRows', $searchRows);
}
$this->assign('duplicateRelationship', $duplicateRelationship);
$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
if ($this->get('contact_type')) {
$this->assign('contact_type', $this->get('contact_type'));
$this->assign('contact_type_display', CRM_Contact_DAO_Contact::tsEnum('contact_type', $this->get('contact_type')));
}
$this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'form-submit'));
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'form-submit'));
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save Relationship'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例2: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
$relTypeID = explode('_', $this->_rtypeId, 3);
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
$searchRows = $this->get('searchRows');
$this->addElement('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactId, $this->_rtype, $this->_relationshipId, null, false, 'label'));
// add a ajax facility for searching contacts
$dataUrl = CRM_Utils_System::url("civicrm/ajax/search", "reset=1", true, null, false);
$this->assign('dataUrl', $dataUrl);
$this->addElement('text', 'name', ts('Find Target Contact'));
$this->addDate('start_date', ts('Start Date'), false, array('formatType' => 'relative'));
$this->addDate('end_date', ts('End Date'), false, array('formatType' => 'relative'));
$this->addElement('advcheckbox', 'is_active', ts('Enabled?'), null, 'setChecked()');
$this->addElement('checkbox', 'is_permission_a_b', ts('Permission for contact a to view and update information for contact b'), null);
$this->addElement('checkbox', 'is_permission_b_a', ts('permission for contact b to view and update information for contact a'), null);
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Relationship', 'description'));
CRM_Contact_Form_Edit_Notes::buildQuickForm($this);
$searchCount = $this->get('searchCount');
$duplicateRelationship = $this->get('duplicateRelationship');
$searchDone = $this->get('searchDone');
$isEmployeeOf = $isEmployerOf = false;
if (!empty($this->_relationshipTypeId) && !empty($this->_rtype)) {
if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employee of') {
$isEmployeeOf = true;
} else {
if ($this->_allRelationshipNames[$this->_relationshipTypeId]["name_{$this->_rtype}"] == 'Employer of') {
$isEmployerOf = true;
}
}
}
if ($searchRows) {
$employers = $checkBoxes = $employees = array();
foreach ($searchRows as $id => $row) {
$checkBoxes[$id] = $this->createElement('checkbox', $id, null, '');
if ($isEmployeeOf) {
$employers[$id] = $this->createElement('radio', null, $id, null, $id);
} else {
if ($isEmployerOf) {
$employees[$id] = $this->createElement('checkbox', $id, null, '');
}
}
}
$this->addGroup($checkBoxes, 'contact_check');
$this->assign('searchRows', $searchRows);
if ($isEmployeeOf) {
$this->assign('isEmployeeOf', $isEmployeeOf);
$this->addGroup($employers, 'employee_of');
} else {
if ($isEmployerOf) {
$this->assign('isEmployerOf', $isEmployerOf);
$this->addGroup($employees, 'employer_of');
}
}
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$this->addElement('checkbox', 'is_current_employer');
}
$this->assign('duplicateRelationship', $duplicateRelationship);
$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $searchDone);
if ($this->get('contact_type')) {
$this->assign('contact_type', $this->get('contact_type'));
$this->assign('contact_type_display', CRM_Contact_DAO_Contact::tsEnum('contact_type', $this->get('contact_type')));
}
if ($searchDone) {
$searchBtn = ts('Search Again');
} else {
$searchBtn = ts('Search');
}
$this->addElement('submit', $this->getButtonName('refresh'), $searchBtn, array('class' => 'form-submit'));
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'form-submit'));
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Relationship');
$this->assign('customDataSubType', $this->_relationshipTypeId);
$this->assign('entityID', $this->_relationshipId);
// make this form an upload since we dont know if the custom data injected dynamically
// is of type file etc $uploadNames = $this->get( 'uploadNames' );
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Save Relationship'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例3: CRM_Core_Transaction
//.........这里部分代码省略.........
require_once 'CRM/Utils/Hook.php';
if (CRM_Utils_Array::value('contact_id', $params)) {
CRM_Utils_Hook::pre('edit', $params['contact_type'], $params['contact_id'], $params);
} else {
CRM_Utils_Hook::pre('create', $params['contact_type'], null, $params);
$isEdit = false;
}
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$contact = self::add($params);
$params['contact_id'] = $contact->id;
if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE) {
// in order to make sure that every contact must be added to a group (CRM-4613) -
require_once 'CRM/Core/BAO/Domain.php';
$domainGroupID = CRM_Core_BAO_Domain::getGroupId();
if (CRM_Utils_Array::value('group', $params) && is_array($params['group'])) {
$grpFlp = array_flip($params['group']);
if (!array_key_exists(1, $grpFlp)) {
$params['group'][$domainGroupID] = 1;
}
} else {
$params['group'] = array($domainGroupID => 1);
}
}
if (array_key_exists('group', $params)) {
require_once 'CRM/Contact/BAO/GroupContact.php';
$contactIds = array($params['contact_id']);
foreach ($params['group'] as $groupId => $flag) {
if ($flag == 1) {
CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
} else {
if ($flag == -1) {
CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contactIds, $groupId);
}
}
}
}
//add location Block data
$blocks = CRM_Core_BAO_Location::create($params, $fixAddress);
foreach ($blocks as $name => $value) {
$contact->{$name} = $value;
}
//get userID from session
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
// add notes
if (CRM_Utils_Array::value('note', $params)) {
if (is_array($params['note'])) {
foreach ($params['note'] as $note) {
$contactId = $contact->id;
if (isset($note['contact_id'])) {
$contactId = $note['contact_id'];
}
//if logged in user, overwrite contactId
if ($userID) {
$contactId = $userID;
}
$noteParams = array('entity_id' => $contact->id, 'entity_table' => 'civicrm_contact', 'note' => $note['note'], 'subject' => $note['subject'], 'contact_id' => $contactId);
CRM_Core_BAO_Note::add($noteParams, CRM_Core_DAO::$_nullArray);
}
} else {
$contactId = $contact->id;
if (isset($note['contact_id'])) {
$contactId = $note['contact_id'];
}
//if logged in user, overwrite contactId
if ($userID) {
$contactId = $userID;
}
$noteParams = array('entity_id' => $contact->id, 'entity_table' => 'civicrm_contact', 'note' => $params['note'], 'subject' => CRM_Utils_Array::value('subject', $params), 'contact_id' => $contactId);
CRM_Core_BAO_Note::add($noteParams, CRM_Core_DAO::$_nullArray);
}
}
// update the UF user_unique_id if that has changed
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::updateUFName($contact->id);
if (CRM_Utils_Array::value('custom', $params) && is_array($params['custom'])) {
require_once 'CRM/Core/BAO/CustomValueTable.php';
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_contact', $contact->id);
}
// make a civicrm_subscription_history entry only on contact create (CRM-777)
if (!CRM_Utils_Array::value('contact_id', $params)) {
$subscriptionParams = array('contact_id' => $contact->id, 'status' => 'Added', 'method' => 'Admin');
CRM_Contact_BAO_SubscriptionHistory::create($subscriptionParams);
}
$transaction->commit();
$contact->contact_type_display = CRM_Contact_DAO_Contact::tsEnum('contact_type', $contact->contact_type);
// reset the group contact cache for this group
require_once 'CRM/Contact/BAO/GroupContactCache.php';
CRM_Contact_BAO_GroupContactCache::remove();
if ($invokeHooks) {
if ($isEdit) {
CRM_Utils_Hook::post('edit', $params['contact_type'], $contact->id, $contact);
} else {
CRM_Utils_Hook::post('create', $params['contact_type'], $contact->id, $contact);
}
}
return $contact;
}
示例4: addDisplayEnums
/**
* adds $value['foo_display'] for each $value['foo'] enum from civicrm_contact
*
* @param array $values (reference) the array up for enhancing
* @return void
*/
function addDisplayEnums(&$values)
{
$enumFields =& CRM_Contact_DAO_Contact::getEnums();
foreach ($enumFields as $enum) {
if (isset($values[$enum])) {
$values[$enum . '_display'] = CRM_Contact_DAO_Contact::tsEnum($enum, $values[$enum]);
}
}
}
示例5: str_replace
/**
* takes an associative array and creates a contact object and all the associated
* derived objects (i.e. individual, location, email, phone etc)
*
* This function is invoked from within the web form layer and also from the api layer
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
* @param int $maxLocationBlocks the maximum number of location blocks to process
*
* @return object CRM_Contact_BAO_Contact object
* @access public
* @static
*/
function &create(&$params, &$ids, $maxLocationBlocks)
{
require_once 'CRM/Utils/Hook.php';
if (CRM_Utils_Array::value('contact', $ids)) {
CRM_Utils_Hook::pre('edit', $params['contact_type'], $ids['contact'], $params);
} else {
CRM_Utils_Hook::pre('create', $params['contact_type'], null, $params);
}
CRM_Core_DAO::transaction('BEGIN');
$contact = CRM_Contact_BAO_Contact::add($params, $ids);
$params['contact_id'] = $contact->id;
// invoke the add operator on the contact_type class
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_BAO_" . $params['contact_type']) . ".php";
eval('$contact->contact_type_object =& CRM_Contact_BAO_' . $params['contact_type'] . '::add($params, $ids);');
$location = array();
for ($locationId = 1; $locationId <= $maxLocationBlocks; $locationId++) {
// start of for loop for location
$location[$locationId] = CRM_Core_BAO_Location::add($params, $ids, $locationId);
}
$contact->location = $location;
// add notes
if (CRM_Utils_Array::value('note', $params)) {
if (is_array($params['note'])) {
foreach ($params['note'] as $note) {
$noteParams = array('entity_id' => $contact->id, 'entity_table' => 'civicrm_contact', 'note' => $note['note']);
CRM_Core_BAO_Note::add($noteParams);
}
} else {
$noteParams = array('entity_id' => $contact->id, 'entity_table' => 'civicrm_contact', 'note' => $params['note']);
CRM_Core_BAO_Note::add($noteParams);
}
}
// update the UF email if that has changed
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::updateUFEmail($contact->id);
// add custom field values
if (CRM_Utils_Array::value('custom', $params)) {
foreach ($params['custom'] as $customValue) {
$cvParams = array('entity_table' => 'civicrm_contact', 'entity_id' => $contact->id, 'value' => $customValue['value'], 'type' => $customValue['type'], 'custom_field_id' => $customValue['custom_field_id']);
if ($customValue['id']) {
$cvParams['id'] = $customValue['id'];
}
CRM_Core_BAO_CustomValue::create($cvParams);
}
}
// make a civicrm_subscription_history entry only on contact create (CRM-777)
if (!CRM_Utils_Array::value('contact', $ids)) {
$subscriptionParams = array('contact_id' => $contact->id, 'status' => 'Added', 'method' => 'Admin');
CRM_Contact_BAO_SubscriptionHistory::create($subscriptionParams);
}
CRM_Core_DAO::transaction('COMMIT');
if (CRM_Utils_Array::value('contact', $ids)) {
CRM_Utils_Hook::post('edit', $params['contact_type'], $contact->id, $contact);
} else {
CRM_Utils_Hook::post('create', $params['contact_type'], $contact->id, $contact);
}
$contact->contact_type_display = CRM_Contact_DAO_Contact::tsEnum('contact_type', $contact->contact_type);
return $contact;
}