本文整理汇总了PHP中eZUser::contentClassIDs方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::contentClassIDs方法的具体用法?PHP eZUser::contentClassIDs怎么用?PHP eZUser::contentClassIDs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::contentClassIDs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: execute
//.........这里部分代码省略.........
if ( in_array( $section, $workflowSections ) )
{
$correctSection = true;
break;
}
}
}
}
else
$correctSection = true;
$inExcludeGroups = count( array_intersect( $userGroups, $workflowGroups ) ) != 0;
$userIsEditor = ( in_array( $user->id(), $editors ) ||
count( array_intersect( $userGroups, $approveGroups ) ) != 0 );
// All languages match by default
$hasLanguageMatch = true;
if ( $languageMask != 0 )
{
// Examine if the published version contains one of the languages we
// match for.
// If the language ID is part of the mask the result is non-zero.
$languageID = (int)$version->attribute( 'initial_language_id' );
$hasLanguageMatch = (bool)( $languageMask & $languageID );
}
if ( $hasLanguageMatch and
!$userIsEditor and
!$inExcludeGroups and
$correctSection )
{
/* Get user IDs from approve user groups */
$userClassIDArray = eZUser::contentClassIDs();
$approveUserIDArray = array();
foreach ( $approveGroups as $approveUserGroupID )
{
if ( $approveUserGroupID != false )
{
$approveUserGroup = eZContentObject::fetch( $approveUserGroupID );
if ( isset( $approveUserGroup ) )
{
foreach ( $approveUserGroup->attribute( 'assigned_nodes' ) as $assignedNode )
{
$userNodeArray = $assignedNode->subTree( array( 'ClassFilterType' => 'include',
'ClassFilterArray' => $userClassIDArray,
'Limitation' => array() ) );
foreach ( $userNodeArray as $userNode )
{
$approveUserIDArray[] = $userNode->attribute( 'contentobject_id' );
}
}
}
}
}
$approveUserIDArray = array_merge( $approveUserIDArray, $editors );
$approveUserIDArray = array_unique( $approveUserIDArray );
$collaborationID = false;
$db = eZDb::instance();
$taskResult = $db->arrayQuery( 'select workflow_process_id, collaboration_id from ezapprove_items where workflow_process_id = ' . $process->attribute( 'id' ) );
if ( count( $taskResult ) > 0 )
$collaborationID = $taskResult[0]['collaboration_id'];
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $collaborationID, 'approve collaborationID' );
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $process->attribute( 'event_state'), 'approve $process->attribute( \'event_state\')' );
if ( $collaborationID === false )
{
$this->createApproveCollaboration( $process, $event, $user->id(), $object->attribute( 'id' ), $versionID, $approveUserIDArray );
$this->setInformation( "We are going to create approval" );
$process->setAttribute( 'event_state', eZApproveType::COLLABORATION_CREATED );
$process->store();
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $this, 'approve execute' );
return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
}
else if ( $process->attribute( 'event_state') == eZApproveType::COLLABORATION_NOT_CREATED )
{
eZApproveCollaborationHandler::activateApproval( $collaborationID );
$process->setAttribute( 'event_state', eZApproveType::COLLABORATION_CREATED );
$process->store();
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $this, 'approve re-execute' );
return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
}
else //eZApproveType::COLLABORATION_CREATED
{
$this->setInformation( "we are checking approval now" );
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'check approval' );
return $this->checkApproveCollaboration( $process, $event );
}
}
else
{
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowSections , "we are not going to create approval " . $object->attribute( 'section_id') );
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $userGroups, "we are not going to create approval" );
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowGroups, "we are not going to create approval" );
eZDebugSetting::writeDebug( 'kernel-workflow-approve', $user->id(), "we are not going to create approval " );
return eZWorkflowType::STATUS_ACCEPTED;
}
}
示例3: swapNode
/**
* Swap a node with another one
*
* @param int $nodeID
* @param int $selectedNodeID
* @param array $nodeIdList
*
* @return array An array with operation status, always true
*/
public static function swapNode($nodeID, $selectedNodeID, $nodeIdList = array())
{
$userClassIDArray = eZUser::contentClassIDs();
$node = eZContentObjectTreeNode::fetch($nodeID);
$selectedNode = eZContentObjectTreeNode::fetch($selectedNodeID);
$object = $node->object();
$nodeParentNodeID = $node->attribute('parent_node_id');
$nodeParent = $node->attribute('parent');
$objectID = $object->attribute('id');
$objectVersion = $object->attribute('current_version');
$selectedObject = $selectedNode->object();
$selectedObjectID = $selectedObject->attribute('id');
$selectedObjectVersion = $selectedObject->attribute('current_version');
$selectedNodeParentNodeID = $selectedNode->attribute('parent_node_id');
$selectedNodeParent = $selectedNode->attribute('parent');
$db = eZDB::instance();
$db->begin();
$node->setAttribute('contentobject_id', $selectedObjectID);
$node->setAttribute('contentobject_version', $selectedObjectVersion);
$selectedNode->setAttribute('contentobject_id', $objectID);
$selectedNode->setAttribute('contentobject_version', $objectVersion);
// fix main node id
if ($node->isMain() && !$selectedNode->isMain()) {
$node->setAttribute('main_node_id', $selectedNode->attribute('main_node_id'));
$selectedNode->setAttribute('main_node_id', $selectedNode->attribute('node_id'));
} else {
if ($selectedNode->isMain() && !$node->isMain()) {
$selectedNode->setAttribute('main_node_id', $node->attribute('main_node_id'));
$node->setAttribute('main_node_id', $node->attribute('node_id'));
}
}
$node->store();
$selectedNode->store();
// clear user policy cache if this was a user object
if (in_array($object->attribute('contentclass_id'), $userClassIDArray)) {
eZUser::purgeUserCacheByUserId($object->attribute('id'));
}
if (in_array($selectedObject->attribute('contentclass_id'), $userClassIDArray)) {
eZUser::purgeUserCacheByUserId($selectedObject->attribute('id'));
}
// modify path string
$changedOriginalNode = eZContentObjectTreeNode::fetch($nodeID);
$changedOriginalNode->updateSubTreePath();
$changedTargetNode = eZContentObjectTreeNode::fetch($selectedNodeID);
$changedTargetNode->updateSubTreePath();
// modify section
if ($changedOriginalNode->isMain()) {
$changedOriginalObject = $changedOriginalNode->object();
$parentObject = $nodeParent->object();
if ($changedOriginalObject->attribute('section_id') != $parentObject->attribute('section_id')) {
eZContentObjectTreeNode::assignSectionToSubTree($changedOriginalNode->attribute('main_node_id'), $parentObject->attribute('section_id'), $changedOriginalObject->attribute('section_id'));
}
}
if ($changedTargetNode->isMain()) {
$changedTargetObject = $changedTargetNode->object();
$selectedParentObject = $selectedNodeParent->object();
if ($changedTargetObject->attribute('section_id') != $selectedParentObject->attribute('section_id')) {
eZContentObjectTreeNode::assignSectionToSubTree($changedTargetNode->attribute('main_node_id'), $selectedParentObject->attribute('section_id'), $changedTargetObject->attribute('section_id'));
}
}
eZContentObject::fixReverseRelations($objectID, 'swap');
eZContentObject::fixReverseRelations($selectedObjectID, 'swap');
$db->commit();
// clear cache for new placement.
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
eZSearch::swapNode($nodeID, $selectedNodeID, $nodeIdList = array());
return array('status' => true);
}
示例4:
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of version 2.0 of the GNU General
// Public License along with this program; if not, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
//
//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
$http = eZHTTPTool::instance();
$module = $Params['Module'];
/* We retrieve the class ID for users as this is used in many places in this
* code in order to be able to cleanup the user-policy cache. */
$userClassIDArray = eZUser::contentClassIDs();
if ($module->hasActionParameter('LanguageCode')) {
$languageCode = $module->actionParameter('LanguageCode');
} else {
$languageCode = false;
}
$viewMode = 'full';
if ($module->hasActionParameter('ViewMode')) {
$viewMode = $module->actionParameter('ViewMode');
}
if ($http->hasPostVariable('BrowseCancelButton') || $http->hasPostVariable('CancelButton')) {
if ($http->hasPostVariable('BrowseCancelURI')) {
return $module->redirectTo($http->postVariable('BrowseCancelURI'));
} else {
if ($http->hasPostVariable('CancelURI')) {
return $module->redirectTo($http->postVariable('CancelURI'));
示例5: isNodeTrashAllowed
/**
* Figure out if a node can be sent to trash or if it should be directly deleted as objects
* containing ezuser attributes can not be sent to trash.
*
* @return bool true if it can go to trash, false if it should be deleted
*/
public function isNodeTrashAllowed()
{
$userClassIDArray = eZUser::contentClassIDs();
$class = $this->attribute('object')->attribute('content_class');
// If current object has ezuser attributes, it can't be sent to trash
if (in_array($class->attribute('id'), $userClassIDArray)) {
return false;
}
// Checking for children using classes with ezuser attribute. Using == because subTreecount returns strings
return $this->subTreeCount(array('Limitation' => array(), 'SortBy' => array('path', false), 'IgnoreVisibility' => true, 'ClassFilterType' => 'include', 'ClassFilterArray' => $userClassIDArray, 'AsObject' => false)) == 0;
}
示例6: removeSubtrees
static function removeSubtrees($deleteIDArray, $moveToTrash = true, $infoOnly = false)
{
$moveToTrashAllowed = true;
$deleteResult = array();
$totalChildCount = 0;
$totalLoneNodeCount = 0;
$canRemoveAll = true;
$hasPendingObject = false;
$db = eZDB::instance();
$db->begin();
$userClassIDArray = eZUser::contentClassIDs();
foreach ($deleteIDArray as $deleteID) {
$node = eZContentObjectTreeNode::fetch($deleteID);
if ($node === null) {
continue;
}
$object = $node->attribute('object');
if ($object === null) {
continue;
}
$class = $object->attribute('content_class');
$canRemove = $node->attribute('can_remove');
$canRemoveSubtree = true;
$nodeID = $node->attribute('node_id');
$nodeName = $object->attribute('name');
$childCount = 0;
$newMainNodeID = false;
$objectNodeCount = 0;
$readableChildCount = 0;
if ($canRemove) {
$isUserClass = in_array($class->attribute('id'), $userClassIDArray);
if ($moveToTrashAllowed and $isUserClass) {
$moveToTrashAllowed = false;
}
$readableChildCount = $node->subTreeCount(array('Limitation' => array()));
$childCount = $node->subTreeCount(array('IgnoreVisibility' => true));
$totalChildCount += $childCount;
$allAssignedNodes = $object->attribute('assigned_nodes');
$objectNodeCount = count($allAssignedNodes);
// We need to find a new main node ID if we are trying
// to remove the current main node.
if ($node->attribute('main_node_id') == $nodeID) {
if (count($allAssignedNodes) > 1) {
foreach ($allAssignedNodes as $assignedNode) {
$assignedNodeID = $assignedNode->attribute('node_id');
if ($assignedNodeID == $nodeID) {
continue;
}
$newMainNodeID = $assignedNodeID;
break;
}
}
}
if ($infoOnly) {
// Find the number of items in the subtree we are allowed to remove
// if this differs from the total count it means we have items we cannot remove
// We do this by fetching the limitation list for content/remove
// and passing it to the subtree count function.
$currentUser = eZUser::currentUser();
$accessResult = $currentUser->hasAccessTo('content', 'remove');
if ($accessResult['accessWord'] == 'limited') {
$limitationList = $accessResult['policies'];
$removeableChildCount = $node->subTreeCount(array('Limitation' => $limitationList, 'IgnoreVisibility' => true));
$canRemoveSubtree = $removeableChildCount == $childCount;
$canRemove = $canRemoveSubtree;
}
//check if there is sub object in pending status
$limitCount = 100;
$offset = 0;
while (1) {
$children = $node->subTree(array('Limitation' => array(), 'SortBy' => array('path', false), 'Offset' => $offset, 'Limit' => $limitCount, 'IgnoreVisibility' => true, 'AsObject' => false));
// fetch pending node assignment(pending object)
$idList = array();
//add node itself into idList
if ($offset === 0) {
$idList[] = $nodeID;
}
foreach ($children as $child) {
$idList[] = $child['node_id'];
}
if (count($idList) === 0) {
break;
}
$pendingChildCount = eZNodeAssignment::fetchChildCountByVersionStatus($idList, eZContentObjectVersion::STATUS_PENDING);
if ($pendingChildCount !== 0) {
// there is pending object
$hasPendingObject = true;
break;
}
$offset += $limitCount;
}
}
// We will only remove the subtree if are allowed
// and are told to do so.
if ($canRemove and !$infoOnly) {
$moveToTrashTemp = $moveToTrash;
if (!$moveToTrashAllowed) {
$moveToTrashTemp = false;
}
// Remove children, fetching them by 100 to avoid memory overflow.
//.........这里部分代码省略.........
示例7: execute
function execute($process, $event)
{
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $process, 'approveLocationType::execute');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approveLocationType::execute');
$parameters = $process->attribute('parameter_list');
$userID = $parameters['user_id'];
$objectID = $parameters['object_id'];
$object = eZContentObject::fetch($objectID);
if (!$object) {
eZDebugSetting::writeError('ezworkflowcollection-workflow-approve-location', "No object with ID {$objectID}", 'approveLocationType::execute');
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
$version = $object->currentversion();
if (!$version) {
eZDebugSetting::writeError('ezworkflowcollection-workflow-approve-location', "No version for object with ID {$objectID}", 'approveLocationType::execute');
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
} else {
$versionID = $version->attribute('version');
}
// version option checking
$version_option = $event->attribute('version_option');
if ($version_option == self::VERSION_OPTION_FIRST_ONLY and $versionID > 1 or $version_option == self::VERSION_OPTION_EXCEPT_FIRST and $versionID == 1) {
return eZWorkflowType::STATUS_ACCEPTED;
}
// Target nodes
$targetNodeIDs = $parameters['select_node_id_array'];
if (!is_array($targetNodeIDs) || count($targetNodeIDs) == 0) {
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
/*
Check userID or get user_id from process object
*/
if ($userID == 0) {
$user = eZUser::currentUser();
$process->setAttribute('user_id', $user->id());
} else {
$user = eZUser::instance($userID);
}
$userGroups = array_merge($user->attribute('groups'), array($user->attribute('contentobject_id')));
$workflowSections = explode(',', $event->attribute('data_text1'));
$workflowGroups = $event->attribute('data_text2') == '' ? array() : explode(',', $event->attribute('data_text2'));
$editors = $event->attribute('data_text3') == '' ? array() : explode(',', $event->attribute('data_text3'));
$approveGroups = $event->attribute('data_text4') == '' ? array() : explode(',', $event->attribute('data_text4'));
$languageMask = $event->attribute('data_int2');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $user, 'approveLocationType::execute::user');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $userGroups, 'approveLocationType::execute::userGroups');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $editors, 'approveLocationType::execute::editor');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $approveGroups, 'approveLocationType::execute::approveGroups');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowSections, 'approveLocationType::execute::workflowSections');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowGroups, 'approveLocationType::execute::workflowGroups');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $languageMask, 'approveLocationType::execute::languageMask');
eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $object->attribute('section_id'), 'approveLocationType::execute::section_id');
$section = $object->attribute('section_id');
$correctSection = false;
if (!in_array($section, $workflowSections) && !in_array(-1, $workflowSections)) {
$assignedNodes = $object->attribute('assigned_nodes');
if ($assignedNodes) {
foreach ($assignedNodes as $assignedNode) {
$parent = $assignedNode->attribute('parent');
$parentObject = $parent->object();
$section = $parentObject->attribute('section_id');
if (in_array($section, $workflowSections)) {
$correctSection = true;
break;
}
}
}
} else {
$correctSection = true;
}
$inExcludeGroups = count(array_intersect($userGroups, $workflowGroups)) != 0;
$userIsEditor = in_array($user->id(), $editors) || count(array_intersect($userGroups, $approveGroups)) != 0;
// All languages match by default
$hasLanguageMatch = true;
if ($languageMask != 0) {
// Examine if the published version contains one of the languages we
// match for.
// If the language ID is part of the mask the result is non-zero.
$languageID = (int) $version->attribute('initial_language_id');
$hasLanguageMatch = (bool) ($languageMask & $languageID);
}
if ($hasLanguageMatch and !$userIsEditor and !$inExcludeGroups and $correctSection) {
/* Get user IDs from approve user groups */
$userClassIDArray = eZUser::contentClassIDs();
$approveUserIDArray = array();
foreach ($approveGroups as $approveUserGroupID) {
if ($approveUserGroupID != false) {
$approveUserGroup = eZContentObject::fetch($approveUserGroupID);
if (isset($approveUserGroup)) {
foreach ($approveUserGroup->attribute('assigned_nodes') as $assignedNode) {
$userNodeArray = $assignedNode->subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => $userClassIDArray, 'Limitation' => array()));
foreach ($userNodeArray as $userNode) {
$approveUserIDArray[] = $userNode->attribute('contentobject_id');
}
}
}
}
}
$approveUserIDArray = array_merge($approveUserIDArray, $editors);
$approveUserIDArray = array_unique($approveUserIDArray);
//.........这里部分代码省略.........