コード例 #1
0
 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
0
    function execute( $process, $event )
    {
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $process, 'eZApproveType::execute' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'eZApproveType::execute' );
        $parameters = $process->attribute( 'parameter_list' );
        $versionID = $parameters['version'];
        $objectID = $parameters['object_id'];
        $object = eZContentObject::fetch( $objectID );

        if ( !$object )
        {
            eZDebugSetting::writeError( 'kernel-workflow-approve', "No object with ID $objectID", 'eZApproveType::execute' );
            return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
        }

        $version = $object->version( $versionID );

        if ( !$version )
        {
            eZDebugSetting::writeError( 'kernel-workflow-approve', "No version $versionID for object with ID $objectID", 'eZApproveType::execute' );
            return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
        }

        // only check this in cronjob
        if( $process->attribute( 'status' ) == eZWorkflow::STATUS_DEFERRED_TO_CRON )
        {
            $nodeAssignmentList = $version->attribute( 'node_assignments' );
            if( !empty( $nodeAssignmentList ) )
            {
                foreach ( $nodeAssignmentList as $nodeAssignment )
                {
                    $parentNode = $nodeAssignment->getParentNode();
                    if( $parentNode === null )
                    {
                        eZDebugSetting::writeError( 'kernel-workflow-approve', "No parent node for object with ID $objectID version $versionID", 'eZApproveType::execute' );
                        return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
                    }
                }
            }
        }

        // version option checking
        $version_option = $event->attribute( 'version_option' );
        if ( ( $version_option == eZApproveType::VERSION_OPTION_FIRST_ONLY and $parameters['version'] > 1 ) or
             ( $version_option == eZApproveType::VERSION_OPTION_EXCEPT_FIRST and $parameters['version'] == 1 ) )
        {
            return eZWorkflowType::STATUS_ACCEPTED;
        }

        /*
          If we run event first time ( when we click publish in admin ) we do not have user_id set in workflow process,
          so we take current user and store it in workflow process, so next time when we run event from cronjob we fetch
          user_id from there.
         */
        if ( $process->attribute( 'user_id' ) == 0 )
        {
            $user = eZUser::currentUser();
            $process->setAttribute( 'user_id', $user->id() );
        }
        else
        {
            $user = eZUser::instance( $process->attribute( 'user_id' ) );
        }

        $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( 'kernel-workflow-approve', $user, 'eZApproveType::execute::user' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $userGroups, 'eZApproveType::execute::userGroups' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $editors, 'eZApproveType::execute::editor' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $approveGroups, 'eZApproveType::execute::approveGroups' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowSections, 'eZApproveType::execute::workflowSections' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $workflowGroups, 'eZApproveType::execute::workflowGroups' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $languageMask, 'eZApproveType::execute::languageMask' );
        eZDebugSetting::writeDebug( 'kernel-workflow-approve', $object->attribute( 'section_id'), 'eZApproveType::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 );

            $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
0
 /**
  * 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
0
ファイル: action.php プロジェクト: rmiguel/ezpublish
//   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
0
 /**
  * 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
0
 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.
                 // removeNodeFromTree -> removeThis handles cache clearing
                 while (1) {
                     // We should remove the latest subitems first,
                     // so we should fetch subitems sorted by 'path_string' DESC
                     $children = $node->subTree(array('Limitation' => array(), 'SortBy' => array('path', false), 'Limit' => 100, 'IgnoreVisibility' => true));
                     if (!$children) {
                         break;
                     }
                     foreach ($children as $child) {
                         $childObject = $child->attribute('object');
                         $child->removeNodeFromTree($moveToTrashTemp);
                         eZContentObject::clearCache();
                     }
                 }
                 $node->removeNodeFromTree($moveToTrashTemp);
             }
         }
         if (!$canRemove) {
             $canRemoveAll = false;
         }
         // Do not create info list if we are removing subtrees
         if (!$infoOnly) {
             continue;
         }
         $soleNodeCount = $node->subtreeSoleNodeCount();
         $totalLoneNodeCount += $soleNodeCount;
         if ($objectNodeCount <= 1) {
             ++$totalLoneNodeCount;
         }
         $item = array("nodeName" => $nodeName, "childCount" => $childCount, "additionalWarning" => '', 'node' => $node, 'object' => $object, 'class' => $class, 'node_name' => $nodeName, 'child_count' => $childCount, 'object_node_count' => $objectNodeCount, 'sole_node_count' => $soleNodeCount, 'can_remove' => $canRemove, 'can_remove_subtree' => $canRemoveSubtree, 'real_child_count' => $readableChildCount, 'new_main_node_id' => $newMainNodeID);
         $deleteResult[] = $item;
     }
     $db->commit();
     if (!$infoOnly) {
         return true;
     }
     if ($moveToTrashAllowed and $totalLoneNodeCount == 0) {
         $moveToTrashAllowed = false;
     }
     return array('move_to_trash' => $moveToTrashAllowed, 'total_child_count' => $totalChildCount, 'can_remove_all' => $canRemoveAll, 'delete_list' => $deleteResult, 'has_pending_object' => $hasPendingObject, 'reverse_related_count' => eZContentObjectTreeNode::reverseRelatedCount($deleteIDArray));
 }
コード例 #7
0
 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);
         $db = eZDb::instance();
         $taskResult = $db->arrayQuery('select workflow_process_id, collaboration_id from ezxapprovelocation_items where workflow_process_id = ' . $process->attribute('id'));
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $process->attribute('event_state'), 'approve $process->attribute( \'event_state\')');
         if (count($taskResult) > 0 && $taskResult[0]['collaboration_id'] !== false) {
             $collaborationID = $taskResult[0]['collaboration_id'];
             $status = eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
             if ($process->attribute('event_state') == self::COLLABORATION_NOT_CREATED) {
                 approveLocationCollaborationHandler::activateApproval($collaborationID);
                 $this->setInformation("We are going to create again approval");
                 $process->setAttribute('event_state', self::COLLABORATION_CREATED);
                 $process->store();
                 eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $this, 'approve re-execute');
                 $status = eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
             } else {
                 $this->setInformation("we are checking approval now");
                 eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'check approval');
                 $status = $this->checkApproveCollaboration($process, $event, $collaborationID);
             }
             return $status;
         } else {
             eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $targetNodeIDs, 'NodeIDs to approve');
             $this->createApproveCollaboration($process, $event, $userID, $object->attribute('id'), $versionID, $approveUserIDArray);
             $this->setInformation("We are going to create approval");
             $process->setAttribute('event_state', self::COLLABORATION_CREATED);
             $process->store();
             eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $this, 'approve execute');
             return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
         }
     } else {
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowSections, "we are not going to create approval " . $object->attribute('section_id'));
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $userGroups, "we are not going to create approval");
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $workflowGroups, "we are not going to create approval");
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $user->id(), "we are not going to create approval ");
         eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $targetNodeIDs, 'NodeIDs approved');
         return eZWorkflowType::STATUS_ACCEPTED;
     }
 }