/** * @dataProvider providerCreateWithValidIdentifier */ public function testCreateWithvalidIdentifier($identifier) { $row = array('identifier' => $identifier); $state = new eZContentObjectState($row); $trans = $state->translationByLocale('eng-GB'); $trans->setAttribute('name', $identifier); $messages = array(); $this->assertTrue($state->isValid($messages), "Valid state identifier '{$identifier}' was refused"); }
function setParameters($parm_array) { // Make sure no unsupported parameters are specified $supported_parameters = array('state_group', 'state'); $parm_keys = array_keys($parm_array); $unsupported_list = array_diff($parm_keys, $supported_parameters); if (isset($unsupported_list[0])) { return "Unsupported parameter '{$unsupported_list[0]}' in operation"; } // Fetch state id's from the identifiers $state_group = eZContentObjectStateGroup::fetchByIdentifier($parm_array['state_group']); if ($state_group === false) { return 'Missing or illegal state group identifier'; } $state_group_id = $state_group->attribute('id'); $state = eZContentObjectState::fetchByIdentifier($parm_array['state'], $state_group_id); if ($state === false) { return 'Missing or illegal state identifier'; } $this->state_id = $state->attribute('id'); return true; }
/** * 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); }
/** * Removes a content object state by its numerical ID * * This method should not be used directly, instead use {@link eZContentObjectStateGroup::removeStatesByID()}. * * @param integer $id the numerical ID of the content object state */ public static function removeByID($id) { $db = eZDB::instance(); $db->begin(); $db->query("DELETE FROM ezcobj_state_link WHERE contentobject_state_id={$id}"); eZPersistentObject::removeObject(eZContentObjectStateLanguage::definition(), array('contentobject_state_id' => $id)); eZPersistentObject::removeObject(eZContentObjectState::definition(), array('id' => $id)); $db->commit(); }
public function stateByIdentifier($stateIdentifier) { return eZContentObjectState::fetchByIdentifier($stateIdentifier, $this->attribute('id')); }
/** * Sets the default states of a content object. * * This function is called upon instantiating a content object with {@link eZContentClass::instantiate()}, so * should normally not be called by any other code. */ function assignDefaultStates() { $db = eZDB::instance(); $db->begin(); $defaultStates = eZContentObjectState::defaults(); $contentObjectID = $this->ID; foreach ( $defaultStates as $state ) { $stateID = $state->attribute( 'id' ); $db->query( "INSERT INTO ezcobj_state_link (contentobject_state_id, contentobject_id) VALUES($stateID, $contentObjectID)" ); } $db->commit(); }
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; }
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));