コード例 #1
0
 /**
  * Unsubscribe the user from an author.
  *
  * @since 2.0.0
  *
  * @param Prompt_User $author
  * @param bool|true $notify
  */
 protected function author_unsubscribe(Prompt_User $author, $notify = true)
 {
     $author->unsubscribe($this->user_id);
     if ($notify) {
         Prompt_Subscription_Mailing::send_unsubscription_notification($this->user_id, $author);
     }
 }
コード例 #2
0
 protected function field_values($user)
 {
     $prompt_user = new Prompt_User($user);
     $origin = $prompt_user->get_subscriber_origin();
     if (!$origin) {
         $origin = new Prompt_Subscriber_Origin(array('timestamp' => strtotime($user->user_registered)));
     }
     $fields = array($user->user_email, $user->first_name, $user->last_name, $origin->get_date('c'), $origin->get_source_label(), $origin->get_source_url());
     return $this->quote($fields);
 }
コード例 #3
0
 protected function execute($args)
 {
     $link = new Prompt_Unsubscribe_Link($args);
     if (!$link->is_valid()) {
         return __('We tried to unsubscribe you, but there was some required information missing from this request.', 'Postmatic');
     }
     $this->subscriber = $link->user();
     $prompt_user = new Prompt_User($this->subscriber);
     $prompt_user->delete_all_subscriptions();
     return sprintf(__('Got it. %s has been unsubscribed from new posts as well as any conversations.', 'Postmatic'), $this->subscriber->user_email);
 }
コード例 #4
0
 public function execute()
 {
     if (!$this->validate()) {
         return;
     }
     $comment_id = $this->keys[0];
     $comment = get_comment($comment_id);
     if (!$comment) {
         Prompt_Logging::add_error('register_subscribe_comment_invalid', __('Couldn\'t find the original registration information for a new user.', 'Postmatic'), array('keys' => $this->keys, 'message' => $this->message));
         return;
     }
     $lists = $this->resolve_lists($comment);
     $user_data = get_comment_meta($comment_id, self::$user_data_meta_key, true);
     $email = $comment->comment_author_email;
     $subscriber = get_user_by('email', $email);
     $opted_in_list = $this->opted_in_list($lists);
     if (!$subscriber and !$opted_in_list) {
         if (self::stop_resending($comment)) {
             return;
         }
         Prompt_Subscription_Mailing::send_agreement($lists, $email, $user_data, $resend_command = $this);
         return;
     }
     if (!$opted_in_list) {
         // The user has already been created, probably via a different reply. Just ignore this nonsense reply.
         return;
     }
     $subscriber_id = $subscriber ? $subscriber->ID : Prompt_User_Handling::create_from_email($email);
     if (is_wp_error($subscriber_id)) {
         Prompt_Logging::add_error('register_subscribe_user_creation_failure', __('Failed to create a new user from an agreement reply email.', 'Postmatic'), array('keys' => $this->keys, 'user_data' => $user_data, 'message' => $this->message, 'error' => $subscriber_id));
         return;
     }
     if (!$subscriber and $user_data) {
         $user_data['ID'] = $subscriber_id;
         wp_update_user($user_data);
         $origin = new Prompt_Subscriber_Origin(array('source_label' => $opted_in_list->subscription_object_label(), 'source_url' => $opted_in_list->subscription_url(), 'agreement' => $this->message));
         $prompt_user = new Prompt_User($subscriber_id);
         $prompt_user->set_subscriber_origin($origin);
         do_action('prompt/register_subscribe_command/created_user', $prompt_user->get_wp_user());
     }
     if (!$opted_in_list->is_subscribed($subscriber_id)) {
         $opted_in_list->subscribe($subscriber_id);
         Prompt_Subscription_Mailing::send_subscription_notification($subscriber_id, $opted_in_list);
     }
     // TODO: remove our pre registration comment?
 }
コード例 #5
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;
 }
