/** * Return the specific attribute with the specified attribute_id (assuming it's attached to the current row) */ public function getAttributeByID($pn_attribute_id, $pa_options = null) { if (isset($pa_options['row_id']) && $pa_options['row_id']) { $vn_row_id = $pa_options['row_id']; } else { $vn_row_id = $this->getPrimaryKey(); } if (!$vn_row_id) { return null; } $t_attr = new ca_attributes($pn_attribute_id); if (!$t_attr->getPrimaryKey()) { return false; } if ((int) $t_attr->get('row_id') !== (int) $vn_row_id) { return false; } return $t_attr->getAttributeValues(array('returnAs' => 'attributeInstance')); }
/** * remove attribute from current row */ public function _removeAttribute($pn_attribute_id, $po_trans = null, $pa_options = null) { $t_attr = new ca_attributes($pn_attribute_id); $t_attr->purify($this->purify()); if ($po_trans) { $t_attr->setTransaction($po_trans); } if (!$t_attr->getPrimaryKey() || $t_attr->get('table_num') != $this->tableNum() || $this->getPrimaryKey() != $t_attr->get('row_id')) { $this->postError(1969, _t('Can\'t edit invalid attribute'), 'BaseModelWithAttributes->editAttribute()', $pa_options['error_source']); return false; } if (!$t_attr->removeAttribute()) { foreach ($t_attr->errors as $o_error) { $this->postError($o_error->getErrorNumber(), $o_error->getErrorDescription(), $o_error->getErrorContext(), $pa_options['error_source']); } return false; } //$this->setFieldValuesArray($this->addAttributesToFieldValuesArray()); return true; }