本文整理汇总了PHP中CRM_Core_BAO_UFGroup::getListingFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::getListingFields方法的具体用法?PHP CRM_Core_BAO_UFGroup::getListingFields怎么用?PHP CRM_Core_BAO_UFGroup::getListingFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::getListingFields方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor
*
* @param $customSearchClass
* @param array $formValues array of form values imported
* @param array $params array of parameters for query
* @param null $returnProperties
* @param \const|int $action - action of search basic or advanced.
*
* @param bool $includeContactIds
* @param bool $searchDescendentGroups
* @param string $searchContext
* @param null $contextMenu
*
* @return CRM_Contact_Selector
* @access public
*/
function __construct($customSearchClass, $formValues = NULL, $params = NULL, $returnProperties = NULL, $action = CRM_Core_Action::NONE, $includeContactIds = FALSE, $searchDescendentGroups = TRUE, $searchContext = 'search', $contextMenu = NULL)
{
//don't build query constructor, if form is not submitted
$force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject);
if (empty($formValues) && !$force) {
return;
}
// submitted form values
$this->_formValues =& $formValues;
$this->_params =& $params;
$this->_returnProperties =& $returnProperties;
$this->_contextMenu =& $contextMenu;
$this->_context = $searchContext;
// type of selector
$this->_action = $action;
$this->_searchContext = $searchContext;
$this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $this->_formValues);
if ($this->_ufGroupID) {
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, FALSE, $this->_ufGroupID);
self::$_columnHeaders = NULL;
$this->_customFields = CRM_Core_BAO_CustomField::getFieldsForImport('Individual');
$this->_returnProperties = CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
$this->_returnProperties['contact_type'] = 1;
$this->_returnProperties['contact_sub_type'] = 1;
$this->_returnProperties['sort_name'] = 1;
}
$displayRelationshipType = CRM_Utils_Array::value('display_relationship_type', $this->_formValues);
$operator = CRM_Utils_Array::value('operator', $this->_formValues, 'AND');
// rectify params to what proximity search expects if there is a value for prox_distance
// CRM-7021
if (!empty($this->_params)) {
CRM_Contact_BAO_ProximityQuery::fixInputParams($this->_params);
}
$this->_query = new CRM_Contact_BAO_Query($this->_params, $this->_returnProperties, NULL, $includeContactIds, FALSE, CRM_Contact_BAO_Query::MODE_CONTACTS, FALSE, $searchDescendentGroups, FALSE, $displayRelationshipType, $operator);
$this->_options =& $this->_query->_options;
}
示例2: preProcess
/**
* Pre processing work done here.
*
* gets session variables for table name, id of entity in table, type of entity and stores them.
*
* @param
*
* @return void
*/
public function preProcess()
{
$this->_id = $this->get('id');
$this->_profileIds = $this->get('profileIds');
$this->_grid = CRM_Utils_Request::retrieve('grid', 'Integer', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
//unset from session when $_GET doesn't have it
//except when the form is submitted
if (empty($_POST)) {
if (!array_key_exists('multiRecord', $_GET)) {
$this->set('multiRecord', NULL);
}
if (!array_key_exists('recordId', $_GET)) {
$this->set('recordId', NULL);
}
}
$this->_session = CRM_Core_Session::singleton();
$this->_currentUserID = $this->_session->get('userID');
if ($this->_mode == self::MODE_EDIT) {
//specifies the action being done on a multi record field
$multiRecordAction = CRM_Utils_Request::retrieve('multiRecord', 'String', $this);
$this->_multiRecord = !is_numeric($multiRecordAction) ? CRM_Core_Action::resolve($multiRecordAction) : $multiRecordAction;
if ($this->_multiRecord) {
$this->set('multiRecord', $this->_multiRecord);
}
if ($this->_multiRecord && !in_array($this->_multiRecord, array(CRM_Core_Action::UPDATE, CRM_Core_Action::ADD, CRM_Core_Action::DELETE))) {
CRM_Core_Error::fatal(ts('Proper action not specified for this custom value record profile'));
}
}
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
$gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0));
if (count($gids) > 1 && !$this->_profileIds && empty($this->_profileIds)) {
if (!empty($gids)) {
foreach ($gids as $pfId) {
$this->_profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive');
}
}
// check if we are rendering mixed profiles
if (CRM_Core_BAO_UFGroup::checkForMixProfiles($this->_profileIds)) {
CRM_Core_Error::fatal(ts('You cannot combine profiles of multiple types.'));
}
// for now consider 1'st profile as primary profile and validate it
// i.e check for profile type etc.
// FIX ME: validations for other than primary
$this->_gid = $this->_profileIds[0];
$this->set('gid', $this->_gid);
$this->set('profileIds', $this->_profileIds);
}
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0);
$this->set('gid', $this->_gid);
}
$this->_activityId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, 0, 'GET');
if (is_numeric($this->_activityId)) {
$latestRevisionId = CRM_Activity_BAO_Activity::getLatestActivityId($this->_activityId);
if ($latestRevisionId) {
$this->_activityId = $latestRevisionId;
}
}
$this->_isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($this->_gid);
//get values for ufGroupName, captch and dupe update.
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
if ($dao->find(TRUE)) {
$this->_isUpdateDupe = $dao->is_update_dupe;
$this->_isAddCaptcha = $dao->add_captcha;
$this->_ufGroup = (array) $dao;
}
$dao->free();
if (!CRM_Utils_Array::value('is_active', $this->_ufGroup)) {
CRM_Core_Error::fatal(ts('The requested profile (gid=%1) is inactive or does not exist.', array(1 => $this->_gid)));
}
}
$this->assign('ufGroupName', $this->_ufGroup['name']);
$gids = empty($this->_profileIds) ? $this->_gid : $this->_profileIds;
// if we dont have a gid use the default, else just use that specific gid
if (($this->_mode == self::MODE_REGISTER || $this->_mode == self::MODE_CREATE) && !$this->_gid) {
$this->_ctype = CRM_Utils_Request::retrieve('ctype', 'String', $this, FALSE, 'Individual', 'REQUEST');
$this->_fields = CRM_Core_BAO_UFGroup::getRegistrationFields($this->_action, $this->_mode, $this->_ctype);
} elseif ($this->_mode == self::MODE_SEARCH) {
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields($this->_action, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, FALSE, $gids, TRUE, NULL, $this->_skipPermission, CRM_Core_Permission::SEARCH);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($gids, FALSE, NULL, NULL, NULL, FALSE, NULL, $this->_skipPermission, NULL, $this->_action == CRM_Core_Action::ADD ? CRM_Core_Permission::CREATE : CRM_Core_Permission::EDIT);
$multiRecordFieldListing = FALSE;
//using selector for listing of multirecord fields
if ($this->_mode == self::MODE_EDIT && $this->_gid) {
CRM_Core_BAO_UFGroup::shiftMultiRecordFields($this->_fields, $this->_multiRecordFields);
if ($this->_multiRecord) {
if ($this->_multiRecord != CRM_Core_Action::ADD) {
$this->_recordId = CRM_Utils_Request::retrieve('recordId', 'Positive', $this);
//.........这里部分代码省略.........
示例3: getProfileContact
/**
* Function to get the list of contacts for a profile
*
* @param $form object
*
* @access public
*/
function getProfileContact($gid)
{
$session =& CRM_Core_Session::singleton();
$params = $session->get('profileParams');
$details = array();
$ufGroupParam = array('id' => $gid);
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::retrieve($ufGroupParam, $details);
// make sure this group can be mapped
if (!$details['is_map']) {
CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.'));
}
$groupId = CRM_Utils_Array::value('limit_listings_group_id', $details);
// add group id to params if a uf group belong to a any group
if ($groupId) {
if (CRM_Utils_Array::value('group', $params)) {
$params['group'][$groupId] = 1;
} else {
$params['group'] = array($groupId => 1);
}
}
$fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $gid);
$returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($fields);
$returnProperties['contact_type'] = 1;
$returnProperties['sort_name'] = 1;
$queryParams =& CRM_Contact_BAO_Query::convertFormValues($params, 1);
$query =& new CRM_Contact_BAO_Query($queryParams, $returnProperties, $fields);
$ids = $query->searchQuery(0, 0, null, false, false, false, true, false);
$contactIds = explode(',', $ids);
return $contactIds;
}
示例4: preProcess
/**
* pre processing work done here.
*
* gets session variables for table name, id of entity in table, type of entity and stores them.
*
* @param
* @return void
*
* @access public
*/
function preProcess()
{
require_once 'CRM/Core/BAO/UFGroup.php';
require_once "CRM/Core/BAO/UFField.php";
$this->_id = $this->get('id');
$this->_gid = $this->get('gid');
$this->_grid = CRM_Utils_Request::retrieve('grid', 'Integer', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, false, 0, 'GET');
}
// if we dont have a gid use the default, else just use that specific gid
if (($this->_mode == self::MODE_REGISTER || $this->_mode == self::MODE_CREATE) && !$this->_gid) {
$this->_ctype = CRM_Utils_Request::retrieve('ctype', 'String', $this, false, 'Individual', 'REQUEST');
$this->_fields = CRM_Core_BAO_UFGroup::getRegistrationFields($this->_action, $this->_mode, $this->_ctype);
} else {
if ($this->_mode == self::MODE_SEARCH) {
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields($this->_action, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $this->_gid, true, null, $this->_skipPermission, CRM_Core_Permission::SEARCH);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid, false, null, null, null, false, null, $this->_skipPermission, null, CRM_Core_Permission::EDIT);
///is profile double-opt process configurablem, key
///should be present in civicrm.settting.php file
$config =& CRM_Core_Config::singleton();
if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $this->_fields)) {
$emailField = false;
foreach ($this->_fields as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$emailField = true;
}
}
if (!$emailField) {
$session =& CRM_Core_Session::singleton();
$status = ts("Email field should be included in profile if you want to use Group(s) when Profile double-opt in process is enabled.");
$session->setStatus($status);
}
}
}
}
if (!is_array($this->_fields)) {
$session =& CRM_Core_Session::singleton();
CRM_Core_Session::setStatus(ts('This feature is not currently available.'));
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm', 'reset=1'));
}
if ($this->_mode != self::MODE_SEARCH) {
CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $defaults);
$this->setDefaults($defaults);
}
$this->setDefaultsValues();
}
示例5: __construct
/**
* Class constructor
*
* @param string params the params for the where clause
*
* @return CRM_Contact_Selector_Profile
* @access public
*/
function __construct(&$params, &$customFields, $ufGroupIds = NULL, $map = FALSE, $editLink = FALSE, $linkToUF = FALSE)
{
$this->_params = $params;
if (is_array($ufGroupIds)) {
$this->_profileIds = $ufGroupIds;
$this->_gid = $ufGroupIds[0];
} else {
$this->_profileIds = array($ufGroupIds);
$this->_gid = $ufGroupIds;
}
$this->_map = $map;
$this->_editLink = $editLink;
$this->_linkToUF = $linkToUF;
//get the details of the uf group
if ($this->_gid) {
$groupId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_UFGroup', $this->_gid, 'limit_listings_group_id');
}
// add group id to params if a uf group belong to a any group
if ($groupId) {
if (!empty($this->_params['group'])) {
$this->_params['group'][$groupId] = 1;
} else {
$this->_params['group'] = array($groupId => 1);
}
}
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, FALSE, $this->_profileIds);
$this->_customFields =& $customFields;
$returnProperties = CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
$returnProperties['contact_type'] = 1;
$returnProperties['contact_sub_type'] = 1;
$returnProperties['sort_name'] = 1;
$queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_params, 1);
$this->_query = new CRM_Contact_BAO_Query($queryParams, $returnProperties, $this->_fields);
//the below is done for query building for multirecord custom field listing
//to show all the custom field multi valued records of a particular contact
$this->setMultiRecordTableName($this->_fields);
$this->_options =& $this->_query->_options;
}
示例6: __construct
/**
* Class constructor
*
* @param string params the params for the where clause
*
* @return CRM_Contact_Selector_Profile
* @access public
*/
function __construct(&$params, &$customFields, $ufGroupId = null, $map = false, $editLink = false, $linkToUF = false)
{
$this->_params = $params;
$this->_gid = $ufGroupId;
$this->_map = $map;
$this->_editLink = $editLink;
$this->_linkToUF = $linkToUF;
//get the details of the uf group
if ($ufGroupId) {
$groupId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_UFGroup', $ufGroupId, 'limit_listings_group_id');
}
// add group id to params if a uf group belong to a any group
if ($groupId) {
if (CRM_Utils_Array::value('group', $this->_params)) {
$this->_params['group'][$groupId] = 1;
} else {
$this->_params['group'] = array($groupId => 1);
}
}
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $this->_gid);
$this->_customFields =& $customFields;
$returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
$returnProperties['contact_type'] = 1;
$returnProperties['contact_sub_type'] = 1;
$returnProperties['sort_name'] = 1;
$queryParams =& CRM_Contact_BAO_Query::convertFormValues($this->_params, 1);
$this->_query =& new CRM_Contact_BAO_Query($queryParams, $returnProperties, $this->_fields);
$this->_options =& $this->_query->_options;
}
示例7: __construct
/**
* Class constructor
*
* @param array $formValues array of form values imported
* @param array $params array of parameters for query
* @param int $action - action of search basic or advanced.
*
* @return CRM_Contact_Selector
* @access public
*/
function __construct($customSearchClass, $formValues = null, $params = null, $returnProperties = null, $action = CRM_Core_Action::NONE, $includeContactIds = false, $searchDescendentGroups = true, $searchContext = 'search', $contextMenu = null)
{
//don't build query constructor, if form is not submitted
$force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject);
if (empty($formValues) && !$force) {
return;
}
// submitted form values
$this->_formValues =& $formValues;
$this->_params =& $params;
$this->_returnProperties =& $returnProperties;
$this->_contextMenu =& $contextMenu;
// type of selector
$this->_action = $action;
$this->_searchContext = $searchContext;
$this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $this->_formValues);
if ($this->_ufGroupID) {
require_once 'CRM/Core/BAO/UFGroup.php';
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $this->_ufGroupID);
self::$_columnHeaders = null;
//CRM_Core_Error::debug( 'f', $this->_fields );
$this->_customFields =& CRM_Core_BAO_CustomField::getFieldsForImport('Individual');
$this->_returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
$this->_returnProperties['contact_type'] = 1;
$this->_returnProperties['contact_sub_type'] = 1;
$this->_returnProperties['sort_name'] = 1;
//$this->_returnProperties['groups' ] = 1;
}
$this->_query =& new CRM_Contact_BAO_Query($this->_params, $this->_returnProperties, null, $includeContactIds, false, 1, false, $searchDescendentGroups);
$this->_options =& $this->_query->_options;
}
示例8: preProcess
/**
* extracts the parameters from the request and constructs information for
* the selector object to do a query
*
* @return void
* @access public
*
*/
function preProcess()
{
$this->_search = true;
$this->_gid = CRM_Utils_Request::retrieve('gid', $this, false, 0, 'GET');
$search = CRM_Utils_Request::retrieve('search', $this, false, 0, 'GET');
if (isset($search) && $search == 0) {
$this->_search = false;
}
require_once 'CRM/Core/BAO/UFGroup.php';
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_CORE_ACTION_UPDATE, CRM_CORE_BAO_UFGROUP_LISTINGS_VISIBILITY, false, $this->_gid);
$this->_customFields = CRM_Core_BAO_CustomField::getFieldsForImport('Individual');
$this->_params = array();
foreach ($this->_fields as $name => $field) {
$value = CRM_Utils_Request::retrieve($name, $this, false, null, 'REQUEST');
if (($name == 'group' || $name == 'tag') && !empty($value) && !is_array($value)) {
$v = explode(',', $value);
$value = array();
foreach ($v as $item) {
$value[$item] = 1;
}
}
$customField = CRM_Utils_Array::value($name, $this->_customFields);
if (!empty($_POST) && !CRM_Utils_Array::value($name, $_POST)) {
if ($customField) {
// reset checkbox because a form does not send null checkbox values
if ($customField['html_type'] == 'CheckBox') {
// only reset on a POST submission if we dont see any value
$value = null;
$this->set($name, $value);
} else {
if (($customField['html_type'] == 'Select' || $customField['html_type'] == 'Radio') && 0 == (int) $value) {
$value = null;
$this->set($name, $value);
}
}
} else {
if ($name == 'group' || $name == 'tag') {
$value = null;
$this->set($name, $value);
}
}
}
if (isset($value) && $value != null) {
$this->_fields[$name]['value'] = $value;
$this->_params[$name] = $value;
}
}
}
示例9: CRM_Profile_Selector_Listings
/**
* Class constructor
*
* @param string params the params for the where clause
*
* @return CRM_Contact_Selector_Profile
* @access public
*/
function CRM_Profile_Selector_Listings(&$params, &$customFields, $ufGroupId = null)
{
$this->_params = $params;
$this->_gid = $ufGroupId;
//get the details of the uf group
$ufGroupParam = array('id' => $ufGroupId);
CRM_Core_BAO_UFGroup::retrieve($ufGroupParam, $details);
$groupId = CRM_Utils_Array::value('limit_listings_group_id', $details);
// add group id to params if a uf group belong to a any group
if ($groupId) {
if (CRM_Utils_Array::value('group', $this->_params)) {
$this->_params['group'][$groupId] = 1;
} else {
$this->_params['group'] = array($groupId => 1);
}
}
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_CORE_ACTION_VIEW, CRM_CORE_BAO_UFGROUP_PUBLIC_VISIBILITY | CRM_CORE_BAO_UFGROUP_LISTINGS_VISIBILITY, false, $this->_gid);
// CRM_Core_Error::debug( 'p', $this->_params );
// CRM_Core_Error::debug( 'f', $this->_fields );
$this->_customFields =& $customFields;
$returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
$returnProperties['contact_type'] = 1;
$returnProperties['sort_name'] = 1;
$this->_query =& new CRM_Contact_BAO_Query($this->_params, $returnProperties, $this->_fields);
$this->_options =& $this->_query->_options;
//CRM_Core_Error::debug( 'q', $this->_query );
}
示例10: __construct
/**
* Class constructor
*
* @param array $formValues array of form values imported
* @param array $params array of parameters for query
* @param int $action - action of search basic or advanced.
*
* @return CRM_Contact_Selector
* @access public
*/
function __construct($customSearchClass, $formValues = null, $params = null, $returnProperties = null, $action = CRM_Core_Action::NONE, $includeContactIds = false, $searchDescendentGroups = true, $searchContext = 'search', $contextMenu = null)
{
//don't build query constructor, if form is not submitted
$force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject);
if (empty($formValues) && !$force) {
return;
}
// submitted form values
$this->_formValues =& $formValues;
$this->_params =& $params;
$this->_returnProperties =& $returnProperties;
$this->_contextMenu =& $contextMenu;
$this->_context = $searchContext;
// type of selector
$this->_action = $action;
$this->_searchContext = $searchContext;
$this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $this->_formValues);
if ($this->_ufGroupID) {
require_once 'CRM/Core/BAO/UFGroup.php';
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $this->_ufGroupID);
self::$_columnHeaders = null;
//CRM_Core_Error::debug( 'f', $this->_fields );
$this->_customFields =& CRM_Core_BAO_CustomField::getFieldsForImport('Individual');
$this->_returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($this->_fields);
$this->_returnProperties['contact_type'] = 1;
$this->_returnProperties['contact_sub_type'] = 1;
$this->_returnProperties['sort_name'] = 1;
}
// rectify params to what proximity search expects if there is a value for prox_distance
// CRM-7021
if (!empty($this->_params)) {
foreach ($this->_params as $param) {
if ($param[0] == 'prox_distance') {
// add prox_ prefix to these
$param_alter = array('street_address', 'city', 'postal_code', 'state_province', 'country');
foreach ($this->_params as $key => $_param) {
if (in_array($_param[0], $param_alter)) {
$this->_params[$key][0] = 'prox_' . $_param[0];
// _id suffix where needed
if ($_param[0] == 'country' || $_param[0] == 'state_province') {
$this->_params[$key][0] .= '_id';
// flatten state_province array
if (is_array($this->_params[$key][2])) {
$this->_params[$key][2] = $this->_params[$key][2][0];
}
}
}
}
break;
}
}
}
$this->_query = new CRM_Contact_BAO_Query($this->_params, $this->_returnProperties, null, $includeContactIds, false, CRM_Contact_BAO_Query::MODE_CONTACTS, false, $searchDescendentGroups);
$this->_options =& $this->_query->_options;
}
示例11: preProcess
/**
* pre processing work done here.
*
* gets session variables for table name, id of entity in table, type of entity and stores them.
*
* @param
* @return void
*
* @access public
*/
function preProcess()
{
require_once 'CRM/Core/BAO/UFGroup.php';
$this->_id = $this->get('id');
$this->_gid = $this->get('gid');
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', $this, false, 0, 'GET');
}
// if we dont have a gid use the default, else just use that specific gid
if (($this->_mode == CRM_PROFILE_FORM_MODE_REGISTER || $this->_mode == CRM_PROFILE_FORM_MODE_CREATE) && !$this->_gid) {
$this->_fields = CRM_Core_BAO_UFGroup::getRegistrationFields($this->_action, $this->_mode);
} else {
if ($this->_mode == CRM_PROFILE_FORM_MODE_SEARCH) {
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields($this->_action, CRM_CORE_BAO_UFGROUP_LISTINGS_VISIBILITY, false, $this->_gid, true);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid, false, $this->_action);
}
}
if (!is_array($this->_fields)) {
$session =& CRM_Core_Session::singleton();
CRM_Core_Session::setStatus(ts('This feature is not currently available.'));
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm', 'reset=1'));
}
if ($this->_id) {
$defaults = array();
// get the contact details (hier)
list($contactDetails, $options) = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $this->_fields);
$this->_contact = $details = $contactDetails[$this->_id];
//start of code to set the default values
foreach ($this->_fields as $name => $field) {
if (CRM_Utils_Array::value($name, $details)) {
//to handle custom data (checkbox) to be written
// to handle gender / suffix / prefix
if ($name == 'gender') {
$defaults[$name] = $details['gender_id'];
} else {
if ($name == 'individual_prefix') {
$defaults[$name] = $details['individual_prefix_id'];
} else {
if ($name == 'individual_suffix') {
$defaults[$name] = $details['individual_suffix_id'];
} else {
if (substr($name, 0, 6) == 'custom') {
/*
$cfID = CRM_Core_BAO_CustomField::getKeyID($name);
$cf =& new CRM_Core_BAO_CustomField();
$cf->id = $cfID;
if ( $cf->find( true ) ) {
switch($cf->html_type) {
case 'Select Date':
$defaults[$name] = CRM_Utils_Date::unformat( $details[$name], '-');
break;
case 'CheckBox':
$data = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $details[$name]);
if (is_array($data)) {
foreach($data as $key) {
$checked[$key] = 1;
}
$defaults[$name] = $checked;
}
break;
default:
$defaults[$name] = $details[$name];
}
} */
} else {
$defaults[$name] = $details[$name];
}
}
}
}
} else {
$nameValue = explode('-', $name);
foreach ($details as $key => $value) {
if (is_numeric($nameValue[1])) {
//fixed for CRM-665
if ($nameValue[1] == $value['location_type_id']) {
if (CRM_Utils_Array::value($nameValue[0], $value)) {
//to handle stateprovince and country
if ($nameValue[0] == 'state_province') {
$defaults[$name] = $value['state_province_id'];
} else {
if ($nameValue[0] == 'country') {
$defaults[$name] = $value['country_id'];
} else {
if ($nameValue[0] == 'phone') {
if ($nameValue[2]) {
$defaults[$name] = $value['phone'][$nameValue[2]];
} else {
$defaults[$name] = $value['phone'][1];
//.........这里部分代码省略.........
示例12: preProcess
/**
* pre processing work done here.
*
* gets session variables for table name, id of entity in table, type of entity and stores them.
*
* @param
*
* @return void
*
* @access public
*/
function preProcess()
{
$this->_id = $this->get('id');
$this->_gid = $this->get('gid');
$this->_profileIds = $this->get('profileIds');
$this->_grid = CRM_Utils_Request::retrieve('grid', 'Integer', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
$gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
if (count($gids) > 1 && !$this->_profileIds && empty($this->_profileIds)) {
if (!empty($gids)) {
foreach ($gids as $pfId) {
$this->_profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive');
}
}
// check if we are rendering mixed profiles
if (CRM_Core_BAO_UFGroup::checkForMixProfiles($this->_profileIds)) {
CRM_Core_Error::fatal(ts('You cannot combine profiles of multiple types.'));
}
// for now consider 1'st profile as primary profile and validate it
// i.e check for profile type etc.
// FIX ME: validations for other than primary
$this->_gid = $this->_profileIds[0];
$this->set('gid', $this->_gid);
$this->set('profileIds', $this->_profileIds);
}
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0, 'GET');
}
$this->_activityId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, 0, 'GET');
if (is_numeric($this->_activityId)) {
$latestRevisionId = CRM_Activity_BAO_Activity::getLatestActivityId($this->_activityId);
if ($latestRevisionId) {
$this->_activityId = $latestRevisionId;
}
}
$this->_isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($this->_gid);
//get values for captch and dupe update.
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
if ($dao->find(TRUE)) {
$this->_isUpdateDupe = $dao->is_update_dupe;
$this->_isAddCaptcha = $dao->add_captcha;
}
$dao->free();
}
if (empty($this->_profileIds)) {
$gids = $this->_gid;
} else {
$gids = $this->_profileIds;
}
// if we dont have a gid use the default, else just use that specific gid
if (($this->_mode == self::MODE_REGISTER || $this->_mode == self::MODE_CREATE) && !$this->_gid) {
$this->_ctype = CRM_Utils_Request::retrieve('ctype', 'String', $this, FALSE, 'Individual', 'REQUEST');
$this->_fields = CRM_Core_BAO_UFGroup::getRegistrationFields($this->_action, $this->_mode, $this->_ctype);
} elseif ($this->_mode == self::MODE_SEARCH) {
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields($this->_action, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, FALSE, $gids, TRUE, NULL, $this->_skipPermission, CRM_Core_Permission::SEARCH);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($gids, FALSE, NULL, NULL, NULL, FALSE, NULL, $this->_skipPermission, NULL, $this->_action == CRM_Core_Action::ADD ? CRM_Core_Permission::CREATE : CRM_Core_Permission::EDIT);
// is profile double-opt in?
if (CRM_Utils_Array::value('group', $this->_fields) && CRM_Core_BAO_UFGroup::isProfileDoubleOptin()) {
$emailField = FALSE;
foreach ($this->_fields as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$emailField = TRUE;
}
}
if (!$emailField) {
$session = CRM_Core_Session::singleton();
$status = ts("Email field should be included in profile if you want to use Group(s) when Profile double-opt in process is enabled.");
$session->setStatus($status);
}
}
}
if (!is_array($this->_fields)) {
$session = CRM_Core_Session::singleton();
CRM_Core_Session::setStatus(ts('This feature is not currently available.'));
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm', 'reset=1'));
}
if ($this->_mode != self::MODE_SEARCH) {
CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $defaults);
$this->setDefaults($defaults);
}
}