public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $page = Document\Page::getById($this->getParam("id")); $page = $this->getLatestVersion($page); $page->setVersions(array_splice($page->getVersions(), 0, 1)); $page->getScheduledTasks(); $page->idPath = Element\Service::getIdPath($page); $page->userPermissions = $page->getUserPermissions(); $page->setLocked($page->isLocked()); $page->setParent(null); if ($page->getContentMasterDocument()) { $page->contentMasterDocumentPath = $page->getContentMasterDocument()->getRealFullPath(); } // get depending redirects $redirectList = new Redirect\Listing(); $redirectList->setCondition("target = ?", $page->getId()); $page->redirects = $redirectList->load(); // unset useless data $page->setElements(null); $page->childs = null; // cleanup properties $this->minimizeProperties($page); if ($page->isAllowed("view")) { $this->_helper->json($page); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $snippet = Document\Snippet::getById($this->getParam("id")); $modificationDate = $snippet->getModificationDate(); $snippet = $this->getLatestVersion($snippet); $snippet->setVersions(array_splice($snippet->getVersions(), 0, 1)); $snippet->getScheduledTasks(); $snippet->idPath = Element\Service::getIdPath($snippet); $snippet->userPermissions = $snippet->getUserPermissions(); $snippet->setLocked($snippet->isLocked()); $snippet->setParent(null); if ($snippet->getContentMasterDocument()) { $snippet->contentMasterDocumentPath = $snippet->getContentMasterDocument()->getRealFullPath(); } $this->minimizeProperties($snippet); // unset useless data $snippet->setElements(null); if ($snippet->isAllowed("view")) { $this->_helper->json($snippet); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")]); } Element\Editlock::lock($this->getParam("id"), "document"); $link = Document\Hardlink::getById($this->getParam("id")); $link = clone $link; $link->idPath = Element\Service::getIdPath($link); $link->userPermissions = $link->getUserPermissions(); $link->setLocked($link->isLocked()); $link->setParent(null); if ($link->getSourceDocument()) { $link->sourcePath = $link->getSourceDocument()->getRealFullPath(); } $this->addTranslationsData($link); $this->minimizeProperties($link); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($link)); \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $link, "returnValueContainer" => $returnValueContainer]); if ($link->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(false); }
public function extractRelations($element, $apiElementKeys, $recursive, $includeRelations) { $foundRelations = []; if ($includeRelations) { $dependency = $element->getDependencies(); if ($dependency) { foreach ($dependency->getRequires() as $r) { if ($e = Element\Service::getDependedElement($r)) { if ($element->getId() != $e->getId() and !in_array(Element\Service::getElementType($e) . "_" . $e->getId(), $apiElementKeys)) { $foundRelations[Element\Service::getElementType($e) . "_" . $e->getId()] = ["elementType" => Element\Service::getType($e), "element" => $e->getId(), "recursive" => false]; } } } } } $childs = $element->getChilds(); if ($recursive and $childs) { foreach ($childs as $child) { if (!in_array(Element\Service::getType($child) . "_" . $child->getId(), $apiElementKeys)) { $foundRelations[Element\Service::getType($child) . "_" . $child->getId()] = ["elementType" => Element\Service::getType($child), "element" => $child->getId(), "recursive" => $recursive]; } } } return $foundRelations; }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")]); } Element\Editlock::lock($this->getParam("id"), "document"); $email = Document\Newsletter::getById($this->getParam("id")); $email = clone $email; $email = $this->getLatestVersion($email); $versions = Element\Service::getSafeVersionInfo($email->getVersions()); $email->setVersions(array_splice($versions, 0, 1)); $email->idPath = Element\Service::getIdPath($email); $email->userPermissions = $email->getUserPermissions(); $email->setLocked($email->isLocked()); $email->setParent(null); // unset useless data $email->setElements(null); $email->childs = null; $this->addTranslationsData($email); $this->minimizeProperties($email); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($email)); \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $email, "returnValueContainer" => $returnValueContainer]); if ($email->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (\Pimcore\Model\Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => \Pimcore\Model\Element\Editlock::getByElement($this->getParam("id"), "document")]); } \Pimcore\Model\Element\Editlock::lock($this->getParam("id"), "document"); $page = Document\Printpage::getById($this->getParam("id")); $page = $this->getLatestVersion($page); $page->getVersions(); $page->getScheduledTasks(); $page->idPath = Service::getIdPath($page); $page->userPermissions = $page->getUserPermissions(); $page->setLocked($page->isLocked()); if ($page->getContentMasterDocument()) { $page->contentMasterDocumentPath = $page->getContentMasterDocument()->getRealFullPath(); } $this->addTranslationsData($page); // unset useless data $page->setElements(null); $page->childs = null; // cleanup properties $this->minimizeProperties($page); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($page)); \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $page, "returnValueContainer" => $returnValueContainer]); if ($page->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(false); }
/** * @param $webResource */ public function __construct($webResource) { $this->id = $webResource->getId(); if ($webResource instanceof Element\ElementInterface) { $this->type = Element\Service::getType($webResource); } else { $this->type = "unknown"; } }
/** * gets workflow config for element. always returns first valid workflow config * * @param Asset|Document|ConcreteObject $element * @return array */ public static function getElementWorkflowConfig(AbstractElement $element) { $config = self::getWorkflowManagementConfig(); if (!is_array($config)) { return null; } $elementType = Service::getElementType($element); $elementSubType = $element->getType(); foreach ($config['workflows'] as $workflow) { //workflow is not enabled, continue with next if (isset($workflow['enabled']) && !$workflow['enabled']) { continue; } if (isset($workflow['workflowSubject']) && in_array($elementType, $workflow['workflowSubject']['types'])) { switch ($elementType) { case 'asset': if (isset($workflow['workflowSubject']['assetTypes']) && is_array($workflow['workflowSubject']['assetTypes'])) { if (in_array($elementSubType, $workflow['workflowSubject']['assetTypes'])) { return $workflow; } } else { \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available asset types'); } break; case 'document': if (isset($workflow['workflowSubject']['documentTypes']) && is_array($workflow['workflowSubject']['documentTypes'])) { if (in_array($elementSubType, $workflow['workflowSubject']['documentTypes'])) { return $workflow; } } else { \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available document types'); } break; case 'object': if ($element instanceof ConcreteObject) { if (isset($workflow['workflowSubject']['classes']) && is_array($workflow['workflowSubject']['classes'])) { $classId = $element->getClassId(); if (in_array($classId, $workflow['workflowSubject']['classes'])) { return $workflow; } } else { \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available class ID\'s'); } } break; default: //unknown element type, return null return null; } } } return null; }
/** * @param string $name * @return $this|void * @throws DAV\Exception\Forbidden * @throws \Exception */ public function setName($name) { if ($this->asset->isAllowed("rename")) { $user = AdminTool::getCurrentUser(); $this->asset->setUserModification($user->getId()); $this->asset->setFilename(Element\Service::getValidKey($name), "asset"); $this->asset->save(); } else { throw new DAV\Exception\Forbidden(); } return $this; }
/** * @param $cid * @param $ctype * @throws \Exception */ public function getByElement($cid, $ctype) { $data = $this->db->fetchRow("SELECT * FROM edit_lock WHERE cid = ? AND ctype = ?", array($cid, $ctype)); if (!$data["id"]) { throw new \Exception("Lock with cid " . $cid . " and ctype " . $ctype . " not found"); } $this->assignVariablesToModel($data); // add elements path $element = Model\Element\Service::getElementById($ctype, $cid); if ($element) { $this->model->setCpath($element->getFullpath()); } }
public static function interpret($value, $config = null) { $result = array(); if (is_array($value)) { foreach ($value as $v) { $result[] = array("dest" => $v->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($v)); } } else { if ($value instanceof \Pimcore\Model\Element\AbstractElement) { $result[] = array("dest" => $value->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($value)); } } return $result; }
/** * @static * @return mixed|\Zend_Config */ public static function getWebsiteConfig() { if (\Zend_Registry::isRegistered("pimcore_config_website")) { $config = \Zend_Registry::get("pimcore_config_website"); } else { $cacheKey = "website_config"; $siteId = null; if (Model\Site::isSiteRequest()) { $siteId = Model\Site::getCurrentSite()->getId(); $cacheKey = $cacheKey . "_site_" . $siteId; } if (!($config = Cache::load($cacheKey))) { $settingsArray = array(); $cacheTags = array("website_config", "system", "config", "output"); $list = new Model\WebsiteSetting\Listing(); $list = $list->load(); foreach ($list as $item) { $key = $item->getName(); $itemSiteId = $item->getSiteId(); if ($itemSiteId != 0 && $itemSiteId != $siteId) { continue; } $s = null; switch ($item->getType()) { case "document": case "asset": case "object": $s = Model\Element\Service::getElementById($item->getType(), $item->getData()); break; case "bool": $s = (bool) $item->getData(); break; case "text": $s = (string) $item->getData(); break; } if ($s instanceof Model\Element\ElementInterface) { $cacheTags = $s->getCacheTags($cacheTags); } if (isset($s)) { $settingsArray[$key] = $s; } } $config = new \Zend_Config($settingsArray, true); Cache::save($config, $cacheKey, $cacheTags, null, 998); } self::setWebsiteConfig($config); } return $config; }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $folder = Document\Folder::getById($this->getParam("id")); $folder->idPath = Element\Service::getIdPath($folder); $folder->userPermissions = $folder->getUserPermissions(); $folder->setLocked($folder->isLocked()); $folder->setParent(null); $this->minimizeProperties($folder); if ($folder->isAllowed("view")) { $this->_helper->json($folder); } $this->_helper->json(false); }
/** * Moves a file/directory * * @param string $sourcePath * @param string $destinationPath * @return void */ public function move($sourcePath, $destinationPath) { $nameParts = explode("/", $sourcePath); $nameParts[count($nameParts) - 1] = Element\Service::getValidKey($nameParts[count($nameParts) - 1], "asset"); $sourcePath = implode("/", $nameParts); $nameParts = explode("/", $destinationPath); $nameParts[count($nameParts) - 1] = Element\Service::getValidKey($nameParts[count($nameParts) - 1], "asset"); $destinationPath = implode("/", $nameParts); try { if (dirname($sourcePath) == dirname($destinationPath)) { $asset = null; if ($asset = Asset::getByPath("/" . $destinationPath)) { // If we got here, this means the destination exists, and needs to be overwritten $sourceAsset = Asset::getByPath("/" . $sourcePath); $asset->setData($sourceAsset->getData()); $sourceAsset->delete(); } // see: Asset\WebDAV\File::delete() why this is necessary $log = Asset\WebDAV\Service::getDeleteLog(); if (!$asset && array_key_exists("/" . $destinationPath, $log)) { $asset = \Pimcore\Tool\Serialize::unserialize($log["/" . $destinationPath]["data"]); if ($asset) { $sourceAsset = Asset::getByPath("/" . $sourcePath); $asset->setData($sourceAsset->getData()); $sourceAsset->delete(); } } if (!$asset) { $asset = Asset::getByPath("/" . $sourcePath); } $asset->setFilename(basename($destinationPath)); } else { $asset = Asset::getByPath("/" . $sourcePath); $parent = Asset::getByPath("/" . dirname($destinationPath)); $asset->setPath($parent->getRealFullPath() . "/"); $asset->setParentId($parent->getId()); } $user = \Pimcore\Tool\Admin::getCurrentUser(); $asset->setUserModification($user->getId()); $asset->save(); } catch (\Exception $e) { Logger::error($e); } }
public function treeGetChildsByIdAction() { $document = Document::getById($this->getParam("node")); $documents = []; $cv = false; if ($document->hasChilds()) { $limit = intval($this->getParam("limit")); if (!$this->getParam("limit")) { $limit = 100000000; } $offset = intval($this->getParam("start")); if ($this->getParam("view")) { $cv = \Pimcore\Model\Element\Service::getCustomViewById($this->getParam("view")); } $list = new Document\Listing(); if ($this->getUser()->isAdmin()) { $list->setCondition("parentId = ? ", $document->getId()); } else { $userIds = $this->getUser()->getRoles(); $userIds[] = $this->getUser()->getId(); $list->setCondition("parentId = ? and\n (\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,`key`),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n or\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,`key`))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )", $document->getId()); } $list->setOrderKey(["index", "id"]); $list->setOrder(["asc", "asc"]); $list->setLimit($limit); $list->setOffset($offset); \Pimcore\Model\Element\Service::addTreeFilterJoins($cv, $list); $childsList = $list->load(); foreach ($childsList as $childDocument) { // only display document if listing is allowed for the current user if ($childDocument->isAllowed("list")) { $documents[] = $this->getTreeNodeConfig($childDocument); } } } if ($this->getParam("limit")) { $this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $document->getChildAmount($this->getUser()), "nodes" => $documents]); } else { $this->_helper->json($documents); } $this->_helper->json(false); }
/** * Clear all relations in the database * @param Element\ElementInterface $element */ public function cleanAllForElement($element) { try { $id = $element->getId(); $type = Element\Service::getElementType($element); //schedule for sanity check $data = $this->db->fetchAll("SELECT * FROM dependencies WHERE targetid = ? AND targettype = ?", array($id, $type)); if (is_array($data)) { foreach ($data as $row) { $sanityCheck = new Element\Sanitycheck(); $sanityCheck->setId($row['sourceid']); $sanityCheck->setType($row['sourcetype']); $sanityCheck->save(); } } $this->db->delete("dependencies", $this->db->quoteInto("sourceid = ?", $id) . " AND " . $this->db->quoteInto("sourcetype = ?", $type)); $this->db->delete("dependencies", $this->db->quoteInto("targetid = ?", $id) . " AND " . $this->db->quoteInto("targettype = ?", $type)); } catch (\Exception $e) { \Logger::error($e); } }
public function getRelationAttribute($attributeName) { $relationObjectArray = array(); if ($this->relations[$attributeName]) { foreach ($this->relations[$attributeName] as $relation) { $relationObject = \Pimcore\Model\Element\Service::getElementById($relation['type'], $relation['id']); if ($relationObject) { $relationObjectArray[] = $relationObject; } } } if (count($relationObjectArray) == 1) { return $relationObjectArray[0]; } else { if (count($relationObjectArray) > 1) { return $relationObjectArray; } else { return null; } } }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $email = Document\Email::getById($this->getParam("id")); $email = $this->getLatestVersion($email); $email->setVersions(array_splice($email->getVersions(), 0, 1)); $email->idPath = Element\Service::getIdPath($email); $email->userPermissions = $email->getUserPermissions(); $email->setLocked($email->isLocked()); $email->setParent(null); // unset useless data $email->setElements(null); $email->childs = null; // cleanup properties $this->minimizeProperties($email); if ($email->isAllowed("view")) { $this->_helper->json($email); } $this->_helper->json(false); }
private function installUserRole() { $userRole = new \Pimcore\Model\User\Role(); $customerRole = $userRole->getByName('kunde'); if ($customerRole !== FALSE) { return $customerRole; } $user = \Pimcore\Model\User\Role::create(array('parentId' => 0, 'name' => 'kunde', 'active' => 1)); $permissions = array('assets' => TRUE, 'plugin_coreshop' => TRUE, 'coreshop_country' => TRUE, 'coreshop_currency' => TRUE, 'coreshop_zone' => TRUE, 'coreshop_user' => TRUE, 'dashboards' => TRUE, 'documents' => TRUE, 'notes_events' => TRUE, 'objects' => TRUE, 'recyclebin' => TRUE, 'redirects' => TRUE, 'seemode' => TRUE, 'users' => TRUE, 'website_settings' => TRUE); $classes = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); $workspaces = array('document' => array(array('path' => '/', 'list' => TRUE, 'save' => TRUE, 'unpublish' => TRUE, 'view' => TRUE, 'publish' => TRUE, 'delete' => TRUE, 'rename' => TRUE, 'create' => TRUE, 'settings' => TRUE, 'versions' => TRUE, 'properties' => TRUE), array('path' => '/demo')), 'object' => array(array('path' => '/', 'list' => TRUE, 'save' => TRUE, 'unpublish' => TRUE, 'view' => TRUE, 'publish' => TRUE, 'delete' => TRUE, 'rename' => TRUE, 'create' => TRUE, 'settings' => TRUE, 'versions' => TRUE, 'properties' => TRUE)), 'asset' => array(array('path' => '/', 'list' => TRUE, 'save' => TRUE, 'unpublish' => TRUE, 'view' => TRUE, 'publish' => TRUE, 'delete' => TRUE, 'rename' => TRUE, 'create' => TRUE, 'settings' => TRUE, 'versions' => TRUE, 'properties' => TRUE))); foreach ($workspaces as $type => $spaces) { $newWorkspaces = array(); foreach ($spaces as $space) { $element = \Pimcore\Model\Element\Service::getElementByPath($type, $space['path']); if ($element) { $className = '\\Pimcore\\Model\\User\\Workspace\\' . ucfirst($type); $workspace = new $className(); $workspace->setValues($space); $workspace->setCid($element->getId()); $workspace->setCpath($element->getFullPath()); $workspace->setUserId($user->getId()); $newWorkspaces[] = $workspace; } } $user->{'setWorkspaces' . ucfirst($type)}($newWorkspaces); } foreach ($permissions as $permName => $permAccess) { $user->setPermission($permName, $permAccess); } $user->setDocTypes(implode(',', array(1))); $user->setClasses(implode(',', $classes)); $user->save(); //var_dump($user); return $user; }
public function getDataByIdAction() { // check for lock if (\Pimcore\Model\Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => \Pimcore\Model\Element\Editlock::getByElement($this->getParam("id"), "document")]); } \Pimcore\Model\Element\Editlock::lock($this->getParam("id"), "document"); $page = Document\Printpage::getById($this->getParam("id")); $page = $this->getLatestVersion($page); $page->getVersions(); $page->getScheduledTasks(); $page->idPath = Service::getIdPath($page); $page->userPermissions = $page->getUserPermissions(); $page->setLocked($page->isLocked()); // unset useless data $page->setElements(null); $page->childs = null; // cleanup properties $this->minimizeProperties($page); if ($page->isAllowed("view")) { $this->_helper->json($page); } $this->_helper->json(false); }
/** * @see Document\Tag\TagInterface::setDataFromEditmode * @param mixed $data * @return void */ public function setDataFromEditmode($data) { $pdf = Asset::getById($data["id"]); if ($pdf instanceof Asset\Document) { $this->id = $pdf->getId(); if (array_key_exists("hotspots", $data) && !empty($data["hotspots"])) { $rewritePath = function ($data) { if (!is_array($data)) { return array(); } foreach ($data as &$page) { foreach ($page as &$element) { if (array_key_exists("data", $element) && is_array($element["data"]) && count($element["data"]) > 0) { foreach ($element["data"] as &$metaData) { if (in_array($metaData["type"], array("object", "asset", "document", "link"))) { $elTtype = $metaData["type"]; if ($metaData["type"] == "link") { $elTtype = "document"; } $el = Element\Service::getElementByPath($elTtype, $metaData["value"]); if (!$el && $metaData["type"] == "link") { $metaData["value"] = $metaData["value"]; } else { $metaData["value"] = $el; } } } } } } return $data; }; if (array_key_exists("hotspots", $data) && is_array($data["hotspots"]) && count($data["hotspots"]) > 0) { $data["hotspots"] = $rewritePath($data["hotspots"]); } $this->hotspots = $data["hotspots"]; } $this->texts = $data['texts']; $this->chapters = $data['chapters']; } return $this; }
/** * */ public function expand() { switch ($this->type) { case "document": case "asset": case "object": if (is_numeric($this->data)) { $element = Element\Service::getElementById($this->type, $this->data); } if ($element) { $this->data = $element->getFullPath(); } else { $this->data = ""; } break; default: //nothing to do } }
public function roleGetAction() { $role = User\Role::getById(intval($this->getParam("id"))); // workspaces $types = ["asset", "document", "object"]; foreach ($types as $type) { $workspaces = $role->{"getWorkspaces" . ucfirst($type)}(); foreach ($workspaces as $workspace) { $el = Element\Service::getElementById($type, $workspace->getCid()); if ($el) { // direct injection => not nice but in this case ok ;-) $workspace->path = $el->getRealFullPath(); } } } // get available permissions $availableUserPermissionsList = new User\Permission\Definition\Listing(); $availableUserPermissions = $availableUserPermissionsList->load(); $availablePerspectives = \Pimcore\Config::getAvailablePerspectives(null); $this->_helper->json(["success" => true, "role" => $role, "permissions" => $role->generatePermissionList(), "classes" => $role->getClasses(), "docTypes" => $role->getDocTypes(), "availablePermissions" => $availableUserPermissions, "availablePerspectives" => $availablePerspectives]); }
/** * @param $object * @param string $ownertype * @param $ownername * @param $position */ public function save($object, $ownertype = "object", $ownername, $position) { $element = $this->getElement(); $type = Model\Element\Service::getElementType($element); $this->getDao()->save($object, $ownertype, $ownername, $position, $type); }
/** * @param $object * @param array $params * @return null|Object\Fieldcollection\Data\Object\Concrete|Object\Objectbrick\Data\ */ public function preGetData($object, $params = array()) { $data = null; if ($object instanceof Object\Concrete) { $data = $object->{$this->getName()}; if ($this->getLazyLoading() and !in_array($this->getName(), $object->getO__loadedLazyFields())) { $data = $this->load($object, array("force" => true)); $setter = "set" . ucfirst($this->getName()); if (method_exists($object, $setter)) { $object->{$setter}($data); } } } else { if ($object instanceof Object\Localizedfield) { $data = $params["data"]; } else { if ($object instanceof Object\Fieldcollection\Data\AbstractData) { $data = $object->{$this->getName()}; } else { if ($object instanceof Object\Objectbrick\Data\AbstractData) { $data = $object->{$this->getName()}; } } } } if (Object\AbstractObject::doHideUnpublished() and $data instanceof Element\ElementInterface) { if (!Element\Service::isPublished($data)) { return null; } } return $data; }
public function getFolderAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "object")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "object"))); } Element\Editlock::lock($this->getParam("id"), "object"); $object = Object::getById(intval($this->getParam("id"))); if ($object->isAllowed("view")) { $objectData = array(); $objectData["general"] = array(); $objectData["idPath"] = Element\Service::getIdPath($object); $allowedKeys = array("o_published", "o_key", "o_id", "o_type", "o_path", "o_modificationDate", "o_creationDate", "o_userOwner", "o_userModification"); foreach (get_object_vars($object) as $key => $value) { if (strstr($key, "o_") && in_array($key, $allowedKeys)) { $objectData["general"][$key] = $value; } } $objectData["general"]["fullpath"] = $object->getFullPath(); $objectData["general"]["o_locked"] = $object->isLocked(); $objectData["properties"] = Element\Service::minimizePropertiesForEditmode($object->getProperties()); $objectData["userPermissions"] = $object->getUserPermissions(); $objectData["classes"] = $object->getDao()->getClasses(); // grid-config $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "-user_" . $this->getUser()->getId() . ".psf"; if (is_file($configFile)) { $gridConfig = Tool\Serialize::unserialize(file_get_contents($configFile)); if ($gridConfig) { $objectData["selectedClass"] = $gridConfig["classId"]; } } $this->_helper->json($objectData); } else { \Logger::debug("prevented getting folder id [ " . $object->getId() . " ] because of missing permissions"); $this->_helper->json(array("success" => false, "message" => "missing_permission")); } }
public function preGetData($object, $params = array()) { $data = null; if ($object instanceof Object\Concrete) { $data = $object->{$this->getName()}; if ($this->getLazyLoading() and !in_array($this->getName(), $object->getO__loadedLazyFields())) { //$data = $this->getDataFromResource($object->getRelationData($this->getName(),true,null)); $data = $this->load($object, array("force" => true)); $setter = "set" . ucfirst($this->getName()); if (method_exists($object, $setter)) { $object->{$setter}($data); } } } else { if ($object instanceof Object\Localizedfield) { $data = $params["data"]; } else { if ($object instanceof Object\Fieldcollection\Data\AbstractData) { $data = $object->{$this->getName()}; } else { if ($object instanceof Object\Objectbrick\Data\AbstractData) { $data = $object->{$this->getName()}; } } } } if (Object\AbstractObject::doHideUnpublished() and is_array($data)) { $publishedList = array(); foreach ($data as $listElement) { if (Element\Service::isPublished($listElement)) { $publishedList[] = $listElement; } } return $publishedList; } return is_array($data) ? $data : array(); }
/** * @param ElementInterface $element * @return $this */ public function setElement(ElementInterface $element) { $this->setCid($element->getId()); $this->setCtype(Service::getType($element)); return $this; }
/** * */ public function getRequiredByDependenciesAction() { $id = $this->getParam("id"); $type = $this->getParam("controller"); $allowedTypes = ["asset", "document", "object"]; if ($id && in_array($type, $allowedTypes)) { $element = Model\Element\Service::getElementById($type, $id); if ($element instanceof Model\Element\ElementInterface) { $dependencies = Model\Element\Service::getRequiredByDependenciesForFrontend($element->getDependencies()); $this->_helper->json($dependencies); } } $this->_helper->json(false); }
public function getValidFilenameAction() { $this->_helper->json(["filename" => \Pimcore\Model\Element\Service::getValidKey($this->getParam("value"), $this->getParam("type"))]); }