示例#1
0
 function WYSIJA_help_rules()
 {
     $forwardEmail = "";
     $forwardEmail = count(str_split($forwardEmail)) . ':"' . $forwardEmail . '"';
     /*
                 $this->defaultrules[]=array("name"=>__('Feedback loop',WYSIJA),
                                             "title"=>__('When feedback loop',WYSIJA),
                                             "regex"=>'feedback|staff@hotmail.com',
                                              "executed_on"=>array(
                                                 "subject"=>1,
                                                  "senderinfo"=>1
                                                 ),
                                             "action_message"=>array(
                                                 "delete"=>1,
                                                 "save"=>1
                                                 ),
                                             "action_user"=>"unsub",
                                              "action_user_min"=>0
                                             );*/
     $this->defaultrules[] = array("order_display" => 0, "key" => "mailbox_full", "name" => __('Mailbox Full', WYSIJA), "title" => __('When mailbox is full', WYSIJA), "regex" => '((mailbox|mailfolder|storage|quota|space) *(is)? *(over)? *(exceeded|size|storage|allocation|full|quota|maxi))|((over|exceeded|full) *(mail|storage|quota))', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 3, "action_user_stats" => 1);
     $this->defaultrules[] = array("order_display" => 1, "key" => "mailbox_na", "name" => __('Mailbox not available', WYSIJA), "title" => __('When mailbox is not available', WYSIJA), "regex" => '(Invalid|no such|unknown|bad|des?activated|undelivered|inactive|unrouteable|delivery|mail ID|failed to|may not|no known user|email account) *(mail|destination|recipient|user|address|person|failure|has failed|does not exist|deliver to|exist|with this email|is closed)|RecipNotFound|status(-code)? *(:|=)? *5\\.(1\\.[1-6]|0\\.0|4\\.[0123467])|(user|mailbox|address|recipients?|host|account|domain) *(is|has been)? *(error|disabled|failed|unknown|unavailable|not *(found|available)|.{1,30}inactiv)|recipient *address *rejected|does *not *like *recipient|no *mailbox *here|user does.?n.t have.{0,20}account', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 0, "action_user_stats" => 1);
     $this->defaultrules[] = array("order_display" => 5, "behave" => "mailbox_na", "key" => "message_delayed", "name" => __('Message delayed', WYSIJA), "title" => __('When message is delayed', WYSIJA), "regex" => 'possible *mail *loop|too *many *hops|Action: *delayed|has.*been.*delayed|delayed *mail|temporary *failure', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 3, "action_user_stats" => 1);
     $this->defaultrules[] = array("order_display" => 6, "behave" => "mailbox_na", "key" => "failed_permanent", "name" => __('Failed Permanently', WYSIJA), "title" => __('When failed permanently', WYSIJA), "regex" => 'failed *permanently|permanent *(fatal)? *(failure|error)|Unrouteable *address|not *accepting *(any)? *mail', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 0, "action_user_stats" => 1);
     /* $this->defaultrules[]=array("order_display"=>2,
                                "name"=>__('Out of office',WYSIJA),
                                "title"=>__('When out of office detected',WYSIJA),
                                "key"=>"is_out_office",
                                "regex"=>'(out|away|on) .*(of|from|leave)|office|vacation|holiday|absen|congÈs|recept|acknowledg|thank you for',
                                 "executed_on"=>array(
                                    "subject"=>1,
                                     "body"=>1
                                    ),
                                "action_message"=>array(
                                    "delete"=>1
                                    ),
                                //"action_user_min"=>0
        );*/
     $this->defaultrules[] = array("order_display" => 3, "key" => "action_required", "name" => __('Action Required', WYSIJA), "title" => __('When you need to confirm you\'re a human being, forward to:', WYSIJA), "regex" => 'action *required|verif', "forward" => 1, "executed_on" => array("subject" => 1), "action_message" => array("delete" => 1), "action_user_min" => 0);
     $this->defaultrules[] = array("order_display" => 4, "key" => "blocked_ip", "name" => __('Blocked IP', WYSIJA), "forward" => 1, "title" => __('When you are flagged as a spammer forward the bounced message to', WYSIJA), "regex" => 'is *(currently)? *blocked *by|block *list|spam *detected|(unacceptable|banned|offensive|filtered|blocked) *(content|message|e-?mail)|administratively *denied', "executed_on" => array("body" => 1), "action_message" => array("delete" => 1), "action_user_min" => 0);
     $this->defaultrules[] = array("order_display" => 7, "key" => "nohandle", "name" => 'Final Rule', "title" => __('When the bounce is weird and we\'re not sure what to do, forward to:', WYSIJA), "forward" => 1, "regex" => '.', "executed_on" => array("senderinfo" => 1, "subject" => 1), "action_message" => array("delete" => 1), "action_user_min" => 0, "action_user_stats" => 1);
     $model_config = WYSIJA::get('config', 'model');
     $prefix_ms = '';
     if (is_multisite()) {
         $prefix_ms = 'ms_';
     }
     foreach ($this->defaultrules as $ki => $vi) {
         //if a rule is defined
         if (isset($model_config->values[$prefix_ms . 'bounce_rule_' . $vi['key']])) {
             if ($model_config->values[$prefix_ms . 'bounce_rule_' . $vi['key']] != '') {
                 $this->defaultrules[$ki]['action_user'] = $model_config->values[$prefix_ms . 'bounce_rule_' . $vi['key']];
             }
         }
         //if a forwarded message is detected
         if (isset($model_config->values[$prefix_ms . 'bounce_rule_' . $vi['key'] . '_forwardto'])) {
             if ($model_config->values[$prefix_ms . 'bounce_rule_' . $vi['key'] . '_forwardto'] != '') {
                 $this->defaultrules[$ki]['action_message_forwardto'] = $model_config->values[$prefix_ms . 'bounce_rule_' . $vi['key'] . '_forwardto'];
             }
         }
     }
 }
