summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Fowler <spider@viovio.com>2005-12-10 22:39:53 +0000
committerChristian Fowler <spider@viovio.com>2005-12-10 22:39:53 +0000
commit33f69c13d225e4e689c73076c118604005a9498a (patch)
tree50e06129b067d2a9a9a9f7d151905e4a04a3fea5
parent34a8fac038f903976d5696a1e2cdaad2100232ca (diff)
downloadnewsletters-33f69c13d225e4e689c73076c118604005a9498a.tar.gz
newsletters-33f69c13d225e4e689c73076c118604005a9498a.tar.bz2
newsletters-33f69c13d225e4e689c73076c118604005a9498a.zip
edition store now working
-rw-r--r--BitNewsletterEdition.php37
-rw-r--r--edition_edit.php15
2 files changed, 36 insertions, 16 deletions
diff --git a/BitNewsletterEdition.php b/BitNewsletterEdition.php
index 999aa41..fd03be4 100644
--- a/BitNewsletterEdition.php
+++ b/BitNewsletterEdition.php
@@ -1,12 +1,12 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletterEdition.php,v 1.1 2005/12/09 20:24:55 spiderr Exp $
+ * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletterEdition.php,v 1.2 2005/12/10 22:39:53 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: BitNewsletterEdition.php,v 1.1 2005/12/09 20:24:55 spiderr Exp $
+ * $Id: BitNewsletterEdition.php,v 1.2 2005/12/10 22:39:53 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.1 $ $Date: 2005/12/09 20:24:55 $ $Author: spiderr $
+ * @version $Revision: 1.2 $ $Date: 2005/12/10 22:39:53 $ $Author: spiderr $
*/
/**
@@ -44,10 +44,31 @@ class BitNewsletterEdition extends LibertyContent {
$this->mNewsletter = new BitNewsletter( $pNlId );
}
- function replace_edition($nl_id, $subject, $data, $users) {
- $now = date("U");
- $query = "insert into `".BIT_DB_PREFIX."tiki_newsletters_editions`(`nl_id`,`subject`,`data`,`sent`,`users`) values(?,?,?,?,?)";
- $result = $this->mDb->query($query,array((int)$nl_id,$subject,$data,(int)$now,$users));
+ function verify( &$pParamHash ) {
+ if( !empty( $pParamHash['nl_id'] ) ) {
+ $pParamHash['edition_store']["nl_id"] = $pParamHash['nl_id'];
+ } else {
+ $this->mErrors['nl_id'] = tra( 'No newsletter was selected for this edition.' );
+ }
+ return( count( $this->mErrors ) == 0 );
+ }
+
+ function store( $pParamHash ) {
+ if( $this->verify( $pParamHash ) ) {
+ $this->mDb->StartTrans();
+ if( parent::store( $pParamHash ) ) {
+ if( $this->mEditionId ) {
+ $result = $this->mDb->associateUpdate( BIT_DB_PREFIX."tiki_newsletters_editions", $pParamHash['edition_store'], array ( "name" => "edition_id", "value" => $this->mEditionId ) );
+ } else {
+ $pParamHash['edition_store']['content_id'] = $pParamHash['content_id'];
+ $result = $this->mDb->associateInsert( BIT_DB_PREFIX."tiki_newsletters_editions", $pParamHash['edition_store'] );
+ }
+ $this->mDb->CompleteTrans();
+ } else {
+ $this->mDb->RollbackTrans();
+ }
+ }
+ return( count( $this->mErrors ) == 0 );
}
function load() {
@@ -77,6 +98,8 @@ class BitNewsletterEdition extends LibertyContent {
return( count( $this->mInfo ) );
}
+
+
function getList( &$pListHash ) {
$bindVars = array();
$this->prepGetList( $pListHash );
diff --git a/edition_edit.php b/edition_edit.php
index b7360ca..aa8ea17 100644
--- a/edition_edit.php
+++ b/edition_edit.php
@@ -33,15 +33,12 @@ if (isset($_REQUEST["preview"])) {
$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);
+ if( $gContent->store( $_REQUEST ) ) {
+vd( $gContent->mErrors );
+ $gBitSmarty->assign( 'success', tra( 'Newsletter edition saved' ) );
+ } else {
+ $gBitSmarty->assign( 'errors', $gContent->mErrors );
+ }
}
// Display the template