/** * 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); }