示例#2
0
 function hook_subscriber_to_list($details)
 {
     $config = WYSIJA::get('config', 'model');
     $modelUser = WYSIJA::get('user', 'model');
     $userdata = $modelUser->getOne(false, array('user_id' => $details['user_id']));
     $confirmed = true;
     /* do not send email if user is not confirmed*/
     /*if($config->getValue('confirm_dbleoptin') && (int)$userdata['status']!=1)   $confirmed=false;
     
             if($confirmed){
                 $helperU=WYSIJA::get('user','helper');
                 $helperU->sendAutoNl($details['user_id'],array(0=>$details));
             }*/
     $dbloptin = $config->getValue('confirm_dbleoptin');
     /*only if dbleoptin has been deactivated we send immediately the post notification*/
     if (!$dbloptin || $dbloptin && (int) $userdata['status'] > 0) {
         /*check for auto nl and send if needed*/
         $helperU = WYSIJA::get('user', 'helper');
         if (isset($this->backSave) && $this->backSave) {
             $helperU->sendAutoNl($details['user_id'], array(0 => $details), 'subs-2-nl', true);
         } else {
             $helperU->sendAutoNl($details['user_id'], array(0 => $details));
         }
     }
     return true;
 }
示例#3
0
 function removeProcess()
 {
     if (is_admin()) {
         $filename = dirname(__FILE__) . DS . 'uninstall.sql';
         $handle = fopen($filename, 'r');
         $query = fread($handle, filesize($filename));
         fclose($handle);
         $modelObj =& WYSIJA::get('user', 'model');
         $queries = str_replace('DROP TABLE `', 'DROP TABLE `[wysija]', $query);
         $queries = explode('-- QUERY ---', $queries);
         $modelWysija = new WYSIJA_model();
         global $wpdb;
         foreach ($queries as $query) {
             $modelWysija->query($query);
         }
         delete_option('wysija');
         WYSIJA::update_option('wysija_reinstall', 1);
         global $wp_roles;
         foreach ($wp_roles->roles as $rolek => $roled) {
             if ($rolek == 'administrator') {
                 continue;
             }
             $role = get_role($rolek);
             $arr = array('wysija_newsletters', 'wysija_subscribers', 'wysija_subscriwidget', 'wysija_config');
             foreach ($arr as $arrkey) {
                 $role->remove_cap($arrkey);
             }
         }
         return true;
     }
     return false;
 }
示例#4
0
 function WYSIJA_help_rules()
 {
     $forwardEmail = "";
     $forwardEmail = count(str_split($forwardEmail)) . ':"' . $forwardEmail . '"';
     $this->defaultrules[] = array("order_display" => 2, "key" => "action_required", "name" => __('Action Required', WYSIJA), "title" => __('When you need to confirm you\'re a human being, forward to:', WYSIJA), "regex" => 'action *required|verif', "forward" => 1, "executed_on" => array("subject" => 1), "action_message" => array("delete" => 1), "action_user_min" => 0);
     $this->defaultrules[] = array("order_display" => 0, "key" => "mailbox_full", "name" => __('Mailbox Full', WYSIJA), "title" => __('When mailbox is full', WYSIJA), "regex" => '((mailbox|mailfolder|storage|quota|space) *(is)? *(over)? *(exceeded|size|storage|allocation|full|quota|maxi))|((over|exceeded|full) *(mail|storage|quota))', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 3, "action_user_stats" => 1);
     $this->defaultrules[] = array("order_display" => 3, "key" => "blocked_ip", "name" => __('Blocked IP', WYSIJA), "forward" => 1, "title" => __('When you are flagged as a spammer forward the bounced message to', WYSIJA), "regex" => 'is *(currently)? *blocked *by|block *list|spam *detected|(unacceptable|banned|offensive|filtered|blocked) *(content|message|e-?mail)|administratively *denied', "executed_on" => array("body" => 1), "action_message" => array("delete" => 1), "action_user_min" => 0);
     $this->defaultrules[] = array("order_display" => 5, "behave" => "mailbox_na", "key" => "message_delayed", "name" => __('Message delayed', WYSIJA), "title" => __('When message is delayed', WYSIJA), "regex" => 'has.*been.*delayed|delayed *mail|temporary *failure', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 3, "action_user_stats" => 1);
     $this->defaultrules[] = array("order_display" => 1, "key" => "mailbox_na", "name" => __('Mailbox not available', WYSIJA), "title" => __('When mailbox is not available', WYSIJA), "regex" => '(Invalid|no such|unknown|bad|des?activated|undelivered) *(mail|destination|recipient|user|address)|RecipNotFound|(user|mailbox|address|recipients?|host) *(disabled|failed|unknown|unavailable|not *found)', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 0, "action_user_stats" => 1);
     $this->defaultrules[] = array("order_display" => 6, "behave" => "mailbox_na", "key" => "failed_permanent", "name" => __('Failed Permanently', WYSIJA), "title" => __('When failed permanently', WYSIJA), "regex" => 'failed *permanently|permanent *(fatal)? *(failure|error)|Unrouteable *address|not *accepting *(any)? *mail', "executed_on" => array("subject" => 1, "body" => 1), "action_message" => array("delete" => 1, "save" => 1), "action_user_min" => 0, "action_user_stats" => 1);
     $this->defaultrules[] = array("order_display" => 4, "key" => "nohandle", "name" => 'Final Rule', "title" => __('When the bounce is weird and we\'re not sure what to do, forward to:', WYSIJA), "forward" => 1, "regex" => '.', "executed_on" => array("senderinfo" => 1, "subject" => 1), "action_message" => array("delete" => 1), "action_user_min" => 0, "action_user_stats" => 1);
     $modelC =& WYSIJA::get("config", "model");
     foreach ($this->defaultrules as $ki => $vi) {
         if (isset($modelC->values['bounce_rule_' . $vi['key']])) {
             if ($modelC->values['bounce_rule_' . $vi['key']] != "") {
                 $this->defaultrules[$ki]['action_user'] = $modelC->values['bounce_rule_' . $vi['key']];
             }
         }
         if (isset($modelC->values['bounce_rule_' . $vi['key'] . '_forwardto'])) {
             if ($modelC->values['bounce_rule_' . $vi['key'] . '_forwardto'] != "") {
                 $this->defaultrules[$ki]['action_message_forwardto'] = $modelC->values['bounce_rule_' . $vi['key'] . '_forwardto'];
             }
         }
     }
 }
示例#5
0
 function queue($mailid, $time, $onlyNew = false)
 {
     $mailid = intval($mailid);
     if (empty($mailid)) {
         return false;
     }
     $classLists =& WYSIJA::get("campaign_list", "model");
     $lists = $classLists->getReceivers($mailid, false);
     if (empty($lists)) {
         return 0;
     }
     $config =& WYSIJA::get("config", "model");
     $querySelect = 'SELECT DISTINCT a.user_id,' . $mailid . ',' . $time . ',' . (int) $config->getValue('priority_newsletter', 3);
     $querySelect .= ' FROM [wysija]user_list as a ';
     $querySelect .= ' JOIN [wysija]user as b ON a.user_id = b.user_id ';
     $querySelect .= 'WHERE a.list_id IN (' . implode(',', array_keys($lists)) . ') AND a.status = 1 ';
     if ($config->getValue('confirm_dbleoptin')) {
         $querySelect .= 'AND b.status = 1 ';
     }
     $query = 'INSERT IGNORE INTO [wysija]queue (user_id,email_id,send_at,priority) ' . $querySelect;
     if (!$this->query($query)) {
         //acymailing_display($this->database->getErrorMsg(),'error');
         $this->error($this->getErrorMsg());
     }
     $totalinserted = $this->getAffectedRows();
     if ($onlyNew) {
         $query = 'DELETE b.* FROM `[wysija]email_user_stat` as a JOIN `[wysija]queue` as b on a.user_id = b.user_id WHERE a.email_id = ' . $mailid;
         $this->query($query);
         $totalinserted = $totalinserted - $this->getAffectedRows();
     }
     //JPluginHelper::importPlugin('acymailing');
     /*$dispatcher = &JDispatcher::getInstance();
       $dispatcher->trigger('onAcySendNewsletter',array($mailid));*/
     return $totalinserted;
 }
示例#6
0
    /**
     * clear upload folders from things we don't need anymore
     */
    function clear(){
        $foldersToclear=array('import','temp');
        $filenameRemoval=array('import-','export-');
        $deleted=array();
        $helperF=WYSIJA::get('file','helper');
        foreach($foldersToclear as $folder){
            $path=$helperF->getUploadDir($folder);
            /* get a list of files from this folder and clear them */

            $files = scandir($path);
            foreach($files as $filename){
                if(!in_array($filename, array('.','..','.DS_Store','Thumbs.db'))){
                    if(preg_match('/('.implode($filenameRemoval,'|').')[0-9]*\.csv/',$filename,$match)){
                       $deleted[]=$path.$filename;
                    }
                }
            }
        }
        foreach($deleted as $filename){
            if(file_exists($filename)){
                unlink($filename);
            }
        }

    }
示例#7
0
 function insert($subid, $action, $data = array(), $mailid = 0)
 {
     $current_user = WYSIJA::wp_get_userdata();
     /*dbg($current_user,0);
       $current_user=wp_get_current_user();*/
     if (!empty($current_user->ID)) {
         $data[] = 'EXECUTED_BY::' . $current_user->ID . ' ( ' . $current_user->user_login . ' )';
     }
     $history = null;
     $history['user_id'] = intval($subid);
     $history['type'] = strip_tags($action);
     $history['details'] = implode("\n", $data);
     $history['executed_at'] = time();
     $history['email_id'] = $mailid;
     $userHelper =& WYSIJA::get("user", "helper");
     $history['executed_by'] = $userHelper->getIP();
     if (!empty($_SERVER)) {
         $source = array();
         $vars = array('HTTP_REFERER', 'HTTP_USER_AGENT', 'HTTP_HOST', 'SERVER_ADDR', 'REMOTE_ADDR', 'REQUEST_URI', 'QUERY_STRING');
         foreach ($vars as $oneVar) {
             if (!empty($_SERVER[$oneVar])) {
                 $source[] = $oneVar . '::' . strip_tags($_SERVER[$oneVar]);
             }
         }
         $history['source'] = implode("\n", $source);
     }
     return parent::insert($history);
 }
示例#8
0
 function save()
 {
     $config = WYSIJA::get('config', 'model');
     if (!$config->getValue('allow_no_js')) {
         $this->notice(__('Subscription without JavaScript is disabled.', WYSIJA));
         return false;
     }
     if (isset($_REQUEST['wysija']['user_list']['list_id'])) {
         $_REQUEST['wysija']['user_list']['list_ids'] = $_REQUEST['wysija']['user_list']['list_id'];
         unset($_REQUEST['wysija']['user_list']['list_id']);
     } elseif (isset($_REQUEST['wysija']['user_list']['list_ids'])) {
         $_REQUEST['wysija']['user_list']['list_ids'] = explode(',', $_REQUEST['wysija']['user_list']['list_ids']);
     }
     $data = $_REQUEST['wysija'];
     unset($_REQUEST['wysija']);
     foreach ($_REQUEST as $key => $val) {
         if (!isset($data[$key])) {
             $data[$key] = $val;
         }
     }
     $helperUser = WYSIJA::get('user', 'helper');
     if (!$helperUser->checkData($data)) {
         return false;
     }
     $helperUser->addSubscriber($data);
     return true;
 }
