/** * Get join row * * @return FabrikTableJoin Join table or false if not loaded */ protected function getJoin() { if (isset($this->join)) { return $this->join; } $input = $this->app->input; $element = $this->getElement(); if ($element->get('published') == 0) { return false; } if (!$this->getFormModel()->getForm()->record_in_database) { // Db join in form not recording to db $joinModel = JModelLegacy::getInstance('Join', 'FabrikFEModel'); $this->join = $joinModel->getJoinFromKey('element_id', $element->get('id')); return $this->join; } else { $listModel = $this->getlistModel(); $table = $listModel->getTable(); $joins = $listModel->getJoins(); foreach ($joins as $join) { if ($join->element_id == $element->get('id')) { $this->join = $join; if (is_string($this->join->params)) { $this->join->params = new Registry($this->join->params); } return $this->join; } } $config = array(); $config['dbo'] = FabrikWorker::getDbo(true); $this->join = JTable::getInstance('Join', 'FabrikTable', $config); if ($this->join->load(array('element_id' => $element->get('id')))) { if (is_string($this->join->params)) { $this->join->params = new Registry($this->join->params); } return $this->join; } } // Try to build the join record (could have been generated from a content type import) $data = array('id' => 0, 'group_id' => $element->get('group_id')); $this->join = $this->updateFabrikJoin($data, $element->get('id'), $this->getDbName(), $this->getJoinValueFieldName(), $this->getLabelParamVal()); // Rebuild the join aliases. $this->getlistModel()->getJoins(); $j = (object) $this->join->getProperties(); $j->params = (string) $j->params; $this->getlistModel()->makeJoinAliases($j); if ($this->join) { return $this->join; } /* * Suppress error for inlineedit, something not quite right as groupModel::getPublishedElements() is limited by the elementid request va * but the list model is calling getAsFields() and loading up the db join element. * so test case would be an inline edit list with a database join element and editing anything but the db join element */ if (!in_array($input->get('task'), array('inlineedit', 'form.inlineedit')) && $input->get('format') !== 'raw') { throw new RuntimeException('unable to process db join element id:' . $element->id, 500); } return false; }
/** * Get join row * * @return FabrikTableJoin Join table or false if not loaded */ protected function getJoin() { if (isset($this->join)) { return $this->join; } $input = $this->app->input; $element = $this->getElement(); if ($element->published == 0) { return false; } if (!$this->getFormModel()->getForm()->record_in_database) { // Db join in form not recording to db $joinModel = JModelLegacy::getInstance('Join', 'FabrikFEModel'); $this->join = $joinModel->getJoinFromKey('element_id', $element->get('id')); return $this->join; } else { $listModel = $this->getlistModel(); $table = $listModel->getTable(); $joins = $listModel->getJoins(); foreach ($joins as $join) { if ($join->element_id == $element->get('id')) { $this->join = $join; if (is_string($this->join->params)) { $this->join->params = new JRegistry($this->join->params); } return $this->join; } } $config = array(); $config['dbo'] = FabrikWorker::getDbo(true); $this->join = JTable::getInstance('Join', 'FabrikTable', $config); if ($this->join->load(array('element_id' => $element->id))) { if (is_string($this->join->params)) { $this->join->params = new JRegistry($this->join->params); } return $this->join; } } if (!in_array($input->get('task'), array('inlineedit', 'form.inlineedit')) && $input->get('format') !== 'raw') { /* * Suppress error for inlineedit, something not quite right as groupModel::getPublishedElements() is limited by the elementid request va * but the list model is calling getAsFields() and loading up the db join element. * so test case would be an inline edit list with a database join element and editing anything but the db join element */ throw new RuntimeException('unable to process db join element id:' . $element->id, 500); } return false; }
/** * Get the group's associated join model * * @return FabrikFEModelJoin join model */ public function getJoinModel() { $group = $this->getGroup(); if (is_null($this->joinModel)) { $this->joinModel = JModelLegacy::getInstance('Join', 'FabrikFEModel'); $this->joinModel->setId($group->join_id); $js = $this->getListModel()->getJoins(); // $$$ rob set join models data from preloaded table joins - reduced load time for ($x = 0; $x < count($js); $x++) { if ($js[$x]->id == $group->join_id && $js[$x]->element_id == 0) { $this->joinModel->setData($js[$x]); break; } } $this->joinModel->getJoin(); } return $this->joinModel; }