Fixes registration and promo addition.
[platal.git] / include / newsletter.inc.php
index 3df810f..667099c 100644 (file)
@@ -433,7 +433,7 @@ class NewsLetter
     /** Get the prefix leading to the page for this NL
      * Only X.org / AX / X groups may be seen on X.org.
      */
-    public function prefix()
+    public function prefix($enforce_xnet=true)
     {
         if (!empty($GLOBALS['IS_XNET_SITE'])) {
             return $this->group . '/nl';
@@ -447,13 +447,13 @@ class NewsLetter
             return 'epletter';
         default:
             // Don't display groups NLs on X.org
-            assert(false);
+            assert(!$enforce_xnet);
         }
     }
 
     /** Get the prefix to use for all 'admin' pages of this NL.
      */
-    public function adminPrefix()
+    public function adminPrefix($enforce_xnet=true)
     {
         if (!empty($GLOBALS['IS_XNET_SITE'])) {
             return $this->group . '/admin/nl';
@@ -467,7 +467,7 @@ class NewsLetter
             return 'epletter/admin';
         default:
             // Don't display groups NLs on X.org
-            assert(false);
+            assert(!$enforce_xnet);
         }
     }
 
@@ -668,11 +668,8 @@ class NLIssue
             if ($success) {
                 global $globals;
                 $mailer = new PlMailer('newsletter/notify_scheduled.mail.tpl');
-                $mailer->assign('group', $this->nl->group);
-                $mailer->assign('nl_title', $this->title_mail);
-                $mailer->assign('nl_id', $this->id());
+                $mailer->assign('issue', $this);
                 $mailer->assign('base', $globals->baseurl);
-                $mailer->assign('send_before', $this->send_before);
                 $mailer->send();
                 $this->refresh();
             }
@@ -689,7 +686,7 @@ class NLIssue
     {
         if ($this->state == self::STATE_PENDING) {
             $success = XDB::execute('UPDATE  newsletter_issues
-                                        SET  send_before = NULL, state = \'new\'
+                                        SET  state = \'new\'
                                       WHERE  id = {?}', $this->id);
             if ($success) {
                 $this->refresh();
@@ -999,7 +996,7 @@ class NLIssue
      */
     public function isEmpty()
     {
-        return $this->mail_title == '' || $this->mail_title == 'to be continued' || (count($this->arts == 0 && strlen($this->head) == 0));
+        return $this->title_mail == '' || $this->title_mail == 'to be continued' || (count($this->arts) == 0 && strlen($this->head) == 0);
     }
 
     /** Retrieve the 'Send before' date, in a clean format.
@@ -1093,7 +1090,7 @@ class NLIssue
                        WHERE  id = {?}',
                        $this->id);
 
-        $ufc = new PFC_And($this->getRecipientsUFC(), new UFC_NLSubscribed($this->nl->id, $this->id), new UFC_HasEmailRedirect());
+        $ufc = new PFC_And($this->getRecipientsUFC(), new UFC_NLSubscribed($this->nl->id, $this->id), new UFC_HasValidEmail());
         $emailsCount = 0;
         $uf = new UserFilter($ufc, array(new UFO_IsAdmin(), new UFO_Uid()));
         $limit = new PlLimit(self::BATCH_SIZE);