From 7a643f4fef3915e98ffae01d3fad7579992f16e1 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 18 Aug 2009 22:33:59 -0400 Subject: [PATCH] allow turning off queued transcripts --- classes/WhatDidTheySay.php | 11 ++++++ classes/WhatDidTheySayAdmin.php | 28 +++++++++----- classes/meta-box.inc | 8 +++- what-did-they-say.php | 68 ++++++++++++++++++--------------- 4 files changed, 74 insertions(+), 41 deletions(-) diff --git a/classes/WhatDidTheySay.php b/classes/WhatDidTheySay.php index 9adb933..e86b936 100644 --- a/classes/WhatDidTheySay.php +++ b/classes/WhatDidTheySay.php @@ -250,6 +250,17 @@ class WhatDidTheySay { return $options['languages']; } + + function set_allow_transcripts_for_post($post_id, $allow = true) { + $current_transcripts = get_post_meta($post_id, "provided_transcripts", true); + $current_transcripts['_allow'] = $allow; + update_post_meta($post_id, "provided_transcripts", $current_transcripts); + } + + function get_allow_transcripts_for_post($post_id) { + $current_transcripts = get_post_meta($post_id, "provided_transcripts", true); + return $current_transcripts['_allow']; + } } ?> diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php index f8cc24c..f64756a 100644 --- a/classes/WhatDidTheySayAdmin.php +++ b/classes/WhatDidTheySayAdmin.php @@ -137,14 +137,16 @@ class WhatDidTheySayAdmin { function handle_update_queue_transcript($queue_transcript_info) { $updated = false; if (current_user_can('submit_transcriptions')) { - switch ($queue_transcript_info['action']) { - case 'submit_queued_transcript': - $result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info); - if ($result) { - $updated = __('Transcript added to queue.', 'what-did-they-say'); - } + if ($what_did_they_say->get_allow_transcripts_for_post($queue_transcript_info['post_id'])) { + switch ($queue_transcript_info['action']) { + case 'submit_queued_transcript': + $result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info); + if ($result) { + $updated = __('Transcript added to queue.', 'what-did-they-say'); + } + } } - } + } return $updated; } @@ -152,12 +154,20 @@ class WhatDidTheySayAdmin { $updated = false; if (current_user_can('approve_transcriptions')) { $options = get_option('what-did-they-say-options'); - + switch ($post_transcript_info['action']) { case "manage_post_transcripts": foreach ($post_transcript_info['transcripts'] as $language => $transcript) { - $this->what_did_they_say->save_transcript($post_transcript_info['post_id'], $language, $transcript); + switch ($language) { + case "_allow": + $allow = true; + break; + default: + $this->what_did_they_say->save_transcript($post_transcript_info['post_id'], $language, $transcript); + break; + } } + $this->what_did_they_say->set_allow_transcripts_for_post($post_transcript_info['post_id'], isset($post_transcript_info['allow_on_post'])); $updated = __('Transcripts updated', 'what-did-they-say'); break; } diff --git a/classes/meta-box.inc b/classes/meta-box.inc index c95cf22..347761a 100644 --- a/classes/meta-box.inc +++ b/classes/meta-box.inc @@ -3,7 +3,13 @@

+

+

+

-
- - - + + + + get_allow_transcripts_for_post($post->ID)) { ?> +
+ + + +

+
+ + +
+