'account_name', * 'rname' => 'name', * 'id_name' => 'account_id', * 'vname' => 'LBL_ACCOUNT_NAME', * 'join_name'=>'accounts', * 'type' => 'relate', * 'link' => 'accounts', * 'table' => 'accounts', * 'module' => 'Accounts', * 'source' => 'non-db' * A link field which references the shared Relationship */ class OneToManyRelationship extends AbstractRelationship { /* * Constructor * @param array $definition Parameters passed in as array defined in parent::$definitionKeys * The lhs_module value is for the One side; the rhs_module value is for the Many */ function __construct ($definition) { parent::__construct ( $definition ) ; } /* * BUILD methods called during the build */ /* * Construct subpanel definitions * The format is that of TO_MODULE => relationship, FROM_MODULE, FROM_MODULES_SUBPANEL, mimicking the format in the layoutdefs.php * @return array An array of subpanel definitions, keyed by the module */ function buildSubpanelDefinitions () { if ($this->relationship_only) return array () ; $source = ""; if ($this->rhs_module == $this->lhs_module) { $source = $this->getJoinKeyLHS(); } return array( $this->lhs_module => $this->getSubpanelDefinition ( $this->relationship_name, $this->rhs_module, $this->rhs_subpanel , $this->getRightModuleSystemLabel() , $source ) ); } /* * @return array An array of field definitions, ready for the vardefs, keyed by module */ function buildVardefs ( ) { $vardefs = array ( ) ; $vardefs [ $this->rhs_module ] [] = $this->getLinkFieldDefinition ( $this->lhs_module, $this->relationship_name, false, 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel() ) . '_TITLE', $this->relationship_only ? false : $this->getIDName( $this->lhs_module ) ) ; if ($this->rhs_module != $this->lhs_module ) { $vardefs [ $this->lhs_module ] [] = $this->getLinkFieldDefinition ( $this->rhs_module, $this->relationship_name, true, 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE'); } if (! $this->relationship_only) { $vardefs [ $this->rhs_module ] [] = $this->getRelateFieldDefinition ( $this->lhs_module, $this->relationship_name, $this->getLeftModuleSystemLabel() ) ; $vardefs [ $this->rhs_module ] [] = $this->getLink2FieldDefinition ( $this->lhs_module, $this->relationship_name, true, 'LBL_' . strtoupper ( $this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel() ) . '_TITLE'); } return $vardefs ; } /* * Define what fields to add to which modules layouts * @return array An array of module => fieldname */ function buildFieldsToLayouts () { if ($this->relationship_only) return array () ; return array( $this->rhs_module =>$this->getValidDBName($this->relationship_name . "_name")); // this must match the name of the relate field from buildVardefs } /* * @return array An array of relationship metadata definitions */ function buildRelationshipMetaData () { return array( $this->lhs_module => $this->getRelationshipMetaData ( MB_ONETOMANY ) ) ; } } ?>