function tempNode() { if ($this->TempNode == null) { $this->TempNode = eZContentObjectTreeNode::create($this->attribute('parent_node'), $this->attribute('contentobject_id'), $this->attribute('contentobject_version'), $this->attribute('sort_field'), $this->attribute('sort_order')); $this->TempNode->setName($this->Name); } return $this->TempNode; }
static function addChildTo($contentobjectID, $nodeID, $asObject = false, $contentObjectVersion = false) { $node = eZContentObjectTreeNode::fetch($nodeID); $contentObject = eZContentObject::fetch($contentobjectID); if (!$contentObject) { return false; } if (!$contentObjectVersion) { $contentObjectVersion = $contentObject->attribute('current_version'); } $db = eZDB::instance(); $parentMainNodeID = $node->attribute('node_id'); //$parent->attribute( 'main_node_id' ); $parentPath = $node->attribute('path_string'); $parentDepth = $node->attribute('depth'); $isInvinsible = $node->attribute('is_invisible'); $nodeDepth = $parentDepth + 1; $insertedNode = eZContentObjectTreeNode::create($parentMainNodeID, $contentobjectID); // set default sorting from content class $contentClass = $contentObject->attribute('content_class'); $insertedNode->setAttribute('sort_field', $contentClass->attribute('sort_field')); $insertedNode->setAttribute('sort_order', $contentClass->attribute('sort_order')); $insertedNode->setAttribute('depth', $nodeDepth); $insertedNode->setAttribute('path_string', '/TEMPPATH'); $insertedNode->setAttribute('contentobject_version', $contentObjectVersion); // If the parent node is invisible, the new created node should be invisible as well. $insertedNode->setAttribute('is_invisible', $isInvinsible); $db->begin(); $insertedNode->store(); $insertedID = $insertedNode->attribute('node_id'); $newNodePath = $parentPath . $insertedID . '/'; $insertedNode->setAttribute('path_string', $newNodePath); $insertedNode->store(); $db->commit(); if ($asObject) { return $insertedNode; } else { return $insertedID; } }
function tempMainNode() { if ( $this->TempNode !== null ) return $this->TempNode; $object = $this->contentObject(); if ( $object->attribute( 'status' ) == eZContentObject::STATUS_DRAFT ) { $nodeAssignments = $this->nodeAssignments(); $mainNodeAssignment = null; foreach( $nodeAssignments as $nodeAssignment ) { if ( $nodeAssignment->attribute( 'is_main' ) ) { $mainNodeAssignment = $nodeAssignment; break; } } if ( $mainNodeAssignment === null and count( $nodeAssignments ) > 0 ) { $mainNodeAssignment = $nodeAssignments[0]; } if ( $mainNodeAssignment ) { $this->TempNode = $mainNodeAssignment->tempNode(); } } else if ( $object->attribute( 'status' ) == eZContentObject::STATUS_PUBLISHED ) { $mainNode = $object->mainNode(); if ( is_object( $mainNode ) ) { $this->TempNode = eZContentObjectTreeNode::create( $mainNode->attribute( 'parent_node_id' ), $mainNode->attribute( 'contentobject_id' ), $this->attribute( 'version' ), $mainNode->attribute( 'sort_field' ), $mainNode->attribute( 'sort_order' ) ); $this->TempNode->setName( $mainNode->Name ); } } return $this->TempNode; }
// #HACK# if ($object->attribute('contentclass_id') == 17) { foreach ($object->relatedContentObjectList($approveStatus->attribute('active_version'), false, false) as $relatedObject) { $relatedObject->setAttribute('flags', $relatedObject->attribute('flags') | EZ_CONTENT_OBJECT_FLAG_LOCK_EDIT | EZ_CONTENT_OBJECT_FLAG_LOCK_REMOVE); $relatedObject->sync(); } } } $collaborationItemID = $approveStatus->createCollaboration(); $approveINI = eZINI::instance('ezapprove2.ini'); if ($approveINI->variable('ApproveSettings', 'NodeCreationOnDraft') == 'true') { // Create temporary contentobject tree node entry $db = eZDB::instance(); #include_once( 'kernel/classes/ezcontentobjecttreenode.php' ); $parentNodeIDArray = $object->attribute('parent_nodes'); $tmpNode = eZContentObjectTreeNode::create($parentNodeIDArray[0], $object->attribute('id'), $approveStatus->attribute('active_version')); $tmpNode->store(); $parentNode = $tmpNode->attribute('parent'); $tmpNode->setAttribute('main_node_id', $tmpNode->attribute('node_id')); $tmpNode->setAttribute('path_string', $parentNode->attribute('path_string') . $tmpNode->attribute('node_id') . '/'); $tmpNode->setAttribute('depth', $parentNode->attribute('depth') + 1); // $tmpNode->setAttribute( 'published', mktime() ); $tmpNode->setAttribute('path_identification_string', $tmpNode->pathWithNames()); $tmpNode->sync(); #include_once( 'kernel/classes/ezurlalias.php' ); $alias = eZURLAlias::create($tmpNode->attribute('path_identification_string'), 'content/versionview/' . $object->attribute('id') . '/' . $approveStatus->attribute('active_version')); $alias->store(); #include_once( "kernel/classes/ezcontentcachemanager.php" ); eZContentCacheManager::clearObjectViewCache($parentNode->attribute('contentobject_id')); } return $Module->redirect('collaboration', 'item', array('full', $collaborationItemID));