}
}
- return new NLIssue($id, &$this);
+ return new NLIssue($id, $this);
}
/** Create a new, empty, pending newsletter issue
/** 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';
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';
return 'epletter/admin';
default:
// Don't display groups NLs on X.org
- assert(false);
+ assert(!$enforce_xnet);
}
}
WHERE id = {?}',
$this->id);
if ($success) {
+ global $globals;
+ $mailer = new PlMailer('newsletter/notify_scheduled.mail.tpl');
+ $mailer->assign('issue', $this);
+ $mailer->assign('base', $globals->baseurl);
+ $mailer->send();
$this->refresh();
}
return $success;
{
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();
}
/** Save an article
- * @p &$a A reference to a NLArticle object (will be modified once saved)
+ * @p $a A reference to a NLArticle object (will be modified once saved)
*/
- public function saveArticle(&$a)
+ public function saveArticle($a)
{
$this->fetchArticles();
* @p $page Smarty object
* @return Either 'true' (if CSS was added to a page) or the raw CSS to add (when $page is null)
*/
- public function css(&$page = null)
+ public function css($page = null)
{
if (!is_null($page)) {
$page->addCssLink($this->nl->cssFile());
* @p $page Smarty object (using the $this->nl->tplFile() template)
* @p $user User to use when rendering the template
*/
- public function toText(&$page, $user)
+ public function toText($page, $user)
{
$this->fetchArticles();
* @p $page Smarty object (using the $this->nl->tplFile() template)
* @p $user User to use when rendering the template
*/
- public function toHtml(&$page, $user)
+ public function toHtml($page, $user)
{
$this->fetchArticles();
/** Set all 'common' data for the page (those which are required for both web and email rendering)
* @p $smarty Smarty object (e.g page) which should be filled
*/
- protected function assignData(&$smarty)
+ protected function assignData($smarty)
{
$this->fetchArticles();
// }}}
// {{{ Mailing
-
+
+ /** Check whether this issue is empty
+ * An issue is empty if the email has no title (or the default one), or no articles and an empty head.
+ */
+ public function isEmpty()
+ {
+ 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.
*/
public function getSendBeforeDate()
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);
+ $uf = new UserFilter($ufc, array(new UFO_IsAdmin(), new UFO_Uid()));
$limit = new PlLimit(self::BATCH_SIZE);
while (true) {