diff options
| -rw-r--r-- | BitNewsletter.php | 33 | ||||
| -rw-r--r-- | admin/index.php | 45 | ||||
| -rw-r--r-- | templates/admin_newsletters.tpl | 2 |
3 files changed, 47 insertions, 33 deletions
diff --git a/BitNewsletter.php b/BitNewsletter.php index 5d0228d..0c8e023 100644 --- a/BitNewsletter.php +++ b/BitNewsletter.php @@ -1,12 +1,12 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletter.php,v 1.1 2005/12/09 18:51:22 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletter.php,v 1.2 2005/12/09 19:15:49 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.1 2005/12/09 18:51:22 spiderr Exp $ + * $Id: BitNewsletter.php,v 1.2 2005/12/09 19:15:49 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 18:51:22 $ $Author: spiderr $ + * @version $Revision: 1.2 $ $Date: 2005/12/09 19:15:49 $ $Author: spiderr $ */ /** @@ -298,13 +298,26 @@ class BitNewsletter extends LibertyContent { return $msg; } - function remove_newsletter($nl_id) { - $query = "delete from `".BIT_DB_PREFIX."tiki_newsletters` where `nl_id`=?"; - $result = $this->mDb->query($query,array((int)$nl_id)); - $query = "delete from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=?"; - $result = $this->mDb->query($query,array((int)$nl_id)); - $this->remove_object('newsletter', $nl_id); - return true; + function expunge() { + $ret = FALSE; + if( $this->isValid() ) { + $this->mDb->StartTrans(); + $query = "delete from `".BIT_DB_PREFIX."tiki_newsletters` where `nl_id`=?"; + $result = $this->mDb->query( $query, array( $this->mNlId ) ); + $query = "delete from `".BIT_DB_PREFIX."tiki_newsletter_subscriptions` where `nl_id`=?"; + $result = $this->mDb->query( $query, array( $this->mNlId ) ); + if( parent::expunge() ) { + $ret = TRUE; + $this->mDb->CompleteTrans(); + } else { + $this->mDb->RollbackTrans(); + } + } + return $ret; + } + + function isValid() { + return( !empty( $this->mNlId ) ); } } diff --git a/admin/index.php b/admin/index.php index 45508fa..b4369ab 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.4 2005/12/09 18:51:22 spiderr Exp $ +// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/Attic/index.php,v 1.5 2005/12/09 19:15:50 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,29 +14,30 @@ $gBitSystem->verifyPermission( 'tiki_p_admin_newsletters' ); require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_inc.php' ); -if (isset($_REQUEST["remove"])) { - $nllib->remove_newsletter($_REQUEST["remove"]); +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->mNlId; + $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/' ); + die; + } + } +} elseif (isset($_REQUEST["save"])) { + $sid = $gContent->store( $_REQUEST ); + header( "Location: ".$_SERVER['PHP_SELF'] ); + die; } -if (isset($_REQUEST["save"])) { - $sid = $gContent->store( $_REQUEST ); - /* - $cat_type='newsletter'; - $cat_objid = $sid; - $cat_desc = substr($_REQUEST["description"],0,200); - $cat_name = $_REQUEST["name"]; - $cat_href= NEWSLETTERS_PKG_URL."newsletters.php?nl_id=".$cat_objid; - include_once( CATEGORIES_PKG_PATH.'categorize_inc.php' ); - */ - $info["name"] = ''; - $info["description"] = ''; - $info["allow_user_sub"] = 'y'; - $info["allow_any_sub"] = 'n'; - $info["unsub_msg"] = 'y'; - $info["validate_addr"] = 'y'; - //$info["frequency"] = 7 * 24 * 60 * 60; - $gBitSmarty->assign('nl_id', 0); - $gBitSmarty->assign('info', $info); +$gContent->invokeServices( 'content_edit_function' ); + +// Configure quicktags list +if ($gBitSystem->isPackageActive( 'quicktags' ) ) { + include_once( QUICKTAGS_PKG_PATH.'quicktags_inc.php' ); } $newsletters = $gContent->getList( $listHash ); diff --git a/templates/admin_newsletters.tpl b/templates/admin_newsletters.tpl index fdc49e4..0ec837f 100644 --- a/templates/admin_newsletters.tpl +++ b/templates/admin_newsletters.tpl @@ -69,7 +69,7 @@ <td>{$nl.editions}</td> <td>{$nl.last_sent|bit_short_datetime}</td> <td> - <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/index.php?offset={$offset}&sort_mode={$sort_mode}&remove={$nlId}">{tr}remove{/tr}</a> + <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/index.php?offset={$offset}&sort_mode={$sort_mode}&remove=1&nl_id={$nlId}">{tr}remove{/tr}</a> <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/index.php?offset={$offset}&sort_mode={$sort_mode}&nl_id={$nlId}">{tr}edit{/tr}</a> <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/admin_newsletter_subscriptions.php?nl_id={$nlId}">{tr}subscriptions{/tr}</a> {if $channels[user].individual eq 'y'}({/if}<a href="{$smarty.const.KERNEL_PKG_URL}object_permissions.php?objectName=newsletter%20{$nl.title}&object_type={$smarty.const.BITNEWSLETTER_CONTENT_TYPE_GUID}&permType=newsletters&object_id={$nlId}">{tr}perms{/tr}</a>{if $nl.individual eq 'y'}){/if} |
