public function updateCollectionField($key, $value, $collection) { if ($collection) { $field = AttributeCollectionKey::getByID($key); $collection->setAttribute($field, $value); } }
public function clear_attribute($ptID = false) { $this->setupPageType($ptID); $sr = new EditResponse(); if (Loader::helper('validation/token')->validate()) { $ak = CollectionKey::getByID(Loader::helper('security')->sanitizeInt($_REQUEST['akID'])); if (is_object($ak)) { $this->defaultPage->clearAttribute($ak); } } else { $this->error->add(Loader::helper('validation/token')->getErrorMessage()); } if ($this->error->has()) { $sr->setError($this->error); } else { $sr->setMessage(t('Attribute cleared successfully.')); } $sr->outputJSON(); }
public function delete($akID = null) { $key = CollectionKey::getByID($akID); $this->executeDelete($key, \URL::to('/dashboard/pages/attributes', 'view')); }
function action_edit_forum_post() { $vf = Core::make('helper/validation/form'); $vf->setData($_POST['ccm_token']); $vf->addRequiredToken('edit_forum_post'); if ($vf->test()) { $th = Core::make('helper/text'); $editPage = Page::getCurrentPage(); $settings = $this->get_saved_settings(); $u = new User(); // if user not loggged in make admin page owner if ($u->isLoggedIn()) { $owner = $u->getUserID(); } else { $owner = 1; } $editPage->update(array('cName' => $_POST['forumTitle'])); // set Page Attribute for Anonymous users if ($_POST['forumEmail']) { $editPage->setAttribute('forum_email', $_POST['forumEmail']); } if ($_POST['forumName']) { $editPage->setAttribute('forum_name', $_POST['forumName']); } // Save forum post if ($settings['rich_text']) { if ($_POST['forumPost']) { $editPage->setAttribute('forum_post', $_POST['forumPost']); } } else { if ($_POST['forumPost']) { $editPage->setAttribute('forum_post', $th->sanitize($_POST['forumPost'])); } } // save tags $ak = CollectionAttributeKey::getByHandle('tags'); $ak->saveAttributeForm($editPage); // Save optional Attributes if ($settings['optional_attributes']) { $optAtts = unserialize($settings['optional_attributes']); foreach ($optAtts as $ot) { $ak = CollectionAttributeKey::getByID($ot); $ak->saveAttributeForm($editPage); } } // check if we need to move the page if ($_POST['forumSelect'] && $_POST['forumSelect'] != $editPage->getCollectionParentID()) { $category = \Page::getByID($_POST['forumSelect']); $editPage->move($category); } $editPage->reindex(); } else { die("Access Denied."); } $this->redirect($editPage->getCollectionPath()); }
public static function getList($filters = array()) { $db = Loader::db(); $q = 'select akID from AttributeKeys inner join AttributeKeyCategories on AttributeKeys.akCategoryID = AttributeKeyCategories.akCategoryID where akCategoryHandle = ?'; foreach ($filters as $key => $value) { $q .= ' and ' . $key . ' = ' . $value . ' '; } $r = $db->Execute($q, array('Collection')); $list = array(); while ($row = $r->FetchRow()) { Loader::model('attribute/categories/collection'); $c1a = CollectionAttributeKey::getByID($row['akID']); if (is_object($c1a)) { $list[] = $c1a; } } $r->Close(); return $list; }