/** * @return Listing */ protected function getListing() { if (empty($this->list)) { $objectList = "\\Pimcore\\Model\\Object\\" . ucfirst($this->class) . "\\Listing"; $this->list = new $objectList(); $conditions = ["(newsletterActive = 1 AND newsletterConfirmed = 1)"]; if ($this->condition) { $conditions[] = "(" . $this->condition . ")"; } if ($this->personas) { $class = ClassDefinition::getByName($this->class); if ($class && $class->getFieldDefinition("persona")) { $personas = []; if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Persona) { foreach ($this->personas as $value) { if (!empty($value)) { $personas[] = $this->list->quote($value); } } $conditions[] = "persona IN (" . implode(",", $personas) . ")"; } elseif ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Personamultiselect) { $personasCondition = []; foreach ($this->personas as $value) { $personasCondition[] = "persona LIKE " . $this->list->quote("%," . $value . ",%"); } $conditions[] = "(" . implode(" OR ", $personasCondition) . ")"; } } } $this->list->setCondition(implode(" AND ", $conditions)); $this->list->setOrderKey("email"); $this->list->setOrder("ASC"); $this->elementsTotal = $this->list->getTotalCount(); } return $this->list; }
public function deleteInfoAction() { $hasDependency = false; $deleteJobs = array(); $recycleJobs = array(); $totalChilds = 0; $ids = $this->getParam("id"); $ids = explode(',', $ids); foreach ($ids as $id) { try { $object = Object::getById($id); if (!$object) { continue; } $hasDependency |= $object->getDependencies()->isRequired(); } catch (\Exception $e) { \Logger::err("failed to access object with id: " . $id); continue; } // check for children if ($object instanceof Object\AbstractObject) { $recycleJobs[] = array(array("url" => "/admin/recyclebin/add", "params" => array("type" => "object", "id" => $object->getId()))); $hasChilds = $object->hasChilds(); if (!$hasDependency) { $hasDependency = $hasChilds; } $childs = 0; if ($hasChilds) { // get amount of childs $list = new Object\Listing(); $list->setCondition("o_path LIKE '" . $object->getFullPath() . "/%'"); $childs = $list->getTotalCount(); $totalChilds += $childs; if ($childs > 0) { $deleteObjectsPerRequest = 5; for ($i = 0; $i < ceil($childs / $deleteObjectsPerRequest); $i++) { $deleteJobs[] = array(array("url" => "/admin/object/delete", "params" => array("step" => $i, "amount" => $deleteObjectsPerRequest, "type" => "childs", "id" => $object->getId()))); } } } // the object itself is the last one $deleteJobs[] = array(array("url" => "/admin/object/delete", "params" => array("id" => $object->getId()))); } } $deleteJobs = array_merge($recycleJobs, $deleteJobs); $this->_helper->json(array("hasDependencies" => $hasDependency, "childs" => $totalChilds, "deletejobs" => $deleteJobs, "batchDelete" => count($ids) > 1)); }