/** * @group issue18073 * @link http://issues.ez.no/18073 */ public function testUnauthorizedContentByObjectId() { $this->setExpectedException('ezpContentAccessDeniedException'); // Let's take content node #5 / object #4 (users) as unauthorized content for anonymous user $unauthorizedObjectID = 4; $content = ezpContent::fromObjectId($unauthorizedObjectID); }
/** * Handles a content unique field request through an object or node ID * * Requests: * - GET /api/content/node/:nodeId/field/:fieldIdentifier * - GET /api/content/object/:objectId/field/:fieldIdentifier * * @return ezpRestMvcResult */ public function doViewField() { $this->setDefaultResponseGroups(array(self::VIEWFIELDS_RESPONSEGROUP_FIELDVALUES)); $isNodeRequested = false; if (isset($this->nodeId)) { $isNodeRequested = true; $content = ezpContent::fromNodeId($this->nodeId); } else { if (isset($this->objectId)) { $content = ezpContent::fromObjectId($this->objectId); } } if (!isset($content->fields->{$this->fieldIdentifier})) { throw new ezpContentFieldNotFoundException("'{$this->fieldIdentifier}' field is not available for this content."); } // Translation parameter if ($this->hasContentVariable('Translation')) { $content->setActiveLanguage($this->getContentVariable('Translation')); } $result = new ezpRestMvcResult(); // Field data if ($this->hasResponseGroup(self::VIEWFIELDS_RESPONSEGROUP_FIELDVALUES)) { $result->variables['fields'][$this->fieldIdentifier] = ezpRestContentModel::attributeOutputData($content->fields->{$this->fieldIdentifier}); } // Handle object/node metadata if ($this->hasResponseGroup(self::VIEWFIELDS_RESPONSEGORUP_METADATA)) { $objectMetadata = ezpRestContentModel::getMetadataByContent($content, $isNodeRequested); if ($isNodeRequested) { $nodeMetadata = ezpRestContentModel::getMetadataByLocation(ezpContentLocation::fetchByNodeId($this->nodeId)); $objectMetadata = array_merge($objectMetadata, $nodeMetadata); } $result->variables['metadata'] = $objectMetadata; } return $result; }
public function doViewFields() { $this->setDefaultResponseGroups(array(self::VIEWFIELDS_RESPONSEGROUP_FIELDVALUES)); $isNodeRequested = false; if (isset($this->nodeId)) { $content = ezpContent::fromNodeId($this->nodeId); $isNodeRequested = true; } else { if (isset($this->objectId)) { $content = ezpContent::fromObjectId($this->objectId); } } $result = new ezpRestMvcResult(); // translation parameter if ($this->hasContentVariable('Translation')) { $content->setActiveLanguage($this->getContentVariable('Translation')); } // Handle field values if ($this->hasResponseGroup(self::VIEWFIELDS_RESPONSEGROUP_FIELDVALUES)) { $result->variables['fields'] = ITOpenDataContentModel::getFieldsByContent($content, $this->request, $this->getRouter()); } // Handle object/node metadata if ($this->hasResponseGroup(self::VIEWFIELDS_RESPONSEGORUP_METADATA)) { $objectMetadata = ITOpenDataContentModel::getMetadataByContent($content); if ($isNodeRequested) { $nodeMetadata = ITOpenDataContentModel::getMetadataByLocation(ezpContentLocation::fetchByNodeId($this->nodeId)); $objectMetadata = array_merge($objectMetadata, $nodeMetadata); } $result->variables['metadata'] = $objectMetadata; } return $result; }
/** * Handles a content unique field request through an object or node ID * * Requests: * - GET /api/content/node/:nodeId/field/:fieldIdentifier * - GET /api/content/object/:objectId/field/:fieldIdentifier * * @return ezcMvcResult */ public function doViewField() { try { if (isset($this->nodeId)) { $content = ezpContent::fromNodeId($this->nodeId); } elseif (isset($this->objectId)) { $content = ezpContent::fromObjectId($this->objectId); } } catch (Exception $e) { // @todo handle error die($e->getMessage()); } if (!isset($content->fields->{$this->fieldIdentifier})) { // @todo Handle error return false; } // translation parameter if (isset($this->request->variables['translation'])) { $content->setActiveLanguage($this->request->variables['translation']); } // object metadata $result = self::viewContent($content); // fieldd data $result->variables['fields'][$this->fieldIdentifier] = $this->attributeOutputData($content->fields->{$this->fieldIdentifier}); return $result; }