当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_BAO_Contact::getContactType方法代码示例

本文整理汇总了PHP中CRM_Contact_BAO_Contact::getContactType方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::getContactType方法的具体用法?PHP CRM_Contact_BAO_Contact::getContactType怎么用?PHP CRM_Contact_BAO_Contact::getContactType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contact_BAO_Contact的用法示例。


在下文中一共展示了CRM_Contact_BAO_Contact::getContactType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $id = CRM_Utils_Request::retrieve('id', $this);
     $dao =& new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(true)) {
         $cid = $dao->entity_id;
     }
     require_once 'CRM/SMS/DAO/History.php';
     $dao =& new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(true)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         require_once 'CRM/Utils/Menu.php';
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         require_once 'CRM/Core/BAO/CustomGroup.php';
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
     }
     parent::run();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:42,代码来源:SMS.php

示例2: 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);
     $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
     $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
     //custom groups Inline
     $entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
     $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId, $cgId, $entitySubType);
     $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contactId);
     //get the fields of single custom group record
     if ($customRecId == 1) {
         $fields = reset($details[$cgId]);
     } else {
         $fields = CRM_Utils_Array::value($customRecId, $details[$cgId]);
     }
     $this->assign('cgcount', $cgcount);
     $this->assign('customRecId', $customRecId);
     $this->assign('contactId', $contactId);
     $this->assign('customGroupId', $cgId);
     $this->assign_by_ref('cd_edit', $fields);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
开发者ID:scardinius,项目名称:civicrm-core,代码行数:33,代码来源:CustomData.php

示例3: preProcess

 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $emails = CRM_Contact_BAO_Contact::allEmails($cid);
         $this->_emails = array();
         $toName = CRM_Contact_BAO_Contact::displayName($cid);
         foreach ($emails as $email => $item) {
             if (!$email && count($emails) <= 1) {
                 $this->_emails[$email] = '"' . $toName . '"';
                 $this->_noEmails = true;
             } else {
                 if ($email) {
                     $this->_emails[$email] = '"' . $toName . '" <' . $email . '> ' . $item['locationType'];
                 }
             }
             if ($item['is_primary']) {
                 $this->_emails[$email] .= ' ' . ts('(preferred)');
             }
             $this->_emails[$email] = htmlspecialchars($this->_emails[$email]);
         }
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:41,代码来源:Email.php

示例4: preProcess

 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Core_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $smsNumbers = CRM_Contact_BAO_Contact::allPhones($cid, 'Mobile');
         $this->_emails = array();
         $toName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name');
         foreach ($smsNumbers as $number => $item) {
             $this->_smsNumbers[$number] = '"' . $toName . '" <' . $number . '> ' . $item['locationType'];
             if ($item['is_primary']) {
                 $this->_smsNumbers[$number] .= ' ' . ts('(preferred)');
             }
             $this->_smsNumbers[$number] = htmlspecialchars($this->_emails[$email]);
         }
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:34,代码来源:SMS.php

示例5: preProcess

 /** 
  * Heart of the viewing process. The runner gets all the meta data for 
  * the contact and calls the appropriate type of page to view. 
  * 
  * @return void 
  * @access public 
  * 
  */
 function preProcess()
 {
     parent::preProcess();
     //Custom Groups Inline
     $entityType = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this->_contactId);
     CRM_Core_BAO_CustomGroup::buildViewHTML($this, $groupTree);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:16,代码来源:Basic.php

示例6: preProcess

 /**
  * call preprocess
  */
 public function preProcess()
 {
     //get all the existing email addresses
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE, NULL, $_REQUEST);
     $this->assign('contactId', $this->_contactId);
     // Get contact type if not set
     if (empty($this->_contactType)) {
         $this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:13,代码来源:CommunicationPreferences.php

示例7: preProcess

 /**
  * call preprocess
  */
 public function preProcess()
 {
     //get all the existing email addresses
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE, NULL, $_REQUEST);
     $this->assign('contactId', $this->_contactId);
     $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST);
     $this->assign('customGroupId', $this->_groupID);
     $type = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
     $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ',');
     CRM_Custom_Form_CustomData::preProcess($this, null, $subType, 1, $type, $this->_contactId);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:14,代码来源:CustomData.php

