protected function getAttributes() { $list = AttributeFormKey::getList(); $attributes = array(); foreach ($list as $item) { $attributes[$item->getAttributeKeyHandle()] = $item; } return $attributes; }
public function getAttributeObjects() { $attributes = $this->getAttributes(); $result = []; foreach ($attributes as $akID) { $afk = AttributeFormKey::getByID($akID); $result[] = $afk; } return $result; }
public function reindex() { $attribs = AttributeFormKey::getAttributes($this->getID(), 'getSearchIndexValue'); $db = Database::connection(); $db->Execute('delete from AttributeFormsIndexAttributes where afID = ?', array($this->getID())); $searchableAttributes = array('afID' => $this->getID()); $rs = $db->Execute('select * from AttributeFormsIndexAttributes where afID = -1'); AttributeKey::reindex('AttributeFormsIndexAttributes', $searchableAttributes, $attribs, $rs); }
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); } }