),
),
);
- $permissions['uf_field'] = $permissions['uf_group'];
+ $permissions['uf_field'] = $permissions['uf_join'] = $permissions['uf_group'];
$permissions['uf_field']['delete'] = array(
'access CiviCRM',
array(
* @param bool $default
* //CRM-15427.
*/
- public function addProfileSelector($name, $label, $allowCoreTypes, $allowSubTypes, $entities, $default = FALSE) {
+ public function addProfileSelector($name, $label, $allowCoreTypes, $allowSubTypes, $entities, $default = FALSE, $usedFor = NULL) {
// Output widget
// FIXME: Instead of adhoc serialization, use a single json_encode()
CRM_UF_Page_ProfileEditor::registerProfileScripts();
'data-entities' => json_encode($entities),
//CRM-15427
'data-default' => $default,
+ 'data-usedfor' => json_encode($usedFor),
));
}
extract(self::getProfileSelectorTypes());
//CRM-15427
- $form->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
- $form->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $form->addProfileSelector('custom_pre_id', ts('Include Profile') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE, $usedFor);
+ $form->addProfileSelector('custom_post_id', ts('Include Profile') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE, $usedFor);
- $form->addProfileSelector('additional_custom_pre_id', ts('Profile for Additional Participants') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
- $form->addProfileSelector('additional_custom_post_id', ts('Profile for Additional Participants') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $form->addProfileSelector('additional_custom_pre_id', ts('Profile for Additional Participants') . '<br />' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE, $usedFor);
+ $form->addProfileSelector('additional_custom_post_id', ts('Profile for Additional Participants') . '<br />' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE, $usedFor);
}
/**
extract((is_null($configs)) ? self::getProfileSelectorTypes() : $configs);
$element = $prefix . "custom_post_id_multiple[$count]";
$label .= '<br />' . ts('(bottom of page)');
- $form->addProfileSelector($element, $label, $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE);
+ $form->addProfileSelector($element, $label, $allowCoreTypes, $allowSubTypes, $profileEntities, TRUE, $usedFor);
}
/**
'allowCoreTypes' => array(),
'allowSubTypes' => array(),
'profileEntities' => array(),
+ 'usedFor' => array(),
);
$configs['allowCoreTypes'] = array_merge(array(
'Individual',
), CRM_Contact_BAO_ContactType::subTypes('Individual'));
$configs['allowCoreTypes'][] = 'Participant';
+ if (CRM_Core_Permission::check('manage event profiles') && !CRM_Core_Permission::check('administer CiviCRM')) {
+ $configs['usedFor'][] = 'CiviEvent';
+ }
//CRM-15427
$id = CRM_Utils_Request::retrieve('id', 'Integer');
if ($id) {
CRM_Core_Resources::singleton()
->addSettingsFactory(function () {
+ $ufGroups = civicrm_api3('UFGroup', 'get', array(
+ 'sequential' => 1,
+ 'is_active' => 1,
+ 'rowCount' => 1000, // FIXME
+ ));
+ if (CRM_Core_Permission::check('manage event profiles') && !CRM_Core_Permission::check('administer CiviCRM')) {
+ foreach ($ufGroups['values'] as $key => $value) {
+ $ufJoin = CRM_Core_BAO_UFGroup::getUFJoinRecord($value['id']);
+ if (in_array('CiviEvent', $ufJoin)) {
+ $ufGroups['values'][$key]['module'] = 'CiviEvent';
+ }
+ }
+ }
return array(
'PseudoConstant' => array(
'locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'),
'websiteType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'),
'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'),
),
- 'initialProfileList' => civicrm_api('UFGroup', 'get', array(
- 'version' => 3,
- 'sequential' => 1,
- 'is_active' => 1,
- 'rowCount' => 1000, // FIXME
- )),
+ 'initialProfileList' => $ufGroups,
'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(),
'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE),
);
$select = $(this).hide().addClass('rendered');
var validTypesId = [];
+ var usedByFilter = null;
if (options.groupTypeFilter) {
matchingUfGroups = ufGroupCollection.subcollection({
filter: function(ufGroupModel) {
- return ufGroupModel.checkGroupType(options.groupTypeFilter, options.allowAllSubtypes);
+ if(!$.isEmptyObject(options.usedByFilter)) {
+ usedByFilter = options.usedByFilter;
+ }
+ return ufGroupModel.checkGroupType(options.groupTypeFilter, options.allowAllSubtypes, usedByFilter);
}
});
} else {
groupTypeFilter: $(this).data('groupType'),
entities: $(this).data('entities'),
//CRM-15427
- allowAllSubtypes: $(this).data('default')
+ allowAllSubtypes: $(this).data('default'),
+ usedByFilter: $(this).data('usedfor')
});
});
});
* @return {Boolean}
*/
//CRM-15427
- checkGroupType: function(validTypesExpr, allowAllSubtypes) {
+ checkGroupType: function(validTypesExpr, allowAllSubtypes, usedByFilter) {
var allMatched = true;
allowAllSubtypes = allowAllSubtypes || false;
+ usedByFilter = usedByFilter || null;
if (_.isEmpty(this.get('group_type'))) {
return true;
}
+ if (usedByFilter && _.isEmpty(this.get('module'))) {
+ return false;
+ }
var actualTypes = CRM.UF.parseTypeList(this.get('group_type'));
var validTypes = CRM.UF.parseTypeList(validTypesExpr);
}
});
+ if (usedByFilter && this.get('module') != usedByFilter) {
+ allMatched = false;
+ }
+
//CRM-15427 allow all subtypes
if (!$.isEmptyObject(validTypes.subTypes) && !allowAllSubtypes) {
// Every actual.subType is a valid.subType