示例#1
0
/**
 * Remove actions TD content if user cannot edit this post in the Workflow context
 *
 * @todo Preferably a non-js way to do this. Currently js is the only option
 */
function annowf_revision_remove_restore_link()
{
    // This is actually the original post, not the revision
    global $post;
    if ($post->post_type == 'article' && !anno_user_can('edit_post')) {
        ?>
<script type="text/javascript">
jQuery(document).ready(function($) {
	$('td.action-links').html('');
});
</script>
<?php 
    }
}
示例#2
0
文件: clone.php 项目: dregula/Annotum
/**
 * Prevent any insert cloned posts from changing the title,
 * Unless a user is an admin
 *
 * @param array $data
 * @param array $postarr
 */
function annowf_clone_prevent_title_save($data, $postarr)
{
    if (!anno_user_can('administrator') && isset($postarr['ID']) && annowf_is_clone($postarr['ID']) && $data['post_type'] == 'article') {
        // Reset data to the old
        $old_post = get_post($postarr['ID']);
        if ($old_post) {
            $data['post_title'] = $old_post->post_title;
        }
    }
    return $data;
}
示例#3
0
/**
 * Published state markup for major actions.
 */
function annowf_major_action_published_markup()
{
    if (anno_user_can('edit_post')) {
        annowf_major_action_revert('left');
        annowf_major_action_clone_markup('right');
    } else {
        annowf_major_action_clone_markup();
    }
}
示例#4
0
/**
 * Determines whether or not a user can edit, based on the workflow being active or not
 */
function anno_current_user_can_edit()
{
    // User must have the WP permissions
    if (current_user_can('edit_article')) {
        $post_id = null;
        if (isset($_POST['attachment_id'])) {
            $post = get_post($_POST['attachment_id']);
            $post_id = $post->post_parent;
        }
        // Do an additional check if the workflow is enabled
        if (anno_workflow_enabled()) {
            if (anno_user_can('edit_post', null, $post_id)) {
                return true;
            } else {
                return false;
            }
        }
        return true;
    }
    return false;
}
/**
 * Enforce general comment capabilities
 */
function anno_internal_comments_capabilities($allcaps, $caps, $args)
{
    // $args are an array => 'capability_name' , 'user_id', 'additional args (obj id)'
    if ($args[0] == 'edit_comment') {
        $comment = get_comment($args[2]);
        if (!empty($comment) && ($comment->comment_type == 'article_general' || $comment->comment_type == 'article_review')) {
            if (anno_workflow_enabled()) {
                if (!anno_user_can('edit_comment', $args[1], '', $args[2])) {
                    $allcaps = array();
                }
            } else {
                $allcaps = array();
            }
        }
    }
    return $allcaps;
}