/** * Calculates a email subject and body for a given notification type * * @param string $type The type of notification to send * @param stdObj $post WP Post object * @param stdObj $comment WP Comment object * @param mixed $single_user (id or object) User in which the notification directly refers to such as the User in which was added as a reviewer. * @return array Array consisting of email title and body */ function annowf_notification_message($type, $post, $comment, $single_user = null, $data = false) { $footer = get_option('blogname') . ' ' . home_url(); $author = get_userdata($post->post_author); $author = anno_user_display($author); if (!empty($single_user->ID)) { $single_user_id = $single_user->ID; } else { $single_user_id = $single_user; } if (!empty($single_user)) { $single_user = anno_user_display($single_user); } // Used in determining a user's recommendation $authors = anno_get_authors($post->ID); $author_names = array_map('anno_user_display', $authors); $edit_link = get_edit_post_link($post->ID, null); $title = $post->post_title; $excerpt = strip_tags($post->post_excerpt ? $post->post_excerpt : $post->post_content); if (strlen($excerpt) > 255) { $excerpt = substr($excerpt, 0, 252) . '...'; } $reviewer_instructions = _x('To review this article, please visit the URL above and navigate to the Reviews section. You may leave comments and questions in this section as well as providing a general review of \'Approve\', \'Reject\' or \'Request Revisions\' from the dropdown.', 'Instructions sent to reviewers via email notification', 'anno'); $notification = array('subject' => '', 'body' => ''); switch ($type) { // Status change to: submitted case 'submitted': $notification = array('subject' => sprintf(_x('New Submission: %s by %s.', 'Email notification subject', 'anno'), $title, $author), 'body' => sprintf(_x('The following article has been submitted for review: -------------------- Title: %s Author(s): %s Excerpt: %s %s %s', 'Email notification body', 'anno'), $title, implode(', ', $author_names), $excerpt, $edit_link, $footer)); break; // Status change to: in_review from submitted // Status change to: in_review from submitted case 'in_review': $notification = array('subject' => sprintf(_x('%s now in review.', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('Review has begun for: %s %s %s', 'Email notification body', 'anno'), $title, $edit_link, $footer)); break; // Status change to: in_review from draft (revisions have occured) // Status change to: in_review from draft (revisions have occured) case 're_review': $notification = array('subject' => sprintf(_x('%s now in review.', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('Revisions have been made for %s and we ask you to please re-review the article. %s %s', 'Email notification body', 'anno'), $title, $edit_link, $footer)); break; // Status change to: approved // Status change to: approved case 'approved': $notification = array('subject' => sprintf(_x('%s review is complete. APPROVED.', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('Thank you for your contribution to %s. We are pleased to inform you that the article, %s, has been approved! You will receive an additional notification when the article is published. Thank you. %s', 'Email notification body', 'anno'), $title, $title, $footer)); break; // Status change to: rejected // Status change to: rejected case 'rejected': $notification = array('subject' => sprintf(_x('%s review is complete.', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('Thank you for contributing to %s. After our review process, we have decided not to accept the article at this time. -------------------- Title: %s %s %s', 'Email notification body', 'anno'), $title, $title, $edit_link, $footer)); break; // Status change to: draft (from in_review) // Status change to: draft (from in_review) case 'revisions': $notification = array('subject' => sprintf(_x('%s review is complete. CHANGES REQUESTED.', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('Thank you for contributing to %s. After reviewing your article, we would like to request some changes. Please open the article here: %s and refer to the comments listed. Once you have updated your submission in accordance with the comments, please resubmit your article. Thank you. %s', 'Email notification body', 'anno'), $title, $edit_link, $footer)); break; // Status change to: published // Status change to: published case 'published': $notification = array('subject' => sprintf(_x('%s has been published.', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('The following article has been published: %s %s %s', 'Email notification body', 'anno'), $title, $edit_link, $footer)); break; case 'reviewer_added': $notification = array('subject' => sprintf(_x('%s has been invited to review %s by %s', 'Email notification subject', 'anno'), $single_user, $title, $author), 'body' => sprintf(_x('%s has been invited to review the following article: -------------------- Title: %s Author(s): %s Excerpt: %s %s %s %s', 'Email notification body', 'anno'), $single_user, $title, implode(', ', $author_names), $excerpt, $edit_link, $reviewer_instructions, $footer)); break; case 'co_author_added': $notification = array('subject' => sprintf(_x('%s has been invited to co-author %s by %s', 'Email notification subject', 'anno'), $single_user, $title, $author), 'body' => sprintf(_x('%s has been invited to co-author %s by %s. %s %s', 'Email notification body', 'anno'), $single_user, $title, $author, $edit_link, $footer)); break; case 'primary_author': $notification = array('subject' => sprintf(_x('%s is now the primary author on %s', 'Email notification subject', 'anno'), $author, $single_user), 'body' => sprintf(_x('%s is now the primary author on %s. %s %s', 'Email notification body', 'anno'), $author, $title, $edit_link, $footer)); break; case 'review_recommendation': global $anno_review_options; //Get user review $review_key = annowf_get_user_review($post->ID, $single_user_id); switch ($review_key) { // Translate here so the entire sentence can be a translated string instead of bits and pieces case 1: $action_text = sprintf(_x('%s has reviewed %s and has accepted the article for publication.', 'Email review action text', 'anno'), $single_user, $title); break; case 2: $action_text = sprintf(_x('%s has reviewed %s and has requested revisions be made to the article prior to publication.', 'Email review action text', 'anno'), $single_user, $title); break; case 3: $action_text = sprintf(_x('%s has reviewed %s and has rejected the article for publication.', 'Email review action text', 'anno'), $single_user, $title); break; default: $action_text = ''; break; } $notification = array('subject' => sprintf(_x('%s has reviewed %s', 'Email notification subject', 'anno'), $single_user, $title), 'body' => sprintf(_x('%s %s %s', 'Email notification body', 'anno'), $action_text, $edit_link, $footer)); break; case 'reviewer_update': // Get review $reviewer = get_user_by('id', $single_user_id); global $anno_review_options; $review_key = annowf_get_user_review($post->ID, $single_user_id); if ($data['status'] == 'revisions') { $status = _x('requested to make revisions', 'Email notification status', 'anno'); } else { global $annowf_states; // approved, published, rejected $status = $annowf_states[$data['status']]; } $notification = array('subject' => sprintf(_x('An article you reviewed, %s, has been %s', 'Email notification subject', 'anno'), $title, $status), 'body' => sprintf(_x('%s by %s has been %s %s -------------------- You left a review of : %s -------------------- Thank you for your contribution. At this time the review process is completed; you will be notified of any further updates to this article. %s', 'Email notification body', 'anno'), $title, implode(', ', $author_names), $status, $edit_link, $anno_review_options[(int) $review_key], $footer)); break; default: break; } if (!empty($comment)) { $comment_author = anno_user_display($comment->user_id); $comment_edit_link = get_edit_post_link($comment->comment_post_ID, null) . '#comment-' . $comment->comment_ID; switch ($type) { case 'general_comment': $notification = array('subject' => sprintf(_x('New internal comment on %s', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('The following comment was submitted on %s by %s. -------------------- %s -------------------- %s %s', 'Email notification body', 'anno'), $title, $comment_author, $comment->comment_content, $comment_edit_link, $footer)); break; case 'review_comment': $notification = array('subject' => sprintf(_x('New reviewer comment on %s', 'Email notification subject', 'anno'), $title), 'body' => sprintf(_x('The following comment was submitted on %s by %s. -------------------- %s -------------------- %s %s', 'Email notification body', 'anno'), $title, $comment_author, $comment->comment_content, $comment_edit_link, $footer)); break; default: break; } } return apply_filters('annowf_notfication', $notification, $type, $post, $comment); }
/** * Markup for user display in meta boxes */ function annowf_user_li_markup($user, $type = null) { $post_id = anno_get_post_id(); $extra = ' '; // expecting reviewer or co_author $type_plural = $type . 's'; if ($type == 'reviewer' && anno_user_can('manage_' . $type_plural, null, $post_id)) { // If the type is a user, show what review they left, if any. Loaded in $extra global $anno_review_options; $round = annowf_get_round($post_id); // Review is stored in DB as an integer corresponding to a given review set in the $anno_review_options global for translation purposes. $review = annowf_get_user_review($post_id, $user->ID); if (isset($anno_review_options[$review])) { $extra = $anno_review_options[$review] . ' '; } } $remove = ' '; // If a user can manage this type of user, show the remove link. if (anno_user_can('manage_' . $type_plural, null, $post_id)) { $remove = ' <a href="#" class="anno-user-remove">' . _x('remove', 'remove user link for admin screens', 'anno') . '</a>'; } ?> <li id="<?php echo esc_attr('user-' . $user->ID); ?> "> <?php echo get_avatar($user->ID, '36'); ?> <div class="anno-user-info"> <a href="<?php echo get_author_posts_url($user->ID); ?> "><?php echo esc_html($user->user_login); ?> </a><?php echo $remove; ?> <br /><?php echo $extra; ?> </div> </li> <?php }
/** * Meta box markup for reviewer review and comments */ function anno_internal_comments_reviewer_comments() { global $anno_review_options, $current_user, $post; $user_review = annowf_get_user_review($post->ID, $current_user->ID); $reviewers = anno_get_reviewers($post->ID); if (anno_user_can('leave_review', $current_user->ID, $post->ID)) { ?> <div class="review-section <?php echo 'status-' . $user_review; ?> "> <label for="anno-review"><?php _ex('Recommendation: ', 'Review label for reviewer meta box review dropdown', 'anno'); ?> </label> <select id="anno-review" name="anno_review"> <?php foreach ($anno_review_options as $opt_key => $opt_val) { ?> <option value="<?php echo esc_attr($opt_key); ?> "<?php selected($user_review, $opt_key, true); ?> ><?php echo esc_html($opt_val); ?> </option> <?php } ?> </select> <span class="review-notice"></span> </div> <?php wp_nonce_field('anno_review', '_ajax_nonce-review', false); } anno_internal_comments_display('review'); }