本文整理汇总了PHP中CRM_Core_BAO_UFGroup::checkForMixProfiles方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::checkForMixProfiles方法的具体用法?PHP CRM_Core_BAO_UFGroup::checkForMixProfiles怎么用?PHP CRM_Core_BAO_UFGroup::checkForMixProfiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::checkForMixProfiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
*/
public function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
if (!$this->_id) {
$session = CRM_Core_Session::singleton();
$this->_id = $session->get('userID');
if (!$this->_id) {
CRM_Core_Error::fatal(ts('Could not find the required contact id parameter (id=) for viewing a contact record with a Profile.'));
}
}
$this->assign('cid', $this->_id);
$gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
$profileIds = array();
if (count($gids) > 1) {
if (!empty($gids)) {
foreach ($gids as $pfId) {
$profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive');
}
}
// check if we are rendering mixed profiles
if (CRM_Core_BAO_UFGroup::checkForMixProfiles($profileIds)) {
CRM_Core_Error::fatal(ts('You cannot combine profiles of multiple types.'));
}
$this->_gid = $profileIds[0];
}
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0, 'GET');
}
$anyContent = TRUE;
if ($this->_gid) {
$page = new CRM_Profile_Page_Dynamic($this->_id, $this->_gid, 'Profile', FALSE, $profileIds);
$profileGroup = array();
$profileGroup['title'] = NULL;
$profileGroup['content'] = $page->run();
if (empty($profileGroup['content'])) {
$anyContent = FALSE;
}
$profileGroups[] = $profileGroup;
$gidString = $this->_gid;
if (!empty($profileIds)) {
$gidString = implode(',', $profileIds);
}
$map = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_map');
if ($map) {
$this->assign('mapURL', CRM_Utils_System::url("civicrm/profile/map", "reset=1&pv=1&cid={$this->_id}&gid={$gidString}"));
}
if (CRM_Core_Permission::ufGroupValid($this->_gid, CRM_Core_Permission::SEARCH)) {
$this->assign('listingURL', CRM_Utils_System::url("civicrm/profile", "force=1&gid={$gidString}"));
}
} else {
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Profile');
$profileGroups = array();
foreach ($ufGroups as $groupid => $group) {
$page = new CRM_Profile_Page_Dynamic($this->_id, $groupid, 'Profile', FALSE, $profileIds);
$profileGroup = array();
$profileGroup['title'] = $group['title'];
$profileGroup['content'] = $page->run();
if (empty($profileGroup['content'])) {
$anyContent = FALSE;
}
$profileGroups[] = $profileGroup;
}
$this->assign('listingURL', CRM_Utils_System::url("civicrm/profile", "force=1"));
}
$this->assign('groupID', $this->_gid);
$this->assign('profileGroups', $profileGroups);
$this->assign('recentlyViewed', FALSE);
// do not set title if there is no content
// CRM-6081
if (!$anyContent) {
CRM_Utils_System::setTitle('');
}
}
示例3: 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;
$search = CRM_Utils_Request::retrieve('search', 'Boolean', $this, false, 0, 'GET');
if (isset($search) && $search == 0) {
$this->_search = false;
}
$this->_gid = $this->get('gid');
$this->_profileIds = $this->get('profileIds');
$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
require_once 'CRM/Core/BAO/UFGroup.php';
if (CRM_Core_BAO_UFGroup::checkForMixProfiles($this->_profileIds)) {
CRM_Core_Error::fatal(ts('You cannot combine profiles of multiple types.'));
}
$this->_gid = $this->_profileIds[0];
$this->set('profileIds', $this->_profileIds);
$this->set('gid', $this->_gid);
}
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, false, 0, 'GET');
}
require_once 'CRM/Core/BAO/UFGroup.php';
if (empty($this->_profileIds)) {
$gids = $this->_gid;
} else {
$gids = $this->_profileIds;
}
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::UPDATE, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $gids, false, 'Profile', CRM_Core_Permission::SEARCH);
$this->_customFields = CRM_Core_BAO_CustomField::getFieldsForImport(null);
$this->_params = array();
$resetArray = array('group', 'tag', 'preferred_communication_method', 'do_not_phone', 'do_not_email', 'do_not_mail', 'do_not_sms', 'do_not_trade', 'gender');
foreach ($this->_fields as $name => $field) {
if (substr($name, 0, 6) == 'custom' && CRM_Utils_Array::value('is_search_range', $field)) {
$from = CRM_Utils_Request::retrieve($name . '_from', 'String', $this, false, null, 'REQUEST');
$to = CRM_Utils_Request::retrieve($name . '_to', 'String', $this, false, null, 'REQUEST');
$value = array();
if ($from && $to) {
$value['from'] = $from;
$value['to'] = $to;
} else {
if ($from) {
$value['from'] = $from;
} else {
if ($to) {
$value['to'] = $to;
}
}
}
} else {
if (substr($name, 0, 7) == 'custom_' && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', substr($name, 7), 'html_type') == 'TextArea') {
$value = trim(CRM_Utils_Request::retrieve($name, 'String', $this, false, null, 'REQUEST'));
if (!empty($value) && !(substr($value, 0, 1) == '%' && substr($value, -1, 1) == '%')) {
$value = '%' . $value . '%';
}
} else {
if (CRM_Utils_Array::value('html_type', $field) == 'Multi-Select State/Province' || CRM_Utils_Array::value('html_type', $field) == 'Multi-Select Country') {
$value = CRM_Utils_Request::retrieve($name, 'String', $this, false, null, 'REQUEST');
if (!is_array($value)) {
$value = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($value, 1, -1));
}
} else {
$value = CRM_Utils_Request::retrieve($name, 'String', $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/radio because a form does not send null checkbox values
if (in_array($customField['html_type'], array('Multi-Select', 'CheckBox', 'Multi-Select State/Province', 'Multi-Select Country', 'Radio'))) {
// only reset on a POST submission if we dont see any value
$value = null;
$this->set($name, $value);
}
} else {
if (in_array($name, $resetArray)) {
$value = null;
$this->set($name, $value);
//.........这里部分代码省略.........
示例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()
{
$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);
}
}