本文整理汇总了PHP中CRM_Contact_BAO_Contact::getContactSubType方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::getContactSubType方法的具体用法?PHP CRM_Contact_BAO_Contact::getContactSubType怎么用?PHP CRM_Contact_BAO_Contact::getContactSubType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::getContactSubType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
$cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
//custom groups Inline
$entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
$entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId, $cgId, $entitySubType);
$details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contactId);
//get the fields of single custom group record
if ($customRecId == 1) {
$fields = reset($details[$cgId]);
} else {
$fields = CRM_Utils_Array::value($customRecId, $details[$cgId]);
}
$this->assign('cgcount', $cgcount);
$this->assign('customRecId', $customRecId);
$this->assign('contactId', $contactId);
$this->assign('customGroupId', $cgId);
$this->assign_by_ref('cd_edit', $fields);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例2: preProcess
/**
* Call preprocess.
*/
public function preProcess()
{
parent::preProcess();
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST);
$this->assign('customGroupId', $this->_groupID);
$customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', $this, FALSE, 1, $_REQUEST);
$cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE, 1, $_REQUEST);
$subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ',');
CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, $cgcount, $this->_contactType, $this->_contactId);
}
示例3: preProcess
/**
* call preprocess
*/
public function preProcess()
{
//get all the existing email addresses
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE, NULL, $_REQUEST);
$this->assign('contactId', $this->_contactId);
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST);
$this->assign('customGroupId', $this->_groupID);
$type = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
$subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ',');
CRM_Custom_Form_CustomData::preProcess($this, null, $subType, 1, $type, $this->_contactId);
}
示例4: relatedContactInfo
static function relatedContactInfo($contactId)
{
$return = array();
if (empty($contactId)) {
return $return;
}
$phone = CRM_Core_BAO_Phone::allPhones($contactId, TRUE, NULL, array('is_primary' => 1));
$contactSubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
$contactType = CRM_Contact_BAO_ContactType::getLabel($contactSubType[0]);
$gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'PCP_Supporter_Profile', 'id', 'name');
$updateURL = CRM_Utils_System::url('civicrm/profile/edit', "reset=1&gid={$gid}&cid={$contactId}");
// $updateURL =CRM_Utils_System::url('civicrm/pcp/support', "action=browse&component=event&id={$params['pcpId']}");
$return = array('name' => CRM_Contact_BAO_Contact::displayName($contactId), 'type' => $contactType, 'email' => CRM_Contact_BAO_Contact::getPrimaryEmail($contactId), 'phone' => !empty($phone) && isset($phone[1]['phone']) ? $phone[1]['phone'] : NULL, 'action' => "<a href={$updateURL}>Update Contact Information</a>");
return $return;
}
示例5: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
//custom groups Inline
$entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
$entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId, $cgId, $entitySubType);
$details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$fields = array_pop($details[$cgId]);
$this->assign('contactId', $contactId);
$this->assign('customGroupId', $cgId);
$this->assign_by_ref('cd_edit', $fields);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例6: civicrm_api3_contact_create
/**
* Create or update a Contact.
*
* @param array $params
* Input parameters.
*
* @throws API_Exception
*
* @return array
* API Result Array
*/
function civicrm_api3_contact_create($params)
{
$contactID = CRM_Utils_Array::value('contact_id', $params, CRM_Utils_Array::value('id', $params));
if ($contactID && !empty($params['check_permissions']) && !CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::EDIT)) {
throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify contact record');
}
$dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
$values = _civicrm_api3_contact_check_params($params, $dupeCheck);
if ($values) {
return $values;
}
if (!$contactID) {
// If we get here, we're ready to create a new contact
if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
$defLocType = CRM_Core_BAO_LocationType::getDefault();
$params['email'] = array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => $defLocType->id ? $defLocType->id : 1));
}
}
if (!empty($params['home_url'])) {
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
$params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
}
_civicrm_api3_greeting_format_params($params);
$values = array();
if (empty($params['contact_type']) && $contactID) {
$params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($contactID);
}
if (!isset($params['contact_sub_type']) && $contactID) {
$params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($contactID);
}
_civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $contactID);
$params = array_merge($params, $values);
//@todo we should just call basic_create here - but need to make contact:create accept 'id' on the bao
$contact = _civicrm_api3_contact_update($params, $contactID);
if (is_a($contact, 'CRM_Core_Error')) {
throw new API_Exception($contact->_errors[0]['message']);
} else {
$values = array();
_civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]);
}
return civicrm_api3_create_success($values, $params, 'Contact', 'create');
}
示例7: processAction
/**
* Method processAction to execute the action
*
* @param CRM_Civirules_EventData_EventData $eventData
* @access public
*
*/
public function processAction(CRM_Civirules_EventData_EventData $eventData)
{
$contactId = $eventData->getContactId();
$subTypes = CRM_Contact_BAO_Contact::getContactSubType($contactId);
$contactType = CRM_Contact_BAO_Contact::getContactType($contactId);
$changed = false;
$action_params = $this->getActionParameters();
foreach ($action_params['sub_type'] as $sub_type) {
if (CRM_Contact_BAO_ContactType::isExtendsContactType($sub_type, $contactType)) {
$subTypes[] = $sub_type;
$changed = true;
}
}
if ($changed) {
$params['id'] = $contactId;
$params['contact_id'] = $contactId;
$params['contact_type'] = $contactType;
$params['contact_sub_type'] = $subTypes;
CRM_Contact_BAO_Contact::add($params);
}
}
示例8: preProcess
/**
* Pre processing work done here.
*
* Gets session variables for table name, id of entity in table, type of entity and stores them.
*/
public function preProcess()
{
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', FALSE);
$this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this);
if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
if ($this->_cdType) {
$this->assign('cdType', TRUE);
}
// NOTE : group id is not stored in session from within CRM_Custom_Form_CustomData::preProcess func
// this is due to some condition inside it which restricts it from saving in session
// so doing this for multi record edit action
$entityId = CRM_Utils_Request::retrieve('entityID', 'Positive', $this);
if (!empty($entityId)) {
$subType = CRM_Contact_BAO_Contact::getContactSubType($entityId, ',');
}
CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, NULL, NULL, $entityId);
if ($this->_multiRecordDisplay) {
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this);
$this->_tableID = $this->_entityId;
$this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID);
$mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
$hasReachedMax = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($this->_groupID, $this->_tableID);
if ($hasReachedMax && $mode == 'add') {
CRM_Core_Error::statusBounce(ts('The maximum record limit is reached'));
}
$this->_copyValueId = CRM_Utils_Request::retrieve('copyValueId', 'Positive', $this);
$groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupID);
$mode = CRM_Utils_Request::retrieve('mode', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
$mode = ucfirst($mode);
CRM_Utils_System::setTitle(ts('%1 %2 Record', array(1 => $mode, 2 => $groupTitle)));
if (!empty($_POST['hidden_custom'])) {
$this->assign('postedInfo', TRUE);
}
}
return;
}
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE);
$this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, TRUE);
$this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID);
$this->_contactSubType = CRM_Contact_BAO_Contact::getContactSubType($this->_tableID, ',');
$this->assign('contact_type', $this->_contactType);
$this->assign('contact_subtype', $this->_contactSubType);
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_tableID);
CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
for ($i = 1; $i <= $_POST['hidden_custom_group_count'][$this->_groupID]; $i++) {
CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_contactSubType, $i, $this->_contactType, $this->_tableID);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
}
}
示例9: civicrm_api3_contact_create
/**
* Create or update a contact (note you should always call this via civicrm_api() & never directly)
*
* @param array $params input parameters
*
* Allowed @params array keys are:
* {@getfields contact_create}
*
*
* @example ContactCreate.php Example of Create Call
*
* @return array API Result Array
*
* @static void
* @access public
*/
function civicrm_api3_contact_create($params)
{
$contactID = CRM_Utils_Array::value('contact_id', $params, CRM_Utils_Array::value('id', $params));
$dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
$values = _civicrm_api3_contact_check_params($params, $dupeCheck);
if ($values) {
return $values;
}
if (empty($contactID)) {
// If we get here, we're ready to create a new contact
if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
require_once 'CRM/Core/BAO/LocationType.php';
$defLocType = CRM_Core_BAO_LocationType::getDefault();
$params['email'] = array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => $defLocType->id ? $defLocType->id : 1));
}
}
if (CRM_Utils_Array::value('home_url', $params)) {
require_once 'CRM/Core/PseudoConstant.php';
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $params['home_url']));
}
if (isset($params['suffix_id']) && !is_numeric($params['suffix_id'])) {
$params['suffix_id'] = array_search($params['suffix_id'], CRM_Core_PseudoConstant::individualSuffix());
}
if (isset($params['prefix_id']) && !is_numeric($params['prefix_id'])) {
$params['prefix_id'] = array_search($params['prefix_id'], CRM_Core_PseudoConstant::individualPrefix());
}
if (isset($params['gender_id']) && !is_numeric($params['gender_id'])) {
$params['gender_id'] = array_search($params['gender_id'], CRM_Core_PseudoConstant::gender());
}
$error = _civicrm_api3_greeting_format_params($params);
if (civicrm_error($error)) {
return $error;
}
$values = array();
$entityId = $contactID;
if (!CRM_Utils_Array::value('contact_type', $params) && $entityId) {
$params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($entityId);
}
if (!isset($params['contact_sub_type']) && $entityId) {
require_once 'CRM/Contact/BAO/Contact.php';
$params['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($entityId);
}
_civicrm_api3_custom_format_params($params, $values, $params['contact_type'], $entityId);
$params = array_merge($params, $values);
$contact = _civicrm_api3_contact_update($params, $contactID);
if (is_a($contact, 'CRM_Core_Error')) {
return civicrm_api3_create_error($contact->_errors[0]['message']);
} else {
$values = array();
_civicrm_api3_object_to_array_unique_fields($contact, $values[$contact->id]);
}
return civicrm_api3_create_success($values, $params, 'Contact', 'create');
}
示例10: civicrm_contact_update
/**
* @todo Write sth
* @todo Serious FIXMES in the code! File issues.
*/
function civicrm_contact_update(&$params, $create_new = FALSE)
{
_civicrm_initialize();
try {
civicrm_api_check_permission(__FUNCTION__, $params, TRUE);
} catch (Exception $e) {
return civicrm_create_error($e->getMessage());
}
require_once 'CRM/Utils/Array.php';
$entityId = CRM_Utils_Array::value('contact_id', $params, NULL);
if (!CRM_Utils_Array::value('contact_type', $params) && $entityId) {
$params['contact_type'] = CRM_Contact_BAO_Contact::getContactType($entityId);
}
$dupeCheck = CRM_Utils_Array::value('dupe_check', $params, FALSE);
$values = civicrm_contact_check_params($params, $dupeCheck);
if ($values) {
return $values;
}
if ($create_new) {
// Make sure nothing is screwed up before we create a new contact
if (!empty($entityId)) {
return civicrm_create_error('Cannot create new contact when contact_id is present');
}
if (empty($params['contact_type'])) {
return civicrm_create_error('Contact Type not specified');
}
// If we get here, we're ready to create a new contact
if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) {
require_once 'CRM/Core/BAO/LocationType.php';
$defLocType = CRM_Core_BAO_LocationType::getDefault();
$params['email'] = array(1 => array('email' => $email, 'is_primary' => 1, 'location_type_id' => $defLocType->id ? $defLocType->id : 1));
}
}
if ($homeUrl = CRM_Utils_Array::value('home_url', $params)) {
require_once 'CRM/Core/PseudoConstant.php';
$websiteTypes = CRM_Core_PseudoConstant::websiteType();
$params['website'] = array(1 => array('website_type_id' => key($websiteTypes), 'url' => $homeUrl));
}
// FIXME: Some legacy support cruft, should get rid of this in 3.1
$change = array('individual_prefix' => 'prefix', 'prefix' => 'prefix_id', 'individual_suffix' => 'suffix', 'suffix' => 'suffix_id', 'gender' => 'gender_id');
foreach ($change as $field => $changeAs) {
if (array_key_exists($field, $params)) {
$params[$changeAs] = $params[$field];
unset($params[$field]);
}
}
// End legacy support cruft
if (isset($params['suffix_id']) && !is_numeric($params['suffix_id'])) {
$params['suffix_id'] = array_search($params['suffix_id'], CRM_Core_PseudoConstant::individualSuffix());
}
if (isset($params['prefix_id']) && !is_numeric($params['prefix_id'])) {
$params['prefix_id'] = array_search($params['prefix_id'], CRM_Core_PseudoConstant::individualPrefix());
}
if (isset($params['gender_id']) && !is_numeric($params['gender_id'])) {
$params['gender_id'] = array_search($params['gender_id'], CRM_Core_PseudoConstant::gender());
}
$error = _civicrm_greeting_format_params($params);
if (civicrm_error($error)) {
return $error;
}
$values = array();
if (!($csType = CRM_Utils_Array::value('contact_sub_type', $params)) && $entityId) {
require_once 'CRM/Contact/BAO/Contact.php';
$csType = CRM_Contact_BAO_Contact::getContactSubType($entityId);
}
$customValue = civicrm_contact_check_custom_params($params, $csType);
if ($customValue) {
return $customValue;
}
_civicrm_custom_format_params($params, $values, $params['contact_type'], $entityId);
$params = array_merge($params, $values);
$contact =& _civicrm_contact_update($params, $entityId);
if (is_a($contact, 'CRM_Core_Error')) {
return civicrm_create_error($contact->_errors[0]['message']);
} else {
$values = array();
$values['contact_id'] = $contact->id;
$values['is_error'] = 0;
}
return $values;
}
示例11: _addWhereAdd
/**
* Add the whereAdd clause for the DAO depending on the type of entity
* the custom group is extending.
*
* @param object CRM_Core_DAO_CustomGroup (reference) - Custom Group DAO.
* @param string $entityType - what entity are we extending here ?
*
* @return void
*
* @access private
* @static
*
*/
private static function _addWhereAdd(&$customGroupDAO, $entityType, $entityID = null)
{
$addSubtypeClause = false;
switch ($entityType) {
case 'Contact':
// if contact, get all related to contact
$extendList = "'Contact','Individual','Household','Organization'";
$customGroupDAO->whereAdd("extends IN ( {$extendList} )");
$addSubtypeClause = true;
break;
case 'Individual':
case 'Household':
case 'Organization':
// is I/H/O then get I/H/O and contact
$extendList = "'Contact','{$entityType}'";
$customGroupDAO->whereAdd("extends IN ( {$extendList} )");
$addSubtypeClause = true;
break;
case 'Location':
case 'Address':
$customGroupDAO->whereAdd("extends IN ('{$entityType}')");
break;
}
if ($addSubtypeClause) {
require_once 'CRM/Contact/BAO/Contact.php';
$csType = is_numeric($entityID) ? CRM_Contact_BAO_Contact::getContactSubType($entityID) : false;
if ($csType) {
$csType = CRM_Core_DAO::VALUE_SEPARATOR . $csType . CRM_Core_DAO::VALUE_SEPARATOR;
$customGroupDAO->whereAdd("( extends_entity_column_value LIKE '%{$csType}%' OR extends_entity_column_value IS NULL )");
} else {
$customGroupDAO->whereAdd("extends_entity_column_value IS NULL");
}
}
}
示例12: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
*
*
* @return void
*/
public function run()
{
$this->preProcess();
//set the userContext stack
$doneURL = 'civicrm/contact/view';
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url($doneURL, 'action=browse&selectedChild=custom_' . $this->_groupId), FALSE);
// get permission detail view or edit
// use a comtact id specific function which gives us much better granularity
// CRM-12646
$editCustomData = CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT);
$this->assign('editCustomData', $editCustomData);
//allow to edit own customdata CRM-5518
$editOwnCustomData = FALSE;
if ($session->get('userID') == $this->_contactId) {
$editOwnCustomData = TRUE;
}
$this->assign('editOwnCustomData', $editOwnCustomData);
if ($this->_action == CRM_Core_Action::BROWSE) {
//Custom Groups Inline
$entityType = CRM_Contact_BAO_Contact::getContactType($this->_contactId);
$entitySubType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $this->_contactId, $this->_groupId, $entitySubType);
$displayStyle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_groupId, 'style');
if ($this->_multiRecordDisplay != 'single') {
$id = "custom_{$this->_groupId}";
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent($id, $this->_contactId, $groupTree[$this->_groupId]['table_name']);
}
if ($displayStyle === 'Tab with table' && $this->_multiRecordDisplay != 'single') {
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'contact_type');
$this->assign('displayStyle', 'tableOriented');
// here the multi custom data listing code will go
$multiRecordFieldListing = TRUE;
$page = new CRM_Profile_Page_MultipleRecordFieldsListing();
$page->set('contactId', $this->_contactId);
$page->set('customGroupId', $this->_groupId);
$page->set('action', CRM_Core_Action::BROWSE);
$page->set('multiRecordFieldListing', $multiRecordFieldListing);
$page->set('pageViewType', 'customDataView');
$page->set('contactType', $ctype);
$page->run();
} else {
$recId = NULL;
if ($this->_multiRecordDisplay == 'single') {
$groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupId);
CRM_Utils_System::setTitle(ts('View %1 Record', array(1 => $groupTitle)));
$recId = $this->_recId;
$this->assign('multiRecordDisplay', $this->_multiRecordDisplay);
$this->assign('skipTitle', 1);
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, $recId);
}
} else {
$controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_CustomData', ts('Custom Data'), $this->_action);
$controller->setEmbedded(TRUE);
$controller->set('tableId', $this->_contactId);
$controller->set('groupId', $this->_groupId);
$controller->set('entityType', CRM_Contact_BAO_Contact::getContactType($this->_contactId));
$controller->set('entitySubType', CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ','));
$controller->process();
$controller->run();
}
return parent::run();
}
示例13: 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->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', false);
if ($this->_cdType) {
$this->assign('cdType', true);
return CRM_Custom_Form_CustomData::preProcess($this);
}
$this->_groupID = CRM_Utils_Request::retrieve('groupId', 'Positive', $this, true);
$this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, true);
require_once "CRM/Contact/BAO/Contact.php";
$this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID);
$this->_contactSubType = CRM_Contact_BAO_Contact::getContactSubType($this->_tableID);
$this->assign('contact_type', $this->_contactType);
$this->assign('contact_subtype', $this->_contactSubType);
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_tableID);
CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
// when custom data is included in this page
if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
for ($i; $i <= $_POST['hidden_custom_group_count'][$this->_groupID]; $i++) {
CRM_Custom_Form_CustomData::preProcess($this, null, null, $i);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
}
}
示例14: _addWhereAdd
/**
* Add the whereAdd clause for the DAO depending on the type of entity
* the custom group is extending.
*
* @param object $customGroupDAO
* @param string $entityType
* What entity are we extending here ?.
*
* @param int $entityID
* @param bool $allSubtypes
*/
private static function _addWhereAdd(&$customGroupDAO, $entityType, $entityID = NULL, $allSubtypes = FALSE)
{
$addSubtypeClause = FALSE;
switch ($entityType) {
case 'Contact':
// if contact, get all related to contact
$extendList = "'Contact','Individual','Household','Organization'";
$customGroupDAO->whereAdd("extends IN ( {$extendList} )");
if (!$allSubtypes) {
$addSubtypeClause = TRUE;
}
break;
case 'Individual':
case 'Household':
case 'Organization':
// is I/H/O then get I/H/O and contact
$extendList = "'Contact','{$entityType}'";
$customGroupDAO->whereAdd("extends IN ( {$extendList} )");
if (!$allSubtypes) {
$addSubtypeClause = TRUE;
}
break;
case 'Case':
case 'Location':
case 'Address':
case 'Activity':
case 'Contribution':
case 'Membership':
case 'Participant':
$customGroupDAO->whereAdd("extends IN ('{$entityType}')");
break;
}
if ($addSubtypeClause) {
$csType = is_numeric($entityID) ? CRM_Contact_BAO_Contact::getContactSubType($entityID) : FALSE;
if (!empty($csType)) {
$subtypeClause = array();
foreach ($csType as $subtype) {
$subtype = CRM_Core_DAO::VALUE_SEPARATOR . $subtype . CRM_Core_DAO::VALUE_SEPARATOR;
$subtypeClause[] = "extends_entity_column_value LIKE '%{$subtype}%'";
}
$subtypeClause[] = "extends_entity_column_value IS NULL";
$customGroupDAO->whereAdd("( " . implode(' OR ', $subtypeClause) . " )");
} else {
$customGroupDAO->whereAdd("extends_entity_column_value IS NULL");
}
}
}
示例15: 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->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', FALSE);
if ($this->_cdType) {
$this->assign('cdType', TRUE);
return CRM_Custom_Form_CustomData::preProcess($this);
}
$this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE);
$this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, TRUE);
$this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID);
$this->_contactSubType = CRM_Contact_BAO_Contact::getContactSubType($this->_tableID, ',');
$this->assign('contact_type', $this->_contactType);
$this->assign('contact_subtype', $this->_contactSubType);
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_tableID);
CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
for ($i = 0; $i <= $_POST['hidden_custom_group_count'][$this->_groupID]; $i++) {
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, $i);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
}
}