summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitNewsletter.php100
-rw-r--r--admin/schema_inc.php6
-rw-r--r--admin/send.php50
-rw-r--r--edition.php54
-rw-r--r--edition_edit.php51
-rw-r--r--index.php9
-rw-r--r--templates/admin_newsletters.tpl3
-rw-r--r--templates/confirm_newsletter_subscription.tpl3
-rw-r--r--templates/edit_edition.tpl34
-rw-r--r--templates/newsletters.tpl1
-rw-r--r--templates/send_newsletters.tpl34
11 files changed, 206 insertions, 139 deletions
diff --git a/BitNewsletter.php b/BitNewsletter.php
index 1c5cc25..6d4b811 100644
--- a/BitNewsletter.php
+++ b/BitNewsletter.php
@@ -1,12 +1,12 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletter.php,v 1.3 2005/12/09 20:24:55 spiderr Exp $
+ * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletter.php,v 1.4 2005/12/10 22:24:23 spiderr Exp $
*
* Copyright (c) 2004 bitweaver.org
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
- * $Id: BitNewsletter.php,v 1.3 2005/12/09 20:24:55 spiderr Exp $
+ * $Id: BitNewsletter.php,v 1.4 2005/12/10 22:24:23 spiderr Exp $
*
* Virtual base class (as much as one can have such things in PHP) for all
* derived tikiwiki classes that require database access.
@@ -16,7 +16,7 @@
*
* @author drewslater <andrew@andrewslater.com>, spiderr <spider@steelsun.com>
*
- * @version $Revision: 1.3 $ $Date: 2005/12/09 20:24:55 $ $Author: spiderr $
+ * @version $Revision: 1.4 $ $Date: 2005/12/10 22:24:23 $ $Author: spiderr $
*/
/**
@@ -48,7 +48,7 @@ class BitNewsletter extends LibertyContent {
$bindVars = array(); $selectSql = ''; $joinSql = ''; $whereSql = '';
- $lookupColumn = !empty( $this->mNlId )? 'nl_id' : 'content_id';
+ $lookupColumn = !empty( $this->mNlId ) ? 'nl_id' : 'content_id';
$lookupId = !empty( $this->mNlId )? $this->mNlId : $this->mContentId;
array_push( $bindVars, $lookupId );
@@ -98,12 +98,13 @@ class BitNewsletter extends LibertyContent {
return( count( $this->mErrors ) == 0 );
}
- function get_subscribers($nl_id) {
- $query = "select email from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `valid`=? and `nl_id`=?";
- $result = $this->mDb->query($query, array('y',(int)$nl_id));
+ function getSubscribers($nl_id) {
$ret = array();
- while ($res = $result->fetchRow()) {
- $ret[] = $res["email"];
+ if( $this->isValid() ) {
+ $query = "select email from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `valid`=? and `nl_id`=?";
+ if( $result = $this->mDb->query( $query, array( 'y', $this->mNlId ) ) ) {
+ $ret = $res->GetRows();
+ }
}
return $ret;
}
@@ -115,43 +116,46 @@ class BitNewsletter extends LibertyContent {
$this->update_users($nl_id);
}
- function newsletter_subscribe($nl_id, $email) {
- global $gBitSmarty;
- global $user;
- global $sender_email;
- $info = $this->get_newsletter($nl_id);
- $gBitSmarty->assign('info', $info);
- $code = md5( BitUser::genPass() );
- $now = date("U");
- if ($info["validate_addr"] == 'y') {
- // Generate a code and store it and send an email with the
- // URL to confirm the subscription put valid as 'n'
- $foo = parse_url($_SERVER["REQUEST_URI"]);
- $foopath = preg_replace('/tiki-admin_newsletter_subscriptions.php/', 'tiki-newsletters.php', $foo["path"]);
- $url_subscribe = httpPrefix(). $foopath;
- $query = "delete from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=? and `email`=?";
- $result = $this->mDb->query($query,array((int)$nl_id,$email));
- $query = "insert into `".BIT_DB_PREFIX."tiki_newsletter_subscriptions`(`nl_id`,`email`,`code`,`valid`,`subscribed`) values(?,?,?,?,?)";
- $result = $this->mDb->query($query,array((int)$nl_id,$email,$code,'n',(int)$now));
- // Now send an email to the address with the confirmation instructions
- $gBitSmarty->assign('mail_date', date("U"));
- $gBitSmarty->assign('mail_user', $user);
- $gBitSmarty->assign('code', $code);
- $gBitSmarty->assign('url_subscribe', $url_subscribe);
- $gBitSmarty->assign('server_name', $_SERVER["SERVER_NAME"]);
- $mail_data = $gBitSmarty->fetch('bitpackage:newsletters/confirm_newsletter_subscription.tpl');
- @mail($email, tra('Newsletter subscription information at '). $_SERVER["SERVER_NAME"], $mail_data,
- "From: $sender_email\r\nContent-type: text/plain;charset=utf-8\r\n");
- } else {
- $query = "delete from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=? and `email`=?";
- $result = $this->mDb->query($query,array((int)$nl_id,$email));
- $query = "insert into `".BIT_DB_PREFIX."tiki_newsletter_subscriptions`(`nl_id`,`email`,`code`,`valid`,`subscribed`) values(?,?,?,?,?)";
- $result = $this->mDb->query($query,array((int)$nl_id,$email,$code,'y',(int)$now));
+ function subscribe( $email ) {
+ $ret = FALSE;
+ if( $this->isValid() ) {
+ global $gBitSmarty;
+ global $gBitUser;
+
+ $code = md5( BitUser::genPass() );
+ $now = date("U");
+ if( $this->getField( 'validate_addr' ) == 'y' ) {
+ // Generate a code and store it and send an email with the
+ // URL to confirm the subscription put valid as 'n'
+ $foo = parse_url($_SERVER["REQUEST_URI"]);
+ $foopath = preg_replace('/tiki-admin_newsletter_subscriptions.php/', 'tiki-newsletters.php', $foo["path"]);
+ $url_subscribe = httpPrefix(). $foopath;
+ $query = "delete from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=? and `email`=?";
+ $result = $this->mDb->query( $query, array( $this->mNlId, $email ) );
+ $query = "insert into `".BIT_DB_PREFIX."tiki_newsletter_subscriptions`(`nl_id`,`email`,`code`,`valid`,`subscribed`) values(?,?,?,?,?)";
+ $result = $this->mDb->query( $query, array( $this->mNlId, $email, $code, 'n', (int)$now ) );
+ // Now send an email to the address with the confirmation instructions
+ $gBitSmarty->assign( 'mail_date', date("U") );
+ $gBitSmarty->assign( 'mail_user', $email );
+ $gBitSmarty->assign( 'code', $code );
+ $gBitSmarty->assign( 'url_subscribe', $url_subscribe );
+ $gBitSmarty->assign( 'server_name', $_SERVER["SERVER_NAME"] );
+ $mail_data = $gBitSmarty->fetch('bitpackage:newsletters/confirm_newsletter_subscription.tpl');
+ @mail($email, tra('Newsletter subscription information at '). $_SERVER["SERVER_NAME"], $mail_data,
+ "From: $sender_email\r\nContent-type: text/plain;charset=utf-8\r\n");
+ } else {
+ $query = "delete from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=? and `email`=?";
+ $result = $this->mDb->query( $query, array( $this->mNlId, $email ) );
+ $query = "insert into `".BIT_DB_PREFIX."tiki_newsletter_subscriptions`(`nl_id`,`email`,`code`,`valid`,`subscribed`) values(?,?,?,?,?)";
+ $result = $this->mDb->query( $query, array( $this->mNlId, $email, $code, 'y', (int)$now ) );
+ }
+ $this->updateUsers();
+ $ret = TRUE;
}
- $this->update_users($nl_id);
+ return $ret;
}
- function confirm_subscription($code) {
+ function confirmSubscription($code) {
global $gBitSmarty;
global $user;
global $sender_email;
@@ -217,10 +221,12 @@ class BitNewsletter extends LibertyContent {
}
}
- function update_users($nl_id) {
- $users = $this->mDb->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=?",array((int)$nl_id));
- $query = "update `".BIT_DB_PREFIX."tiki_newsletters` set `users`=? where `nl_id`=?";
- $result = $this->mDb->query($query,array($users,(int)$nl_id));
+ function updateUsers() {
+ if( $this->isValid() ) {
+ $users = $this->mDb->getOne( "select count(*) from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=?", array( $this->mNlId ) );
+ $query = "update `".BIT_DB_PREFIX."tiki_newsletters` set `users`=? where `nl_id`=?";
+ $result = $this->mDb->query( $query, array( $users, $this->mNlId ) );
+ }
}
function getList( &$pListHash ) {
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 25d3f7a..0236724 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -19,11 +19,11 @@ $tables = array(
'tiki_newsletter_subscriptions' => "
nl_id I4 PRIMARY,
email C(160) PRIMARY,
+ user_id I4,
code C(32),
valid C(1),
- subscribed I8,
- user_id I4,
- group_id I4 NOTNULL PRIMARY
+ subscribed_date I8,
+ unsubscribed_date I8
CONSTRAINTS ', CONSTRAINT `tiki_nl_sub_nl_ref` FOREIGN KEY (`nl_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters`( `nl_id` ),
, CONSTRAINT `tiki_nl_group_ref` FOREIGN KEY (`group_id`) REFERENCES `".BIT_DB_PREFIX."users_groups`( `group_id` )'
",
diff --git a/admin/send.php b/admin/send.php
index 198a94f..28fc6a3 100644
--- a/admin/send.php
+++ b/admin/send.php
@@ -1,6 +1,6 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.3 2005/12/09 20:36:57 spiderr Exp $
+// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.4 2005/12/10 22:24:23 spiderr Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
@@ -13,28 +13,8 @@ include_once( UTIL_PKG_PATH.'htmlMimeMail.php' );
$gBitSystem->verifyPackage( 'newsletters' );
-
require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_edition_inc.php' );
-$listHash = array();
-$newsletters = $gContent->mNewsletter->getList( $listHash );
-$gBitSmarty->assign( 'newsletters', $newsletters );
-
-if (isset($_REQUEST["remove"] ) && $gContent->isValid() ) {
- if( !empty( $_REQUEST['cancel'] ) ) {
- // user cancelled - just continue on, doing nothing
- } elseif( empty( $_REQUEST['confirm'] ) ) {
- $formHash['remove'] = TRUE;
- $formHash['edition_id'] = $gContent->mEditionId;
- $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to delete the newsletter edition '.$gContent->getTitle().'?' ) );
- } else {
- if( $gContent->expunge() ) {
- header( "Location: ".NEWSLETTERS_PKG_URL.'admin/' );
- die;
- }
- }
-}
-
if (isset($_REQUEST["template_id"]) && $_REQUEST["template_id"] > 0) {
$template_data = $tikilib->get_template($_REQUEST["template_id"]);
@@ -43,32 +23,7 @@ if (isset($_REQUEST["template_id"]) && $_REQUEST["template_id"] > 0) {
}
$gBitSmarty->assign('preview', 'n');
-
-if (isset($_REQUEST["preview"])) {
- $gBitSmarty->assign('preview', 'y');
-
- //$parsed = $tikilib->parse_data($_REQUEST["content"]);
- $parsed = $_REQUEST["edit"];
- $gBitSmarty->assign('parsed', $parsed);
- $info["data"] = $_REQUEST['edit'];
- $info["subject"] = $_REQUEST['title'];
- $gBitSmarty->assign('info', $info);
-}
-
$gBitSmarty->assign('presend', 'n');
-
-if (isset($_REQUEST["save"])) {
- // Now send the newsletter to all the email addresses and save it in sent_newsletters
- $gBitSmarty->assign('presend', 'y');
-
- $subscribers = $nllib->get_subscribers($_REQUEST["nl_id"]);
- $gBitSmarty->assign('nl_id', $_REQUEST["nl_id"]);
- $gBitSmarty->assign('edit', $_REQUEST['edit']);
- $gBitSmarty->assign('subject', $_REQUEST['title']);
- $cant = count($subscribers);
- $gBitSmarty->assign('subscribers', $cant);
-}
-
$gBitSmarty->assign('emited', 'n');
if (isset($_REQUEST["send"])) {
@@ -103,9 +58,8 @@ if (isset($_REQUEST["send"])) {
$nllib->replace_edition($_REQUEST["nl_id"], $_REQUEST['title'], $_REQUEST['edit'], $sent);
}
-$gEdition = new BitNewsletterEdition();
$listHash = array();
-$editions = $gEdition->getList( $listHash );
+$editions = $gContent->getList( $listHash );
$gBitSmarty->assign_by_ref( 'editions', $editions );
$gBitSmarty->assign( 'listInfo', $listHash );
diff --git a/edition.php b/edition.php
new file mode 100644
index 0000000..655da4b
--- /dev/null
+++ b/edition.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ *
+ * Copyright (c) 2005 bitweaver.org
+ * All Rights Reserved. See copyright.txt for details and a complete list of authors.
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+ *
+ * created 2005/12/10
+ *
+ * @author spider <spider@steelsun.com>
+ */
+
+// Initialization
+require_once( '../bit_setup_inc.php' );
+include_once( NEWSLETTERS_PKG_PATH.'nl_lib.php' );
+include_once( UTIL_PKG_PATH.'htmlMimeMail.php' );
+
+$gBitSystem->verifyPackage( 'newsletters' );
+
+require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_edition_inc.php' );
+
+$listHash = array();
+$newsletters = $gContent->mNewsletter->getList( $listHash );
+$gBitSmarty->assign( 'newsletters', $newsletters );
+
+if (isset($_REQUEST["remove"] ) && $gContent->isValid() ) {
+ if( !empty( $_REQUEST['cancel'] ) ) {
+ // user cancelled - just continue on, doing nothing
+ } elseif( empty( $_REQUEST['confirm'] ) ) {
+ $formHash['remove'] = TRUE;
+ $formHash['edition_id'] = $gContent->mEditionId;
+ $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to delete the newsletter edition '.$gContent->getTitle().'?' ) );
+ } else {
+ if( $gContent->expunge() ) {
+ header( "Location: ".NEWSLETTERS_PKG_URL.'edition.php' );
+ die;
+ }
+ }
+}
+
+if( $gContent->isValid() ) {
+ $mid = 'bitpackage:bitcommerce/view_edition.tpl';
+} else {
+ $listHash = array();
+ $editions = $gContent->getList( $listHash );
+ $gBitSmarty->assign_by_ref( 'editions', $editions );
+ $gBitSmarty->assign( 'listInfo', $listHash );
+ $mid = 'bitpackage:bitcommerce/list_editions.tpl';
+}
+
+// Display the template
+$gBitSystem->display( $mid );
+
+?> \ No newline at end of file
diff --git a/edition_edit.php b/edition_edit.php
new file mode 100644
index 0000000..b7360ca
--- /dev/null
+++ b/edition_edit.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ *
+ * Copyright (c) 2005 bitweaver.org
+ * All Rights Reserved. See copyright.txt for details and a complete list of authors.
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+ *
+ * created 2005/12/10
+ *
+ * @author spider <spider@steelsun.com>
+ */
+
+// Initialization
+require_once( '../bit_setup_inc.php' );
+include_once( NEWSLETTERS_PKG_PATH.'nl_lib.php' );
+include_once( UTIL_PKG_PATH.'htmlMimeMail.php' );
+
+$gBitSystem->verifyPackage( 'newsletters' );
+
+require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_edition_inc.php' );
+
+$listHash = array();
+$newsletters = $gContent->mNewsletter->getList( $listHash );
+$gBitSmarty->assign( 'newsletters', $newsletters );
+
+if (isset($_REQUEST["preview"])) {
+ $gBitSmarty->assign('preview', 'y');
+
+ //$parsed = $tikilib->parse_data($_REQUEST["content"]);
+ $parsed = $_REQUEST["edit"];
+ $gBitSmarty->assign('parsed', $parsed);
+ $info["data"] = $_REQUEST['edit'];
+ $info["subject"] = $_REQUEST['title'];
+ $gBitSmarty->assign('info', $info);
+} elseif (isset($_REQUEST["save"])) {
+ // Now send the newsletter to all the email addresses and save it in sent_newsletters
+ $gBitSmarty->assign('presend', 'y');
+
+ $subscribers = $nllib->get_subscribers($_REQUEST["nl_id"]);
+ $gBitSmarty->assign('nl_id', $_REQUEST["nl_id"]);
+ $gBitSmarty->assign('edit', $_REQUEST['edit']);
+ $gBitSmarty->assign('subject', $_REQUEST['title']);
+ $cant = count($subscribers);
+ $gBitSmarty->assign('subscribers', $cant);
+}
+
+// Display the template
+$gBitSystem->display( 'bitpackage:newsletters/edit_edition.tpl' );
+
+
+?> \ No newline at end of file
diff --git a/index.php b/index.php
index a7cb951..0ab90ab 100644
--- a/index.php
+++ b/index.php
@@ -1,6 +1,6 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_newsletters/index.php,v 1.5 2005/12/10 02:21:42 spiderr Exp $
+// $Header: /cvsroot/bitweaver/_bit_newsletters/index.php,v 1.6 2005/12/10 22:24:23 spiderr Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
@@ -9,7 +9,6 @@
// Initialization
require_once( '../bit_setup_inc.php' );
-include_once( NEWSLETTERS_PKG_PATH.'nl_lib.php' );
if( $gBitSystem->isPackageActive( 'webmail' ) ) {
include_once( WEBMAIL_PKG_PATH.'htmlMimeMail.php' );
}
@@ -17,14 +16,14 @@ $gBitSystem->verifyPackage( 'newsletters' );
$gBitSmarty->assign('confirm', 'n');
if( isset( $_REQUEST["confirm_subscription"] ) ) {
- if( $conf = $nllib->confirm_subscription( $_REQUEST["confirm_subscription"] ) ) {
+ if( $conf = $gContent->confirmSubscription( $_REQUEST["confirm_subscription"] ) ) {
$gBitSmarty->assign( 'confirm', 'y' );
$gBitSmarty->assign( 'nl_info', $conf );
}
}
if( isset( $_REQUEST["unsubscribe"] ) ) {
- if( $conf = $nllib->unsubscribe( $_REQUEST["unsubscribe"] ) ) {
+ if( $conf = $gContent->unsubscribe( $_REQUEST["unsubscribe"] ) ) {
$feedback['success'] = tra( "Your email address was removed from the list of subscriptors." );
$gBitSmarty->assign('nl_info', $conf);
}
@@ -53,7 +52,7 @@ if( isset( $_REQUEST["subscribe"] ) ) {
}
// Now subscribe the email address to the newsletter
- $nllib->newsletter_subscribe( $_REQUEST["nl_id"], $_REQUEST["email"] );
+ $gContent->subscribe( $_REQUEST["email"] );
}
/* List newsletters */
diff --git a/templates/admin_newsletters.tpl b/templates/admin_newsletters.tpl
index 49cfbcb..0c7e1db 100644
--- a/templates/admin_newsletters.tpl
+++ b/templates/admin_newsletters.tpl
@@ -11,6 +11,7 @@
<a href="{$smarty.const.KERNEL_PKG_URL}object_permissions.php?objectName=newsletter%20{$gContent->mInfo.name}&amp;object_type=newsletter&amp;permType=newsletters&amp;object_id={$gContent->mInfo.nl_id}">{tr}There are individual permissions set for this newsletter{/tr}</a><br /><br />
{/if}
{form legend="Create / Edit Newsletters"}
+ <input type="hidden" name="nl_id" value="{$gContent->mNlId}" />
maybe we could have an option to autosubscribe users to a list when they register with the site.
<div class="row">
{formlabel label="Title" for="title"}
@@ -88,7 +89,7 @@
<td style="text-align:right;"><a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/admin_newsletter_subscriptions.php?nl_id={$nlId}">{$nl.users|default:0} [ {$channels[user].confirmed|default:0} ]</a></td>
<td style="text-align:right;">{$nl.editions|default:0}</td>
<td style="text-align:right;">
- <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/index.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;remove={$nlId}">{biticon ipackage=liberty iname=delete iexplain=Remove}</a>
+ <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/index.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;remove=1&amp;nl_id={$nlId}">{biticon ipackage=liberty iname=delete iexplain=Remove}</a>
<a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/index.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;nl_id={$nlId}">{biticon ipackage=liberty iname=edit iexplain=Edit}</a>
{if $channels[user].individual eq 'y'}({/if}<a href="{$smarty.const.KERNEL_PKG_URL}object_permissions.php?objectName=newsletter%20{$nl.title}&amp;object_type={$smarty.const.BITNEWSLETTER_CONTENT_TYPE_GUID}&amp;permType=newsletters&amp;object_id={$nlId}">{biticon ipackage=liberty iname=permissions iexplain=Permissions}</a>{if $nl.individual eq 'y'}){/if}
</td>
diff --git a/templates/confirm_newsletter_subscription.tpl b/templates/confirm_newsletter_subscription.tpl
index 9c3b462..7144158 100644
--- a/templates/confirm_newsletter_subscription.tpl
+++ b/templates/confirm_newsletter_subscription.tpl
@@ -1,5 +1,6 @@
{tr}Somebody or you tried to subscribe this email address at our site:{/tr} {$server_name}
-{tr}To the newsletter:{/tr} {$info.name}
+
+{tr}To the newsletter:{/tr} {$info.title}
{tr}Description:{/tr}
{$info.description}
diff --git a/templates/edit_edition.tpl b/templates/edit_edition.tpl
new file mode 100644
index 0000000..221cae7
--- /dev/null
+++ b/templates/edit_edition.tpl
@@ -0,0 +1,34 @@
+{if $preview eq 'y'}
+<br />
+<div class="wikibody">{$info.subject}</div>
+<div class="wikibody">{$parsed}</div>
+{/if}
+
+<h2>{tr}Prepare a newsletter to be sent{/tr}</h2>
+<form action="{$smarty.const.NEWSLETTERS_PKG_URL}edition_edit.php" method="post" id='editpageform'>
+<table class="panel">
+<tr><td>{tr}Subject{/tr}:</td><td><input type="text" maxlength="250" size="40" name="title" value="{$info.subject|escape}" /></td></tr>
+<tr><td>{tr}Newsletter{/tr}:</td><td>
+<select name="nl_id">
+{foreach from=$newsletters item=nl key=nlId}
+<option value="{$nlId|escape}" {if $nlId eq $nl_id}selected="selected"{/if}>{$nl.title}</option>
+{/foreach}
+</select>
+</td></tr>
+{if $tiki_p_use_content_templates eq 'y'}
+<tr><td>{tr}Apply template{/tr}</td><td>
+<select name="template_id" onchange="javascript:document.getElementById('editpageform').submit();">
+<option value="0">{tr}none{/tr}</option>
+{section name=ix loop=$templates}
+<option value="{$templates[ix].template_id|escape}">{$templates[ix].name}</option>
+{/section}
+</select>
+</td></tr>
+{/if}
+<tr><td>{tr}Data{/tr}:</td><td><textarea name="edit" rows="25" cols="60">{$info.data|escape}</textarea></td></tr>
+<tr class="panelsubmitrow"><td colspan="2">
+<input type="submit" name="preview" value="{tr}Preview{/tr}" />&nbsp;<input type="submit" name="save" value="{tr}Save Edition{/tr}" />
+</td></tr>
+</table>
+</form>
+
diff --git a/templates/newsletters.tpl b/templates/newsletters.tpl
index 992a391..d5f8368 100644
--- a/templates/newsletters.tpl
+++ b/templates/newsletters.tpl
@@ -27,6 +27,7 @@
{if ($gContent->mInfo.allow_user_sub eq 'y') or $gBitUser->hasPermission( 'bit_p_subscribe_newsletters' )}
{form}
+ <input type="hidden" name="nl_id" value="{$gContent->mNlId}" />
<div class="row">
{formlabel label="Email" for=""}
{forminput}
diff --git a/templates/send_newsletters.tpl b/templates/send_newsletters.tpl
index 22c3449..33c010a 100644
--- a/templates/send_newsletters.tpl
+++ b/templates/send_newsletters.tpl
@@ -18,40 +18,6 @@
<input type="submit" name="preview" value="{tr}cancel{/tr}" />
</form>
{else}
-{if $preview eq 'y'}
-<br />
-<div class="wikibody">{$info.subject}</div>
-<div class="wikibody">{$parsed}</div>
-{/if}
-
-<h2>{tr}Prepare a newsletter to be sent{/tr}</h2>
-<form action="{$smarty.const.NEWSLETTERS_PKG_URL}admin/send.php" method="post" id='editpageform'>
-<table class="panel">
-<tr><td>{tr}Subject{/tr}:</td><td><input type="text" maxlength="250" size="40" name="title" value="{$info.subject|escape}" /></td></tr>
-<tr><td>{tr}Newsletter{/tr}:</td><td>
-<select name="nl_id">
-{foreach from=$newsletters item=nl key=nlId}
-<option value="{$nlId|escape}" {if $nlId eq $nl_id}selected="selected"{/if}>{$nl.title}</option>
-{/foreach}
-</select>
-</td></tr>
-{if $tiki_p_use_content_templates eq 'y'}
-<tr><td>{tr}Apply template{/tr}</td><td>
-<select name="template_id" onchange="javascript:document.getElementById('editpageform').submit();">
-<option value="0">{tr}none{/tr}</option>
-{section name=ix loop=$templates}
-<option value="{$templates[ix].template_id|escape}">{$templates[ix].name}</option>
-{/section}
-</select>
-</td></tr>
-{/if}
-<tr><td>{tr}Data{/tr}:</td><td><textarea name="edit" rows="25" cols="60">{$info.data|escape}</textarea></td></tr>
-<tr class="panelsubmitrow"><td colspan="2">
-<input type="submit" name="preview" value="{tr}Preview{/tr}" />&nbsp;<input type="submit" name="save" value="{tr}Send Newsletters{/tr}" />
-</td></tr>
-</table>
-</form>
-{/if}
<h2>{tr}Sent editions{/tr}</h2>
<table class="find">