コード例 #1
0
ファイル: UFField.php プロジェクト: kidaa30/yes
 /**
  * Check for mix profile fields (eg: individual + other contact types)
  *
  * @param int $ufGroupId
  *
  * @return bool
  *   true for mix profile else false
  */
 public static function checkProfileType($ufGroupId)
 {
     $ufGroup = new CRM_Core_DAO_UFGroup();
     $ufGroup->id = $ufGroupId;
     $ufGroup->find(TRUE);
     $profileTypes = array();
     if ($ufGroup->group_type) {
         $typeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ufGroup->group_type);
         $profileTypes = explode(',', $typeParts[0]);
     }
     //early return if new profile.
     if (empty($profileTypes)) {
         return FALSE;
     }
     //we need to unset Contact
     if (count($profileTypes) > 1) {
         $index = array_search('Contact', $profileTypes);
         if ($index !== FALSE) {
             unset($profileTypes[$index]);
         }
     }
     // suppress any subtypes if present
     CRM_Contact_BAO_ContactType::suppressSubTypes($profileTypes);
     $contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
     $components = array('Contribution', 'Participant', 'Membership', 'Activity');
     $fields = array();
     // check for mix profile condition
     if (count($profileTypes) > 1) {
         //check the there are any components include in profile
         foreach ($components as $value) {
             if (in_array($value, $profileTypes)) {
                 return TRUE;
             }
         }
         //check if there are more than one contact types included in profile
         if (count($profileTypes) > 1) {
             return TRUE;
         }
     } elseif (count($profileTypes) == 1) {
         // note for subtype case count would be zero
         $profileTypes = array_values($profileTypes);
         if (!in_array($profileTypes[0], $contactTypes)) {
             return TRUE;
         }
     }
     return FALSE;
 }