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


PHP CRM_Contact_BAO_Relationship::getContactRelationshipType方法代码示例

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


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

示例1: __construct

 function __construct()
 {
     $contact_type = CRM_Contact_BAO_ContactType::getSelectElements(false, true, '_');
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('display_name_a' => array('title' => ts('Contact A'), 'name' => 'display_name', 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING)), 'grouping' => 'conact_a_fields'), 'civicrm_contact_b' => array('dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', 'fields' => array('display_name_b' => array('title' => ts('Contact B'), 'name' => 'display_name', 'required' => true), 'id' => array('no_display' => true, 'required' => true)), 'filters' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING)), 'grouping' => 'conact_b_fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email_a' => array('title' => ts('Email of Contact A'), 'name' => 'email')), 'grouping' => 'conact_a_fields'), 'civicrm_email_b' => array('dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', 'fields' => array('email_b' => array('title' => ts('Email of Contact B'), 'name' => 'email')), 'grouping' => 'conact_b_fields'), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType', 'fields' => array('label_a_b' => array('title' => ts('Relationship A-B '), 'default' => true), 'label_b_a' => array('title' => ts('Relationship B-A '), 'default' => true)), 'filters' => array('contact_type_a' => array('title' => ts('Contact Type  A'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING), 'contact_type_b' => array('title' => ts('Contact Type  B'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'relation-fields'), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('start_date' => array('title' => ts('Relationship Start Date')), 'end_date' => array('title' => ts('Relationship End Date')), 'description' => array('title' => ts('Description'))), 'filters' => array('is_active' => array('title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- Any -', 1 => 'Active', 0 => 'Inactive'), 'type' => CRM_Utils_Type::T_INT), 'relationship_type_id' => array('title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- any relationship type -') + CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, null, true), 'type' => CRM_Utils_Type::T_INT)), 'grouping' => 'relation-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince())), 'grouping' => 'contact-fields'), 'civicrm_group' => array('dao' => 'CRM_Contact_DAO_Group', 'alias' => 'cgroup', 'filters' => array('gid' => array('name' => 'group_id', 'title' => ts('Group'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => true, 'options' => CRM_Core_PseudoConstant::group()))));
     $this->_tagFilter = true;
     parent::__construct();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:7,代码来源:Relationship.php

