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


PHP CRM_Contact_BAO_ContactType::subTypes方法代码示例

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


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

示例1: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // Register 'contact_1' model
     $entities = array();
     $entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
     $allowCoreTypes = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
     $allowSubTypes = array();
     // Register 'contribution_1'
     $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'financial_type_id');
     $allowCoreTypes[] = 'Contribution';
     //CRM-15427
     $allowSubTypes['ContributionType'] = array($financialTypeId);
     $entities[] = array('entity_name' => 'contribution_1', 'entity_type' => 'ContributionModel', 'entity_sub_type' => '*');
     // If applicable, register 'membership_1'
     $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
     if ($member && $member['is_active']) {
         //CRM-15427
         $entities[] = array('entity_name' => 'membership_1', 'entity_type' => 'MembershipModel', 'entity_sub_type' => '*');
         $allowCoreTypes[] = 'Membership';
         $allowSubTypes['MembershipType'] = explode(',', $member['membership_types']);
     }
     //CRM-15427
     $this->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
     $this->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE);
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id);
     parent::buildQuickForm();
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:32,代码来源:Custom.php

示例2: buildQuickForm

 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     require_once "CRM/Core/BAO/UFGroup.php";
     require_once "CRM/Contact/BAO/ContactType.php";
     $types = array_merge(array('Contact', 'Individual', 'Contribution', 'Membership'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
     $profiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     if (empty($profiles)) {
         $this->assign('noProfile', true);
     }
     $this->add('select', 'custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), array('' => ts('- select -')) + $profiles);
     $this->add('select', 'custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), array('' => ts('- select -')) + $profiles);
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id);
     parent::buildQuickForm();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:20,代码来源:Custom.php

示例3: buildQuickForm

 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $types = array_merge(array('Contact', 'Individual', 'Contribution', 'Membership'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
     $profiles = CRM_Core_BAO_UFGroup::getProfiles($types);
     $excludeTypes = array('Organization', 'Household', 'Participant', 'Activity');
     $excludeProfiles = CRM_Core_BAO_UFGroup::getProfiles($excludeTypes);
     foreach ($excludeProfiles as $key => $value) {
         if (array_key_exists($key, $profiles)) {
             unset($profiles[$key]);
         }
     }
     if (empty($profiles)) {
         $this->assign('noProfile', TRUE);
     }
     $this->add('select', 'custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), array('' => ts('- select -')) + $profiles);
     $this->add('select', 'custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), array('' => ts('- select -')) + $profiles);
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this->_id);
     parent::buildQuickForm();
 }
开发者ID:hguru,项目名称:224Civi,代码行数:25,代码来源:Custom.php

示例4: hrjobcontract_civicrm_install

/**
 * Implementation of hook_civicrm_install
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 */
function hrjobcontract_civicrm_install()
{
    $cType = CRM_Contact_BAO_ContactType::basicTypePairs(false, 'id');
    $org_id = array_search('Organization', $cType);
    $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
    $orgSubType = CRM_Contact_BAO_ContactType::subTypes('Organization', true);
    $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
    $params['parent_id'] = $org_id;
    $params['is_active'] = 1;
    if ($org_id) {
        foreach ($sub_type_name as $sub_type_name) {
            $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
            $subID = array_key_exists($subTypeName, $orgSubType);
            if (!$subID) {
                $params['name'] = $subTypeName;
                $params['label'] = $sub_type_name;
                CRM_Contact_BAO_ContactType::add($params);
            } elseif ($subID && $orgSubType[$subTypeName]['is_active'] == 0) {
                CRM_Contact_BAO_ContactType::setIsActive($orgSubType[$subTypeName]['id'], 1);
            }
        }
    }
    // Add Job Contract top menu
    $jobContractNavigation = new CRM_Core_DAO_Navigation();
    $jobContractNavigation->name = 'job_contracts';
    $jobContractNavigationResult = $jobContractNavigation->find();
    if (!$jobContractNavigationResult) {
        $contactsWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'weight', 'name');
        $jobContractNavigation = new CRM_Core_DAO_Navigation();
        $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Job Contracts'), 'name' => 'job_contracts', 'url' => null, 'operator' => null, 'weight' => $contactsWeight + 1, 'is_active' => 1);
        $jobContractNavigation->copyValues($params);
        $jobContractNavigation->save();
        $jobContractMenuTree = array(array('label' => ts('Import / Export'), 'name' => 'import_export_job_contracts'));
        foreach ($jobContractMenuTree as $key => $menuItems) {
            $menuItems['is_active'] = 1;
            $menuItems['parent_id'] = $jobContractNavigation->id;
            $menuItems['weight'] = $key;
            CRM_Core_BAO_Navigation::add($menuItems);
        }
    }
    return _hrjobcontract_civix_civicrm_install();
}
开发者ID:JoeMurray,项目名称:civihr,代码行数:47,代码来源:hrjobcontract.php

示例5: hrjob_civicrm_install

/**
 * Implementation of hook_civicrm_install
 */
function hrjob_civicrm_install()
{
    $cType = CRM_Contact_BAO_ContactType::basicTypePairs(false, 'id');
    $org_id = array_search('Organization', $cType);
    $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
    $orgSubType = CRM_Contact_BAO_ContactType::subTypes('Organization', true);
    $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
    $params['parent_id'] = $org_id;
    $params['is_active'] = 1;
    if ($org_id) {
        foreach ($sub_type_name as $sub_type_name) {
            $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
            $subID = array_key_exists($subTypeName, $orgSubType);
            if (!$subID) {
                $params['name'] = $subTypeName;
                $params['label'] = $sub_type_name;
                CRM_Contact_BAO_ContactType::add($params);
            } elseif ($subID && $orgSubType[$subTypeName]['is_active'] == 0) {
                CRM_Contact_BAO_ContactType::setIsActive($orgSubType[$subTypeName]['id'], 1);
            }
        }
    }
    //Add job import navigation menu
    $weight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Import Contacts', 'weight', 'name');
    $contactNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contacts', 'id', 'name');
    $administerNavId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Dropdown Options', 'id', 'name');
    $importJobNavigation = new CRM_Core_DAO_Navigation();
    $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => ts('Import Jobs'), 'name' => 'jobImport', 'url' => null, 'parent_id' => $contactNavId, 'weight' => $weight + 1, 'permission' => 'access HRJobs', 'separator' => 1, 'is_active' => 1);
    $importJobNavigation->copyValues($params);
    $importJobNavigation->save();
    $importJobMenuTree = array(array('label' => ts('Hours Types'), 'name' => 'hoursType', 'url' => 'civicrm/hour/editoption', 'permission' => 'administer CiviCRM', 'parent_id' => $administerNavId));
    foreach ($importJobMenuTree as $key => $menuItems) {
        $menuItems['is_active'] = 1;
        CRM_Core_BAO_Navigation::add($menuItems);
    }
    CRM_Core_BAO_Navigation::resetNavigation();
    return _hrjob_civix_civicrm_install();
}
开发者ID:JoeMurray,项目名称:civihr,代码行数:41,代码来源:hrjob.php

示例6: buildQuickForm

 function buildQuickForm()
 {
     /**
      *
      * id
      * name
      * description
      * require_login
      * is_active
      *
      */
     $this->assign('wid', $this->_wid);
     // add form elements
     $this->add('text', 'name', ts('Name'), array("maxlength" => 255, "size" => 45), true);
     $this->addRule('name', ts('You must supply a name for this Workflow'), 'required');
     $this->add('textarea', 'description', ts('Description'), array("rows" => 3, "cols" => 80));
     $entities = array();
     $entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel');
     $allowCoreTypes = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual'));
     $allowSubTypes = array();
     $this->addProfileSelector('login_form_id', ts('Login Profile'), $allowCoreTypes, $allowSubTypes, $entities);
     /*
     $this->add(
         'select',
         'login_form_id',
         ts('Login Profile'),
         array('' => ts('- select profile -')) + $profiles,
         false
     );
     */
     $this->add('checkbox', 'require_login', ts('Require Login'));
     $this->addElement('checkbox', 'is_active', ts('Is this workflow active?'));
     $this->addButtons(array(array('type' => 'submit', 'name' => ts('Submit'), 'isDefault' => TRUE)));
     // export form elements
     $this->assign('elementNames', $this->getRenderableElementNames());
     parent::buildQuickForm();
 }
开发者ID:robbrandt,项目名称:civicrm-workflow,代码行数:37,代码来源:Workflow.php

示例7: __construct

 /**
  * Class constructor.
  *
  * Takes in a set of custom field ids andsets up the data structures to
  * generate a query
  *
  * @param array $ids
  *   The set of custom field ids.
  *
  * @param bool $contactSearch
  * @param array $locationSpecificFields
  */
 public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array())
 {
     $this->_ids =& $ids;
     $this->_locationSpecificCustomFields = $locationSpecificFields;
     $this->_select = array();
     $this->_element = array();
     $this->_tables = array();
     $this->_whereTables = array();
     $this->_where = array();
     $this->_qill = array();
     $this->_options = array();
     $this->_fields = array();
     $this->_contactSearch = $contactSearch;
     if (empty($this->_ids)) {
         return;
     }
     // initialize the field array
     $tmpArray = array_keys($this->_ids);
     $idString = implode(',', $tmpArray);
     $query = "\nSELECT f.id, f.label, f.data_type,\n       f.html_type, f.is_search_range,\n       f.option_group_id, f.custom_group_id,\n       f.column_name, g.table_name,\n       f.date_format,f.time_format\n  FROM civicrm_custom_field f,\n       civicrm_custom_group g\n WHERE f.custom_group_id = g.id\n   AND g.is_active = 1\n   AND f.is_active = 1\n   AND f.id IN ( {$idString} )";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         // get the group dao to figure which class this custom field extends
         $extends = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $dao->custom_group_id, 'extends');
         if (array_key_exists($extends, self::$extendsMap)) {
             $extendsTable = self::$extendsMap[$extends];
         } elseif (in_array($extends, CRM_Contact_BAO_ContactType::subTypes())) {
             // if $extends is a subtype, refer contact table
             $extendsTable = self::$extendsMap['Contact'];
         }
         $this->_fields[$dao->id] = array('id' => $dao->id, 'label' => $dao->label, 'extends' => $extendsTable, 'data_type' => $dao->data_type, 'html_type' => $dao->html_type, 'is_search_range' => $dao->is_search_range, 'column_name' => $dao->column_name, 'table_name' => $dao->table_name, 'option_group_id' => $dao->option_group_id);
         // store it in the options cache to make things easier
         // during option lookup
         $this->_options[$dao->id] = array();
         $this->_options[$dao->id]['attributes'] = array('label' => $dao->label, 'data_type' => $dao->data_type, 'html_type' => $dao->html_type);
         $optionGroupID = NULL;
         $htmlTypes = array('CheckBox', 'Radio', 'Select', 'Multi-Select', 'AdvMulti-Select', 'Autocomplete-Select');
         if (in_array($dao->html_type, $htmlTypes) && $dao->data_type != 'ContactReference') {
             if ($dao->option_group_id) {
                 $optionGroupID = $dao->option_group_id;
             } elseif ($dao->data_type != 'Boolean') {
                 $errorMessage = ts("The custom field %1 is corrupt. Please delete and re-build the field", array(1 => $dao->label));
                 CRM_Core_Error::fatal($errorMessage);
             }
         } elseif ($dao->html_type == 'Select Date') {
             $this->_options[$dao->id]['attributes']['date_format'] = $dao->date_format;
             $this->_options[$dao->id]['attributes']['time_format'] = $dao->time_format;
         }
         // build the cache for custom values with options (label => value)
         if ($optionGroupID != NULL) {
             $query = "\nSELECT label, value\n  FROM civicrm_option_value\n WHERE option_group_id = {$optionGroupID}\n";
             $option = CRM_Core_DAO::executeQuery($query);
             while ($option->fetch()) {
                 $dataType = $this->_fields[$dao->id]['data_type'];
                 if ($dataType == 'Int' || $dataType == 'Float') {
                     $num = round($option->value, 2);
                     $this->_options[$dao->id]["{$num}"] = $option->label;
                 } else {
                     $this->_options[$dao->id][$option->value] = $option->label;
                 }
             }
             $options = $this->_options[$dao->id];
             //unset attributes to avoid confussion
             unset($options['attributes']);
             CRM_Utils_Hook::customFieldOptions($dao->id, $options, FALSE);
         }
     }
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:80,代码来源:CustomQuery.php

示例8: formatCustomField

 /**
  * Format custom fields before inserting.
  *
  * @param int $customFieldId
  *   Custom field id.
  * @param array $customFormatted
  *   Formatted array.
  * @param mix $value
  *   Value of custom field.
  * @param string $customFieldExtend
  *   Custom field extends.
  * @param int $customValueId
  *   Custom option value id.
  * @param int $entityId
  *   Entity id (contribution, membership...).
  * @param bool $inline
  *   Consider inline custom groups only.
  * @param bool $checkPermission
  *   If false, do not include permissioning clause.
  * @param bool $includeViewOnly
  *   If true, fields marked 'View Only' are included. Required for APIv3.
  *
  * @return array|NULL
  *   formatted custom field array
  */
 public static function formatCustomField($customFieldId, &$customFormatted, $value, $customFieldExtend, $customValueId = NULL, $entityId = NULL, $inline = FALSE, $checkPermission = TRUE, $includeViewOnly = FALSE)
 {
     //get the custom fields for the entity
     //subtype and basic type
     $customDataSubType = NULL;
     if ($customFieldExtend) {
         // This is the case when getFieldsForImport() requires fields
         // of subtype and its parent.CRM-5143
         // CRM-16065 - Custom field set data not being saved if contact has more than one contact sub type
         $customDataSubType = array_intersect(CRM_Contact_BAO_ContactType::subTypes(), (array) $customFieldExtend);
         if (!empty($customDataSubType) && is_array($customDataSubType)) {
             $customFieldExtend = CRM_Contact_BAO_ContactType::getBasicType($customDataSubType);
             if (is_array($customFieldExtend)) {
                 $customFieldExtend = array_unique(array_values($customFieldExtend));
             }
         }
     }
     $customFields = CRM_Core_BAO_CustomField::getFields($customFieldExtend, FALSE, $inline, $customDataSubType, NULL, FALSE, FALSE, $checkPermission);
     if (!array_key_exists($customFieldId, $customFields)) {
         return NULL;
     }
     // return if field is a 'code' field
     if (!$includeViewOnly && !empty($customFields[$customFieldId]['is_view'])) {
         return NULL;
     }
     list($tableName, $columnName, $groupID) = self::getTableColumnGroup($customFieldId);
     if (!$customValueId && !$customFields[$customFieldId]['is_multiple'] && $entityId) {
         $query = "\nSELECT id\n  FROM {$tableName}\n WHERE entity_id={$entityId}";
         $customValueId = CRM_Core_DAO::singleValueQuery($query);
     }
     //fix checkbox, now check box always submits values
     if ($customFields[$customFieldId]['html_type'] == 'CheckBox') {
         if ($value) {
             // Note that only during merge this is not an array, and you can directly use value
             if (is_array($value)) {
                 $selectedValues = array();
                 foreach ($value as $selId => $val) {
                     if ($val) {
                         $selectedValues[] = $selId;
                     }
                 }
                 if (!empty($selectedValues)) {
                     $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $selectedValues) . CRM_Core_DAO::VALUE_SEPARATOR;
                 } else {
                     $value = '';
                 }
             }
         }
     }
     if ($customFields[$customFieldId]['html_type'] == 'Multi-Select' || $customFields[$customFieldId]['html_type'] == 'AdvMulti-Select') {
         if ($value) {
             // Note that only during merge this is not an array,
             // and you can directly use value, CRM-4385
             if (is_array($value)) {
                 $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($value)) . CRM_Core_DAO::VALUE_SEPARATOR;
             }
         } else {
             $value = '';
         }
     }
     if (($customFields[$customFieldId]['html_type'] == 'Multi-Select' || $customFields[$customFieldId]['html_type'] == 'AdvMulti-Select' || $customFields[$customFieldId]['html_type'] == 'CheckBox') && $customFields[$customFieldId]['data_type'] == 'String' && !empty($customFields[$customFieldId]['text_length']) && !empty($value)) {
         // lets make sure that value is less than the length, else we'll
         // be losing some data, CRM-7481
         if (strlen($value) >= $customFields[$customFieldId]['text_length']) {
             // need to do a few things here
             // 1. lets find a new length
             $newLength = $customFields[$customFieldId]['text_length'];
             $minLength = strlen($value);
             while ($newLength < $minLength) {
                 $newLength = $newLength * 2;
             }
             // set the custom field meta data to have a length larger than value
             // alter the custom value table column to match this length
             CRM_Core_BAO_SchemaHandler::alterFieldLength($customFieldId, $tableName, $columnName, $newLength);
         }
//.........这里部分代码省略.........
开发者ID:Hack4Eugene,项目名称:Hack4Cause2016,代码行数:101,代码来源:CustomField.php

示例9: __construct

 /**
  * Class constructor.
  *
  * Takes in a set of custom field ids andsets up the data structures to
  * generate a query
  *
  * @param array $ids
  *   The set of custom field ids.
  *
  * @param bool $contactSearch
  * @param array $locationSpecificFields
  */
 public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array())
 {
     $this->_ids =& $ids;
     $this->_locationSpecificCustomFields = $locationSpecificFields;
     $this->_select = array();
     $this->_element = array();
     $this->_tables = array();
     $this->_whereTables = array();
     $this->_where = array();
     $this->_qill = array();
     $this->_options = array();
     $this->_fields = array();
     $this->_contactSearch = $contactSearch;
     if (empty($this->_ids)) {
         return;
     }
     // initialize the field array
     $tmpArray = array_keys($this->_ids);
     $idString = implode(',', $tmpArray);
     $query = "\nSELECT f.id, f.label, f.data_type,\n       f.html_type, f.is_search_range,\n       f.option_group_id, f.custom_group_id,\n       f.column_name, g.table_name,\n       f.date_format,f.time_format\n  FROM civicrm_custom_field f,\n       civicrm_custom_group g\n WHERE f.custom_group_id = g.id\n   AND g.is_active = 1\n   AND f.is_active = 1\n   AND f.id IN ( {$idString} )";
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         // get the group dao to figure which class this custom field extends
         $extends = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $dao->custom_group_id, 'extends');
         if (array_key_exists($extends, self::$extendsMap)) {
             $extendsTable = self::$extendsMap[$extends];
         } elseif (in_array($extends, CRM_Contact_BAO_ContactType::subTypes())) {
             // if $extends is a subtype, refer contact table
             $extendsTable = self::$extendsMap['Contact'];
         }
         $this->_fields[$dao->id] = array('id' => $dao->id, 'label' => $dao->label, 'extends' => $extendsTable, 'data_type' => $dao->data_type, 'html_type' => $dao->html_type, 'is_search_range' => $dao->is_search_range, 'column_name' => $dao->column_name, 'table_name' => $dao->table_name, 'option_group_id' => $dao->option_group_id);
         // Deprecated (and poorly named) cache of field attributes
         $this->_options[$dao->id] = array('attributes' => array('label' => $dao->label, 'data_type' => $dao->data_type, 'html_type' => $dao->html_type));
         $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $dao->id, array(), 'search');
         if ($options) {
             $this->_options[$dao->id] += $options;
         }
         if ($dao->html_type == 'Select Date') {
             $this->_options[$dao->id]['attributes']['date_format'] = $dao->date_format;
             $this->_options[$dao->id]['attributes']['time_format'] = $dao->time_format;
         }
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:55,代码来源:CustomQuery.php

