From 65fb1d1049df6915fc7283d63276dc214556bd09 Mon Sep 17 00:00:00 2001 From: Tristan Olive Date: Fri, 17 Apr 2015 12:34:46 -0400 Subject: [PATCH] Fixed handling of unauthorized requests to update official BOINC translations (DBOINCP-141) --- .../boinctranslate/boinctranslate.module | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module b/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module index 3ec3aafbdb..efbbb62e32 100644 --- a/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module +++ b/drupal/sites/default/boinc/modules/boinctranslate/boinctranslate.module @@ -389,21 +389,10 @@ function boinctranslate_update_official_boinc_translations() { break; } } - if (!$source_exists) { - // Error - $result = "ERROR: The {$drupal_resource} resource does not exist" - . " in the {$project_name} project at Transifex"; - } } - if ($result AND substr($result, 0, 6) != 'ERROR:') { + if ($source_exists) { $enabled_languages = locale_language_list(); - if ($source_exists) { - drupal_set_message('Updated source translation strings at Transifex'); - } - else { - drupal_set_message('Established new translation resource at Transifex'); - } // Try to export translations for all enabled languages foreach ($enabled_languages as $langcode => $language_name) { if ($langcode == 'en') { @@ -416,12 +405,21 @@ function boinctranslate_update_official_boinc_translations() { 'content' => $po_file, ); $result = boinctranslate_transifex_request($path, $post, TRUE, TRUE); - if (!is_array($result) - AND substr($result, 0, 6) == 'ERROR:') { - drupal_set_message( - "Unable to update {$language_name} official BOINC translations: {$result}", - 'warning' - ); + + if (!is_array($result)) { + if (substr($result, 0, 6) == 'ERROR:') { + drupal_set_message( + "Unable to update {$language_name} official BOINC translations: {$result}", + 'warning' + ); + } + elseif ($result == '401 UNAUTHORIZED') { + drupal_set_message( + 'Not authorized to update official BOINC translations', + 'warning' + ); + break; + } } else { drupal_set_message("Updated {$language_name} official BOINC translations"); @@ -435,7 +433,7 @@ function boinctranslate_update_official_boinc_translations() { } else { drupal_set_message( - "Unable to update the official BOINC translation source: {$result}", + "The {$drupal_resource} resource does not exist in the {$project_name} project at Transifex", 'warning' ); }