本文整理汇总了PHP中eZNodeAssignment类的典型用法代码示例。如果您正苦于以下问题:PHP eZNodeAssignment类的具体用法?PHP eZNodeAssignment怎么用?PHP eZNodeAssignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZNodeAssignment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testFetchChildListByVersionStatus
/**
* test fetchChildListByVersionStatus
*/
public function testFetchChildListByVersionStatus()
{
//create object
$top = new ezpObject('article', 2);
$top->name = 'TOP ARTICLE';
$top->publish();
$child = new ezpObject('article', $top->mainNode->node_id);
$child->name = 'THIS IS AN ARTICLE';
$child->publish();
$child2 = new ezpObject('article', $top->mainNode->node_id);
$child2->name = 'THIS IS AN ARTICLE2';
$child2->publish();
$pendingChild = new ezpObject('article', $top->mainNode->node_id);
$pendingChild->name = 'THIS IS A PENDING ARTICLE';
$pendingChild->publish();
$version = $pendingChild->currentVersion();
$version->setAttribute('status', eZContentObjectVersion::STATUS_PENDING);
$version->store();
$idList = array($top->mainNode->node_id);
$arrayResult = eZNodeAssignment::fetchChildListByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING, false);
$this->assertEquals($pendingChild->id, $arrayResult[0]['contentobject_id']);
$arrayResult = eZNodeAssignment::fetchChildListByVersionStatus($idList, eZContentObjectVersion::STATUS_PUBLISHED, true);
$this->assertEquals($child->id, $arrayResult[0]->attribute('contentobject_id'));
$countResult = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING);
$this->assertEquals(1, $countResult);
$countResult = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PUBLISHED);
$this->assertEquals(2, $countResult);
}
开发者ID:runelangseid,项目名称:ezpublish,代码行数:31,代码来源:eznodeassignment_test.php
示例2: createUser
/**
* 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 = 'ngconnect_' . $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;
}
开发者ID:netgen,项目名称:ngconnect,代码行数:66,代码来源:ngconnectfunctions.php
示例3: move
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;
}
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:58,代码来源:ezcontentobjecttreenodeoperations.php
示例4: create
public function create($parentNodeId, $classIdentifier, $dataSet)
{
$result = array("result" => false);
$parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
if (!is_object($parentNode)) {
throw new Exception("createObject::create(): Failed to locate parent node. id='" . $parentNodeId . "'");
}
$contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$contentClass) {
throw new Exception("Failed to instantiate content class [" . $classIdentifier . "]");
}
// take care over clustered setups
$db = eZDB::instance();
$db->begin();
$contentObject = $contentClass->instantiate(false, 0, false);
$dataMap = $contentObject->attribute('data_map');
foreach ($dataSet as $key => $value) {
// attributes are lower case
$key = strtolower($key);
// if the field exists in the object, write to it
if (isset($dataMap[$key])) {
$dataMap[$key]->fromString($value);
$dataMap[$key]->store();
}
}
$contentObject->store();
$result["objectid"] = $contentObject->attribute('id');
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $parentNodeId, 'is_main' => 1));
if (!$nodeAssignment) {
throw new Exception("createObject::create(): Failed to create matching node for object of class '" . $classIdentifier . "'");
}
$nodeAssignment->store();
$obj_version = $contentObject->currentVersion();
$publish = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $obj_version->attribute('version')));
$db->commit();
$result["publish"] = $publish;
$result["parentnodeid"] = $parentNodeId;
$result["mainnodeid"] = $contentObject->mainNodeID();
$result["contentclass"] = $classIdentifier;
$result["contentobjectid"] = $contentObject->attribute('id');
$result["result"] = true;
return $result;
}
开发者ID:truffo,项目名称:eep,代码行数:43,代码来源:index.php
示例5: 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));
}
开发者ID:legende91,项目名称:ez,代码行数:41,代码来源:copy.php
示例6: createObject
function createObject($classIdentifier, $parentNodeID, $name)
{
$user = eZUser::currentUser();
$Class = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$Class) {
eZDebug::writeError("No class with identifier {$classIdentifier}", "classCreation");
return false;
}
$contentObject = $Class->instantiate($user->attribute('contentobject_id'));
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$attributes = $contentObject->attribute('contentobject_attributes');
$attributes[0]->fromString($name);
$attributes[0]->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
return true;
}
开发者ID:rmdev,项目名称:lisautocreateobject,代码行数:22,代码来源:autocreateobjecttype.php
示例7: array
$class = $object->contentClass();
if ($module->isCurrentAction('AddAssignment')) {
$selectedNodeIDArray = eZContentBrowse::result('AddNodeAssignment');
if (!is_array($selectedNodeIDArray)) {
$selectedNodeIDArray = array();
}
if (eZOperationHandler::operationIsAvailable('content_addlocation')) {
$operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $nodeID, 'object_id' => $objectID, 'select_node_id_array' => $selectedNodeIDArray), null, true);
} else {
eZContentOperationCollection::addAssignment($nodeID, $objectID, $selectedNodeIDArray);
}
} else {
if ($module->isCurrentAction('SelectAssignmentLocation')) {
$ignoreNodesSelect = array();
$ignoreNodesClick = array();
$assigned = eZNodeAssignment::fetchForObject($objectID, $object->attribute('current_version'), 0, false);
$publishedAssigned = $object->assignedNodes(false);
$isTopLevel = false;
foreach ($publishedAssigned as $element) {
$append = false;
if ($element['parent_node_id'] == 1) {
$isTopLevel = true;
}
foreach ($assigned as $ass) {
if ($ass['parent_node'] == $element['parent_node_id']) {
$append = true;
break;
}
}
if ($append) {
$ignoreNodesSelect[] = $element['node_id'];
开发者ID:heliopsis,项目名称:ezpublish-legacy,代码行数:31,代码来源:action.php
示例8: handleNodeTemplate
function handleNodeTemplate( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $tpl )
{
// When the object has been published we will use the nodes as
// node-assignments by faking the list, this is required since new
// version of the object does not have node-assignments/
// When the object is a draft we use the normal node-assignment list
$assignedNodeArray = array();
$versionedAssignedNodeArray = $version->attribute( 'parent_nodes' );
$parentNodeIDMap = array();
$nodes = $object->assignedNodes();
$i = 0;
foreach ( $nodes as $node )
{
$data = array( 'id' => null,
'contentobject_id' => $object->attribute( 'id' ),
'contentobject_version' => $version->attribute( 'version' ),
'parent_node' => $node->attribute( 'parent_node_id' ),
'sort_field' => $node->attribute( 'sort_field' ),
'sort_order' => $node->attribute( 'sort_order' ),
'is_main' => ( $node->attribute( 'main_node_id' ) == $node->attribute( 'node_id' ) ? 1 : 0 ),
'parent_remote_id' => $node->attribute( 'remote_id' ),
'op_code' => eZNodeAssignment::OP_CODE_NOP );
$assignment = eZNodeAssignment::create( $data );
$assignedNodeArray[$i] = $assignment;
$parentNodeIDMap[$node->attribute( 'parent_node_id' )] = $i;
++$i;
}
foreach ( $versionedAssignedNodeArray as $nodeAssignment )
{
$opCode = $nodeAssignment->attribute( 'op_code' );
if ( ( $opCode & 1 ) == eZNodeAssignment::OP_CODE_NOP ) // If the execute bit is not set it will be ignored.
{
continue;
}
// Only add assignments whose parent is not present in the published nodes.
if ( isset( $parentNodeIDMap[$nodeAssignment->attribute( 'parent_node' )] ) )
{
if ( $opCode == eZNodeAssignment::OP_CODE_CREATE ) // CREATE entries are just skipped
{
continue;
}
// Or if they have an op_code (move,remove) set, in which case they overwrite the entry
$index = $parentNodeIDMap[$nodeAssignment->attribute( 'parent_node' )];
$assignedNodeArray[$index]->setAttribute( 'id', $nodeAssignment->attribute( 'id' ) );
$assignedNodeArray[$index]->setAttribute( 'from_node_id', $nodeAssignment->attribute( 'from_node_id' ) );
$assignedNodeArray[$index]->setAttribute( 'remote_id', $nodeAssignment->attribute( 'remote_id' ) );
$assignedNodeArray[$index]->setAttribute( 'op_code', $nodeAssignment->attribute( 'op_code' ) );
continue;
}
if ( $opCode == eZNodeAssignment::OP_CODE_REMOVE ||
$opCode == eZNodeAssignment::OP_CODE_MOVE )
{
// The node-assignment has a remove/move operation but the node does not exist.
// We will not show it in this case.
continue;
}
$assignedNodeArray[$i] = $nodeAssignment;
++$i;
}
eZDebugSetting::writeDebug( 'kernel-content-edit', $assignedNodeArray, "assigned nodes array" );
$remoteMap = array();
$db = eZDB::instance();
$db->begin();
foreach ( $assignedNodeArray as $assignedNodeKey => $assignedNode )
{
$node = $assignedNode->getParentNode();
if ( $node !== null )
{
$remoteID = $assignedNode->attribute( 'remote_id' );
if ( $remoteID > 0 )
{
if ( isset( $remoteMap[$remoteID] ) )
{
if ( is_array( $remoteMap[$remoteID] ) )
{
$remoteMap[$remoteID][] = $assignedNode;
}
else
{
$currentRemote = $remoteMap[$remoteID];
unset( $remoteMap[$remoteID] );
$remoteMap[$remoteID] = array();
$remoteMap[$remoteID][] = $currentRemote;
$remoteMap[$remoteID][] = $assignedNode;
}
}
else
{
$remoteMap[$remoteID] = $assignedNode;
}
}
}
else
{
$assignedNode->purge();
if( isset( $assignedNodeArray[$assignedNodeKey] ) )
unset( $assignedNodeArray[$assignedNodeKey] );
}
}
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:node_edit.php
示例9: setupAssignments
//.........这里部分代码省略.........
foreach ( $classMatchArray as $classMatch )
{
$classMatch = trim( $classMatch );
if ( preg_match( "#^group_([0-9]+)$#", $classMatch, $matches ) )
{
$classGroupID = $matches[1];
if ( $contentClass->inGroup( $classGroupID ) )
{
$hasAssignment = true;
break;
}
}
else if ( $classMatch == $contentClassIdentifier )
{
$hasAssignment = true;
break;
}
else if ( $classMatch == $contentClassID )
{
$hasAssignment = true;
break;
}
}
if ( $hasAssignment )
break;
}
if ( !$hasAssignment )
{
$assignmentRules = explode( ';', $defaultAssignment );
$assignments = $assignmentRules[0];
$mainID = false;
if ( isset( $assignmentRules[1] ) )
$mainID = $assignmentRules[1];
}
eZDebug::writeDebug( $assignments, 'assignments' );
if ( $assignments )
{
if ( $mainID )
$mainID = $this->nodeID( $mainID );
$nodeList = $this->nodeIDList( $assignments );
eZDebug::writeDebug( $nodeList, 'nodeList' );
$assignmentCount = 0;
eZDebug::writeDebug( $this->CurrentObject->attribute( 'id' ), 'current object' );
eZDebug::writeDebug( $this->CurrentVersion->attribute( 'version' ), 'current version' );
foreach ( $nodeList as $nodeID )
{
$node = eZContentObjectTreeNode::fetch( $nodeID );
if ( !$node )
continue;
$parentContentObject = $node->attribute( 'object' );
eZDebug::writeDebug( "Checking for '$nodeID'" );
if ( $parentContentObject->checkAccess( 'create',
$contentClassID,
$parentContentObject->attribute( 'contentclass_id' ) ) == '1' )
{
eZDebug::writeDebug( "Adding to '$nodeID' and main = '$mainID'" );
if ( $mainID === false )
{
$isMain = ( $assignmentCount == 0 );
}
else
$isMain = ( $mainID == $nodeID );
/* Here we figure out the section ID in case it is needed
* to assign a newly created object to. */
if ( $sectionIDWanted and $isMain )
{
$db = eZDB::instance();
$query = "SELECT section_id
FROM ezcontentobject c, ezcontentobject_tree t
WHERE t.node_id = 109
AND t.contentobject_id = c.id";
$result = $db->arrayQuery( $query );
$sectionID = $result[0]['section_id'];
}
$nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $this->CurrentObject->attribute( 'id' ),
'contentobject_version' => $this->CurrentVersion->attribute( 'version' ),
'parent_node' => $node->attribute( 'node_id' ),
'is_main' => $isMain ) );
$nodeAssignment->store();
++$assignmentCount;
}
return $sectionID;
}
if ( $assignmentCount == 0 &&
$parameters['fallback-node-id'] )
{
$nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $this->CurrentObject->attribute( 'id' ),
'contentobject_version' => $this->CurrentVersion->attribute( 'version' ),
'parent_node' => $parameters['fallback-node-id'],
'is_main' => true ) );
$nodeAssignment->store();
++$assignmentCount;
}
}
return true;
}
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:101,代码来源:ezcontentobjectassignmenthandler.php
示例10: onPublish
function onPublish($contentObjectAttribute, $contentObject, $publishedNodes)
{
$content = $contentObjectAttribute->content();
foreach ($content['relation_list'] as $key => $relationItem) {
if ($relationItem['is_modified']) {
$subObjectID = $relationItem['contentobject_id'];
$subObjectVersion = $relationItem['contentobject_version'];
$object = eZContentObject::fetch($subObjectID);
$time = time();
$version = eZContentObjectVersion::fetchVersion($subObjectVersion, $subObjectID);
$version->setAttribute('modified', $time);
$version->store();
if ($relationItem['parent_node_id'] > 0) {
// action 1: edit a normal object
if (!eZNodeAssignment::fetch($object->attribute('id'), $object->attribute('current_version'), $relationItem['parent_node_id'], false)) {
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $relationItem['parent_node_id'], 'sort_field' => eZContentObjectTreeNode::SORT_FIELD_PUBLISHED, 'sort_order' => eZContentObjectTreeNode::SORT_ORDER_DESC, 'is_main' => 1));
$nodeAssignment->store();
}
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object->attribute('id'), 'version' => $subObjectVersion));
$objectNodeID = $object->attribute('main_node_id');
$content['relation_list'][$key]['node_id'] = $objectNodeID;
} else {
// action 2: edit a nodeless object (or creating a new node
// Make the previous version archived
$currentVersion = $object->currentVersion();
$currentVersion->setAttribute('status', eZContentObjectVersion::STATUS_ARCHIVED);
$currentVersion->setAttribute('modified', $time);
$currentVersion->store();
$version->setAttribute('status', eZContentObjectVersion::STATUS_PUBLISHED);
$version->store();
$object->setAttribute('status', eZContentObject::STATUS_PUBLISHED);
if (!$object->attribute('published')) {
$object->setAttribute('published', $time);
}
$object->setAttribute('modified', $time);
$object->setAttribute('current_version', $subObjectVersion);
$class = $object->contentClass();
$objectName = $class->contentObjectName($object, $version->attribute('version'));
$object->setName($objectName, $version->attribute('version'));
$object->store();
if (!eZNodeAssignment::fetch($object->attribute('id'), $object->attribute('current_version'), $contentObject->attribute('main_node_id'), false)) {
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $object->attribute('id'), 'contentobject_version' => $object->attribute('current_version'), 'parent_node' => $contentObject->attribute('main_node_id'), 'sort_field' => eZContentObjectTreeNode::SORT_FIELD_PUBLISHED, 'sort_order' => eZContentObjectTreeNode::SORT_ORDER_DESC, 'is_main' => 1));
$nodeAssignment->store();
}
}
$content['relation_list'][$key]['is_modified'] = false;
}
}
$this->storeObjectAttributeContent($contentObjectAttribute, $content);
$contentObjectAttribute->setContent($content);
$contentObjectAttribute->store();
}
开发者ID:nfrp,项目名称:ezpublish,代码行数:52,代码来源:ezobjectrelationlisttype.php
示例11: copyPublishContentObject
function copyPublishContentObject($sourceObject, $sourceSubtreeNodeIDList, &$syncNodeIDListSrc, &$syncNodeIDListNew, &$syncObjectIDListSrc, &$syncObjectIDListNew, $allVersions = false, $keepCreator = false, $keepTime = false)
{
global $cli;
$sourceObjectID = $sourceObject->attribute('id');
$key = array_search($sourceObjectID, $syncObjectIDListSrc);
if ($key !== false) {
return 1;
// object already copied
}
$srcNodeList = $sourceObject->attribute('assigned_nodes');
// check if all parent nodes for given contentobject are already published:
foreach ($srcNodeList as $srcNode) {
$sourceParentNodeID = $srcNode->attribute('parent_node_id');
// if parent node for this node is outside
// of subtree being copied, then skip this node.
$key = array_search($sourceParentNodeID, $sourceSubtreeNodeIDList);
if ($key === false) {
continue;
}
$key = array_search($sourceParentNodeID, $syncNodeIDListSrc);
if ($key === false) {
return 2;
// one of parent nodes is not published yet - have to try to publish later.
} else {
$newParentNodeID = $syncNodeIDListNew[$key];
if (($newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID)) === null) {
return 3;
// cannot fetch one of parent nodes - must be error somewhere above.
}
}
}
// make copy of source object
$newObject = $sourceObject->copy($allVersions);
// insert source and new object's ids in $syncObjectIDList
// 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();
$syncObjectIDListSrc[] = $sourceObjectID;
$syncObjectIDListNew[] = $newObject->attribute('id');
$curVersion = $newObject->attribute('current_version');
$curVersionObject = $newObject->attribute('current');
$newObjAssignments = $curVersionObject->attribute('node_assignments');
// copy nodeassigments:
$assignmentsForRemoving = array();
$foundMainAssignment = false;
foreach ($newObjAssignments as $assignment) {
$parentNodeID = $assignment->attribute('parent_node');
// if assigment is outside of subtree being copied then do not copy this assigment
$key = array_search($parentNodeID, $sourceSubtreeNodeIDList);
if ($key === false) {
$assignmentsForRemoving[] = $assignment->attribute('id');
continue;
}
$key = array_search($parentNodeID, $syncNodeIDListSrc);
if ($key === false) {
$cli->error("Subtree Copy Error!\nOne of parent nodes for contentobject (ID = {$sourceObjectID}) is not published yet.");
return 4;
}
if ($assignment->attribute('is_main')) {
$foundMainAssignment = true;
}
$newParentNodeID = $syncNodeIDListNew[$key];
$assignment->setAttribute('parent_node', $newParentNodeID);
$assignment->store();
}
// remove assigments which are outside of subtree being copied:
eZNodeAssignment::purgeByID($assignmentsForRemoving);
// JB valid
// if main nodeassigment was not copied then set as main first nodeassigment
if ($foundMainAssignment == false) {
$newObjAssignments = $curVersionObject->attribute('node_assignments');
// JB start
// We need to check if it has any assignments before changing the data.
if (isset($newObjAssignments[0])) {
$newObjAssignments[0]->setAttribute('is_main', 1);
$newObjAssignments[0]->store();
}
// JB end
}
// publish the newly created object
$result = eZOperationHandler::execute('content', 'publish', array('object_id' => $newObject->attribute('id'), 'version' => $curVersion));
// JB start
// Refetch the object data since it might change in the database.
$newObjectID = $newObject->attribute('id');
$newObject = eZContentObject::fetch($newObjectID);
// JB end
$newNodeList = $newObject->attribute('assigned_nodes');
if (count($newNodeList) == 0) {
$newObject->purge();
$cli->error("Subtree Copy Error!\nCannot publish contentobject.");
return 5;
}
$objAssignments = $curVersionObject->attribute('node_assignments');
foreach ($newNodeList as $newNode) {
$newParentNodeID = $newNode->attribute('parent_node_id');
$keyA = array_search($newParentNodeID, $syncNodeIDListNew);
if ($keyA === false) {
die("Copy Subtree Error: Algoritm ERROR! Cannot find new parent node ID in new ID's list");
}
//.........这里部分代码省略.........
开发者ID:nlescure,项目名称:ezpublish,代码行数:101,代码来源:ezsubtreecopy.php
示例12: createAndPublishObject
/**
* Creates and publishes a new content object.
*
* This function takes all the variables passes in the $params
* argument and creates a new content object out of it.
*
* Here is an example
* <code>
* <?php
*
* // admin user
* $creatorID = 14;
*
* // folder content class
* $classIdentifier = 'folder';
*
* // root node
* $parentNodeID = 2;
*
* // have a look at the folder content class' definition ;)
* // basically the array is the following :
* // key : attribute identifier ( not attribute ID !! )
* // value : value for this attribute
* //
* // Please refer to each fromString/toString function to see
* // how to organize your data
*
* $xmlDeclaration = '<?xml version="1.0" encoding="utf-8"?>
* <section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
* xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
* xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">';
*
* $attributeList = array( 'name' => 'A newly created folder object',
* 'short_name' => 'A new folder',
* 'short_description' => $xmlDeclaration .'<paragraph>This is the short description</paragraph></section>',
* 'description' => $xmlDeclaration . '<section><section><header>Some header</header><paragraph>Some paragraph
* with a <link target="_blank" url_id="1">link</link></paragraph>
* </section></section></section>',
* 'show_children' => true);
*
* // Creates the data import array
* $params = array();
* $params['creator_id'] = $creatorID;
* $params['class_identifier'] = $classIdentifier;
* $params['parent_node_id'] = $parentNodeID;
* $params['attributes'] = $attributeList;
*
* $contentObject = eZContentFunctions::createAndPublishObject( $params );
*
* if( $contentObject )
* {
* // do anything you want here
* }
*
* ?>
* </code>
*
* @param array $params An array with all the informations to store.
* This array must contains a strict list of key/value pairs.
* The possible keys are the following :
* - 'parent_node_id' : The parentNodeID for this new object.
* - 'class_identifier' : The classIdentifier for this new object.
* using the classID is not possible.
* - 'creator_id' : The eZUser::contentObjectID to use as creator
* of this new eZContentObject, uses current user
* and stores object id in current session if not set
* - 'attributes' : The list of attributes to store, in order to now
* which values you can use for this key, you have to
* read the code of the fromString and toString functions
* of the attribute's datatype you use
* - 'storage_dir' :
* - 'remote_id' : The value for the remoteID (optional)
* - 'section_id' : The value for the sectionID (optional)
* @return eZContentObject|false An eZContentObject object if success, false otherwise
*/
static function createAndPublishObject($params)
{
$parentNodeID = $params['parent_node_id'];
$classIdentifier = $params['class_identifier'];
$creatorID = isset($params['creator_id']) ? $params['creator_id'] : false;
$attributesData = isset($params['attributes']) ? $params['attributes'] : false;
$storageDir = isset($params['storage_dir']) ? $params['storage_dir'] : '';
$contentObject = false;
$parentNode = eZContentObjectTreeNode::fetch($parentNodeID, false, false);
if (is_array($parentNode)) {
$contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
if ($contentClass instanceof eZContentClass) {
$db = eZDB::instance();
$db->begin();
$languageCode = isset($params['language']) ? $params['language'] : false;
$sectionID = isset($params['section_id']) ? $params['section_id'] : 0;
$contentObject = $contentClass->instantiate($creatorID, $sectionID, false, $languageCode);
if (array_key_exists('remote_id', $params)) {
$contentObject->setAttribute('remote_id', $params['remote_id']);
}
$contentObject->store();
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1, 'sort_field' => $contentClass->attribute('sort_field'), 'sort_order' => $contentClass->attribute('sort_order')));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
//.........这里部分代码省略.........
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:101,代码来源:ezcontentfunctions.php
示例13: copyObject
/**
* @param eZContentObject $object
* @param bool $allVersions
* @param int $newParentNodeID
* @throws Exception
* @return eZContentObject
*/
public static function copyObject(eZContentObject $object, $allVersions = false, $newParentNodeID = null)
{
if (!$object instanceof eZContentObject) {
throw new InvalidArgumentException('Object not found');
}
if (!$newParentNodeID) {
$newParentNodeID = $object->attribute('main_parent_node_id');
}
// check if we can create node under the specified parent node
if (($newParentNode = eZContentObjectTreeNode::fetch($newParentNodeID)) === null) {
throw new InvalidArgumentException('Parent node not found');
}
$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');
throw new Exception('Object not found');
}
$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) {
/** @var eZNodeAssignment $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();
$db->commit();
return $newObject;
}
开发者ID:OpencontentCoop,项目名称:ocoperatorscollection,代码行数:47,代码来源:ocoperatorscollectionstools.php
示例14: array
if (!$discardConfirm) {
$isConfirmed = true;
}
}
if ($isConfirmed) {
$object = eZContentObject::fetch($objectID);
if ($object === null) {
return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$versionObject = $object->version($version);
if (is_object($versionObject) and in_array($versionObject->attribute('status'), array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT))) {
if (!$object->attribute('can_edit')) {
// Check if it is a first created version of an object.
// If so, then edit is allowed if we have an access to the 'create' function.
if ($object->attribute('current_version') == 1 && !$object->attribute('status')) {
$mainNode = eZNodeAssignment::fetchForObject($object->attribute('id'), 1);
$parentObj = $mainNode[0]->attribute('parent_contentobject');
$allowEdit = $parentObj->checkAccess('create', $object->attribute('contentclass_id'), $parentObj->attribute('contentclass_id'));
} else {
$allowEdit = false;
}
if (!$allowEdit) {
return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array('AccessList' => $object->accessList('edit')));
}
}
$versionCount = $object->getVersionCount();
$nodeID = $versionCount == 1 ? $versionObject->attribute('main_parent_node_id') : $object->attribute('main_node_id');
$versionObject->removeThis();
}
$hasRedirected = false;
if ($http->hasSessionVariable('RedirectIfDiscarded')) {
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:31,代码来源:removeeditversion.php
|
请发表评论