/**
  * Find a translation with any status for the given language pair and title.
  */
 public function find($sourceTitle, $sourceLanguage, $targetLanguage)
 {
     $result = $this->getResult();
     $translation = ContentTranslation\Translation::find($sourceLanguage, $targetLanguage, $sourceTitle);
     if ($translation !== null) {
         $translator = $translation->translation['lastUpdatedTranslator'];
         $translation->translation['translatorName'] = ContentTranslation\GlobalUser::newFromId($translator)->getName();
         $result->addValue(array('query', 'contenttranslation'), 'translation', $translation->translation);
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
 public function execute()
 {
     $params = $this->extractRequestParams();
     $user = $this->getUser();
     if ($user->isBlocked()) {
         $this->dieUsageMsg('blockedtext');
     }
     $translator = new ContentTranslation\Translator($user);
     $translation = ContentTranslation\Translation::find($params['from'], $params['to'], $params['sourcetitle']);
     $translation = $translation->translation;
     $translationId = $translation['id'];
     if ($translationId === null || $translator->getGlobalUserId() !== intval($translation['startedTranslator'])) {
         // Translation does not exist or belong to another translator
         $this->dieUsageMsg(array('invalidtitle', $params['sourcetitle']));
     }
     ContentTranslation\Translator::removeTranslation($translationId);
     ContentTranslation\Translation::delete($translationId);
     ContentTranslation\Draft::delete($translationId);
     $result = array('result' => 'success');
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }