/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl(&$node = null) { $token = $this->getToken(); $dataMap = $node->dataMap(); $mediaContentAttribute = $dataMap['media_content']; $mediaContentAttributeContent = $mediaContentAttribute->content(); $linkObjectID = $mediaContentAttributeContent['relation_list'][0]['contentobject_id']; $linkObject = eZContentObject::fetch( $linkObjectID ); $linkDatamap = $linkObject->dataMap(); $url = $linkDatamap['url']->content(); $queryStringPosition = strpos($url, '?'); $queryString = substr($url, $queryStringPosition + 1); $url = substr($url, 0, $queryStringPosition); $queryStringParts = array(); parse_str($queryString, $queryStringParts); $queryStringParts[self::SESSION_ID_FIELD] = $token; $queryString = http_build_query($queryStringParts); $url .= '?' . $queryString; return $url; }
public static function getTimeTableFromNode(eZContentObjectTreeNode $node) { $dataMap = $node->attribute('data_map'); if (isset($dataMap['timetable']) && $dataMap['timetable'] instanceof eZContentObjectAttribute && $dataMap['timetable']->attribute('has_content')) { $timeTableContent = $dataMap['timetable']->attribute('content')->attribute('matrix'); $timeTable = array(); foreach ($timeTableContent['columns']['sequential'] as $column) { foreach ($column['rows'] as $row) { $parts = explode('-', $row); if (count($parts) == 2) { $fromParts = explode(':', $parts[0]); if (count($fromParts) != 2) { $fromParts = explode('.', $parts[0]); } $toParts = explode(':', $parts[1]); if (count($toParts) != 2) { $toParts = explode('.', $parts[1]); } if (count($fromParts) == 2 && count($toParts) == 2) { if (!isset($timeTable[$column['identifier']])) { $timeTable[$column['identifier']] = array(); } $timeTable[$column['identifier']][] = array('from_time' => array('hour' => trim($fromParts[0]), 'minute' => trim($fromParts[1])), 'to_time' => array('hour' => trim($toParts[0]), 'minute' => trim($toParts[1]))); } } } } return $timeTable; } return array(); }
static function fetchByNode(eZContentObjectTreeNode $node) { $attributes = $node->attribute('data_map'); foreach ($attributes as $attribute) { if ($attribute->DataTypeString == 'xrowmetadata' and $attribute->hasContent()) { return $attribute->content(); } } return false; }
/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl(&$node = null) { $dataMap = $node->dataMap(); $mediaContentAttribute = $dataMap['media_content']; $mediaContentAttributeContent = $mediaContentAttribute->content(); $linkObjectID = $mediaContentAttributeContent['relation_list'][0]['contentobject_id']; $linkObject = eZContentObject::fetch( $linkObjectID ); $linkDatamap = $linkObject->dataMap(); $url = $linkDatamap['url']->content(); $delimiter = ( strpos($url, '?') === false ) ? '?' : '&'; $url .= $delimiter.'ID=mmed45652&PASSWORD=medicus&NEWS=n'; return $url; }
/** * Returns block item XHTML * * @param mixed $args * @return array */ public static function getNextItems($args) { $http = eZHTTPTool::instance(); $tpl = eZTemplate::factory(); $result = array(); $galleryID = $http->postVariable('gallery_id'); $offset = $http->postVariable('offset'); $limit = $http->postVariable('limit'); $galleryNode = eZContentObjectTreeNode::fetch($galleryID); if ($galleryNode instanceof eZContentObjectTreeNode) { $params = array('Depth' => 1, 'Offset' => $offset, 'Limit' => $limit); $pictureNodes = $galleryNode->subtree($params); foreach ($pictureNodes as $validNode) { $tpl->setVariable('node', $validNode); $tpl->setVariable('view', 'block_item'); $tpl->setVariable('image_class', 'blockgallery1'); $content = $tpl->fetch('design:node/view/view.tpl'); $result[] = $content; if ($counter === $limit) { break; } } } return $result; }
/** * This method returns list of related publisher folders if custom parameter ShowPublisherLogos is != null * @return null|PublisherFolder[] */ protected function getRelatedPublishers() { $publisherFolders = null; if ($this->getCustomParameter('ShowPublisherLogos') == null) { return $publisherFolders; } if ($this->node instanceof eZContentObjectTreeNode) { $dataMap = $this->node->dataMap(); $taxonomies = $dataMap["serialized_taxonomies"]->content(); $publisherPaths = $taxonomies["publisher_folder"]; foreach ($publisherPaths as $publisherPath) { $publisherFolders[] = $this->applicationLocalized()->getPublisherFolderFromPath( $publisherPath ); } } else { $publisherFolders = $this->applicationLocalized()->publisherFolders; } return $publisherFolders; }
private static function fetchIndexTargets($indexTarget, $classIdentifiers, $contentObjectAttribute) { if (!is_array($classIdentifiers)) { return array(); } if ($indexTarget == 'parent_line') { $path = $contentObjectAttribute->object()->mainNode()->fetchPath(); if (!empty($classIdentifiers)) { $targets = array(); foreach ($path as $pathNode) { if (in_array($pathNode->classIdentifier(), $classIdentifiers)) { $targets[] = $pathNode; } } return $targets; } return $path; } else { if ($indexTarget == 'parent') { $parentNode = $contentObjectAttribute->object()->mainNode()->fetchParent(); if (empty($classIdentifiers) || in_array($parentNode->classIdentifier(), $classIdentifiers)) { return array($parentNode); } } else { if ($indexTarget == 'children' || $indexTarget == 'subtree') { $children = eZContentObjectTreeNode::subTreeByNodeID(array('ClassFilterType' => !empty($classIdentifiers) ? 'include' : false, 'ClassFilterArray' => !empty($classIdentifiers) ? $classIdentifiers : false, 'Depth' => $indexTarget == 'children' ? 1 : false), $contentObjectAttribute->object()->mainNode()->attribute('node_id')); if (is_array($children)) { return $children; } } } } return array(); }
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters) { $parentNodeID = $namedParameters['parent_node_id']; switch ($operatorName) { case 'ezkeywordlist': include_once 'lib/ezdb/classes/ezdb.php'; $db = eZDB::instance(); if ($parentNodeID) { $node = eZContentObjectTreeNode::fetch($parentNodeID); if ($node) { $pathString = "AND ezcontentobject_tree.path_string like '" . $node->attribute('path_string') . "%'"; } $parentNodeIDSQL = "AND ezcontentobject_tree.node_id != " . (int) $parentNodeID; } $showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString(true, false); $limitation = false; $limitationList = eZContentObjectTreeNode::getLimitationList($limitation); $sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList); $versionNameJoins = " AND ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id AND\n ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version AND "; $languageFilter = " AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject'); $versionNameJoins .= eZContentLanguage::sqlFilter('ezcontentobject_name', 'ezcontentobject'); $quotedClassIdentifiers = array(); foreach ((array) $namedParameters['class_identifier'] as $classIdentifier) { $quotedClassIdentifiers[] = "'" . $db->escapeString($classIdentifier) . "'"; } $rs = $db->arrayQuery("SELECT DISTINCT ezkeyword.keyword\n FROM ezkeyword_attribute_link,\n ezkeyword,\n ezcontentobject,\n ezcontentobject_name,\n ezcontentobject_attribute,\n ezcontentobject_tree,\n ezcontentclass\n {$sqlPermissionChecking['from']}\n WHERE ezkeyword.id = ezkeyword_attribute_link.keyword_id\n AND ezkeyword_attribute_link.objectattribute_id = ezcontentobject_attribute.id\n AND ezcontentobject_tree.contentobject_id = ezcontentobject_attribute.contentobject_id\n AND ezkeyword.class_id = ezcontentclass.id\n AND " . $db->generateSQLINStatement($quotedClassIdentifiers, 'ezcontentclass.identifier') . "\n {$pathString}\n {$parentNodeIDSQL} " . ($namedParameters['depth'] > 0 ? "AND ezcontentobject_tree.depth=" . (int) $namedParameters['depth'] : '') . "\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$languageFilter}\n {$versionNameJoins}\n ORDER BY ezkeyword.keyword ASC"); $operatorValue = $rs; break; } }
public static function getMetaTitle( $pathArray ) { $metaINI = eZINI::instance( 'ezmetadata.ini' ); $allowedClasses = $metaINI->variable( 'TitleSettings', 'ParentClasses' ); $maxDepth = $metaINI->variable( 'TitleSettings', 'MaxDepth' ); $separator = ' '.$metaINI->variable( 'TitleSettings', 'PathSeparator' ).' '; $contentINI = eZINI::instance( 'content.ini' ); $rootNodeID = $contentINI->variable( 'NodeSettings', 'RootNode' ); $titleArray = array(); $depth = -1; $currentItem = array_pop( $pathArray ); foreach ( $pathArray as $item ) { if ( $item['node_id'] == $rootNodeID ) $depth = 0; if ( $depth < 0 ) continue; $itemNode = eZContentObjectTreeNode::fetch( $item['node_id'] ); $itemClass = $itemNode->attribute( 'class_identifier' ); if ( in_array( $itemClass, $allowedClasses ) ) { $titleArray[] = self::getMetaTitleItem( $itemNode ); $depth++; if ( $depth >= $maxDepth ) break; } } $itemNode = eZContentObjectTreeNode::fetch( $currentItem['node_id'] ); if ( $itemNode ) $titleArray[] = self::getMetaTitleItem( $itemNode ); $titleArray = array_reverse( $titleArray ); return implode( $separator, $titleArray ); }
public function fetch($parameters, $publishedAfter, $publishedBeforeOrAt) { if (isset($parameters['Source'])) { $nodeID = $parameters['Source']; $node = eZContentObjectTreeNode::fetch($nodeID, false, false); // not as an object if ($node && $node['modified_subnode'] <= $publishedAfter) { return array(); } } else { $nodeID = 0; } $subTreeParameters = array(); $subTreeParameters['AsObject'] = false; $subTreeParameters['SortBy'] = array('published', false); // first the latest $subTreeParameters['AttributeFilter'] = array('and', array('published', '>', $publishedAfter), array('published', '<=', $publishedBeforeOrAt), array('visibility', '=', true)); if (isset($parameters['Class'])) { $subTreeParameters['ClassFilterType'] = 'include'; $subTreeParameters['ClassFilterArray'] = explode(';', $parameters['Class']); } if (isset($parameters['Limit'])) { $subTreeParameters['Limit'] = (int) $parameters['Limit']; } $result = eZContentObjectTreeNode::subTreeByNodeID($subTreeParameters, $nodeID); if ($result === null) { return array(); } $fetchResult = array(); foreach ($result as $item) { $fetchResult[] = array('object_id' => $item['id'], 'node_id' => $item['node_id'], 'ts_publication' => $item['published']); } return $fetchResult; }
/** * @param eZContentObjectTreeNode $node * @return string */ public function getNodeUrl(&$node = null) { $url = ''; if ( $node ) { $dataMap = $node->dataMap(); $mediaContentAttribute = $dataMap['media_content']; $mediaContentAttributeContent = $mediaContentAttribute->content(); $linkObjectID = $mediaContentAttributeContent['relation_list'][0]['contentobject_id']; $linkObject = eZContentObject::fetch( $linkObjectID ); $linkDatamap = $linkObject->dataMap(); $url = $linkDatamap['url']->content(); } return $url; }
/** * Tests that the output process works with objects. * * There should be no crash from casting errors. * @group templateOperators * @group attributeOperator */ public function testDisplayVariableWithObject() { $db = eZDB::instance(); // STEP 1: Add test folder $folder = new ezpObject( "folder", 2 ); $folder->name = __METHOD__; $folder->publish(); $nodeId = $folder->mainNode->node_id; $node = eZContentObjectTreeNode::fetch( $nodeId ); $attrOp = new eZTemplateAttributeOperator(); $outputTxt = ''; $formatterMock = $this->getMock( 'ezpAttributeOperatorFormatterInterface' ); $formatterMock->expects( $this->any() ) ->method( 'line' ) ->will( $this->returnValue( __METHOD__ ) ); try { $attrOp->displayVariable( $node, $formatterMock, true, 2, 0, $outputTxt ); } catch ( PHPUnit_Framework_Error $e ) { self::fail( "eZTemplateAttributeOperator raises an error when working with objects." ); } self::assertNotNull( $outputTxt, "Output text is empty." ); // this is an approxmiate test. The output shoudl contain the name of the object it has been generated correctly. self::assertContains( __METHOD__, $outputTxt, "There is something wrong with the output of the attribute operator. Object name not found." ); }
static function remove($objectID, $removeSubtrees = true) { eZContentCacheManager::clearContentCacheIfNeeded($objectID); $object = eZContentObject::fetch($objectID); if (!is_object($object)) { return false; } // TODO: Is content cache cleared for all objects in subtree ?? if ($removeSubtrees) { $assignedNodes = $object->attribute('assigned_nodes'); if (count($assignedNodes) == 0) { $object->purge(); eZContentObject::expireAllViewCache(); return true; } $assignedNodeIDArray = array(); foreach ($assignedNodes as $node) { $assignedNodeIDArray[] = $node->attribute('node_id'); } eZContentObjectTreeNode::removeSubtrees($assignedNodeIDArray, false); } else { $object->purge(); } return true; }
public function fetch($parameters, $publishedAfter, $publishedBeforeOrAt) { if (isset($parameters['Source'])) { $nodeID = $parameters['Source']; $node = eZContentObjectTreeNode::fetch($nodeID, false, false); // not as an object if ($node && $node['modified_subnode'] <= $publishedAfter) { return array(); } } else { $nodeID = 0; } $subTreeParameters = array(); $subTreeParameters['AsObject'] = false; $subTreeParameters['SortBy'] = array('published', true); // first the oldest $subTreeParameters['AttributeFilter'] = array('and', array('published', '>', $publishedAfter), array('published', '<=', $publishedBeforeOrAt)); if (isset($parameters['Classes'])) { $subTreeParameters['ClassFilterType'] = 'include'; $subTreeParameters['ClassFilterArray'] = explode(',', $parameters['Classes']); } // Do not fetch hidden nodes even when ShowHiddenNodes=true $subTreeParameters['AttributeFilter'] = array('and', array('visibility', '=', true)); $nodes = eZContentObjectTreeNode::subTreeByNodeID($subTreeParameters, $nodeID); if ($nodes === null) { return array(); } $fetchResult = array(); foreach ($nodes as $node) { $fetchResult[] = array('object_id' => $node['contentobject_id'], 'node_id' => $node['node_id'], 'ts_publication' => $node['published']); } return $fetchResult; }
/** * eZContentObjectTreeNode::createAttributeFilterSQLStrings() returns * invalid 'in'/'not in' SQL statements * * @link http://issues.ez.no/23528 * @dataProvider providerForTestIssue23528 */ public function testIssue23528($name, $expected) { $params = array(1, '3', 'foo', '1foo', 'foo_1'); $attributeFilterParams = array(array($name, 'in', $params)); $attributeFilter = eZContentObjectTreeNode::createAttributeFilterSQLStrings($attributeFilterParams); $this->assertEquals($expected, $attributeFilter['where']); }
/** * @group issue18073 * @link http://issues.ez.no/18073 */ public function testUnauthorizedContentByNode() { $this->setExpectedException('ezpContentAccessDeniedException'); // Let's take content node #5 / object #4 (users) as unauthorized content for anonymous user $unauthorizedNodeID = 5; $content = ezpContent::fromNode(eZContentObjectTreeNode::fetch($unauthorizedNodeID)); }
public function execute($process, $event) { $params = $process->attribute('parameter_list'); $object_id = $params['object_id']; $object = eZContentObject::fetch($object_id); if (!is_object($object)) { eZDebug::writeError("Unable to fetch object: '{$object_id}'", __METHOD__); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } // current parent node(s) $parentNodeIds = $object->attribute('parent_nodes'); $checkedObjs = array(); foreach ($parentNodeIds as $parentNodeId) { //eZDebug::writeDebug( "Checking parent node: " . $parentNodeId, __METHOD__ ); $parentNode = eZContentObjectTreeNode::fetch($parentNodeId); $parentObj = $parentNode->attribute('object'); if (!in_array($parentObj->attribute('id'), $checkedObjs)) { //eZDebug::writeDebug( "Checking all nodes of parent obj: " . $parentObj->attribute( 'id' ), __METHOD__ ); foreach ($parentObj->attribute('assigned_nodes') as $node) { if (!in_array($node->attribute('node_id'), $parentNodeIds)) { //eZDebug::writeDebug( "Found a node which is not parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ ); // the current obj has no node which is children of the given node of one of its parent objects $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $object->attribute('main_node_id'), 'object_id' => $object->attribute('id'), 'select_node_id_array' => array($node->attribute('node_id'))), null, true); if ($operationResult == null || $operationResult['status'] != true) { eZDebug::writeError("Unable to add new location to object: " . $object->attribute('id'), __METHOD__); } } else { //eZDebug::writeDebug( "Found a node which is already parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ ); } } } $checkedObjs[] = $parentObj->attribute('id'); } return eZWorkflowType::STATUS_ACCEPTED; }
/** * Return valid items for block with given $blockID * * @static * @param string $blockID * @param bool $asObject * @return array(eZContentObjectTreeNode) */ static function validNodes($blockID, $asObject = true) { if (isset($GLOBALS['eZFlowPool']) === false) { $GLOBALS['eZFlowPool'] = array(); } if (isset($GLOBALS['eZFlowPool'][$blockID])) { return $GLOBALS['eZFlowPool'][$blockID]; } $visibilitySQL = ""; if (eZINI::instance('site.ini')->variable('SiteAccessSettings', 'ShowHiddenNodes') !== 'true') { $visibilitySQL = "AND ezcontentobject_tree.is_invisible = 0 "; } $db = eZDB::instance(); $validNodes = $db->arrayQuery("SELECT ezm_pool.node_id\n FROM ezm_pool, ezcontentobject_tree, ezcontentobject\n WHERE ezm_pool.block_id='{$blockID}'\n AND ezm_pool.ts_visible>0\n AND ezm_pool.ts_hidden=0\n AND ezcontentobject_tree.node_id = ezm_pool.node_id\n AND ezcontentobject.id = ezm_pool.object_id\n AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject') . "\n {$visibilitySQL}\n ORDER BY ezm_pool.priority DESC"); if ($asObject && !empty($validNodes)) { $validNodesObjects = array(); foreach ($validNodes as $node) { $validNodeObject = eZContentObjectTreeNode::fetch($node['node_id']); if ($validNodeObject instanceof eZContentObjectTreeNode && $validNodeObject->canRead()) { $validNodesObjects[] = $validNodeObject; } } $GLOBALS['eZFlowPool'][$blockID] = $validNodesObjects; return $validNodesObjects; } else { return $validNodes; } }
/** * Creates a user with provided auth data * * @param array $authResult * * @return bool|eZUser */ public static function createUser($authResult) { $ngConnectINI = eZINI::instance('ngconnect.ini'); $siteINI = eZINI::instance('site.ini'); $defaultUserPlacement = $ngConnectINI->variable('LoginMethod_' . $authResult['login_method'], 'DefaultUserPlacement'); $placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement); if (!$placementNode instanceof eZContentObjectTreeNode) { $defaultUserPlacement = $siteINI->variable('UserSettings', 'DefaultUserPlacement'); $placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement); if (!$placementNode instanceof eZContentObjectTreeNode) { return false; } } $contentClass = eZContentClass::fetch($siteINI->variable('UserSettings', 'UserClassID')); $userCreatorID = $siteINI->variable('UserSettings', 'UserCreatorID'); $defaultSectionID = $siteINI->variable('UserSettings', 'DefaultSectionID'); $db = eZDB::instance(); $db->begin(); $contentObject = $contentClass->instantiate($userCreatorID, $defaultSectionID); $contentObject->store(); $nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $placementNode->attribute('node_id'), 'is_main' => 1)); $nodeAssignment->store(); $currentTimeStamp = eZDateTime::currentTimeStamp(); /** @var eZContentObjectVersion $version */ $version = $contentObject->currentVersion(); $version->setAttribute('modified', $currentTimeStamp); $version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT); $version->store(); $dataMap = $version->dataMap(); self::fillUserObject($version->dataMap(), $authResult); if (!isset($dataMap['user_account'])) { $db->rollback(); return false; } $userLogin = '******' . $authResult['login_method'] . '_' . $authResult['id']; $userPassword = (string) rand() . 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'] . (string) rand(); $userExists = false; if (eZUser::requireUniqueEmail()) { $userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser; } if (empty($authResult['email']) || $userExists) { $email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local'; } else { $email = $authResult['email']; } $user = new eZUser(array('contentobject_id' => $contentObject->attribute('id'), 'email' => $email, 'login' => $userLogin, 'password_hash' => md5("{$userLogin}\n{$userPassword}"), 'password_hash_type' => 1)); $user->store(); $userSetting = new eZUserSetting(array('is_enabled' => true, 'max_login' => 0, 'user_id' => $contentObject->attribute('id'))); $userSetting->store(); $dataMap['user_account']->setContent($user); $dataMap['user_account']->store(); $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $version->attribute('version'))); if (array_key_exists('status', $operationResult) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) { $db->commit(); return $user; } $db->rollback(); return false; }
protected function mainNode() { if ( is_null($this->_mainNode) ) { $this->_mainNode = eZContentObjectTreeNode::fetch( $this->mainNodeId ); } return $this->_mainNode; }
protected static function getNode($parentNodeId) { $parentNode = $parentNodeId; if (!$parentNode instanceof eZContentObjectTreeNode) { $parentNode = eZContentObjectTreeNode::fetch($parentNodeId); } return $parentNode instanceof eZContentObjectTreeNode ? $parentNode : null; }
public function execute($process, $event) { $processParameters = $process->attribute('parameter_list'); $object = eZContentObject::fetch($processParameters['object_id']); $targetClassIdentifier = $object->contentClass()->attribute('identifier'); $iniGroups = eZINI::instance('ngindexer.ini')->groups(); $targets = array(); foreach ($iniGroups as $iniGroupName => $iniGroup) { $iniGroupNameArray = explode('/', $iniGroupName); if (is_array($iniGroupNameArray) && count($iniGroupNameArray) == 3) { $class = eZContentClass::fetchByIdentifier($iniGroupNameArray[0]); if ($class instanceof eZContentClass) { $classAttribute = $class->fetchAttributeByIdentifier($iniGroupNameArray[1]); if ($classAttribute instanceof eZContentClassAttribute) { $indexTarget = isset($iniGroup['IndexTarget']) ? trim($iniGroup['IndexTarget']) : ''; $referencedClassIdentifiers = isset($iniGroup['ClassIdentifiers']) && is_array($iniGroup['ClassIdentifiers']) ? $iniGroup['ClassIdentifiers'] : null; if ($referencedClassIdentifiers != null && (empty($referencedClassIdentifiers) || in_array($targetClassIdentifier, $referencedClassIdentifiers))) { switch ($indexTarget) { case 'parent': case 'parent_line': $children = eZContentObjectTreeNode::subTreeByNodeID(array('ClassFilterType' => 'include', 'ClassFilterArray' => array($iniGroupNameArray[0]), 'Depth' => $indexTarget == 'parent' ? 1 : false), $object->mainNode()->attribute('node_id')); if (is_array($children)) { $targets = array_merge($targets, $children); } break; case 'children': $parentNode = $object->mainNode()->fetchParent(); if ($parentNode->classIdentifier() == $iniGroupNameArray[0]) { $targets[] = $parentNode; } break; case 'subtree': $path = $object->mainNode()->fetchPath(); foreach ($path as $pathNode) { if ($pathNode->classIdentifier() == $iniGroupNameArray[0]) { $targets[] = $parentNode; } } break; default: continue; } } } } } } $filteredTargets = array(); foreach ($targets as $target) { $objectID = $target->attribute('contentobject_id'); $version = $target->object()->attribute('current_version'); if (!isset($filteredTargets[$objectID])) { $filteredTargets[$objectID] = $version; eZContentOperationCollection::registerSearchObject($objectID, $version); } } return eZWorkflowType::STATUS_ACCEPTED; }
static function move($nodeID, $newParentNodeID) { $result = false; if (!is_numeric($nodeID) || !is_numeric($newParentNodeID)) { return false; } $node = eZContentObjectTreeNode::fetch($nodeID); if (!$node) { return false; } $object = $node->object(); if (!$object) { return false; } $objectID = $object->attribute('id'); $oldParentNode = $node->fetchParent(); $oldParentObject = $oldParentNode->object(); // clear user policy cache if this is a user object if (in_array($object->attribute('contentclass_id'), eZUser::contentClassIDs())) { eZUser::purgeUserCacheByUserId($object->attribute('id')); } // clear cache for old placement. eZContentCacheManager::clearContentCacheIfNeeded($objectID); $db = eZDB::instance(); $db->begin(); $node->move($newParentNodeID); $newNode = eZContentObjectTreeNode::fetchNode($objectID, $newParentNodeID); if ($newNode) { $newNode->updateSubTreePath(true, true); if ($newNode->attribute('main_node_id') == $newNode->attribute('node_id')) { // If the main node is moved we need to check if the section ID must change $newParentNode = $newNode->fetchParent(); $newParentObject = $newParentNode->object(); if ($object->attribute('section_id') != $newParentObject->attribute('section_id')) { eZContentObjectTreeNode::assignSectionToSubTree($newNode->attribute('main_node_id'), $newParentObject->attribute('section_id'), $oldParentObject->attribute('section_id')); } } // modify assignment $curVersion = $object->attribute('current_version'); $nodeAssignment = eZNodeAssignment::fetch($objectID, $curVersion, $oldParentNode->attribute('node_id')); if ($nodeAssignment) { $nodeAssignment->setAttribute('parent_node', $newParentNodeID); $nodeAssignment->setAttribute('op_code', eZNodeAssignment::OP_CODE_MOVE); $nodeAssignment->store(); // update search index $nodeIDList = array($nodeID); eZSearch::removeNodeAssignment($node->attribute('main_node_id'), $newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList); eZSearch::addNodeAssignment($newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList); } $result = true; } else { eZDebug::writeError("Node {$nodeID} was moved to {$newParentNodeID} but fetching the new node failed"); } $db->commit(); // clear cache for new placement. eZContentCacheManager::clearContentCacheIfNeeded($objectID); return $result; }
/** * @param eZContentObjectTreeNode $node * @return eZContentObjectTreeNode */ public static function getPublisherNodeFromNode( $node ) { if ( !$node instanceof eZContentObjectTreeNode ) return null; $publisherFolderNodeId = PublisherFolderTool::getPublisherNodeIdFromArticleNode($node); return eZContentObjectTreeNode::fetch( $publisherFolderNodeId ); }
function execute( $xmlNode ) { $action = $xmlNode->getAttribute( 'action' ); $xmlNodeID = $xmlNode->getAttribute( 'nodeID' ); $nodeID = $this->getReferenceID( $xmlNodeID ); if ( !$nodeID ) { $this->writeMessage( "\tInvalid node $nodeID does not exist.", 'warning' ); return false; } if ( !$action ) { $action = 'toogle'; } $node = eZContentObjectTreeNode::fetch( $nodeID ); if ( !$node ) { $this->writeMessage( "\tNo node defined.", 'error' ); return false; } switch ( $action ) { case 'unhide': { if ( $node->attribute( 'is_hidden' ) ) { eZContentObjectTreeNode::unhideSubTree( $node ); $this->writeMessage( "\tNode " . $node->attribute( 'name' ) . " has be unhidden.", 'error' ); } } break; case 'hide': { if ( !$node->attribute( 'is_hidden' ) ) { eZContentObjectTreeNode::hideSubTree( $node ); $this->writeMessage( "\tNode " . $node->attribute( 'name' ) . " has be hidden.", 'error' ); } } break; case 'toogle': { if ( $node->attribute( 'is_hidden' ) ) { eZContentObjectTreeNode::unhideSubTree( $node ); $this->writeMessage( "\tNode " . $node->attribute( 'name' ) . " has be unhidden.", 'error' ); } else { eZContentObjectTreeNode::hideSubTree( $node ); $this->writeMessage( "\tNode " . $node->attribute( 'name' ) . " has be hidden.", 'error' ); } } break; } }
static function validateContentNodeId($id) { if (is_numeric($id) && 0 < (int) $id) { $id = (int) $id; if (eZContentObjectTreeNode::fetch($id, false, false, false)) { return true; } } return false; }
/** * Returns the ezpContentLocation object for a particular node by ID * @param int $nodeId * @return ezpContentLocation * @throws ezcBaseException When the node is not found */ public static function fetchByNodeId($nodeId) { $node = eZContentObjectTreeNode::fetch($nodeId); if ($node instanceof eZContentObjectTreeNode) { return self::fromNode($node); } else { // @TODO Currently this exception is only in rest package. Needs to be fixed. throw new ezpContentNotFoundException("Unable to find node with ID {$nodeId}"); } }
/** definition of ezsrRatingObjectTreeNode, extends eZContentObjectTreeNode definition * * @return array */ static function definition() { static $def = null; if ($def === null) { $def = parent::definition(); $def['class_name'] = 'ezsrRatingObjectTreeNode'; $def['fields']['rating'] = array('name' => 'Rating', 'datatype' => 'integer', 'default' => 0, 'required' => false); $def['fields']['rating_count'] = array('name' => 'RatingCount', 'datatype' => 'integer', 'default' => 0, 'required' => false); } return $def; }
function execute($process, $event) { $user = eZUser::currentUser(); if ($user->isLoggedIn()) { return eZWorkflowType::STATUS_ACCEPTED; } $http = eZHTTPTool::instance(); // Get current content object ID. $parameters = $process->attribute('parameter_list'); $nodeID = $parameters['node_id']; $node = eZContentObjectTreeNode::fetch($nodeID); if (!$node) { return eZWorkflowType::STATUS_REJECTED; } $objectID = $node->attribute('contentobject_id'); // Get newsletter hash $uri = $GLOBALS['eZRequestedURI']; $userParameters = $uri->userParameters(); $hash = isset($userParameters['hash']) ? $userParameters['hash'] : false; $sendItem = eZSendNewsletterItem::fetchByHash($hash); if ($http->hasSessionVariable('NewsletterNodeIDArray')) { $globalNodeIDList = $http->sessionVariable('NewsletterNodeIDArray'); if (in_array($nodeID, $http->sessionVariable('NewsletterNodeIDArray'))) { $sendID = $http->sessionVariable('NewletterNodeMap_' . $nodeID); $sendItem = eZSendNewsletterItem::fetch($sendID); $sendItem->addObjectRead($objectID); return eZWorkflowType::STATUS_ACCEPTED; } } // Get send item, and check that is contains the object id. if (!$sendItem) { return eZWorkflowType::STATUS_REJECTED; } $sendItemIDList = $sendItem->attribute('newsletter_related_object_list'); if (!$sendItemIDList || !in_array($objectID, $sendItemIDList)) { return eZWorkflowType::STATUS_REJECTED; } $sendNodeIDArray = array(); // Set session variables foreach ($sendItemIDList as $sendObjectID) { $sendObject = eZContentObject::fetch($sendObjectID); if ($sendObject) { foreach ($sendObject->assignedNodes(false) as $nodeArray) { $http->setSessionVariable('NewletterNodeMap_' . $nodeArray['node_id'], $sendItem->attribute('id')); $sendNodeIDArray[] = $nodeArray['node_id']; } } } $globalNodeIDList = array_unique(array_merge($globalNodeIDList, $sendNodeIDArray)); $http->setSessionVariable('NewsletterNodeIDArray', $globalNodeIDList); // Add object read $sendItem->addObjectRead($objectID); return eZWorkflowType::STATUS_ACCEPTED; }
function runOperation(&$node) { if (!$node->canHide()) { return false; } if ($this->hidden) { eZContentObjectTreeNode::hideSubTree($node); } else { eZContentObjectTreeNode::unhideSubTree($node); } // We have no result value, so assume the operation worked return true; }