本文整理汇总了PHP中CRM_Contact_BAO_GroupContact类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_GroupContact类的具体用法?PHP CRM_Contact_BAO_GroupContact怎么用?PHP CRM_Contact_BAO_GroupContact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Contact_BAO_GroupContact类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* called when action is browse.
*
*/
public function browse()
{
$in = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
// keep track of all 'added' contact groups so we can remove them from the smart group
// section
$staticGroups = array();
if (!empty($in)) {
foreach ($in as $group) {
$staticGroups[$group['group_id']] = 1;
}
}
$allGroup = CRM_Contact_BAO_GroupContactCache::contactGroup($this->_contactId);
$this->assign('groupSmart', NULL);
$this->assign('groupParent', NULL);
if (!empty($allGroup)) {
$smart = $parent = array();
foreach ($allGroup['group'] as $group) {
// delete all smart groups which are also in static groups
if (isset($staticGroups[$group['id']])) {
continue;
}
if (empty($group['children'])) {
$smart[] = $group;
} else {
$parent[] = $group;
}
}
if (!empty($smart)) {
$this->assign_by_ref('groupSmart', $smart);
}
if (!empty($parent)) {
$this->assign_by_ref('groupParent', $parent);
}
}
}
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:39,代码来源:ContactSmartGroup.php
示例2: browse
/**
* called when action is browse.
*
* @return void
*/
public function browse()
{
$count = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, NULL, NULL, TRUE, TRUE, $this->_onlyPublicGroups);
$in =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added', NULL, FALSE, TRUE, $this->_onlyPublicGroups);
$pending =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Pending', NULL, FALSE, TRUE, $this->_onlyPublicGroups);
$out =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Removed', NULL, FALSE, TRUE, $this->_onlyPublicGroups);
$this->assign('groupCount', $count);
$this->assign_by_ref('groupIn', $in);
$this->assign_by_ref('groupPending', $pending);
$this->assign_by_ref('groupOut', $out);
}
开发者ID:kidaa30,项目名称:yes,代码行数:16,代码来源:GroupContact.php
示例3: confirm
/**
* Confirm a pending subscription
*
* @param int $contact_id The id of the contact
* @param int $subscribe_id The id of the subscription event
* @param string $hash The hash
*
* @return boolean True on success
* @access public
* @static
*/
public static function confirm($contact_id, $subscribe_id, $hash)
{
$se =& CRM_Mailing_Event_BAO_Subscribe::verify($contact_id, $subscribe_id, $hash);
if (!$se) {
return FALSE;
}
// before we proceed lets just check if this contact is already 'Added'
// if so, we should ignore this request and hence avoid sending multiple
// emails - CRM-11157
$details = CRM_Contact_BAO_GroupContact::getMembershipDetail($contact_id, $se->group_id);
if ($details && $details->status == 'Added') {
// This contact is already subscribed
// lets return the group title
return CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $se->group_id, 'title');
}
$transaction = new CRM_Core_Transaction();
$ce = new CRM_Mailing_Event_BAO_Confirm();
$ce->event_subscribe_id = $se->id;
$ce->time_stamp = date('YmdHis');
$ce->save();
CRM_Contact_BAO_GroupContact::addContactsToGroup(array($contact_id), $se->group_id, 'Email', 'Added', $ce->id);
$transaction->commit();
$config = CRM_Core_Config::singleton();
$domain = CRM_Core_BAO_Domain::getDomain();
list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();
list($display_name, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($se->contact_id);
$group = new CRM_Contact_DAO_Group();
$group->id = $se->group_id;
$group->find(TRUE);
$component = new CRM_Mailing_BAO_Component();
$component->is_default = 1;
$component->is_active = 1;
$component->component_type = 'Welcome';
$component->find(TRUE);
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$html = $component->body_html;
if ($component->body_text) {
$text = $component->body_text;
} else {
$text = CRM_Utils_String::htmlToText($component->body_html);
}
$bao = new CRM_Mailing_BAO_Mailing();
$bao->body_text = $text;
$bao->body_html = $html;
$tokens = $bao->getTokens();
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
$html = CRM_Utils_Token::replaceWelcomeTokens($html, $group->title, TRUE);
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
$text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->title, FALSE);
$mailParams = array('groupName' => 'Mailing Event ' . $component->component_type, 'subject' => $component->subject, 'from' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'toEmail' => $email, 'toName' => $display_name, 'replyTo' => "do-not-reply@{$emailDomain}", 'returnPath' => "do-not-reply@{$emailDomain}", 'html' => $html, 'text' => $text);
// send - ignore errors because the desired status change has already been successful
$unused_result = CRM_Utils_Mail::send($mailParams);
return $group->title;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:65,代码来源:Confirm.php
示例4: postProcess
/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess()
{
$groupId = $this->controller->exportValue('RemoveFromGroup', 'group_id');
$group = CRM_Core_PseudoConstant::group();
list($total, $removed, $notRemoved) = CRM_Contact_BAO_GroupContact::removeContactsFromGroup($this->_contactIds, $groupId);
$status = array(ts("%count contact removed from '%2'", array('count' => $removed, 'plural' => "%count contacts removed from '%2'", 2 => $group[$groupId])));
if ($notRemoved) {
$status[] = ts('1 contact was already not in this group', array('count' => $notRemoved, 'plural' => '%count contacts were already not in this group'));
}
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
CRM_Core_Session::setStatus($status, ts("Removed Contact From Group", array('plural' => "Removed Contacts From Group", 'count' => $removed)), 'success', array('expires' => 0));
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:15,代码来源:RemoveFromGroup.php
示例5: testForceCiviToMailchimpSyncNullEmail
function testForceCiviToMailchimpSyncNullEmail()
{
$mailchimp_sync_setting = CRM_CiviMailchimp_BAO_SyncSettingsTest::createTestGroupAndSyncSettings('Test Group testForceCiviToMailchimpSyncNullEmail');
$params = CRM_CiviMailchimp_UtilsTest::sampleContactParams();
unset($params['email']);
$contact = CRM_Contact_BAO_Contact::create($params);
$contact_ids = array($contact->id);
CRM_Contact_BAO_GroupContact::addContactsToGroup($contact_ids, $mailchimp_sync_setting->civicrm_group_id);
$contacts = CRM_CiviMailchimp_Form_Sync::forceCiviToMailchimpSync($mailchimp_sync_setting);
$mailchimp_api_subscribe = civimailchimp_static('mailchimp_api_subscribe');
$this->assertCount(0, $contacts);
$this->assertNull($mailchimp_api_subscribe);
}
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:13,代码来源:SyncTest.php
示例6: contactIsMemberOfAllGroups
protected function contactIsMemberOfAllGroups($contact_id, $group_ids)
{
$isValid = 0;
foreach ($group_ids as $gid) {
if (CRM_Contact_BAO_GroupContact::isContactInGroup($contact_id, $gid)) {
$isValid++;
}
}
if (count($group_ids) == $isValid && count($group_ids) > 0) {
return true;
}
return false;
}
开发者ID:Kajakaran,项目名称:org.civicoop.civirules,代码行数:13,代码来源:InGroup.php
示例7: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
function postProcess()
{
$groupId = $this->controller->exportValue('RemoveFromGroup', 'group_id');
$group =& CRM_Core_PseudoConstant::group();
list($total, $removed, $notRemoved) = CRM_Contact_BAO_GroupContact::removeContactsFromGroup($this->_contactIds, $groupId);
$status = array(ts('Removed Contact(s) from %1', array(1 => $group[$groupId])), ts('Total Selected Contact(s): %1', array(1 => $total)));
if ($removed) {
$status[] = ts('Total Contact(s) removed from group: %1', array(1 => $removed));
}
if ($notRemoved) {
$status[] = ts('Total Contact(s) not in group: %1', array(1 => $notRemoved));
}
CRM_Core_Session::setStatus($status);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:20,代码来源:RemoveFromGroup.php
示例8: testFindByContactId
function testFindByContactId()
{
$expected_mailchimp_sync_setting = self::createTestGroupAndSyncSettings('Test group testFindByContactId');
$params = CRM_CiviMailchimp_UtilsTest::sampleContactParams();
$contact = CRM_Contact_BAO_Contact::create($params);
$contact_ids = array($contact->id);
CRM_Contact_BAO_GroupContact::addContactsToGroup($contact_ids, $expected_mailchimp_sync_setting->civicrm_group_id);
$mailchimp_sync_settings = CRM_CiviMailchimp_BAO_SyncSettings::findByContactId($contact->id);
$mailchimp_sync_setting = $mailchimp_sync_settings[$expected_mailchimp_sync_setting->civicrm_group_id];
$this->assertEquals($expected_mailchimp_sync_setting->id, $mailchimp_sync_setting->id);
$this->assertEquals($expected_mailchimp_sync_setting->civicrm_group_id, $mailchimp_sync_setting->civicrm_group_id);
$this->assertEquals($expected_mailchimp_sync_setting->mailchimp_list_id, $mailchimp_sync_setting->mailchimp_list_id);
$this->assertEquals($expected_mailchimp_sync_setting->mailchimp_interest_groups, $mailchimp_sync_setting->mailchimp_interest_groups);
}
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:14,代码来源:SyncSettingsTest.php
示例9: confirm
/**
* Confirm a pending subscription
*
* @param int $contact_id The id of the contact
* @param int $subscribe_id The id of the subscription event
* @param string $hash The hash
* @return boolean True on success
* @access public
* @static
*/
function confirm($contact_id, $subscribe_id, $hash)
{
$se =& CRM_Mailing_Event_BAO_Subscribe::verify($contact_id, $subscribe_id, $hash);
if (!$se) {
return false;
}
CRM_Core_DAO::transaction('BEGIN');
$ce =& new CRM_Mailing_Event_BAO_Confirm();
$ce->event_subscribe_id = $se->id;
$ce->time_stamp = date('YmdHis');
$ce->save();
CRM_Contact_BAO_GroupContact::updateGroupMembershipStatus($contact_id, $se->group_id, 'Email', $ce->id);
CRM_Core_DAO::transaction('COMMIT');
$config =& CRM_Core_Config::singleton();
$domain =& CRM_Mailing_Event_BAO_Subscribe::getDomain($subscribe_id);
list($display_name, $email) = CRM_Contact_BAO_Contact::getEmailDetails($se->contact_id);
$group =& new CRM_Contact_DAO_Group();
$group->id = $se->group_id;
$group->find(true);
require_once 'CRM/Mailing/BAO/Component.php';
$component =& new CRM_Mailing_BAO_Component();
$component->domain_id = $domain->id;
$component->is_default = 1;
$component->is_active = 1;
$component->component_type = 'Welcome';
$component->find(true);
$headers = array('Subject' => $component->subject, 'From' => ts('"%1 Administrator" <do-not-reply@%2>', array(1 => $domain->name, 2 => $domain->email_domain)), 'To' => $email, 'Reply-To' => "do-not-reply@{$domain->email_domain}", 'Return-Path' => "do-not-reply@{$domain->email_domain}");
$html = $component->body_html;
require_once 'CRM/Utils/Token.php';
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, true);
$html = CRM_Utils_Token::replaceWelcomeTokens($html, $group->name, true);
$text = $component->body_text;
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, false);
$text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->name, false);
$message =& new Mail_Mime("\n");
$message->setHTMLBody($html);
$message->setTxtBody($text);
$b = $message->get();
$h = $message->headers($headers);
$mailer =& $config->getMailer();
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Mailing_BAO_Mailing', 'catchSMTP'));
$mailer->send($email, $h, $b);
CRM_Core_Error::setCallback();
return true;
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:55,代码来源:Confirm.php
示例10: getGroups
/**
* Method to get groups
*
* @return array
* @access protected
*/
protected function getGroups()
{
return array('' => ts('-- please select --')) + CRM_Contact_BAO_GroupContact::getGroupList();
}
开发者ID:alejandro-ixiam,项目名称:org.civicoop.civirules,代码行数:10,代码来源:GroupId.php
示例11: add2group
/**
* @param int $groupID
*/
public function add2group($groupID)
{
if (is_numeric($groupID)) {
$sql = "\n{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}\nORDER BY civicrm_contribution_total_amount_sum DESC\n) as abc {$this->_groupLimit}";
$dao = CRM_Core_DAO::executeQuery($sql);
$contact_ids = array();
// Add resulting contacts to group
while ($dao->fetch()) {
$contact_ids[$dao->civicrm_contact_id] = $dao->civicrm_contact_id;
}
CRM_Contact_BAO_GroupContact::addContactsToGroup($contact_ids, $groupID);
CRM_Core_Session::setStatus(ts("Listed contact(s) have been added to the selected group."), ts('Contacts Added'), 'success');
}
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:17,代码来源:TopDonor.php
示例12: civicrm_api3_group_contact_update_status
/**
* Update group contact status.
*
* @deprecated - this should be part of create but need to know we aren't missing something
*
* @param array $params
*
* @return bool
* @throws \API_Exception
*/
function civicrm_api3_group_contact_update_status($params)
{
civicrm_api3_verify_mandatory($params, NULL, array('contact_id', 'group_id'));
CRM_Contact_BAO_GroupContact::addContactsToGroup(array($params['contact_id']), $params['group_id'], CRM_Utils_Array::value('method', $params, 'API'), 'Added', CRM_Utils_Array::value('tracking', $params));
return TRUE;
}
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:16,代码来源:GroupContact.php
示例13: displayProfile
//.........这里部分代码省略.........
if ('gender' == substr($name, 0, 6)) {
$gender = CRM_Core_PseudoConstant::gender();
$values[$index] = $gender[$params[$name]];
} else {
if ('individual_prefix' == substr($name, 0, 17)) {
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$values[$index] = $prefix[$params[$name]];
} else {
if ('individual_suffix' == substr($name, 0, 17)) {
$suffix = CRM_Core_PseudoConstant::individualSuffix();
$values[$index] = $suffix[$params[$name]];
} else {
if (in_array($name, array('addressee', 'email_greeting', 'postal_greeting'))) {
$filterCondition = array('greeting_type' => $name);
$greeting =& CRM_Core_PseudoConstant::greeting($filterCondition);
$values[$index] = $greeting[$params[$name]];
} else {
if ($name === 'preferred_communication_method') {
$communicationFields = CRM_Core_PseudoConstant::pcm();
$pref = array();
$compref = array();
$pref = $params[$name];
if (is_array($pref)) {
foreach ($pref as $k => $v) {
if ($v) {
$compref[] = $communicationFields[$k];
}
}
}
$values[$index] = implode(",", $compref);
} else {
if ($name == 'group') {
require_once 'CRM/Contact/BAO/GroupContact.php';
$groups = CRM_Contact_BAO_GroupContact::getGroupList();
$title = array();
foreach ($params[$name] as $gId => $dontCare) {
if ($dontCare) {
$title[] = $groups[$gId];
}
}
$values[$index] = implode(', ', $title);
} else {
if ($name == 'tag') {
require_once 'CRM/Core/BAO/EntityTag.php';
$entityTags = $params[$name];
$allTags =& CRM_Core_PseudoConstant::tag();
$title = array();
if (is_array($entityTags)) {
foreach ($entityTags as $tagId => $dontCare) {
$title[] = $allTags[$tagId];
}
}
$values[$index] = implode(', ', $title);
} else {
if ('participant_role_id' == $name) {
$roles = CRM_Event_PseudoConstant::participantRole();
$values[$index] = $roles[$params[$name]];
} else {
if ('participant_status_id' == $name) {
$status = CRM_Event_PseudoConstant::participantStatus();
$values[$index] = $status[$params[$name]];
} else {
if (strpos($name, '-') !== false) {
list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2);
$detailName = str_replace(' ', '_', $name);
if (in_array($fieldName, array('state_province', 'country', 'county'))) {
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:67,代码来源:Event.php
示例14: 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()
{
$template = CRM_Core_Smarty::singleton();
if ($this->_id && $this->_gid) {
// first check that id is part of the limit group id, CRM-4822
$limitListingsGroupsID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'limit_listings_group_id');
$config = CRM_Core_Config::singleton();
if ($limitListingsGroupsID) {
if (!CRM_Contact_BAO_GroupContact::isContactInGroup($this->_id, $limitListingsGroupsID)) {
CRM_Utils_System::setTitle(ts('Profile View - Permission Denied'));
return CRM_Core_Session::setStatus(ts('You do not have permission to view this contact record. Contact the site administrator if you need assistance.'), ts('Permission Denied'), 'error');
}
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$this->_isPermissionedChecksum = $allowPermission = FALSE;
$permissionType = CRM_Core_Permission::VIEW;
if (CRM_Core_Permission::check('administer users') || CRM_Core_Permission::check('view all contacts') || CRM_Contact_BAO_Contact_Permission::allow($this->_id)) {
$allowPermission = TRUE;
}
if ($this->_id != $userID) {
// do not allow edit for anon users in joomla frontend, CRM-4668, unless u have checksum CRM-5228
if ($config->userFrameworkFrontend) {
$this->_isPermissionedChecksum = CRM_Contact_BAO_Contact_Permission::validateOnlyChecksum($this->_id, $this, FALSE);
if (!$this->_isPermissionedChecksum) {
$this->_isPermissionedChecksum = $allowPermission;
}
} else {
$this->_isPermissionedChecksum = CRM_Contact_BAO_Contact_Permission::validateChecksumContact($this->_id, $this, FALSE);
}
}
// CRM-10853
// Users with create or edit permission should be allowed to view their own profile
if ($this->_id == $userID || $this->_isPermissionedChecksum) {
if (!CRM_Core_Permission::check('profile view')) {
if (CRM_Core_Permission::check('profile create') || CRM_Core_Permission::check('profile edit')) {
$this->_skipPermission = TRUE;
}
}
}
// make sure we dont expose all fields based on permission
$admin = FALSE;
if (!$config->userFrameworkFrontend && $allowPermission || $this->_id == $userID || $this->_isPermissionedChecksum) {
$admin = TRUE;
}
$values = array();
$fields = CRM_Core_BAO_UFGroup::getFields($this->_profileIds, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, $this->_restrict, $this->_skipPermission, NULL, $permissionType);
if ($this->_multiRecord & CRM_Core_Action::VIEW && $this->_recordId && !$this->_allFields) {
CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields);
$fields = $multiRecordFields;
}
if ($this->_isContactActivityProfile && $this->_gid) {
$errors = CRM_Profile_Form::validateContactActivityProfile($this->_activityId, $this->_id, $this->_gid);
if (!empty($errors)) {
CRM_Core_Error::fatal(array_pop($errors));
}
}
//reformat fields array
foreach ($fields as $name => $field) {
// also eliminate all formatting fields
if (CRM_Utils_Array::value('field_type', $field) == 'Formatting') {
unset($fields[$name]);
}
// make sure that there is enough permission to expose this field
if (!$admin && $field['visibility'] == 'User and User Admin Only') {
unset($fields[$name]);
}
}
if ($this->_isContactActivityProfile) {
$contactFields = $activityFields = array();
foreach ($fields as $fieldName => $field) {
if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
$activityFields[$fieldName] = $field;
} else {
$contactFields[$fieldName] = $field;
}
}
CRM_Core_BAO_UFGroup::getValues($this->_id, $contactFields, $values);
if ($this->_activityId) {
CRM_Core_BAO_UFGroup::getValues(NULL, $activityFields, $values, TRUE, array(array('activity_id', '=', $this->_activityId, 0, 0)));
}
} else {
$customWhereClause = NULL;
if ($this->_multiRecord & CRM_Core_Action::VIEW && $this->_recordId) {
if ($this->_allFields) {
$copyFields = $fields;
CRM_Core_BAO_UFGroup::shiftMultiRecordFields($copyFields, $multiRecordFields);
$fieldKey = key($multiRecordFields);
} else {
$fieldKey = key($fields);
}
if ($fieldID = CRM_Core_BAO_CustomField::getKeyID($fieldKey)) {
//.........这里部分代码省略.........
开发者ID:sarehag,项目名称:civicrm-core,代码行数:101,代码来源:Dynamic.php
示例15: postProcessOld
//.........这里部分代码省略.........
}
} 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);
}
$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];
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:67,代码来源:Preview.php
示例16: getValues
/**
* Given a contact id and a field set, return the values from the db
* for this contact
*
* @param int $cid
* @param array $fields
* The profile fields of interest.
* @param array $values
* The values for the above fields.
* @param bool $searchable
* Searchable or not.
* @param array $componentWhere
* Component condition.
* @param bool $absolute
* Return urls in absolute form (useful when sending an email).
* @param null $additionalWhereClause
*/
public static function getValues($cid, &$fields, &$values, $searchable = TRUE, $componentWhere = NULL, $absolute = FALSE, $additionalWhereClause = NULL)
{
if (empty($cid) && empty($componentWhere)) {
return NULL;
}
// get the contact details (hier)
$returnProperties = CRM_Contact_BAO_Contact::makeHierReturnProperties($fields);
$params = $cid ? array(array('contact_id', '=', $cid, 0, 0)) : array();
// add conditions specified by components. eg partcipant_id etc
if (!empty($componentWhere)) {
$params = array_merge($params, $componentWhere);
}
$query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields);
$options =& $query->_options;
$details = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $additionalWhereClause);
if (!$details->fetch()) {
return;
}
$query->convertToPseudoNames($details);
$config = CRM_Core_Config::singleton();
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
$websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id');
$multipleFields = array('url');
//start of code to set the default values
foreach ($fields as $name => $field) {
// fix for CRM-3962
if ($name == 'id') {
$name = 'contact_id';
}
// skip fields that should not be displayed separately
if (!empty($field['skipDisplay'])) {
continue;
}
// Create a unique, non-empty index for each field.
$index = $field['title'];
if ($index === '') {
$index = ' ';
}
while (array_key_exists($index, $values)) {
$index .= ' ';
}
$params[$index] = $values[$index] = '';
$customFieldName = NULL;
// hack for CRM-665
if (isset($details->{$name}) || $name == 'group' || $name == 'tag') {
// to handle gender / suffix / prefix
if (in_array(substr($name, 0, -3), array('gender', 'prefix', 'suffix'))) {
$params[$index] = $details->{$name};
$values[$index] = $details->{$name};
} elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)) {
$dname = $name . '_display';
$values[$index] = $details->{$dname};
$name = $name . '_id';
$params[$index] = $details->{$name};
} elseif (in_array($name, array('state_province', 'country', 'county'))) {
$values[$index] = $details->{$name};
$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') {
//.........这里部分代码省略.........
开发者ID:rollox,项目名称:civicrm-core,代码行数:101,代码来源:UFGroup.php
示例17: CRM_ACL_BAO_ACL
/**
* Get all of the ACLs for a contact through ACL groups owned by Contact
* groups.
*
* @param int $contact_id - ID of a contact to search for
*
* @return array - Array of assoc. arrays of ACL rules
* @access public
* @static
*/
public static function &getGroupACLRoles($contact_id)
{
$contact_id = CRM_Utils_Type::escape($contact_id, 'Integer');
$rule = new CRM_ACL_BAO_ACL();
$acl = self::getTableName();
$aclRole = 'civicrm_acl_role';
$aclER = CRM_ACL_DAO_EntityRole::getTableName();
$c2g = CRM_Contact_BAO_GroupContact::getTableName();
$group = CRM_Contact_BAO_Group::getTableName();
$query = " SELECT {$acl}.*\n FROM {$acl}\n INNER JOIN civicrm_option_group og\n ON og.name = 'acl_role'\n INNER JOIN civicrm_option_value ov\n ON {$acl}.entity_table = '{$aclRole}'\n AND ov.option_group_id = og.id\n AND {$acl}.entity_id = ov.value\n AND ov.is_active = 1\n INNER JOIN {$aclER}\n ON {$aclER}.acl_role_id = {$acl}.entity_id\n AND {$aclER}.is_active = 1\n INNER JOIN {$c2g}\n ON {$aclER}.entity_id = {$c2g}.group_id\n AND {$aclER}.entity_table = 'civicrm_group'\n WHERE {$acl}.entity_table = '{$aclRole}'\n AND {$acl}.is_active = 1\n AND {$c2g}.contact_id = {$contact_id}\n AND {$c2g}.status = 'Added'";
$results = array();
$rule->query($query);
while ($rule->fetch()) {
$results[$rule->id] =& $rule->toArray();
}
// also get all acls for "Any Role" case
// and authenticated User Role if present
$roles = "0";
$session = CRM_Core_Session::singleton();
if ($session->get('ufID') > 0) {
$roles .= ",2";
}
$query = "\nSELECT {$acl}.*\n FROM {$acl}\n WHERE {$acl}.entity_id IN ( {$roles} )\n AND {$acl}.entity_table = 'civicrm_acl_role'\n";
$rule->query($query);
while ($rule->fetch()) {
$results[$rule->id] =& $rule->toArray();
}
return $results;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:39,代码来源:ACL.php
示例18: postProcess
/**
* Form submission of new/edit contact is processed.
*
* @access public
* @return None
*/
public function postProcess()
{
// check if dedupe button, if so return.
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->_dedupeButtonName) {
return;
}
//get the submitted values in an array
$params = $this->controller->exportValues($this->_name);
//get the related id for shared / current employer
if (CRM_Utils_Array::value('shared_household_id', $params)) {
$params['shared_household'] = $params['shared_household_id'];
}
if (is_numeric(CRM_Utils_Array::value('current_employer_id', $params)) && CRM_Utils_Array::value('current_employer', $params)) {
$params['current_employer'] = $params['current_employer_id'];
}
// don't carry current_employer_id field,
// since we don't want to directly update DAO object without
// handling related business logic ( eg related membership )
if (isset($params['current_employer_id'])) {
unset($params['current_employer_id']);
}
$params['contact_type'] = $this->_contactType;
if ($this->_contactId) {
$params['contact_id'] = $this->_contactId;
}
//make deceased date null when is_deceased = false
if ($this->_contactType == 'Individual' && CRM_Utils_Array::value('Demographics', $this->_editOptions) && !CRM_Utils_Array::value('is_deceased', $params)) {
$params['is_deceased'] = false;
$params['deceased_date'] = null;
}
if ($this->_contactSubType && $this->_action & CRM_Core_Action::ADD) {
$params['contact_sub_type'] = $this->_contactSubType;
}
// action is taken depending upon the mode
require_once 'CRM/Utils/Hook.php';
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_Hook::pre('edit', $params['contact_type'], $params['contact_id'], $params);
} else {
CRM_Utils_Hook::pre('create', $params['contact_type'], null, $params);
}
require_once 'CRM/Core/BAO/CustomField.php';
$customFields = CRM_Core_BAO_CustomField::getFields($params['contact_type'], false, true);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_contactId, $params['contact_type'], true);
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);
}
// copy household address, if use_household_address option (for individual form) is checked
if ($this->_contactType == 'Individual') {
if (CRM_Utils_Array::value('use_household_address', $params) &&
|
请发表评论