本文整理汇总了PHP中SugarBean::save_relationship_changes方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarBean::save_relationship_changes方法的具体用法?PHP SugarBean::save_relationship_changes怎么用?PHP SugarBean::save_relationship_changes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarBean
的用法示例。
在下文中一共展示了SugarBean::save_relationship_changes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Save changes that have been made to a relationship.
*
* @param $is_update true if this save is an update.
*/
function save_relationship_changes($is_update, $exclude = array())
{
parent::save_relationship_changes($is_update, $exclude);
$new_rel_id = false;
$new_rel_link = false;
//this allows us to dynamically relate modules without adding it to the relationship_fields array
if (!empty($_REQUEST['relate_id']) && !in_array($_REQUEST['relate_to'], $exclude) && $_REQUEST['relate_id'] != $this->id) {
$new_rel_id = $_REQUEST['relate_id'];
$new_rel_relname = $_REQUEST['relate_to'];
if (!empty($this->in_workflow) && !empty($this->not_use_rel_in_req)) {
$new_rel_id = $this->new_rel_id;
$new_rel_relname = $this->new_rel_relname;
}
$new_rel_link = $new_rel_relname;
//Try to find the link in this bean based on the relationship
foreach ($this->field_defs as $key => $def) {
if (isset($def['type']) && $def['type'] == 'link' && isset($def['relationship']) && $def['relationship'] == $new_rel_relname) {
$new_rel_link = $key;
}
}
if ($new_rel_link == 'contacts') {
$accountId = $this->db->getOne('SELECT account_id FROM accounts_contacts WHERE contact_id=' . $this->db->quoted($new_rel_id));
if ($accountId !== false) {
if ($this->load_relationship('accounts')) {
$this->accounts->add($accountId);
}
}
}
}
}
示例2: testChangingOfRelation
/**
* Test tries to emulate changing of related field and assert correct result
*
* @group 44930
* @return void
*/
public function testChangingOfRelation()
{
$_REQUEST['relate_id'] = '2';
$_REQUEST['relate_to'] = 'test';
$bean = new SugarBean();
$bean->id = '1';
$bean->test_id = '3';
$bean->field_defs = array('test' => array('type' => 'link', 'relationship' => 'test', 'link_file' => 'data/SugarBean.php', 'link_class' => 'Link44930'));
$bean->relationship_fields = array('test_id' => 'test');
$bean->save_relationship_changes(true);
$this->assertEquals($bean->test_id, $bean->test->lastCall, 'Last relation should point to test_id instead of relate_id');
}
示例3:
function save_relationship_changes($is_update)
{
parent::save_relationship_changes($is_update);
if ($this->lead_id != "") {
$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
}
if ($this->contact_id != "") {
$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
}
if ($this->prospect_id != "") {
$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
}
}
示例4: array
function save_relationship_changes($is_update) {
$exclude = array();
if(empty($this->in_workflow))
{
if(empty($this->in_import))
{
//if the global soap_server_object variable is not empty (as in from a soap/OPI call), then process the assigned_user_id relationship, otherwise
//add assigned_user_id to exclude list and let the logic from MeetingFormBase determine whether assigned user id gets added to the relationship
if(!empty($GLOBALS['soap_server_object']))
{
$exclude = array('lead_id', 'contact_id', 'user_id');
}
else
{
$exclude = array('lead_id', 'contact_id', 'user_id', 'assigned_user_id');
}
}
else
{
$exclude = array('user_id');
}
}
parent::save_relationship_changes($is_update, $exclude);
}
示例5:
function save_relationship_changes($is_update)
{
parent::save_relationship_changes($is_update);
if (!empty($this->contact_id)) {
$this->set_case_contact_relationship($this->contact_id);
}
}
示例6:
function save_relationship_changes($is_update)
{
//if account_id was replaced unlink the previous account_id.
//this rel_fields_before_value is populated by sugarbean during the retrieve call.
if (!empty($this->account_id) and !empty($this->rel_fields_before_value['account_id']) and trim($this->account_id) != trim($this->rel_fields_before_value['account_id'])) {
//unlink the old record.
$this->load_relationship('accounts');
$this->accounts->delete($this->id, $this->rel_fields_before_value['account_id']);
}
// Bug 38529 & 40938 - exclude currency_id
parent::save_relationship_changes($is_update, ['currency_id']);
if (!empty($this->contact_id)) {
$this->set_opportunity_contact_relationship($this->contact_id);
}
}
示例7: array
function save_relationship_changes($is_update, $exclude = array())
{
parent::save_relationship_changes($is_update, $exclude);
if($this->lead_id != "")
$this->set_prospect_relationship($this->id, $this->lead_id, "lead");
if($this->contact_id != "")
$this->set_prospect_relationship($this->id, $this->contact_id, "contact");
if($this->prospect_id != "")
$this->set_prospect_relationship($this->id, $this->contact_id, "prospect");
}
示例8: array
function save_relationship_changes($is_update)
{
$exclude = array();
if (empty($this->in_workflow)) {
$exclude = array('lead_id', 'contact_id', 'user_id');
}
parent::save_relationship_changes($is_update, $exclude);
}
示例9: save_relationship_changes
public function save_relationship_changes($is_update)
{
//if account_id was replaced unlink the previous account_id.
//this rel_fields_before_value is populated by sugarbean during the retrieve call.
if (!empty($this->account_id) and !empty($this->rel_fields_before_value['account_id']) and trim($this->account_id) != trim($this->rel_fields_before_value['account_id'])) {
//unlink the old record.
$this->load_relationship('accounts');
$this->accounts->delete($this->id, $this->rel_fields_before_value['account_id']);
//propagate change down to related beans
$relationshipsToBeTouched = array('products', 'revenuelineitems');
foreach ($relationshipsToBeTouched as $relationship) {
$this->load_relationship($relationship);
foreach ($this->{$relationship}->getBeans() as $bean) {
$bean->account_id = $this->account_id;
$bean->save();
}
}
}
// Bug 38529 & 40938 - exclude currency_id
parent::save_relationship_changes($is_update, array('currency_id'));
if (!empty($this->contact_id)) {
$this->set_opportunity_contact_relationship($this->contact_id);
}
}
示例10: array
function save_relationship_changes($is_update)
{
parent::save_relationship_changes($is_update, array('lead_id', 'contact_id', 'user_id'));
}
示例11:
function save_relationship_changes($is_update)
{
//if account_id was replaced unlink the previous account_id.
//this rel_fields_before_value is populated by sugarbean during the retrieve call.
if (!empty($this->account_id) and !empty($this->rel_fields_before_value['account_id']) and trim($this->account_id) != trim($this->rel_fields_before_value['account_id'])) {
//unlink the old record.
$this->load_relationship('accounts');
$this->accounts->delete($this->id, $this->rel_fields_before_value['account_id']);
}
parent::save_relationship_changes($is_update);
}