本文整理汇总了PHP中CRM_Contact_BAO_Relationship类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Relationship类的具体用法?PHP CRM_Contact_BAO_Relationship怎么用?PHP CRM_Contact_BAO_Relationship使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Contact_BAO_Relationship类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: triggerTrigger
/**
* Trigger a rule for this trigger
*
* @param $op
* @param $objectName
* @param $objectId
* @param $objectRef
*/
public function triggerTrigger($op, $objectName, $objectId, $objectRef)
{
$t = $this->getTriggerDataFromPost($op, $objectName, $objectId, $objectRef);
//trigger for each client
$clients = CRM_Case_BAO_Case::getCaseClients($objectId);
foreach ($clients as $client) {
$triggerData = clone $t;
$triggerData->setEntityData('Relationship', null);
$triggerData->setContactId($client);
CRM_Civirules_Engine::triggerRule($this, $triggerData);
}
//trigger for each case role
$relatedContacts = CRM_Case_BAO_Case::getRelatedContacts($objectId);
foreach ($relatedContacts as $contact) {
$triggerData = clone $t;
$relationshipData = null;
$relationship = new CRM_Contact_BAO_Relationship();
$relationship->contact_id_b = $contact['contact_id'];
$relationship->case_id = $objectId;
if ($relationship->find(true)) {
CRM_Core_DAO::storeValues($relationship, $relationshipData);
}
$triggerData->setEntityData('Relationship', $relationshipData);
$triggerData->setContactId($contact['contact_id']);
CRM_Civirules_Engine::triggerRule($this, $triggerData);
}
}
示例2: addRelationships
/**
* Add relationships from form.
*/
public function addRelationships()
{
if (!is_array($this->_contactIds)) {
// Could this really happen?
return;
}
$relationshipTypeParts = explode('_', $this->params['relationship_type_id']);
$params = array('relationship_type_id' => $relationshipTypeParts[0], 'is_active' => 1);
$secondaryRelationshipSide = $relationshipTypeParts[1];
$primaryRelationshipSide = $relationshipTypeParts[2];
$primaryFieldName = 'contact_id_' . $primaryRelationshipSide;
$secondaryFieldName = 'contact_id_' . $secondaryRelationshipSide;
$relationshipLabel = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $params['relationship_type_id'], "label_{$secondaryRelationshipSide}_{$primaryRelationshipSide}");
$params[$secondaryFieldName] = $this->_contactIds;
$params[$primaryFieldName] = $this->params['contact_check'];
$outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $primaryRelationshipSide);
$relatedContactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$primaryFieldName], 'display_name');
$status = array(ts('%count %2 %3 relationship created', array('count' => $outcome['valid'], 'plural' => '%count %2 %3 relationships created', 2 => $relationshipLabel, 3 => $relatedContactName)));
if ($outcome['duplicate']) {
$status[] = ts('%count was skipped because the contact is already %2 %3', array('count' => $outcome['duplicate'], 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationshipLabel, 3 => $relatedContactName));
}
if ($outcome['invalid']) {
$status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array('count' => $outcome['invalid'], 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship'));
}
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
CRM_Core_Session::setStatus($status, ts('Relationship created.', array('count' => $outcome['valid'], 'plural' => 'Relationships created.')), 'success', array('expires' => 0));
}
示例3: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
CRM_Utils_System::setTitle(ts('Add Contacts to Organization'));
$this->addElement('text', 'name', ts('Find Target Organization'));
$this->add('select', 'relationship_type_id', ts('Relationship Type'), array('' => ts('- select -')) + CRM_Contact_BAO_Relationship::getRelationType("Organization"), TRUE);
$searchRows = $this->get('searchRows');
$searchCount = $this->get('searchCount');
if ($searchRows) {
$checkBoxes = array();
$chekFlag = 0;
foreach ($searchRows as $id => $row) {
if (!$chekFlag) {
$chekFlag = $id;
}
$checkBoxes[$id] = $this->createElement('radio', NULL, NULL, NULL, $id);
}
$this->addGroup($checkBoxes, 'contact_check');
if ($chekFlag) {
$checkBoxes[$chekFlag]->setChecked(TRUE);
}
$this->assign('searchRows', $searchRows);
}
$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', ts('Organization'));
$this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit'));
$this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit'));
$this->addButtons(array(array('type' => 'next', 'name' => ts('Add to Organization'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
示例4: __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();
}
示例5: preProcess
/**
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
*/
public static function preProcess(&$form)
{
$session = CRM_Core_Session::singleton();
$contactID = $form->_contactID;
$ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $form->_id);
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$form->_profileId = $profileId[0];
if (!$form->_profileId || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
}
$requiredProfileFields = array('organization_name', 'email');
$validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
if (!$validProfile) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
}
$form->assign('profileId', $form->_profileId);
$form->assign('mode', $form->_mode);
if ($contactID) {
$form->_employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
if (!empty($form->_membershipContactID) && $contactID != $form->_membershipContactID) {
// renewal case - membership being renewed may or may not be for organization
if (!empty($form->_employers) && array_key_exists($form->_membershipContactID, $form->_employers)) {
// if _membershipContactID belongs to employers list, we can say:
$form->_relatedOrganizationFound = TRUE;
}
} elseif (!empty($form->_employers)) {
// not a renewal case and _employers list is not empty
$form->_relatedOrganizationFound = TRUE;
}
if ($form->_relatedOrganizationFound) {
// Related org url - pass checksum if needed
$args = array('cid' => '');
if (!empty($_GET['cs'])) {
$args = array('uid' => $form->_contactID, 'cs' => $_GET['cs'], 'cid' => '');
}
$locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
$form->assign('locDataURL', $locDataURL);
if (!empty($form->_submitValues['onbehalf'])) {
if (!empty($form->_submitValues['onbehalfof_id'])) {
$form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
}
$form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
}
}
if ($form->_values['is_for_organization'] != 2) {
$form->assign('relatedOrganizationFound', $form->_relatedOrganizationFound);
} else {
$form->assign('onBehalfRequired', $form->_onBehalfRequired);
}
if (count($form->_employers) == 1) {
foreach ($form->_employers as $id => $value) {
$form->_organizationName = $value['name'];
$orgId = $id;
}
$form->assign('orgId', $orgId);
$form->assign('organizationName', $form->_organizationName);
}
}
}
示例6: __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();
}
示例7: setDefaultValues
/**
* set defaults for the form
*
* @return array
* @access public
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if ($this->_contactType == 'Individual') {
// set current employer details
$currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
$defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
$this->assign('currentEmployer', CRM_Utils_Array::value('current_employer_id', $defaults));
}
return $defaults;
}
示例8: preProcess
/**
* This function is called prior to building and submitting the form
*/
function preProcess()
{
// check contact_id
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if (empty($this->_contactId)) {
CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// check for permissions
$session = CRM_Core_Session::singleton();
if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
// this also redirects to the default civicrm page
}
// get session
$session = CRM_Core_Session::singleton();
// redirect user after postProcess
//$urlParams = 'reset=1&cid=' . $this->_contactId;
//$session->pushUserContext(CRM_Utils_System::url('civicrm/lidmaatschapwijziging/contact', $urlParams));
// get values
$this->_configContact = CRM_Lidmaatschapwijziging_ConfigContact::singleton($this->_contactId);
$this->_values = $this->_configContact->getContact();
// set display name
$this->_display_name = $this->_values['display_name'];
// set title
CRM_Utils_System::setTitle('LidmaatschapWijziging - Contact - ' . $this->_values['display_name']);
// set contact id
$this->_values['contact_id'] = $this->_contactId;
// change the default name like huppeldepup_35 to huppeldepup, this
// ensures the we can use the know names for custom fields in the template like
// huppeldepup and not the column_names like huppeldepup_35
$values = $this->_configContact->getVnvInfoCustomValues();
// set vnvn info id, is neede for update or insert in the postProccess
if (isset($values['id']) and !empty($values['id'])) {
$this->_vnvinfoId = $values['id'];
}
foreach ($this->_configContact->getVnvInfoCustomFields() as $key => $field) {
$this->_values[$field['name']] = $values[$field['column_name']];
}
$values = $this->_configContact->getWerkgeverCustomValues();
// set werkgever id, is neede for update or insert in the postProccess
if (isset($values['id']) and !empty($values['id'])) {
$this->_werkgeverId = $values['id'];
}
foreach ($this->_configContact->getWerkgeverCustomFields() as $key => $field) {
$this->_values[$field['name']] = $values[$field['column_name']];
}
$currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
$defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
// assign values needed for the template
$this->assign('contactId', $this->_contactId);
$this->assign('employerDataURL', '/civicrm/ajax/rest?className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $this->_contactId);
$this->assign('currentEmployer', $this->_values['employer_id']);
}
示例9: 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);
}
示例10: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
static function preProcess(&$form)
{
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
$ufJoinParams = array('module' => 'onBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $form->_id);
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
$form->_profileId = $profileId[0];
if (!$form->_profileId || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $form->_profileId, 'is_active')) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the selected onbehalf profile is either disabled or not found.'));
}
$requiredProfileFields = array('organization_name', 'email');
$validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_profileId, $requiredProfileFields);
if (!$validProfile) {
CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of an organization and the required fields of the selected onbehalf profile are disabled.'));
}
$form->assign('profileId', $form->_profileId);
$form->assign('mode', $form->_mode);
if ($contactID) {
$form->_employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($contactID);
if (!empty($form->_employers)) {
$form->_relatedOrganizationFound = TRUE;
$locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', 'cid=', FALSE, NULL, FALSE);
$form->assign('locDataURL', $locDataURL);
$dataURL = CRM_Utils_System::url('civicrm/ajax/employer', 'cid=' . $contactID, FALSE, NULL, FALSE);
$form->assign('employerDataURL', $dataURL);
}
if ($form->_values['is_for_organization'] != 2) {
$form->assign('relatedOrganizationFound', $form->_relatedOrganizationFound);
} else {
$form->assign('onBehalfRequired', $form->_onBehalfRequired);
}
if (count($form->_employers) == 1) {
foreach ($form->_employers as $id => $value) {
$form->_organizationName = $value['name'];
$orgId = $id;
}
$form->assign('orgId', $orgId);
$form->assign('organizationName', $form->_organizationName);
}
}
}
示例11: 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');
}
}
}
示例12: getCaseClientRelationships
public static function getCaseClientRelationships()
{
$caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
// Retrieve ALL client relationships
$relClient = CRM_Contact_BAO_Relationship::getRelationship($contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, NULL, NULL, FALSE);
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
// Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles
// so they don't show up twice.
$clientRelationships = array();
foreach ($relClient as $r) {
if (!array_key_exists($r['id'], $caseRelationships)) {
$clientRelationships[] = $r;
}
}
// sort clientRelationships array using jquery call params
foreach ($clientRelationships as $key => $row) {
$sortArray[$key] = $row[$params['_raw_values']['sort'][0]];
}
$sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]);
array_multisort($sortArray, constant($sort_type), $clientRelationships);
$relationships = array();
// after sort we can update username fields to be a url
foreach ($clientRelationships as $key => $value) {
$relationship = array();
$relationship['relation'] = $value['relation'];
$relationship['name'] = '<a href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $clientRelationships[$key]['cid']) . '>' . $clientRelationships[$key]['name'] . '</a>';
$relationship['phone'] = $value['phone'];
$relationship['email'] = $value['email'];
array_push($relationships, $relationship);
}
$clientRelationshipsDT = array();
$clientRelationshipsDT['data'] = $relationships;
$clientRelationshipsDT['recordsTotal'] = count($relationships);
$clientRelationshipsDT['recordsFiltered'] = count($relationships);
CRM_Utils_JSON::output($clientRelationshipsDT);
}
示例13: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
$defaults = $this->_values;
$params = array();
if ($this->_action & CRM_Core_Action::ADD) {
if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
// set group and tag defaults if any
if ($this->_gid) {
$defaults['group'][$this->_gid] = 1;
}
if ($this->_tid) {
$defaults['tag'][$this->_tid] = 1;
}
}
if ($this->_contactSubType) {
$defaults['contact_sub_type'] = $this->_contactSubType;
}
} else {
if (isset($this->_elementIndex["shared_household"])) {
$sharedHousehold = $this->getElementValue("shared_household");
if ($sharedHousehold) {
$this->assign('defaultSharedHousehold', $sharedHousehold);
} elseif (CRM_Utils_Array::value('mail_to_household_id', $defaults)) {
$defaults['use_household_address'] = true;
$this->assign('defaultSharedHousehold', $defaults['mail_to_household_id']);
}
$defaults['shared_household_id'] = CRM_Utils_Array::value('mail_to_household_id', $defaults);
if (array_key_exists(1, $defaults['address'])) {
$this->assign('sharedHouseholdAddress', $defaults['address'][1]['display']);
}
}
require_once 'CRM/Contact/BAO/Relationship.php';
$currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
$defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
$this->assign('currentEmployer', $defaults['current_employer_id']);
}
// set defaults for blocks ( custom data, address, communication preference, notes, tags and groups )
foreach ($this->_editOptions as $name => $label) {
if (!in_array($name, array('Address', 'Notes'))) {
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $name) . ".php";
eval('CRM_Contact_Form_Edit_' . $name . '::setDefaultValues( $this, $defaults );');
}
}
//set location type and country to default for each block
$this->blockSetDefaults($defaults);
return $defaults;
}
示例14: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$config = CRM_Core_Config::singleton();
$session = CRM_Core_Session::singleton();
// current contribution page id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if (!$this->_id) {
// seems like the session is corrupted and/or we lost the id trail
// lets just bump this to a regular session error and redirect user to main page
$this->controller->invalidKeyRedirect();
}
// this was used prior to the cleverer this_>getContactID - unsure now
$this->_userID = $session->get('userID');
$this->_contactID = $this->_membershipContactID = $this->getContactID();
$this->_mid = NULL;
if ($this->_contactID) {
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
if ($this->_mid) {
$membership = new CRM_Member_DAO_Membership();
$membership->id = $this->_mid;
if ($membership->find(TRUE)) {
$this->_defaultMemTypeId = $membership->membership_type_id;
if ($membership->contact_id != $this->_contactID) {
$validMembership = FALSE;
$employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
if (!empty($employers) && array_key_exists($membership->contact_id, $employers)) {
$this->_membershipContactID = $membership->contact_id;
$this->assign('membershipContactID', $this->_membershipContactID);
$this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
$validMembership = TRUE;
} else {
$membershipType = new CRM_Member_BAO_MembershipType();
$membershipType->id = $membership->membership_type_id;
if ($membershipType->find(TRUE)) {
// CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
// Convert to commma separated list.
$inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
$permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
if (array_key_exists($membership->contact_id, $permContacts)) {
$this->_membershipContactID = $membership->contact_id;
$validMembership = TRUE;
}
}
}
if (!$validMembership) {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
}
}
} else {
CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
}
unset($membership);
}
}
// we do not want to display recently viewed items, so turn off
$this->assign('displayRecent', FALSE);
// Contribution page values are cleared from session, so can't use normal Printer Friendly view.
// Use Browser Print instead.
$this->assign('browserPrint', TRUE);
// action
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
$this->assign('action', $this->_action);
// current mode
$this->_mode = $this->_action == 1024 ? 'test' : 'live';
$this->_values = $this->get('values');
$this->_fields = $this->get('fields');
$this->_bltID = $this->get('bltID');
$this->_paymentProcessor = $this->get('paymentProcessor');
$this->_priceSetId = $this->get('priceSetId');
$this->_priceSet = $this->get('priceSet');
if (!$this->_values) {
// get all the values from the dao object
$this->_values = array();
$this->_fields = array();
CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
// check if form is active
if (!CRM_Utils_Array::value('is_active', $this->_values)) {
// form is inactive, die a fatal death
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
// also check for billing informatin
// get the billing location type
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
// CRM-8108 remove ts around Billing location type
//$this->_bltID = array_search( ts('Billing'), $locationTypes );
$this->_bltID = array_search('Billing', $locationTypes);
if (!$this->_bltID) {
CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
}
$this->set('bltID', $this->_bltID);
// check for is_monetary status
$isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
$isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
//FIXME: to support multiple payment processors
//.........这里部分代码省略.........
示例15: getContactRelationships
/**
* Retrieve contact relationships.
*/
public static function getContactRelationships()
{
$contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
$context = CRM_Utils_Type::escape($_GET['context'], 'String');
$relationship_type_id = CRM_Utils_Type::escape(CRM_Utils_Array::value('relationship_type_id', $_GET), 'Integer', FALSE);
if (!CRM_Contact_BAO_Contact_Permission::allow($contactID)) {
return CRM_Utils_System::permissionDenied();
}
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
$params['contact_id'] = $contactID;
$params['context'] = $context;
if ($relationship_type_id) {
$params['relationship_type_id'] = $relationship_type_id;
}
// get the contact relationships
$relationships = CRM_Contact_BAO_Relationship::getContactRelationshipSelector($params);
CRM_Utils_JSON::output($relationships);
}