working on user permissions and usability
This commit is contained in:
parent
ec9d031d2e
commit
387d1136cb
@ -134,7 +134,10 @@ class WhatDidTheySayAdmin {
|
||||
*/
|
||||
function template_redirect() {
|
||||
wp_enqueue_script('toggle-transcript', plugin_dir_url(dirname(__FILE__)) . 'js/toggle-transcript.js', array('prototype'), false, true);
|
||||
if (current_user_can('submit_transcriptions')) { wp_enqueue_script('scriptaculous-effects'); }
|
||||
if (current_user_can('submit_transcriptions')) {
|
||||
wp_enqueue_script('scriptaculous-effects');
|
||||
wp_enqueue_script('edit-transcript', plugin_dir_url(dirname(__FILE__)) . 'js/edit-transcripts.js', array('scriptaculous-effects'), false, true);
|
||||
}
|
||||
|
||||
foreach (get_class_methods($this) as $method) {
|
||||
if (strpos($method, "shortcode_") === 0) {
|
||||
@ -283,13 +286,13 @@ class WhatDidTheySayAdmin {
|
||||
function user_has_cap($capabilities, $requested_capabilities, $capability_name) {
|
||||
$options = get_option('what-did-they-say-options');
|
||||
if (is_array($options)) {
|
||||
$role_cascade = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
|
||||
$role_cascade = array('subscriber', 'contributor', 'author', 'editor', 'administrator');
|
||||
$allowed_roles = array();
|
||||
$capture_roles = false;
|
||||
|
||||
for ($i = 0; $i < count($role_cascade); ++$i) {
|
||||
if (in_array($role_cascade, $capabilities)) { $capture_roles = true; }
|
||||
if ($capture_roles) { $allowed_roles[] = $role_cascade[$i]; }
|
||||
if (isset($capabilities[$role_cascade[$i]])) {
|
||||
$allowed_roles = array_slice($role_cascade, 0, $i + 1); break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($requested_capabilities as $requested_capability) {
|
||||
@ -616,7 +619,7 @@ class WhatDidTheySayAdmin {
|
||||
add_options_page(
|
||||
__('What Did They Say?!?', 'what-did-they-say'),
|
||||
__('What Did They Say?!?', 'what-did-they-say'),
|
||||
'manage_options',
|
||||
'submit_transcriptions',
|
||||
'manage-wdts',
|
||||
array(&$this, 'manage_admin')
|
||||
);
|
||||
@ -645,6 +648,7 @@ class WhatDidTheySayAdmin {
|
||||
|
||||
wp_enqueue_style('wdts-admin', plugin_dir_url(dirname(__FILE__)) . 'css/wdts-admin.css');
|
||||
wp_enqueue_script('scriptaculous-effects');
|
||||
wp_enqueue_script('edit-transcript', plugin_dir_url(dirname(__FILE__)) . 'js/edit-transcripts.js', array('scriptaculous-effects'), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -683,6 +687,7 @@ class WhatDidTheySayAdmin {
|
||||
|
||||
$nonce = wp_create_nonce('what-did-they-say');
|
||||
include('partials/meta-box.inc');
|
||||
include('partials/_editor-script.inc');
|
||||
}
|
||||
}
|
||||
|
||||
|
16
classes/partials/_editor-script.inc
Normal file
16
classes/partials/_editor-script.inc
Normal file
@ -0,0 +1,16 @@
|
||||
<script type="text/javascript">
|
||||
var ajax_url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
|
||||
var nonce = '<?php echo $nonce ?>';
|
||||
|
||||
var messages = {
|
||||
'overwrite': '<?php _e('This will overwrite the current transcript. Are you sure?', 'what-did-they-say') ?>',
|
||||
'delete': '<?php _e('This will delete the queued transcript. Are you sure?', 'what-did-they-say') ?>',
|
||||
'approved': '<?php _e('Transcript approved and posted. You can further edit it below.', 'what-did-they-say') ?>',
|
||||
'deleted': '<?php _e('Transcript deleted.', 'what-did-they-say') ?>',
|
||||
'scene_heading': '<?php _e('Enter the scene heading:', 'what-did-they-say') ?>',
|
||||
'scene_action': '<?php _e('Enter the scene action:', 'what-did-they-say') ?>',
|
||||
'dialog_name': '<?php _e('Enter the character name:', 'what-did-they-say') ?>',
|
||||
'dialog_direction': '<?php _e('Enter the direction in which the character is speaking:', 'what-did-they-say') ?>',
|
||||
'dialog_speech': '<?php _e('Enter what the character is speaking:', 'what-did-they-say') ?>',
|
||||
};
|
||||
</script>
|
@ -15,14 +15,16 @@
|
||||
<p>
|
||||
<?php if (current_user_can('manage_options')) { ?>
|
||||
<?php _e('<strong>What Did They Say?!?</strong> can attempt to embed excerpts into your posts automatically:', 'what-did-they-say') ?>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
name="wdts[automatic_embedding]"
|
||||
value="yes"
|
||||
<?php echo $options['automatic_embedding'] ? 'checked="checked"' : '' ?> />
|
||||
<?php _e('Enable automatic transcript embedding', 'what-did-they-say') ?>
|
||||
</label>
|
||||
<input type="submit" class="button" value="<?php _e('Submit', 'what-did-they-say') ?>" />
|
||||
<fieldset>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
name="wdts[automatic_embedding]"
|
||||
value="yes"
|
||||
<?php echo $options['automatic_embedding'] ? 'checked="checked"' : '' ?> />
|
||||
<?php _e('Enable automatic transcript embedding', 'what-did-they-say') ?>
|
||||
</label>
|
||||
<input type="submit" class="button" value="<?php _e('Submit', 'what-did-they-say') ?>" />
|
||||
</fieldset>
|
||||
<?php } else { ?>
|
||||
<?php if ($options['automatic_embedding']) { ?>
|
||||
<?php _e('<strong>What Did They Say?!?</strong> is set to attempt to embed excerpts into your posts automatically.', 'what-did-they-say') ?>
|
||||
@ -49,14 +51,16 @@
|
||||
<?php _e('When someone searches your site, <strong>What Did They Say?!?</strong> can search your transcripts, too.', 'what-did-they-say') ?>
|
||||
|
||||
<?php if (current_user_can('manage_options')) { ?>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
name="wdts[search_integration]"
|
||||
value="yes"
|
||||
<?php echo $options['search_integration'] ? 'checked="checked"' : '' ?> />
|
||||
<?php _e('Enable transcript search integration', 'what-did-they-say') ?>
|
||||
</label>
|
||||
<input type="submit" class="button" value="<?php _e('Submit', 'what-did-they-say') ?>" />
|
||||
<fieldset>
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
name="wdts[search_integration]"
|
||||
value="yes"
|
||||
<?php echo $options['search_integration'] ? 'checked="checked"' : '' ?> />
|
||||
<?php _e('Enable transcript search integration', 'what-did-they-say') ?>
|
||||
</label>
|
||||
<input type="submit" class="button" value="<?php _e('Submit', 'what-did-they-say') ?>" />
|
||||
</fieldset>
|
||||
<?php } else { ?>
|
||||
<?php if ($options['search_integration']) { ?>
|
||||
<?php _e('<strong>What Did They Say?!?</strong> is set to search transcripts when your site is searched.', 'what-did-they-say') ?>
|
||||
|
@ -56,23 +56,4 @@
|
||||
<textarea class="edit-transcript" id="wdts-transcripts-<?php echo $code ?>" name="wdts[transcripts][<?php echo $code ?>]" style="display: none; width: 99%; height: 200px"><?php echo $approved_transcript_text ?></textarea>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</p>
|
||||
|
||||
<script type="text/javascript">
|
||||
var language_selector = $('wdts-language');
|
||||
var ajax_url = '<?php echo $_SERVER['REQUEST_URI'] ?>';
|
||||
var nonce = '<?php echo $nonce ?>';
|
||||
|
||||
var messages = {
|
||||
'overwrite': '<?php _e('This will overwrite the current transcript. Are you sure?', 'what-did-they-say') ?>',
|
||||
'delete': '<?php _e('This will delete the queued transcript. Are you sure?', 'what-did-they-say') ?>',
|
||||
'approved': '<?php _e('Transcript approved and posted. You can further edit it below.', 'what-did-they-say') ?>',
|
||||
'deleted': '<?php _e('Transcript deleted.', 'what-did-they-say') ?>',
|
||||
'scene_heading': '<?php _e('Enter the scene heading:', 'what-did-they-say') ?>',
|
||||
'scene_action': '<?php _e('Enter the scene action:', 'what-did-they-say') ?>',
|
||||
'dialog_name': '<?php _e('Enter the character name:', 'what-did-they-say') ?>',
|
||||
'dialog_direction': '<?php _e('Enter the direction in which the character is speaking:', 'what-did-they-say') ?>',
|
||||
'dialog_speech': '<?php _e('Enter what the character is speaking:', 'what-did-they-say') ?>',
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="<?php echo plugin_dir_url(dirname(__FILE__)) . '../js/edit-transcripts.js' ?>"></script>
|
||||
</p>
|
@ -61,3 +61,7 @@
|
||||
-moz-border-radius: 2px;
|
||||
-webkit-border-radius: 2px;
|
||||
}
|
||||
|
||||
#wdts-page-introduction label {
|
||||
display: inline
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
var language_selector = $('wdts-language');
|
||||
|
||||
function switch_transcript() {
|
||||
$$('.edit-transcript').each(function(t) {
|
||||
(t.id == "wdts-transcripts-" + $F('wdts-language')) ? t.show() : t.hide();
|
||||
@ -28,10 +30,16 @@ var WDTSInjector = Class.create({
|
||||
});
|
||||
|
||||
Event.observe(window, 'load', function() {
|
||||
[
|
||||
[ '#wdts-shorttags button', $("wdts-transcripts-" + $F('wdts-language')) ],
|
||||
[ '#wdts-submit-shorttags button', $('wdts-transcript') ]
|
||||
].each(function(info) {
|
||||
var buttons_to_watch = [];
|
||||
if ($('wdts-transcript')) {
|
||||
buttons_to_watch.push([ '#wdts-submit-shorttags button', $('wdts-transcript') ]);
|
||||
}
|
||||
|
||||
if ($$('select[name=wdts-language]').pop()) {
|
||||
buttons_to_watch.push([ '#wdts-shorttags button', $("wdts-transcripts-" + $F('wdts-language')) ]);
|
||||
}
|
||||
|
||||
buttons_to_watch.each(function(info) {
|
||||
$$(info[0]).each(function(b) {
|
||||
b.observe('click', function(e) {
|
||||
Event.stop(e);
|
||||
@ -179,6 +187,8 @@ $$('.delete-transcript').each(function(b) {
|
||||
});
|
||||
});
|
||||
|
||||
switch_transcript();
|
||||
Event.observe(window, 'load', switch_transcript);
|
||||
Event.observe(language_selector, 'change', switch_transcript);
|
||||
if (language_selector) {
|
||||
switch_transcript();
|
||||
Event.observe(window, 'load', switch_transcript);
|
||||
Event.observe(language_selector, 'change', switch_transcript);
|
||||
}
|
@ -211,6 +211,8 @@ function the_media_transcript_queue_editor() {
|
||||
|
||||
$nonce = wp_create_nonce('what-did-they-say');
|
||||
|
||||
include(dirname(__FILE__) . '/classes/partials/_editor-script.inc');
|
||||
|
||||
?>
|
||||
<?php if (current_user_can('approve_transcriptions')) { ?>
|
||||
<h3><?php _e('Manage Transcripts:', 'what-did-they-say') ?></h3>
|
||||
|
Loading…
Reference in New Issue
Block a user