public function getAttributeObjects() { $attributes = $this->getAttributes(); $result = []; foreach ($attributes as $akID) { $afk = AttributeFormKey::getByID($akID); $result[] = $afk; } return $result; }
public function delete() { $db = Database::connection(); $db->Execute("delete from " . self::$table . " where afID = ?", array($this->getID())); $r = $db->Execute('select avID, akID from AttributeFormsAttributeValues where afID = ?', array($this->getID())); while ($row = $r->FetchRow()) { $uak = AttributeFormKey::getByID($row['akID']); $av = $this->getAttributeValueObject($uak); if (is_object($av)) { $av->delete(); } } $db->Execute('delete from AttributeFormsIndexAttributes where afID = ?', array($this->getID())); }
public function delete($akID, $token = null) { try { $ak = AttributeFormKey::getByID($akID); if (!$ak instanceof AttributeFormKey) { throw new Exception(t('Invalid attribute ID.')); } $valt = Loader::helper('validation/token'); if (!$valt->validate('delete_attribute', $token)) { throw new Exception($valt->getErrorMessage()); } $ak->delete(); $this->redirect("/dashboard/forms/attributes", 'attribute_deleted'); } catch (Exception $e) { $this->set('error', $e); } }