本文整理汇总了PHP中CRM_Core_BAO_UFGroup::getModuleUFGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::getModuleUFGroup方法的具体用法?PHP CRM_Core_BAO_UFGroup::getModuleUFGroup怎么用?PHP CRM_Core_BAO_UFGroup::getModuleUFGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::getModuleUFGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
* @access public
*
*/
function preProcess()
{
$id = CRM_Utils_Request::retrieve('cid', $this, true);
$gid = CRM_Utils_Request::retrieve('gid', $this);
if ($gid) {
require_once 'CRM/Profile/Page/Dynamic.php';
$page =& new CRM_Profile_Page_Dynamic($id, $gid);
$profileGroup = array();
$profileGroup['title'] = $title;
$profileGroup['content'] = $page->run();
$profileGroups[] = $profileGroup;
} else {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Profile');
$profileGroups = array();
foreach ($ufGroups as $groupid => $group) {
require_once 'CRM/Profile/Page/Dynamic.php';
$page =& new CRM_Profile_Page_Dynamic($id, $groupid);
$profileGroup = array();
$profileGroup['title'] = $group['title'];
$profileGroup['content'] = $page->run();
$profileGroups[] = $profileGroup;
}
}
$this->assign('profileGroups', $profileGroups);
$this->assign('recentlyViewed', false);
CRM_Utils_System::setTitle(ts('Contact\'s Profile'));
}
示例2: preProcess
function preProcess()
{
// pick the first profile ID that has user register checked
require_once 'CRM/Core/BAO/UFGroup.php';
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
if (count($ufGroups) > 1) {
CRM_Core_Error::fatal(ts('You have more than one profile that has been enabled for user registration.'));
}
foreach ($ufGroups as $id => $dontCare) {
$this->_profileID = $id;
}
require_once 'CRM/Core/Session.php';
$session =& CRM_Core_Session::singleton();
$this->_openID = $session->get('openid');
}
示例3: getRegistrationFields
/**
* Get all the registration fields.
*
* @param int $action
* What action are we doing.
* @param int $mode
* Mode.
*
* @param null $ctype
*
* @return array
* the fields that are needed for registration
*/
public static function getRegistrationFields($action, $mode, $ctype = NULL)
{
if ($mode & CRM_Profile_Form::MODE_REGISTER) {
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
} else {
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Profile');
}
if (!is_array($ufGroups)) {
return FALSE;
}
$fields = array();
foreach ($ufGroups as $id => $title) {
if ($ctype) {
$fieldType = CRM_Core_BAO_UFField::getProfileType($id);
if ($fieldType != 'Contact' && $fieldType != $ctype && !CRM_Contact_BAO_ContactType::isExtendsContactType($fieldType, $ctype)) {
continue;
}
if (CRM_Contact_BAO_ContactType::isaSubType($fieldType)) {
$profileSubType = $fieldType;
}
}
$subset = self::getFields($id, TRUE, $action, NULL, NULL, FALSE, NULL, TRUE, $ctype);
// we do not allow duplicates. the first field is the winner
foreach ($subset as $name => $field) {
if (empty($fields[$name])) {
$fields[$name] = $field;
}
}
}
return $fields;
}
示例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: getRegistrationFields
/**
* get all the registration fields
*
* @param int $action what action are we doing
* @param int $mode mode
*
* @return array the fields that are needed for registration
* @static
* @access public
*/
static function getRegistrationFields($action, $mode, $ctype = null)
{
if ($mode & CRM_Profile_Form::MODE_REGISTER) {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
} else {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Profile');
}
if (!is_array($ufGroups)) {
return false;
}
$fields = array();
require_once "CRM/Core/BAO/UFField.php";
foreach ($ufGroups as $id => $title) {
if ($ctype) {
$fieldType = CRM_Core_BAO_UFField::getProfileType($id);
if ($fieldType != 'Contact' && $fieldType != $ctype && !CRM_Contact_BAO_ContactType::isExtendsContactType($fieldType, $ctype)) {
continue;
}
if (CRM_Contact_BAO_ContactType::isaSubType($fieldType)) {
$profileSubType = $fieldType;
}
}
$subset = self::getFields($id, true, $action, null, null, false, null, true, $ctype);
// we do not allow duplicates. the first field is the winner
foreach ($subset as $name => $field) {
if (!CRM_Utils_Array::value($name, $fields)) {
$fields[$name] = $field;
}
}
}
return $fields;
}
示例6: getRegistrationFields
/**
* get all the registration fields
*
* @param int $action what action are we doing
* @param int $mode mode
*
* @return array the fields that are needed for registration
* @static
* @access public
*/
function getRegistrationFields($action, $mode)
{
if ($mode & CRM_PROFILE_FORM_MODE_REGISTER) {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
} else {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Profile');
}
if (!is_array($ufGroups)) {
return false;
}
$fields = array();
require_once "CRM/Core/BAO/UFField.php";
foreach ($ufGroups as $id => $title) {
if (CRM_Core_BAO_UFField::checkProfileType($id)) {
// to skip mix profiles
continue;
}
$subset = CRM_Core_BAO_UFGroup::getFields($id, true, $action);
// we do not allow duplicates. the first field is the winner
foreach ($subset as $name => $field) {
if (!CRM_Utils_Array::value($name, $fields)) {
$fields[$name] = $field;
}
}
}
return $fields;
}
示例7: basic
/**
* @param CRM_Core_Form $form
*/
public static function basic(&$form)
{
$form->addElement('hidden', 'hidden_basic', 1);
if ($form->_searchOptions['contactType']) {
// add checkboxes for contact type
//@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
// this is loaded onto then replace with something like '__' & test
$separator = CRM_Core_DAO::VALUE_SEPARATOR;
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
if ($contactTypes) {
$form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
}
}
if ($form->_searchOptions['groups']) {
// multiselect for groups
if ($form->_group) {
// Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
$groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, ' ', TRUE);
$form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type');
$form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$form->add('hidden', 'group_search_selected', 'group');
}
}
if ($form->_searchOptions['tags']) {
// multiselect for categories
$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE);
$used_for = CRM_Core_OptionGroup::values('tag_used_for');
$tagsTypes = array();
$showAllTagTypes = FALSE;
foreach ($used_for as $key => $value) {
//check tags for every type and find if there are any defined
$tags = CRM_Core_BAO_Tag::getTagsUsedFor($key, FALSE, TRUE, NULL);
// check if there are tags other than contact type, if no - keep checkbox hidden on adv search
// we will hide searching contact by attachments tags until it will be implemented in core
if (count($tags) && $key != 'civicrm_file' && $key != 'civicrm_contact') {
//if tags exists then add type to display in adv search form help text
$tagsTypes[] = ts($value);
$showAllTagTypes = TRUE;
}
}
$tagTypesText = implode(" or ", $tagsTypes);
if ($showAllTagTypes) {
$form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText)));
$form->add('hidden', 'tag_types_text', $tagTypesText);
}
}
// add text box for last name, first name, street name, city
$form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// add text box for last name, first name, street name, city
$form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
//added contact source
$form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source'));
//added job title
$form->addElement('text', 'job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title'));
//added internal ID
$form->addElement('text', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id'));
$form->addRule('contact_id', ts('Please enter valid Contact ID'), 'positiveInteger');
//added external ID
$form->addElement('text', 'external_identifier', ts('External ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'external_identifier'));
if (CRM_Core_Permission::check('access deleted contacts') and CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL)) {
$form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
}
// add checkbox for cms users only
$form->addYesNo('uf_user', ts('CMS User?'), TRUE);
// tag all search
$form->add('text', 'tag_search', ts('All Tags'));
// add search profiles
// FIXME: This is probably a part of profiles - need to be
// FIXME: eradicated from here when profiles are reworked.
$types = array('Participant', 'Contribution', 'Membership');
// get component profiles
$componentProfiles = array();
$componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
$accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
$searchProfiles = array();
foreach ($ufGroups as $key => $var) {
if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
$searchProfiles[$key] = $var['title'];
}
}
$form->add('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles, FALSE, array('class' => 'crm-select2'));
$componentModes = CRM_Contact_Form_Search::getModeSelect();
// unset contributions or participants if user does not have
// permission on them
if (!CRM_Core_Permission::access('CiviContribute')) {
unset($componentModes['2']);
}
if (!CRM_Core_Permission::access('CiviEvent')) {
unset($componentModes['3']);
}
//.........这里部分代码省略.........
示例8: basic
static function basic(&$form)
{
$form->addElement('hidden', 'hidden_basic', 1);
if ($form->_searchOptions['contactType']) {
// add checkboxes for contact type
$contact_type = array();
require_once 'CRM/Contact/BAO/ContactType.php';
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
foreach ($contactTypes as $k => $v) {
if (!empty($k)) {
$contact_type[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
}
}
$form->addGroup($contact_type, 'contact_type', ts('Contact Type(s)'), '<br />');
}
if ($form->_searchOptions['groups']) {
// checkboxes for groups
foreach ($form->_group as $groupID => $group) {
$form->_groupElement =& $form->addElement('checkbox', "group[{$groupID}]", null, $group);
}
}
if ($form->_searchOptions['tags']) {
// checkboxes for categories
require_once 'CRM/Core/BAO/Tag.php';
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree();
$form->assign('tree', $tags->getTree());
foreach ($form->_tag as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "tag[{$tagID}]", null, $tagName);
}
}
// add text box for last name, first name, street name, city
$form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// add text box for last name, first name, street name, city
$form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
//added contact source
$form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
// add checkbox for cms users only
if (CIVICRM_UF != 'Standalone') {
$form->addYesNo('uf_user', ts('CMS User?'));
}
// add search profiles
require_once 'CRM/Core/BAO/UFGroup.php';
// FIXME: This is probably a part of profiles - need to be
// FIXME: eradicated from here when profiles are reworked.
$types = array('Participant', 'Contribution', 'Membership');
// get component profiles
$componentProfiles = array();
$componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
$accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
$searchProfiles = array();
foreach ($ufGroups as $key => $var) {
if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
$searchProfiles[$key] = $var['title'];
}
}
$form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).');
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']);
$form->addGroup($privacy, 'privacy', ts('Privacy'), array(' ', ' ', ' ', '<br/>'));
// preferred communication method
require_once 'CRM/Core/PseudoConstant.php';
$comm = CRM_Core_PseudoConstant::pcm();
$commPreff = array();
foreach ($comm as $k => $v) {
$commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
}
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
}
示例9: postProcess
//.........这里部分代码省略.........
}
if ($this->_mode == self::MODE_REGISTER) {
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::setOverwrite(false);
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//used to send subcribe mail to the group which user want.
//if the profile double option in is enabled
$mailingType = array();
$config = CRM_Core_Config::singleton();
if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $params)) {
$result = null;
foreach ($params as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$result['email'] = $values;
}
}
$groupSubscribed = array();
if (CRM_Utils_Array::value('email', $result)) {
require_once 'CRM/Contact/DAO/Group.php';
//array of group id, subscribed by contact
$contactGroup = array();
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
foreach ($params['group'] as $key => $val) {
if (!$val) {
unset($params['group'][$key]);
continue;
}
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
$groupType = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType)) {
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($key, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $key;
unset($params['group'][$key]);
}
}
}
}
}
if (CRM_Utils_Array::value('add_to_group', $params)) {
$addToGroupId = $params['add_to_group'];
// since we are directly adding contact to group lets unset it from mailing
if ($key = array_search($addToGroupId, $mailingType)) {
unset($mailingType[$key]);
}
}
if ($this->_grid) {
$params['group'] = $groupSubscribed;
}
// commenting below code, since we potentially
// triggered maximum name field formatting cases during CRM-4430.
// CRM-4343
// $params['preserveDBName'] = true;
$this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_id, $this->_addToGroupID, $this->_gid, $this->_ctype, true);
//mailing type group
if (!empty($mailingType)) {
require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result);
}
require_once 'CRM/Core/BAO/UFGroup.php';
$ufGroups = array();
if ($this->_gid) {
$ufGroups[$this->_gid] = 1;
} else {
if ($this->_mode == self::MODE_REGISTER) {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
}
}
foreach ($ufGroups as $gId => $val) {
if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, null);
CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
}
}
//create CMS user (if CMS user option is selected in profile)
if (CRM_Utils_Array::value('cms_create_account', $params) && $this->_mode == self::MODE_CREATE) {
$params['contactID'] = $this->_id;
require_once "CRM/Core/BAO/CMSUser.php";
if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'));
$transaction->rollback();
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
}
}
$transaction->commit();
}
示例10: 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('');
}
}
示例11: 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
* @access 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);
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
$anyContent = true;
if ($this->_gid) {
require_once 'CRM/Profile/Page/Dynamic.php';
$page =& new CRM_Profile_Page_Dynamic($this->_id, $this->_gid, 'Profile');
$profileGroup = array();
$profileGroup['title'] = null;
$profileGroup['content'] = $page->run();
if (empty($profileGroup['content'])) {
$anyContent = false;
}
$profileGroups[] = $profileGroup;
$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={$this->_gid}"));
}
if (CRM_Core_Permission::ufGroupValid($this->_gid, CRM_Core_Permission::SEARCH)) {
$this->assign('listingURL', CRM_Utils_System::url("civicrm/profile", "force=1&gid={$this->_gid}"));
}
} else {
require_once 'CRM/Core/BAO/UFGroup.php';
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Profile');
$profileGroups = array();
foreach ($ufGroups as $groupid => $group) {
require_once 'CRM/Profile/Page/Dynamic.php';
$page =& new CRM_Profile_Page_Dynamic($this->_id, $groupid, 'Profile');
$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) {
return;
}
$title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'title');
//CRM-4131.
$sortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'display_name');
if ($sortName) {
require_once 'CRM/Core/Permission.php';
require_once 'CRM/Contact/BAO/Contact/Permission.php';
$session = CRM_Core_Session::singleton();
$config = CRM_Core_Config::singleton();
if ($session->get('userID') && CRM_Core_Permission::check('access CiviCRM') && CRM_Contact_BAO_Contact_Permission::allow($session->get('userID'), CRM_Core_Permission::VIEW) && !$config->userFrameworkFrontend) {
$sortNameUrl = CRM_Utils_System::url('civicrm/contact/view', "action=view&reset=1&cid={$this->_id}", true);
$sortName = "<a href=\"{$sortNameUrl}\">{$sortName}</a>";
}
$title .= ' - ' . $sortName;
}
CRM_Utils_System::setTitle($title);
}
示例12: postProcess
/**
* Process the user submitted custom data values.
*
* @access public
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
if ($this->_mode == self::MODE_REGISTER) {
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::setOverwrite(false);
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//used to send subcribe mail to the group which user want.
//if the profile double option in is enabled
$mailingType = array();
$config =& CRM_Core_Config::singleton();
if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $params)) {
$result = null;
foreach ($params as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$result['email'] = $values;
}
}
$groupSubscribed = array();
if (CRM_Utils_Array::value('email', $result)) {
require_once 'CRM/Contact/DAO/Group.php';
//array of group id, subscribed by contact
$contactGroup = array();
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
foreach ($params['group'] as $key => $val) {
if (!$val) {
unset($params['group'][$key]);
continue;
}
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
$groupType = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType)) {
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($key, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $key;
unset($params['group'][$key]);
}
}
}
}
}
if ($this->_grid) {
$params['group'] = $groupSubscribed;
}
// commenting below code, since we potentially
// triggered maximum name field formatting cases during CRM-4430.
// CRM-4343
// $params['preserveDBName'] = true;
$this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_id, $this->_addToGroupID, $this->_gid, $this->_ctype, true);
//mailing type group
if (!empty($mailingType)) {
require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result);
}
require_once 'CRM/Core/BAO/UFGroup.php';
$ufGroups = array();
if ($this->_gid) {
$ufGroups[$this->_gid] = 1;
} else {
if ($this->_mode == self::MODE_REGISTER) {
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
}
}
foreach ($ufGroups as $gId => $val) {
if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, null);
CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
}
}
//create CMS user (if CMS user option is selected in profile)
if (CRM_Utils_Array::value('cms_create_account', $params) && $this->_mode == self::MODE_CREATE) {
$params['contactID'] = $this->_id;
require_once "CRM/Core/BAO/CMSUser.php";
if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'));
$transaction->rollback();
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
}
}
$transaction->commit();
//.........这里部分代码省略.........
示例13: basic
static function basic(&$form)
{
$form->addElement('hidden', 'hidden_basic', 1);
if ($form->_searchOptions['contactType']) {
// add checkboxes for contact type
$contact_type = array();
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
if ($contactTypes) {
$form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
}
if ($form->_searchOptions['groups']) {
// multiselect for groups
if ($form->_group) {
$form->add('select', 'group', ts('Groups'), $form->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
}
if ($form->_searchOptions['tags']) {
// multiselect for categories
$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE, TRUE);
}
// add text box for last name, first name, street name, city
$form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// add text box for last name, first name, street name, city
$form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
//added contact source
$form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
//added job title
$attributes['job_title']['size'] = 30;
$form->addElement('text', 'job_title', ts('Job Title'), $attributes['job_title'], 'size="30"');
//added internal ID
$attributes['id']['size'] = 30;
$form->addElement('text', 'id', ts('Contact ID'), $attributes['id'], 'size="30"');
//added external ID
$attributes['external_identifier']['size'] = 30;
$form->addElement('text', 'external_identifier', ts('External ID'), $attributes['external_identifier'], 'size="30"');
$config = CRM_Core_Config::singleton();
if (CRM_Core_Permission::check('access deleted contacts') and $config->contactUndelete) {
$form->add('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
}
// add checkbox for cms users only
$form->addYesNo('uf_user', ts('CMS User?'));
// tag all search
$form->add('text', 'tag_search', ts('All Tags'));
// add search profiles
// FIXME: This is probably a part of profiles - need to be
// FIXME: eradicated from here when profiles are reworked.
$types = array('Participant', 'Contribution', 'Membership');
// get component profiles
$componentProfiles = array();
$componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
$accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
$searchProfiles = array();
foreach ($ufGroups as $key => $var) {
if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
$searchProfiles[$key] = $var['title'];
}
}
$form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
$componentModes = CRM_Contact_Form_Search::getModeSelect();
// unset contributions or participants if user does not have
// permission on them
if (!CRM_Core_Permission::access('CiviContribute')) {
unset($componentModes['2']);
}
if (!CRM_Core_Permission::access('CiviEvent')) {
unset($componentModes['3']);
}
if (!CRM_Core_Permission::access('CiviMember')) {
unset($componentModes['5']);
}
if (!CRM_Core_Permission::check('view all activities')) {
unset($componentModes['4']);
}
if (count($componentModes) > 1) {
$form->addElement('select', 'component_mode', ts('Display Results As'), $componentModes);
}
$form->addElement('select', 'operator', ts('Search Operator'), array('AND' => ts('AND'), 'OR' => ts('OR')));
// add the option to display relationships
$rTypes = CRM_Core_PseudoConstant::relationshipType();
$rSelect = array('' => ts('- Select Relationship Type-'));
foreach ($rTypes as $rid => $rValue) {
if ($rValue['label_a_b'] == $rValue['label_b_a']) {
$rSelect[$rid] = $rValue['label_a_b'];
} else {
$rSelect["{$rid}_a_b"] = $rValue['label_a_b'];
$rSelect["{$rid}_b_a"] = $rValue['label_b_a'];
}
}
$form->addElement('select', 'display_relationship_type', ts('Display Results as Relationship'), $rSelect);
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$form->add('select', 'privacy_options', ts('Privacy'), $t, FALSE, array('id' => 'privacy_options', 'multiple' => 'multiple', 'title' => ts('- select -')));
//.........这里部分代码省略.........
示例14: 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);
}
示例15: postProcess
//.........这里部分代码省略.........
if (!empty($addToGroupId)) {
//run same check whether group is a mailing list
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $addToGroupId, 'group_type', 'id');
$groupType = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType) && !empty($result['email']) && CRM_Core_BAO_UFGroup::isProfileAddToGroupDoubleOptin()) {
if (!count($contactGroup)) {
//array of group id, subscribed by contact
$contactGroup = array();
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
}
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($addToGroupId, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $addToGroupId;
$addToGroupId = NULL;
}
} else {
// since we are directly adding contact to group lets unset it from mailing
if ($key = array_search($addToGroupId, $mailingType)) {
unset($mailingType[$key]);
}
}
}
if ($this->_grid) {
$params['group'] = $groupSubscribed;
}
// commenting below code, since we potentially
// triggered maximum name field formatting cases during CRM-4430.
// CRM-4343
// $params['preserveDBName'] = true;
$profileFields = $this->_fields;
if ($this->_mode & self::MODE_EDIT && $this->_activityId && $this->_isContactActivityProfile) {
$profileFields = $activityParams = array();
foreach ($this->_fields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
if (isset($params[$fieldName])) {
$activityParams[$fieldName] = $params[$fieldName];
}
if (isset($params['activity_date_time'])) {
$activityParams['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
}
if (!empty($params[$fieldName]) && isset($params["{$fieldName}_id"])) {
$activityParams[$fieldName] = $params["{$fieldName}_id"];
}
} else {
$profileFields[$fieldName] = $field;
}
}
if (!empty($activityParams)) {
$activityParams['version'] = 3;
$activityParams['id'] = $this->_activityId;
$activityParams['skipRecentView'] = TRUE;
civicrm_api('Activity', 'create', $activityParams);
}
}
if ($this->_multiRecord && $this->_recordId && $this->_multiRecordFields && $this->_recordExists) {
$params['customRecordValues'][$this->_recordId] = array_keys($this->_multiRecordFields);
}
$this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $profileFields, $this->_id, $addToGroupId, $this->_gid, $this->_ctype, TRUE);
//mailing type group
if (!empty($mailingType)) {
// we send in the contactID so we match the same groups and are exact, rather than relying on email
// CRM-8710
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result, $this->_id, 'profile');
}
$ufGroups = array();
if ($this->_gid) {
$ufGroups[$this->_gid] = 1;
} elseif ($this->_mode == self::MODE_REGISTER) {
$ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
}
foreach ($ufGroups as $gId => $val) {
if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, NULL);
CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
}
}
//create CMS user (if CMS user option is selected in profile)
if (!empty($params['cms_create_account']) && $this->_mode == self::MODE_CREATE) {
$params['contactID'] = $this->_id;
if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'), ts('Profile Error'), 'error');
CRM_Core_Error::debug_log_message("Rolling back transaction as CMSUser Create failed in Profile_Form for contact " . $params['contactID']);
$transaction->rollback();
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
}
}
$transaction->commit();
}