本文整理汇总了PHP中eZContentObjectTreeNode::subTreeByNodeID方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::subTreeByNodeID方法的具体用法?PHP eZContentObjectTreeNode::subTreeByNodeID怎么用?PHP eZContentObjectTreeNode::subTreeByNodeID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::subTreeByNodeID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
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;
}
示例2: fetchIndexTargets
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();
}
示例3: fetch
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;
}
示例4: execute
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;
}
示例5: query
/**
* Runs a content repository query using a given set of criteria
*
* @param ezpContentCriteria $criteria
* @return ezpContentList
*/
public static function query(ezpContentCriteria $criteria)
{
$fetchParams = self::translateFetchParams($criteria);
$nodes = eZContentObjectTreeNode::subTreeByNodeID($fetchParams->params, $fetchParams->rootNodeId);
$return = array();
foreach ($nodes as $node) {
$return[] = ezpContent::fromNode($node);
}
return $return;
}
示例6: fetchObjectAttributeHTTPInput
function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$postVariableName = $base . "_data_object_relation_id_" . $contentObjectAttribute->attribute("id");
$haveData = false;
if ($http->hasPostVariable($postVariableName)) {
$relatedObjectID = $http->postVariable($postVariableName);
if ($relatedObjectID == '') {
$relatedObjectID = null;
}
$contentObjectAttribute->setAttribute('data_int', $relatedObjectID);
$haveData = true;
}
$fuzzyMatchVariableName = $base . "_data_object_relation_fuzzy_match_" . $contentObjectAttribute->attribute("id");
if ($http->hasPostVariable($fuzzyMatchVariableName)) {
$trans = eZCharTransform::instance();
$fuzzyMatchText = trim($http->postVariable($fuzzyMatchVariableName));
if ($fuzzyMatchText != '') {
$fuzzyMatchText = $trans->transformByGroup($fuzzyMatchText, 'lowercase');
$classAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
if ($classAttribute) {
$classContent = $classAttribute->content();
if ($classContent['default_selection_node']) {
$nodeID = $classContent['default_selection_node'];
$nodeList = eZContentObjectTreeNode::subTreeByNodeID(array('Depth' => 1), $nodeID);
$lastDiff = false;
$matchObjectID = false;
foreach ($nodeList as $node) {
$name = $trans->transformByGroup(trim($node->attribute('name')), 'lowercase');
$diff = $this->fuzzyTextMatch($name, $fuzzyMatchText);
if ($diff === false) {
continue;
}
if ($diff == 0) {
$matchObjectID = $node->attribute('contentobject_id');
break;
}
if ($lastDiff === false or $diff < $lastDiff) {
$lastDiff = $diff;
$matchObjectID = $node->attribute('contentobject_id');
}
}
if ($matchObjectID !== false) {
$contentObjectAttribute->setAttribute('data_int', $matchObjectID);
$haveData = true;
}
}
}
}
}
return $haveData;
}
示例7: foreach
if ($dryRun) {
$cli->notice("Don't worry, --dry-run mode activated.");
}
foreach ($deleteIDArray as $nodeID) {
/** @var eZContentObjectTreeNode $node */
$node = eZContentObjectTreeNode::fetch($nodeID);
if ($node === null) {
$cli->error("\nSubtree remove Error!\nCannot find subtree with nodeID: '{$nodeID}'.");
continue;
}
$count = (int) eZContentObjectTreeNode::subTreeCountByNodeID($params, $nodeID);
$cli->notice("===== {$nodeID} : {$count} children to remove. " . $node->url());
$i = 0;
do {
/** @var eZContentObjectTreeNode[] $children */
$children = eZContentObjectTreeNode::subTreeByNodeID($params, $nodeID);
foreach ($children as $child) {
$i++;
$child_node_id = $child->attribute('node_id');
if ($verbose) {
$t = time();
$te = max($t - $start, 1);
// temps écoulé. (1 min pour éviter les divisions par 0)
$tm = $te / $i;
// temps moyen. = temps déjà consomé divisé par le nombre de objet passé. FLoat.
$r = $count - $i;
$tr = (int) ($r * $tm);
// temps restant = nombre d'objet restant multiplié par le temp moyen.
$tf = $t + $tr;
// temps final = temps actuel plus le temps restant
$df = date('H:i.s', $tf);
示例8: fetchPublisherFoldersForCluster
/**
* Returns publisher folders related to given cluster
* @param string $clusterIdentifier
* @throws Exception
* @return array:
*/
function fetchPublisherFoldersForCluster( $clusterIdentifier )
{
$remoteID = 'country_' . $clusterIdentifier;
$clusterObject = eZContentObject::fetchByRemoteId($remoteID);
if ( !$clusterObject instanceof eZContentObject )
throw new Exception( 'No node found for cluster ' . $clusterIdentifier );
$clusterNodeID = $clusterObject->mainNode()->attribute('node_id');
$class = eZContentClass::fetchByIdentifier( CLASS_IDENTIFIER_PUBLISHER_FOLDER );
$attributeID = (int) $class->fetchAttributeByIdentifier( ATTRIBUTE_TARGET_CONTENT_SERVICE )->ID;
$limit = 200;
$offset = 0;
$result = array();
while ( true )
{
$params = array(
'Depth' => 1,
'AsObject' => true,
'ClassFilterType' => 'include',
'ClassFilterArray' => array(
CLASS_IDENTIFIER_APPLICATION_FOLDER
),
'Limit' => $limit,
'Offset' => $offset,
);
$fetchedNodes = eZContentObjectTreeNode::subTreeByNodeID( $params, $clusterNodeID );
if ( empty( $fetchedNodes ) )
break;
foreach ( $fetchedNodes as $node )
{
$object = $node->ContentObject;
$publisherFolders = $object->relatedObjects( false, false, $attributeID, false, array(
'AllRelations' => eZContentObject::RELATION_ATTRIBUTE
), true );
foreach ( $publisherFolders as $publisherFolder )
{
$result['objects'][] = $publisherFolder;
$result['questions'][] = str_replace( 'publisher_folder-', '', $publisherFolder->RemoteID );
}
}
$offset += $limit;
}
return $result;
}
示例9: array
}
// check that solr is enabled and used
$eZSolr = eZSearch::getEngine();
if (!$eZSolr instanceof eZSolr) {
$script->shutdown(1, 'The current search engine plugin is not eZSolr');
}
$limit = 50;
$entries = eZPendingActions::fetchByAction(eZSolr::PENDING_ACTION_INDEX_SUBTREE);
if (!empty($entries)) {
$parentNodeIDList = array();
foreach ($entries as $entry) {
$parentNodeID = $entry->attribute('param');
$parentNodeIDList[] = (int) $parentNodeID;
$offset = 0;
while (true) {
$nodes = eZContentObjectTreeNode::subTreeByNodeID(array('IgnoreVisibility' => true, 'Offset' => $offset, 'Limit' => $limit, 'Limitation' => array()), $parentNodeID);
if (!empty($nodes) && is_array($nodes)) {
foreach ($nodes as $node) {
++$offset;
$cli->output("\tIndexing object ID #{$node->attribute('contentobject_id')}");
// delay commits with passing false for $commit parameter
$eZSolr->addObject($node->attribute('object'), false);
}
// finish up with commit
$eZSolr->commit();
// clear object cache to conserver memory
eZContentObject::clearCache();
} else {
break;
// No valid nodes
}
示例10: copySubtree
function copySubtree($srcNodeID, $dstNodeID, &$notifications, $allVersions, $keepCreator, $keepTime)
{
// 1. Copy subtree and form the arrays of accordance of the old and new nodes and content objects.
$sourceSubTreeMainNode = $srcNodeID ? eZContentObjectTreeNode::fetch($srcNodeID) : false;
$destinationNode = $dstNodeID ? eZContentObjectTreeNode::fetch($dstNodeID) : false;
if (!$sourceSubTreeMainNode) {
eZDebug::writeError("Cannot get subtree main node (nodeID = {$srcNodeID}).", "Subtree copy Error!");
$notifications['Errors'][] = ezpI18n::tr('kernel/content/copysubtree', "Fatal error: cannot get subtree main node (ID = %1).", null, array($srcNodeID));
$notifications['Result'] = false;
return $notifications;
}
if (!$destinationNode) {
eZDebug::writeError("Cannot get destination node (nodeID = {$dstNodeID}).", "Subtree copy Error!");
$notifications['Errors'][] = ezpI18n::tr('kernel/content/copysubtree', "Fatal error: cannot get destination node (ID = %1).", null, array($dstNodeID));
$notifications['Result'] = false;
return $notifications;
}
$sourceNodeList = array();
$syncNodeIDListSrc = array();
// arrays for synchronizing between source and new IDs of nodes
$syncNodeIDListNew = array();
$syncObjectIDListSrc = array();
// arrays for synchronizing between source and new IDs of contentobjects
$syncObjectIDListNew = array();
$sourceSubTreeMainNodeID = $sourceSubTreeMainNode->attribute('node_id');
$sourceNodeList[] = $sourceSubTreeMainNode;
$syncNodeIDListSrc[] = $sourceSubTreeMainNode->attribute('parent_node_id');
$syncNodeIDListNew[] = (int) $dstNodeID;
$nodeIDBlackList = array();
// array of nodes which are unable to copy
$objectIDBlackList = array();
// array of contentobjects which are unable to copy in any location inside new subtree
$sourceNodeList = array_merge($sourceNodeList, eZContentObjectTreeNode::subTreeByNodeID(array('Limitation' => array()), $sourceSubTreeMainNodeID));
$countNodeList = count($sourceNodeList);
$notifications['Notifications'][] = ezpI18n::tr('kernel/content/copysubtree', "Number of nodes of source subtree - %1", null, array($countNodeList));
// Prepare list of source node IDs. We will need it in the future
// for checking node is inside or outside of the subtree being copied.
$sourceNodeIDList = array();
foreach ($sourceNodeList as $sourceNode) {
$sourceNodeIDList[] = $sourceNode->attribute('node_id');
}
eZDebug::writeDebug("Source NodeID = {$srcNodeID}, destination NodeID = {$dstNodeID}", "Subtree copy: START!");
// 1. copying and publishing source subtree
$k = 0;
while (count($sourceNodeList) > 0) {
if ($k > $countNodeList) {
eZDebug::writeError("Too many loops while copying nodes.", "Subtree Copy Error!");
break;
}
for ($i = 0; $i < count($sourceNodeList); $i) {
$sourceNodeID = $sourceNodeList[$i]->attribute('node_id');
// if node was alreaty copied
if (in_array($sourceNodeID, $syncNodeIDListSrc)) {
array_splice($sourceNodeList, $i, 1);
continue;
}
//////////// check permissions START
// if node is already in black list, then skip current node:
if (in_array($sourceNodeID, $nodeIDBlackList)) {
array_splice($sourceNodeList, $i, 1);
continue;
}
$sourceObject = $sourceNodeList[$i]->object();
$srcSubtreeNodeIDlist = $sourceNodeID == $sourceSubTreeMainNodeID ? $syncNodeIDListSrc : $sourceNodeIDList;
$copyResult = copyPublishContentObject($sourceObject, $srcSubtreeNodeIDlist, $syncNodeIDListSrc, $syncNodeIDListNew, $syncObjectIDListSrc, $syncObjectIDListNew, $objectIDBlackList, $nodeIDBlackList, $notifications, $allVersions, $keepCreator, $keepTime);
if ($copyResult === 0) {
// if copying successful then remove $sourceNode from $sourceNodeList
array_splice($sourceNodeList, $i, 1);
} else {
$i++;
}
}
$k++;
}
array_shift($syncNodeIDListSrc);
array_shift($syncNodeIDListNew);
$countNewNodes = count($syncNodeIDListNew);
$countNewObjects = count($syncObjectIDListNew);
$notifications['Notifications'][] = ezpI18n::tr('kernel/content/copysubtree', "Number of copied nodes - %1", null, array($countNewNodes));
$notifications['Notifications'][] = ezpI18n::tr('kernel/content/copysubtree', "Number of copied contentobjects - %1", null, array($countNewObjects));
eZDebug::writeDebug(count($syncNodeIDListNew), "Number of copied nodes: ");
eZDebug::writeDebug(count($syncObjectIDListNew), "Number of copied contentobjects: ");
eZDebug::writeDebug($objectIDBlackList, "Copy subtree: Not copied object IDs list:");
eZDebug::writeDebug($nodeIDBlackList, "Copy subtree: Not copied node IDs list:");
$key = array_search($sourceSubTreeMainNodeID, $syncNodeIDListSrc);
if ($key === false) {
eZDebug::writeDebug("Root node of given subtree was not copied.", "Subtree copy:");
$notifications['Result'] = false;
return $notifications;
}
// 2. fetch all new subtree
$newSubTreeMainNodeID = $syncNodeIDListSrc[$key];
$newSubTreeMainNode = eZContentObjectTreeNode::fetch($newSubTreeMainNodeID);
$newNodeList[] = $newSubTreeMainNode;
$newNodeList = $sourceNodeList = array_merge($newNodeList, eZContentObjectTreeNode::subTreeByNodeID(false, $newSubTreeMainNodeID));
// 3. fix local links (in ezcontentobject_link)
eZDebug::writeDebug("Fixing global and local links...", "Subtree copy:");
$db = eZDB::instance();
if (!$db) {
eZDebug::writeError("Cannot create instance of eZDB for fixing local links (related objects).", "Subtree Copy Error!");
//.........这里部分代码省略.........
示例11: fetchObjectTree
public static function fetchObjectTree($parentNodeID, $sortBy, $onlyTranslated, $language, $offset, $limit, $depth, $depthOperator, $classID, $attribute_filter, $extended_attribute_filter, $class_filter_type, $class_filter_array, $groupBy, $mainNodeOnly, $ignoreVisibility, $limitation, $asObject, $objectNameFilter, $loadDataMap = null)
{
$treeParameters = array('Offset' => $offset, 'OnlyTranslated' => $onlyTranslated, 'Language' => $language, 'Limit' => $limit, 'Limitation' => $limitation, 'SortBy' => $sortBy, 'class_id' => $classID, 'AttributeFilter' => $attribute_filter, 'ExtendedAttributeFilter' => $extended_attribute_filter, 'ClassFilterType' => $class_filter_type, 'ClassFilterArray' => $class_filter_array, 'IgnoreVisibility' => $ignoreVisibility, 'ObjectNameFilter' => $objectNameFilter, 'MainNodeOnly' => $mainNodeOnly);
if (is_array($groupBy)) {
$groupByHash = array('field' => $groupBy[0], 'type' => false);
if (isset($groupBy[1])) {
$groupByHash['type'] = $groupBy[1];
}
$treeParameters['GroupBy'] = $groupByHash;
}
if ($asObject !== null) {
$treeParameters['AsObject'] = $asObject;
}
if ($loadDataMap) {
$treeParameters['LoadDataMap'] = true;
} else {
if ($loadDataMap === null) {
$treeParameters['LoadDataMap'] = 15;
}
}
if ($depth !== false) {
$treeParameters['Depth'] = $depth;
$treeParameters['DepthOperator'] = $depthOperator;
}
$children = null;
if (is_numeric($parentNodeID) or is_array($parentNodeID)) {
$children = eZContentObjectTreeNode::subTreeByNodeID($treeParameters, $parentNodeID);
}
if ($children === null) {
return array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
} else {
return array('result' => $children);
}
}
示例12: array
$options = $script->getOptions('', '', false, false, array('siteaccess' => true, 'user' => true));
$siteAccess = $options['siteaccess'] ? $options['siteaccess'] : false;
$script->setUseSiteAccess($siteAccess);
$script->initialize();
$cli->output("\nStart.");
$contentIni = eZINI::instance('content.ini');
$userRootNodeID = $contentIni->variable('NodeSettings', 'UserRootNode');
$siteIni = eZINI::instance('site.ini');
$anonymousUserID = $siteIni->variable('UserSettings', 'AnonymousUserID');
$anonymousUser = eZUser::fetch($anonymousUserID);
$anonymousUsers = array();
if (is_object($anonymousUser)) {
$anonymousUsers = $anonymousUser->groups();
$anonymousUsers[] = $anonymousUserID;
}
$topUserNodes = eZContentObjectTreeNode::subTreeByNodeID(array('Depth' => 1), $userRootNodeID);
if (count($topUserNodes) == 0) {
$cli->warning("Unable to retrieve the user root node. Please make sure\n" . "you log in to the system with the administrator's user\n" . "acount by using the -l and -p command line options.");
$script->shutdown(1);
}
$roleName = 'Tipafriend Role';
$role = eZRole::fetchByName($roleName);
if (is_object($role)) {
$cli->warning("The 'Tipafriend Role' already exists in the system. This means that\n" . "the script was already run before or the same role was added manually.\n" . "The role will not be added. Check the role settings of the system.");
} else {
$userInput = '';
$usersToAssign = array();
$stdin = fopen("php://stdin", "r+");
foreach ($topUserNodes as $userNode) {
if ($userInput != 'a') {
$name = $userNode->getName();
示例13: array_shift
$k++;
}
array_shift($syncNodeIDListSrc);
array_shift($syncNodeIDListNew);
$cli->output("\nNumber of copied nodes: " . count($syncNodeIDListNew));
$cli->output("Number of copied contentobjects: " . count($syncObjectIDListNew));
// 2. fetch all new subtree
$key = array_search($sourceSubTreeMainNodeID, $syncNodeIDListSrc);
if ($key === false) {
$cli->error("Subtree copy Error!\nCannot find subtree root node in array of IDs of copied nodes.");
$script->shutdown(1);
}
$newSubTreeMainNodeID = $syncNodeIDListSrc[$key];
$newSubTreeMainNode = eZContentObjectTreeNode::fetch($newSubTreeMainNodeID);
$newNodeList[] = $newSubTreeMainNode;
$newNodeList = $sourceNodeList = array_merge($newNodeList, eZContentObjectTreeNode::subTreeByNodeID(false, $newSubTreeMainNodeID));
$cli->output("Fixing global and local links...");
// 3. fix local links (in ezcontentobject_link)
$db = eZDB::instance();
if (!$db) {
$cli->error("Subtree Copy Error!\nCannot create instance of eZDB for fixing local links (related objects).");
$script->shutdown(3);
}
$idListStr = implode(',', $syncObjectIDListNew);
$relatedRecordsList = $db->arrayQuery("SELECT * FROM ezcontentobject_link WHERE from_contentobject_id IN ({$idListStr})");
foreach ($relatedRecordsList as $relatedEntry) {
$kindex = array_search($relatedEntry['to_contentobject_id'], $syncObjectIDListSrc);
if ($kindex !== false) {
$newToContentObjectID = $syncObjectIDListNew[$kindex];
$linkID = $relatedEntry['id'];
$db->query("UPDATE ezcontentobject_link SET to_contentobject_id={$newToContentObjectID} WHERE id={$linkID}");
示例14: array
$cli->error( "Subtree remove Error!\nCannot get subtree nodes. Please check nodes-id argument and try again." );
$script->showHelp();
$script->shutdown( 1 );
}
*/
$ini = eZINI::instance();
// Get user's ID who can remove subtrees. (Admin by default with userID = 14)
$userCreatorID = $ini->variable("UserSettings", "UserCreatorID");
$user = eZUser::fetch($userCreatorID);
if (!$user) {
$cli->error("Subtree remove Error!\nCannot get user object by userID = '{$userCreatorID}'.\n(See site.ini[UserSettings].UserCreatorID)");
$script->shutdown(1);
}
eZUser::setCurrentlyLoggedInUser($user, $userCreatorID);
$moveToTrash = false;
$deleteIDArray = eZContentObjectTreeNode::subTreeByNodeID(array('Limit' => 10000, 'Depth' => 4, 'ClassFilterType' => 'include', 'ClassFilterArray' => array('blog_post')), 2);
// print_r( count( $deleteIDArray ) );
$deleteIDArrayResult = array();
foreach ($deleteIDArray as $nodeID) {
$node = eZContentObjectTreeNode::fetch($nodeID->attribute('node_id'));
if ($node === null) {
$cli->error("\nSubtree remove Error!\nCannot find subtree with nodeID: '{$nodeID}'.");
continue;
}
$deleteIDArrayResult[] = $nodeID->attribute('node_id');
}
// Get subtree removal information
$info = eZContentObjectTreeNode::subtreeRemovalInformation($deleteIDArrayResult);
$deleteResult = $info['delete_list'];
if (count($deleteResult) == 0) {
$cli->output("\nExit.");
示例15: goAndPublishGroups
static function goAndPublishGroups(&$requiredParams, $curDN, &$groupsTree, &$stack, $depth, $isUser = false)
{
if (!isset($groupsTree[$curDN])) {
eZDebug::writeError('Passed $curDN is not in result tree array.', __METHOD__);
return false;
}
array_push($stack, $curDN);
$current =& $groupsTree[$curDN];
// check the name
if ($isUser) {
$currentName = $current['data'][$requiredParams['LDAPLoginAttribute']];
} else {
$currentName = $current['data'][$requiredParams['LDAPGroupNameAttribute']];
}
if (is_array($currentName) and isset($currentName['count']) and $currentName['count'] > 0) {
$currentName = $currentName[0];
}
if (empty($currentName)) {
eZDebug::writeWarning("Cannot create/use group with empty name (dn = {$curDN})", __METHOD__);
return false;
}
// go through parents
if (is_array($current['parents']) and count($current['parents']) > 0) {
foreach (array_keys($current['parents']) as $key) {
$parent =& $groupsTree[$key];
if (in_array($parent['data']['dn'], $stack)) {
$groupsTree['_recursion_detected_'] = true;
eZDebug::writeError('Recursion is detected in the user-groups tree while getting parent groups for ' . $curDN, __METHOD__);
return false;
}
if (isset($parent['nodes']) and count($parent['nodes']) > 0) {
continue;
}
$ret = self::goAndPublishGroups($requiredParams, $parent['data']['dn'], $groupsTree, $stack, $depth - 1);
if (isset($groupsTree['_recursion_detected_']) and $groupsTree['_recursion_detected_']) {
return false;
}
}
} else {
// We've reached a top node
if (!isset($groupsTree['root'])) {
$groupsTree['root'] = array('data' => null, 'parents' => null, 'children' => array(), 'nodes' => array($requiredParams['TopUserGroupNodeID']));
}
if (!isset($groupsTree['root']['children'][$curDN])) {
$groupsTree['root']['children'][$curDN] =& $current;
}
if (!isset($current['parents']['root'])) {
$current['parents']['root'] =& $groupsTree['root'];
}
}
if (!isset($current['nodes'])) {
$current['nodes'] = array();
}
$parentNodesForNew = array();
foreach (array_keys($current['parents']) as $key) {
$parent =& $groupsTree[$key];
if (is_array($parent['nodes']) and count($parent['nodes']) > 0) {
foreach ($parent['nodes'] as $parentNodeID) {
// fetch current parent node
$parentNode = eZContentObjectTreeNode::fetch($parentNodeID);
if (is_object($parentNode)) {
$params = array('AttributeFilter' => array(array('name', '=', $currentName)), 'Limitation' => array());
$nodes = eZContentObjectTreeNode::subTreeByNodeID($params, $parentNodeID);
if (is_array($nodes) and count($nodes) > 0 and !$isUser) {
// if group with given name already exist under $parentNode then get fetch
// group node and remember its ID
$node =& $nodes[0];
$nodeID = $node->attribute('node_id');
$current['nodes'][] = $nodeID;
} else {
// if not exist then remember $parentNodeID to publish a new one
$parentNodesForNew[] = $parentNodeID;
}
} else {
eZDebug::writeError('Cannot fetch parent node for creating new user group ' . $parentNodeID, __METHOD__);
}
}
} else {
eZDebug::writeError("Cannot get any published parent group for group/user with name = '{$currentName}'" . " (dn = '" . $current['data']['dn'] . "')", __METHOD__);
}
}
if (count($parentNodesForNew) > 0) {
if ($isUser) {
$current['new_parents'] = $parentNodesForNew;
$newNodeIDs = array();
} else {
$newNodeIDs = eZLDAPUser::publishNewUserGroup($parentNodesForNew, array('name' => $currentName, 'description' => ''));
}
$current['nodes'] = array_merge($current['nodes'], $newNodeIDs);
}
array_pop($stack);
return true;
}