示例#1
0
 /**
  * Initializes the class when called upon.
  */
 public function init()
 {
     /** Settings *****************************************************/
     $this->settings = bp_get_option('bp-rbe');
     /** Includes *****************************************************/
     $this->includes();
     /** Constants ****************************************************/
     $this->constants();
     /** Localization *************************************************/
     // we place this here instead of in hooks() because we want to
     // localize even before our requirements are fulfilled
     $this->localization();
     /** Requirements check *******************************************/
     // If requirements are not fulfilled, then throw an admin notice and stop now!
     if (!bp_rbe_is_required_completed($this->settings)) {
         add_action('admin_notices', array(&$this, 'admin_notice'));
         return;
     }
     /** Post-requirements routine ************************************/
     // load inbound provider
     if (bp_rbe_is_inbound()) {
         $this->load_inbound_provider();
     }
     // load the hooks!
     $this->hooks();
 }
示例#2
0
    /**
     * Outputs next scheduled run of the (pseudo) cron.
     */
    protected function schedule()
    {
        // only show the following if required fields are filled in correctly
        if (bp_rbe_is_required_completed() && !bp_rbe_is_inbound()) {
            $is_connected = bp_rbe_is_connected();
            ?>
		<h3><?php 
            _e('Connection Info', 'bp-rbe');
            ?>
</h3>

		<p class="<?php 
            echo $is_connected ? 'connected' : 'not-connected';
            ?>
">
			<?php 
            if ($is_connected) {
                ?>
				<?php 
                _e('<strong>Reply By Email</strong> is currently <span>CONNECTED</span> and checking your inbox continuously.', 'bp-rbe');
                ?>
			<?php 
            } else {
                ?>
				<?php 
                _e('<strong>Reply By Email</strong> is currently <span>NOT CONNECTED</span>.  Please refresh the page to initiate a connection.', 'bp-rbe');
                ?>
			<?php 
            }
            ?>
		</p>

	<?php 
        }
    }
/**
 * Injects querystring into an email address.
 *
 * For IMAP mode, the constructed email address will look like this:
 *  test@gmail.com -> test+THEQUERYSTRING@gmail.com
 *
 * For inbound mode, the constructed email address will look like this:
 *  THEQUERYSTRING@reply.yourdomain.com
 *
 * @since 1.0-beta
 *
 * @param string $qs The querystring we want to add to an email address.
 * @returns string
 */
function bp_rbe_inject_qs_in_email($qs)
{
    // inbound mode uses subdomain addressing
    // eg. whatever@reply.yourdomain.com
    if (bp_rbe_is_inbound()) {
        $retval = $qs . '@' . bp_rbe_get_setting('inbound-domain');
        // imap mode uses address tags
        // eg. test+whatever@gmail.com
    } else {
        $email = bp_rbe_get_setting('email');
        $at_pos = strpos($email, '@');
        // Address tag + $qs
        $qs = bp_rbe_get_setting('tag') . $qs;
        $retval = substr_replace($email, $qs, $at_pos, 0);
    }
    return apply_filters('bp_rbe_inject_qs_in_email', $retval, $qs);
}
 /**
  * Returns the querystring from an email address.
  *
  * In IMAP mode:
  *   test+THEQUERYSTRING@gmail.com> -> THEQUERYSTRING
  *
  * In Inbound mode:
  *   THEQUERYSTRING@reply.mydomain.com -> THEQUERYSTRING
  *
  * The querystring is encoded by default.
  *
  * @param string $address The email address containing the address tag
  * @return mixed Either the address tag on success or false on failure
  */
 public static function get_querystring($address = '')
 {
     if (empty($address)) {
         return false;
     }
     $at = strpos($address, '@');
     if ($at === false) {
         return false;
     }
     // inbound mode uses subdomain addressing
     if (bp_rbe_is_inbound()) {
         $qs = substr($address, 0, $at);
         // imap mode uses address tags
     } else {
         $tag = strpos($address, bp_rbe_get_setting('tag'));
         if ($tag === false) {
             $qs = false;
         } else {
             $qs = substr($address, ++$tag, $at - $tag);
         }
     }
     /**
      * Filter the querystring from an email address.
      *
      * @since 1.0-RC4
      *
      * @param string|false $qs      Current querystring.
      * @param string       $address Full 'to' email address.
      */
     return apply_filters('bp_rbe_get_querystring', $qs, $address);
 }
示例#5
0
<?php

/**
 * BP Reply By Email Hooks
 *
 * @package BP_Reply_By_Email
 * @subpackage Hooks
 */
// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
// only run the following hooks if requirements are fulfilled
if (bp_rbe_is_required_completed()) {
    // imap mode hooks
    if (!bp_rbe_is_inbound()) {
        // cron - only run on the root blog and if WP cron is not active
        if (bp_is_root_blog() && !defined('DOING_CRON')) {
            add_action('init', 'bp_rbe_should_connect', 20);
            add_action('init', 'bp_rbe_run_inbox_listener', 999);
        }
        // email inbox parsing
        /**
         * In Gmail, imap_delete() moves the email to the "All Mail" folder; it doesn't mark the email for deletion.
         *
         * Note: If you're using Gmail AND you're hooking into the "bp_rbe_imap_no_match" or "bp_rbe_imap_loop" filters,
         *       DO NOT USE imap_mail_move() or imap_mail_copy() as this will F up the message loop.
         *
         *       From my testing, using GMail and imap_mail_move() / imap_mail_copy() will also expunge the email.
         *       (Will need to test non-Gmail IMAP servers.)
         *