示例#9
0
 function getAllByTheme($theme, $type = 'all')
 {
     $fileHelper =& WYSIJA::get('file', 'helper');
     $dirHandle = $fileHelper->exists('themes' . DS . $theme . DS . 'bookmarks');
     if ($dirHandle['result'] === FALSE) {
         return array();
     } else {
         $bookmarks = array();
         $sourceDir = $dirHandle['file'];
         $icons = scandir($sourceDir);
         foreach ($icons as $icon) {
             if (in_array($icon, array('.', '..', '.DS_Store', 'Thumbs.db')) === FALSE and strrpos($icon, '.txt') === FALSE) {
                 if ($type === 'all') {
                     $info = pathinfo($sourceDir . DS . $icon);
                     $dimensions = @getimagesize($sourceDir . DS . $icon);
                     $bookmarks[basename($icon, '.' . $info['extension'])] = array('src' => $fileHelper->url($icon, 'themes/' . $theme . '/bookmarks'), 'width' => $dimensions[0], 'height' => $dimensions[1]);
                 } else {
                     if ($type === 'url') {
                         $info = pathinfo($sourceDir . DS . $icon);
                         $bookmarks[basename($icon, '.' . $info['extension'])] = $fileHelper->url($icon, 'themes/' . $theme . '/bookmarks');
                     }
                 }
             }
         }
         return $bookmarks;
     }
 }
 /**
  * Subscribe an email to a list
  */
 public function subscribe_email($user_info = array(), $list_id = false, $opt_in_overridde = false)
 {
     global $edd_options;
     if (!class_exists('WYSIJA')) {
         return false;
     }
     // Retrieve the global list ID if none is provided
     if (!$list_id) {
         $list_id = !empty($edd_options['edd_wysija_list']) ? $edd_options['edd_wysija_list'] : false;
         if (!$list_id) {
             return false;
         }
     }
     $user_data = array('email' => $user_info['email'], 'firstname' => $user_info['first_name'], 'lastname' => $user_info['last_name']);
     $data = array('user' => $user_data, 'user_list' => array('list_ids' => array($list_id)));
     $userHelper = WYSIJA::get('user', 'helper');
     $model_user_list = WYSIJA::get('user_list', 'model');
     $user = get_user_by('email', $user_data['email']);
     $lists = $model_user_list->get_lists(array($user->ID));
     $users_lists = isset($lists[$user->ID]) ? $lists[$user->ID] : array();
     if (!in_array($list_id, $users_lists)) {
         $userHelper->addSubscriber($data);
     }
     if ($userHelper) {
         return true;
     }
     return false;
 }
 /**
  * init_fields function.
  *
  * @access public
  * @since 1.0.0
  * @return void
  */
 public function init_fields()
 {
     global $pagenow;
     $fields = array();
     $fields['rss'] = array('name' => __('RSS', 'subscribe-and-connect'), 'description' => __('Display an RSS icon along with your social network links.', 'subscribe-and-connect'), 'type' => 'checkbox', 'default' => true, 'section' => 'networks', 'required' => 0);
     $fields['networks'] = array('name' => __('Social Networks', 'subscribe-and-connect'), 'description' => __('The social networks to be linked to in the "Connect" portion of the output. Drag and drop to reorder.', 'subscribe-and-connect'), 'type' => 'network', 'default' => array('facebook'), 'section' => 'networks', 'required' => 0);
     $fields['networks_order'] = array('name' => '', 'description' => '', 'type' => 'hidden', 'default' => '', 'section' => 'networks', 'required' => 0);
     // Subscriptions
     $newsletter_services = array('none' => __('None', 'subscribe-and-connect'), 'aweber' => __('Aweber', 'subscribe-and-connect'), 'campaign_monitor' => __('Campaign Monitor', 'subscribe-and-connect'), 'feedburner' => __('Feedburner', 'subscribe-and-connect'), 'mad_mimi' => __('Mad Mimi', 'subscribe-and-connect'), 'mailchimp' => __('Mailchimp', 'subscribe-and-connect'));
     // Check if MailPoet is installed and add as option
     $wysija_lists = array();
     if (class_exists('WYSIJA')) {
         $newsletter_services['wysija'] = __('MailPoet Newsletters', 'subscribe-and-connect');
         $model_list = WYSIJA::get('list', 'model');
         $wysija_lists_temp = $model_list->get(array('name', 'list_id'), array('is_enabled' => 1));
         foreach ($wysija_lists_temp as $list) {
             $wysija_lists[$list['list_id']] = $list['name'];
         }
     }
     $fields['newsletter_service'] = array('name' => __('Newsletter Service', 'subscribe-and-connect'), 'description' => __('Select the newsletter service you are using.', 'subscribe-and-connect') . '<br /><small>' . sprintf(__('(Need a hand setting up your newsletter subscriptions? %1$sSee our documentation%2$s for a helping hand.)', 'subscribe-and-connect'), '<a href="' . esc_url('http://docs.woothemes.com/document/subscribe-and-connect/#section-2') . '">', '</a>') . '</small>', 'type' => 'select', 'default' => 'none', 'options' => $newsletter_services, 'section' => 'subscriptions');
     $fields['newsletter_service_id'] = array('name' => __('Feedburner Feed ID', 'subscribe-and-connect'), 'description' => sprintf(__('Enter the your Feedburner Feed ID %s(?)%s.', 'subscribe-and-connect'), '<a href="' . esc_url('http://support.google.com/feedburner/bin/answer.py?hl=en&answer=78982') . '" target="_blank">', '</a>'), 'type' => 'text', 'default' => '', 'section' => 'subscriptions');
     $fields['newsletter_service_form_action'] = array('name' => __('Newsletter Form Action', 'subscribe-and-connect'), 'description' => __('Enter the the form action if required.', 'subscribe-and-connect'), 'type' => 'text', 'default' => '', 'section' => 'subscriptions');
     $fields['newsletter_mail_chimp_list_subscription_url'] = array('name' => __('MailChimp List Subscription URL', 'subscribe-and-connect'), 'description' => sprintf(__('If you have a MailChimp account you can enter the %sMailChimp List Subscribe URL%s to allow your users to subscribe to a MailChimp List.', 'subscribe-and-connect'), '<a href="' . esc_url('http://woochimp.heroku.com/') . '" target="_blank">', '</a>'), 'type' => 'text', 'default' => '', 'section' => 'subscriptions');
     $fields['newsletter_mad_mimi_subscription_url'] = array('name' => __('Mad Mimi Webform URL', 'subscribe-and-connect'), 'description' => __('Your Mad Mini Webform URL, eg. https://madmimi.com/signups/subscribe/84680', 'subscribe-and-connect'), 'type' => 'text', 'default' => '', 'section' => 'subscriptions');
     $fields['newsletter_aweber_list_id'] = array('name' => __('Aweber List Name', 'subscribe-and-connect'), 'description' => __('The name of the list to subscribe users to.', 'subscribe-and-connect'), 'type' => 'text', 'default' => '', 'section' => 'subscriptions');
     if (class_exists('WYSIJA')) {
         $fields['newsletter_wysija_list_id'] = array('name' => __('MailPoet List', 'subscribe-and-connect'), 'description' => __('Select the name of the MailPoet list to subscribe users to.', 'subscribe-and-connect'), 'type' => 'select', 'default' => '', 'section' => 'subscriptions', 'options' => $wysija_lists);
     }
     $this->fields = $fields;
 }
 function mailpoet_lists()
 {
     // This will return an array of results with the name and list_id of each mailing list
     $model_list = WYSIJA::get('list', 'model');
     $mailpoet_lists = $model_list->get(array('name', 'list_id'), array('is_enabled' => 1));
     return $mailpoet_lists;
 }
