本文整理汇总了PHP中CRM_Core_BAO_EntityTag类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_EntityTag类的具体用法?PHP CRM_Core_BAO_EntityTag怎么用?PHP CRM_Core_BAO_EntityTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_EntityTag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: processCaseTags
function processCaseTags()
{
$caseId = CRM_Utils_Type::escape($_POST['case_id'], 'Integer');
$tags = CRM_Utils_Type::escape($_POST['tag'], 'String');
if (empty($caseId)) {
echo 'false';
CRM_Utils_System::civiExit();
}
$tagIds = array();
if ($tags) {
$tagIds = explode(',', $tags);
}
$params = array('entity_id' => $caseId, 'entity_table' => 'civicrm_case');
CRM_Core_BAO_EntityTag::del($params);
foreach ($tagIds as $tagid) {
if (is_numeric($tagid)) {
$params['tag_id'] = $tagid;
CRM_Core_BAO_EntityTag::add($params);
}
}
$session = CRM_Core_Session::singleton();
$activityParams = array();
$activityParams['source_contact_id'] = $session->get('userID');
$activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Change Case Tags', 'name');
$activityParams['activity_date_time'] = date('YmdHis');
$activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
$activityParams['case_id'] = $caseId;
$activityParams['is_auto'] = 0;
$activityParams['subject'] = 'Change Case Tags';
$activity = CRM_Activity_BAO_Activity::create($activityParams);
$caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
CRM_Case_BAO_Case::processCaseActivity($caseParams);
echo 'true';
CRM_Utils_System::civiExit();
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:35,代码来源:AJAX.php
示例2: contactHasOneOfTags
protected function contactHasOneOfTags($contact_id, $tag_ids)
{
$isValid = false;
$tags = CRM_Core_BAO_EntityTag::getTag($contact_id);
foreach ($tag_ids as $tag_id) {
if (in_array($tag_id, $tags)) {
$isValid = true;
break;
}
}
return $isValid;
}
开发者ID:JMAConsulting,项目名称:org.civicoop.civirules,代码行数:12,代码来源:HasTag.php
示例3: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
function postProcess()
{
$tagId = $this->controller->exportValue('RemoveFromTag', 'tag_id');
$this->_name = $this->_tags[$tagId];
list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeContactsFromTag($this->_contactIds, $tagId);
$status = array('Contact(s) tagged as: ' . $this->_name, 'Total Selected Contact(s): ' . $total);
if ($removed) {
$status[] = 'Total Contact(s) to be removed from tag: ' . $removed;
}
if ($notRemoved) {
$status[] = 'Total Contact(s) already removed: ' . $notRemoved;
}
CRM_Core_Session::setStatus($status);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:20,代码来源:RemoveFromTag.php
示例4: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
function postProcess()
{
$tagId = $this->controller->exportValue('AddToTag', 'tag_id');
$this->_name = $this->_tags[$tagId];
list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addContactsToTag($this->_contactIds, $tagId);
$status = array('Contact(s) tagged as: ' . $this->_name, 'Total Selected Contact(s): ' . $total);
if ($added) {
$status[] = 'Total Contact(s) tagged: ' . $added;
}
if ($notAdded) {
$status[] = 'Total Contact(s) already tagged: ' . $notAdded;
}
CRM_Core_Session::setStatus($status);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:20,代码来源:AddToTag.php
示例5: postProcess
//.........这里部分代码省略.........
} else {
CRM_Utils_Hook::pre('create', $params['contact_type'], NULL, $params);
}
$customFields = CRM_Core_BAO_CustomField::getFields($params['contact_type'], FALSE, TRUE);
//CRM-5143
//if subtype is set, send subtype as extend to validate subtype customfield
$customFieldExtends = CRM_Utils_Array::value('contact_sub_type', $params) ? $params['contact_sub_type'] : $params['contact_type'];
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_contactId, $customFieldExtends, TRUE);
if ($this->_contactId && !empty($this->_oldSubtypes)) {
CRM_Contact_BAO_ContactType::deleteCustomSetForSubtypeMigration($this->_contactId, $params['contact_type'], $this->_oldSubtypes, $params['contact_sub_type']);
}
if (array_key_exists('CommunicationPreferences', $this->_editOptions)) {
// this is a chekbox, so mark false if we dont get a POST value
$params['is_opt_out'] = CRM_Utils_Array::value('is_opt_out', $params, FALSE);
}
// process shared contact address.
CRM_Contact_BAO_Contact_Utils::processSharedAddress($params['address']);
if (!array_key_exists('TagsAndGroups', $this->_editOptions) && !empty($params['group'])) {
unset($params['group']);
}
if (!empty($params['contact_id']) && $this->_action & CRM_Core_Action::UPDATE && !empty($params['group'])) {
// figure out which all groups are intended to be removed
$contactGroupList = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], 'Added');
if (is_array($contactGroupList)) {
foreach ($contactGroupList as $key) {
if ((!array_key_exists($key['group_id'], $params['group']) || $params['group'][$key['group_id']] != 1) && empty($key['is_hidden'])) {
$params['group'][$key['group_id']] = -1;
}
}
}
}
// parse street address, CRM-5450
$parseStatusMsg = NULL;
if ($this->_parseStreetAddress) {
$parseResult = self::parseAddress($params);
$parseStatusMsg = self::parseAddressStatusMsg($parseResult);
}
// Allow un-setting of location info, CRM-5969
$params['updateBlankLocInfo'] = TRUE;
$contact = CRM_Contact_BAO_Contact::create($params, TRUE, FALSE, TRUE);
// status message
if ($this->_contactId) {
$message = ts('%1 has been updated.', array(1 => $contact->display_name));
} else {
$message = ts('%1 has been created.', array(1 => $contact->display_name));
}
// set the contact ID
$this->_contactId = $contact->id;
if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
//add contact to tags
CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $params['contact_id']);
//save free tags
if (isset($params['contact_taglist']) && !empty($params['contact_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['contact_taglist'], $params['contact_id'], 'civicrm_contact', $this);
}
}
if (!empty($parseStatusMsg)) {
$message .= "<br />{$parseStatusMsg}";
}
if (!empty($updateMembershipMsg)) {
$message .= "<br />{$updateMembershipMsg}";
}
$session = CRM_Core_Session::singleton();
$session->setStatus($message, ts('Contact Saved'), 'success');
// add the recently viewed contact
$recentOther = array();
if ($session->get('userID') == $contact->id || CRM_Contact_BAO_Contact_Permission::allow($contact->id, CRM_Core_Permission::EDIT)) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', 'reset=1&action=update&cid=' . $contact->id);
}
if ($session->get('userID') != $this->_contactId && CRM_Core_Permission::check('delete contacts')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/delete', 'reset=1&delete=1&cid=' . $contact->id);
}
CRM_Utils_Recent::add($contact->display_name, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $contact->id), $contact->id, $this->_contactType, $contact->id, $contact->display_name, $recentOther);
// here we replace the user context with the url to view this contact
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->getButtonName('upload', 'new')) {
$contactSubTypes = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_contactSubType));
$resetStr = "reset=1&ct={$contact->contact_type}";
$resetStr .= count($contactSubTypes) == 1 ? "&cst=" . array_pop($contactSubTypes) : '';
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/add', $resetStr));
} else {
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
//validate the qfKey
$urlParams = 'reset=1&cid=' . $contact->id;
if ($context) {
$urlParams .= "&context={$context}";
}
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= "&key={$qfKey}";
}
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', $urlParams));
}
// now invoke the post hook
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_Hook::post('edit', $params['contact_type'], $contact->id, $contact);
} else {
CRM_Utils_Hook::post('create', $params['contact_type'], $contact->id, $contact);
}
}
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contact.php
示例6: testCreateProfileContact
/**
* Test case for createProfileContact.
*/
public function testCreateProfileContact()
{
$fields = CRM_Contact_BAO_Contact::exportableFields('Individual');
//current employer field for individual
$fields['organization_name'] = array('name' => 'organization_name', 'where' => 'civicrm_organization.organization_name', 'title' => 'Current Employer');
//get the common params
$contactParams = $this->contactParams();
$unsetParams = array('location', 'privacy');
foreach ($unsetParams as $param) {
unset($contactParams[$param]);
}
$profileParams = array('organization_name' => 'Yahoo', 'gender_id' => '2', 'prefix_id' => '3', 'suffix_id' => '2', 'city-Primary' => 'Newark', 'contact_type' => 'Individual', 'country-Primary' => '1228', 'do_not_email' => '1', 'do_not_mail' => '1', 'do_not_phone' => '1', 'do_not_trade' => '1', 'do_not_sms' => '1', 'email-Primary' => '[email protected]', 'geo_code_1-Primary' => '18.219023', 'geo_code_2-Primary' => '-105.00973', 'im-Primary-provider_id' => '1', 'im-Primary' => 'john.smith', 'on_hold' => '1', 'openid' => '[email protected]', 'phone-Primary-1' => '303443689', 'phone-Primary-2' => '9833910234', 'postal_code-Primary' => '01903', 'postal_code_suffix-Primary' => '12345', 'state_province-Primary' => '1029', 'street_address-Primary' => 'Saint Helier St', 'supplemental_address_1-Primary' => 'Hallmark Ct', 'supplemental_address_2-Primary' => 'Jersey Village', 'user_unique_id' => '123456789', 'is_bulkmail' => '1', 'world_region' => 'India', 'tag' => array('3' => '1', '4' => '1', '1' => '1'));
$createParams = array_merge($contactParams, $profileParams);
//create the contact using create profile contact.
$contactId = CRM_Contact_BAO_Contact::createProfileContact($createParams, $fields, NULL, NULL, NULL, NULL, TRUE);
//get the parameters to compare.
$params = $this->contactParams();
//check the values in DB.
foreach ($params as $key => $val) {
if (!is_array($params[$key])) {
if ($key == 'contact_source') {
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, 'source', 'id', $params[$key], "Check for {$key} creation.");
} else {
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, $key, 'id', $params[$key], "Check for {$key} creation.");
}
}
}
//check privacy options.
foreach ($params['privacy'] as $key => $value) {
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, $key, 'id', $params['privacy'][$key], 'Check for do_not_email creation.');
}
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, 'contact_type', 'id', $profileParams['contact_type'], 'Check for contact type creation.');
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, 'user_unique_id', 'id', $profileParams['user_unique_id'], 'Check for user_unique_id creation.');
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, 'birth_date', 'id', $params['birth_date'], 'Check for birth_date creation.');
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, 'deceased_date', 'id', $params['deceased_date'], 'Check for deceased_date creation.');
$dbPrefComm = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'preferred_communication_method', 'id', TRUE));
$checkPrefComm = array();
foreach ($dbPrefComm as $key => $value) {
if ($value) {
$checkPrefComm[$value] = 1;
}
}
$this->assertAttributesEquals($checkPrefComm, $params['preferred_communication_method']);
//Now check DB for Address
$searchParams = array('contact_id' => $contactId, 'location_type_id' => 1, 'is_primary' => 1);
$compareParams = array('street_address' => CRM_Utils_Array::value('street_address-Primary', $profileParams), 'supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1-Primary', $profileParams), 'supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2-Primary', $profileParams), 'city' => CRM_Utils_Array::value('city-Primary', $profileParams), 'postal_code' => CRM_Utils_Array::value('postal_code-Primary', $profileParams), 'country_id' => CRM_Utils_Array::value('country-Primary', $profileParams), 'state_province_id' => CRM_Utils_Array::value('state_province-Primary', $profileParams), 'geo_code_1' => CRM_Utils_Array::value('geo_code_1-Primary', $profileParams), 'geo_code_2' => CRM_Utils_Array::value('geo_code_2-Primary', $profileParams));
$this->assertDBCompareValues('CRM_Core_DAO_Address', $searchParams, $compareParams);
//Now check DB for Email
$compareParams = array('email' => CRM_Utils_Array::value('email-Primary', $profileParams));
$this->assertDBCompareValues('CRM_Core_DAO_Email', $searchParams, $compareParams);
//Now check DB for IM
$compareParams = array('name' => CRM_Utils_Array::value('im-Primary', $profileParams), 'provider_id' => CRM_Utils_Array::value('im-Primary-provider_id', $profileParams));
$this->assertDBCompareValues('CRM_Core_DAO_IM', $searchParams, $compareParams);
//Now check DB for Phone
$searchParams = array('contact_id' => $contactId, 'location_type_id' => 1, 'is_primary' => 1);
$compareParams = array('phone' => CRM_Utils_Array::value('phone-Primary-1', $profileParams));
$this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams);
//Now check DB for Mobile
$searchParams = array('contact_id' => $contactId, 'location_type_id' => 1, 'phone_type_id' => CRM_Utils_Array::value('phone_type_id', $params['phone'][2]));
$compareParams = array('phone' => CRM_Utils_Array::value('phone-Primary-2', $profileParams));
$this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams);
//get the value of relationship
$values = array();
$searchParams = array('contact_id' => $contactId);
$relationship = CRM_Contact_BAO_Relationship::getValues($searchParams, $values);
//Now check values of Relationship Count.
$this->assertEquals(0, $values['relationship']['totalCount'], 'Check for total relationship count');
foreach ($values['relationship']['data'] as $key => $val) {
//Now check values of Relationship organization.
$this->assertEquals($profileParams['organization_name'], $val['name'], 'Check for organization');
//Now check values of Relationship type.
$this->assertEquals('Employee of', $val['relation'], 'Check for relationship type');
//delete the organization.
$this->contactDelete(CRM_Utils_Array::value('cid', $val));
}
//Now check values of tag ids.
$tags = CRM_Core_BAO_EntityTag::getTag($contactId);
foreach ($tags as $key => $val) {
$tagIds[$key] = 1;
}
$this->assertAttributesEquals($profileParams['tag'], $tagIds);
//update Contact mode
$updateCParams = array('first_name' => 'john', 'last_name' => 'doe', 'contact_type' => 'Individual', 'middle_name' => 'abc', 'prefix_id' => 2, 'suffix_id' => 3, 'nick_name' => 'Nick Name Updated', 'job_title' => 'software Developer', 'gender_id' => 1, 'is_deceased' => 1, 'website' => array(1 => array('website_type_id' => 1, 'url' => 'http://civicrmUpdate.org')), 'contact_source' => 'test contact', 'external_identifier' => 111222333, 'preferred_mail_format' => 'Both', 'is_opt_out' => 0, 'legal_identifier' => '123123123123', 'image_URL' => 'http://imageupdate.com', 'deceased_date' => '1981-10-10', 'birth_date' => '1951-11-11', 'privacy' => array('do_not_phone' => 1, 'do_not_email' => 1), 'preferred_communication_method' => array('1' => 0, '2' => 1, '3' => 0, '4' => 1, '5' => 0));
$updatePfParams = array('organization_name' => 'Google', 'city-Primary' => 'Mumbai', 'contact_type' => 'Individual', 'country-Primary' => '1228', 'do_not_email' => '1', 'do_not_mail' => '1', 'do_not_phone' => '1', 'do_not_trade' => '1', 'do_not_sms' => '1', 'email-Primary' => '[email protected]', 'geo_code_1-Primary' => '31.694842', 'geo_code_2-Primary' => '-106.29998', 'im-Primary-provider_id' => '1', 'im-Primary' => 'john.doe', 'on_hold' => '1', 'openid' => '[email protected]', 'phone-Primary-1' => '02115245336', 'phone-Primary-2' => '9766323895', 'postal_code-Primary' => '12345', 'postal_code_suffix-Primary' => '123', 'state_province-Primary' => '1004', 'street_address-Primary' => 'Oberoi Garden', 'supplemental_address_1-Primary' => 'A-wing:3037', 'supplemental_address_2-Primary' => 'Andhery', 'user_unique_id' => '1122334455', 'is_bulkmail' => '1', 'world_region' => 'India', 'tag' => array('2' => '1', '5' => '1'));
$createParams = array_merge($updateCParams, $updatePfParams);
//create the contact using create profile contact.
$contactID = CRM_Contact_BAO_Contact::createProfileContact($createParams, $fields, $contactId, NULL, NULL, NULL, TRUE);
//check the contact ids
$this->assertEquals($contactId, $contactID, 'check for Contact ids');
//check the values in DB.
foreach ($updateCParams as $key => $val) {
if (!is_array($updateCParams[$key])) {
if ($key == 'contact_source') {
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, 'source', 'id', $updateCParams[$key], "Check for {$key} creation.");
} else {
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $contactId, $key, 'id', $updateCParams[$key], "Check for {$key} creation.");
}
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:ContactTest.php
示例7: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
//get the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$contactTags = $tagList = array();
// check if contact tags exists
if (!empty($params['tag'])) {
$contactTags = $params['tag'];
}
// check if tags are selected from taglists
if (!empty($params['contact_taglist'])) {
foreach ($params['contact_taglist'] as $val) {
if ($val) {
if (is_numeric($val)) {
$tagList[$val] = 1;
} else {
$tagIDs = explode(',', $val);
if (!empty($tagIDs)) {
foreach ($tagIDs as $tagID) {
if (is_numeric($tagID)) {
$tagList[$tagID] = 1;
}
}
}
}
}
}
}
$tagSets = CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_contact', FALSE, TRUE);
foreach ($tagSets as $key => $value) {
$this->_tags[$key] = $value['name'];
}
// merge contact and taglist tags
$allTags = CRM_Utils_Array::crmArrayMerge($contactTags, $tagList);
$this->_name = array();
foreach ($allTags as $key => $dnc) {
$this->_name[] = $this->_tags[$key];
list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_contactIds, $key);
$status = array(ts('%count contact tagged', array('count' => $added, 'plural' => '%count contacts tagged')));
if ($notAdded) {
$status[] = ts('%count contact already had this tag', array('count' => $notAdded, 'plural' => '%count contacts already had this tag'));
}
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
CRM_Core_Session::setStatus($status, ts("Added Tag <em>%1</em>", array(1 => $this->_tags[$key])), 'success', array('expires' => 0));
}
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:53,代码来源:AddToTag.php
示例8: postProcessOld
//.........这里部分代码省略.........
if (isset($mapper[$key][1])) {
$header[] = $locationTypes[$mapper[$key][1]];
}
if (isset($mapper[$key][2])) {
$header[] = $phoneTypes[$mapper[$key][2]];
}
}
}
$mapperFields[] = implode(' - ', $header);
}
$tableName = $this->get('importTableName');
//print "Running parser on table: $tableName<br/>";
$parser->run($tableName, $mapperFields, CRM_Import_Parser::MODE_IMPORT, $this->get('contactType'), $this->get('primaryKeyName'), $this->get('statusFieldName'), $onDuplicate, $this->get('statusID'), $this->get('totalRowCount'), $doGeocodeAddress, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $this->get('contactSubType'), $this->get('dedupe'));
// add the new contacts to selected groups
$contactIds =& $parser->getImportedContacts();
// add the new related contacts to selected groups
$relatedContactIds =& $parser->getRelatedImportedContacts();
$this->set('relatedCount', count($relatedContactIds));
$newGroupId = NULL;
//changed below if-statement "if ($newGroup) {" to "if ($newGroupName) {"
if ($newGroupName) {
/* Create a new group */
$gParams = array('name' => $newGroupName, 'title' => $newGroupName, 'description' => $newGroupDesc, 'is_active' => TRUE);
$group = CRM_Contact_BAO_Group::create($gParams);
$groups[] = $newGroupId = $group->id;
}
if (is_array($groups)) {
$groupAdditions = array();
foreach ($groups as $groupId) {
$addCount = CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
if (!empty($relatedContactIds)) {
$addRelCount = CRM_Contact_BAO_GroupContact::addContactsToGroup($relatedContactIds, $groupId);
}
$totalCount = $addCount[1] + $addRelCount[1];
if ($groupId == $newGroupId) {
$name = $newGroupName;
$new = TRUE;
} else {
$name = $allGroups[$groupId];
$new = FALSE;
}
$groupAdditions[] = array('url' => CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $groupId), 'name' => $name, 'added' => $totalCount, 'notAdded' => $addCount[2] + $addRelCount[2], 'new' => $new);
}
$this->set('groupAdditions', $groupAdditions);
}
$newTagId = NULL;
if ($newTagName) {
/* Create a new Tag */
$tagParams = array('name' => $newTagName, 'title' => $newTagName, 'description' => $newTagDesc, 'is_active' => TRUE);
$id = array();
$addedTag = CRM_Core_BAO_Tag::add($tagParams, $id);
$tag[$addedTag->id] = 1;
}
//add Tag to Import
if (is_array($tag)) {
$tagAdditions = array();
foreach ($tag as $tagId => $val) {
$addTagCount = CRM_Core_BAO_EntityTag::addContactsToTag($contactIds, $tagId);
if (!empty($relatedContactIds)) {
$addRelTagCount = CRM_Core_BAO_EntityTag::addContactsToTag($relatedContactIds, $tagId);
}
$totalTagCount = $addTagCount[1] + $addRelTagCount[1];
if ($tagId == $addedTag->id) {
$tagName = $newTagName;
$new = TRUE;
} else {
$tagName = $allTags[$tagId];
$new = FALSE;
}
$tagAdditions[] = array('url' => CRM_Utils_System::url('civicrm/contact/search', 'reset=1&force=1&context=smog&id=' . $tagId), 'name' => $tagName, 'added' => $totalTagCount, 'notAdded' => $addTagCount[2] + $addRelTagCount[2], 'new' => $new);
}
$this->set('tagAdditions', $tagAdditions);
}
// add all the necessary variables to the form
$parser->set($this, CRM_Import_Parser::MODE_IMPORT);
// check if there is any error occured
$errorStack = CRM_Core_Error::singleton();
$errors = $errorStack->getErrors();
$errorMessage = array();
if (is_array($errors)) {
foreach ($errors as $key => $value) {
$errorMessage[] = $value['message'];
}
// there is no fileName since this is a sql import
// so fudge it
$config = CRM_Core_Config::singleton();
$errorFile = $config->uploadDir . "sqlImport.error.log";
if ($fd = fopen($errorFile, 'w')) {
fwrite($fd, implode('\\n', $errorMessage));
}
fclose($fd);
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contact_Import_Parser';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlparams));
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contact_Import_Parser';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contact_Import_Parser';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Preview.php
示例9: civicrm_entity_tag_common
/**
*
* @param <type> $params
* @param <type> $op
*
* @return <type>
*/
function civicrm_entity_tag_common(&$params, $op = 'add')
{
$entityIDs = array();
$tagsIDs = array();
$entityTable = 'civicrm_contact';
if (is_array($params)) {
foreach ($params as $n => $v) {
if (substr($n, 0, 10) == 'contact_id' || substr($n, 0, 9) == 'entity_id') {
$entityIDs[] = $v;
} elseif (substr($n, 0, 6) == 'tag_id') {
$tagIDs[] = $v;
} elseif (substr($n, 0, 12) == 'entity_table') {
$entityTable = $v;
}
}
}
if (empty($entityIDs)) {
return civicrm_create_error(ts('contact_id is a required field'));
}
if (empty($tagIDs)) {
return civicrm_create_error(ts('tag_id is a required field'));
}
require_once 'CRM/Core/BAO/EntityTag.php';
$values = array('is_error' => 0);
if ($op == 'add') {
$values['total_count'] = $values['added'] = $values['not_added'] = 0;
foreach ($tagIDs as $tagID) {
list($te, $a, $na) = CRM_Core_BAO_EntityTag::addEntitiesToTag($entityIDs, $tagID, $entityTable);
$values['total_count'] += $te;
$values['added'] += $a;
$values['not_added'] += $na;
}
} else {
$values['total_count'] = $values['removed'] = $values['not_removed'] = 0;
foreach ($tagIDs as $tagID) {
list($te, $r, $nr) = CRM_Core_BAO_EntityTag::removeEntitiesFromTag($entityIDs, $tagID, $entityTable);
$values['total_count'] += $te;
$values['removed'] += $r;
$values['not_removed'] += $nr;
}
}
return $values;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:50,代码来源:EntityTag.php
示例10: getValues
//.........这里部分代码省略.........
$idx = $name . '_id';
$params[$index] = $details->{$idx};
} elseif ($name === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
$compref = array();
$pref = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name});
foreach ($pref as $k) {
if ($k) {
$compref[] = $communicationFields[$k];
}
}
$params[$index] = $details->{$name};
$values[$index] = implode(',', $compref);
} elseif ($name === 'preferred_language') {
$params[$index] = $details->{$name};
$values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $details->{$name});
} elseif ($name == 'group') {
$groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', NULL, FALSE, TRUE);
$title = $ids = array();
foreach ($groups as $g) {
// CRM-8362: User and User Admin visibility groups should be included in display if user has
// VIEW permission on that group
$groupPerm = CRM_Contact_BAO_Group::checkPermission($g['group_id'], $g['title']);
if ($g['visibility'] != 'User and User Admin Only' || CRM_Utils_Array::key(CRM_Core_Permission::VIEW, $groupPerm)) {
$title[] = $g['title'];
if ($g['visibility'] == 'Public Pages') {
$ids[] = $g['group_id'];
}
}
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $ids);
} elseif ($name == 'tag') {
$entityTags = CRM_Core_BAO_EntityTag::getTag($cid);
$allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
$title = array();
foreach ($entityTags as $tagId) {
$title[] = $allTags[$tagId];
}
$values[$index] = implode(', ', $title);
$params[$index] = implode(',', $entityTags);
} elseif ($name == 'activity_status_id') {
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$values[$index] = $activityStatus[$details->{$name}];
$params[$index] = $details->{$name};
} elseif ($name == 'activity_date_time') {
$values[$index] = CRM_Utils_Date::customFormat($details->{$name});
$params[$index] = $details->{$name};
} elseif ($name == 'contact_sub_type') {
$contactSubTypeNames = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->{$name});
if (!empty($contactSubTypeNames)) {
$contactSubTypeLabels = array();
// get all contact subtypes
$allContactSubTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
// build contact subtype labels array
foreach ($contactSubTypeNames as $cstName) {
if ($cstName) {
$contactSubTypeLabels[] = $allContactSubTypes[$cstName]['label'];
}
}
$values[$index] = implode(',', $contactSubTypeLabels);
}
$params[$index] = $details->{$name};
} else {
if (substr($name, 0, 7) === 'do_not_' || substr($name, 0, 3) === 'is_') {
if ($details->{$name}) {
开发者ID:rollox,项目名称:civicrm-core,代码行数:67,代码来源:UFGroup.php
示例11: postProcess
//.........这里部分代码省略.........
$mapperRelatedContactPhoneType[$key] = null;
}
}
$parser =& new CRM_Import_Parser_Contact($mapperKeys, $mapperLocTypes, $mapperPhoneTypes, $mapperRelated, $mapperRelatedContactType, $mapperRelatedContactDetails, $mapperRelatedContactLocType, $mapperRelatedContactPhoneType);
$mapFields = $this->get('fields');
$locationTypes = CRM_Core_PseudoConstant::locationType();
$phoneTypes = CRM_Core_SelectValues::phoneType();
foreach ($mapper as $key => $value) {
$header = array();
list($id, $first, $second) = explode('_', $mapper[$key][0]);
if ($first == 'a' && $second == 'b' || $first == 'b' && $second == 'a') {
$relationType =& new CRM_Contact_DAO_RelationshipType();
$relationType->id = $id;
$relationType->find(true);
$header[] = $relationType->name_a_b;
$header[] = ucwords(str_replace("_", " ", $mapper[$key][1]));
if (isset($mapper[$key][2])) {
$header[] = $locationTypes[$mapper[$key][2]];
}
if (isset($mapper[$key][3])) {
$header[] = $phoneTypes[$mapper[$key][3]];
}
} else {
if (isset($mapFields[$mapper[$key][0]])) {
$header[] = $mapFields[$mapper[$key][0]];
if (isset($mapper[$key][1])) {
$header[] = $locationTypes[$mapper[$key][1]];
}
if (isset($mapper[$key][2])) {
$header[] = $phoneTypes[$mapper[$key][2]];
}
}
}
$mapperFields[] = implode(' - ', $header);
}
$parser->run($fileName, $seperator, $mapperFields, $skipColumnHeader, CRM_IMPORT_PARSER_MODE_IMPORT, $this->get('contactType'), $onDuplicate);
// add the new contacts to selected groups
$contactIds =& $parser->getImportedContacts();
// add the new related contacts to selected groups
$relatedContactIds =& $parser->getRelatedImportedContacts();
$this->set('relatedCount', count($relatedContactIds));
$newGroupId = null;
//changed below if-statement "if ($newGroup) {" to "if ($newGroupName) {"
if ($newGroupName) {
/* Create a new group */
$gParams = array('domain_id' => CRM_Core_Config::domainID(), 'name' => $newGroupName, 'title' => $newGroupName, 'description' => $newGroupDesc, 'is_active' => true);
$group =& CRM_Contact_BAO_Group::create($gParams);
$groups[] = $newGroupId = $group->id;
}
if (is_array($groups)) {
$groupAdditions = array();
foreach ($groups as $groupId) {
$addCount =& CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId);
if (!empty($relatedContactIds)) {
$addRelCount =& CRM_Contact_BAO_GroupContact::addContactsToGroup($relatedContactIds, $groupId);
}
$totalCount = $addCount[1] + $addRelCount[1];
if ($groupId == $newGroupId) {
$name = $newGroupName;
$new = true;
} else {
$name = $allGroups[$groupId];
$new = false;
}
$groupAdditions[] = array('url' => CRM_Utils_System::url('civicrm/group/search', 'reset=1&force=1&context=smog&gid=' . $groupId), 'name' => $name, 'added' => $totalCount, 'notAdded' => $addCount[2], 'new' => $new);
}
$this->set('groupAdditions', $groupAdditions);
}
if (is_array($tagForContact)) {
$tagAddition = array();
require_once "CRM/Core/BAO/EntityTag.php";
foreach ($tagForContact as $tagId => $selected) {
$taggedContacts = CRM_Core_BAO_EntityTag::addContactsToTag($contactIds, $tagId);
$tagName = $allTags[$tagId];
$tagAdditions[] = array('name' => $tagName, 'added' => $taggedContacts[1], 'notAdded' => $taggedContacts[2]);
}
$this->set('tagAdditions', $tagAdditions);
}
// add all the necessary variables to the form
$parser->set($this, CRM_IMPORT_PARSER_MODE_IMPORT);
// check if there is any error occured
$errorStack =& CRM_Core_Error::singleton();
$errors = $errorStack->getErrors();
$errorMessage = array();
$config =& CRM_Core_Config::singleton();
if (is_array($errors)) {
foreach ($errors as $key => $value) {
$errorMessage[] = $value['message'];
}
$errorFile = $fileName . '.error.log';
if ($fd = fopen($errorFile, 'w')) {
fwrite($fd, implode('\\n', $errorMessage));
}
fclose($fd);
$this->set('errorFile', $errorFile);
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=1'));
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=2'));
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', 'type=4'));
}
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:101,代码来源:Preview.php
示例12: setDefaults
/**
* set defaults for relevant form elements
*
* @param int $id the contact id
* @param array $defaults the defaults array to store the values in
* @param int $type what components are we interested in
* @param string $fieldName this is used in batch profile(i.e to build multiple blocks)
*
* @return void
* @access public
* @static
*/
static function setDefaults($id, &$defaults, $type = CRM_Contact_Form_Edit_TagsandGroups::ALL, $fieldName = null)
{
$type = (int) $type;
if ($type & self::GROUP) {
$fName = 'group';
if ($fieldName) {
$fName = $fieldName;
}
require_once 'CRM/Contact/BAO/GroupContact.php';
$contactGroup =& CRM_Contact_BAO_GroupContact::getContactGroup($id, 'Added', null, false, true);
if ($contactGroup) {
foreach ($contactGroup as $group) {
$defaults[$fName . "[" . $group['group_id'] . "]"] = 1;
}
}
}
if ($type & self::TAG) {
$fName = 'tag';
if ($fieldName) {
$fName = $fieldName;
}
require_once 'CRM/Core/BAO/EntityTag.php';
$contactTag =& CRM_Core_BAO_EntityTag::getTag($id);
if ($contactTag) {
foreach ($contactTag as $tag) {
$defaults[$fName . "[" . $tag . "]"] = 1;
}
}
}
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:42,代码来源:TagsAndGroups.php
示例13: create
/**
* Takes an associative array and creates tag entity record for all tag entities.
*
* @param array $params
* (reference) an assoc array of name/value pairs.
* @param $entityTable
* @param int $entityID
*
* @return void
*/
public static function create(&$params, $entityTable, $entityID)
{
// get categories for the entity id
$entityTag = CRM_Core_BAO_EntityTag::getTag($entityID, $entityTable);
// get the list of all the categories
$allTag = CRM_Core_BAO_Tag::getTags($entityTable);
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($params)) {
$params = array();
}
// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($entityTag)) {
$entityTag = array();
}
// check which values has to be inserted/deleted for contact
foreach ($allTag as $key => $varValue) {
$tagParams['entity_table'] = $entityTable;
$tagParams['entity_id'] = $entityID;
$tagParams['tag_id'] = $key;
if (array_key_exists($key, $params) && !array_key_exists($key, $entityTag)) {
// insert a new record
CRM_Core_BAO_EntityTag::add($tagParams);
} elseif (!array_key_exists($key, $params) && array_key_exists($key, $entityTag)) {
// delete a record for existing contact
CRM_Core_BAO_EntityTag::del($tagParams);
}
}
}
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:38,代码来源:EntityTag.php
示例14: mergeTags
static function mergeTags()
{
$tagAId = CRM_Utils_Type::escape($_POST['fromId'], 'Integer');
$tagBId = CRM_Utils_Type::escape($_POST['toId'], 'Integer');
$result = CRM_Core_BAO_EntityTag::mergeTags($tagAId, $tagBId);
if (!empty($result['tagB_used_for'])) {
$usedFor = CRM_Core_OptionGroup::values('tag_used_for');
foreach ($result['tagB_used_for'] as &$val) {
$val = $usedFor[$val];
}
$result['tagB_used_for'] = implode(', ', $result['tagB_used_for']);
}
$result['message'] = ts('"%1" has been merged with "%2". All records previously tagged "%1" are now tagged "%2".', array(1 => $result['tagA'], 2 => $result['tagB']));
CRM_Utils_JSON::output($result);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:15,代码来源:AJAX.php
示例15: view
/**
* View summary details of a contact.
*/
public function view()
{
// Add js for tabs, in-place editing, and jstree for tags
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js', 2, 'html-header')->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')->addSetting(array('summaryPrint' => array('mode' => $this->_print), 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary'))));
$this->assign('summaryPrint', $this->_print);
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
$session->pushUserContext($url);
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE;
|
请发表评论