当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_BAO_GroupContact::getContactGroup方法代码示例

本文整理汇总了PHP中CRM_Contact_BAO_GroupContact::getContactGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_GroupContact::getContactGroup方法的具体用法?PHP CRM_Contact_BAO_GroupContact::getContactGroup怎么用?PHP CRM_Contact_BAO_GroupContact::getContactGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contact_BAO_GroupContact的用法示例。


在下文中一共展示了CRM_Contact_BAO_GroupContact::getContactGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: browse

 /**
  * This function is called when action is browse
  * 
  * return null
  * @access public
  */
 function browse()
 {
     $count = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, null, null, true);
     $in =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
     $pending =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Pending');
     $out =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Removed');
     $this->assign('groupCount', $count);
     $this->assign_by_ref('groupIn', $in);
     $this->assign_by_ref('groupPending', $pending);
     $this->assign_by_ref('groupOut', $out);
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:17,代码来源:GroupContact.php

示例4: civicrm_group_contact_get

/**
 * This API will give list of the groups for particular contact
 * Particualr status can be sent in params array
 * If no status mentioned in params, by default 'added' will be used
 * to fetch the records
 *
 * @param  array $params  name value pair of contact information
 *
 * @return  array  list of groups, given contact subsribed to
 */
function civicrm_group_contact_get(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error(ts('input parameter should be an array'));
    }
    if (!array_key_exists('contact_id', $params)) {
        return civicrm_create_error(ts('contact_id is a required field'));
    }
    $status = CRM_Utils_Array::value('status', $params, 'Added');
    require_once 'CRM/Contact/BAO/GroupContact.php';
    $values = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE);
    return $values;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:23,代码来源:GroupContact.php

示例5: civicrm_api3_group_contact_get

/**
 * This API will give list of the groups for particular contact
 * Particualr status can be sent in params array
 * If no status mentioned in params, by default 'added' will be used
 * to fetch the records
 *
 * @param  array $params  name value pair of contact information
 * {@getfields GroupContact_get}
 *
 * @return  array  list of groups, given contact subsribed to
 */
function civicrm_api3_group_contact_get($params)
{
    if (empty($params['contact_id'])) {
        if (empty($params['status'])) {
            //default to 'Added'
            $params['status'] = 'Added';
        }
        //ie. id passed in so we have to return something
        return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
    }
    $status = CRM_Utils_Array::value('status', $params, 'Added');
    $values =& CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE);
    return civicrm_api3_create_success($values, $params);
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:25,代码来源:GroupContact.php

