public function groupsAction()
{
if ($this->getParam("data")) {
$dataParam = $this->getParam("data");
$data = \Zend_Json::decode($dataParam);
$id = $data["id"];
$config = Classificationstore\GroupConfig::getById($id);
foreach ($data as $key => $value) {
if ($key != "id") {
$setter = "set" . $key;
$config->{$setter}($value);
}
}
$config->save();
$this->_helper->json(["success" => true, "data" => $config]);
} else {
$start = 0;
$limit = 15;
$orderKey = "name";
$order = "ASC";
if ($this->getParam("dir")) {
$order = $this->getParam("dir");
}
if ($this->getParam("sort")) {
$orderKey = $this->getParam("sort");
}
if ($this->getParam("limit")) {
$limit = $this->getParam("limit");
}
if ($this->getParam("start")) {
$start = $this->getParam("start");
}
$sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
if ($sortingSettings['orderKey'] && $sortingSettings['order']) {
$orderKey = $sortingSettings['orderKey'];
$order = $sortingSettings['order'];
}
if ($this->getParam("overrideSort") == "true") {
$orderKey = "id";
$order = "DESC";
}
$list = new Classificationstore\GroupConfig\Listing();
$list->setLimit($limit);
$list->setOffset($start);
$list->setOrder($order);
$list->setOrderKey($orderKey);
$conditionParts = [];
$db = Db::get();
$searchfilter = $this->getParam("searchfilter");
if ($searchfilter) {
$conditionParts[] = "(name LIKE " . $db->quote("%" . $searchfilter . "%") . " OR description LIKE " . $db->quote("%" . $searchfilter . "%") . ")";
}
if ($this->getParam("storeId")) {
$conditionParts[] = "(storeId = " . $this->getParam("storeId") . ")";
}
if ($this->getParam("filter")) {
$filterString = $this->getParam("filter");
$filters = json_decode($filterString);
foreach ($filters as $f) {
if (\Pimcore\Tool\Admin::isExtJS6()) {
$conditionParts[] = $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%");
} else {
$conditionParts[] = $db->getQuoteIdentifierSymbol() . $f->field . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%");
}
}
}
if ($this->getParam("oid")) {
$object = Object\Concrete::getById($this->getParam("oid"));
$class = $object->getClass();
$fd = $class->getFieldDefinition($this->getParam("fieldname"));
$allowedGroupIds = $fd->getAllowedGroupIds();
if ($allowedGroupIds) {
$conditionParts[] = "ID in (" . implode(",", $allowedGroupIds) . ")";
}
}
$condition = implode(" AND ", $conditionParts);
$list->setCondition($condition);
$list->load();
$configList = $list->getList();
$rootElement = [];
$data = [];
foreach ($configList as $config) {
$name = $config->getName();
if (!$name) {
$name = "EMPTY";
}
$item = ["storeId" => $config->getStoreId(), "id" => $config->getId(), "name" => $name, "description" => $config->getDescription()];
if ($config->getCreationDate()) {
$item["creationDate"] = $config->getCreationDate();
}
if ($config->getModificationDate()) {
$item["modificationDate"] = $config->getModificationDate();
}
$data[] = $item;
}
$rootElement["data"] = $data;
$rootElement["success"] = true;
$rootElement["total"] = $list->getTotalCount();
return $this->_helper->json($rootElement);
}
}