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,14 +137,16 @@ 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')) {
switch ($queue_transcript_info['action']) { if ($what_did_they_say->get_allow_transcripts_for_post($queue_transcript_info['post_id'])) {
case 'submit_queued_transcript': switch ($queue_transcript_info['action']) {
$result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info); case 'submit_queued_transcript':
if ($result) { $result = $this->what_did_they_say->add_queued_transcription_to_post($queue_transcript_info['post_id'], $queue_transcript_info);
$updated = __('Transcript added to queue.', 'what-did-they-say'); if ($result) {
} $updated = __('Transcript added to queue.', 'what-did-they-say');
}
}
} }
} }
return $updated; return $updated;
} }
@ -152,12 +154,20 @@ class WhatDidTheySayAdmin {
$updated = false; $updated = false;
if (current_user_can('approve_transcriptions')) { if (current_user_can('approve_transcriptions')) {
$options = get_option('what-did-they-say-options'); $options = get_option('what-did-they-say-options');
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) {
$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'); $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,9 +75,11 @@ 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) {
$transcript = trim($transcript); if (substr($code, 0, 1) != "_") {
if (!empty($transcript)) { $transcript = trim($transcript);
$transcripts[$code] = $transcript; if (!empty($transcript)) {
$transcripts[$code] = $transcript;
}
} }
} }
@ -126,35 +128,39 @@ 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)) { ?>
<div class="queued-transcriptions"> <?php if (count($queued_transcripts_for_user) > 0) { ?>
<h3><?php _e('Your queued transcriptions', 'what-did-they-say') ?></h3> <div class="queued-transcriptions">
<?php foreach ($queued_transcripts_for_user as $transcript) { ?> <h3><?php _e('Your queued transcriptions', 'what-did-they-say') ?></h3>
<h4><?php echo $what_did_they_say->get_language_name($transcript->language) ?></h4> <?php foreach ($queued_transcripts_for_user as $transcript) { ?>
<div> <h4><?php echo $what_did_they_say->get_language_name($transcript->language) ?></h4>
<?php echo $transcript->transcript ?> <div>
</div> <?php echo $transcript->transcript ?>
<?php } ?> </div>
</div>
<?php } ?>
<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[action]" value="submit_queued_transcript" />
<input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
<h3><?php _e('Submit a new transcription:', 'what-did-they-say') ?></h3>
<label>
<?php _e('Language:', 'what-did-they-say') ?>
<select name="wdts[language]">
<?php foreach ($what_did_they_say->get_languages() as $code => $info) { ?>
<option value="<?php echo $code ?>"><?php echo $info['name'] ?></option>
<?php } ?> <?php } ?>
</select> </div>
</label><br /> <?php } ?>
<label> <?php } ?>
<?php _e('Transcription:', 'what-did-they-say') ?><br /> <?php if ($what_did_they_say->get_allow_transcripts_for_post($post->ID)) { ?>
<textarea style="height: 200px; width: 90%" name="wdts[transcript]"></textarea> <form method="post" class="transcript-editor">
</label> <input type="hidden" name="wdts[_nonce]" value="<?php echo wp_create_nonce('what-did-they-say') ?>" />
<input type="submit" value="<?php _e('Submit New Transcription', 'what-did-they-say') ?>" /> <input type="hidden" name="wdts[action]" value="submit_queued_transcript" />
</form> <input type="hidden" name="wdts[post_id]" value="<?php echo $post->ID ?>" />
<h3><?php _e('Submit a new transcription:', 'what-did-they-say') ?></h3>
<label>
<?php _e('Language:', 'what-did-they-say') ?>
<select name="wdts[language]">
<?php foreach ($what_did_they_say->get_languages() as $code => $info) { ?>
<option value="<?php echo $code ?>"><?php echo $info['name'] ?></option>
<?php } ?>
</select>
</label><br />
<label>
<?php _e('Transcription:', 'what-did-they-say') ?><br />
<textarea style="height: 200px; width: 90%" name="wdts[transcript]"></textarea>
</label>
<input type="submit" value="<?php _e('Submit New Transcription', 'what-did-they-say') ?>" />
</form>
<?php } ?>
<?php } <?php }
} }