示例2: __construct

 /**
  * Class constructor.
  */
 public function __construct()
 {
     $contact_type = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '_');
     $this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type_a' => array('title' => ts('Contact Type (Contact A)'), 'name' => 'contact_type'), 'contact_sub_type_a' => array('title' => ts('Contact Subtype (Contact A)'), 'name' => 'contact_sub_type')), 'filters' => array('sort_name_a' => array('title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_type_a' => array('title' => ts('Contact Type A'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'contact_a_fields'), 'civicrm_contact_b' => array('dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', 'fields' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'required' => TRUE), 'id' => array('no_display' => TRUE, 'required' => TRUE), 'contact_type_b' => array('title' => ts('Contact Type (Contact B)'), 'name' => 'contact_type'), 'contact_sub_type_b' => array('title' => ts('Contact Subtype (Contact B)'), 'name' => 'contact_sub_type')), 'filters' => array('sort_name_b' => array('title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_type_b' => array('title' => ts('Contact Type B'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING)), 'grouping' => 'contact_b_fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('email_a' => array('title' => ts('Email (Contact A)'), 'name' => 'email')), 'grouping' => 'contact_a_fields'), 'civicrm_email_b' => array('dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', 'fields' => array('email_b' => array('title' => ts('Email (Contact B)'), 'name' => 'email')), 'grouping' => 'contact_b_fields'), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_a', 'fields' => array('phone_a' => array('title' => ts('Phone (Contact A)'), 'name' => 'phone'), 'phone_ext_a' => array('title' => ts('Phone Ext (Contact A)'), 'name' => 'phone_ext')), 'grouping' => 'contact_a_fields'), 'civicrm_phone_b' => array('dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_b', 'fields' => array('phone_b' => array('title' => ts('Phone (Contact B)'), 'name' => 'phone'), 'phone_ext_b' => array('title' => ts('Phone Ext (Contact B)'), 'name' => 'phone_ext')), 'grouping' => 'contact_b_fields'), 'civicrm_relationship_type' => array('dao' => 'CRM_Contact_DAO_RelationshipType', 'fields' => array('label_a_b' => array('title' => ts('Relationship A-B '), 'default' => TRUE), 'label_b_a' => array('title' => ts('Relationship B-A '), 'default' => TRUE)), 'grouping' => 'relation-fields'), 'civicrm_relationship' => array('dao' => 'CRM_Contact_DAO_Relationship', 'fields' => array('start_date' => array('title' => ts('Relationship Start Date')), 'end_date' => array('title' => ts('Relationship End Date')), 'description' => array('title' => ts('Description')), 'relationship_id' => array('title' => ts('Rel ID'), 'name' => 'id')), 'filters' => array('is_active' => array('title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('' => '- Any -', 1 => 'Active', 0 => 'Inactive'), 'type' => CRM_Utils_Type::T_INT), 'is_valid' => array('title' => ts('Relationship Dates Validity'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array(NULL => ts('- Any -'), 1 => ts('Not expired'), 0 => ts('Expired')), 'type' => CRM_Utils_Type::T_INT), 'relationship_type_id' => array('title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE), 'type' => CRM_Utils_Type::T_INT), 'start_date' => array('title' => ts('Start Date'), 'type' => CRM_Utils_Type::T_DATE), 'end_date' => array('title' => ts('End Date'), 'type' => CRM_Utils_Type::T_DATE)), 'grouping' => 'relation-fields'), 'civicrm_address' => array('dao' => 'CRM_Core_DAO_Address', 'filters' => array('country_id' => array('title' => ts('Country'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country()), 'state_province_id' => array('title' => ts('State/Province'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince())), 'grouping' => 'contact-fields'));
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
     parent::__construct();
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:11,代码来源:Relationship.php

示例3: basic

 /**
  * @param CRM_Core_Form $form
  */
 public static function basic(&$form)
 {
     $form->addElement('hidden', 'hidden_basic', 1);
     // text for sort_name
     $form->addElement('text', 'target_name', ts('Target Contact'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $allRelationshipType = array();
     $allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
     $form->add('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + $allRelationshipType, FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
     // relation status
     $relStatusOption = array(ts('Active'), ts('Inactive'), ts('All'));
     $form->addRadio('is_active', ts('Relationship Status'), $relStatusOption);
     $form->setDefaults(array('is_active' => 0));
     CRM_Core_Form_Date::buildDateRange($form, 'start_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
     CRM_Core_Form_Date::buildDateRange($form, 'end_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
 }
开发者ID:Chirojeugd-Vlaanderen,项目名称:civicrm-relationship-entity,代码行数:18,代码来源:Criteria.php

示例4: testGetExportStructureArrays

 /**
  * Test the function that extracts the arrays used to structure the output.
  *
  * The keys in the output fields array should by matched by field aliases in the sql query (with
  * exceptions of course - currently country is one - although maybe a future refactor can change that!).
  *
  * We are trying to move towards simpler processing in the per row iteration as that may be
  * repeated 100,000 times and in general we should simply be able to match the query fields to
  * our expected rows & do a little pseudoconstant mapping.
  */
 public function testGetExportStructureArrays()
 {
     // This is how return properties are formatted internally within the function for passing to the BAO query.
     $returnProperties = array('first_name' => 1, 'last_name' => 1, 'receive_date' => 1, 'contribution_source' => 1, 'location' => array('Home' => array('street_address' => 1, 'city' => 1, 'country' => 1, 'email' => 1, 'im-1' => 1, 'im_provider' => 1, 'phone-1' => 1)), 'phone' => 1, 'trxn_id' => 1, 'contribution_id' => 1);
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
     $contactRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE, 'name', FALSE);
     $query = new CRM_Contact_BAO_Query(array(), $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE, FALSE, TRUE, TRUE, NULL, 'AND');
     list($select) = $query->query();
     $pattern = '/as `?([^`,]*)/';
     $queryFieldAliases = array();
     preg_match_all($pattern, $select, $queryFieldAliases, PREG_PATTERN_ORDER);
     list($outputFields) = CRM_Export_BAO_Export::getExportStructureArrays($returnProperties, $query, $phoneTypes, $imProviders, $contactRelationshipTypes, '', array());
     foreach (array_keys($outputFields) as $fieldAlias) {
         if ($fieldAlias == 'Home-country') {
             $this->assertTrue(in_array($fieldAlias . '_id', $queryFieldAliases[1]), 'Country is subject to some funky translate so we make sure country id is present');
         } else {
             $this->assertTrue(in_array($fieldAlias, $queryFieldAliases[1]), 'looking for field ' . $fieldAlias . ' in generaly the alias fields need to match the outputfields');
         }
     }
 }
开发者ID:GuGuss,项目名称:civicrm-core,代码行数:31,代码来源:ExportTest.php

示例5: relationship

 static function relationship(&$form)
 {
     $form->add('hidden', 'hidden_relationship', 1);
     require_once 'CRM/Contact/BAO/Relationship.php';
     require_once 'CRM/Core/PseudoConstant.php';
     $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Individual');
     $relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Organization');
     $relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Household');
     $allRelationshipType = array();
     $allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
     $allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
     $form->addElement('select', 'relation_type_id', ts('Relationship Type'), array('' => ts('- select -')) + $allRelationshipType);
     $form->addElement('text', 'relation_target_name', ts('Target Contact'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
     $relStatusOption = array(ts('Active '), ts('Inactive '), ts('All'));
     $form->addRadio('relation_status', ts('Relationship Status'), $relStatusOption);
     $form->setDefaults(array('relation_status' => 0));
     // add all the custom  searchable fields
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $relationship = array('Relationship');
     $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(null, true, $relationship);
     if ($groupDetails) {
         require_once 'CRM/Core/BAO/CustomField.php';
         $form->assign('relationshipGroupTree', $groupDetails);
         foreach ($groupDetails as $group) {
             foreach ($group['fields'] as $field) {
                 $fieldId = $field['id'];
                 $elementName = 'custom_' . $fieldId;
                 CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, false, false, true);
             }
         }
     }
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:32,代码来源:Criteria.php

示例6: exportComponents

 /**
  * Function to get the list the export fields
  *
  * @param int    $selectAll user preference while export
  * @param array  $ids  contact ids
  * @param array  $params associated array of fields
  * @param string $order order by clause
  * @param array  $associated array of fields
  * @param array  $moreReturnProperties additional return fields
  * @param int    $exportMode export mode
  * @param string $componentClause component clause
  *
  * @static
  * @access public
  */
 static function exportComponents($selectAll, $ids, $params, $order = null, $fields = null, $moreReturnProperties = null, $exportMode = CRM_Export_Form_Select::CONTACT_EXPORT, $componentClause = null)
 {
     $headerRows = array();
     $primary = false;
     $returnProperties = array();
     $origFields = $fields;
     $queryMode = null;
     $paymentFields = false;
     $phoneTypes = CRM_Core_PseudoConstant::phoneType();
     $imProviders = CRM_Core_PseudoConstant::IMProvider();
     $contactRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, null, null, null, true, 'label', false);
     $queryMode = CRM_Contact_BAO_Query::MODE_CONTACTS;
     switch ($exportMode) {
         case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
             break;
         case CRM_Export_Form_Select::EVENT_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_EVENT;
             break;
         case CRM_Export_Form_Select::MEMBER_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_MEMBER;
             break;
         case CRM_Export_Form_Select::PLEDGE_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE;
             break;
         case CRM_Export_Form_Select::CASE_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_CASE;
             break;
         case CRM_Export_Form_Select::GRANT_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_GRANT;
             break;
     }
     require_once 'CRM/Core/BAO/CustomField.php';
     if ($fields) {
         //construct return properties
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $locationTypeFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'phone', 'email', 'im');
         foreach ($fields as $key => $value) {
             $phoneTypeId = null;
             $imProviderId = null;
             $relationshipTypes = $fieldName = CRM_Utils_Array::value(1, $value);
             if (!$fieldName) {
                 continue;
             }
             // get phoneType id and IM service provider id seperately
             if ($fieldName == 'phone') {
                 $phoneTypeId = CRM_Utils_Array::value(3, $value);
             } else {
                 if ($fieldName == 'im') {
                     $imProviderId = CRM_Utils_Array::value(3, $value);
                 }
             }
             if (array_key_exists($relationshipTypes, $contactRelationshipTypes)) {
                 if (CRM_Utils_Array::value(2, $value)) {
                     $relationField = CRM_Utils_Array::value(2, $value);
                     if (trim(CRM_Utils_Array::value(3, $value))) {
                         $relLocTypeId = CRM_Utils_Array::value(3, $value);
                     } else {
                         $relLocTypeId = 1;
                     }
                     if ($relationField == 'phone') {
                         $relPhoneTypeId = CRM_Utils_Array::value(4, $value);
                     } else {
                         if ($relationField == 'im') {
                             $relIMProviderId = CRM_Utils_Array::value(4, $value);
                         }
                     }
                 } else {
                     if (CRM_Utils_Array::value(4, $value)) {
                         $relationField = CRM_Utils_Array::value(4, $value);
                         $relLocTypeId = CRM_Utils_Array::value(5, $value);
                         if ($relationField == 'phone') {
                             $relPhoneTypeId = CRM_Utils_Array::value(6, $value);
                         } else {
                             if ($relationField == 'im') {
                                 $relIMProviderId = CRM_Utils_Array::value(6, $value);
                             }
                         }
                     }
                 }
             }
             $contactType = CRM_Utils_Array::value(0, $value);
             $locTypeId = CRM_Utils_Array::value(2, $value);
             $phoneTypeId = CRM_Utils_Array::value(3, $value);
             if ($relationField) {
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Export.php

示例7: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     // Select list
     $relationshipList = CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactId, $this->_rtype, $this->_relationshipId);
     // Metadata needed on clientside
     $this->assign('relationshipData', self::getRelationshipTypeMetadata($relationshipList));
     foreach ($this->_allRelationshipNames as $id => $vals) {
         if ($vals['name_a_b'] === 'Employee of') {
             $this->assign('employmentRelationship', $id);
             break;
         }
     }
     $this->addField('relationship_type_id', array('options' => array('' => ts('- select -')) + $relationshipList, 'class' => 'huge', 'placeholder' => '- select -'), TRUE);
     $label = $this->_action & CRM_Core_Action::ADD ? ts('Contact(s)') : ts('Contact');
     $contactField = $this->addField('related_contact_id', array('label' => $label, 'name' => 'contact_id_b', 'multiple' => TRUE, 'create' => TRUE), TRUE);
     // This field cannot be updated
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $contactField->freeze();
     }
     $this->add('advcheckbox', 'is_current_employer', $this->_contactType == 'Organization' ? ts('Current Employee') : ts('Current Employer'));
     $this->addField('start_date', array('label' => ts('Start Date'), 'formatType' => 'searchDate'));
     $this->addField('end_date', array('label' => ts('End Date'), 'formatType' => 'searchDate'));
     $this->addField('is_active', array('label' => ts('Enabled?'), 'type' => 'advcheckbox'));
     $this->addField('is_permission_a_b');
     $this->addField('is_permission_b_a');
     $this->addField('description', array('label' => ts('Description')));
     CRM_Contact_Form_Edit_Notes::buildQuickForm($this);
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'))));
     } else {
         // make this form an upload since we don't know if the custom data injected dynamically is of type file etc.
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save Relationship'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:41,代码来源:Relationship.php

示例8: init

 /**
  * the initializer code, called before the processing
  *
  * @return void
  * @access public
  */
 function init()
 {
     require_once 'CRM/Contact/BAO/Contact.php';
     $fields =& CRM_Contact_BAO_Contact::importableFields($this->_contactType);
     //CRM-5125
     //supporting import for contact subtypes
     if (!empty($this->_contactSubType)) {
         //custom fields for sub type
         $subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($this->_contactSubType);
         if (!empty($subTypeFields)) {
             foreach ($subTypeFields as $customSubTypeField => $details) {
                 $fields[$customSubTypeField] = $details;
             }
         }
     }
     //Relationship importables
     $this->_relationships = $relations = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, null, null, $this->_contactType, false, 'label', true, $this->_contactSubType);
     asort($relations);
     foreach ($relations as $key => $var) {
         list($type) = explode('_', $key);
         $relationshipType[$key]['title'] = $var;
         $relationshipType[$key]['headerPattern'] = '/' . preg_quote($var, '/') . '/';
         $relationshipType[$key]['import'] = true;
         $relationshipType[$key]['relationship_type_id'] = $type;
         $relationshipType[$key]['related'] = true;
     }
     if (!empty($relationshipType)) {
         $fields = array_merge($fields, array('related' => array('title' => ts('- related contact info -'))), $relationshipType);
     }
     foreach ($fields as $name => $field) {
         $this->addField($name, $field['title'], CRM_Utils_Array::value('type', $field), CRM_Utils_Array::value('headerPattern', $field), CRM_Utils_Array::value('dataPattern', $field), CRM_Utils_Array::value('hasLocationType', $field));
     }
     $this->_newContacts = array();
     $this->setActiveFields($this->_mapperKeys);
     $this->setActiveFieldLocationTypes($this->_mapperLocType);
     $this->setActiveFieldPhoneTypes($this->_mapperPhoneType);
     //set active fields of IM provider of contact
     $this->setActiveFieldImProviders($this->_mapperImProvider);
     //related info
     $this->setActiveFieldRelated($this->_mapperRelated);
     $this->setActiveFieldRelatedContactType($this->_mapperRelatedContactType);
     $this->setActiveFieldRelatedContactDetails($this->_mapperRelatedContactDetails);
     $this->setActiveFieldRelatedContactLocType($this->_mapperRelatedContactLocType);
     $this->setActiveFieldRelatedContactPhoneType($this->_mapperRelatedContactPhoneType);
     //set active fields of IM provider of related contact
     $this->setActiveFieldRelatedContactImProvider($this->_mapperRelatedContactImProvider);
     $this->_phoneIndex = -1;
     $this->_emailIndex = -1;
     $this->_firstNameIndex = -1;
     $this->_lastNameIndex = -1;
     $this->_householdNameIndex = -1;
     $this->_organizationNameIndex = -1;
     $this->_externalIdentifierIndex = -1;
     $index = 0;
     foreach ($this->_mapperKeys as $key) {
         if (substr($key, 0, 5) == 'email' && substr($key, 0, 14) != 'email_greeting') {
             $this->_emailIndex = $index;
             $this->_allEmails = array();
         }
         if (substr($key, 0, 5) == 'phone') {
             $this->_phoneIndex = $index;
         }
         if ($key == 'first_name') {
             $this->_firstNameIndex = $index;
         }
         if ($key == 'last_name') {
             $this->_lastNameIndex = $index;
         }
         if ($key == 'household_name') {
             $this->_householdNameIndex = $index;
         }
         if ($key == 'organization_name') {
             $this->_organizationNameIndex = $index;
         }
         if ($key == 'external_identifier') {
             $this->_externalIdentifierIndex = $index;
             $this->_allExternalIdentifiers = array();
         }
         $index++;
     }
     $this->_updateWithId = false;
     if (in_array('id', $this->_mapperKeys) || $this->_externalIdentifierIndex >= 0 && in_array($this->_onDuplicate, array(CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::DUPLICATE_FILL))) {
         $this->_updateWithId = true;
     }
     require_once 'CRM/Core/BAO/Preferences.php';
     $this->_parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', CRM_Core_BAO_Preferences::valueOptions('address_options'), false);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:93,代码来源:Contact.php

示例9: relationship

 /**
  * where / qill clause for relationship
  *
  * @return void
  * @access public
  */
 function relationship(&$values)
 {
     list($name, $op, $value, $grouping, $wildcard) = $values;
     // also get values array for relation_target_name
     // for relatinship search we always do wildcard
     $targetName = $this->getWhereValues('relation_target_name', $grouping);
     $relStatus = $this->getWhereValues('relation_status', $grouping);
     $targetGroup = $this->getWhereValues('relation_target_group', $grouping);
     $nameClause = $name = NULL;
     if ($targetName) {
         $name = trim($targetName[2]);
         if (substr($name, 0, 1) == '"' && substr($name, -1, 1) == '"') {
             $name = substr($name, 1, -1);
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "= '{$name}'";
         } else {
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "LIKE '%{$name}%'";
         }
     }
     $rel = explode('_', $value);
     self::$_relType = $rel[1];
     $params = array('id' => $rel[0]);
     $rTypeValues = array();
     $rType = CRM_Contact_BAO_RelationshipType::retrieve($params, $rTypeValues);
     if (!$rType) {
         return;
     }
     if ($rTypeValues['name_a_b'] == $rTypeValues['name_b_a']) {
         self::$_relType = 'reciprocal';
     }
     if ($nameClause) {
         $this->_where[$grouping][] = "( contact_b.sort_name {$nameClause} AND contact_b.id != contact_a.id )";
     }
     $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual');
     $relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization');
     $relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household');
     $allRelationshipType = array();
     $allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
     $allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
     if ($nameClause || !$targetGroup) {
         $this->_qill[$grouping][] = "{$allRelationshipType[$value]}  {$name}";
     }
     //check to see if the target contact is in specified group
     if ($targetGroup) {
         //add contacts from static groups
         $this->_tables['civicrm_relationship_group_contact'] = $this->_whereTables['civicrm_relationship_group_contact'] = " LEFT JOIN civicrm_group_contact civicrm_relationship_group_contact ON civicrm_relationship_group_contact.contact_id = contact_b.id";
         $groupWhere[] = "( civicrm_relationship_group_contact.group_id IN  (" . implode(",", $targetGroup[2]) . ") )";
         //add contacts from saved searches
         $ssWhere = $this->addGroupContactCache($targetGroup[2], "civicrm_relationship_group_contact_cache", "contact_b");
         //set the group where clause
         if ($ssWhere) {
             $groupWhere[] = "( " . $ssWhere . " )";
         }
         $this->_where[$grouping][] = "( " . implode(" OR ", $groupWhere) . " )";
         //Get the names of the target groups for the qill
         $groupNames =& CRM_Core_PseudoConstant::group();
         $qillNames = array();
         foreach ($targetGroup[2] as $groupId) {
             if (array_key_exists($groupId, $groupNames)) {
                 $qillNames[] = $groupNames[$groupId];
             }
         }
         $this->_qill[$grouping][] = "{$allRelationshipType[$value]}  ( " . implode(", ", $qillNames) . " )";
     }
     //check for active, inactive and all relation status
     $today = date('Ymd');
     if ($relStatus[2] == 0) {
         $this->_where[$grouping][] = "(\ncivicrm_relationship.is_active = 1 AND\n( civicrm_relationship.end_date IS NULL OR civicrm_relationship.end_date >= {$today} ) AND\n( civicrm_relationship.start_date IS NULL OR civicrm_relationship.start_date <= {$today} )\n)";
         $this->_qill[$grouping][] = ts('Relationship - Active');
     } elseif ($relStatus[2] == 1) {
         $this->_where[$grouping][] = "(\ncivicrm_relationship.is_active = 0 OR\ncivicrm_relationship.end_date < {$today} OR\ncivicrm_relationship.start_date > {$today}\n)";
         $this->_qill[$grouping][] = ts('Relationship - Inactive');
     }
     $this->_where[$grouping][] = 'civicrm_relationship.relationship_type_id = ' . $rel[0];
     $this->_tables['civicrm_relationship'] = $this->_whereTables['civicrm_relationship'] = 1;
     $this->_useDistinct = TRUE;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:84,代码来源:Query.php

示例10: relationship

 /**
  * Where / qill clause for relationship.
  *
  * @param array $values
  */
 public function relationship(&$values)
 {
     list($name, $op, $value, $grouping, $wildcard) = $values;
     if ($this->_relationshipValuesAdded) {
         return;
     }
     // also get values array for relation_target_name
     // for relationship search we always do wildcard
     $relationType = $this->getWhereValues('relation_type_id', $grouping);
     $targetName = $this->getWhereValues('relation_target_name', $grouping);
     $relStatus = $this->getWhereValues('relation_status', $grouping);
     $relPermission = $this->getWhereValues('relation_permission', $grouping);
     $targetGroup = $this->getWhereValues('relation_target_group', $grouping);
     $nameClause = $name = NULL;
     if ($targetName) {
         $name = trim($targetName[2]);
         if (substr($name, 0, 1) == '"' && substr($name, -1, 1) == '"') {
             $name = substr($name, 1, -1);
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "= '{$name}'";
         } else {
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "LIKE '%{$name}%'";
         }
     }
     $rTypeValues = array();
     if (!empty($relationType)) {
         $rel = explode('_', $relationType[2]);
         self::$_relType = $rel[1];
         $params = array('id' => $rel[0]);
         $rType = CRM_Contact_BAO_RelationshipType::retrieve($params, $rTypeValues);
     }
     if (!empty($rTypeValues) && $rTypeValues['name_a_b'] == $rTypeValues['name_b_a']) {
         // if we don't know which end of the relationship we are dealing with we'll create a temp table
         //@todo unless we are dealing with a target group
         self::$_relType = 'reciprocal';
     }
     // if we are creating a temp table we build our own where for the relationship table
     $relationshipTempTable = NULL;
     if (self::$_relType == 'reciprocal' && empty($targetGroup)) {
         $where = array();
         self::$_relationshipTempTable = $relationshipTempTable = CRM_Core_DAO::createTempTableName('civicrm_rel');
         if ($nameClause) {
             $where[$grouping][] = " sort_name {$nameClause} ";
         }
     } else {
         $where =& $this->_where;
         if ($nameClause) {
             $where[$grouping][] = "( contact_b.sort_name {$nameClause} AND contact_b.id != contact_a.id )";
         }
     }
     $allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
     if ($nameClause || !$targetGroup) {
         if (!empty($relationType)) {
             $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] . " {$name}";
         } else {
             $this->_qill[$grouping][] = $name;
         }
     }
     //check to see if the target contact is in specified group
     if ($targetGroup) {
         //add contacts from static groups
         $this->_tables['civicrm_relationship_group_contact'] = $this->_whereTables['civicrm_relationship_group_contact'] = " LEFT JOIN civicrm_group_contact civicrm_relationship_group_contact ON civicrm_relationship_group_contact.contact_id = contact_b.id AND civicrm_relationship_group_contact.status = 'Added'";
         $groupWhere[] = "( civicrm_relationship_group_contact.group_id IN  (" . implode(",", $targetGroup[2]) . ") ) ";
         //add contacts from saved searches
         $ssWhere = $this->addGroupContactCache($targetGroup[2], "civicrm_relationship_group_contact_cache", "contact_b", $op);
         //set the group where clause
         if ($ssWhere) {
             $groupWhere[] = "( " . $ssWhere . " )";
         }
         $this->_where[$grouping][] = "( " . implode(" OR ", $groupWhere) . " )";
         //Get the names of the target groups for the qill
         $groupNames = CRM_Core_PseudoConstant::group();
         $qillNames = array();
         foreach ($targetGroup[2] as $groupId) {
             if (array_key_exists($groupId, $groupNames)) {
                 $qillNames[] = $groupNames[$groupId];
             }
         }
         if (!empty($relationType)) {
             $this->_qill[$grouping][] = $allRelationshipType[$relationType[2]] . " ( " . implode(", ", $qillNames) . " )";
         } else {
             $this->_qill[$grouping][] = implode(", ", $qillNames);
         }
     }
     // Note we do not currently set mySql to handle timezones, so doing this the old-fashioned way
     $today = date('Ymd');
     //check for active, inactive and all relation status
     if ($relStatus[2] == 0) {
         $where[$grouping][] = "(\ncivicrm_relationship.is_active = 1 AND\n( civicrm_relationship.end_date IS NULL OR civicrm_relationship.end_date >= {$today} ) AND\n( civicrm_relationship.start_date IS NULL OR civicrm_relationship.start_date <= {$today} )\n)";
         $this->_qill[$grouping][] = ts('Relationship - Active and Current');
     } elseif ($relStatus[2] == 1) {
         $where[$grouping][] = "(\ncivicrm_relationship.is_active = 0 OR\ncivicrm_relationship.end_date < {$today} OR\ncivicrm_relationship.start_date > {$today}\n)";
         $this->_qill[$grouping][] = ts('Relationship - Inactive or not Current');
     }
//.........这里部分代码省略.........
开发者ID:hoegrammer,项目名称:civicrm-core,代码行数:101,代码来源:Query.php

示例11: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'name'), TRUE);
     $this->addRule('name', ts('A membership type with this name already exists. Please select another name.'), 'objectExists', array('CRM_Member_DAO_MembershipType', $this->_id));
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'description'));
     $this->add('text', 'minimum_fee', ts('Minimum Fee'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'minimum_fee'));
     $this->addRule('minimum_fee', ts('Please enter a monetary value for the Minimum Fee.'), 'money');
     $this->addElement('select', 'duration_unit', ts('Duration') . ' ', CRM_Core_SelectValues::unitList('duration'), array('onchange' => 'showHidePeriodSettings()'));
     //period type
     $this->addElement('select', 'period_type', ts('Period Type'), CRM_Core_SelectValues::periodType(), array('onchange' => 'showHidePeriodSettings()'));
     $this->add('text', 'duration_interval', ts('Duration Interval'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'duration_interval'));
     $memberOrg =& $this->add('text', 'member_org', ts('Membership Organization'), 'size=30 maxlength=120');
     //start day
     $this->add('date', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_SelectValues::date(NULL, 'M d'), FALSE);
     $msgTemplates = CRM_Core_BAO_MessageTemplates::getMessageTemplates(FALSE);
     $hasMsgTemplates = FALSE;
     if (!empty($msgTemplates)) {
         $hasMsgTemplates = TRUE;
     }
     //Auto-renew Option
     $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
     $isAuthorize = FALSE;
     $options = array();
     $allowAutoRenewMsg = FALSE;
     if (is_array($paymentProcessor) && !empty($paymentProcessor)) {
         $isAuthorize = TRUE;
         $options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required '));
         if ($hasMsgTemplates) {
             $allowAutoRenewMsg = TRUE;
             $autoRenewReminderMsg = $this->add('select', 'autorenewal_msg_id', ts('Auto-renew Reminder Message'), array('' => ts('- select -')) + $msgTemplates);
         }
     }
     $this->addRadio('auto_renew', ts('Auto-renew Option'), $options, array('onclick' => "setReminder(this.value);"));
     $this->assign('authorize', $isAuthorize);
     $this->assign('allowAutoRenewMsg', $allowAutoRenewMsg);
     //rollover day
     $this->add('date', 'fixed_period_rollover_day', ts('Fixed Period Rollover Day'), CRM_Core_SelectValues::date(NULL, 'M d'), FALSE);
     // required in form rule
     $this->add('hidden', 'action', $this->_action);
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionType());
     $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE);
     if (is_array($relTypeInd)) {
         asort($relTypeInd);
     }
     $memberRel =& $this->add('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + $relTypeInd);
     $memberRel->setMultiple(TRUE);
     $this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::memberVisibility());
     $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'weight'));
     $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($hasMsgTemplates) {
         $reminderMsg = $this->add('select', 'renewal_msg_id', ts('Renewal Reminder Message'), array('' => ts('- select -')) + $msgTemplates);
     }
     $this->assign('hasMsgTemplates', $hasMsgTemplates);
     $reminderDay =& $this->add('text', 'renewal_reminder_day', ts('Renewal Reminder Day'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipType', 'renewal_reminder_day'));
     $searchRows = $this->get('searchRows');
     $searchCount = $this->get('searchCount');
     $searchDone = $this->get('searchDone');
     if ($searchRows) {
         $checkBoxes = array();
         $chekFlag = 0;
         foreach ($searchRows as $id => $row) {
             $checked = '';
             if (!$chekFlag) {
                 $checked = array('checked' => NULL);
                 $chekFlag++;
             }
             $checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id, $checked);
         }
         $this->addGroup($checkBoxes, 'contact_check');
         $this->assign('searchRows', $searchRows);
     }
     $this->assign('searchCount', $searchCount);
     $this->assign('searchDone', $searchDone);
     if ($searchDone) {
         $searchBtn = ts('Search Again');
     } elseif ($this->_action & CRM_Core_Action::UPDATE) {
         $searchBtn = ts('Change');
     } else {
         $searchBtn = ts('Search');
     }
     $membershipRecords = FALSE;
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $membershipType = new CRM_Member_BAO_Membership();
         $membershipType->membership_type_id = $this->_id;
         if ($membershipType->find(TRUE)) {
             $membershipRecords = TRUE;
             $memberRel->freeze();
         }
         $memberOrg->freeze();
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:MembershipType.php

示例12: clauseComponent

 function clauseComponent()
 {
     $selectedContacts = implode(',', $this->_contactSelected);
     $contribution = $membership = $participant = null;
     $eligibleResult = $rows = $tempArray = array();
     foreach ($this->_component as $val) {
         if (CRM_Utils_Array::value($val, $this->_selectComponent) && ($val != 'activity_civireport' && $val != 'relationship_civireport')) {
             $sql = "{$this->_selectComponent[$val]} {$this->_formComponent[$val]} \n                         WHERE    {$this->_aliases['civicrm_contact']}.id IN ( {$selectedContacts} )\n                         GROUP BY {$this->_aliases['civicrm_contact']}.id,{$val}.id ";
             $dao = CRM_Core_DAO::executeQuery($sql);
             while ($dao->fetch()) {
                 $countRecord = 0;
                 $eligibleResult[$val] = $val;
                 $CC = "civicrm_" . substr_replace($val, '', -11, 11) . "_contact_id";
                 $row = array();
                 foreach ($this->_columnHeadersComponent[$val] as $key => $value) {
                     $countRecord++;
                     $row[$key] = $dao->{$key};
                 }
                 //if record exist for component(except contact_id)
                 //since contact_id is selected for every component
                 if ($countRecord > 1) {
                     $rows[$dao->{$CC}][$val][] = $row;
                 }
                 $tempArray[$dao->{$CC}] = $dao->{$CC};
             }
         }
     }
     if (CRM_Utils_Array::value('relationship_civireport', $this->_selectComponent)) {
         require_once 'CRM/Contact/BAO/Relationship.php';
         $relTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, null, true);
         $val = 'relationship_civireport';
         $eligibleResult[$val] = $val;
         $sql = "{$this->_selectComponent[$val]},{$this->_aliases['civicrm_contact']}.display_name as contact_b_name,  contact_a.id as contact_a_id , contact_a.display_name  as contact_a_name  {$this->_formComponent[$val]} \n                         WHERE    ({$this->_aliases['civicrm_contact']}.id IN ( {$selectedContacts} )\n                                  OR \n                                  contact_a.id IN ( {$selectedContacts} ) ) AND\n                                  {$this->_aliases['civicrm_relationship']}.is_active = 1\n                         GROUP BY {$this->_aliases['civicrm_relationship']}.id";
         $dao = CRM_Core_DAO::executeQuery($sql);
         while ($dao->fetch()) {
             foreach ($this->_columnHeadersComponent[$val] as $key => $value) {
                 if ($key == 'civicrm_relationship_contact_id_b') {
                     $row[$key] = $dao->contact_b_name;
                     continue;
                 }
                 $row[$key] = $dao->{$key};
             }
             $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . "_a_b";
             $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
             $rows[$dao->contact_a_id][$val][] = $row;
             $row['civicrm_relationship_contact_id_b'] = $dao->contact_a_name;
             $relTitle = "" . $dao->civicrm_relationship_relationship_type_id . "_b_a";
             if (isset($relTypes[$relTitle])) {
                 $row['civicrm_relationship_relationship_type_id'] = $relTypes[$relTitle];
             }
             $rows[$dao->civicrm_relationship_contact_id_b][$val][] = $row;
         }
     }
     if (CRM_Utils_Array::value('activity_civireport', $this->_selectComponent)) {
         $componentClause = "civicrm_option_value.component_id IS NULL";
         $componentsIn = null;
         $compInfo = CRM_Core_Component::getEnabledComponents();
         foreach ($compInfo as $compObj) {
             if ($compObj->info['showActivitiesInCore']) {
                 $componentsIn = $componentsIn ? $componentsIn . ', ' . $compObj->componentID : $compObj->componentID;
             }
         }
         if ($componentsIn) {
             $componentClause = "( {$componentClause} OR \n                                      civicrm_option_value.component_id IN ({$componentsIn}) )";
         }
         $val = 'activity_civireport';
         $eligibleResult[$val] = $val;
         $sql = "{$this->_selectComponent[$val]} , \n                 sourceContact.display_name as added_by {$this->_formComponent[$val]}\n\n                 WHERE ( {$this->_aliases['civicrm_activity']}.source_contact_id IN ({$selectedContacts}) OR \n                         target_contact_id IN ({$selectedContacts}) OR \n                         assignee_contact_id IN ({$selectedContacts}) OR \n                         civicrm_case_contact.contact_id IN ({$selectedContacts}) ) AND \n                        civicrm_option_group.name = 'activity_type' AND \n                        {$this->_aliases['civicrm_activity']}.is_test = 0 AND \n                        ({$componentClause})\n\n                 GROUP BY {$this->_aliases['civicrm_activity']}.id \n\n                 ORDER BY {$this->_aliases['civicrm_activity']}.activity_date_time desc  ";
         $dao = CRM_Core_DAO::executeQuery($sql);
         while ($dao->fetch()) {
             foreach ($this->_columnHeadersComponent[$val] as $key => $value) {
                 if ($key == 'civicrm_activity_source_contact_id') {
                     $row[$key] = $dao->added_by;
                     continue;
                 }
                 $row[$key] = $dao->{$key};
             }
             if (isset($dao->civicrm_activity_source_contact_id)) {
                 $rows[$dao->civicrm_activity_source_contact_id][$val][] = $row;
             }
             if (isset($dao->target_contact_id)) {
                 $rows[$dao->target_contact_id][$val][] = $row;
             }
             if (isset($dao->assignee_contact_id)) {
                 $rows[$dao->assignee_contact_id][$val][] = $row;
             }
         }
         //unset the component header if data is not present
         foreach ($this->_component as $val) {
             if (!in_array($val, $eligibleResult)) {
                 unset($this->_columnHeadersComponent[$val]);
             }
         }
     }
     return $rows;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:96,代码来源:Detail.php

示例13: exportComponents

 /**
  * Function to get the list the export fields
  *
  * @param int    $selectAll user preference while export
  * @param array  $ids  contact ids
  * @param array  $params associated array of fields
  * @param string $order order by clause
  * @param array  $associated array of fields
  * @param array  $moreReturnProperties additional return fields
  * @param int    $exportMode export mode
  * @param string $componentClause component clause
  *
  * @static
  * @access public
  */
 static function exportComponents($selectAll, $ids, $params, $order = null, $fields = null, $moreReturnProperties = null, $exportMode = CRM_Export_Form_Select::CONTACT_EXPORT, $componentClause = null)
 {
     $headerRows = array();
     $primary = false;
     $returnProperties = array();
     $origFields = $fields;
     $queryMode = null;
     $paymentFields = false;
     $phoneTypes = CRM_Core_PseudoConstant::phoneType();
     $imProviders = CRM_Core_PseudoConstant::IMProvider();
     $contactRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, null, null, null, true, 'label', false);
     $queryMode = CRM_Contact_BAO_Query::MODE_CONTACTS;
     switch ($exportMode) {
         case CRM_Export_Form_Select::CONTRIBUTE_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_CONTRIBUTE;
             break;
         case CRM_Export_Form_Select::EVENT_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_EVENT;
             break;
         case CRM_Export_Form_Select::MEMBER_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_MEMBER;
             break;
         case CRM_Export_Form_Select::PLEDGE_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_PLEDGE;
             break;
         case CRM_Export_Form_Select::CASE_EXPORT:
             $queryMode = CRM_Contact_BAO_Query::MODE_CASE;
             break;
     }
     require_once 'CRM/Core/BAO/CustomField.php';
     if ($fields) {
         //construct return properties
         $locationTypes =& CRM_Core_PseudoConstant::locationType();
         $locationTypeFields = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'geo_code_1', 'geo_code_2', 'state_province', 'country', 'phone', 'email', 'im');
         foreach ($fields as $key => $value) {
             $phoneTypeId = null;
             $imProviderId = null;
             $relationshipTypes = $fieldName = CRM_Utils_Array::value(1, $value);
             if (!$fieldName) {
                 continue;
             }
             // get phoneType id and IM service provider id seperately
             if ($fieldName == 'phone') {
                 $phoneTypeId = CRM_Utils_Array::value(3, $value);
             } else {
                 if ($fieldName == 'im') {
                     $imProviderId = CRM_Utils_Array::value(3, $value);
                 }
             }
             if (array_key_exists($relationshipTypes, $contactRelationshipTypes)) {
                 if (CRM_Utils_Array::value(2, $value)) {
                     $relationField = CRM_Utils_Array::value(2, $value);
                     if (trim(CRM_Utils_Array::value(3, $value))) {
                         $relLocTypeId = CRM_Utils_Array::value(3, $value);
                     } else {
                         $relLocTypeId = 1;
                     }
                     if ($relationField == 'phone') {
                         $relPhoneTypeId = CRM_Utils_Array::value(4, $value);
                     } else {
                         if ($relationField == 'im') {
                             $relIMProviderId = CRM_Utils_Array::value(4, $value);
                         }
                     }
                 } else {
                     if (CRM_Utils_Array::value(4, $value)) {
                         $relationField = CRM_Utils_Array::value(4, $value);
                         $relLocTypeId = CRM_Utils_Array::value(5, $value);
                         if ($relationField == 'phone') {
                             $relPhoneTypeId = CRM_Utils_Array::value(6, $value);
                         } else {
                             if ($relationField == 'im') {
                                 $relIMProviderId = CRM_Utils_Array::value(6, $value);
                             }
                         }
                     }
                 }
             }
             $contactType = CRM_Utils_Array::value(0, $value);
             $locTypeId = CRM_Utils_Array::value(2, $value);
             $phoneTypeId = CRM_Utils_Array::value(3, $value);
             if ($relationField) {
                 if (in_array($relationField, $locationTypeFields)) {
                     if ($relPhoneTypeId) {
                         $returnProperties[$relationshipTypes]['location'][$locationTypes[$relLocTypeId]]['phone-' . $relPhoneTypeId] = 1;
//.........这里部分代码省略.........
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:Export.php

示例14: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     // Select list
     $relationshipList = CRM_Contact_BAO_Relationship::getContactRelationshipType($this->_contactId, $this->_rtype, $this->_relationshipId);
     // Metadata needed on clientside
     $contactTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE);
     $jsData = array();
     // Get just what we need to keep the dom small
     $whatWeWant = array_flip(array('contact_type_a', 'contact_type_b', 'contact_sub_type_a', 'contact_sub_type_b'));
     foreach ($this->_allRelationshipNames as $id => $vals) {
         if ($vals['name_a_b'] === 'Employee of') {
             $this->assign('employmentRelationship', $id);
         }
         if (isset($relationshipList["{$id}_a_b"]) || isset($relationshipList["{$id}_b_a"])) {
             $jsData[$id] = array_filter(array_intersect_key($this->_allRelationshipNames[$id], $whatWeWant));
             // Add user-friendly placeholder
             foreach (array('a', 'b') as $x) {
                 $type = !empty($jsData[$id]["contact_sub_type_{$x}"]) ? $jsData[$id]["contact_sub_type_{$x}"] : CRM_Utils_Array::value("contact_type_{$x}", $jsData[$id]);
                 $jsData[$id]["placeholder_{$x}"] = $type ? ts('- select %1 -', array(strtolower($contactTypes[$type]['label']))) : ts('- select contact -');
             }
         }
     }
     $this->assign('relationshipData', $jsData);
     $this->addField('relationship_type_id', array('options' => array('' => ts('- select -')) + $relationshipList, 'class' => 'huge', 'placeholder' => '- select -'), TRUE);
     $label = $this->_action & CRM_Core_Action::ADD ? ts('Contact(s)') : ts('Contact');
     $contactField = $this->addField('related_contact_id', array('label' => $label, 'name' => 'contact_id_b', 'multiple' => TRUE, 'create' => TRUE), TRUE);
     // This field cannot be updated
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $contactField->freeze();
     }
     $this->add('advcheckbox', 'is_current_employer', $this->_contactType == 'Organization' ? ts('Current Employee') : ts('Current Employer'));
     $this->addField('start_date', array('label' => ts('Start Date'), 'formatType' => 'searchDate'));
     $this->addField('end_date', array('label' => ts('End Date'), 'formatType' => 'searchDate'));
     $this->addField('is_active', array('label' => ts('Enabled?')));
     $this->addField('is_permission_a_b');
     $this->addField('is_permission_b_a');
     $this->addField('description', array('label' => ts('Description')));
     CRM_Contact_Form_Edit_Notes::buildQuickForm($this);
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'))));
     } else {
         // make this form an upload since we don't know if the custom data injected dynamically is of type file etc.
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save Relationship'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     }
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:52,代码来源:Relationship.php

示例15: relationship

 /**
  * where / qill clause for relationship
  *
  * @return void
  * @access public
  */
 function relationship(&$values)
 {
     list($name, $op, $value, $grouping, $wildcard) = $values;
     // also get values array for relation_target_name
     // for relatinship search we always do wildcard
     $targetName = $this->getWhereValues('relation_target_name', $grouping);
     $relStatus = $this->getWhereValues('relation_status', $grouping);
     $nameClause = null;
     if ($targetName) {
         $name = trim($targetName[2]);
         if (substr($name, 0, 1) == '"' && substr($name, -1, 1) == '"') {
             $name = substr($name, 1, -1);
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "= '{$name}'";
         } else {
             $name = strtolower(CRM_Core_DAO::escapeString($name));
             $nameClause = "LIKE '%{$name}%'";
         }
     }
     $rel = explode('_', $value);
     self::$_relType = $rel[1];
     if ($nameClause) {
         require_once 'CRM/Contact/BAO/RelationshipType.php';
         $params = array('id' => $rel[0]);
         $rTypeValues = array();
         require_once "CRM/Contact/BAO/RelationshipType.php";
         $rType =& CRM_Contact_BAO_RelationshipType::retrieve($params, $rTypeValues);
         if (!$rType) {
             return;
         }
         // for relatinship search we always do wildcard
         if ($rTypeValues['name_a_b'] == $rTypeValues['name_b_a']) {
             self::$_relType = 'reciprocal';
         }
         $this->_where[$grouping][] = "( contact_b.sort_name {$nameClause} AND contact_b.id != contact_a.id )";
     }
     require_once 'CRM/Contact/BAO/Relationship.php';
     $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Individual');
     $relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Organization');
     $relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(null, 'null', null, 'Household');
     $allRelationshipType = array();
     $allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
     $allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
     $this->_qill[$grouping][] = "{$allRelationshipType[$value]}  {$name}";
     //check for active, inactive and all relation status
     $today = date('Ymd');
     if ($relStatus[2] == 0) {
         $this->_where[$grouping][] = "civicrm_relationship.is_active = 1 AND ( civicrm_relationship.end_date is NULL OR civicrm_relationship.end_date >= {$today} )";
         $this->_qill[$grouping][] = ts('Relationship - Active');
     } else {
         if ($relStatus[2] == 1) {
             $this->_where[$grouping][] = "(civicrm_relationship.is_active = 0 OR civicrm_relationship.end_date < {$today})";
             $this->_qill[$grouping][] = ts('Relationship - Inactive');
         }
     }
     $this->_where[$grouping][] = 'civicrm_relationship.relationship_type_id = ' . $rel[0];
     $this->_tables['civicrm_relationship'] = $this->_whereTables['civicrm_relationship'] = 1;
     $this->_useDistinct = true;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:65,代码来源:Query.php


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