summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2010-02-27 18:54:36 -0800
committerAndy Staudacher <andy.st@gmail.com>2010-02-27 18:54:36 -0800
commit48193371e4a1fc315a5f24986dbdad002270e061 (patch)
tree0449d4644ffcf417a52f485f9ff605558c48337d
parenta18ddd2fe9a920115df580a1ded5b2e33bb12a02 (diff)
Incremental fix for ticket #1042: Delete translation from outgoing_translations when the user submits a form with an empty translation.
-rw-r--r--modules/gallery/controllers/l10n_client.php36
1 files changed, 21 insertions, 15 deletions
diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php
index be0aaa11..e3b47681 100644
--- a/modules/gallery/controllers/l10n_client.php
+++ b/modules/gallery/controllers/l10n_client.php
@@ -60,25 +60,31 @@ class L10n_Client_Controller extends Controller {
->where("locale", "=", $locale)
->find();
- if (!$entry->loaded()) {
- $entry->key = $key;
- $entry->locale = $locale;
- $entry->message = $root_message->message;
- $entry->base_revision = null;
- }
+ if (empty($translation)) {
+ if ($entry->loaded()) {
+ $entry->delete();
+ }
+ } else {
+ if (!$entry->loaded()) {
+ $entry->key = $key;
+ $entry->locale = $locale;
+ $entry->message = $root_message->message;
+ $entry->base_revision = null;
+ }
- $entry->translation = serialize($translation);
+ $entry->translation = serialize($translation);
- $entry_from_incoming = ORM::factory("incoming_translation")
- ->where("key", "=", $key)
- ->where("locale", "=", $locale)
- ->find();
+ $entry_from_incoming = ORM::factory("incoming_translation")
+ ->where("key", "=", $key)
+ ->where("locale", "=", $locale)
+ ->find();
- if (!$entry_from_incoming->loaded()) {
- $entry->base_revision = $entry_from_incoming->revision;
- }
+ if (!$entry_from_incoming->loaded()) {
+ $entry->base_revision = $entry_from_incoming->revision;
+ }
- $entry->save();
+ $entry->save();
+ }
Gallery_I18n::clear_cache($locale);