本文整理汇总了PHP中CRM_Contact_BAO_Relationship::getCurrentEmployer方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Relationship::getCurrentEmployer方法的具体用法?PHP CRM_Contact_BAO_Relationship::getCurrentEmployer怎么用?PHP CRM_Contact_BAO_Relationship::getCurrentEmployer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Relationship
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Relationship::getCurrentEmployer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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']);
}
示例3: 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;
}
示例4: 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 {
$currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
$defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
foreach ($defaults['email'] as $dontCare => &$val) {
if (isset($val['signature_text'])) {
$val['signature_text_hidden'] = $val['signature_text'];
}
if (isset($val['signature_html'])) {
$val['signature_html_hidden'] = $val['signature_html'];
}
}
if (CRM_Utils_Array::value('contact_sub_type', $defaults)) {
$defaults['contact_sub_type'] = $this->_oldSubtypes;
}
}
$this->assign('currentEmployer', CRM_Utils_Array::value('current_employer_id', $defaults));
// 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'))) {
eval('CRM_Contact_Form_Edit_' . $name . '::setDefaultValues( $this, $defaults );');
}
}
//set address block defaults
CRM_Contact_Form_Edit_Address::setDefaultValues($defaults, $this);
if (CRM_Utils_Array::value('image_URL', $defaults)) {
list($imageWidth, $imageHeight) = getimagesize($defaults['image_URL']);
list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
$this->assign('imageWidth', $imageWidth);
$this->assign('imageHeight', $imageHeight);
$this->assign('imageThumbWidth', $imageThumbWidth);
$this->assign('imageThumbHeight', $imageThumbHeight);
$this->assign('imageURL', $defaults['image_URL']);
}
//set location type and country to default for each block
$this->blockSetDefaults($defaults);
$this->_preEditValues = $defaults;
return $defaults;
}
示例5: view
/**
* View summary details of a contact
*
* @return void
* @access public
*/
function view()
{
$session =& CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
$session->pushUserContext($url);
$params = array();
$defaults = array();
$ids = array();
$params['id'] = $params['contact_id'] = $this->_contactId;
$contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, true);
$communicationType = array('phone' => array('type' => 'phoneType', 'id' => 'phone_type'), 'im' => array('type' => 'IMProvider', 'id' => 'provider'), 'address' => array('skip' => true), 'email' => array('skip' => true), 'openid' => array('skip' => true));
foreach ($communicationType as $key => $value) {
if (CRM_Utils_Array::value($key, $defaults)) {
foreach ($defaults[$key] as &$val) {
CRM_Utils_Array::lookupValue($val, 'location_type', CRM_Core_PseudoConstant::locationType(), false);
if (!CRM_Utils_Array::value('skip', $value)) {
eval('$pseudoConst = CRM_Core_PseudoConstant::' . $value['type'] . '( );');
CRM_Utils_Array::lookupValue($val, $value['id'], $pseudoConst, false);
}
}
}
}
if (CRM_Utils_Array::value('gender_id', $defaults)) {
$gender = CRM_Core_PseudoConstant::gender();
$defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
}
if (CRM_Utils_Array::value('contact_sub_type', $defaults)) {
$defaults['contact_sub_type'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $defaults['contact_sub_type'], 'label', 'name');
}
// get the list of all the categories
$tag =& CRM_Core_PseudoConstant::tag();
// get categories for the contact id
require_once 'CRM/Core/BAO/EntityTag.php';
$entityTag =& CRM_Core_BAO_EntityTag::getTag($this->_contactId);
if ($entityTag) {
$categories = array();
foreach ($entityTag as $key) {
$categories[] = $tag[$key];
}
$defaults['contactTag'] = implode(', ', $categories);
}
$defaults['privacy_values'] = CRM_Core_SelectValues::privacy();
//Show blocks only if they are visible in edit form
require_once 'CRM/Core/BAO/Preferences.php';
$this->_editOptions = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options');
$configItems = array('CommBlock' => 'Communication Preferences', 'Demographics' => 'Demographics', 'TagsAndGroups' => 'Tags and Groups', 'Notes' => 'Notes');
foreach ($configItems as $c => $t) {
$varName = '_show' . $c;
$this->{$varName} = CRM_Utils_Array::value($c, $this->_editOptions);
$this->assign(substr($varName, 1), $this->{$varName});
}
//get the householdname
if (isset($defaults['mail_to_household_id'])) {
$HouseholdName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $defaults['mail_to_household_id'], 'display_name', 'id');
$this->assign('HouseholdName', $HouseholdName);
}
//get the current employer name
if (CRM_Utils_Array::value('contact_type', $defaults) == 'Individual') {
require_once 'CRM/Contact/BAO/Relationship.php';
$currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
$defaults['current_employer'] = $currentEmployer[$this->_contactId]['org_name'];
$defaults['current_employer_id'] = $currentEmployer[$this->_contactId]['org_id'];
//for birthdate format with respect to birth format set
$this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
}
$this->assign($defaults);
// also assign the last modifed details
require_once 'CRM/Core/BAO/Log.php';
$lastModified =& CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact');
$this->assign_by_ref('lastModified', $lastModified);
$allTabs = array();
$weight = 10;
$this->_viewOptions = CRM_Core_BAO_Preferences::valueOptions('contact_view_options', true);
$changeLog = $this->_viewOptions['log'];
$this->assign_by_ref('changeLog', $changeLog);
require_once 'CRM/Core/Component.php';
$components = CRM_Core_Component::getEnabledComponents();
foreach ($components as $name => $component) {
if (CRM_Utils_Array::value($name, $this->_viewOptions) && CRM_Core_Permission::access($component->name)) {
$elem = $component->registerTab();
// FIXME: not very elegant, probably needs better approach
// allow explicit id, if not defined, use keyword instead
if (array_key_exists('id', $elem)) {
$i = $elem['id'];
} else {
$i = $component->getKeyword();
}
$u = $elem['url'];
//appending isTest to url for test soft credit CRM-3891.
//FIXME: hack ajax url.
$q = "reset=1&snippet=1&force=1&cid={$this->_contactId}";
if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
$q = $q . "&isTest=1";
}
//.........这里部分代码省略.........
示例6: 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 {
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']);
foreach ($defaults['email'] as $dontCare => &$val) {
if (isset($val['signature_text'])) {
$val['signature_text_hidden'] = $val['signature_text'];
}
if (isset($val['signature_html'])) {
$val['signature_html_hidden'] = $val['signature_html'];
}
}
}
// 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 );');
}
}
$addressValues = array();
if (isset($defaults['address']) && is_array($defaults['address']) && !CRM_Utils_system::isNull($defaults['address'])) {
// start of contact shared adddress defaults
$sharedAddresses = array();
$masterAddress = array();
// get contact name of shared contact names
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']);
foreach ($defaults['address'] as $key => $addressValue) {
if (CRM_Utils_Array::value('master_id', $addressValue) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
} else {
$defaults['address'][$key]['use_shared_address'] = 0;
}
//check if any address is shared by any other contacts
$masterAddress[$key] = CRM_Core_BAO_Address::checkContactSharedAddress($addressValue['id']);
}
$this->assign('sharedAddresses', $sharedAddresses);
$this->assign('masterAddress', $masterAddress);
// end of shared address defaults
// start of parse address functionality
// build street address, CRM-5450.
if ($this->_parseStreetAddress) {
$parseFields = array('street_address', 'street_number', 'street_name', 'street_unit');
foreach ($defaults['address'] as $cnt => &$address) {
$streetAddress = null;
foreach (array('street_number', 'street_number_suffix', 'street_name', 'street_unit') as $fld) {
if (in_array($fld, array('street_name', 'street_unit'))) {
$streetAddress .= ' ';
}
$streetAddress .= CRM_Utils_Array::value($fld, $address);
}
$streetAddress = trim($streetAddress);
if (!empty($streetAddress)) {
$address['street_address'] = $streetAddress;
}
$address['street_number'] .= CRM_Utils_Array::value('street_number_suffix', $address);
// build array for set default.
foreach ($parseFields as $field) {
$addressValues["{$field}_{$cnt}"] = CRM_Utils_Array::value($field, $address);
}
// don't load fields, use js to populate.
foreach (array('street_number', 'street_name', 'street_unit') as $f) {
if (isset($address[$f])) {
unset($address[$f]);
}
}
}
$this->assign('allAddressFieldValues', json_encode($addressValues));
//hack to handle show/hide address fields.
$parsedAddress = array();
if ($this->_contactId && CRM_Utils_Array::value('address', $_POST) && is_array($_POST['address'])) {
foreach ($_POST['address'] as $cnt => $values) {
$showField = 'streetAddress';
foreach (array('street_number', 'street_name', 'street_unit') as $fld) {
if (CRM_Utils_Array::value($fld, $values)) {
//.........这里部分代码省略.........
示例7: 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 );');
}
}
// build street address, CRM-5450.
$addressValues = array();
if ($this->_parseStreetAddress) {
if (is_array($defaults['address']) && !CRM_Utils_system::isNull($defaults['address'])) {
$parseFields = array('street_address', 'street_number', 'street_name', 'street_unit');
foreach ($defaults['address'] as $cnt => &$address) {
$streetAddress = null;
foreach (array('street_number', 'street_number_suffix', 'street_name', 'street_unit') as $fld) {
if (in_array($fld, array('street_name', 'street_unit'))) {
$streetAddress .= ' ';
}
$streetAddress .= CRM_Utils_Array::value($fld, $address);
}
$streetAddress = trim($streetAddress);
if (!empty($streetAddress)) {
$address['street_address'] = $streetAddress;
}
$address['street_number'] .= CRM_Utils_Array::value('street_number_suffix', $address);
// build array for set default.
foreach ($parseFields as $field) {
$addressValues["{$field}_{$cnt}"] = CRM_Utils_Array::value($field, $address);
}
// don't load fields, use js to populate.
foreach (array('street_number', 'street_name', 'street_unit') as $f) {
if (isset($address[$f])) {
unset($address[$f]);
}
}
}
}
$this->assign('allAddressFieldValues', json_encode($addressValues));
//hack to handle show/hide address fields.
$parsedAddress = array();
if ($this->_contactId && CRM_Utils_Array::value('address', $_POST) && is_array($_POST['address'])) {
foreach ($_POST['address'] as $cnt => $values) {
$showField = 'streetAddress';
foreach (array('street_number', 'street_name', 'street_unit') as $fld) {
if (CRM_Utils_Array::value($fld, $values)) {
$showField = 'addressElements';
break;
}
}
$parsedAddress[$cnt] = $showField;
}
}
$this->assign('showHideAddressFields', $parsedAddress);
$this->assign('loadShowHideAddressFields', empty($parsedAddress) ? false : true);
}
//set location type and country to default for each block
$this->blockSetDefaults($defaults);
//.........这里部分代码省略.........