protected function rejoin()
 {
     $prompt_post = new Prompt_Post($this->post_id);
     if ($prompt_post->is_subscribed($this->user_id)) {
         return;
     }
     $prompt_post->subscribe($this->user_id);
     Prompt_Subscription_Mailing::send_rejoin_notification($this->user_id, $prompt_post);
     return;
 }
Example #2
0
 protected function save($post_id)
 {
     if (!isset($_POST[self::$custom_text_name]) or $post_id != $this->prompt_post->id()) {
         return;
     }
     if (!current_user_can('edit_post', $post_id)) {
         return;
     }
     $this->prompt_post->set_custom_text($_POST[self::$custom_text_name]);
 }
 protected static function set_context($comment)
 {
     if (self::$post_id == $comment->comment_post_ID) {
         return;
     }
     self::$post_id = $comment->comment_post_ID;
     $prompt_post = new Prompt_Post(self::$post_id);
     $flood_comment_id = $prompt_post->get_flood_control_comment_id();
     if ($flood_comment_id) {
         self::$flood_comment = get_comment($flood_comment_id);
     }
 }
 /**
  * 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);
     }
 }
 /**
  * Get Postmatic's text version of the current post content.
  * @return mixed|string
  */
 public function get_the_text_content()
 {
     $this->ensure_setup();
     $prompt_post = new Prompt_Post($this->post);
     $text = $prompt_post->get_custom_text();
     if ($text) {
         return $text;
     }
     if (Prompt_Admin_Delivery_Metabox::excerpt_only($prompt_post->id())) {
         return Prompt_Html_To_Markdown::convert(get_the_excerpt());
     }
     $html = apply_filters('the_content', get_the_content());
     $html = str_replace(']]>', ']]>', $html);
     return Prompt_Html_To_Markdown::convert($html);
 }
 protected function send_notifications($recipient_ids)
 {
     $template_data = array('post' => $this->prompt_post, 'comment_header' => true);
     /**
      * Filter comment email template data.
      *
      * @param array $template_data {
      * @type Prompt_post $post
      * @type bool $comment_header
      * }
      */
     $template_data = apply_filters('prompt/comment_flood_email/template_data', $template_data);
     $html_template = new Prompt_Template('comment-flood-email.php');
     $text_template = new Prompt_Text_Template('comment-flood-email-text.php');
     $footnote_html = sprintf(__('You received this email because you\'re subscribed to %s.', 'Postmatic'), $this->prompt_post->subscription_object_label());
     $batch = new Prompt_Email_Batch(array('subject' => __('We\'re pausing comment notices for you.', 'Postmatic'), 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::SUBSCRIPTION, 'reply_to' => '{{{reply_to}}}', 'footnote_html' => $footnote_html, 'footnote_text' => Prompt_Content_Handling::reduce_html_to_utf8($footnote_html)));
     foreach ($recipient_ids as $recipient_id) {
         $subscriber = get_userdata($recipient_id);
         if (!$subscriber or !$subscriber->user_email) {
             continue;
         }
         $command = new Prompt_Comment_Flood_Command();
         $command->set_post_id($this->prompt_post->id());
         $command->set_user_id($recipient_id);
         $batch->add_individual_message_values(array('to_address' => $subscriber->user_email, 'reply_to' => Prompt_Email_Batch::trackable_address(Prompt_Command_Handling::get_command_metadata($command))));
     }
     /**
      * Filter comment notification email batch.
      *
      * @param Prompt_Email_Batch $batch
      * @param array $template_data see prompt/comment_email/template_data
      */
     $batch = apply_filters('prompt/comment_flood_email_batch', $batch, $template_data);
     Prompt_Factory::make_mailer($batch)->send();
 }
 public static function after_form()
 {
     if (!Prompt_Core::$options->get('enable_comment_delivery') or empty(self::$prompt_post)) {
         return;
     }
     $current_user = Prompt_User_Handling::current_user();
     if (!$current_user or !self::$prompt_post->is_subscribed($current_user->ID)) {
         return;
     }
     echo html('div class="prompt-unsubscribe"', html('div class=".loading-indicator" style="display: none;"', html('img', array('src' => path_join(Prompt_Core::$url_path, 'media/ajax-loader.gif')))), html('p', __('You are subscribed to new comments on this post.', 'Postmatic')), scbForms::input(array('type' => 'submit', 'name' => self::UNSUBSCRIBE_ACTION, 'value' => __('Unsubscribe', 'Postmatic'))));
 }
 /**
  * Any time a post is published schedule notifications.
  *
  * @param string $new_status
  * @param string $old_status
  * @param WP_Post $post
  */
 public static function action_transition_post_status($new_status, $old_status, $post)
 {
     if (!Prompt_Core::$options->get('enable_post_delivery')) {
         return;
     }
     if ('publish' == $old_status or 'publish' != $new_status) {
         return;
     }
     // There is no way to suppress mailing when restoring a trashed post, so we always do it
     if ('trash' == $old_status) {
         return;
     }
     if (defined('WP_IMPORTING') and WP_IMPORTING) {
         return;
     }
     if (self::ignore_published_post($post->ID)) {
         return;
     }
     $prompt_post = new Prompt_Post($post);
     if (!$prompt_post->unsent_recipient_ids() or Prompt_Admin_Delivery_Metabox::suppress_email($post->ID)) {
         return;
     }
     Prompt_Post_Mailing::send_notifications($post);
 }
 /**
  *
  * @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 '';
 }
Example #10
0
 /**
  * Build output for the subscriptions column.
  *
  * @see manage_users_custom_column filter trigger
  *
  * @param string $value
  * @param string $column_name
  * @param int $user_id
  * @return string column content
  */
 public static function subscriptions_column($value, $column_name, $user_id)
 {
     if (self::$subscriptions_column_name !== $column_name) {
         return $value;
     }
     $column_content = '';
     $edit_url = esc_url(add_query_arg('wp_http_referer', urlencode(wp_unslash($_SERVER['REQUEST_URI'])), get_edit_user_link($user_id)));
     $signup_lists = Prompt_Subscribing::get_signup_lists();
     foreach ($signup_lists as $signup_list) {
         $column_content .= self::signup_list_column_content($user_id, $signup_list, $edit_url);
     }
     $author_count = count(Prompt_User::subscribed_object_ids($user_id));
     if ($author_count > 0) {
         $column_content .= html('a', array('href' => $edit_url . '#prompt-author-subscriptions'), sprintf(_n('%d Author', '%d authors', $author_count), $author_count), '<br/>');
     }
     $post_count = count(Prompt_Post::subscribed_object_ids($user_id));
     if ($post_count > 0) {
         $column_content .= html('a', array('href' => $edit_url . '#prompt-post-subscriptions'), sprintf(_n('%d Conversations', '%d Conversations', $post_count), $post_count), '<br/>');
     }
     return $column_content;
 }
