本文整理汇总了PHP中CRM_Contact_BAO_ContactType::isAllowEdit方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_ContactType::isAllowEdit方法的具体用法?PHP CRM_Contact_BAO_ContactType::isAllowEdit怎么用?PHP CRM_Contact_BAO_ContactType::isAllowEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_ContactType
的用法示例。
在下文中一共展示了CRM_Contact_BAO_ContactType::isAllowEdit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
//.........这里部分代码省略.........
//special case to check dedupe if external id present.
//if we send external id dedupe will stop.
unset($dedupeParams['external_identifier']);
$checkDedupe = _civicrm_duplicate_formatted_contact($dedupeParams);
if (civicrm_duplicate($checkDedupe)) {
$matchingContactIds = explode(',', $checkDedupe['error_message']['params'][0]);
if (count($matchingContactIds) == 1) {
$params['id'] = array_pop($matchingContactIds);
} else {
$message = "More than one matching contact found for given criteria.";
array_unshift($values, $message);
$this->_retCode = CRM_Import_Parser::NO_MATCH;
}
} else {
$createNewContact = true;
}
}
}
$error = _civicrm_duplicate_formatted_contact($formatted);
if (civicrm_duplicate($error)) {
$matchedIDs = explode(',', $error['error_message']['params'][0]);
if (count($matchedIDs) >= 1) {
$updateflag = true;
foreach ($matchedIDs as $contactId) {
if ($params['id'] == $contactId) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_type');
if ($formatted['contact_type'] == $contactType) {
//validation of subtype for update mode
//CRM-5125
$contactSubType = null;
if (CRM_Utils_Array::value('contact_sub_type', $params)) {
$contactSubType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_sub_type');
}
if (!empty($contactSubType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params['id'], $contactSubType) || $contactSubType != CRM_Utils_Array::value('contact_sub_type', $formatted))) {
$message = "Mismatched contact SubTypes :";
array_unshift($values, $message);
$updateflag = false;
$this->_retCode = CRM_Import_Parser::NO_MATCH;
} else {
$newContact = $this->createContact($formatted, $contactFields, $onDuplicate, $contactId, false);
$updateflag = false;
$this->_retCode = CRM_Import_Parser::VALID;
}
} else {
$message = "Mismatched contact Types :";
array_unshift($values, $message);
$updateflag = false;
$this->_retCode = CRM_Import_Parser::NO_MATCH;
}
}
}
if ($updateflag) {
$message = "Mismatched contact IDs OR Mismatched contact Types :";
array_unshift($values, $message);
$this->_retCode = CRM_Import_Parser::NO_MATCH;
}
}
} else {
$contactType = null;
if (CRM_Utils_Array::value('id', $params)) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_type');
if ($contactType) {
if ($formatted['contact_type'] == $contactType) {
//validation of subtype for update mode
//CRM-5125
$contactSubType = null;
示例2: postProcess
/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess()
{
$params = $this->exportValues();
$ufGroupId = $this->get('ufGroupId');
$notify = NULL;
$inValidSubtypeCnt = 0;
//send profile notification email if 'notify' field is set
$notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $ufGroupId, 'notify');
foreach ($params['field'] as $key => $value) {
//CRM-5521
//validate subtype before updating
if (!empty($value['contact_sub_type']) && !CRM_Contact_BAO_ContactType::isAllowEdit($key)) {
unset($value['contact_sub_type']);
$inValidSubtypeCnt++;
}
$value['preserveDBName'] = $this->_preserveDefault;
//parse street address, CRM-7768
self::parseStreetAddress($value, $this);
CRM_Contact_BAO_Contact::createProfileContact($value, $this->_fields, $key, NULL, $ufGroupId, NULL, TRUE);
if ($notify) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($ufGroupId, $key, NULL);
CRM_Core_BAO_UFGroup::commonSendMail($key, $values);
}
}
CRM_Core_Session::setStatus('', ts("Updates Saved"), 'success');
if ($inValidSubtypeCnt) {
CRM_Core_Session::setStatus(ts('Contact Subtype field of 1 contact has not been updated.', array('plural' => 'Contact Subtype field of %count contacts has not been updated.', 'count' => $inValidSubtypeCnt)), ts('Invalid Subtype'));
}
}
示例3: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return None
*/
public function postProcess()
{
$params = $this->exportValues();
$ufGroupId = $this->get('ufGroupId');
$notify = NULL;
$inValidSubtypeCnt = 0;
//send profile notification email if 'notify' field is set
$notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $ufGroupId, 'notify');
foreach ($params['field'] as $key => $value) {
//CRM-5521
//validate subtype before updating
if (CRM_Utils_Array::value('contact_sub_type', $value) && !CRM_Contact_BAO_ContactType::isAllowEdit($key)) {
unset($value['contact_sub_type']);
$inValidSubtypeCnt++;
}
$value['preserveDBName'] = $this->_preserveDefault;
//parse street address, CRM-7768
self::parseStreetAddress($value, $this);
CRM_Contact_BAO_Contact::createProfileContact($value, $this->_fields, $key, NULL, $ufGroupId);
if ($notify) {
$values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($ufGroupId, $key, NULL);
CRM_Core_BAO_UFGroup::commonSendMail($key, $values);
}
}
$statusMsg = ts("Your updates have been saved.");
if ($inValidSubtypeCnt) {
$statusMsg .= ' ' . ts('Contact SubType field of %1 number of contact(s) has not been updated.', array(1 => $inValidSubtypeCnt));
}
CRM_Core_Session::setStatus("{$statusMsg}");
}
示例4: import
/**
* Handle the values in import mode.
*
* @param int $onDuplicate
* The code for what action to take on duplicates.
* @param array $values
* The array of values belonging to this line.
*
* @param bool $doGeocodeAddress
*
* @return bool
* the result of this processing
*/
public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE)
{
$config = CRM_Core_Config::singleton();
$this->_unparsedStreetAddressContacts = array();
if (!$doGeocodeAddress) {
// CRM-5854, reset the geocode method to null to prevent geocoding
$config->geocodeMethod = NULL;
}
// first make sure this is a valid line
//$this->_updateWithId = false;
$response = $this->summary($values);
$statusFieldName = $this->_statusFieldName;
if ($response != CRM_Import_Parser::VALID) {
$importRecordParams = array($statusFieldName => 'INVALID', "{$statusFieldName}Msg" => "Invalid (Error Code: {$response})");
$this->updateImportRecord($values[count($values) - 1], $importRecordParams);
return $response;
}
$params =& $this->getActiveFieldParams();
$formatted = array('contact_type' => $this->_contactType);
static $contactFields = NULL;
if ($contactFields == NULL) {
$contactFields = CRM_Contact_DAO_Contact::import();
}
//check if external identifier exists in database
if (!empty($params['external_identifier']) && (!empty($params['id']) || in_array($onDuplicate, array(CRM_Import_Parser::DUPLICATE_SKIP, CRM_Import_Parser::DUPLICATE_NOCHECK)))) {
if ($internalCid = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['external_identifier'], 'id', 'external_identifier')) {
if ($internalCid != CRM_Utils_Array::value('id', $params)) {
$errorMessage = ts('External ID already exists in Database.');
array_unshift($values, $errorMessage);
$importRecordParams = array($statusFieldName => 'ERROR', "{$statusFieldName}Msg" => $errorMessage);
$this->updateImportRecord($values[count($values) - 1], $importRecordParams);
return CRM_Import_Parser::DUPLICATE;
}
}
}
if (!empty($this->_contactSubType)) {
$params['contact_sub_type'] = $this->_contactSubType;
}
if ($subType = CRM_Utils_Array::value('contact_sub_type', $params)) {
if (CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType, FALSE, 'label')) {
$subTypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType, FALSE, NULL);
$params['contact_sub_type'] = array_search($subType, $subTypes);
} elseif (!CRM_Contact_BAO_ContactType::isExtendsContactType($subType, $this->_contactType)) {
$message = "Mismatched or Invalid Contact Subtype.";
array_unshift($values, $message);
return CRM_Import_Parser::NO_MATCH;
}
}
// Get contact id to format common data in update/fill mode,
// prioritising a dedupe rule check over an external_identifier check, but falling back on ext id.
if ($this->_updateWithId && empty($params['id'])) {
$possibleMatches = $this->getPossibleContactMatches($params);
foreach ($possibleMatches as $possibleID) {
$params['id'] = $formatted['id'] = $possibleID;
}
}
//format common data, CRM-4062
$this->formatCommonData($params, $formatted, $contactFields);
$relationship = FALSE;
$createNewContact = TRUE;
// Support Match and Update Via Contact ID
if ($this->_updateWithId && isset($params['id'])) {
$createNewContact = FALSE;
// @todo - it feels like all the rows from here to the end of the IF
// could be removed in favour of a simple check for whether the contact_type & id match
// the call to the deprecated function seems to add no value other that to do an additional
// check for the contact_id & type.
$error = _civicrm_api3_deprecated_duplicate_formatted_contact($formatted);
if (CRM_Core_Error::isAPIError($error, CRM_Core_ERROR::DUPLICATE_CONTACT)) {
$matchedIDs = explode(',', $error['error_message']['params'][0]);
if (count($matchedIDs) >= 1) {
$updateflag = TRUE;
foreach ($matchedIDs as $contactId) {
if ($params['id'] == $contactId) {
$contactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_type');
if ($formatted['contact_type'] == $contactType) {
//validation of subtype for update mode
//CRM-5125
$contactSubType = NULL;
if (!empty($params['contact_sub_type'])) {
$contactSubType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params['id'], 'contact_sub_type');
}
if (!empty($contactSubType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params['id'], $contactSubType) && $contactSubType != CRM_Utils_Array::value('contact_sub_type', $formatted))) {
$message = "Mismatched contact SubTypes :";
array_unshift($values, $message);
$updateflag = FALSE;
$this->_retCode = CRM_Import_Parser::NO_MATCH;
//.........这里部分代码省略.........
示例5: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
//load form for child blocks
if ($this->_addBlockName) {
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_addBlockName) . ".php";
return eval('CRM_Contact_Form_Edit_' . $this->_addBlockName . '::buildQuickForm( $this );');
}
if ($this->_action == CRM_Core_Action::UPDATE) {
$deleteExtra = ts('Are you sure you want to delete contact image.');
$deleteURL = array(CRM_Core_Action::DELETE => array('name' => ts('Delete Contact Image'), 'url' => 'civicrm/contact/image', 'qs' => 'reset=1&cid=%%id%%&action=delete', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"'));
$deleteURL = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, array('id' => $this->_contactId));
$this->assign('deleteURL', $deleteURL);
}
//build contact type specific fields
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_contactType) . ".php";
eval('CRM_Contact_Form_Edit_' . $this->_contactType . '::buildQuickForm( $this, $this->_action );');
// build Custom data if Custom data present in edit option
$buildCustomData = null;
if (array_key_exists('CustomData', $this->_editOptions)) {
$buildCustomData = "removeDefaultCustomFields( ), buildCustomData('{$this->_contactType}',this.value), highlightTabs( );";
}
// subtype is a common field. lets keep it here
$typeLabel = CRM_Contact_BAO_ContactType::getLabel($this->_contactType);
$subtypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType);
$subtypeElem =& $this->addElement('select', 'contact_sub_type', ts('Contact Type'), array('' => $typeLabel) + $subtypes, array('onchange' => $buildCustomData));
$allowEditSubType = true;
if ($this->_contactId && $this->_contactSubType) {
$allowEditSubType = CRM_Contact_BAO_ContactType::isAllowEdit($this->_contactId, $this->_contactSubType);
}
if (!$allowEditSubType) {
$subtypeElem->freeze();
}
// build edit blocks ( custom data, demographics, communication preference, notes, tags and groups )
foreach ($this->_editOptions as $name => $label) {
if ($name == 'Address') {
$this->_blocks['Address'] = $this->_editOptions['Address'];
continue;
}
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $name) . ".php";
eval('CRM_Contact_Form_Edit_' . $name . '::buildQuickForm( $this );');
}
// build location blocks.
CRM_Contact_Form_Location::buildQuickForm($this);
// add attachment
$this->addElement('file', 'image_URL', ts('Browse/Upload Image'), 'size=30 maxlength=60');
$this->addUploadElement('image_URL');
// add the dedupe button
$this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)'));
$this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact'));
$this->addElement('submit', $this->getButtonName('next', 'sharedHouseholdDuplicate'), ts('Save With Duplicate Household'));
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'spacing' => ' ', 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例6: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
//load form for child blocks
if ($this->_addBlockName) {
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_addBlockName) . ".php";
return eval('CRM_Contact_Form_Edit_' . $this->_addBlockName . '::buildQuickForm( $this );');
}
//build contact type specific fields
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_contactType) . ".php";
eval('CRM_Contact_Form_Edit_' . $this->_contactType . '::buildQuickForm( $this, $this->_action );');
// subtype is a common field. lets keep it here
$typeLabel = CRM_Contact_BAO_ContactType::getLabel($this->_contactType);
$subtypes = CRM_Contact_BAO_ContactType::subTypePairs($this->_contactType);
$subtypeElem =& $this->addElement('select', 'contact_sub_type', ts('Contact Type'), array('' => $typeLabel) + $subtypes);
$allowEditSubType = true;
if ($this->_contactId && $this->_contactSubType) {
$allowEditSubType = CRM_Contact_BAO_ContactType::isAllowEdit($this->_contactId, $this->_contactSubType);
}
if (!$allowEditSubType) {
$subtypeElem->freeze();
}
// build edit blocks ( custom data, demographics, communication preference, notes, tags and groups )
foreach ($this->_editOptions as $name => $label) {
if ($name == 'Address') {
$this->_blocks['Address'] = $this->_editOptions['Address'];
continue;
}
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $name) . ".php";
eval('CRM_Contact_Form_Edit_' . $name . '::buildQuickForm( $this );');
}
// build location blocks.
CRM_Contact_Form_Location::buildQuickForm($this);
// add the dedupe button
$this->addElement('submit', $this->_dedupeButtonName, ts('Check for Matching Contact(s)'));
$this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact'));
$this->addElement('submit', $this->getButtonName('next', 'sharedHouseholdDuplicate'), ts('Save With Duplicate Household'));
$this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => true), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
}