コード例 #6
0
 /**
  * Import a user.
  *
  * @param string $subscriber The subscriber's email address
  * @param object|\Prompt_Post Post subscribe object for current post.
  */
 protected function import($subscriber, $object)
 {
     $existing_user = get_user_by('email', $subscriber);
     if ($existing_user and $object->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if (!$existing_user) {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber);
     } else {
         $subscriber_id = $existing_user->ID;
     }
     $subscribed = $object->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Subscribe 2 Comments Reloaded Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
コード例 #7
0
 /**
  * Import a MailPoet subscriber.
  *
  * @since 1.0.0
  * @param array $subscriber
  */
 protected function import($subscriber)
 {
     $existing_user = get_user_by('email', $subscriber['email']);
     if ($existing_user and $this->target_list->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if (!$existing_user) {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber['email']);
         wp_update_user(array('ID' => $subscriber_id, 'first_name' => $subscriber['firstname'], 'last_name' => $subscriber['lastname']));
     } else {
         $subscriber_id = $existing_user->ID;
     }
     $this->target_list->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Mailpoet Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
コード例 #8
0
ファイル: user.php プロジェクト: postmatic/beta-dist
 /**
  * Get the IDs of all users subscribed to an author.
  * @since 1.0.0
  * @return array
  */
 public static function all_subscriber_ids()
 {
     // Using a "fake" object for PHP 5.2, which doesn't have static method inheritance
     $user = new Prompt_User(0);
     return $user->_all_subscriber_ids();
 }
コード例 #9
0
 protected function import($subscriber)
 {
     $existing_user = get_user_by('email', $subscriber['email_address']);
     $prompt_site = new Prompt_Site();
     if ($existing_user and $prompt_site->is_subscribed($existing_user->ID)) {
         $this->already_subscribed_count++;
         return;
     }
     if ($existing_user) {
         $subscriber_id = $existing_user->ID;
     } else {
         $subscriber_id = Prompt_User_Handling::create_from_email($subscriber['email_address']);
     }
     $prompt_site->subscribe($subscriber_id);
     $prompt_user = new Prompt_User($subscriber_id);
     $origin = new Prompt_Subscriber_Origin(array('source_label' => 'Jetpack Import', 'source_url' => scbUtil::get_current_url()));
     $prompt_user->set_subscriber_origin($origin);
     $this->imported_count++;
 }
コード例 #10
0
 /**
  * Add recipient-specific values to the batch.
  *
  * @since 2.0.0
  *
  * @param Prompt_User $recipient
  * @return $this
  */
 public function add_recipient(Prompt_User $recipient)
 {
     if (!$recipient->get_wp_user()) {
         trigger_error(__('Did not add an invalid post recipient', 'Postmatic'), E_USER_NOTICE);
         return $this;
     }
     $prompt_site = $this->context->get_site();
     $prompt_author = $this->context->get_author();
     $subscribed_object = $prompt_author->is_subscribed($recipient->id()) ? $prompt_author : $prompt_site;
     $unsubscribe_link = new Prompt_Unsubscribe_Link($recipient->get_wp_user());
     $values = array('id' => $recipient->id(), 'to_name' => $recipient->get_wp_user()->display_name, 'to_address' => $recipient->get_wp_user()->user_email, 'subscribed_object_label' => html_entity_decode($subscribed_object->subscription_object_label()), 'unsubscribe_url' => $unsubscribe_link->url());
     if (is_a($subscribed_object, 'Prompt_User') and $prompt_author->id()) {
         $values['from_name'] = get_option('blogname') . ' [' . $prompt_author->get_wp_user()->display_name . ']';
     }
     $values = array_merge($values, $this->mail_command_values($recipient->id(), $subscribed_object));
     return $this->add_individual_message_values($values);
 }
コード例 #11
0
ファイル: post.php プロジェクト: postmatic/beta-dist
 /**
  * Get the IDs of users who should receive an email when this post is published.
  *
  * This includes both subscribers to the author and to the site.
  *
  * Post types not enabled in the options will have no recipients.
  *
  * @return array An array of user IDs.
  */
 public function recipient_ids()
 {
     $post = $this->get_wp_post();
     if (!in_array($post->post_type, Prompt_Core::$options->get('site_subscription_post_types'))) {
         return array();
     }
     $recipient_ids = $this->cached_recipient_ids();
     if (!$recipient_ids) {
         $prompt_site = new Prompt_Site();
         $recipient_ids = $prompt_site->subscriber_ids();
         $prompt_author = new Prompt_User($post->post_author);
         $recipient_ids = array_unique(array_merge($recipient_ids, $prompt_author->subscriber_ids()));
         /**
          * Filter the recipient ids of notifications for a post.
          *
          * @param array   $recipient_ids
          * @param WP_Post $post
          */
         $recipient_ids = apply_filters('prompt/recipient_ids/post', $recipient_ids, $post);
         if ('publish' == $post->post_status) {
             update_post_meta($post->ID, self::$recipient_ids_meta_key, $recipient_ids);
         }
     }
     return $recipient_ids;
 }
コード例 #12
0
ファイル: user-handling.php プロジェクト: postmatic/beta-dist
 /**
  * Prevent subscribers who were not sent credentials from resetting their password.
  *
  * Hooks allow_password_reset
  *
  * @since 1.3.2
  *
  * @param int $user_id
  * @return boolean
  */
 public static function filter_allow_password_reset($allow, $user_id)
 {
     $prompt_user = new Prompt_User($user_id);
     if (!$prompt_user->get_wp_user()->has_cap('subscriber')) {
         return $allow;
     }
     if (!$prompt_user->get_subscriber_origin()) {
         return $allow;
     }
     if (Prompt_Core::$options->get('send_login_info')) {
         return $allow;
     }
     return false;
 }