示例#13
0
 /**
  * count the click statistic and redirect to the right url
  * @return boolean
  */
 function analyse()
 {
     if (isset($_REQUEST['email_id']) && isset($_REQUEST['user_id'])) {
         $WJ_Stats = new WJ_Stats();
         if (!empty($WJ_Stats->clicked_url)) {
             // clicked stats
             $url = $this->encode_url($WJ_Stats->subscriber_clicked());
             $external_url = htmlentities($WJ_Stats->subscriber_clicked());
             // escape HTML characters (that's how URLs are saved in the DB)
             $external_url = preg_replace('!/?\\?utm.*!', '', $external_url);
             // remove anything that starts with ?utm or /?utm
             $internal_url = htmlentities(get_site_url());
             $model_email = WYSIJA::get('email', 'model');
             $email_object = $model_email->getOne(false, array('email_id' => $_REQUEST['email_id']));
             if (preg_match('/' . preg_quote($external_url, '/') . '/', $email_object['body']) || preg_match('/^' . preg_quote($internal_url, '/') . '/', $url)) {
                 do_action('mpoet_click_stats', $WJ_Stats);
                 $this->redirect($url);
             }
             header('HTTP/1.0 404 Not Found');
             echo '<h1>404 Not Found</h1>';
             echo 'The page that you have requested could not be found.';
             exit;
         } else {
             // opened stat
             $WJ_Stats->subscriber_opened();
         }
     }
     return true;
 }
示例#14
0
 protected function get_post_params()
 {
     $params = array();
     $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
     switch (strtolower($order_by)) {
         case 'sent':
             $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
             break;
         case 'open':
             $order_by = WYSIJA_module_statistics::ORDER_BY_OPEN;
             break;
         case 'click':
             $order_by = WYSIJA_module_statistics::ORDER_BY_CLICK;
             break;
         case 'unsubscribe':
             $order_by = WYSIJA_module_statistics::ORDER_BY_UNSUBSCRIBE;
             break;
         default:
             $order_by = null;
             break;
     }
     $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
     switch (strtolower($order_direction)) {
         case 'asc':
             $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
             break;
         case 'desc':
         default:
             $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_DESC;
             break;
     }
     $params['top'] = !empty($_REQUEST['filter']['itemPerPage']) ? (int) $_REQUEST['filter']['itemPerPage'] : WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
     $params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : null;
     $params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : null;
     $params['last_days'] = isset($_REQUEST['filter']['lastDays']) ? $_REQUEST['filter']['lastDays'] : null;
     $params['order_by'] = $order_by;
     $params['order_direction'] = $order_direction;
     $params['additional_param'] = !empty($_REQUEST['filter']['additionalParam']) ? trim($_REQUEST['filter']['additionalParam']) : null;
     // this doesn't work when php is less than 5.3, this is the case on my host (ben) which is very popular in France, SPain and UK
     // we cannot use functions from php 5.3
     if (function_exists('date_diff')) {
         $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
     } else {
         $duration = strtotime($params['to']) - strtotime($params['from']);
         $helper_toolbox = WYSIJA::get('toolbox', 'helper');
         $this->data['date_interval'] = (object) $helper_toolbox->convert_seconds_to_array($duration, false);
     }
     $params['group_by'] = $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD ? WYSIJA_module_statistics::GROUP_BY_MONTH : WYSIJA_module_statistics::GROUP_BY_DATE;
     // $date_interval->days == 0, means, no begin date, no end date
     // Hack!
     $_REQUEST['limit_pp'] = $params['top'];
     // Pagination, mark current selected value
     $this->save_last_selection($params);
     // Modify TO date to make sure we always count 23:59:59 of that day
     $to = new DateTime($params['to']);
     $to->modify('+1 day');
     $params['to'] = $to->format($this->date_format);
     return $params;
 }
