本文整理汇总了PHP中CRM_Core_BAO_UFGroup::getUFJoinRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::getUFJoinRecord方法的具体用法?PHP CRM_Core_BAO_UFGroup::getUFJoinRecord怎么用?PHP CRM_Core_BAO_UFGroup::getUFJoinRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::getUFJoinRecord方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerProfileScripts
/**
* Register profile scripts.
*/
public static function registerProfileScripts()
{
static $loaded = FALSE;
if ($loaded || CRM_Core_Resources::isAjaxMode()) {
return;
}
$loaded = TRUE;
CRM_Core_Resources::singleton()->addSettingsFactory(function () {
$ufGroups = civicrm_api3('UFGroup', 'get', array('sequential' => 1, 'is_active' => 1, 'options' => array('limit' => 0)));
//CRM-16915 - insert 'module' param for the profile used by CiviEvent.
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) || in_array('CiviEvent_Additional', $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' => $ufGroups, 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), 'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE));
})->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.js', 120, 'html-header')->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.collectionsubset.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/backbone-forms.js', 130, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/adapters/backbone.bootstrap-modal.min.js', 140, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/editors/list.min.js', 140, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/backbone-forms/distribution/templates/default.css', 140, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addStyleFile('civicrm', 'css/crm.designer.css', 140, 'html-header')->addScriptFile('civicrm', 'js/crm.backbone.js', 150)->addScriptFile('civicrm', 'js/model/crm.schema-mapped.js', 200)->addScriptFile('civicrm', 'js/model/crm.uf.js', 200)->addScriptFile('civicrm', 'js/model/crm.designer.js', 200)->addScriptFile('civicrm', 'js/model/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/view/crm.designer.js', 200)->addScriptFile('civicrm', 'js/view/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/jquery/jquery.crmProfileSelector.js', 250)->addScriptFile('civicrm', 'js/crm.designerapp.js', 250);
CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/UF/Page/ProfileTemplates.tpl'));
}
示例2: browse
/**
* Browse all uf data groups.
*
* @param
*
* @return void
* @access public
* @static
*/
function browse($action = NULL)
{
$ufGroup = array();
$allUFGroups = array();
$allUFGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup();
if (empty($allUFGroups)) {
return;
}
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $allUFGroups);
foreach ($allUFGroups as $id => $value) {
$ufGroup[$id] = array();
$ufGroup[$id]['id'] = $id;
$ufGroup[$id]['title'] = $value['title'];
$ufGroup[$id]['created_id'] = $value['created_id'];
$ufGroup[$id]['created_by'] = CRM_Contact_BAO_Contact::displayName($value['created_id']);
$ufGroup[$id]['description'] = $value['description'];
$ufGroup[$id]['is_active'] = $value['is_active'];
$ufGroup[$id]['group_type'] = $value['group_type'];
$ufGroup[$id]['is_reserved'] = $value['is_reserved'];
// form all action links
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on uf_group properties.
if ($value['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
// drop certain actions if the profile is reserved
if ($value['is_reserved']) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$groupTypes = self::extractGroupTypes($value['group_type']);
$groupComponents = array('Contribution', 'Membership', 'Activity', 'Participant');
// drop Create, Edit and View mode links if profile group_type is Contribution, Membership, Activities or Participant
$componentFound = array_intersect($groupComponents, array_keys($groupTypes));
if (!empty($componentFound)) {
$action -= CRM_Core_Action::ADD;
}
$groupTypesString = '';
if (!empty($groupTypes)) {
$groupTypesStrings = array();
foreach ($groupTypes as $groupType => $typeValues) {
if (is_array($typeValues)) {
if ($groupType == 'Participant') {
foreach ($typeValues as $subType => $subTypeValues) {
$groupTypesStrings[] = $subType . '::' . implode(': ', $subTypeValues);
}
} else {
$groupTypesStrings[] = $groupType . '::' . implode(': ', current($typeValues));
}
} else {
$groupTypesStrings[] = $groupType;
}
}
$groupTypesString = implode(', ', $groupTypesStrings);
}
$ufGroup[$id]['group_type'] = $groupTypesString;
$ufGroup[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $id));
//get the "Used For" from uf_join
$ufGroup[$id]['module'] = implode(', ', CRM_Core_BAO_UFGroup::getUFJoinRecord($id, TRUE));
}
$this->assign('rows', $ufGroup);
}
示例3: createUFJoin
/**
* Make uf join entries for an uf group.
*
* @param array $params
* (reference) an assoc array of name/value pairs.
* @param int $ufGroupId
* Ufgroup id.
*/
public static function createUFJoin(&$params, $ufGroupId)
{
$groupTypes = CRM_Utils_Array::value('uf_group_type', $params);
// get ufjoin records for uf group
$ufGroupRecord = CRM_Core_BAO_UFGroup::getUFJoinRecord($ufGroupId);
// get the list of all ufgroup types
$allUFGroupType = CRM_Core_SelectValues::ufGroupTypes();
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($groupTypes)) {
$groupTypes = array();
}
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($ufGroupRecord)) {
$ufGroupRecord = array();
}
// check which values has to be inserted/deleted for contact
$menuRebuild = FALSE;
foreach ($allUFGroupType as $key => $value) {
$joinParams = array();
$joinParams['uf_group_id'] = $ufGroupId;
$joinParams['module'] = $key;
if ($key == 'User Account') {
$menuRebuild = TRUE;
}
if (array_key_exists($key, $groupTypes) && !in_array($key, $ufGroupRecord)) {
// insert a new record
CRM_Core_BAO_UFGroup::addUFJoin($joinParams);
} elseif (!array_key_exists($key, $groupTypes) && in_array($key, $ufGroupRecord)) {
// delete a record for existing ufgroup
CRM_Core_BAO_UFGroup::delUFJoin($joinParams);
}
}
//update the weight
$query = "\nUPDATE civicrm_uf_join\nSET weight = %1\nWHERE uf_group_id = %2\nAND ( entity_id IS NULL OR entity_id <= 0 )\n";
$p = array(1 => array($params['weight'], 'Integer'), 2 => array($ufGroupId, 'Integer'));
CRM_Core_DAO::executeQuery($query, $p);
// do a menu rebuild if we are on drupal, so it gets all the new menu entries
// for user account
$config = CRM_Core_Config::singleton();
if ($menuRebuild && $config->userSystem->is_drupal) {
menu_rebuild();
}
}
示例4: browse
/**
* Browse all uf data groups.
*
* @param
*
* @return void
*/
public function browse($action = NULL)
{
$ufGroup = array();
$allUFGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup();
if (empty($allUFGroups)) {
return;
}
$ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id');
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, NULL, 'civicrm_uf_group', $ufGroups, $allUFGroups);
foreach ($allUFGroups as $id => $value) {
$ufGroup[$id] = array();
$ufGroup[$id]['id'] = $id;
$ufGroup[$id]['title'] = $value['title'];
$ufGroup[$id]['created_id'] = $value['created_id'];
$ufGroup[$id]['created_by'] = CRM_Contact_BAO_Contact::displayName($value['created_id']);
$ufGroup[$id]['description'] = $value['description'];
$ufGroup[$id]['is_active'] = $value['is_active'];
$ufGroup[$id]['group_type'] = $value['group_type'];
$ufGroup[$id]['is_reserved'] = $value['is_reserved'];
// form all action links
$action = array_sum(array_keys(self::actionLinks()));
// update enable/disable links depending on uf_group properties.
if ($value['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
// drop certain actions if the profile is reserved
if ($value['is_reserved']) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$groupTypes = self::extractGroupTypes($value['group_type']);
// drop Create, Edit and View mode links if profile group_type is one of the following:
// Contribution, Membership, Activity, Participant, Case, Grant
$isMixedProfile = CRM_Core_BAO_UFField::checkProfileType($id);
if ($isMixedProfile) {
$action -= CRM_Core_Action::ADD;
$action -= CRM_Core_Action::ADVANCED;
$action -= CRM_Core_Action::BASIC;
$action -= CRM_Core_Action::PROFILE;
}
$ufGroup[$id]['group_type'] = self::formatGroupTypes($groupTypes);
$ufGroup[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $id), ts('more'), FALSE, 'ufGroup.row.actions', 'UFGroup', $id);
//get the "Used For" from uf_join
$ufGroup[$id]['module'] = implode(', ', CRM_Core_BAO_UFGroup::getUFJoinRecord($id, TRUE));
}
$this->assign('rows', $ufGroup);
}
示例5: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
*
* @return void
*/
function setDefaultValues()
{
$defaults = array();
$showHide = new CRM_Core_ShowHideBlocks();
if ($this->_action == CRM_Core_Action::ADD) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFJoin');
}
//id fetched for Dojo Pane
$pId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (isset($pId)) {
$this->_id = $pId;
}
if (isset($this->_id)) {
$defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight($this->_id);
$params = array('id' => $this->_id);
CRM_Core_BAO_UFGroup::retrieve($params, $defaults);
$defaults['group'] = CRM_Utils_Array::value('limit_listings_group_id', $defaults);
$defaults['add_contact_to_group'] = CRM_Utils_Array::value('add_to_group_id', $defaults);
//get the uf join records for current uf group
$ufJoinRecords = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id);
foreach ($ufJoinRecords as $key => $value) {
$checked[$value] = 1;
}
$defaults['uf_group_type'] = isset($checked) ? $checked : "";
//get the uf join records for current uf group other than default modules
$otherModules = array();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id, TRUE, TRUE);
if (!empty($otherModules)) {
$otherModuleString = NULL;
foreach ($otherModules as $key) {
$otherModuleString .= " [ x ] <label>" . $key . "</label>";
}
$this->assign('otherModuleString', $otherModuleString);
}
$showAdvanced = 0;
$advFields = array('group', 'post_URL', 'cancel_URL', 'add_captcha', 'is_map', 'is_uf_link', 'is_edit_link', 'is_update_dupe', 'is_cms_user', 'is_proximity_search');
foreach ($advFields as $key) {
if (!empty($defaults[$key])) {
$showAdvanced = 1;
$this->_allPanes['Advanced Settings']['open'] = 'true';
break;
}
}
} else {
$defaults['is_active'] = 1;
$defaults['is_map'] = 0;
$defaults['is_update_dupe'] = 0;
$defaults['is_proximity_search'] = 0;
}
// Don't assign showHide elements to template in DELETE mode (fields to be shown and hidden don't exist)
if (!($this->_action & CRM_Core_Action::DELETE) && !($this->_action & CRM_Core_Action::DISABLE)) {
$showHide->addToTemplate();
}
$this->assign('allPanes', $this->_allPanes);
return $defaults;
}
示例6: createUFJoin
/**
* Function to make uf join entries for an uf group
*
* @param array $params (reference) an assoc array of name/value pairs
* @param int $ufGroupId ufgroup id
*
* @return void
* @access public
* @static
*/
function createUFJoin(&$params, $ufGroupId)
{
$groupTypes = $params['uf_group_type'];
// get ufjoin records for uf group
$ufGroupRecord =& CRM_Core_BAO_UFGroup::getUFJoinRecord($ufGroupId);
// get the list of all ufgroup types
$allUFGroupType =& CRM_Core_SelectValues::ufGroupTypes();
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($groupTypes)) {
$groupTypes = array();
}
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($ufGroupRecord)) {
$ufGroupRecord = array();
}
// check which values has to be inserted/deleted for contact
foreach ($allUFGroupType as $key => $value) {
$joinParams = array();
$joinParams['uf_group_id'] = $ufGroupId;
$joinParams['module'] = $key;
if (array_key_exists($key, $groupTypes) && !in_array($key, $ufGroupRecord)) {
// insert a new record
CRM_Core_BAO_UFGroup::addUFJoin($joinParams);
} else {
if (!array_key_exists($key, $groupTypes) && in_array($key, $ufGroupRecord)) {
// delete a record for existing ufgroup
CRM_Core_BAO_UFGroup::delUFJoin($joinParams);
}
}
}
//update the weight for remaining group
CRM_Core_BAO_UFGroup::updateWeight($params['weight'], $ufGroupId);
}
示例7: browse
/**
* Browse all uf data groups.
*
* @param
* @return void
* @access public
* @static
*/
function browse($action = null)
{
$ufGroup = array();
$allUFGroups = array();
require_once 'CRM/Core/BAO/UFGroup.php';
$allUFGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup();
if (empty($allUFGroups)) {
return;
}
foreach ($allUFGroups as $id => $value) {
$ufGroup[$id] = array();
$ufGroup[$id]['id'] = $id;
$ufGroup[$id]['title'] = $value['title'];
$ufGroup[$id]['is_active'] = $value['is_active'];
$ufGroup[$id]['group_type'] = $value['group_type'];
$ufGroup[$id]['is_reserved'] = $value['is_reserved'];
// form all action links
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on uf_group properties.
if ($value['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
// drop certain actions if the profile is reserved
if ($value['is_reserved']) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$ufGroup[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $id));
//get the "Used For" from uf_join
$ufGroup[$id]['module'] = implode(', ', CRM_Core_BAO_UFGroup::getUFJoinRecord($id, true));
}
$this->assign('rows', $ufGroup);
}
示例8: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Profile Field'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Core_BAO_UFField::retrieve($params, $defaults);
// set it to null if so (avoids crappy E_NOTICE errors below
$defaults['location_type_id'] = CRM_Utils_Array::value('location_type_id', $defaults);
$specialFields = CRM_Core_BAO_UFGroup::getLocationFields();
if (!$defaults['location_type_id'] && $defaults["field_type"] != "Formatting" && in_array($defaults['field_name'], $specialFields)) {
$defaults['location_type_id'] = 0;
}
$defaults['field_name'] = array($defaults['field_type'], $defaults['field_type'] == "Formatting" ? "" : $defaults['field_name'], $defaults['field_name'] == "url" ? $defaults['website_type_id'] : $defaults['location_type_id'], CRM_Utils_Array::value('phone_type_id', $defaults));
$this->_gid = $defaults['uf_group_id'];
} else {
$defaults['is_active'] = 1;
}
$otherModules = array_values(CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid));
$this->assign('otherModules', $otherModules);
if ($this->_action & CRM_Core_Action::ADD) {
$fieldValues = array('uf_group_id' => $this->_gid);
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFField', $fieldValues);
}
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
//hidden field to catch the group id in profile
$this->add('hidden', 'group_id', $this->_gid);
//hidden field to catch the field id in profile
$this->add('hidden', 'field_id', $this->_id);
$fields = CRM_Core_BAO_UFField::getAvailableFields($this->_gid, $defaults);
$noSearchable = $hasWebsiteTypes = array();
$addressCustomFields = array_keys(CRM_Core_BAO_CustomField::getFieldsForImport('Address'));
foreach ($fields as $key => $value) {
foreach ($value as $key1 => $value1) {
//CRM-2676, replacing the conflict for same custom field name from different custom group.
if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key1)) {
$customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $customFieldId, 'custom_group_id');
$customGroupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'title');
$this->_mapperFields[$key][$key1] = $value1['title'] . ' :: ' . $customGroupName;
if (in_array($key1, $addressCustomFields)) {
$noSearchable[] = $value1['title'] . ' :: ' . $customGroupName;
}
} else {
$this->_mapperFields[$key][$key1] = $value1['title'];
}
$hasLocationTypes[$key][$key1] = CRM_Utils_Array::value('hasLocationType', $value1);
$hasWebsiteTypes[$key][$key1] = CRM_Utils_Array::value('hasWebsiteType', $value1);
// hide the 'is searchable' field for 'File' custom data
if (isset($value1['data_type']) && isset($value1['html_type']) && ($value1['data_type'] == 'File' && $value1['html_type'] == 'File' || $value1['data_type'] == 'Link' && $value1['html_type'] == 'Link')) {
if (!in_array($value1['title'], $noSearchable)) {
$noSearchable[] = $value1['title'];
}
}
}
}
$this->assign('noSearchable', $noSearchable);
$this->_location_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
$this->_website_types = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
/**
* FIXME: dirty hack to make the default option show up first. This
* avoids a mozilla browser bug with defaults on dynamically constructed
* selector widgets.
*/
if ($defaultLocationType) {
$defaultLocation = $this->_location_types[$defaultLocationType->id];
unset($this->_location_types[$defaultLocationType->id]);
$this->_location_types = array($defaultLocationType->id => $defaultLocation) + $this->_location_types;
}
$this->_location_types = array('Primary') + $this->_location_types;
// since we need a hierarchical list to display contact types & subtypes,
// this is what we going to display in first selector
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE);
unset($contactTypes['']);
$contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array();
$sel1 = array('' => '- select -') + $contactTypes;
if (!empty($fields['Activity'])) {
$sel1['Activity'] = 'Activity';
}
if (CRM_Core_Permission::access('CiviEvent')) {
$sel1['Participant'] = 'Participants';
}
if (!empty($fields['Contribution'])) {
$sel1['Contribution'] = 'Contributions';
}
if (!empty($fields['Membership'])) {
$sel1['Membership'] = 'Membership';
}
if (!empty($fields['Case'])) {
$sel1['Case'] = 'Case';
}
if (!empty($fields['Formatting'])) {
//.........这里部分代码省略.........
示例9: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return void
*/
function setDefaultValues()
{
$defaults = array();
if ($this->_action == CRM_CORE_ACTION_ADD) {
$defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight();
$UFGroupType = CRM_Core_SelectValues::ufGroupTypes();
foreach ($UFGroupType as $key => $value) {
$checked[$key] = 1;
}
$defaults['uf_group_type'] = $checked;
}
if (isset($this->_id)) {
$defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight($this->_id);
$params = array('id' => $this->_id);
CRM_Core_BAO_UFGroup::retrieve($params, $defaults);
$defaults['group'] = $defaults['limit_listings_group_id'];
//get the uf join records for current uf group
$ufJoinRecords = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id);
foreach ($ufJoinRecords as $key => $value) {
$checked[$value] = 1;
}
$defaults['uf_group_type'] = $checked;
//get the uf join records for current uf group other than default modules
$otherModules = array();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id, true, true);
if (!empty($otherModules)) {
foreach ($otherModules as $key) {
$otherModuleString .= " [ x ] " . $key;
}
$this->assign('otherModuleString', $otherModuleString);
}
} else {
$defaults['is_active'] = 1;
}
return $defaults;
}
示例10: browse
/**
* Browse all CiviCRM Profile group fields.
*
* @return void
*/
public function browse()
{
$resourceManager = CRM_Core_Resources::singleton();
if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) {
$resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header');
}
$ufField = array();
$ufFieldBAO = new CRM_Core_BAO_UFField();
// fkey is gid
$ufFieldBAO->uf_group_id = $this->_gid;
$ufFieldBAO->orderBy('weight', 'field_name');
$ufFieldBAO->find();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid);
$this->assign('otherModules', $otherModules);
$isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved');
$this->assign('isGroupReserved', $isGroupReserved);
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') {
$this->assign('skipCreate', TRUE);
}
$locationType = array();
$locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
$fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields);
$select = array();
foreach ($fields as $name => $field) {
if ($name) {
$select[$name] = $field['title'];
}
}
$select['group'] = ts('Group(s)');
$select['tag'] = ts('Tag(s)');
$visibility = CRM_Core_SelectValues::ufVisibility();
while ($ufFieldBAO->fetch()) {
$ufField[$ufFieldBAO->id] = array();
$phoneType = $locType = '';
CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]);
$ufField[$ufFieldBAO->id]['visibility_display'] = $visibility[$ufFieldBAO->visibility];
$ufField[$ufFieldBAO->id]['label'] = $ufFieldBAO->label;
$action = array_sum(array_keys($this->actionLinks()));
if ($ufFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($ufFieldBAO->is_reserved) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$ufField[$ufFieldBAO->id]['order'] = $ufField[$ufFieldBAO->id]['weight'];
$ufField[$ufFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $ufFieldBAO->id, 'gid' => $this->_gid), ts('more'), FALSE, 'ufField.row.actions', 'UFField', $ufFieldBAO->id);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
$filter = "uf_group_id = {$this->_gid}";
CRM_Utils_Weight::addOrder($ufField, 'CRM_Core_DAO_UFField', 'id', $returnURL, $filter);
$this->assign('ufField', $ufField);
// retrieve showBestResult from session
$session = CRM_Core_Session::singleton();
$showBestResult = $session->get('showBestResult');
$this->assign('showBestResult', $showBestResult);
$session->set('showBestResult', 0);
}
示例11: browse
/**
* Browse all CiviCRM Profile group fields.
*
* @return void
* @access public
* @static
*/
function browse()
{
$ufField = array();
$ufFieldBAO = new CRM_Core_BAO_UFField();
// fkey is gid
$ufFieldBAO->uf_group_id = $this->_gid;
$ufFieldBAO->orderBy('weight', 'field_name');
$ufFieldBAO->find();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid);
$this->assign('otherModules', $otherModules);
$isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved');
$this->assign('isGroupReserved', $isGroupReserved);
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') {
$this->assign('skipCreate', TRUE);
}
$locationType = array();
$locationType = CRM_Core_PseudoConstant::locationType();
$fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
$fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields);
if (CRM_Core_Permission::access('Quest')) {
$fields = array_merge(CRM_Quest_BAO_Student::exportableFields(), $fields);
}
$select = array();
foreach ($fields as $name => $field) {
if ($name) {
$select[$name] = $field['title'];
}
}
$select['group'] = ts('Group(s)');
$select['tag'] = ts('Tag(s)');
while ($ufFieldBAO->fetch()) {
$ufField[$ufFieldBAO->id] = array();
$phoneType = $locType = '';
CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]);
CRM_Core_DAO_UFField::addDisplayEnums($ufField[$ufFieldBAO->id]);
$ufField[$ufFieldBAO->id]['label'] = $ufFieldBAO->label;
$action = array_sum(array_keys($this->actionLinks()));
if ($ufFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($ufFieldBAO->is_reserved) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$ufField[$ufFieldBAO->id]['order'] = $ufField[$ufFieldBAO->id]['weight'];
$ufField[$ufFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $ufFieldBAO->id, 'gid' => $this->_gid));
}
$returnURL = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
$filter = "uf_group_id = {$this->_gid}";
CRM_Utils_Weight::addOrder($ufField, 'CRM_Core_DAO_UFField', 'id', $returnURL, $filter);
$this->assign('ufField', $ufField);
// retrieve showBestResult from session
$session = CRM_Core_Session::singleton();
$showBestResult = $session->get('showBestResult');
$this->assign('showBestResult', $showBestResult);
$session->set('showBestResult', 0);
}
示例12: browse
/**
* Browse all uf data groups.
*
* @param
* @return void
* @access public
* @static
*/
function browse($action = null)
{
$ufGroup = array();
$allUFGroups = array();
require_once 'CRM/Core/BAO/UFGroup.php';
$allUFGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup();
if (empty($allUFGroups)) {
return;
}
require_once 'CRM/Utils/Hook.php';
$ufGroups = CRM_Core_PseudoConstant::ufGroup();
CRM_Utils_Hook::aclGroup(CRM_Core_Permission::ADMIN, null, 'civicrm_uf_group', $ufGroups, $allUFGroups);
foreach ($allUFGroups as $id => $value) {
$ufGroup[$id] = array();
$ufGroup[$id]['id'] = $id;
$ufGroup[$id]['title'] = $value['title'];
$ufGroup[$id]['is_active'] = $value['is_active'];
$ufGroup[$id]['group_type'] = $value['group_type'];
$ufGroup[$id]['is_reserved'] = $value['is_reserved'];
// form all action links
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on uf_group properties.
if ($value['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
// drop certain actions if the profile is reserved
if ($value['is_reserved']) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
// drop Create, Edit and View mode links if profile group_type is Contribution, Membership, or Participant
if ($value['group_type'] == 'Contribution' || $value['group_type'] == 'Membership' || $value['group_type'] == 'Participant') {
$action -= CRM_Core_Action::ADD;
}
$ufGroup[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $id));
//get the "Used For" from uf_join
$ufGroup[$id]['module'] = implode(', ', CRM_Core_BAO_UFGroup::getUFJoinRecord($id, true));
}
$this->assign('rows', $ufGroup);
}
示例13: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Profile Field'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Core_BAO_UFField::retrieve($params, $defaults);
// set it to null if so (avoids crappy E_NOTICE errors below
$defaults['location_type_id'] = CRM_Utils_Array::value('location_type_id', $defaults);
$specialFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'county', 'phone', 'email', 'im', 'address_name');
if (!$defaults['location_type_id'] && $defaults["field_type"] != "Formatting" && in_array($defaults['field_name'], $specialFields)) {
$defaults['location_type_id'] = 0;
}
$defaults['field_name'] = array($defaults['field_type'], $defaults['field_type'] == "Formatting" ? "" : $defaults['field_name'], $defaults['location_type_id'], CRM_Utils_Array::value('phone_type_id', $defaults));
$this->_gid = $defaults['uf_group_id'];
} else {
$defaults['is_active'] = 1;
}
$otherModules = array_values(CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid));
$this->assign('otherModules', $otherModules);
if ($this->_action & CRM_Core_Action::ADD) {
$fieldValues = array('uf_group_id' => $this->_gid);
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFField', $fieldValues);
}
// lets trim all the whitespace
$this->applyFilter('__ALL__', 'trim');
//hidden field to catch the group id in profile
$this->add('hidden', 'group_id', $this->_gid);
//hidden field to catch the field id in profile
$this->add('hidden', 'field_id', $this->_id);
$fields = array();
$fields['Individual'] = CRM_Contact_BAO_Contact::importableFields('Individual', FALSE, FALSE, TRUE);
$fields['Household'] = CRM_Contact_BAO_Contact::importableFields('Household', FALSE, FALSE, TRUE);
$fields['Organization'] = CRM_Contact_BAO_Contact::importableFields('Organization', FALSE, FALSE, TRUE);
// add current employer for individuals
$fields['Individual']['current_employer'] = array('name' => 'organization_name', 'title' => ts('Current Employer'));
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
if (!$addressOptions['county']) {
unset($fields['Individual']['county']);
unset($fields['Household']['county']);
unset($fields['Organization']['county']);
}
$fields['Contact'] = array();
//build the common contact fields array CRM-3037.
foreach ($fields['Individual'] as $key => $value) {
if (CRM_Utils_Array::value($key, $fields['Household']) && CRM_Utils_Array::value($key, $fields['Organization'])) {
$fields['Contact'][$key] = $value;
//as we move common fields to contacts. There fore these fields
//are unset from resoective array's.
unset($fields['Individual'][$key]);
unset($fields['Household'][$key]);
unset($fields['Organization'][$key]);
}
}
// add current employer for individuals
$fields['Contact']['id'] = array('name' => 'id', 'title' => ts('Internal Contact ID'));
unset($fields['Contact']['contact_type']);
// since we need a hierarchical list to display contact types & subtypes,
// this is what we going to display in first selector
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE);
unset($contactTypes['']);
// include Subtypes For Profile
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $name => $val) {
//custom fields for sub type
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($name);
if (array_key_exists($val['parent'], $fields)) {
$fields[$name] = $fields[$val['parent']] + $subTypeFields;
} else {
$fields[$name] = $subTypeFields;
}
}
//group selected and unwanted fields list
$groupFieldList = array_merge(CRM_Core_BAO_UFGroup::getFields($this->_gid, FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE), array('note', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'id'));
//unset selected fields
foreach ($groupFieldList as $key => $value) {
if (is_integer($key)) {
unset($fields['Individual'][$value], $fields['Household'][$value], $fields['Organization'][$value]);
continue;
}
if (CRM_Utils_Array::value('field_name', $defaults) && $defaults['field_name']['0'] == $value['field_type'] && $defaults['field_name']['1'] == $key) {
continue;
}
unset($fields[$value['field_type']][$key]);
}
unset($subTypes);
if (CRM_Core_Permission::access('Quest')) {
$fields['Student'] = CRM_Quest_BAO_Student::exportableFields();
}
// add current employer for individuals
$fields['Contact']['id'] = array('name' => 'id', 'title' => ts('Internal Contact ID'));
if (CRM_Core_Permission::access('CiviContribute')) {
//.........这里部分代码省略.........