public function _migrateData(\b2db\Table $old_table) { switch ($old_table->getVersion()) { case 1: if ($res = $old_table->doSelectAll()) { $customdatatypes_table = \thebuggenie\core\entities\CustomDatatype::getB2DBTable(); $crit = $customdatatypes_table->getCriteria(); $crit->indexBy(CustomFields::FIELD_KEY); $customfields = $customdatatypes_table->select($crit); while ($row = $res->getNextRow()) { $key = $row->get('customfieldoptions.customfield_key'); $customfield = array_key_exists($key, $customfields) ? $customfields[$key] : null; if ($customfield instanceof \thebuggenie\core\entities\CustomDatatype) { $crit = $this->getCriteria(); $crit->addUpdate(self::CUSTOMFIELD_ID, $customfield->getID()); $this->doUpdateById($crit, $row->get(self::ID)); } else { $this->doDeleteById($row->get(self::ID)); } } } break; } }
protected function _initializeCustomfields() { foreach (CustomDatatype::getAll() as $key => $customdatatype) { $var_name = "_customfield" . $key; $this->{$var_name} = null; } if ($rows = tables\IssueCustomFields::getTable()->getAllValuesByIssueID($this->getID())) { foreach ($rows as $row) { $datatype = CustomDatatype::getB2DBTable()->selectById($row->get(tables\IssueCustomFields::CUSTOMFIELDS_ID)); if ($datatype instanceof CustomDatatype) { $var_name = "_customfield" . $datatype->getKey(); if ($datatype->hasCustomOptions()) { $option = tables\CustomFieldOptions::getTable()->selectById((int) $row->get(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID)); if ($option instanceof \thebuggenie\core\entities\CustomDatatypeOption) { $this->{$var_name} = $option; } } else { if ($datatype->hasPredefinedOptions()) { $this->{$var_name} = $row->get(tables\IssueCustomFields::CUSTOMFIELDOPTION_ID); } else { $this->{$var_name} = $row->get(tables\IssueCustomFields::OPTION_VALUE); } } } } } }
public function _migrateData(\b2db\Table $old_table) { switch ($old_table->getVersion()) { case 1: if ($res = $old_table->doSelectAll()) { $customfields = \thebuggenie\core\entities\CustomDatatype::getB2DBTable()->selectAll(); while ($row = $res->getNextRow()) { $customfield_id = $row->get(self::CUSTOMFIELDS_ID); $customfield = array_key_exists($customfield_id, $customfields) ? $customfields[$customfield_id] : null; if ($customfield instanceof \thebuggenie\core\entities\CustomDatatype && $customfield->hasCustomOptions()) { $customfieldoption = CustomFieldOptions::getTable()->getByValueAndCustomfieldID((int) $row->get(self::OPTION_VALUE), $customfield->getID()); if ($customfieldoption instanceof \thebuggenie\core\entities\CustomDatatypeOption) { $crit = $this->getCriteria(); $crit->addUpdate(self::CUSTOMFIELDOPTION_ID, $customfieldoption->getID()); $crit->addUpdate(self::OPTION_VALUE, null); $this->doUpdateById($crit, $row->get(self::ID)); } elseif ($row->get(self::ID)) { $this->doDeleteById($row->get(self::ID)); } } } } break; } }