示例10: formatCustomField

 /**
  * Format custom fields before inserting
  *
  * @param int    $customFieldId       custom field id
  * @param array  $customFormatted     formatted array
  * @param mix    $value               value of custom field
  * @param string $customFieldExtend   custom field extends
  * @param int    $customValueId custom option value id
  * @param int    $entityId            entity id (contribution, membership...)
  *
  * @return array $customFormatted formatted custom field array
  * @static
  */
 static function formatCustomField($customFieldId, &$customFormatted, $value, $customFieldExtend, $customValueId = null, $entityId = null, $inline = false)
 {
     //get the custom fields for the entity
     //subtype and basic type
     $customDataSubType = null;
     if (in_array($customFieldExtend, CRM_Contact_BAO_ContactType::subTypes())) {
         // This is the case when getFieldsForImport() requires fields
         // of subtype and its parent.CRM-5143
         $customDataSubType = $customFieldExtend;
         $customFieldExtend = CRM_Contact_BAO_ContactType::getBasicType($customDataSubType);
     }
     $customFields = CRM_Core_BAO_CustomField::getFields($customFieldExtend, false, $inline, $customDataSubType);
     if (!array_key_exists($customFieldId, $customFields)) {
         return;
     }
     // return if field is a 'code' field
     if (CRM_Utils_Array::value('is_view', $customFields[$customFieldId])) {
         return;
     }
     list($tableName, $columnName, $groupID) = self::getTableColumnGroup($customFieldId);
     if (is_array($customFieldExtend)) {
         $customFieldExtend = $customFieldExtend[0];
     }
     if (!$customValueId && !$customFields[$customFieldId]['is_multiple'] && $entityId) {
         //get the entity table for the custom field
         require_once "CRM/Core/BAO/CustomQuery.php";
         $entityTable = CRM_Core_BAO_CustomQuery::$extendsMap[$customFieldExtend];
         $query = "\nSELECT id \n  FROM {$tableName}\n WHERE entity_id={$entityId}";
         $customValueId = CRM_Core_DAO::singleValueQuery($query);
     }
     //fix checkbox, now check box always submits values
     if ($customFields[$customFieldId]['html_type'] == 'CheckBox') {
         if ($value) {
             // Note that only during merge this is not an array, and you can directly use value
             if (is_array($value)) {
                 $selectedValues = null;
                 foreach ($value as $selId => $val) {
                     if ($val) {
                         $selectedValues .= $selId . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
                     }
                 }
                 if ($selectedValues) {
                     $value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . $selectedValues;
                 } else {
                     $value = '';
                 }
             }
         }
     }
     if ($customFields[$customFieldId]['html_type'] == 'Multi-Select' || $customFields[$customFieldId]['html_type'] == 'AdvMulti-Select') {
         if ($value) {
             // Note that only during merge this is not an array,
             // and you can directly use value, CRM-4385
             if (is_array($value)) {
                 $value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_values($value)) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
             }
         } else {
             $value = '';
         }
     }
     $date = null;
     if ($customFields[$customFieldId]['data_type'] == 'Date') {
         if (!CRM_Utils_System::isNull($value)) {
             $format = $customFields[$customFieldId]['date_format'];
             if (in_array($format, array('dd-mm', 'mm/dd'))) {
                 $dateTimeArray = explode(' ', $value);
                 $separator = '/';
                 if ($format == 'dd-mm') {
                     $separator = '-';
                 }
                 $value = $dateTimeArray[0] . $separator . '1902';
                 if (array_key_exists(1, $dateTimeArray)) {
                     $value .= ' ' . $dateTimeArray[1];
                 }
             }
             $date = CRM_Utils_Date::processDate($value);
         }
         $value = $date;
     }
     if ($customFields[$customFieldId]['data_type'] == 'Float' || $customFields[$customFieldId]['data_type'] == 'Money') {
         if (!$value) {
             $value = 0;
         }
         if ($customFields[$customFieldId]['data_type'] == 'Money') {
             require_once 'CRM/Utils/Rule.php';
             $value = CRM_Utils_Rule::cleanMoney($value);
         }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:CustomField.php

示例11: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  *
  * @return void
  */
 function buildQuickForm()
 {
     $this->set('context', 'advanced');
     $this->_searchPane = CRM_Utils_Array::value('searchPane', $_GET);
     $this->_searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options');
     if (!$this->_searchPane || $this->_searchPane == 'basic') {
         CRM_Contact_Form_Search_Criteria::basic($this);
     }
     $allPanes = array();
     $paneNames = array(ts('Address Fields') => 'location', ts('Custom Fields') => 'custom', ts('Activities') => 'activity', ts('Relationships') => 'relationship', ts('Demographics') => 'demographics', ts('Notes') => 'notes', ts('Change Log') => 'changeLog');
     //check if there are any custom data searchable fields
     $groupDetails = array();
     $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
     // if no searchable fields unset panel
     if (empty($groupDetails)) {
         unset($paneNames[ts('Custom Fields')]);
     }
     foreach ($paneNames as $name => $type) {
         if (!$this->_searchOptions[$type]) {
             unset($paneNames[$name]);
         }
     }
     $components = CRM_Core_Component::getEnabledComponents();
     $componentPanes = array();
     foreach ($components as $name => $component) {
         if (in_array($name, array_keys($this->_searchOptions)) && $this->_searchOptions[$name] && CRM_Core_Permission::access($component->name)) {
             $componentPanes[$name] = $component->registerAdvancedSearchPane();
             $componentPanes[$name]['name'] = $name;
         }
     }
     usort($componentPanes, array('CRM_Utils_Sort', 'cmpFunc'));
     foreach ($componentPanes as $name => $pane) {
         // FIXME: we should change the use of $name here to keyword
         $paneNames[$pane['title']] = $pane['name'];
     }
     $hookPanes = array();
     CRM_Contact_BAO_Query_Hook::singleton()->registerAdvancedSearchPane($hookPanes);
     $paneNames = array_merge($paneNames, $hookPanes);
     $this->_paneTemplatePath = array();
     foreach ($paneNames as $name => $type) {
         if (!array_key_exists($type, $this->_searchOptions) && !in_array($type, $hookPanes)) {
             continue;
         }
         $allPanes[$name] = array('url' => CRM_Utils_System::url('civicrm/contact/search/advanced', "snippet=1&searchPane={$type}&qfKey={$this->controller->_key}"), 'open' => 'false', 'id' => $type);
         // see if we need to include this paneName in the current form
         if ($this->_searchPane == $type || CRM_Utils_Array::value("hidden_{$type}", $_POST) || CRM_Utils_Array::value("hidden_{$type}", $this->_formValues)) {
             $allPanes[$name]['open'] = 'true';
             if (CRM_Utils_Array::value($type, $components)) {
                 $c = $components[$type];
                 $this->add('hidden', "hidden_{$type}", 1);
                 $c->buildAdvancedSearchPaneForm($this);
                 $this->_paneTemplatePath[$type] = $c->getAdvancedSearchPaneTemplatePath();
             } else {
                 if (in_array($type, $hookPanes)) {
                     CRM_Contact_BAO_Query_Hook::singleton()->buildAdvancedSearchPaneForm($this, $type);
                     CRM_Contact_BAO_Query_Hook::singleton()->setAdvancedSearchPaneTemplatePath($this->_paneTemplatePath, $type);
                 } else {
                     CRM_Contact_Form_Search_Criteria::$type($this);
                     $template = ucfirst($type);
                     $this->_paneTemplatePath[$type] = "CRM/Contact/Form/Search/Criteria/{$template}.tpl";
                 }
             }
         }
     }
     $this->assign('allPanes', $allPanes);
     if (!$this->_searchPane) {
         parent::buildQuickForm();
     } else {
         $this->assign('suppressForm', TRUE);
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:79,代码来源:Advanced.php

示例12: checkForMixProfiles

 /**
  * Check if we are rendering mixed profiles.
  *
  * @param array $profileIds
  *   Associated array of profile ids.
  *
  * @return bool
  *   true if profile is mixed
  */
 public static function checkForMixProfiles($profileIds)
 {
     $mixProfile = FALSE;
     $contactTypes = array('Individual', 'Household', 'Organization');
     $subTypes = CRM_Contact_BAO_ContactType::subTypes();
     $components = array('Contribution', 'Participant', 'Membership', 'Activity');
     $typeCount = array('ctype' => array(), 'subtype' => array());
     foreach ($profileIds as $gid) {
         $profileType = CRM_Core_BAO_UFField::getProfileType($gid);
         // ignore profile of type Contact
         if ($profileType == 'Contact') {
             continue;
         }
         if (in_array($profileType, $contactTypes)) {
             if (!isset($typeCount['ctype'][$profileType])) {
                 $typeCount['ctype'][$profileType] = 1;
             }
             // check if we are rendering profile of different contact types
             if (count($typeCount['ctype']) == 2) {
                 $mixProfile = TRUE;
                 break;
             }
         } elseif (in_array($profileType, $components)) {
             $mixProfile = TRUE;
             break;
         } else {
             if (!isset($typeCount['subtype'][$profileType])) {
                 $typeCount['subtype'][$profileType] = 1;
             }
             // check if we are rendering profile of different contact sub types
             if (count($typeCount['subtype']) == 2) {
                 $mixProfile = TRUE;
                 break;
             }
         }
     }
     return $mixProfile;
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:47,代码来源:UFGroup.php

示例13: custom

 /**
  * Generate the custom Data Fields based
  * on the is_searchable
  *
  * @access private
  * @return void
  */
 static function custom(&$form)
 {
     $form->add('hidden', 'hidden_custom', 1);
     $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $extends);
     $form->assign('groupTree', $groupDetails);
     foreach ($groupDetails as $key => $group) {
         $_groupTitle[$key] = $group['name'];
         CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
         $groupId = $group['id'];
         foreach ($group['fields'] as $field) {
             $fieldId = $field['id'];
             $elementName = 'custom_' . $fieldId;
             CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true);
         }
     }
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:24,代码来源:Criteria.php

示例14: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $this->assignToTemplate();
     $productID = $this->get('productID');
     $option = $this->get('option');
     $membershipTypeID = $this->get('membershipTypeID');
     $this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values));
     if ($productID) {
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, FALSE, $productID, $option);
     }
     if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) {
         $this->assign('lineItem', $this->_lineItem);
     } else {
         if (is_array($membershipTypeID)) {
             $membershipTypeID = current($membershipTypeID);
         }
         $this->assign('is_quick_config', 1);
         $this->_params['is_quick_config'] = 1;
     }
     $this->assign('priceSetID', $this->_priceSetId);
     $this->assign('useForMember', $this->get('useForMember'));
     $params = $this->_params;
     $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     if ($invoicing) {
         $getTaxDetails = FALSE;
         $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
         foreach ($this->_lineItem as $key => $value) {
             foreach ($value as $v) {
                 if (isset($v['tax_rate'])) {
                     if ($v['tax_rate'] != '') {
                         $getTaxDetails = TRUE;
                     }
                 }
             }
         }
         $this->assign('getTaxDetails', $getTaxDetails);
         $this->assign('taxTerm', $taxTerm);
         $this->assign('totalTaxAmount', $params['tax_amount']);
     }
     if ($this->_honor_block_is_active && !empty($params['soft_credit_type_id'])) {
         $honorName = NULL;
         $softCreditTypes = CRM_Core_OptionGroup::values("soft_credit_type", FALSE);
         $this->assign('honor_block_is_active', $this->_honor_block_is_active);
         $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]);
         CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields($this, $params['honor'], $params['honoree_profile_id']);
         $fieldTypes = array('Contact');
         $fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($params['honoree_profile_id']);
         $this->buildCustom($params['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     //pcp elements
     if ($this->_pcpId) {
         $qParams .= "&amp;pcpId={$this->_pcpId}";
         $this->assign('pcpBlock', TRUE);
         foreach (array('pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note') as $val) {
             if (!empty($this->_params[$val])) {
                 $this->assign($val, $this->_params[$val]);
             }
         }
     }
     $this->assign('qParams', $qParams);
     if ($membershipTypeID) {
         $transactionID = $this->get('membership_trx_id');
         $membershipAmount = $this->get('membership_amount');
         $renewalMode = $this->get('renewal_mode');
         $this->assign('membership_trx_id', $transactionID);
         $this->assign('membership_amount', $membershipAmount);
         $this->assign('renewal_mode', $renewalMode);
         $this->buildMembershipBlock($this->_membershipContactID, FALSE, $membershipTypeID, TRUE, NULL);
         if (!empty($params['auto_renew'])) {
             $this->assign('auto_renew', TRUE);
         }
     }
     $this->_separateMembershipPayment = $this->get('separateMembershipPayment');
     $this->assign("is_separate_payment", $this->_separateMembershipPayment);
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre', TRUE);
     $this->buildCustom($this->_values['custom_post_id'], 'customPost', TRUE);
     if (!empty($params['hidden_onbehalf_profile'])) {
         $ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
         $OnBehalfProfile = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         $profileId = $OnBehalfProfile[0];
         $fieldTypes = array('Contact', 'Organization');
         $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization');
         $fieldTypes = array_merge($fieldTypes, $contactSubType);
         if (is_array($this->_membershipBlock) && !empty($this->_membershipBlock)) {
             $fieldTypes = array_merge($fieldTypes, array('Membership'));
         } else {
             $fieldTypes = array_merge($fieldTypes, array('Contribution'));
         }
         $this->buildCustom($profileId, 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes);
     }
     $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $this->_params));
     $this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $this->_params)));
     $defaults = array();
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:ThankYou.php

