summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/index.php66
-rw-r--r--admin/schema_inc.php48
2 files changed, 34 insertions, 80 deletions
diff --git a/admin/index.php b/admin/index.php
index 5a98885..45508fa 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,6 +1,6 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/Attic/index.php,v 1.3 2005/12/09 07:07:05 spiderr Exp $
+// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/Attic/index.php,v 1.4 2005/12/09 18:51:22 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.
@@ -14,51 +14,12 @@ $gBitSystem->verifyPermission( 'tiki_p_admin_newsletters' );
require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_inc.php' );
-if ($_REQUEST["nl_id"]) {
- $info = $nllib->get_newsletter($_REQUEST["nl_id"]);
-} else {
- $info = array();
-
- $info["name"] = '';
- $info["description"] = '';
- $info["allow_user_sub"] = 'y';
- $info["allow_any_sub"] = 'n';
- $info["unsub_msg"] = 'y';
- $info["validate_addr"] = 'y';
-}
-
-$gBitSmarty->assign('info', $info);
-
if (isset($_REQUEST["remove"])) {
$nllib->remove_newsletter($_REQUEST["remove"]);
}
if (isset($_REQUEST["save"])) {
- if (isset($_REQUEST["allow_user_sub"]) && $_REQUEST["allow_user_sub"] == 'on') {
- $_REQUEST["allow_user_sub"] = 'y';
- } else {
- $_REQUEST["allow_user_sub"] = 'n';
- }
-
- if (isset($_REQUEST["allow_any_sub"]) && $_REQUEST["allow_any_sub"] == 'on') {
- $_REQUEST["allow_any_sub"] = 'y';
- } else {
- $_REQUEST["allow_any_sub"] = 'n';
- }
-
- if (isset($_REQUEST["unsub_msg"]) && $_REQUEST["unsub_msg"] == 'on') {
- $_REQUEST["unsub_msg"] = 'y';
- } else {
- $_REQUEST["unsub_msg"] = 'n';
- }
-
- if (isset($_REQUEST["validate_addr"]) && $_REQUEST["validate_addr"] == 'on') {
- $_REQUEST["validate_addr"] = 'y';
- } else {
- $_REQUEST["validate_addr"] = 'n';
- }
-
- $sid = $nllib->replace_newsletter($_REQUEST["nl_id"], $_REQUEST["name"], $_REQUEST["description"], $_REQUEST["allow_user_sub"], $_REQUEST["allow_any_sub"], $_REQUEST["unsub_msg"], $_REQUEST["validate_addr"]);
+ $sid = $gContent->store( $_REQUEST );
/*
$cat_type='newsletter';
$cat_objid = $sid;
@@ -78,26 +39,9 @@ if (isset($_REQUEST["save"])) {
$gBitSmarty->assign('info', $info);
}
-$channels = $nllib->getList( $listHash );
-
-$cant_pages = ceil( $channels["cant"] / $listHash['max_records'] );
-$gBitSmarty->assign_by_ref('cant_pages', $cant_pages);
-$gBitSmarty->assign( 'actual_page', 1 + ( $listHash['offset'] / $listHash['max_records'] ) );
-
-if( $channels["cant"] > ( $listHash['offset'] + $listHash['max_records'] ) ) {
- $gBitSmarty->assign( 'next_offset', $offset + $listHash['max_records'] );
-} else {
- $gBitSmarty->assign('next_offset', -1);
-}
-
-// If offset is > 0 then prev_offset
-if( $listHash['offset'] > 0) {
- $gBitSmarty->assign('prev_offset', $listHash['offset'] - $listHash['max_records']);
-} else {
- $gBitSmarty->assign('prev_offset', -1);
-}
-
-$gBitSmarty->assign_by_ref('channels', $channels["data"]);
+$newsletters = $gContent->getList( $listHash );
+$gBitSmarty->assign_by_ref( 'newsletters', $newsletters );
+$gBitSmarty->assign_by_ref( 'listInfo', $listHash );
// Fill array with possible number of questions per page
/*
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 104076f..25d3f7a 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -4,9 +4,7 @@ $tables = array(
'tiki_newsletters' => "
nl_id I4 AUTO PRIMARY,
- name C(200),
- description X,
- created I8,
+ content_id I4 NOTNULL,
last_sent I8,
editions I8,
users I8,
@@ -15,6 +13,7 @@ $tables = array(
unsub_msg C(1) default 'y',
validate_addr C(1) default 'y',
frequency I8
+ CONSTRAINTS ', CONSTRAINT `tiki_nl_ed_con_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )'
",
'tiki_newsletter_subscriptions' => "
@@ -23,26 +22,35 @@ $tables = array(
code C(32),
valid C(1),
subscribed I8,
- is_user C(1) NOTNULL default 'n'
- CONSTRAINTS ', CONSTRAINT `tiki_nl_sub_nl_id_ref` FOREIGN KEY (`nl_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters`( `nl_id` )'
+ user_id I4,
+ group_id I4 NOTNULL PRIMARY
+ 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` )'
",
-'tiki_sent_newsletters' => "
+'tiki_newsletters_editions' => "
edition_id I4 AUTO PRIMARY,
nl_id I4 NOTNULL,
- users I8,
- sent I8,
- subject C(200),
- data X
- CONSTRAINTS ', CONSTRAINT `tiki_nl_sent_nl_id_ref` FOREIGN KEY (`nl_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters`( `nl_id` )'
+ content_id I4 NOTNULL
+ CONSTRAINTS ', CONSTRAINT `tiki_nl_ed_nl_ref` FOREIGN KEY (`nl_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters`( `nl_id` )
+ , CONSTRAINT `tiki_nl_ed_con_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )'
+",
+
+'tiki_newsletters_mailings' => "
+ edition_id I4 NOTNULL,
+ queue_date I8,
+ send_date I8,
+ emails_sent I8
+ CONSTRAINTS ', CONSTRAINT `tiki_nl_mail_ed_ref` FOREIGN KEY (`edition_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters_editions`( `edition_id` )'
",
-'tiki_newsletter_groups_map' => "
- nl_id I4 NOTNULL PRIMARY,
- group_id I4 NOTNULL PRIMARY,
- code C(32)
- CONSTRAINTS ', CONSTRAINT `tiki_nl_groups_nl_id_ref` FOREIGN KEY (`nl_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters`( `nl_id` ),
- , CONSTRAINT `tiki_nl_groups_id_ref` FOREIGN KEY (`group_id`) REFERENCES `".BIT_DB_PREFIX."users_groups`( `group_id` )'
+'tiki_newsletters_mailings_queue' => "
+ edition_id I4 PRIMARY,
+ email C(160) PRIMARY,
+ user_id C(1),
+ sent_date I8
+ CONSTRAINTS ', CONSTRAINT `tiki_nl_mailq_ed_ref` FOREIGN KEY (`edition_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters_editions`( `edition_id` ),
+ , CONSTRAINT `tiki_nl_mailq_user_ref` FOREIGN KEY (`users_id`) REFERENCES `".BIT_DB_PREFIX."users_users`( `users_id` )'
"
);
@@ -64,10 +72,12 @@ $gBitInstaller->registerPackageInfo( NEWSLETTERS_PKG_NAME, array(
// ### Indexes
$indices = array (
'tiki_nl_sub_nl_idx' => array( 'table' => 'tiki_newsletter_subscriptions', 'cols' => 'nl_id', 'opts' => NULL ),
+ 'tiki_nl_sub_group_idx' => array( 'table' => 'tiki_newsletter_subscriptions', 'cols' => 'group_id', 'opts' => NULL ),
'tiki_nl_sub_email_idx' => array( 'table' => 'tiki_newsletter_subscriptions', 'cols' => 'email', 'opts' => NULL ),
- 'tiki_nl_sent_nl_idx' => array( 'table' => 'tiki_sent_newsletters', 'cols' => 'nl_id', 'opts' => NULL ),
- 'tiki_nl_group_idx' => array( 'table' => 'tiki_newsletter_groups', 'cols' => 'group_id', 'opts' => NULL ),
+ 'tiki_nl_ed_nl_idx' => array( 'table' => 'tiki_newsletters_editions', 'cols' => 'nl_id', 'opts' => NULL ),
'tiki_nl_group_nl_idx' => array( 'table' => 'tiki_newsletter_groups', 'cols' => 'nl_id', 'opts' => NULL ),
+ 'tiki_nl_mq_email_idx' => array( 'table' => 'tiki_newsletters_mailings_queue', 'cols' => 'email', 'opts' => NULL ),
+ 'tiki_nl_mq_sent_idx' => array( 'table' => 'tiki_newsletters_mailings_queue', 'cols' => 'sent_date', 'opts' => NULL ),
);
$gBitInstaller->registerSchemaIndexes( LIBERTY_PKG_NAME, $indices );