示例#15
0
 function view()
 {
     $data = array();
     header('Content-type:text/html; charset=utf-8');
     // Get email model as object.
     $emailM = WYSIJA::get('email', 'model');
     $emailM->getFormat = OBJECT;
     // Get config model
     $configM = WYSIJA::get('config', 'model');
     $configM->add_translated_default();
     // Helpers
     $emailH = WYSIJA::get('email', 'helper');
     $mailerH = WYSIJA::get('mailer', 'helper');
     $email_id = (int) $_REQUEST['email_id'];
     // Get current email object.
     $current_email = $emailM->getOne($email_id);
     if (empty($current_email)) {
         exit;
     }
     if ($current_email->type == 2) {
         $emailM->reset();
         $autonewsHelper = WYSIJA::get('autonews', 'helper');
         $autonewsHelper->refresh_automatic_content(array($email_id));
         $emailM->getFormat = OBJECT;
         $current_email = $emailM->getOne($email_id);
     }
     // Get current user object if possible
     $current_user = null;
     // Parse and replace user tags.
     $mailerH->parseUserTags($current_email);
     $mailerH->parseSubjectUserTags($current_email);
     $mailerH->replaceusertags($current_email, $current_user);
     // Set Body
     $email_render = $current_email->body;
     // Parse old shortcodes that we are parsing in the queue.
     $find = array('[unsubscribe_linklabel]');
     $replace = array($configM->getValue('unsubscribe_linkname'));
     if (isset($current_email->params['autonl']['articles']['first_subject'])) {
         $find[] = '[post_title]';
         $replace[] = $current_email->params['autonl']['articles']['first_subject'];
     }
     if (isset($current_email->params['autonl']['articles']['total'])) {
         $find[] = '[total]';
         $replace[] = $current_email->params['autonl']['articles']['total'];
     }
     //        if (isset($current_email->params['autonl']['articles']['ids'])){
     //            $find[] = '[number]';
     //            $replace[] = count($current_email->params['autonl']['articles']['ids']);
     //        }
     if (isset($current_email->params['autonl']['total_child'])) {
         $find[] = '[number]';
         $replace[] = $current_email->params['autonl']['total_child'];
     }
     $email_render1 = str_replace($find, $replace, $email_render);
     // Strip unsubscribe links.
     $email_render2 = $emailH->stripPersonalLinks($email_render1);
     echo apply_filters('wysija_preview', $email_render2);
     exit;
 }
示例#16
0
文件: tmce.php 项目: rotoballer/emily
 function WYSIJA_control_back_tmce()
 {
     if (!WYSIJA::current_user_can('wysija_subscriwidget')) {
         die("Action is forbidden.");
     }
     parent::WYSIJA_control();
     $this->viewObj =& WYSIJA::get('tmce', 'view');
 }
示例#17
0
 /**
 * Get default divider
 * @return array
 */
 function getDefault() {
     $fileHelper = WYSIJA::get('file', 'helper');
     return array(
         'src' => $fileHelper->url('solid.jpg', 'dividers'),
         'width' => 564,
         'height' => 1
     );
 }
示例#18
0
 public function defaultDisplay()
 {
     if (!WYSIJA::current_user_can('wysija_stats_dashboard')) {
         die('Action is forbidden.');
     }
     $this->pre_defined_dates = $this->get_pre_defined_dates();
     // Define view
     $this->viewShow = $this->action = 'main';
     $this->js['jquery.core'] = 'jquery/ui/jquery.ui.core';
     $this->js['jquery.datepicker'] = 'jquery/ui/jquery.ui.datepicker';
     $this->js['wysijalazyload'] = 'wysija-lazyload';
     $this->js['admin-statistics-filter'] = 'admin-statistics-filter';
     wp_enqueue_style('jquery.core', WYSIJA_URL . 'css/jquery/ui/themes/base/jquery.ui.core.min.css', array(), WYSIJA::get_version());
     wp_enqueue_style('jquery.core', WYSIJA_URL . 'css/jquery/ui/themes/base/jquery.ui.theme.min.css', array(), WYSIJA::get_version());
     // date filter
     $default_duration = $this->get_default_duration();
     if (function_exists('date_diff')) {
         $this->data['date_interval'] = date_diff(date_create($default_duration->from), date_create($default_duration->to));
     } else {
         $duration = strtotime($default_duration->to) - strtotime($default_duration->from);
         $helper_toolbox = WYSIJA::get('toolbox', 'helper');
         $this->data['date_interval'] = (object) $helper_toolbox->convert_seconds_to_array($duration, false);
     }
     $this->data['custom_dates'] = $this->pre_defined_dates;
     $this->data['default_duration'] = $default_duration;
     $this->data['js_date_format'] = $this->js_date_format;
     // Process and push data into view
     $this->data['lazy_load'] = $this->lazy_load;
     $hook_name = 'hook_stats';
     $hook_params = array();
     $hook_params['top'] = WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
     $hook_params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : $default_duration->from;
     $hook_params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : $default_duration->to;
     $hook_params['group_by'] = $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD ? WYSIJA_module_statistics::GROUP_BY_MONTH : WYSIJA_module_statistics::GROUP_BY_DATE;
     // $this->data['date_interval']->days == 0, means, no begin date, no end date
     // Hack!
     $_REQUEST['limit_pp'] = $hook_params['top'];
     // Pagination, mark current selected value
     // Modify TO date to make sure we always count 23:59:59 of that day
     $to = new DateTime($hook_params['to']);
     $to->modify('+1 day');
     $hook_params['to'] = $to->format($this->date_format);
     $modules = WYSIJA_module::get_modules_from_hook($hook_name);
     $this->data['modules'] = $modules;
     $this->data['lazy_load_modules'] = array();
     $this->data['first_module'] = '';
     if (!$this->lazy_load) {
         $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
     } else {
         if (!empty($modules)) {
             $first_module = array_shift($modules);
             // List of lazy loaded modules
             $this->data['lazy_load_modules'] = $modules;
             // Evenly we are lazy loading, we always load the first module by default
             $this->data['first_module'] = apply_filters('custom_module_hook', '', $first_module, $hook_name, $hook_params);
         }
     }
 }
