本文整理汇总了PHP中eZContentObjectTreeNode::updateMainNodeID方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::updateMainNodeID方法的具体用法?PHP eZContentObjectTreeNode::updateMainNodeID怎么用?PHP eZContentObjectTreeNode::updateMainNodeID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::updateMainNodeID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateMainAssignment
/**
* Update a node's main assignment
*
* @param int $mainAssignmentID
* @param int $objectID
* @param int $mainAssignmentParentID
*
* @return array An array with operation status, always true
*/
public static function updateMainAssignment($mainAssignmentID, $ObjectID, $mainAssignmentParentID)
{
eZContentObjectTreeNode::updateMainNodeID($mainAssignmentID, $ObjectID, false, $mainAssignmentParentID);
eZContentCacheManager::clearContentCacheIfNeeded($ObjectID);
return array('status' => true);
}
示例2: installSuspendedNodeAssignment
function installSuspendedNodeAssignment( &$installParameters )
{
if ( !isset( $installParameters['suspended-nodes'] ) )
{
return;
}
foreach ( $installParameters['suspended-nodes'] as $parentNodeRemoteID => $suspendedNodeInfo )
{
$parentNode = eZContentObjectTreeNode::fetchByRemoteID( $parentNodeRemoteID );
if ( $parentNode !== null )
{
$nodeInfo = $suspendedNodeInfo['nodeinfo'];
$nodeInfo['parent_node'] = $parentNode->attribute( 'node_id' );
$existNodeAssignment = eZPersistentObject::fetchObject( eZNodeAssignment::definition(),
null,
$nodeInfo );
$nodeInfo['priority'] = $suspendedNodeInfo['priority'];
if( !is_object( $existNodeAssignment ) )
{
$nodeAssignment = eZNodeAssignment::create( $nodeInfo );
$nodeAssignment->store();
}
$contentObject = eZContentObject::fetch( $nodeInfo['contentobject_id'] );
if ( is_object( $contentObject ) && $contentObject->attribute( 'current_version' ) == $nodeInfo['contentobject_version'] )
{
eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $nodeInfo['contentobject_id'],
'version' => $nodeInfo['contentobject_version'] ) );
}
if ( isset( $nodeInfo['is_main'] ) && $nodeInfo['is_main'] )
{
$existingMainNode = eZContentObjectTreeNode::fetchByRemoteID( $nodeInfo['parent_remote_id'], false );
if ( $existingMainNode )
{
eZContentObjectTreeNode::updateMainNodeID( $existingMainNode['node_id'],
$nodeInfo['contentobject_id'],
$nodeInfo['contentobject_version'],
$nodeInfo['parent_node'] );
}
}
}
else
{
eZDebug::writeError( 'Can not find parent node by remote-id ID = ' . $parentNodeRemoteID, __METHOD__ );
}
unset( $installParameters['suspended-nodes'][$parentNodeRemoteID] );
}
}
示例3: removeNodeFromTree
function removeNodeFromTree($moveToTrash = true)
{
$nodeID = $this->attribute('node_id');
$object = $this->object();
$assignedNodes = $object->attribute('assigned_nodes');
if ($nodeID == $this->attribute('main_node_id')) {
if (count($assignedNodes) > 1) {
$newMainNode = false;
foreach ($assignedNodes as $assignedNode) {
$assignedNodeID = $assignedNode->attribute('node_id');
if ($assignedNodeID == $nodeID) {
continue;
}
$newMainNode = $assignedNode;
break;
}
// We need to change the main node ID before we remove the current node
$db = eZDB::instance();
$db->begin();
eZContentObjectTreeNode::updateMainNodeID($newMainNode->attribute('node_id'), $object->attribute('id'), $object->attribute('current_version'), $newMainNode->attribute('parent_node_id'));
$this->removeThis();
eZSearch::addObject($object);
$db->commit();
} else {
// This is the last assignment so we remove the object too
$db = eZDB::instance();
$db->begin();
$this->removeThis();
if ($moveToTrash) {
// saving information about this node in ..trash_node table
$trashNode = eZContentObjectTrashNode::createFromNode($this);
$db = eZDB::instance();
$db->begin();
$trashNode->storeToTrash();
$db->commit();
$object->removeThis();
} else {
$object->purge();
}
$db->commit();
}
} else {
$this->removeThis();
if (count($assignedNodes) > 1) {
eZSearch::addObject($object);
}
}
}
示例4: unserialize
//.........这里部分代码省略.........
return $retValue;
}
$versionStatus = $versionDOMNode->getAttributeNS( 'http://ez.no/ezobject', 'status' );
$versionList[$versionDOMNode->getAttributeNS( 'http://ez.no/ezobject', 'version' )] = array( 'node_list' => $nodeList,
'status' => $versionStatus );
unset( $versionStatus );
$firstVersion = false;
$lastVersion = $contentObjectVersion->attribute( 'version' );
if ( $versionDOMNode->getAttribute( 'version' ) == $versionListActiveVersion )
{
$activeVersion = $contentObjectVersion->attribute( 'version' );
}
eZNodeAssignment::setNewMainAssignment( $contentObject->attribute( 'id' ), $lastVersion );
eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ),
'version' => $lastVersion ) );
$mainNodeInfo = null;
foreach ( $nodeList as $nodeInfo )
{
if ( $nodeInfo['is_main'] )
{
$mainNodeInfo =& $nodeInfo;
break;
}
}
if ( $mainNodeInfo )
{
$existingMainNode = eZContentObjectTreeNode::fetchByRemoteID( $mainNodeInfo['parent_remote_id'], false );
if ( $existingMainNode )
{
eZContentObjectTreeNode::updateMainNodeID( $existingMainNode['node_id'],
$mainNodeInfo['contentobject_id'],
$mainNodeInfo['contentobject_version'],
$mainNodeInfo['parent_node'],
$updateWithParentSection );
}
}
unset( $mainNodeInfo );
// Refresh $contentObject from DB.
$contentObject = eZContentObject::fetch( $contentObject->attribute( 'id' ) );
}
if ( !$activeVersion )
{
$activeVersion = $lastVersion;
}
/*
$contentObject->setAttribute( 'current_version', $activeVersion );
*/
$contentObject->setAttribute( 'name', $name );
if ( isset( $options['use_dates_from_package'] ) && $options['use_dates_from_package'] )
{
$contentObject->setAttribute( 'published', eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'published' ) ) );
$contentObject->setAttribute( 'modified', eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'modified' ) ) );
}
$contentObject->store();
$versions = $contentObject->versions();
$objectName = $contentObject->name();
$objectID = $contentObject->attribute( 'id' );
foreach ( $versions as $version )
{
$versionNum = $version->attribute( 'version' );
示例5: publishUpdateUser
//.........这里部分代码省略.........
$lastNameAttribute = $attribute;
}
}
}
}
}
//================= common part 2: start ========================
if ($firstNameAttribute) {
$firstNameAttribute->setAttribute('data_text', $first_name);
$firstNameAttribute->store();
}
if ($lastNameAttribute) {
$lastNameAttribute->setAttribute('data_text', $last_name);
$lastNameAttribute->store();
}
if (!isset($userDataChanged) or $userDataChanged === true) {
$contentClass = $contentObject->attribute('content_class');
$name = $contentClass->contentObjectName($contentObject);
$contentObject->setName($name);
}
if (!isset($emailChanged) or $emailChanged === true) {
$user->setAttribute('email', $email);
}
$user->setAttribute('password_hash', "");
$user->setAttribute('password_hash_type', 0);
$user->store();
$debugArray = array('Updating user data', 'createNewUser' => $createNewUser, 'userDataChanged' => isset($userDataChanged) ? $userDataChanged : null, 'login' => $login, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'firstNameAttribute is_object' => is_object($firstNameAttribute), 'lastNameAttribute is_object' => is_object($lastNameAttribute), 'content object id' => $contentObjectID, 'version id' => $version->attribute('version'));
eZDebug::writeNotice(var_export($debugArray, true), __METHOD__);
//================= common part 2: end ==========================
if ($createNewUser) {
reset($parentNodeIDs);
// prepare node assignments for publishing new user
foreach ($parentNodeIDs as $parentNodeID) {
$newNodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObjectID, 'contentobject_version' => 1, 'parent_node' => $parentNodeID, 'parent_remote_id' => uniqid('LDAP_'), 'is_main' => $defaultUserPlacement == $parentNodeID ? 1 : 0));
$newNodeAssignment->store();
}
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
} else {
if ($userDataChanged) {
// Publish object
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => $version->attribute('version')));
// Refetch object
$contentObject = eZContentObject::fetch($contentObjectID);
$version = $contentObject->attribute('current');
}
$LDAPIni = eZINI::instance('ldap.ini');
$keepGroupAssignment = $LDAPIni->hasVariable('LDAPSettings', 'KeepGroupAssignment') ? $LDAPIni->variable('LDAPSettings', 'KeepGroupAssignment') == "enabled" : false;
if ($keepGroupAssignment == false) {
$objectIsChanged = false;
$db = eZDB::instance();
$db->begin();
// First check existing assignments, remove any that should not exist
$assignedNodesList = $contentObject->assignedNodes();
$existingParentNodeIDs = array();
foreach ($assignedNodesList as $node) {
$parentNodeID = $node->attribute('parent_node_id');
if (!in_array($parentNodeID, $parentNodeIDs)) {
$node->removeThis();
$objectIsChanged = true;
} else {
$existingParentNodeIDs[] = $parentNodeID;
}
}
// Then check assignments that should exist, add them if they are missing
foreach ($parentNodeIDs as $parentNodeID) {
if (!in_array($parentNodeID, $existingParentNodeIDs)) {
$newNode = $contentObject->addLocation($parentNodeID, true);
$newNode->updateSubTreePath();
$newNode->setAttribute('contentobject_is_published', 1);
$newNode->sync();
$existingParentNodeIDs[] = $parentNodeID;
$objectIsChanged = true;
}
}
// Then ensure that the main node is correct
$currentMainParentNodeID = $contentObject->attribute('main_parent_node_id');
if ($currentMainParentNodeID != $defaultUserPlacement) {
$existingNode = eZContentObjectTreeNode::fetchNode($contentObjectID, $defaultUserPlacement);
if (!is_object($existingNode)) {
eZDebug::writeError("Cannot find assigned node as {$defaultUserPlacement}'s child.", __METHOD__);
} else {
$existingNodeID = $existingNode->attribute('node_id');
$versionNum = $version->attribute('version');
eZContentObjectTreeNode::updateMainNodeID($existingNodeID, $contentObjectID, $versionNum, $defaultUserPlacement);
$objectIsChanged = true;
}
}
$db->commit();
// Finally, clear object view cache if something was changed
if ($objectIsChanged) {
eZContentCacheManager::clearObjectViewCache($contentObjectID, true);
}
}
}
eZUser::updateLastVisit($userID);
//eZUser::setCurrentlyLoggedInUser( $user, $userID );
// Reset number of failed login attempts
eZUser::setFailedLoginAttempts($userID, 0);
return $user;
}
示例6: execute
//.........这里部分代码省略.........
self::writeDebug('writeNotice', "Content Class is: " . $objectContentClass);
$objectContentClassID = $object->attribute('contentclass_id');
self::writeDebug('writeNotice', "Default user class id is: " . $defaultUserClassID . ". This object class id is: " . $objectContentClassID);
/**
* Test if content object class ID matches ini settings default user content object class ID
* Only perform workflow event operations on content objects of the correct content class
*/
if ($objectContentClassID == $defaultUserClassID) {
// Fetch content object attributes needed
$assignedNodes = $object->attribute('assigned_nodes');
$objectDataMap = $object->attribute('data_map');
$objectNodeAssignments = eZNodeAssignment::fetchForObject($objectID, $object->attribute('current_version'), 0, false);
//$objectNodeAssignments = $object->attribute( 'assigned_nodes' );
// Get the selection content
$objectSelectionAttributeContent = $objectDataMap[$objectSelectionAttributeIdentifier]->attribute('content');
$objectSelectionAttributeContentString = implode(',', $objectSelectionAttributeContent);
self::writeDebug('writeNotice', "User object attribute " . $objectSelectionAttributeIdentifier . " content is set to: " . $objectSelectionAttributeContentString);
/**
* Test to ensure that object selection attribute content is greater than 0 (no selection) or
* that object selection attribute count is less than the count of userGroups (defined in ini settings)
*/
if ($objectSelectionAttributeContent > 0 || $objectSelectionAttributeContent < count($userGroups)) {
// Set userGroupID from ini defined user groups based on content object selection attribute content
$userGroupID = $userGroups[$objectSelectionAttributeContentString];
$selectedNodeID = $userGroupID;
}
$parentNodeIDs = array();
$ourNode = false;
/**
* Iterate over object assigned nodes and object node assignements
* test for parent node id matches and build array of parent_node_ids
* test for user content object selection attribute content selected node id
* and set node to move based on match
*/
foreach ($assignedNodes as $assignedNode) {
$append = false;
foreach ($objectNodeAssignments as $nodeAssignment) {
if ($nodeAssignment['parent_node'] == $assignedNode->attribute('parent_node_id')) {
$append = true;
break;
}
}
if ($append) {
$parentNodeIDs[] = $assignedNode->attribute('parent_node_id');
}
if ($assignedNode->attribute('parent_node_id') == $selectedNodeID) {
$ourNode = $assignedNode;
}
}
/**
* Test if we are to move the current main node to the selected location
*/
if ($move) {
self::writeDebug('writeDebug', 'Moving tactic');
if (!is_object($ourNode)) {
self::writeDebug('writeDebug', 'Node not found, so moving existing main node...');
eZContentObjectTreeNodeOperations::move($object->attribute('main_node_id'), $selectedNodeID);
}
} else {
/**
* Create a new node location assignment
*/
self::writeDebug('writeDebug', 'New node tactic');
if (!is_object($ourNode)) {
self::writeDebug('writeDebug', 'Node not found, so creating a new one ...');
$parentNode = eZContentObjectTreeNode::fetch($selectedNodeID);
$parentNodeObject = $parentNode->attribute('object');
// Add user content object location
$ourNode = $object->addLocation($selectedNodeID, true);
// Now set node as published and fix main_node_id
$ourNode->setAttribute('contentobject_is_published', 1);
$ourNode->setAttribute('main_node_id', $object->attribute('main_node_id'));
$ourNode->setAttribute('contentobject_version', $object->attribute('current_version'));
// Make sure the node's path_identification_string is set correctly
$ourNode->updateSubTreePath();
$ourNode->sync();
eZUser::cleanupCache();
}
if ($setMainNode) {
self::writeDebug('writeDebug', "'Setting as main node is enabled'", "", true);
if ($object->attribute('main_node_id') != $ourNode->attribute('node_id')) {
self::writeDebug('writeDebug', 'Existing main node is not our node, so updating main node', "", true);
eZContentObjectTreeNode::updateMainNodeID($ourNode->attribute('node_id'), $objectID, false, $selectedNodeID);
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
}
}
}
} else {
self::writeDebug('writeNotice', $objectName . ' is not a user class object');
}
if (self::WORKFLOW_TYPE_DEBUG_STOP_EXECUTION === true) {
die("<hr />\n\nWorkflow: " . self::WORKFLOW_TYPE_STRING . " execution has been ended before normal completion for debugging");
}
/**
* Return default succesful workflow event status code, by default, regardless of results of execution, always.
* Image alias image variation image files may not always need to be created. Also returning any other status
* will result in problems with the succesfull and normal completion of the workflow event process
*/
return eZWorkflowType::STATUS_ACCEPTED;
}
开发者ID:brookinsconsulting,项目名称:bcuserregisteruserplacement,代码行数:101,代码来源:bcuserregisteruserplacementtype.php