本文整理汇总了PHP中eZContentObjectTreeNode::updateNodeVisibility方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::updateNodeVisibility方法的具体用法?PHP eZContentObjectTreeNode::updateNodeVisibility怎么用?PHP eZContentObjectTreeNode::updateNodeVisibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::updateNodeVisibility方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyObject
function copyObject($Module, $object, $allVersions, $newParentNodeID)
{
if (!$newParentNodeID) {
return $Module->redirectToView('view', array('full', 2));
}
// check if we can create node under the specified parent node
if (($newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID)) === null) {
return $Module->redirectToView('view', array('full', 2));
}
$classID = $object->attribute('contentclass_id');
if (!$newParentNode->checkAccess('create', $classID)) {
$objectID = $object->attribute('id');
eZDebug::writeError("Cannot copy object {$objectID} to node {$newParentNodeID}, " . "the current user does not have create permission for class ID {$classID}", 'content/copy');
return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
$db = eZDB::instance();
$db->begin();
$newObject = $object->copy($allVersions);
// We should reset section that will be updated in updateSectionID().
// If sectionID is 0 then the object has been newly created
$newObject->setAttribute('section_id', 0);
$newObject->store();
$curVersion = $newObject->attribute('current_version');
$curVersionObject = $newObject->attribute('current');
$newObjAssignments = $curVersionObject->attribute('node_assignments');
unset($curVersionObject);
// remove old node assignments
foreach ($newObjAssignments as $assignment) {
$assignment->purge();
}
// and create a new one
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $newObject->attribute('id'), 'contentobject_version' => $curVersion, 'parent_node' => $newParentNodeID, 'is_main' => 1));
$nodeAssignment->store();
// publish the newly created object
eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
// Update "is_invisible" attribute for the newly created node.
$newNode = $newObject->attribute('main_node');
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
$db->commit();
return $Module->redirectToView('view', array('full', $newParentNodeID));
}
示例2: checkContentActions
//.........这里部分代码省略.........
else if ( isset( $operationResult['result'] ) )
{
$result = $operationResult['result'];
$resultContent = false;
if ( is_array( $result ) )
{
if ( isset( $result['content'] ) )
{
$resultContent = $result['content'];
}
if ( isset( $result['path'] ) )
{
$Result['path'] = $result['path'];
}
}
else
{
$resultContent = $result;
}
// Temporary fix to make approval workflow work with edit.
if ( strpos( $resultContent, 'Deffered to cron' ) === 0 )
{
$Result = null;
}
else
{
$Result['content'] = $resultContent;
}
}
}break;
case eZModuleOperationInfo::STATUS_CANCELLED:
{
$Result = array();
$Result['content'] = "Content publish cancelled<br/>";
}
}
/* If we already have a correct module result
* we don't need to continue module execution.
*/
if ( is_array( $Result ) )
return eZModule::HOOK_STATUS_CANCEL_RUN;
}
// update content object attributes array by refetching them from database
$object = eZContentObject::fetch( $object->attribute( 'id' ) );
$contentObjectAttributes = $object->attribute( 'contentobject_attributes' );
// set chosen hidden/invisible attributes for object nodes
$http = eZHTTPTool::instance();
$assignedNodes = $object->assignedNodes( true );
foreach ( $assignedNodes as $node )
{
$nodeID = $node->attribute( 'node_id' );
$parentNodeID = $node->attribute( 'parent_node_id' );
$updateNodeVisibility = false;
$postVarName = "FutureNodeHiddenState_$parentNodeID";
if ( !$http->hasPostVariable( $postVarName ) )
$updateNodeVisibility = true;
else
{
$futureNodeHiddenState = $http->postVariable( $postVarName );
$db = eZDB::instance();
$db->begin();
if ( $futureNodeHiddenState == 'hidden' )
eZContentObjectTreeNode::hideSubTree( $node );
else if ( $futureNodeHiddenState == 'visible' )
eZContentObjectTreeNode::unhideSubTree( $node );
else if ( $futureNodeHiddenState == 'unchanged' )
$updateNodeVisibility = true;
else
eZDebug::writeWarning( "Unknown value for the future node hidden state: '$futureNodeHiddenState'" );
$db->commit();
}
if ( $updateNodeVisibility )
{
// this might be redundant
$db = eZDB::instance();
$db->begin();
$parentNode = eZContentObjectTreeNode::fetch( $parentNodeID );
eZContentObjectTreeNode::updateNodeVisibility( $node, $parentNode, /* $recursive = */ false );
$db->commit();
unset( $node, $parentNode );
}
}
unset( $assignedNodes );
$object = eZContentObject::fetch( $object->attribute( 'id' ) );
$newObjectName = $object->name();
$http = eZHTTPTool::instance();
computeRedirect( $module, $object, $version, $EditLanguage );
// we have set redirection URI for module so we don't need to continue module execution
return eZModule::HOOK_STATUS_CANCEL_RUN;
}
}
示例3: move
function move($newParentNodeID, $nodeID = 0)
{
if ($nodeID == 0) {
$node = $this;
$nodeID = $node->attribute('node_id');
} else {
$node = eZContentObjectTreeNode::fetch($nodeID);
}
$oldPath = $node->attribute('path_string');
$oldParentNodeID = $node->attribute('parent_node_id');
$newParentNodeID = (int) $newParentNodeID;
if ($oldParentNodeID != $newParentNodeID) {
$node->updateAndStoreModified();
// Who moves which content should be logged.
$object = $node->object();
eZAudit::writeAudit('content-move', array('Node ID' => $node->attribute('node_id'), 'Old parent node ID' => $oldParentNodeID, 'New parent node ID' => $newParentNodeID, 'Object ID' => $object->attribute('id'), 'Content Name' => $object->attribute('name'), 'Comment' => 'Moved the node to the given node: eZContentObjectTreeNode::move()'));
$newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID);
$newParentPath = $newParentNode->attribute('path_string');
$newParentDepth = $newParentNode->attribute('depth');
$newPath = $newParentPath . $nodeID;
$oldDepth = $node->attribute('depth');
$oldPathLength = strlen($oldPath);
$moveQuery = "UPDATE\n ezcontentobject_tree\n SET\n parent_node_id = {$newParentNodeID}\n WHERE\n node_id = {$nodeID}";
$db = eZDB::instance();
$subStringString = $db->subString('path_string', $oldPathLength);
$newPathString = $db->concatString(array("'{$newPath}'", $subStringString));
$moveQuery1 = "UPDATE\n ezcontentobject_tree\n SET\n path_identification_string = " . $db->concatString(array("'" . $db->escapeString($newParentNode->PathIdentificationString) . "'", $db->subString("path_identification_string", mb_strlen($node->PathIdentificationString) + 1))) . ",\n path_string = {$newPathString},\n depth = depth + {$newParentDepth} - {$oldDepth} + 1\n WHERE\n path_string LIKE '{$oldPath}%'";
$db->begin();
$db->query($moveQuery);
$db->query($moveQuery1);
/// role system clean up
// Clean up policies and limitations
$expireRoleCache = false;
$limitationsToFix = eZPolicyLimitation::findByType('SubTree', $node->attribute('path_string'), false);
if (count($limitationsToFix) > 0) {
$limitationIDString = $db->generateSQLINStatement($limitationsToFix, 'limitation_id');
$subStringString = $db->subString('value', $oldPathLength);
$newValue = $db->concatString(array("'{$newPath}'", $subStringString));
$query = "UPDATE\n ezpolicy_limitation_value\n SET\n value = {$newValue}\n WHERE\n value LIKE '{$oldPath}%' AND {$limitationIDString}";
$db->query($query);
$expireRoleCache = true;
}
// clean up limitations on role assignment level
$countRows = $db->arrayQuery("SELECT COUNT(*) AS row_count FROM ezuser_role WHERE limit_identifier='Subtree' AND limit_value LIKE '{$oldPath}%'");
$assignmentsToFixCount = $countRows[0]['row_count'];
if ($assignmentsToFixCount > 0) {
$subStringString = $db->subString('limit_value', $oldPathLength);
$newValue = $db->concatString(array("'{$newPath}'", $subStringString));
$db->query("UPDATE\n ezuser_role\n SET\n limit_value = {$newValue}\n WHERE\n limit_identifier='Subtree' AND limit_value LIKE '{$oldPath}%'");
$expireRoleCache = true;
}
if ($expireRoleCache) {
eZRole::expireCache();
}
// Update "is_invisible" node attribute.
$newNode = eZContentObjectTreeNode::fetch($nodeID);
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
$db->commit();
}
}
示例4: copyPublishContentObject
//.........这里部分代码省略.........
}
$srcParentNodeID = $syncNodeIDListSrc[$keyA];
// Update attributes of node
$bSrcParentFound = false;
foreach ($srcNodeList as $srcNode) {
if ($srcNode->attribute('parent_node_id') == $srcParentNodeID) {
$newNode->setAttribute('priority', $srcNode->attribute('priority'));
$newNode->setAttribute('is_hidden', $srcNode->attribute('is_hidden'));
$newNode->setAttribute('is_invisible', $srcNode->attribute('is_invisible'));
$syncNodeIDListSrc[] = $srcNode->attribute('node_id');
$syncNodeIDListNew[] = $newNode->attribute('node_id');
$bSrcParentFound = true;
break;
}
}
if ($bSrcParentFound == false) {
die("Copy Subtree Error: Algoritm ERROR! Cannot find source parent node ID in source parent node ID's list of contentobject being copied.");
}
// Create unique remote_id
$newRemoteID = eZRemoteIdUtility::generate('node');
$oldRemoteID = $newNode->attribute('remote_id');
$newNode->setAttribute('remote_id', $newRemoteID);
// Change parent_remote_id for object assignments
foreach ($objAssignments as $assignment) {
if ($assignment->attribute('parent_remote_id') == $oldRemoteID) {
$assignment->setAttribute('parent_remote_id', $newRemoteID);
$assignment->store();
}
}
$newNode->store();
}
// Update "is_invisible" attribute for the newly created node.
$newNode = $newObject->attribute('main_node');
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
// ??? do we need this here?
// if $keepCreator == true then keep owner of contentobject being
// copied and creator of its published version Unchaged
$isModified = false;
if ($keepTime) {
$srcPublished = $sourceObject->attribute('published');
$newObject->setAttribute('published', $srcPublished);
$srcModified = $sourceObject->attribute('modified');
$newObject->setAttribute('modified', $srcModified);
$isModified = true;
}
if ($keepCreator) {
$srcOwnerID = $sourceObject->attribute('owner_id');
$newObject->setAttribute('owner_id', $srcOwnerID);
$isModified = true;
}
if ($isModified) {
$newObject->store();
}
if ($allVersions) {
// copy time of creation and modification and creator id for
// all versions of content object being copied.
$srcVersionsList = $sourceObject->versions();
foreach ($srcVersionsList as $srcVersionObject) {
$newVersionObject = $newObject->version($srcVersionObject->attribute('version'));
if (!is_object($newVersionObject)) {
continue;
}
$isModified = false;
if ($keepTime) {
$srcVersionCreated = $srcVersionObject->attribute('created');
$newVersionObject->setAttribute('created', $srcVersionCreated);
示例5: copyObjectSameDirectory
/**
* Copies the specified object to the same folder, with optional $destinationName.
*
* @param eZContentObject $object
* @param eZContentObject $newParentNode
* @param string $destinationName
* @return bool
*/
protected function copyObjectSameDirectory($object, $newParentNode, $destinationName = null)
{
$object = $object->ContentObject;
$newParentNodeID = $newParentNode->attribute('node_id');
$classID = $object->attribute('contentclass_id');
if (!$newParentNode->checkAccess('create', $classID)) {
$objectID = $object->attribute('id');
return false;
}
$db = eZDB::instance();
$db->begin();
$newObject = $object->copy(true);
// We should reset section that will be updated in updateSectionID().
// If sectionID is 0 than the object has been newly created
$newObject->setAttribute('section_id', 0);
// @as 2009-01-08 - Added check for destination name the same as the source name
// (this was causing problems with nodes disappearing after renaming)
$newName = $destinationName;
if ($destinationName === null || strtolower($destinationName) === strtolower($object->attribute('name'))) {
$newName = 'Copy of ' . $object->attribute('name');
}
// @todo @as avoid using [0] (could be another index in some classes)
$contentObjectAttributes = $newObject->contentObjectAttributes();
$contentObjectAttributes[0]->setAttribute('data_text', $newName);
$contentObjectAttributes[0]->store();
$newObject->store();
$curVersion = $newObject->attribute('current_version');
$curVersionObject = $newObject->attribute('current');
$newObjAssignments = $curVersionObject->attribute('node_assignments');
unset($curVersionObject);
// remove old node assignments
foreach ($newObjAssignments as $assignment) {
$assignment->purge();
}
// and create a new one
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $newObject->attribute('id'), 'contentobject_version' => $curVersion, 'parent_node' => $newParentNodeID, 'is_main' => 1));
$nodeAssignment->store();
// publish the newly created object
eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
// Update "is_invisible" attribute for the newly created node.
$newNode = $newObject->attribute('main_node');
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
$db->commit();
return true;
}
示例6: copyObject
/**
* Create a copy of an object.
*
* The basis for this method is taken from kernel/content/copy.php
*
* @todo Merge this method into kernel wrapper's object class.
*
* @param eZContentObject $object
* @param int $newParentNodeID
* @return eZContentObject
*/
public static function copyObject($object, $newParentNodeID)
{
$newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID);
$db = eZDB::instance();
$db->begin();
$newObject = $object->copy(true);
// We should reset section that will be updated in updateSectionID().
// If sectionID is 0 than the object has been newly created
$newObject->setAttribute('section_id', 0);
$newObject->store();
$curVersion = $newObject->attribute('current_version');
$curVersionObject = $newObject->attribute('current');
$newObjAssignments = $curVersionObject->attribute('node_assignments');
unset($curVersionObject);
// remove old node assignments
foreach ($newObjAssignments as $assignment) {
$assignment->purge();
}
// and create a new one
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $newObject->attribute('id'), 'contentobject_version' => $curVersion, 'parent_node' => $newParentNodeID, 'is_main' => 1));
$nodeAssignment->store();
// publish the newly created object
eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
// Update "is_invisible" attribute for the newly created node.
$newNode = $newObject->attribute('main_node');
eZContentObjectTreeNode::updateNodeVisibility($newNode, $newParentNode);
$db->commit();
return $newObject;
}
示例7: editContentObject
//.........这里部分代码省略.........
$newRow['name'] = 'Row_' . ( $matrix->NumRows + 1 );
$matrix->NumRows++;
$matrix->Matrix['rows']['sequential'][] = $newRow;
}
$matrix->Cells = $cells;
$attribute->setAttribute( 'data_text', $matrix->xmlString() );
$matrix->decodeXML( $attribute->attribute( 'data_text' ) );
$attribute->setContent( $matrix );
}
} break;
case 'ezauthor':
case 'ezbinaryfile':
case 'ezcountry':
case 'ezdate':
case 'ezdatetime':
case 'ezenum':
case 'ezidentifier':
case 'ezinisetting':
case 'ezisbn':
case 'ezmedia':
case 'ezmultioption':
case 'ezmultiprice':
case 'ezobjectrelationlist':
case 'ezoption':
case 'ezpackage':
case 'ezproductcategory':
case 'ezrangeoption':
case 'ezsubtreesubscription':
case 'eztime':
{
$this->writeMessage( "\tDatatype " . $dataType . " not supported yet.", 'warning' );
} break;
}
$attribute->store();
}
}
if ( isset($objectInformation['sectionID']) && $objectInformation['sectionID'] != '' && $objectInformation['sectionID'] != 0 )
{
$contentObject->setAttribute( 'section_id', $objectInformation['sectionID'] );
}
if ( isset($objectInformation['creatorID']) && $objectInformation['creatorID'] != '' && $objectInformation['creatorID'] != 0 )
{
$contentObjectVersion->setAttribute( 'creator_id', $objectInformation['creatorID'] );
}
if ( isset($objectInformation['ownerID']) && $objectInformation['ownerID'] != '' && $objectInformation['ownerID'] != 0 )
{
$contentObject->setAttribute( 'owner_id', $objectInformation['ownerID'] );
}
$contentObjectVersion->store();
$contentObject->store();
$db->commit();
eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ), 'version' => $versionNumber ) );
// set chosen hidden/invisible attributes for object nodes
$http = eZHTTPTool::instance();
$assignedNodes = $contentObject->assignedNodes( true );
foreach ( $assignedNodes as $node )
{
$nodeID = $node->attribute( 'node_id' );
$parentNodeID = $node->attribute( 'parent_node_id' );
$db = eZDB::instance();
$db->begin();
$parentNode = eZContentObjectTreeNode::fetch( $parentNodeID );
eZContentObjectTreeNode::updateNodeVisibility( $node, $parentNode, /* $recursive = */ false );
$db->commit();
unset( $node, $parentNode );
}
unset( $assignedNodes );
eZContentCacheManager::clearObjectViewCacheIfNeeded( $contentObject->attribute( 'id' ) );
$newNodeArray = eZContentObjectTreeNode::fetchByContentObjectID( $contentObject->attribute( 'id' ) );
$refArray = false;
if ( $newNodeArray && count($newNodeArray) >= 1 )
{
$newNode = $newNodeArray[0];
if ( $newNode )
{
$refArray = array( "node_id" => $newNode->attribute( 'node_id' ),
"name" => $contentObject->attribute( 'name' ),
"object_id" => $contentObject->attribute( 'id' ) );
}
}
unset($contentObjectVersion);
unset($contentObject);
return $refArray;
}
return false;
}