示例#19
0
 /**
  * Render shortcodes
  * @param array $newsletters a list of object Email
  * @return array a list of object Email, with renedered shortcodes at subject
  */
 protected function replace_shortcodes($newsletters)
 {
     $helper_mailer = WYSIJA::get('mailer', 'helper');
     $helper_shortcodes = WYSIJA::get('shortcodes', 'helper');
     foreach ($newsletters as &$newsletter) {
         $helper_mailer->parseSubjectUserTags($newsletter);
         $newsletter->subject = $helper_shortcodes->replace_subject($newsletter);
     }
     return $newsletters;
 }
示例#20
0
 function getVIB($dataEmail)
 {
     if (false && isset($dataEmail['params']['vib_id'])) {
         return WYSIJA::get_permalink($dataEmail['params']['vib_id'], false);
     } else {
         $paramsurl = array('wysija-page' => 1, 'controller' => "email", 'action' => "view", 'email_id' => $dataEmail["email_id"]);
         $modelConf =& WYSIJA::get("config", "model");
         return WYSIJA::get_permalink($modelConf->getValue("confirm_email_link"), $paramsurl);
     }
 }
function siw_woo_checkout_newsletter_subscribe($order_id, $posted_form)
{
    $newsletter_signup = isset($_POST['newsletter_signup']) ? 1 : 0;
    $list = (int) get_option('siw_woo_newsletter_list');
    if (1 == $newsletter_signup) {
        $user_data = array('email' => sanitize_text_field($_POST['billing_email']), 'firstname' => sanitize_text_field($_POST['billing_first_name']), 'lastname' => sanitize_email($_POST['billing_last_name']));
        $data_subscriber = array('user' => $user_data, 'user_list' => array('list_ids' => array($list)));
        $user_id = WYSIJA::get('user', 'helper')->addSubscriber($data_subscriber, true);
    }
}
示例#22
0
 /**
  * Reruns necessary data for tooltip.
  *
  * @return array $data
  */
 public static function get_tip_data()
 {
     $model_config = WYSIJA::get('config', 'model');
     $is_gmail = 'false';
     if ('gmail' === $model_config->getValue('sending_method')) {
         $is_gmail = 'true';
     }
     $data = array('text' => sprintf(__('Use an email from your domain, like <strong>info@%s</strong> to avoid the spam folder, or even be blocked.', WYSIJA), self::get_domain()), 'gmailText' => sprintf(__('If you want to use a Gmail address, you need to send with Gmail. Check <a id="tip-send-with" href="%s">sending settings</a>.', WYSIJA), admin_url('admin.php?page=wysija_config#tab-sendingmethod')), 'domain' => self::get_domain(), 'isGmail' => $is_gmail);
     return $data;
 }
示例#23
0
 function wp_notifications_cancelled(&$phpmailer)
 {
     $modelC = WYSIJA::get('config', 'model');
     if (!$modelC->getValue('wp_notifications')) {
         return $phpmailer;
     }
     $mailobj = new WYSIJA_sendfalse();
     $phpmailer = $mailobj;
     return $phpmailer;
 }
示例#24
0
 function view()
 {
     $data = array();
     header('Content-type:text/html; charset=utf-8');
     // Get email model as object.
     $emailM =& WYSIJA::get('email', 'model');
     $emailM->getFormat = OBJECT;
     // Get config model
     $configM =& WYSIJA::get('config', 'model');
     // Helpers
     $emailH =& WYSIJA::get('email', 'helper');
     $mailerH =& WYSIJA::get('mailer', 'helper');
     // Get current email object.
     $current_email = $emailM->getOne((int) $_REQUEST['email_id']);
     // Get current user object if possible
     $current_user = null;
     if (isset($_REQUEST['user_id'])) {
         // Get User Model
         $userM =& WYSIJA::get('user', 'model');
         $userM->getFormat = OBJECT;
         $current_user = $userM->getOne((int) $_REQUEST['user_id']);
     }
     // Parse and replace user tags.
     $mailerH->parseUserTags($current_email);
     $mailerH->parseSubjectUserTags($current_email);
     $mailerH->replaceusertags($current_email, $current_user);
     // Parse and replace old shortcodes.
     // $emailObject->subject = str_replace(
     //         array('[total]','[number]','[post_title]'),
     //         array($itemCount, $totalCount, $firstSubject),
     //         $emailChild['subject']);
     // Set Body
     $email_render = $current_email->body;
     // Parse old shortcodes that we are parsing in the queue.
     $find = array('[unsubscribe_linklabel]');
     $replace = array($configM->getValue('unsubscribe_linkname'));
     if (isset($current_email->params['autonl']['articles']['first_subject'])) {
         $find[] = '[post_title]';
         $replace[] = $current_email->params['autonl']['articles']['first_subject'];
     }
     if (isset($current_email->params['autonl']['articles']['total'])) {
         $find[] = '[total]';
         $replace[] = $current_email->params['autonl']['articles']['total'];
     }
     if (isset($current_email->params['autonl']['articles']['ids'])) {
         $find[] = '[number]';
         $replace[] = $current_email->params['autonl']['articles']['ids'];
     }
     $email_render = str_replace($find, $replace, $email_render);
     // Strip unsubscribe links.
     $email_render = $emailH->stripPersonalLinks($email_render);
     do_action('wysija_preview', array(&$this));
     echo $email_render;
     exit;
 }
