updateObjectState() public static method

Update a contentobject's state
public static updateObjectState ( integer $objectID, integer $selectedStateIDList ) : array
$objectID integer
$selectedStateIDList integer
return array An array with operation status, always true
 function execute($process, $event)
 {
     // get object being published
     $parameters = $process->attribute('parameter_list');
     $objectID = $parameters['object_id'];
     eZDebug::writeDebug('Update object state for object: ' . $objectID);
     $object = eZContentObject::fetch($objectID);
     $state_before = $event->attribute('state_before');
     $state_after = $event->attribute('state_after');
     if ($object == null) {
         eZDebug::writeError('Update object state failed for inexisting object: ' . $objectID, __METHOD__);
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     if ($state_before == null || $state_after == null) {
         eZDebug::writeError('Update object state failed: badly configured states', __METHOD__);
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     $currentStateIDArray = $object->attribute('state_id_array');
     if (in_array($state_before->attribute('id'), $currentStateIDArray)) {
         $canAssignStateIDList = $object->attribute('allowed_assign_state_id_list');
         if (!in_array($state_after->attribute('id'), $canAssignStateIDList)) {
             eZDebug::writeWarning("Not enough rights to assign state to object {$objectID}: " . $state_after->attribute('id'), __METHOD__);
         } else {
             eZDebug::writeDebug('Changing object state from ' . $state_before->attribute('name') . ' to ' . $state_after->attribute('name'), __METHOD__);
             if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                 $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($state_after->attribute('id'))));
             } else {
                 eZContentOperationCollection::updateObjectState($objectID, array($state_after->attribute('id')));
             }
         }
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
示例#2
0
function stateEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
    if ($module->isCurrentAction('StateEdit')) {
        $http = eZHTTPTool::instance();
        if ($http->hasPostVariable('SelectedStateIDList')) {
            $selectedStateIDList = $http->postVariable('SelectedStateIDList');
            $objectID = $object->attribute('id');
            if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => $selectedStateIDList));
            } else {
                eZContentOperationCollection::updateObjectState($objectID, $selectedStateIDList);
            }
        }
    }
}
示例#3
0
    $objectID = isset( $Params['ObjectID'] ) ? $Params['ObjectID'] : false;
    $selectedStateIDList = isset( $Params['SelectedStateID'] ) ? array( $Params['SelectedStateID'] ) : false ;
}

// Change object's state
if ( $objectID and $selectedStateIDList )
{
    if ( eZOperationHandler::operationIsAvailable( 'content_updateobjectstate' ) )
    {
        $operationResult = eZOperationHandler::execute( 'content', 'updateobjectstate',
                                                        array( 'object_id'     => $objectID,
                                                               'state_id_list' => $selectedStateIDList ) );
    }
    else
    {
        eZContentOperationCollection::updateObjectState( $objectID, $selectedStateIDList );
    }

    // Redirect to the provided URI, or to the root if not provided.
    // @TODO : in case this view is called through Ajax, make sure the module ends another way.
    $Module->hasActionParameter( 'RedirectRelativeURI' ) ? $Module->redirectTo( $Module->actionParameter( 'RedirectRelativeURI' ) ) : $Module->redirectTo( '/' );
}
elseif ( $objectID )
{
    // Propose an interface. The end-user probably accessed this view through a simple URL like
    // '/state/assign/<object_id>'
    if ( ( $object = eZContentObject::fetch( $objectID ) ) !== null  )
    {
        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'node', $object->attribute( 'main_node' ) );
        $Result['content'] = $tpl->fetch( 'design:state/assign.tpl' );
示例#4
0
$cli->output('Published : Starting.');
$cli->output('Supported Classes : ' . implode(', ', $unpublishClasses));
foreach ($rootNodeIDList as $nodeID) {
    $rootNode = eZContentObjectTreeNode::fetch($nodeID);
    $articleNodeArray = $rootNode->subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => $unpublishClasses));
    foreach ($articleNodeArray as $articleNode) {
        $article = $articleNode->attribute('object');
        // Si le contenu est à l'état Mise en ligne programmée 'publish_chain/waituntildate'
        if (in_array($ini->variable('UpdateObjectStatesSettings', 'PendingObjectState'), $article->attribute('state_id_array'))) {
            $dataMap = $article->attribute('data_map');
            $dateAttribute = $dataMap['publish_date'];
            if ($dateAttribute === null) {
                continue;
            }
            $date = $dateAttribute->content();
            $articleRetractDate = $date->attribute('timestamp');
            if ($articleRetractDate > 0 && $articleRetractDate < $currrentDate) {
                $ok = "NOT-OK";
                // Switch Object state to Published
                if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                    $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $articleNode->attribute('contentobject_id'), 'state_id_list' => array($targetState)));
                    $ok = "OK";
                } else {
                    eZContentOperationCollection::updateObjectState($articleNode->attribute('contentobject_id'), array($targetState));
                    $ok = "OK";
                }
                $cli->output('Archived : ' . $ok . ' - ' . $articleNode->attribute('name'));
            }
        }
    }
}
示例#5
0
    $state = $ini->variable('UpdateObjectStatesSettings', 'DefaultObjectState');
}
if ($http->hasVariable('SelectIDArray') && $http->hasVariable('UpdateObjectStateButton') && $http->hasVariable('TargetObjectState')) {
    $targetState = null;
    if ($http->variable('TargetObjectState') > 0) {
        $targetState = $http->variable('TargetObjectState');
        $targetState = eZContentObjectState::fetchById($targetState);
    }
    if ($targetState != null) {
        foreach ($http->variable('SelectIDArray') as $objectID) {
            $object = eZContentObject::fetch($objectID);
            if ($object != null) {
                if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
                    $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($targetState->attribute('id'))));
                } else {
                    eZContentOperationCollection::updateObjectState($objectID, array($targetState->attribute('id')));
                }
            }
        }
    }
}
$state = eZContentObjectState::fetchById($state);
if (!is_object($state)) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
} else {
    $stateName = $state->attribute('current_translation');
    $stateName = $stateName->attribute('name');
}
$tpl = templateInit();
$tpl->setVariable('state', $state);
$tpl->setVariable('state_name', $stateName);
 function runOperation(&$node)
 {
     eZContentOperationCollection::updateObjectState($node->attribute('contentobject_id'), array($this->state_id));
     return true;
 }