示例8: civicrm_api3_contact_create

/**
 * Create or update a Contact.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 *
 * @return array
 *   API Result Array
 */
function civicrm_api3_contact_create($params)
{
    $contactID = CRM_Utils_Array::value('contact_id', $params, CRM_Utils_Array::value('id', $params));
    if ($contactID && !empty($params['check_permissions']) && !CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) {
        throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify contact record');
    }
    $dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
    $values = _civicrm_api3_contact_check_params($params, $dupeCheck);
    if ($values) {
        return $values;
    }
    if (array_key_exists('api_key', $params) && !empty($params['check_permissions'])) {
        if (CRM_Core_Permission::check('edit api keys') || CRM_Core_Permission::check('administer CiviCRM')) {
            // OK
        } elseif ($contactID && CRM_Core_Permission::check('edit own api keys') && CRM_Core_Session::singleton()->get('userID') == $contactID) {
            // OK
        } else {
            throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify api key');
        }
    }
    if (!$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'])) {
            $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 (!empty($params['home_url'])) {
        $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
        $params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
    }
    _civicrm_api3_greeting_format_params($params);
    $values = array();
    if (empty($params['contact_type']) && $contactID) {
        $params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($contactID);
    }
    if (!isset($params['contact_sub_type']) && $contactID) {
        $params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($contactID);
    }
    _civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $contactID);
    $params = array_merge($params, $values);
    //@todo we should just call basic_create here - but need to make contact:create accept 'id' on the bao
    $contact = _civicrm_api3_contact_update($params, $contactID);
    if (is_a($contact, 'CRM_Core_Error')) {
        throw new API_Exception($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');
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:62,代码来源:Contact.php

示例9: hrui_civicrm_pageRun

function hrui_civicrm_pageRun($page)
{
    CRM_Core_Resources::singleton()->addStyleFile('org.civicrm.hrui', 'css/hrui.css');
    if ($page instanceof CRM_Contact_Page_DashBoard) {
        CRM_Utils_System::setTitle(ts('CiviHR Home'));
    }
    if ($page instanceof CRM_Contact_Page_View_Summary) {
        CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrui', 'js/hrui.js')->addSetting(array('pageName' => 'viewSummary'));
        //set government field value for individual page
        $contactType = CRM_Contact_BAO_Contact::getContactType(CRM_Utils_Request::retrieve('cid', 'Integer'));
        if ($contactType == 'Individual') {
            $hideGId = civicrm_api3('CustomField', 'getvalue', array('custom_group_id' => 'Identify', 'name' => 'is_government', 'return' => 'id'));
            CRM_Core_Resources::singleton()->addSetting(array('cid' => CRM_Utils_Request::retrieve('cid', 'Integer'), 'hideGId' => $hideGId));
        }
    }
}
开发者ID:JoeMurray,项目名称:civihr,代码行数:16,代码来源:hrui.php

示例10: preProcess

 /** 
  * build all the data structures needed to build the form 
  * 
  * @return void 
  * @access public 
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $this->assign('totalSelectedContacts', 1);
     } else {
         parent::preProcess();
     }
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:24,代码来源:Delete.php

示例11: 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);
     $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     //custom groups Inline
     $entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
     $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId, $cgId, $entitySubType);
     $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $fields = array_pop($details[$cgId]);
     $this->assign('contactId', $contactId);
     $this->assign('customGroupId', $cgId);
     $this->assign_by_ref('cd_edit', $fields);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:28,代码来源:CustomData.php

示例12: processAction

 /**
  * Method processAction to execute the action
  *
  * @param CRM_Civirules_EventData_EventData $eventData
  * @access public
  *
  */
 public function processAction(CRM_Civirules_EventData_EventData $eventData)
 {
     $contactId = $eventData->getContactId();
     $subTypes = CRM_Contact_BAO_Contact::getContactSubType($contactId);
     $contactType = CRM_Contact_BAO_Contact::getContactType($contactId);
     $changed = false;
     $action_params = $this->getActionParameters();
     foreach ($action_params['sub_type'] as $sub_type) {
         if (CRM_Contact_BAO_ContactType::isExtendsContactType($sub_type, $contactType)) {
             $subTypes[] = $sub_type;
             $changed = true;
         }
     }
     if ($changed) {
         $params['id'] = $contactId;
         $params['contact_id'] = $contactId;
         $params['contact_type'] = $contactType;
         $params['contact_sub_type'] = $subTypes;
         CRM_Contact_BAO_Contact::add($params);
     }
 }
开发者ID:JMAConsulting,项目名称:org.civicoop.civirules,代码行数:28,代码来源:Subtype.php

示例13: civicrm_api3_contact_create

/**
 * Create or update a Contact.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 *
 * @return array
 *   API Result Array
 */
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 (!$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'])) {
            $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 (!empty($params['home_url'])) {
        $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
        $params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
    }
    _civicrm_api3_greeting_format_params($params);
    $values = array();
    if (empty($params['contact_type']) && $contactID) {
        $params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($contactID);
    }
    if (!isset($params['contact_sub_type']) && $contactID) {
        $params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($contactID);
    }
    _civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $contactID);
    $params = array_merge($params, $values);
    //@todo we should just call basic_create here - but need to make contact:create accept 'id' on the bao
    $contact = _civicrm_api3_contact_update($params, $contactID);
    if (is_a($contact, 'CRM_Core_Error')) {
        throw new API_Exception($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');
}
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:50,代码来源:Contact.php

示例14: getMultiRecordFieldList

 /**
  * Get list of Multi Record Fields.
  *
  */
 public static function getMultiRecordFieldList()
 {
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(0, 10);
     $params['cid'] = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $params['cgid'] = CRM_Utils_Type::escape($_GET['cgid'], 'Integer');
     $contactType = CRM_Contact_BAO_Contact::getContactType($params['cid']);
     $obj = new CRM_Profile_Page_MultipleRecordFieldsListing();
     $obj->_pageViewType = 'customDataView';
     $obj->_contactId = $params['cid'];
     $obj->_customGroupId = $params['cgid'];
     $obj->_contactType = $contactType;
     $obj->_DTparams['offset'] = ($params['page'] - 1) * $params['rp'];
     $obj->_DTparams['rowCount'] = $params['rp'];
     if (!empty($params['sortBy'])) {
         $obj->_DTparams['sort'] = $params['sortBy'];
     }
     list($fields, $attributes) = $obj->browse();
     // format params and add class attributes
     $fieldList = array();
     foreach ($fields as $id => $value) {
         $field = array();
         foreach ($value as $fieldId => &$fieldName) {
             if (!empty($attributes[$fieldId][$id]['class'])) {
                 $fieldName = array('data' => $fieldName, 'cellClass' => $attributes[$fieldId][$id]['class']);
             }
             if (is_numeric($fieldId)) {
                 $fName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $fieldId, 'column_name');
                 CRM_Utils_Array::crmReplaceKey($value, $fieldId, $fName);
             }
         }
         $field = $value;
         array_push($fieldList, $field);
     }
     $totalRecords = !empty($obj->_total) ? $obj->_total : 0;
     $multiRecordFields = array();
     $multiRecordFields['data'] = $fieldList;
     $multiRecordFields['recordsTotal'] = $totalRecords;
     $multiRecordFields['recordsFiltered'] = $totalRecords;
     if (!empty($_GET['is_unit_test'])) {
         return $multiRecordFields;
     }
     CRM_Utils_JSON::output($multiRecordFields);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:47,代码来源:AJAX.php

示例15: format

 /**
  * format an address string from address fields and a format string
  *
  * Format an address basing on the address fields provided.
  * Use Setting's address_format if there's no format specified.
  *
  * @param array $fields the address fields
  * @param string $format the desired address format
  * @param boolean $microformat if true indicates, the address to be built in hcard-microformat standard.
  * @param boolean $mailing if true indicates, the call has been made from mailing label
  * @param boolean $individualFormat if true indicates, the call has been made for the contact of type 'individual'
  *
  * @param null $tokenFields
  *
  * @return string  formatted address string
  *
  * @static
  */
 static function format($fields, $format = NULL, $microformat = FALSE, $mailing = FALSE, $individualFormat = FALSE, $tokenFields = NULL)
 {
     static $config = NULL;
     if (!$format) {
         $format = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_format');
     }
     if ($mailing) {
         $format = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'mailing_format');
     }
     $formatted = $format;
     $fullPostalCode = CRM_Utils_Array::value('postal_code', $fields);
     if (!empty($fields['postal_code_suffix'])) {
         $fullPostalCode .= "-{$fields['postal_code_suffix']}";
     }
     // make sure that some of the fields do have values
     $emptyFields = array('supplemental_address_1', 'supplemental_address_2', 'state_province_name', 'county');
     foreach ($emptyFields as $f) {
         if (!isset($fields[$f])) {
             $fields[$f] = NULL;
         }
     }
     $contactName = CRM_Utils_Array::value('display_name', $fields);
     if (!$individualFormat) {
         if (isset($fields['id'])) {
             $type = CRM_Contact_BAO_Contact::getContactType($fields['id']);
         } else {
             $type = 'Individual';
         }
         if ($type == 'Individual') {
             $contactName = CRM_Utils_Array::value('addressee_display', $fields);
         }
     }
     if (!$microformat) {
         // replacements in case of Individual Name Format
         $replacements = array('contact.display_name' => CRM_Utils_Array::value('display_name', $fields), 'contact.individual_prefix' => CRM_Utils_Array::value('individual_prefix', $fields), 'contact.formal_title' => CRM_Utils_Array::value('formal_title', $fields), 'contact.first_name' => CRM_Utils_Array::value('first_name', $fields), 'contact.middle_name' => CRM_Utils_Array::value('middle_name', $fields), 'contact.last_name' => CRM_Utils_Array::value('last_name', $fields), 'contact.individual_suffix' => CRM_Utils_Array::value('individual_suffix', $fields), 'contact.address_name' => CRM_Utils_Array::value('address_name', $fields), 'contact.street_address' => CRM_Utils_Array::value('street_address', $fields), 'contact.supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', $fields), 'contact.supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', $fields), 'contact.city' => CRM_Utils_Array::value('city', $fields), 'contact.state_province_name' => CRM_Utils_Array::value('state_province_name', $fields), 'contact.county' => CRM_Utils_Array::value('county', $fields), 'contact.state_province' => CRM_Utils_Array::value('state_province', $fields), 'contact.postal_code' => $fullPostalCode, 'contact.country' => CRM_Utils_Array::value('country', $fields), 'contact.world_region' => CRM_Utils_Array::value('world_region', $fields), 'contact.geo_code_1' => CRM_Utils_Array::value('geo_code_1', $fields), 'contact.geo_code_2' => CRM_Utils_Array::value('geo_code_2', $fields), 'contact.current_employer' => CRM_Utils_Array::value('current_employer', $fields), 'contact.nick_name' => CRM_Utils_Array::value('nick_name', $fields), 'contact.email' => CRM_Utils_Array::value('email', $fields), 'contact.im' => CRM_Utils_Array::value('im', $fields), 'contact.do_not_email' => CRM_Utils_Array::value('do_not_email', $fields), 'contact.do_not_phone' => CRM_Utils_Array::value('do_not_phone', $fields), 'contact.do_not_mail' => CRM_Utils_Array::value('do_not_mail', $fields), 'contact.do_not_sms' => CRM_Utils_Array::value('do_not_sms', $fields), 'contact.do_not_trade' => CRM_Utils_Array::value('do_not_trade', $fields), 'contact.job_title' => CRM_Utils_Array::value('job_title', $fields), 'contact.birth_date' => CRM_Utils_Array::value('birth_date', $fields), 'contact.gender' => CRM_Utils_Array::value('gender', $fields), 'contact.is_opt_out' => CRM_Utils_Array::value('is_opt_out', $fields), 'contact.home_URL' => CRM_Utils_Array::value('home_URL', $fields), 'contact.preferred_mail_format' => CRM_Utils_Array::value('preferred_mail_format', $fields), 'contact.phone' => CRM_Utils_Array::value('phone', $fields), 'contact.home_URL' => CRM_Utils_Array::value('home_URL', $fields), 'contact.contact_source' => CRM_Utils_Array::value('contact_source', $fields), 'contact.external_identifier' => CRM_Utils_Array::value('external_identifier', $fields), 'contact.contact_id' => CRM_Utils_Array::value('id', $fields), 'contact.household_name' => CRM_Utils_Array::value('display_name', $fields), 'contact.organization_name' => CRM_Utils_Array::value('display_name', $fields), 'contact.legal_name' => CRM_Utils_Array::value('legal_name', $fields), 'contact.preferred_communication_method' => CRM_Utils_Array::value('preferred_communication_method', $fields), 'contact.communication_style' => CRM_Utils_Array::value('communication_style', $fields), 'contact.addressee' => CRM_Utils_Array::value('addressee_display', $fields), 'contact.email_greeting' => CRM_Utils_Array::value('email_greeting_display', $fields), 'contact.postal_greeting' => CRM_Utils_Array::value('postal_greeting_display', $fields));
     } else {
         $replacements = array('contact.address_name' => "<span class=\"address-name\">" . $fields['address_name'] . "</span>", 'contact.street_address' => "<span class=\"street-address\">" . $fields['street_address'] . "</span>", 'contact.supplemental_address_1' => "<span class=\"extended-address\">" . $fields['supplemental_address_1'] . "</span>", 'contact.supplemental_address_2' => $fields['supplemental_address_2'], 'contact.city' => "<span class=\"locality\">" . $fields['city'] . "</span>", 'contact.state_province_name' => "<span class=\"region\">" . $fields['state_province_name'] . "</span>", 'contact.county' => "<span class=\"region\">" . $fields['county'], 'contact.state_province' => "<span class=\"region\">" . $fields['state_province'] . "</span>", 'contact.postal_code' => "<span class=\"postal-code\">" . $fullPostalCode . "</span>", 'contact.country' => "<span class=\"country-name\">" . $fields['country'] . "</span>", 'contact.world_region' => "<span class=\"region\">" . $fields['world_region'] . "</span>");
         // erase all empty ones, so we dont get blank lines
         foreach (array_keys($replacements) as $key) {
             $exactKey = substr($key, 0, 8) == 'contact.' ? substr($key, 8) : $key;
             if ($key != 'contact.postal_code' && CRM_Utils_Array::value($exactKey, $fields) == NULL) {
                 $replacements[$key] = '';
             }
         }
         if (empty($fullPostalCode)) {
             $replacements['contact.postal_code'] = '';
         }
     }
     // replacements in case of Custom Token
     if (stristr($formatted, 'custom_')) {
         $customToken = array_keys($fields);
         foreach ($customToken as $value) {
             if (substr($value, 0, 7) == 'custom_') {
                 $replacements["contact.{$value}"] = $fields["{$value}"];
             }
         }
     }
     // also sub all token fields
     if ($tokenFields) {
         foreach ($tokenFields as $token) {
             $replacements["{$token}"] = CRM_Utils_Array::value("{$token}", $fields);
         }
     }
     // for every token, replace {fooTOKENbar} with fooVALUEbar if
     // the value is not empty, otherwise drop the whole {fooTOKENbar}
     foreach ($replacements as $token => $value) {
         if ($value && is_string($value) || is_numeric($value)) {
             $formatted = preg_replace("/{([^{}]*)\\b{$token}\\b([^{}]*)}/u", "\${1}{$value}\${2}", $formatted);
         } else {
             $formatted = preg_replace("/{[^{}]*\\b{$token}\\b[^{}]*}/u", '', $formatted);
         }
     }
     // drop any {...} constructs from lines' ends
     if (!$microformat) {
         $formatted = "\n{$formatted}\n";
     } else {
         if ($microformat == 1) {
             $formatted = "\n<div class=\"location vcard\"><span class=\"adr\">\n{$formatted}</span></div>\n";
         } else {
             $formatted = "\n<div class=\"vcard\"><span class=\"adr\">{$formatted}</span></div>\n";
         }
     }
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Address.php


注:本文中的CRM_Contact_BAO_Contact::getContactType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。