Example #11
0
 /**
  * @since 1.0.0
  * @return string
  */
 protected function profile_post_subscriptions()
 {
     $subscribed_post_ids = Prompt_Post::subscribed_object_ids($this->id);
     if (empty($subscribed_post_ids)) {
         return '';
     }
     $post_items = '';
     foreach ($subscribed_post_ids as $post_id) {
         $post_items .= html('li', $this->profile_subscription_checkbox(new Prompt_Post($post_id)), comments_open($post_id) ? '' : __('(closed)', 'Postmatic'));
     }
     return html('div id="prompt-post-subscriptions"', html('h4', __('Discussions you are subscribed to:', 'Postmatic')), html('ul', $post_items));
 }
Example #12
0
 protected function set_post($post)
 {
     $this->post = $post;
     $prompt_post = new Prompt_Post($post);
     $this->recipient_ids = $prompt_post->recipient_ids();
     $this->sent_recipient_ids = $prompt_post->sent_recipient_ids();
 }
Example #13
0
 /**
  * Handle unsubscribe requests from the comment form.
  */
 public static function action_wp_ajax_prompt_comment_unsubscribe()
 {
     if (!wp_verify_nonce($_POST['nonce'], self::AJAX_NONCE)) {
         wp_die(-1);
     }
     $post_id = absint($_POST['post_id']);
     if (!$post_id) {
         wp_die(0);
     }
     $current_user = Prompt_User_Handling::current_user();
     $prompt_post = new Prompt_Post($post_id);
     if (!$current_user or !$prompt_post->is_subscribed($current_user->ID)) {
         wp_die(0);
     }
     $prompt_post->unsubscribe($current_user->ID);
     _e('You have unsubscribed.', 'Postmatic');
     wp_die();
 }
Example #14
0
 /**
  * Get the IDs of all users subscribed to at least one post.
  *
  * @return array
  */
 public static function all_subscriber_ids()
 {
     // Using a "fake" object for PHP 5.2, which doesn't have static method inheritance
     $prompt_post = new Prompt_Post(0);
     return $prompt_post->_all_subscriber_ids();
 }