value pairs of fields to save on the relationship * @return boolean true if successful */ public function add($lhs, $rhs, $additionalFields = array()) { $lhsLinkName = $this->lhsLink; if (empty($lhs->$lhsLinkName) && !$lhs->load_relationship($lhsLinkName)) { $lhsClass = get_class($lhs); $GLOBALS['log']->fatal("could not load LHS $lhsLinkName in $lhsClass"); return false; } //Many to many has no additional logic, so just add a new row to the table and notify the beans. $dataToInsert = $this->getRowToInsert($lhs, $rhs, $additionalFields); $this->addRow($dataToInsert); if ($this->self_referencing) $this->addSelfReferencing($lhs, $rhs, $additionalFields); if ($lhs->$lhsLinkName->beansAreLoaded()) $lhs->$lhsLinkName->addBean($rhs); $this->callAfterAdd($lhs, $rhs, $lhsLinkName); } public function remove($lhs, $rhs) { $lhsLinkName = $this->lhsLink; if (!($lhs instanceof SugarBean)) { $GLOBALS['log']->fatal("LHS is not a SugarBean object"); return false; } if (!($rhs instanceof SugarBean)) { $GLOBALS['log']->fatal("RHS is not a SugarBean object"); return false; } if (empty($lhs->$lhsLinkName) && !$lhs->load_relationship($lhsLinkName)) { $GLOBALS['log']->fatal("could not load LHS $lhsLinkName"); return false; } $dataToRemove = array( $this->def['join_key_lhs'] => $lhs->id, $this->def['join_key_rhs'] => $rhs->id ); $this->removeRow($dataToRemove); if ($this->self_referencing) $this->removeSelfReferencing($lhs, $rhs); if (empty($_SESSION['disable_workflow']) || $_SESSION['disable_workflow'] != "Yes") { if (!empty($lhs->$lhsLinkName)) { $lhs->$lhsLinkName->load(); $this->callAfterDelete($lhs, $rhs, $lhsLinkName); } } } }