allow turning off queued transcripts

This commit is contained in:
John Bintz 2009-08-18 22:33:59 -04:00
parent eec73ad64d
commit 7a643f4fef
4 changed files with 74 additions and 41 deletions

View File

@ -250,6 +250,17 @@ class WhatDidTheySay {
return $options['languages']; 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'];
}
} }
?> ?>

View File

@ -137,6 +137,7 @@ class WhatDidTheySayAdmin {
function handle_update_queue_transcript($queue_transcript_info) { function handle_update_queue_transcript($queue_transcript_info) {
$updated = false; $updated = false;
if (current_user_can('submit_transcriptions')) { if (current_user_can('submit_transcriptions')) {
if ($what_did_they_say->get_allow_transcripts_for_post($queue_transcript_info['post_id'])) {
switch ($queue_transcript_info['action']) { switch ($queue_transcript_info['action']) {
case 'submit_queued_transcript': case 'submit_queued_transcript':
$result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info); $result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info);
@ -145,6 +146,7 @@ class WhatDidTheySayAdmin {
} }
} }
} }
}
return $updated; return $updated;
} }
@ -156,8 +158,16 @@ class WhatDidTheySayAdmin {
switch ($post_transcript_info['action']) { switch ($post_transcript_info['action']) {
case "manage_post_transcripts": case "manage_post_transcripts":
foreach ($post_transcript_info['transcripts'] as $language => $transcript) { foreach ($post_transcript_info['transcripts'] as $language => $transcript) {
switch ($language) {
case "_allow":
$allow = true;
break;
default:
$this->what_did_they_say->save_transcript($post_transcript_info['post_id'], $language, $transcript); $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'); $updated = __('Transcripts updated', 'what-did-they-say');
break; break;
} }

View File

@ -3,7 +3,13 @@
<input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" /> <input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
<p> <p>
<label> <label>
Edit transcript for: <input type="checkbox" name="wdts[allow_on_post]" value="yes" <?php echo ($transcripts['_allow']) ? 'checked="checked"' : '' ?> />
<?php _e('Allow new transcripts to be submitted for this post', 'what-did-they-say') ?>
</label>
</p>
<p>
<label>
<?php _e('Edit transcript for:', 'what-did-they-say') ?>
<select name="wdts[language]" id="wdts-language"> <select name="wdts[language]" id="wdts-language">
<?php foreach ($options['languages'] as $code => $info) { ?> <?php foreach ($options['languages'] as $code => $info) { ?>
<option value="<?php echo $code ?>" <?php echo $info['default'] ? 'selected="selected"' : '' ?>><?php echo $info['name'] ?></option> <option value="<?php echo $code ?>" <?php echo $info['default'] ? 'selected="selected"' : '' ?>><?php echo $info['name'] ?></option>

View File

@ -75,11 +75,13 @@ function transcripts_display($dropdown_message = null, $single_language_message
$post_transcripts = $what_did_they_say->get_transcripts($post->ID); $post_transcripts = $what_did_they_say->get_transcripts($post->ID);
if (!empty($post_transcripts)) { if (!empty($post_transcripts)) {
foreach ($post_transcripts as $code => $transcript) { foreach ($post_transcripts as $code => $transcript) {
if (substr($code, 0, 1) != "_") {
$transcript = trim($transcript); $transcript = trim($transcript);
if (!empty($transcript)) { if (!empty($transcript)) {
$transcripts[$code] = $transcript; $transcripts[$code] = $transcript;
} }
} }
}
if (count($transcripts) > 0) { if (count($transcripts) > 0) {
$default_language = $what_did_they_say->get_default_language(); $default_language = $what_did_they_say->get_default_language();
@ -126,6 +128,7 @@ function the_media_transcript_queue_editor() {
if (current_user_can('submit_transcriptions')) { ?> if (current_user_can('submit_transcriptions')) { ?>
<?php if (is_array($queued_transcripts_for_user)) { ?> <?php if (is_array($queued_transcripts_for_user)) { ?>
<?php if (count($queued_transcripts_for_user) > 0) { ?>
<div class="queued-transcriptions"> <div class="queued-transcriptions">
<h3><?php _e('Your queued transcriptions', 'what-did-they-say') ?></h3> <h3><?php _e('Your queued transcriptions', 'what-did-they-say') ?></h3>
<?php foreach ($queued_transcripts_for_user as $transcript) { ?> <?php foreach ($queued_transcripts_for_user as $transcript) { ?>
@ -136,6 +139,8 @@ function the_media_transcript_queue_editor() {
<?php } ?> <?php } ?>
</div> </div>
<?php } ?> <?php } ?>
<?php } ?>
<?php if ($what_did_they_say->get_allow_transcripts_for_post($post->ID)) { ?>
<form method="post" class="transcript-editor"> <form method="post" class="transcript-editor">
<input type="hidden" name="wdts[_nonce]" value="<?php echo wp_create_nonce('what-did-they-say') ?>" /> <input type="hidden" name="wdts[_nonce]" value="<?php echo wp_create_nonce('what-did-they-say') ?>" />
<input type="hidden" name="wdts[action]" value="submit_queued_transcript" /> <input type="hidden" name="wdts[action]" value="submit_queued_transcript" />
@ -155,6 +160,7 @@ function the_media_transcript_queue_editor() {
</label> </label>
<input type="submit" value="<?php _e('Submit New Transcription', 'what-did-they-say') ?>" /> <input type="submit" value="<?php _e('Submit New Transcription', 'what-did-they-say') ?>" />
</form> </form>
<?php } ?>
<?php } <?php }
} }