summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorChristian Fowler <spider@viovio.com>2006-06-19 02:35:20 +0000
committerChristian Fowler <spider@viovio.com>2006-06-19 02:35:20 +0000
commit52c3ae75fe0ce196368b98eebb8cb1509eff953b (patch)
tree6a2337da5afbc6d92950dd52bf6d0fe6ee205056 /admin
parent5e00826a94b5c5143f481c3a444106243384f6bf (diff)
downloadnewsletters-52c3ae75fe0ce196368b98eebb8cb1509eff953b.tar.gz
newsletters-52c3ae75fe0ce196368b98eebb8cb1509eff953b.tar.bz2
newsletters-52c3ae75fe0ce196368b98eebb8cb1509eff953b.zip
merge all of wolffies changes to HEAD. Now need to work on a few things like user_id in mail_subs table, etc.
Diffstat (limited to 'admin')
-rw-r--r--admin/admin_newsletter_subscriptions.php85
-rw-r--r--admin/admin_newsletters.php68
-rw-r--r--admin/admin_newsletters_inc.php4
-rw-r--r--admin/schema_inc.php11
-rw-r--r--admin/send.php31
-rw-r--r--admin/tend_mail_queue.php8
-rw-r--r--admin/upgrade_inc.php4
7 files changed, 175 insertions, 36 deletions
diff --git a/admin/admin_newsletter_subscriptions.php b/admin/admin_newsletter_subscriptions.php
index e9058aa..8c83c16 100644
--- a/admin/admin_newsletter_subscriptions.php
+++ b/admin/admin_newsletter_subscriptions.php
@@ -1,6 +1,6 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/admin_newsletter_subscriptions.php,v 1.4 2006/04/20 16:24:47 squareing Exp $
+// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/admin_newsletter_subscriptions.php,v 1.5 2006/06/19 02:35:19 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.
@@ -36,22 +36,79 @@ if ($userlib->object_has_one_permission($_REQUEST["nl_id"], 'newsletter')) {
}
}
*/
+if( $gContent->isValid() ) {
+ $nl_id = $_REQUEST['nl_id'];
+ $gBitSmarty->assign( 'nl_id', $nl_id );
-if (isset($_REQUEST["remove"])) {
- check_ticket('admin-nl-subsriptions');
- $nllib->remove_newsletter_subscription($_REQUEST["remove"], $_REQUEST["email"]);
-}
-
-if (isset($_REQUEST["add_all"])) {
- check_ticket('admin-nl-subsriptions');
- $nllib->add_all_users($_REQUEST["nl_id"]);
-}
+ /* mass-remove:
+ the checkboxes are sent as the array $_REQUEST["checked[]"], values are the wiki-PageNames,
+ e.g. $_REQUEST["checked"][3]="HomePage"
+ $_REQUEST["submit_mult"] holds the value of the "with selected do..."-option list
+ we look if any page's checkbox is on and if remove_pages is selected.
+ then we check permission to delete pages.
+ if so, we call BitPage::expunge for all the checked pages.
+ */
+ if (isset($_REQUEST["submit_mult"]) && isset($_REQUEST["checked"]) && $_REQUEST["submit_mult"] == "remove") {
+ if( !empty( $_REQUEST['cancel'] ) ) {
+ // user cancelled - just continue on, doing nothing
+ } elseif( empty( $_REQUEST['confirm'] ) ) {
+ $formHash['nl_id'] = $nl_id;
+ $formHash['delete'] = TRUE;
+ $formHash['submit_mult'] = 'remove';
+ foreach( $_REQUEST["checked"] as $del ) {
+ $formHash['input'][] = '<input type="hidden" name="checked[]" value="'.$del.'"/>';
+ }
+ $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to delete '.count($_REQUEST["checked"]).' subscriptions?', 'error' => 'This cannot be undone!' ) );
+ } else {
+ foreach ($_REQUEST["checked"] as $delete) {
+ $gContent->removeSubscription($delete, FALSE, TRUE );
+ }
+ }
+ } elseif (isset($_REQUEST["submit_mult"]) && isset($_REQUEST["checked"]) && $_REQUEST["submit_mult"] == "unsubscribe") {
+ if( !empty( $_REQUEST['cancel'] ) ) {
+ // user cancelled - just continue on, doing nothing
+ } elseif( empty( $_REQUEST['confirm'] ) ) {
+ $formHash['nl_id'] = $nl_id;
+ $formHash['delete'] = TRUE;
+ $formHash['submit_mult'] = 'unsubscribe';
+ foreach( $_REQUEST["checked"] as $del ) {
+ $formHash['input'][] = '<input type="hidden" name="checked[]" value="'.$del.'"/>';
+ }
+ $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to unsubscribe '.count($_REQUEST["checked"]).' subscriptions?', 'error' => 'This cannot be undone!' ) );
+ } else {
+ foreach ($_REQUEST["checked"] as $delete) {
+ $gContent->removeSubscription($delete, FALSE, FALSE );
+ }
+ }
+ } elseif (isset($_REQUEST["submit_mult"]) && isset($_REQUEST["checked"]) && $_REQUEST["submit_mult"] == "resubscribe") {
+ if( !empty( $_REQUEST['cancel'] ) ) {
+ // user cancelled - just continue on, doing nothing
+ } elseif( empty( $_REQUEST['confirm'] ) ) {
+ $formHash['nl_id'] = $nl_id;
+ $formHash['delete'] = TRUE;
+ $formHash['submit_mult'] = 'resubscribe';
+ foreach( $_REQUEST["checked"] as $del ) {
+ $formHash['input'][] = '<input type="hidden" name="checked[]" value="'.$del.'"/>';
+ }
+ $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to resubscribe '.count($_REQUEST["checked"]).' subscriptions?', 'error' => 'This cannot be undone!' ) );
+ } else {
+ foreach ($_REQUEST["checked"] as $delete) {
+ $gContent->subscribe($delete, FALSE, FALSE );
+ }
+ }
+ } elseif (isset($_REQUEST["save"])) {
+ $new_subs = preg_split("/[\s,]+/", $_REQUEST["new_subscribers"]);
+ foreach($new_subs as $sub) {
+ $sub = trim($sub);
+ if (empty($sub))
+ continue;
+ $gContent->subscribe($sub, TRUE );
+ }
+ }
-if (isset($_REQUEST["save"])) {
- check_ticket('admin-nl-subsriptions');
- $sid = $nllib->newsletter_subscribe($_REQUEST["nl_id"], $_REQUEST["email"]);
+ $subscribers = $gContent->getAllSubscribers($nl_id);
+ $gBitSmarty->assign( 'subscribers', $subscribers );
}
-
/*
$cat_type='newsletter';
$cat_objid = $_REQUEST["nl_id"];
diff --git a/admin/admin_newsletters.php b/admin/admin_newsletters.php
new file mode 100644
index 0000000..1a59fa6
--- /dev/null
+++ b/admin/admin_newsletters.php
@@ -0,0 +1,68 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/admin_newsletters.php,v 1.2 2006/06/19 02:35:19 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.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
+// Initialization
+require_once( '../../bit_setup_inc.php' );
+$gBitSystem->verifyPackage( 'newsletters' );
+$gBitSystem->verifyPermission( 'p_newsletters_create' );
+
+require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_inc.php' );
+
+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['nl_id'] = $gContent->mNewsletterId;
+ $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to delete the newsletter '.$gContent->getTitle().'?' ) );
+ } else {
+ if( $gContent->expunge() ) {
+ header( "Location: ".NEWSLETTERS_PKG_URL.'admin/admin_newsletters.php' );
+ die;
+ }
+ }
+} elseif (isset($_REQUEST["save"])) {
+ $sid = $gContent->store( $_REQUEST );
+ header( "Location: ".$_SERVER['PHP_SELF'] );
+ die;
+}
+
+$gContent->invokeServices( 'content_edit_function' );
+
+// Configure quicktags list
+if ($gBitSystem->isPackageActive( 'quicktags' ) ) {
+ include_once( QUICKTAGS_PKG_PATH.'quicktags_inc.php' );
+}
+
+$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
+/*
+$freqs = array();
+
+for ($i = 0; $i < 90; $i++) {
+ $aux["i"] = $i;
+
+ $aux["t"] = $i * 24 * 60 * 60;
+ $freqs[] = $aux;
+}
+
+$gBitSmarty->assign('freqs', $freqs);
+*/
+/*
+$cat_type='newsletter';
+$cat_objid = $_REQUEST["nl_id"];
+include_once( CATEGORIES_PKG_PATH.'categorize_list_inc.php' );
+*/
+
+// Display the template
+$gBitSystem->display( 'bitpackage:newsletters/admin_list_newsletters.tpl');
+
+?>
diff --git a/admin/admin_newsletters_inc.php b/admin/admin_newsletters_inc.php
index 988b420..6d52dc7 100644
--- a/admin/admin_newsletters_inc.php
+++ b/admin/admin_newsletters_inc.php
@@ -1,5 +1,5 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/admin_newsletters_inc.php,v 1.4 2006/04/19 13:48:39 squareing Exp $
+// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/admin_newsletters_inc.php,v 1.5 2006/06/19 02:35:19 spiderr Exp $
$formNewsletterFeatures = array(
"bitmailer_sender_email" => array(
@@ -15,7 +15,7 @@ $formNewsletterFeatures = array(
"bitmailer_servers" => array(
'label' => 'Mail Servers',
'note' => '',
- 'default' => $gBitSystem->getConfig( 'feature_server_name', '127.0.0.1' ),
+ 'default' => $gBitSystem->getConfig( 'kernel_server_name', '127.0.0.1' ),
),
"bitmailer_protocol" => array(
'label' => 'Protocol',
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index fd3fc1d..71321ab 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -28,6 +28,9 @@ $tables = array(
email C(160),
user_id I4,
nl_content_id I4,
+ sub_code C(36),
+ is_valid C(1),
+ subscribed_date I8,
response_content_id I4,
unsubscribe_all C(1),
unsubscribe_date I8
@@ -64,13 +67,16 @@ $tables = array(
sent_date I8,
last_read_date I8,
reads I2 NOTNULL DEFAULT '0'
- CONSTRAINT ', CONSTRAINT `mailq_content_ref` FOREIGN KEY (`nl_content_id`) REFERENCES `".BIT_DB_PREFIX."liberty_content`( `content_id` )'
+ CONSTRAINT ', CONSTRAINT `mailq_content_ref` FOREIGN KEY (`nl_content_id`) REFERENCES `".BIT_DB_PREFIX."liberty_content`( `content_id` )
+ , CONSTRAINT `mailq_user_ref` FOREIGN KEY (`user_id`) REFERENCES `".BIT_DB_PREFIX."users_users`( `user_id` )'
"
);
global $gBitInstaller;
+$gBitInstaller->makePackageHomeable(NEWSLETTERS_PKG_NAME);
+
foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerSchemaTable( NEWSLETTERS_PKG_DIR, $tableName, $tables[$tableName] );
}
@@ -78,6 +84,9 @@ foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerPackageInfo( NEWSLETTERS_PKG_NAME, array(
'description' => "Newsletters is for emailing users updates about your site.",
'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
+ 'version' => '1.0',
+ 'state' => 'R2',
+ 'dependencies' => '',
) );
// ### Indexes
diff --git a/admin/send.php b/admin/send.php
index bb1b50e..6e07d6f 100644
--- a/admin/send.php
+++ b/admin/send.php
@@ -1,6 +1,6 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.13 2006/04/20 16:24:47 squareing Exp $
+// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.14 2006/06/19 02:35:19 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,31 +9,35 @@
// Initialization
require_once( '../../bit_setup_inc.php' );
include_once( NEWSLETTERS_PKG_PATH.'BitMailer.php' );
+include_once( NEWSLETTERS_PKG_PATH.'BitNewsletterEdition.php' );
$gBitSystem->verifyPackage( 'newsletters' );
-$gBitSystem->verifyPermission( 'p_admin_newsletters' );
+$gBitSystem->verifyPermission( 'p_send_newsletters' );
require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_edition_inc.php' );
$feedback = array();
-if( @BitBase::verifyId( $_REQUEST["template_id"] ) ) {
- $template_data = $tikilib->get_template($_REQUEST["template_id"]);
+if( @BitBase::verifyId( $_REQUEST["edition_id"] ) ) {
+ $gContent->mEditionId = $_REQUEST["edition_id"];
+ $gContent->load();
- $_REQUEST['edit'] = $template_data["content"];
- $_REQUEST["preview"] = 1;
+ $_REQUEST['edit'] = $gContent->mInfo['data'];
+// $_REQUEST["preview"] = 1;
}
$gBitSmarty->assign('preview', 'n');
$gBitSmarty->assign('presend', 'n');
$gBitSmarty->assign('emited', 'n');
+$validated = (isset($_REQUEST["validated"]) && !empty($_REQUEST["validated"])) ? TRUE : FALSE;
-if( $gContent->isValid() && isset( $_REQUEST['preview'] ) ) {
- $recipients = $gContent->getRecipients( $_REQUEST['send_group'] );
+if( $gContent->isValid() && isset( $_REQUEST['preview'] ) && isset( $_REQUEST['send_group'] ) ) {
+ $recipients = $gContent->getRecipients( $_REQUEST['send_group'], $validated );
$gBitSmarty->assign_by_ref( 'recipientList', $recipients );
+ $gBitSmarty->assign( 'validated', $validated );
$gBitSmarty->assign( 'sending', TRUE );
} elseif( $gContent->isValid() && isset( $_REQUEST["send"] ) ) {
- if( $emails = $gContent->getRecipients( $_REQUEST['send_group'] ) ) {
+ if( $emails = $gContent->getRecipients( $_REQUEST['send_group'], $validated ) ) {
global $gBitMailer;
$gBitMailer = new BitMailer();
$gBitMailer->queueRecipients( $gContent->mContentId, $gContent->mNewsletter->mContentId, $emails );
@@ -47,17 +51,22 @@ if( $gContent->isValid() && isset( $_REQUEST['preview'] ) ) {
if( $gContent->isValid() ) {
$groupListHash = array();
$groups = $gBitUser->getAllGroups( $groupListHash );
+ $groups['data']['send_subs']['group_name'] = 'Send to subscribers';
$gBitSmarty->assign_by_ref( 'groupList', $groups['data'] );
} else {
$listHash = array();
$editions = $gContent->getList( $listHash );
$gBitSmarty->assign_by_ref( 'editionList', $editions );
- $gBitSmarty->assign( 'listInfo', $listHash );
+
+/* if( $gBitSystem->isFeatureActive( 'bit_p_use_content_templates' ) ) {
+ $templates = $bitlib->list_templates('newsletters', 0, -1, 'name_asc', '');
+ $gBitSmarty->assign_by_ref('templates', $templates["data"]);
+ }*/
}
$gBitSmarty->assign_by_ref( 'feedback', $feedback );
// Display the template
-$gBitSystem->display( 'bitpackage:newsletters/send_newsletters.tpl');
+$gBitSystem->display( 'bitpackage:newsletters/send_newsletters.tpl' , "Send Newsletters");
?>
diff --git a/admin/tend_mail_queue.php b/admin/tend_mail_queue.php
index e99fdf6..f7bcbd8 100644
--- a/admin/tend_mail_queue.php
+++ b/admin/tend_mail_queue.php
@@ -14,17 +14,11 @@
*/
if( !empty( $argc ) ) {
// reduce feedback for command line to keep log noise way down
-// define( 'BIT_PHP_ERROR_REPORTING', E_ERROR | E_PARSE );
+ define( 'BIT_PHP_ERROR_REPORTING', E_ERROR | E_PARSE );
}
require_once( '../../bit_setup_inc.php' );
- // add some protection for arbitrary thumbail execution.
- // if argc is present, we will trust it was exec'ed command line.
- if( empty( $argc ) && !$gBitUser->isAdmin() ) {
- $gBitSystem->fatalError( 'You cannot run the thumbnailer' );
- }
-
if( $gBitSystem->isPackageActive( 'newsletters' ) ) {
require_once( NEWSLETTERS_PKG_PATH.'BitMailer.php' );
global $gBitMailer;
diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php
index 1e7bd65..a026749 100644
--- a/admin/upgrade_inc.php
+++ b/admin/upgrade_inc.php
@@ -19,6 +19,9 @@ array( 'DATADICT' => array(
'tiki_newsletters' => array( '`validateAddr`' => "`validate_addr` C(1) default 'y'" ),
'tiki_newsletters' => array( '`lastSent`' => '`last_sent` I8' ),
'tiki_newsletters_editions' => array( '`editionId`' => '`edition_id` I4 AUTO' ),
+ 'tiki_newsletter_subscriptions' => array( '`code`' => "`sub_code` C(36)" ),
+ 'tiki_newsletter_subscriptions' => array( '`valid`' => "`is_valid` C(1)" ),
+ 'tiki_newsletter_subscriptions' => array( '`subscribed`' => "`subscribed_date` I8" ),
)),
// ALTER
array( 'ALTER' => array(
@@ -52,7 +55,6 @@ array( 'QUERY' =>
array( 'DATADICT' => array(
array( 'DROPCOLUMN' => array(
'tiki_newsletters' => array( '`name`', '`description`', '`created`', '`users`', '`editions`' ),
- 'tiki_newsletter_subscriptions' => array( '`code`', '`valid`', '`subscribed`' ),
)),
)),
)