function attributeDecoder($event, $attr) { switch ($attr) { case 'state_before': $returnValue = $event->attribute('data_int1'); if ($returnValue > 0) { return eZContentObjectState::fetchById($returnValue); } break; case 'state_after': $returnValue = $event->attribute('data_int2'); if ($returnValue > 0) { return eZContentObjectState::fetchById($returnValue); } break; } return null; }
/** * Update a contentobject's state * * @param int $objectID * @param int $selectedStateIDList * * @return array An array with operation status, always true */ public static function updateObjectState($objectID, $selectedStateIDList) { $object = eZContentObject::fetch($objectID); // we don't need to re-assign states the object currently already has assigned $currentStateIDArray = $object->attribute('state_id_array'); $selectedStateIDList = array_diff($selectedStateIDList, $currentStateIDArray); // filter out any states the current user is not allowed to assign $canAssignStateIDList = $object->attribute('allowed_assign_state_id_list'); $selectedStateIDList = array_intersect($selectedStateIDList, $canAssignStateIDList); foreach ($selectedStateIDList as $selectedStateID) { $state = eZContentObjectState::fetchById($selectedStateID); $object->assignState($state); } //call appropriate method from search engine eZSearch::updateObjectState($objectID, $selectedStateIDList); eZContentCacheManager::clearContentCacheIfNeeded($objectID); return array('status' => true); }
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); $tpl->setVariable('view_parameters', $viewParameters); $Result = array(); $Result['content'] = $tpl->fetch('design:updatestate/list.tpl'); $Result['path'] = array(array('text' => "Content in state: " . $stateName, 'url' => false));