/** * Trigger flood notification if necessary and return IDs that should * receive a regular comment notification. * * @return array */ function control_recipient_ids() { $site_comments = new Prompt_Site_Comments(); $site_recipient_ids = $site_comments->subscriber_ids(); $comment_author_id = $this->comment->user_id; if (!$comment_author_id) { $author = get_user_by('email', $this->comment->comment_author_email); $comment_author_id = $author ? $author->ID : null; } $post_author_recipient_ids = array(); if (Prompt_Core::$options->get('auto_subscribe_authors')) { $post_author_recipient_ids = array($this->prompt_post->get_wp_post()->post_author); } $post_recipient_ids = array_diff($this->prompt_post->subscriber_ids(), array($comment_author_id)); if ($this->is_flood()) { $this->prompt_post->set_flood_control_comment_id($this->comment->comment_ID); $this->unsubscribe($post_recipient_ids); $this->send_notifications($post_recipient_ids); return $this->all_ids_except($comment_author_id, $site_recipient_ids, $post_author_recipient_ids); } return $this->all_ids_except($comment_author_id, $site_recipient_ids, $post_author_recipient_ids, $post_recipient_ids); }
/** * Unsubscribe from the post author or site. * @param boolean $notify * @return array */ protected function unsubscribe($notify = true) { $prompt_post = new Prompt_Post($this->post_id); $prompt_author = new Prompt_User($prompt_post->get_wp_post()->post_author); if ($prompt_author->is_subscribed($this->user_id)) { $this->author_unsubscribe($prompt_author, $notify); return; } // The user was not subscribed to the post author, so unsubscribe them from the site. $prompt_site = new Prompt_Site(); $prompt_site->unsubscribe($this->user_id); if ($notify) { Prompt_Subscription_Mailing::send_unsubscription_notification($this->user_id, $prompt_site); } }
/** * * @since 2.0.0 * * @param WP_User $subscriber * @param string $type Default HTML, alternately Prompt_Enum_Content_Types::TEXT. * @return string */ protected function subscriber_comment_intro(WP_User $subscriber, $type = Prompt_Enum_Content_Types::HTML) { $name = $this->commenter_name; $parent_author_name = $this->parent_author_name; $title = $this->prompt_post->get_wp_post()->post_title; if (Prompt_Enum_Content_Types::HTML === $type) { $name = html('span class="capitalize"', $name); $parent_author_name = html('span class="capitalize"', $parent_author_name); $title = $this->subscribed_post_title_link; } if ($this->parent_author and $this->parent_author->ID == $subscriber->ID) { return sprintf(__('%s replied to your comment on %s:', 'Postmatic'), $name, $title); } if ($this->parent_author) { return sprintf(__('%s left a reply to a comment by %s on %s:', 'Postmatic'), $name, $parent_author_name, $this->subscribed_post_title_link); } return ''; }
/** * Subscribe the user to comments on the post. * @since 1.0.0 * @param bool $notify Whether to send a subscription notification to the user */ protected function subscribe($notify = false) { $prompt_post = new Prompt_Post($this->post_id); if ($prompt_post->is_subscribed($this->user_id)) { return; } if (Prompt_Core::$options->get('auto_subscribe_authors') and $this->user_id == $prompt_post->get_wp_post()->post_author) { return; } $prompt_post->subscribe($this->user_id); if ($notify) { Prompt_Subscription_Mailing::send_subscription_notification($this->user_id, $prompt_post); } }
/** * Get current delivery status information for a post. * @param int $post_id * @return array { * @type string $description * @type int $recipient_count * @type int $sent_count * } */ public static function status($post_id) { $prompt_post = new Prompt_Post($post_id); $recipient_count = count($prompt_post->recipient_ids()); $sent_count = count($prompt_post->sent_recipient_ids()); if ($sent_count == 0 and 'publish' != $prompt_post->get_wp_post()->post_status) { $description = self::recipient_count_description($recipient_count); } else { $description = self::sent_count_description($sent_count); } return compact('description', 'sent_count', 'recipient_count'); }