示例#25
0
/**
 * Get an array of MailPoet lists
 *
 * @return mixed
 */
function wpcf7_mailpoetsignup_get_lists()
{
    // make sure we have the class loaded
    if (!class_exists('WYSIJA')) {
        return;
    }
    // get MailPoet / Wysija lists
    $model_list = WYSIJA::get('list', 'model');
    $mailpoet_lists = $model_list->get(array('name', 'list_id'), array('is_enabled' => 1));
    return $mailpoet_lists;
}
示例#26
0
 /**
  * Render a typical link
  * @param type $html_content
  * @param type $link
  * @param string $max_link_length if the link exceeds to max_link_length, cut it off
  * @param string $sub_string_length if the link exceeds to max_link_length, cut it off and keep a substring of $sub_string_length characters
  * @param boolean $is_full_link if true, show full link, if no, show truncated link
  * @param string $default_html if this is defined, we will use this value instead.
  * @return < a > rendered tag
  */
 public function render_link($html_content, $link, $max_link_length = 50, $sub_string_length = 15, $is_full_link = false, $default_html = NULL)
 {
     if (!empty($default_html) && is_string($default_html)) {
         return $default_html;
     }
     $link = $link;
     // not in use
     $helper_licence = WYSIJA::get('licence', 'helper');
     $url_checkout = $helper_licence->get_url_checkout('count_click_stats');
     $html_content .= str_replace(array('[link]', '[/link]'), array('<a title="' . __('Get Premium now', WYSIJA) . '" target="_blank" href="' . $url_checkout . '">', '</a>'), __("Get [link]MailPoet Premium[/link] to see the link.", WYSIJA));
     return $html_content;
 }
示例#27
0
 function comment_posted($cid, $comment)
 {
     $cid = (int) $cid;
     if (!is_object($comment)) {
         $comment = get_comment($cid);
     }
     if ($comment->comment_karma == 0 && isset($_POST['wysija']['comment_subscribe']) && $_POST['wysija']['comment_subscribe']) {
         $mConfig =& WYSIJA::get('config', 'model');
         $userHelper =& WYSIJA::get('user', 'helper');
         $data = array('user' => array('email' => $comment->comment_author_email, 'firstname' => $comment->comment_author), 'user_list' => array('list_ids' => $mConfig->getValue('commentform_lists')));
         $userHelper->addSubscriber($data);
     }
 }
/**
 * This process the customers subscription if any 
 * to the newsletters along with their order.
 */
function on_process_order()
{
    global $woocommerce;
    $mailpoet_checkout_subscribe = isset($_POST['mailpoet_checkout_subscribe']) ? 1 : 0;
    // If the check box has been ticked then the customer is added to the MailPoet lists enabled.
    if ($mailpoet_checkout_subscribe == 1) {
        $checkout_lists = get_option('mailpoet_woocommerce_subscribe_too');
        $user_data = array('email' => $_POST['billing_email'], 'firstname' => $_POST['billing_first_name'], 'lastname' => $_POST['billing_last_name']);
        $data_subscriber = array('user' => $user_data, 'user_list' => array('list_ids' => $checkout_lists));
        $userHelper =& WYSIJA::get('user', 'helper');
        $userHelper->addSubscriber($data_subscriber);
    }
}
示例#29
0
    public function form($instance)
    {
        $widget_defaults = array('title' => 'Blijf op de hoogte', 'list' => '');
        $instance = wp_parse_args((array) $instance, $widget_defaults);
        $model_list = WYSIJA::get('list', 'model');
        $mailpoet_lists = $model_list->get(array('name', 'list_id'), array('is_enabled' => 1));
        ?>

		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Titel', 'siw');
        ?>
</label>
			<input type="text" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" class="widefat" value="<?php 
        echo esc_attr($instance['title']);
        ?>
">
			<label for="<?php 
        echo $this->get_field_id('list');
        ?>
"><?php 
        _e('Lijst', 'siw');
        ?>
</label>
			<select id="<?php 
        echo $this->get_field_id('list');
        ?>
" name="<?php 
        echo $this->get_field_name('list');
        ?>
" class="widefat">
			<?php 
        foreach ($mailpoet_lists as $list) {
            echo '<option value="', $list['list_id'], '"', $instance['list'] == $list['list_id'] ? ' selected="selected"' : '', '>', $list['name'], '</option>';
        }
        echo '</select>';
        ?>
		</p>

		
		<?php 
    }
示例#30
0
 function addScripts($print = true)
 {
     if ($print) {
         //wp_print_styles('validate-engine-css');
         /*in some case we don't want to have an ajax subscription*/
         $modelC =& WYSIJA::get('config', 'model');
         add_action('wp_footer', array($this, 'printScripts'));
     } else {
         wp_enqueue_script('wysija-validator-lang');
         wp_enqueue_script('wysija-validator');
         wp_enqueue_script('wysija-form');
         wp_enqueue_style('validate-engine-css');
     }
 }