function runOperation(&$node) { $object = $node->attribute('object'); $object_id = $object->attribute('id'); $objectLocales = $object->attribute('available_languages'); // If the alternative locale does not exist for object, create it if (!in_array($this->altLocale, $objectLocales)) { // The only translation is in locate to be removed - create a version in another locale first. echo "Copying the single translation in " . $this->remLocale . " to " . $this->altLocale . " so former could be removed.\n"; $newVersion = $object->createNewVersionIn($this->altLocale, $this->remLocale, false, true, eZContentObjectVersion::STATUS_DRAFT); $publishResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object_id, 'version' => $newVersion->attribute('version'))); eZContentObject::clearCache(); $object = eZContentObject::fetch($object_id); } // Change objects main language to alternative language, if its current main language is to be removed. if ($object->attribute('initial_language_code') == $this->remLocale) { eZContentObject::clearCache(); $object = eZContentObject::fetch($object_id); echo "Switching initial language to {$this->altLocale} so that " . $this->remLocale . " could be removed.\n"; $updateResult = eZContentOperationCollection::updateInitialLanguage($object_id, $this->altLangID); $object->store(); eZContentObject::clearCache(); $object = eZContentObject::fetch($object_id); } // Now it should be safe to remove translation. return $object->removeTranslation($this->remLangID); }
} $objectID = $module->actionParameter('ObjectID'); $object = eZContentObject::fetch($objectID); if (!$object) { return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } if ($module->isCurrentAction('UpdateInitialLanguage')) { if ($module->hasActionParameter('InitialLanguageID')) { $newInitialLanguageID = $module->actionParameter('InitialLanguageID'); if (!$object->canEdit()) { return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array()); } if (eZOperationHandler::operationIsAvailable('content_updateinitiallanguage')) { $operationResult = eZOperationHandler::execute('content', 'updateinitiallanguage', array('object_id' => $objectID, 'new_initial_language_id' => $newInitialLanguageID, 'node_id' => $nodeID)); } else { eZContentOperationCollection::updateInitialLanguage($objectID, $newInitialLanguageID); } } return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode)); } else { if ($module->isCurrentAction('UpdateAlwaysAvailable')) { if (!$object->canEdit()) { return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel', array()); } $newAlwaysAvailable = $module->hasActionParameter('AlwaysAvailable'); if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) { $operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $objectID, 'new_always_available' => $newAlwaysAvailable, 'node_id' => $nodeID)); } else { eZContentOperationCollection::updateAlwaysAvailable($objectID, $newAlwaysAvailable); } return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));