示例15: formRule


//.........这里部分代码省略.........
             }
             if (!$emailField) {
                 $disableSettingURL = CRM_Utils_System::url('civicrm/admin/setting/preferences/mailing', 'reset=1');
                 $errors['field_name'] = ts('Your site is currently configured to require double-opt in when users join (subscribe) to Group(s) via a Profile form. In this mode, you need to include an Email field in a Profile BEFORE you can add the Group(s) field. This ensures that an opt-in confirmation email can be sent. Your site administrator can disable double opt-in on the civimail admin settings: <em>%1</em>', array(1 => $disableSettingURL));
             }
         }
     }
     //fix for CRM-3037
     $fieldType = $fields['field_name'][0];
     //get the group type.
     $groupType = CRM_Core_BAO_UFGroup::calculateGroupType($self->_gid, FALSE, CRM_Utils_Array::value('field_id', $fields));
     switch ($fieldType) {
         case 'Contact':
             self::formRuleSubType($fieldType, $groupType, $errors);
             break;
         case 'Individual':
             if (in_array('Activity', $groupType) || in_array('Household', $groupType) || in_array('Organization', $groupType)) {
                 //CRM-7603 - need to support activity + individual.
                 //$errors['field_name'] =
                 //ts( 'Cannot add or update profile field type Individual with combination of Household or Organization or Activity' );
                 if (in_array('Household', $groupType) || in_array('Organization', $groupType)) {
                     $errors['field_name'] = ts('Cannot add or update profile field type Individual with combination of Household or Organization');
                 }
             } else {
                 self::formRuleSubType($fieldType, $groupType, $errors);
             }
             break;
         case 'Household':
             if (in_array('Activity', $groupType) || in_array('Individual', $groupType) || in_array('Organization', $groupType)) {
                 $errors['field_name'] = ts('Cannot add or update profile field type Household with combination of Individual or Organization or Activity');
             } else {
                 self::formRuleSubType($fieldType, $groupType, $errors);
             }
             break;
         case 'Organization':
             if (in_array('Activity', $groupType) || in_array('Household', $groupType) || in_array('Individual', $groupType)) {
                 $errors['field_name'] = ts('Cannot add or update profile field type Organization with combination of Household or Individual or Activity');
             } else {
                 self::formRuleSubType($fieldType, $groupType, $errors);
             }
             break;
         case 'Activity':
             if (in_array('Individual', $groupType) || in_array('Membership', $groupType) || in_array('Contribution', $groupType) || in_array('Organization', $groupType) || in_array('Household', $groupType) || in_array('Participant', $groupType)) {
                 //CRM-7603 - need to support activity + contact type.
                 //$errors['field_name'] =
                 //ts( 'Cannot add or update profile field type Activity with combination Participant or Membership or Contribution or Household or Organization or Individual' );
                 if (in_array('Membership', $groupType) || in_array('Contribution', $groupType) || in_array('Participant', $groupType)) {
                     $errors['field_name'] = ts('Cannot add or update profile field type Activity with combination Participant or Membership or Contribution');
                 }
             } else {
                 self::formRuleSubType($fieldType, $groupType, $errors);
             }
             if ($isCustomField && !isset($errors['field_name'])) {
                 self::formRuleCustomDataExtentColumnValue($customField, $self->_gid, $fieldType, $errors);
             }
             break;
         case 'Participant':
             if (in_array('Membership', $groupType) || in_array('Contribution', $groupType) || in_array('Organization', $groupType) || in_array('Household', $groupType) || in_array('Activity', $groupType)) {
                 $errors['field_name'] = ts('Cannot add or update profile field type Participant with combination of Activity or Membership or Contribution or Household or Organization.');
             } else {
                 self::formRuleSubType($fieldType, $groupType, $errors);
             }
             break;
         case 'Contribution':
             //special case where in we allow contribution + oganization fields, for on behalf feature
             $profileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'on_behalf_organization', 'id', 'name');
             if (in_array('Participant', $groupType) || in_array('Membership', $groupType) || $profileId != $self->_gid && in_array('Organization', $groupType) || in_array('Household', $groupType) || in_array('Activity', $groupType)) {
                 $errors['field_name'] = ts('Cannot add or update profile field type Contribution with combination of Activity or Membership or Participant or Household or Organization');
             } else {
                 self::formRuleSubType($fieldType, $groupType, $errors);
             }
             break;
         case 'Membership':
             //special case where in we allow contribution + oganization fields, for on behalf feature
             $profileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'on_behalf_organization', 'id', 'name');
             if (in_array('Participant', $groupType) || in_array('Contribution', $groupType) || $profileId != $self->_gid && in_array('Organization', $groupType) || in_array('Household', $groupType) || in_array('Activity', $groupType)) {
                 $errors['field_name'] = ts('Cannot add or update profile field type Membership with combination of Activity or Participant or Contribution or Household or Organization');
             } else {
                 self::formRuleSubType($fieldType, $groupType, $errors);
             }
             break;
         default:
             $profileType = CRM_Core_BAO_UFField::getProfileType($fields['group_id'], TRUE, FALSE, TRUE);
             if (CRM_Contact_BAO_ContactType::isaSubType($fieldType)) {
                 if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                     if ($fieldType != $profileType) {
                         $errors['field_name'] = ts('Cannot add or update profile field type "%1" with combination of "%2".', array(1 => $fieldType, 2 => $profileType));
                     }
                 } else {
                     $basicType = CRM_Contact_BAO_ContactType::getBasicType($fieldType);
                     if ($profileType && $profileType != $basicType && $profileType != 'Contact') {
                         $errors['field_name'] = ts('Cannot add or update profile field type "%1" with combination of "%2".', array(1 => $fieldType, 2 => $profileType));
                     }
                 }
             } elseif (CRM_Utils_Array::value(1, $fields['field_name']) == 'contact_sub_type' && !in_array($profileType, array('Individual', 'Household', 'Organization')) && !in_array($profileType, CRM_Contact_BAO_ContactType::subTypes())) {
                 $errors['field_name'] = ts('Cannot add or update profile field Contact Subtype as profile type is not one of Individual, Household or Organization.');
             }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:Field.php


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