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


PHP CRM_Core_PseudoConstant::greetingDefaults方法代码示例

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


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

示例1: processGreetings

 /**
  * Process greetings and cache.
  *
  * @param object $contact
  *   Contact object after save.
  * @param bool $useDefaults
  *   Use default greeting values.
  */
 public static function processGreetings(&$contact, $useDefaults = FALSE)
 {
     if ($useDefaults) {
         //retrieve default greetings
         $defaultGreetings = CRM_Core_PseudoConstant::greetingDefaults();
         $contactDefaults = $defaultGreetings[$contact->contact_type];
     }
     // note that contact object not always has required greeting related
     // fields that are required to calculate greeting and
     // also other fields used in tokens etc,
     // hence we need to retrieve it again.
     if ($contact->_query !== FALSE) {
         $contact->find(TRUE);
     }
     // store object values to an array
     $contactDetails = array();
     CRM_Core_DAO::storeValues($contact, $contactDetails);
     $contactDetails = array(array($contact->id => $contactDetails));
     $emailGreetingString = $postalGreetingString = $addresseeString = NULL;
     $updateQueryString = array();
     //cache email and postal greeting to greeting display
     if ($contact->email_greeting_custom != 'null' && $contact->email_greeting_custom) {
         $emailGreetingString = $contact->email_greeting_custom;
     } elseif ($contact->email_greeting_id != 'null' && $contact->email_greeting_id) {
         // the filter value for Individual contact type is set to 1
         $filter = array('contact_type' => $contact->contact_type, 'greeting_type' => 'email_greeting');
         $emailGreeting = CRM_Core_PseudoConstant::greeting($filter);
         $emailGreetingString = $emailGreeting[$contact->email_greeting_id];
         $updateQueryString[] = " email_greeting_custom = NULL ";
     } else {
         if ($useDefaults) {
             reset($contactDefaults['email_greeting']);
             $emailGreetingID = key($contactDefaults['email_greeting']);
             $emailGreetingString = $contactDefaults['email_greeting'][$emailGreetingID];
             $updateQueryString[] = " email_greeting_id = {$emailGreetingID} ";
             $updateQueryString[] = " email_greeting_custom = NULL ";
         } elseif ($contact->email_greeting_custom) {
             $updateQueryString[] = " email_greeting_display = NULL ";
         }
     }
     if ($emailGreetingString) {
         CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($emailGreetingString, $contactDetails, $contact->id, 'CRM_Contact_BAO_Contact');
         $emailGreetingString = CRM_Core_DAO::escapeString(CRM_Utils_String::stripSpaces($emailGreetingString));
         $updateQueryString[] = " email_greeting_display = '{$emailGreetingString}'";
     }
     //postal greetings
     if ($contact->postal_greeting_custom != 'null' && $contact->postal_greeting_custom) {
         $postalGreetingString = $contact->postal_greeting_custom;
     } elseif ($contact->postal_greeting_id != 'null' && $contact->postal_greeting_id) {
         $filter = array('contact_type' => $contact->contact_type, 'greeting_type' => 'postal_greeting');
         $postalGreeting = CRM_Core_PseudoConstant::greeting($filter);
         $postalGreetingString = $postalGreeting[$contact->postal_greeting_id];
         $updateQueryString[] = " postal_greeting_custom = NULL ";
     } else {
         if ($useDefaults) {
             reset($contactDefaults['postal_greeting']);
             $postalGreetingID = key($contactDefaults['postal_greeting']);
             $postalGreetingString = $contactDefaults['postal_greeting'][$postalGreetingID];
             $updateQueryString[] = " postal_greeting_id = {$postalGreetingID} ";
             $updateQueryString[] = " postal_greeting_custom = NULL ";
         } elseif ($contact->postal_greeting_custom) {
             $updateQueryString[] = " postal_greeting_display = NULL ";
         }
     }
     if ($postalGreetingString) {
         CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($postalGreetingString, $contactDetails, $contact->id, 'CRM_Contact_BAO_Contact');
         $postalGreetingString = CRM_Core_DAO::escapeString(CRM_Utils_String::stripSpaces($postalGreetingString));
         $updateQueryString[] = " postal_greeting_display = '{$postalGreetingString}'";
     }
     // addressee
     if ($contact->addressee_custom != 'null' && $contact->addressee_custom) {
         $addresseeString = $contact->addressee_custom;
     } elseif ($contact->addressee_id != 'null' && $contact->addressee_id) {
         $filter = array('contact_type' => $contact->contact_type, 'greeting_type' => 'addressee');
         $addressee = CRM_Core_PseudoConstant::greeting($filter);
         $addresseeString = $addressee[$contact->addressee_id];
         $updateQueryString[] = " addressee_custom = NULL ";
     } else {
         if ($useDefaults) {
             reset($contactDefaults['addressee']);
             $addresseeID = key($contactDefaults['addressee']);
             $addresseeString = $contactDefaults['addressee'][$addresseeID];
             $updateQueryString[] = " addressee_id = {$addresseeID} ";
             $updateQueryString[] = " addressee_custom = NULL ";
         } elseif ($contact->addressee_custom) {
             $updateQueryString[] = " addressee_display = NULL ";
         }
     }
     if ($addresseeString) {
         CRM_Contact_BAO_Contact_Utils::processGreetingTemplate($addresseeString, $contactDetails, $contact->id, 'CRM_Contact_BAO_Contact');
         $addresseeString = CRM_Core_DAO::escapeString(CRM_Utils_String::stripSpaces($addresseeString));
         $updateQueryString[] = " addressee_display = '{$addresseeString}'";
//.........这里部分代码省略.........
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:Contact.php

示例2: array

 /**
  * Construct array of default greeting values for contact type
  *
  * @access public
  * @static
  *
  * @return array - array reference of default greetings.
  *
  */
 public static function &greetingDefaults()
 {
     if (!self::$greetingDefaults) {
         $defaultGreetings = array();
         $contactTypes = array('Individual' => 1, 'Household' => 2, 'Organization' => 3);
         foreach ($contactTypes as $contactType => $filter) {
             $filterCondition = " AND (v.filter = 0 OR v.filter = {$filter}) AND v.is_default = 1 ";
             foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
                 $tokenVal = CRM_Core_OptionGroup::values($greeting, NULL, NULL, NULL, $filterCondition, 'label');
                 $defaultGreetings[$contactType][$greeting] = $tokenVal;
             }
         }
         self::$greetingDefaults = $defaultGreetings;
     }
     return self::$greetingDefaults;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:25,代码来源:PseudoConstant.php

示例3: array

 /**
  * Construct array of default greeting values for contact type
  *
  * @access public
  * @static
  *
  * @return array - array reference of default greetings.
  *
  */
 public static function &greetingDefaults()
 {
     if (!self::$greetingDefaults) {
         $defaultGreetings = array();
         $contactTypes = self::get('CRM_Contact_DAO_Contact', 'contact_type', array('keyColumn' => 'id', 'labelColumn' => 'name'));
         foreach ($contactTypes as $filter => $contactType) {
             $filterCondition = " AND (v.filter = 0 OR v.filter = {$filter}) AND v.is_default = 1 ";
             foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
                 $tokenVal = CRM_Core_OptionGroup::values($greeting, NULL, NULL, NULL, $filterCondition, 'label');
                 $defaultGreetings[$contactType][$greeting] = $tokenVal;
             }
         }
         self::$greetingDefaults = $defaultGreetings;
     }
     return self::$greetingDefaults;
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:25,代码来源:PseudoConstant.php

示例4: processGreetings

 /**
  * Function to process greetings and cache
  *
  */
 static function processGreetings(&$contact, $useDefaults = FALSE)
 {
     if ($useDefaults) {
         //retrieve default greetings
         $defaultGreetings = CRM_Core_PseudoConstant::greetingDefaults();
         $contactDefaults = $defaultGreetings[$contact->contact_type];
     }
     // store object values to an array
     $contactDetails = array();
     CRM_Core_DAO::storeValues($contact, $contactDetails);
     $contactDetails = array(array($contact->id => $contactDetails));
     $emailGreetingString = $postalGreetingString = $addresseeString = NULL;
     $updateQueryString = array();
     //cache email and postal greeting to greeting display
     if ($contact->email_greeting_custom != 'null' && $contact->email_greeting_custom) {
         $emailGreetingString = $contact->email_greeting_custom;
     } elseif ($contact->email_greeting_id != 'null' && $contact->email_greeting_id) {
         // the filter value for Individual contact type is set to 1
         $filter = array('contact_type' => $contact->contact_type, 'greeting_type' => 'email_greeting');
         $emailGreeting = CRM_Core_PseudoConstant::greeting($filter);
         $emailGreetingString = $emailGreeting[$contact->email_greeting_id];
         $updateQueryString[] = " email_greeting_custom = NULL ";
     } else {
         if ($useDefaults) {
             reset($contactDefaults['email_greeting']);
             $emailGreetingID = key($contactDefaults['email_greeting']);
             $emailGreetingString = $contactDefaults['email_greeting'][$emailGreetingID];
             $updateQueryString[] = " email_greeting_id = {$emailGreetingID} ";
             $updateQueryString[] = " email_greeting_custom = NULL ";
         } elseif ($contact->email_greeting_custom) {
             $updateQueryString[] = " email_greeting_display = NULL ";
         }
     }
     if ($emailGreetingString) {
         CRM_Utils_Token::replaceGreetingTokens($emailGreetingString, $contactDetails, $contact->id, 'CRM_Contact_BAO_Contact');
         $emailGreetingString = CRM_Core_DAO::escapeString(CRM_Utils_String::stripSpaces($emailGreetingString));
         $updateQueryString[] = " email_greeting_display = '{$emailGreetingString}'";
     }
     //postal greetings
     if ($contact->postal_greeting_custom != 'null' && $contact->postal_greeting_custom) {
         $postalGreetingString = $contact->postal_greeting_custom;
     } elseif ($contact->postal_greeting_id != 'null' && $contact->postal_greeting_id) {
         $filter = array('contact_type' => $contact->contact_type, 'greeting_type' => 'postal_greeting');
         $postalGreeting = CRM_Core_PseudoConstant::greeting($filter);
         $postalGreetingString = $postalGreeting[$contact->postal_greeting_id];
         $updateQueryString[] = " postal_greeting_custom = NULL ";
     } else {
         if ($useDefaults) {
             reset($contactDefaults['postal_greeting']);
             $postalGreetingID = key($contactDefaults['postal_greeting']);
             $postalGreetingString = $contactDefaults['postal_greeting'][$postalGreetingID];
             $updateQueryString[] = " postal_greeting_id = {$postalGreetingID} ";
             $updateQueryString[] = " postal_greeting_custom = NULL ";
         } elseif ($contact->postal_greeting_custom) {
             $updateQueryString[] = " postal_greeting_display = NULL ";
         }
     }
     if ($postalGreetingString) {
         CRM_Utils_Token::replaceGreetingTokens($postalGreetingString, $contactDetails, $contact->id, 'CRM_Contact_BAO_Contact');
         $postalGreetingString = CRM_Core_DAO::escapeString(CRM_Utils_String::stripSpaces($postalGreetingString));
         $updateQueryString[] = " postal_greeting_display = '{$postalGreetingString}'";
     }
     // addressee
     if ($contact->addressee_custom != 'null' && $contact->addressee_custom) {
         $addresseeString = $contact->addressee_custom;
     } elseif ($contact->addressee_id != 'null' && $contact->addressee_id) {
         $filter = array('contact_type' => $contact->contact_type, 'greeting_type' => 'addressee');
         $addressee = CRM_Core_PseudoConstant::greeting($filter);
         $addresseeString = $addressee[$contact->addressee_id];
         $updateQueryString[] = " addressee_custom = NULL ";
     } else {
         if ($useDefaults) {
             reset($contactDefaults['addressee']);
             $addresseeID = key($contactDefaults['addressee']);
             $addresseeString = $contactDefaults['addressee'][$addresseeID];
             $updateQueryString[] = " addressee_id = {$addresseeID} ";
             $updateQueryString[] = " addressee_custom = NULL ";
         } elseif ($contact->addressee_custom) {
             $updateQueryString[] = " addressee_display = NULL ";
         }
     }
     if ($addresseeString) {
         CRM_Utils_Token::replaceGreetingTokens($addresseeString, $contactDetails, $contact->id, 'CRM_Contact_BAO_Contact');
         $addresseeString = CRM_Core_DAO::escapeString(CRM_Utils_String::stripSpaces($addresseeString));
         $updateQueryString[] = " addressee_display = '{$addresseeString}'";
     }
     if (!empty($updateQueryString)) {
         $updateQueryString = implode(',', $updateQueryString);
         $queryString = "UPDATE civicrm_contact SET {$updateQueryString} WHERE id = {$contact->id}";
         CRM_Core_DAO::executeQuery($queryString);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:96,代码来源:Contact.php


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