protected function _initializeCustomfields() { foreach (TBGCustomDatatype::getAll() as $key => $customdatatype) { $var_name = "_customfield" . $key; $this->{$var_name} = null; } if ($rows = TBGIssueCustomFieldsTable::getTable()->getAllValuesByIssueID($this->getID())) { foreach ($rows as $row) { $datatype = new TBGCustomDatatype($row->get(TBGIssueCustomFieldsTable::CUSTOMFIELDS_ID)); $var_name = "_customfield" . $datatype->getKey(); if ($datatype->hasCustomOptions()) { $option = TBGCustomFieldOptionsTable::getTable()->selectById((int) $row->get(TBGIssueCustomFieldsTable::CUSTOMFIELDOPTION_ID)); if ($option instanceof TBGCustomDatatypeOption) { $this->{$var_name} = $option; } } else { if ($datatype->hasPredefinedOptions()) { $this->{$var_name} = $row->get(TBGIssueCustomFieldsTable::CUSTOMFIELDOPTION_ID); } else { $this->{$var_name} = $row->get(TBGIssueCustomFieldsTable::OPTION_VALUE); } } } } }
/** * Populates all the custom field values */ protected function _populateCustomfields() { if (!$this->_custom_populated) { $this->_custom_populated = true; foreach (TBGCustomDatatype::getAll() as $key => $customdatatype) { $var_name = "_customfield" . $key; $this->{$var_name} = null; } if ($res = TBGIssueCustomFieldsTable::getTable()->getAllValuesByIssueID($this->getID())) { while ($row = $res->getNextRow()) { $datatype = new TBGCustomDatatype($row->get(TBGIssueCustomFieldsTable::CUSTOMFIELDS_ID)); $var_name = "_customfield" . $datatype->getKey(); if ($datatype->hasCustomOptions()) { if ($optionrow = TBGCustomFieldOptionsTable::getTable()->doSelectById($row->get(TBGIssueCustomFieldsTable::OPTION_VALUE))) { $this->{$var_name} = $optionrow->get(TBGCustomFieldOptionsTable::OPTION_VALUE); } } else { $this->{$var_name} = $row->get(TBGIssueCustomFieldsTable::OPTION_VALUE); } } } $this->_mergeChangedProperties(); } }