public function sortInSet() { $this->canAccess(); $as = Set::getByID($_REQUEST['asID']); $uats = $_REQUEST['akID']; if (is_array($uats)) { $uats = array_filter($uats, 'is_numeric'); } if (count($uats)) { } }
<?php defined('C5_EXECUTE') or die("Access Denied."); use Concrete\Core\Attribute\Set as AttributeSet; $canRead = false; $ch = Page::getByID($_REQUEST['cID']); $path = $ch->getCollectionPath(); if (strpos($path, '/dashboard') === 0) { $cp = new Permissions($ch); if ($cp->canViewPage()) { $canRead = true; } } if (!$canRead) { die(t("Access Denied.")); } // this should be cleaned up.... yeah $db = Loader::db(); // update order of collections $uats = $_REQUEST['akID_' . $_REQUEST['asID']]; if (is_array($uats)) { $as = AttributeSet::getByID($_REQUEST['asID']); $as->updateAttributesDisplayOrder($uats); }
protected function assignToSetFromRequest(AttributeKeyInterface $key) { $request = $this->request; $entity = $this->getCategoryObject(); $category = $entity->getAttributeKeyCategory(); if ($category->getSetManager()->allowAttributeSets()) { $set = Set::getByID($request->request->get('asID')); $setKeys = Set::getByAttributeKey($key); if (in_array($set, $setKeys)) { return; } if ($category->getSetManager()->allowAttributeSets() == StandardSetManager::ASET_ALLOW_SINGLE || !is_object($set)) { $query = $this->entityManager->createQuery('delete from \\Concrete\\Core\\Entity\\Attribute\\SetKey sk where sk.attribute_key = :attribute_key'); $query->setParameter('attribute_key', $key); $query->execute(); } if (is_object($set)) { $this->entityManager->refresh($set); // Refresh display order just in case. $displayOrder = 0; foreach ($set->getAttributeKeyCollection() as $setKey) { $setKey->setDisplayOrder($displayOrder); $this->entityManager->persist($setKey); ++$displayOrder; } $setKey = new SetKey(); $setKey->setAttributeKey($key); $setKey->setAttributeSet($set); $setKey->setDisplayOrder($displayOrder); $this->entityManager->persist($setKey); } } $this->entityManager->flush(); }
/** * @param string $asHandle The unique attribute set handle * @param string $asName The attribute set name * @param bool|\Package $pkg The package object to associate the set with or false if it does not belong to a package * @param int $asIsLocked * @return null|AttributeSet Returns the AttribueSet object if it was created successfully, null if it could not be * created (usually due to the category not allowing sets) */ public function addSet($asHandle, $asName, $pkg = false, $asIsLocked = 1) { if ($this->akCategoryAllowSets > static::ASET_ALLOW_NONE) { $pkgID = 0; if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } $db = Database::connection(); $sets = $db->fetchColumn('SELECT COUNT(asID) FROM AttributeSets WHERE akCategoryID = ?', array($this->akCategoryID)); $asDisplayOrder = 0; if ($sets > 0) { $asDisplayOrder = $db->fetchColumn('SELECt MAX(asDisplayOrder) FROM AttributeSets WHERE akCategoryID = ?', array($this->akCategoryID)); $asDisplayOrder++; } $db->executeQuery('INSERT INTO AttributeSets (asHandle, asName, akCategoryID, asIsLocked, asDisplayOrder, pkgID) VALUES (?, ?, ?, ?, ?,?)', array($asHandle, $asName, $this->akCategoryID, $asIsLocked, $asDisplayOrder, $pkgID)); $id = $db->lastInsertId(); $as = AttributeSet::getByID($id); return $as; } return null; }
public function addAttributeKey($type, $args, $pkg = false) { if (!is_object($type)) { $type = \Concrete\Core\Attribute\Type::getByHandle($type); } $controller = $type->getController(); $settings = $controller->saveKey($args); if (!is_object($settings)) { $settings = $controller->getAttributeKeySettings(); } // $key is actually an array. $handle = $args['akHandle']; $name = $args['akName']; $key = new LegacyKey(); $key->setAttributeKeyHandle($handle); $key->setAttributeKeyName($name); $key->setAttributeType($type); $this->entityManager->persist($key); $this->entityManager->flush(); $settings->setAttributeKey($key); $this->entityManager->persist($settings); $this->entityManager->flush(); $key->setAttributeKeySettings($settings); $key->setAttributeCategoryEntity($this->getCategoryEntity()); if (is_object($pkg)) { $key->setPackage($pkg); } // Modify the category's search indexer. $indexer = $this->getSearchIndexer(); if (is_object($indexer)) { $indexer->updateRepositoryColumns($this, $key); } $this->entityManager->persist($key); $this->entityManager->flush(); $this->clearAttributeSet($key); if (isset($args['asID']) && $args['asID'] > 0) { $key->setAttributeSet(Set::getByID($args['asID'])); } $this->entityManager->flush(); return $key; }
public function addSet($asHandle, $asName, $pkg = false, $asIsLocked = 1) { if ($this->akCategoryAllowSets > static::ASET_ALLOW_NONE) { $db = Loader::db(); $pkgID = 0; if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } $sets = $db->GetOne('select count(asID) from AttributeSets where akCategoryID = ?', array($this->akCategoryID)); $asDisplayOrder = 0; if ($sets > 0) { $asDisplayOrder = $db->GetOne('select max(asDisplayOrder) from AttributeSets where akCategoryID = ?', array($this->akCategoryID)); $asDisplayOrder++; } $db->Execute('insert into AttributeSets (asHandle, asName, akCategoryID, asIsLocked, asDisplayOrder, pkgID) values (?, ?, ?, ?, ?,?)', array($asHandle, $asName, $this->akCategoryID, $asIsLocked, $asDisplayOrder, $pkgID)); $id = $db->Insert_ID(); $as = AttributeSet::getByID($id); return $as; } }