示例6: 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).
  *
  * @param string $groupElementType
  *
  * @return void
  */
 public static function setDefaults($id, &$defaults, $type = self::ALL, $fieldName = NULL, $groupElementType = 'checkbox')
 {
     $type = (int) $type;
     if ($type & self::GROUP) {
         $fName = 'group';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $contactGroup = CRM_Contact_BAO_GroupContact::getContactGroup($id, 'Added', NULL, FALSE, TRUE);
         if ($contactGroup) {
             foreach ($contactGroup as $group) {
                 if ($groupElementType == 'select') {
                     $defaults[$fName][] = $group['group_id'];
                 } else {
                     $defaults[$fName . '[' . $group['group_id'] . ']'] = 1;
                 }
             }
         }
     }
     if ($type & self::TAG) {
         $fName = 'tag';
         if ($fieldName) {
             $fName = $fieldName;
         }
         $contactTag = CRM_Core_BAO_EntityTag::getTag($id);
         if ($contactTag) {
             foreach ($contactTag as $tag) {
                 $defaults[$fName . '[' . $tag . ']'] = 1;
             }
         }
     }
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:48,代码来源:TagsAndGroups.php

示例7: 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

示例8: setShowHide

 /**
  * Fix what blocks to show/hide based on the default values set
  *
  * @param array   $defaults the array of default values
  * @param boolean $force    should we set show hide based on input defaults
  *
  * @return void
  */
 function setShowHide(&$defaults, $force)
 {
     $this->_showHide =& new CRM_Core_ShowHideBlocks(array('commPrefs' => 1), '');
     if ($this->_contactType == 'Individual') {
         $this->_showHide->addShow('demographics[show]');
         $this->_showHide->addHide('demographics');
     }
     // first do the defaults showing
     CRM_Contact_Form_Location::setShowHideDefaults($this->_showHide, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS);
     if ($this->_action & CRM_CORE_ACTION_ADD) {
         // notes are only included in the template for New Contact
         $this->_showHide->addShow('notes[show]');
         $this->_showHide->addHide('notes');
     }
     //add group and tags
     $contactGroup = $contactTag = array();
     if ($this->_contactId) {
         $contactGroup =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added');
         $contactTag =& CRM_Core_BAO_EntityTag::getTag('civicrm_contact', $this->_contactId);
     }
     if (empty($contactGroup) || empty($contactTag)) {
         $this->_showHide->addShow('group[show]');
         $this->_showHide->addHide('group');
     } else {
         $this->_showHide->addShow('group');
         $this->_showHide->addHide('group[show]');
     }
     // is there any demographics data?
     if (CRM_Utils_Array::value('gender_id', $defaults) || CRM_Utils_Array::value('is_deceased', $defaults) || CRM_Utils_Array::value('birth_date', $defaults)) {
         $this->_showHide->addShow('demographics');
         $this->_showHide->addHide('demographics[show]');
     }
     if ($force) {
         $locationDefaults = CRM_Utils_Array::value('location', $defaults);
         CRM_Contact_Form_Location::updateShowHide($this->_showHide, $locationDefaults, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS);
     }
     $this->_showHide->addToTemplate();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:46,代码来源:Edit.php

示例9: getValues

 /**
  * Given a contact id and a field set, return the values from the db
  * for this contact
  *
  * @param int     $id             the contact id
  * @param array   $fields         the profile fields of interest
  * @param array   $values         the values for the above fields
  * @param boolean $searchable     searchable or not
  * @param array   $componentWhere component condition
  *
  * @return void
  * @access public
  * @static
  */
 public static function getValues($cid, &$fields, &$values, $searchable = true, $componentWhere = null)
 {
     if (empty($cid)) {
         return null;
     }
     $options = array();
     $studentFields = array();
     if (CRM_Core_Permission::access('Quest', false)) {
         //student fields ( check box )
         require_once 'CRM/Quest/BAO/Student.php';
         $studentFields = CRM_Quest_BAO_Student::$multipleSelectFields;
     }
     // get the contact details (hier)
     $returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties($fields);
     $params = array(array('contact_id', '=', $cid, 0, 0));
     // 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();
     if (!$details->fetch()) {
         return;
     }
     $config =& CRM_Core_Config::singleton();
     require_once 'CRM/Core/PseudoConstant.php';
     $locationTypes = $imProviders = array();
     $locationTypes = CRM_Core_PseudoConstant::locationType();
     $imProviders = CRM_Core_PseudoConstant::IMProvider();
     //start of code to set the default values
     foreach ($fields as $name => $field) {
         // fix for CRM-3962
         if ($name == 'id') {
             $name = 'contact_id';
         }
         $index = $field['title'];
         $params[$index] = $values[$index] = '';
         $customFieldName = null;
         $elements = array('email_greeting_custom' => 'email_greeting', 'postal_greeting_custom' => 'postal_greeting', 'addressee_custom' => 'addressee');
         if (isset($details->{$name}) || $name == 'group' || $name == 'tag') {
             //hack for CRM-665
             // to handle gender / suffix / prefix
             if (in_array($name, array('gender', 'individual_prefix', 'individual_suffix'))) {
                 $values[$index] = $details->{$name};
                 $name = $name . '_id';
                 $params[$index] = $details->{$name};
             } else {
                 if (in_array($name, array('email_greeting', 'postal_greeting', 'addressee'))) {
                     $dname = $name . '_display';
                     $values[$index] = $details->{$dname};
                     $name = $name . '_id';
                     $params[$index] = $details->{$name};
                 } else {
                     if (in_array($name, array('state_province', 'country', 'county'))) {
                         $values[$index] = $details->{$name};
                         $idx = $name . '_id';
                         $params[$index] = $details->{$idx};
                     } else {
                         if ($name === 'preferred_communication_method') {
                             $communicationFields = CRM_Core_PseudoConstant::pcm();
                             $pref = array();
                             $compref = array();
                             $pref = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $details->{$name});
                             foreach ($pref as $k) {
                                 if ($k) {
                                     $compref[] = $communicationFields[$k];
                                 }
                             }
                             $params[$index] = $details->{$name};
                             $values[$index] = implode(",", $compref);
                         } else {
                             if ($name == 'group') {
                                 $groups = CRM_Contact_BAO_GroupContact::getContactGroup($cid, 'Added', null, false, true);
                                 $title = array();
                                 $ids = array();
                                 foreach ($groups as $g) {
                                     if ($g['visibility'] != 'User and User Admin Only') {
                                         $title[] = $g['title'];
                                         if ($g['visibility'] == 'Public Pages') {
                                             $ids[] = $g['group_id'];
                                         }
                                     }
                                 }
                                 $values[$index] = implode(', ', $title);
                                 $params[$index] = implode(',', $ids);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:UFGroup.php

示例10: 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;
         }
         $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;
         }
         $contactTag = CRM_Core_BAO_EntityTag::getTag($id);
         if ($contactTag) {
             foreach ($contactTag as $tag) {
                 $defaults[$fName . '[' . $tag . ']'] = 1;
             }
         }
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:40,代码来源:TagsAndGroups.php

示例11: getCountComponent

 /**
  * Given the component name and returns 
  * the count of participation of contact
  *
  * @param string  $component input component name
  * @param integer $contactId input contact id
  * @param string  $tableName optional tableName if component is custom group
  *
  * @return total number of count of occurence in database
  * @access public
  * @static
  */
 static function getCountComponent($component, $contactId, $tableName = null)
 {
     $object = null;
     switch ($component) {
         case 'tag':
             require_once 'CRM/Core/BAO/EntityTag.php';
             return CRM_Core_BAO_EntityTag::getContactTags($contactId, true);
         case 'rel':
             require_once 'CRM/Contact/BAO/Relationship.php';
             return count(CRM_Contact_BAO_Relationship::getRelationship($contactId));
         case 'group':
             require_once 'CRM/Contact/BAO/GroupContact.php';
             return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, null, null, true);
         case 'log':
             require_once 'CRM/Core/BAO/Log.php';
             return CRM_Core_BAO_Log::getContactLogCount($contactId);
         case 'note':
             require_once 'CRM/Core/BAO/Note.php';
             return CRM_Core_BAO_Note::getContactNoteCount($contactId);
         case 'contribution':
             require_once 'CRM/Contribute/BAO/Contribution.php';
             return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
         case 'membership':
             require_once 'CRM/Member/BAO/Membership.php';
             return CRM_Member_BAO_Membership::getContactMembershipCount($contactId);
         case 'participant':
             require_once 'CRM/Event/BAO/Participant.php';
             return CRM_Event_BAO_Participant::getContactParticipantCount($contactId);
         case 'pledge':
             require_once 'CRM/Pledge/BAO/Pledge.php';
             return CRM_Pledge_BAO_Pledge::getContactPledgeCount($contactId);
         case 'case':
             require_once 'CRM/Case/BAO/Case.php';
             return CRM_Case_BAO_Case::caseCount($contactId);
         case 'grant':
             require_once 'CRM/Grant/BAO/Grant.php';
             return CRM_Grant_BAO_Grant::getContactGrantCount($contactId);
         case 'activity':
             require_once 'CRM/Activity/BAO/Activity.php';
             return CRM_Activity_BAO_Activity::getActivitiesCount($contactId, false, null, null);
         default:
             $custom = explode('_', $component);
             if ($custom['0'] = 'custom') {
                 require_once 'CRM/Core/DAO/CustomGroup.php';
                 if (!$tableName) {
                     $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
                 }
                 $queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
                 return CRM_Core_DAO::singleValueQuery($queryString);
             }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:64,代码来源:Contact.php

示例12: create

 /**
  * takes an associative array and creates / removes
  * contacts from the groups
  *
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  * @param array $contactId    contact id
  *
  * @return none
  * @access public
  * @static
  */
 static function create(&$params, $contactId, $visibility = false, $method = 'Admin')
 {
     $contactIds = array();
     $contactIds[] = $contactId;
     if ($contactId) {
         $contactGroupList =& CRM_Contact_BAO_GroupContact::getContactGroup($contactId, 'Added');
         if (is_array($contactGroupList)) {
             foreach ($contactGroupList as $key) {
                 $groupId = $key['group_id'];
                 $contactGroup[$groupId] = $groupId;
             }
         }
     }
     // get the list of all the groups
     $allGroup =& CRM_Contact_BAO_GroupContact::getGroupList(0, $visibility);
     // 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 (!isset($contactGroup) || !is_array($contactGroup)) {
         $contactGroup = array();
     }
     // check which values has to be add/remove contact from group
     foreach ($allGroup as $key => $varValue) {
         if (CRM_Utils_Array::value($key, $params) && !array_key_exists($key, $contactGroup)) {
             // add contact to group
             CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $key, $method);
         } else {
             if (!CRM_Utils_Array::value($key, $params) && array_key_exists($key, $contactGroup)) {
                 // remove contact from group
                 CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contactIds, $key, $method);
             }
         }
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:48,代码来源:GroupContact.php

示例13: 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) && CRM_Utils_Array::value('shared_household', $params)) {
             if (is_numeric($params['shared_household'])) {
                 CRM_Contact_Form_Edit_Individual::copyHouseholdAddress($params);
             }
             CRM_Contact_Form_Edit_Individual::createSharedHousehold($params);
         } else {
             $params['mail_to_household_id'] = 'null';
         }
     } else {
         $params['mail_to_household_id'] = 'null';
     }
     if (!array_key_exists('TagsAndGroups', $this->_editOptions)) {
         unset($params['group']);
     }
     if (CRM_Utils_Array::value('contact_id', $params) && $this->_action & CRM_Core_Action::UPDATE) {
         // cleanup unwanted location blocks
         require_once 'CRM/Core/BAO/Location.php';
         CRM_Core_BAO_Location::cleanupContactLocations($params);
         // figure out which all groups are intended to be removed
         if (!empty($params['group'])) {
             $contactGroupList =& CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], 'Added');
             if (is_array($contactGroupList)) {
                 foreach ($contactGroupList as $key) {
                     if ($params['group'][$key['group_id']] != 1) {
                         $params['group'][$key['group_id']] = -1;
                     }
                 }
             }
         }
     }
     require_once 'CRM/Contact/BAO/Contact.php';
     $contact =& CRM_Contact_BAO_Contact::create($params, true, false);
     if ($this->_contactType == 'Individual' && CRM_Utils_Array::value('use_household_address', $params) && CRM_Utils_Array::value('mail_to_household_id', $params)) {
         // add/edit/delete the relation of individual with household, if use-household-address option is checked/unchecked.
         CRM_Contact_Form_Edit_Individual::handleSharedRelation($contact->id, $params);
     }
     if ($this->_contactType == 'Household' && $this->_action & CRM_Core_Action::UPDATE) {
         //TO DO: commented because of schema changes
         require_once 'CRM/Contact/Form/Edit/Household.php';
         CRM_Contact_Form_Edit_Household::synchronizeIndividualAddresses($contact->id);
     }
     if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
         //add contact to tags
         require_once 'CRM/Core/BAO/EntityTag.php';
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Contact.php

示例14: 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

示例15: getCountComponent

 /**
  * Given the component name and returns 
  * the count of participation of contact
  *
  * @param string $component input component name
  * @param integer $contactId input contact id
  *
  * @return total number of count of occurence in database
  * @access public
  * @static
  */
 static function getCountComponent($component, $contactId)
 {
     $object = null;
     switch ($component) {
         case 'tag':
             require_once 'CRM/Core/BAO/EntityTag.php';
             return count(CRM_Core_BAO_EntityTag::getTag($contactId));
         case 'rel':
             require_once 'CRM/Contact/BAO/Relationship.php';
             return count(CRM_Contact_BAO_Relationship::getRelationship($contactId));
         case 'group':
             require_once 'CRM/Contact/BAO/GroupContact.php';
             return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, null, null, true);
         case 'log':
         case 'note':
             eval('$object =& new CRM_Core_DAO_' . $component . '( );');
             $object->entity_table = 'civicrm_contact';
             $object->entity_id = $contactId;
             $object->orderBy('modified_date desc');
             break;
         case 'contribution':
             require_once 'CRM/Contribute/BAO/Contribution.php';
             return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
             break;
         case 'membership':
             require_once 'CRM/Member/DAO/Membership.php';
             eval('$object =& new CRM_Member_DAO_Membership( );');
             $object->contact_id = $contactId;
             $object->is_test = 0;
             break;
         case 'participant':
             require_once 'CRM/Event/DAO/Participant.php';
             eval('$object =& new CRM_Event_DAO_Participant( );');
             $object->contact_id = $contactId;
             $object->is_test = 0;
             break;
         case 'pledge':
             require_once 'CRM/Pledge/DAO/Pledge.php';
             eval('$object =& new CRM_Pledge_DAO_Pledge( );');
             $object->contact_id = $contactId;
             $object->is_test = 0;
             break;
         case 'case':
             require_once 'CRM/Case/BAO/Case.php';
             return CRM_Case_BAO_Case::caseCount($contactId);
         case 'grant':
             require_once 'CRM/Grant/DAO/Grant.php';
             eval('$object =& new CRM_Grant_DAO_Grant( );');
             $object->contact_id = $contactId;
             break;
         case 'activity':
             require_once 'CRM/Activity/BAO/Activity.php';
             return CRM_Activity_BAO_Activity::getActivitiesCount($contactId, false, null, null);
         default:
             $custom = explode('_', $component);
             if ($custom['0'] = 'custom') {
                 require_once 'CRM/Core/DAO/CustomGroup.php';
                 $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
                 $queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
                 return CRM_Core_DAO::singleValueQuery($queryString);
             }
     }
     $object->find();
     return $object->N;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:76,代码来源:Contact.php


注:本文中的CRM_Contact_BAO_GroupContact::getContactGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。