Ejemplo n.º 1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->settingsAll = $this->settings->getSettings();
     $this->htmlEmail = isset($this->settingsAll['emailType']['source']) ? $this->settingsAll['emailType']['source'] == 0 ? TRUE : FALSE : TRUE;
     $this->subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
     $this->log = \SimpleSubscribe\RepositoryLog::getInstance();
     $this->mailer = new \Nette\Mail\SendmailMailer();
     $this->senderName = isset($this->settingsAll['misc']['senderName']) ? $this->settingsAll['misc']['senderName'] : html_entity_decode(get_option('blogname'), ENT_QUOTES);
     $this->senderEmail = isset($this->settingsAll['misc']['senderEmail']) ? $this->settingsAll['misc']['senderEmail'] : get_option('admin_email');
 }
Ejemplo n.º 2
0
 /**
  * Unsubscription form
  *
  * @return Nette\Forms\Form
  */
 public static function getUnsubscriptionForm()
 {
     $form = \SimpleSubscribe\Forms::unsubscriptionForm();
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
             $formValues = $form->getValues();
             $subscribers->deleteOrDeactivateByEmail($formValues->email);
             $form->setValues(array(), TRUE);
         } catch (RepositarySubscribersException $e) {
             $form->addError($e->getMessage());
         }
     }
     return $form;
 }
Ejemplo n.º 3
0
 /**
  * Process actions
  */
 public function process()
 {
     if (isset($this->queryVars['a']) && $this->queryVars['a'] == 's') {
         if (isset($this->queryVars['sb']) && !empty($this->queryVars['sb']) && (isset($this->queryVars['i']) && !empty($this->queryVars['i']))) {
             try {
                 $subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
                 $subscribers->validateApiCall($this->queryVars['i'], $this->queryVars['sb']);
                 $subscribers->activateUser($this->queryVars['i']);
                 $this->addMessage('success', 'Congratulations! You\'ve successfully subscribed!');
             } catch (RepositarySubscribersException $e) {
                 $this->addMessage('error', $e->getMessage());
             }
         }
     }
     $this->display();
 }
Ejemplo n.º 4
0
 /**
  * Constructor
  */
 public function __construct()
 {
     // admin actions
     add_action('admin_init', array($this, 'adminInit'));
     add_action('admin_menu', array($this, 'adminMenu'));
     add_action('admin_notices', array($this, 'adminNotices'));
     add_action('admin_enqueue_scripts', function () {
         wp_enqueue_style('core', SUBSCRIBE_ASSETS . 'styleAdmin.css', null, '2.0');
         wp_enqueue_script('netteForms', SUBSCRIBE_ASSETS . 'netteForms.js', array(), '1.0.0');
     });
     // settings & forms
     $this->settings = new \SimpleSubscribe\Settings(SUBSCRIBE_KEY);
     $this->subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
     $this->log = \SimpleSubscribe\RepositoryLog::getInstance();
     $this->email = \SimpleSubscribe\Email::getInstance();
     $this->formSettings = \SimpleSubscribe\Forms::settings($this->settings->getSettings());
     $this->formEmailTemplate = \SimpleSubscribe\Forms::emailTemplate($this->settings->getSettings());
     $this->formEmail = \SimpleSubscribe\Forms::email($_GET);
     $this->formSubscriber = \SimpleSubscribe\Forms::subscribeAdmin($this->settings->getTableColumns());
     $this->formSubscriberWp = \SimpleSubscribe\Forms::subscribeAdminWp($this->subscribers->getAllRegisteredInactive());
     $this->formEmailPreview = \SimpleSubscribe\Forms::emailPreview();
 }
Ejemplo n.º 5
0
 /**
  * Unsubscription form
  *
  * @param bool $widget
  * @param array $args
  * @return Nette\Templating\FileTemplate
  */
 public static function unsubscriptionForm($widget = FALSE, $args = array())
 {
     $widgetMessage = '';
     $widgetTitle = isset($args['title']) && !empty($args['title']) ? $args['title'] : 'Unsubscribe';
     $widgetId = isset($args['widget_id']) ? $args['widget_id'] : NULL;
     $form = \SimpleSubscribe\Forms::unsubscriptionForm($widget, $widgetId);
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
             $formValues = $form->getValues();
             $subscribers->deleteOrDeactivateByEmail($formValues->email);
             $widgetMessage = '<strong>You have successfully unsubscribed. We\'re sorry to see you leave!</strong>';
             $form = '';
         } catch (RepositarySubscribersException $e) {
             $form->addError($e->getMessage());
         }
     }
     if ($widget) {
         // defaults
         $defaults = array('beforeWidget' => $args['before_widget'], 'beforeTitle' => $args['before_title'], 'afterTitle' => $args['after_title'], 'widgetTitle' => $widgetTitle, 'message' => $widgetMessage, 'guts' => $form, 'afterWidget' => $args['after_widget']);
         // template
         $template = new \SimpleSubscribe\Template('widget.latte');
         $template->prepareTemplate($defaults);
     } else {
         // defaults
         $defaults = array('title' => 'Unsubscribe', 'message' => $widgetMessage, 'guts' => $form);
         // template
         $template = new \SimpleSubscribe\Template('shortcode.latte');
         $template->prepareTemplate($defaults);
     }
     return $template->getTemplate();
 }
Ejemplo n.º 6
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
     $this->columnHeaders = $this->subscribers->getColumnHeaders();
 }