diff options
| author | Christian Fowler <spider@viovio.com> | 2005-12-29 18:46:39 +0000 |
|---|---|---|
| committer | Christian Fowler <spider@viovio.com> | 2005-12-29 18:46:39 +0000 |
| commit | 54ab99d9ef3d0edb3b9527922a34296495d170db (patch) | |
| tree | 6b1278f2e9cf468ce176308139ab9fd27ba5c1b6 | |
| parent | 4918af1a903bac5765cbf8709cfe2ce7f41ff082 (diff) | |
| download | newsletters-54ab99d9ef3d0edb3b9527922a34296495d170db.tar.gz newsletters-54ab99d9ef3d0edb3b9527922a34296495d170db.tar.bz2 newsletters-54ab99d9ef3d0edb3b9527922a34296495d170db.zip | |
clean up permissions, and creating of editions
| -rw-r--r-- | BitMailer.php | 14 | ||||
| -rw-r--r-- | BitNewsletterEdition.php | 10 | ||||
| -rw-r--r-- | admin/schema_inc.php | 7 | ||||
| -rw-r--r-- | admin/send.php | 3 | ||||
| -rw-r--r-- | lookup_newsletter_inc.php | 2 | ||||
| -rw-r--r-- | templates/edit_edition.tpl | 8 | ||||
| -rw-r--r-- | templates/edit_newsletter.tpl | 6 | ||||
| -rw-r--r-- | templates/list_editions_inc.tpl | 8 | ||||
| -rw-r--r-- | templates/list_newsletters.tpl | 8 | ||||
| -rw-r--r-- | templates/user_subscriptions.tpl | 2 | ||||
| -rw-r--r-- | templates/view_edition.tpl | 5 |
11 files changed, 40 insertions, 33 deletions
diff --git a/BitMailer.php b/BitMailer.php index 298e1a0..c5c925c 100644 --- a/BitMailer.php +++ b/BitMailer.php @@ -1,12 +1,12 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.11 2005/12/29 17:22:47 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.12 2005/12/29 18:46:39 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: BitMailer.php,v 1.11 2005/12/29 17:22:47 spiderr Exp $ + * $Id: BitMailer.php,v 1.12 2005/12/29 18:46:39 spiderr Exp $ * * Class that handles editions of newsletters * @package newsletters @@ -15,7 +15,7 @@ * * @author spiderr <spider@steelsun.com> * - * @version $Revision: 1.11 $ $Date: 2005/12/29 17:22:47 $ $Author: spiderr $ + * @version $Revision: 1.12 $ $Date: 2005/12/29 18:46:39 $ $Author: spiderr $ */ /** @@ -94,13 +94,17 @@ class BitMailer extends phpmailer { if( $content->load() ) { $body[$pick['content_id']]['body'] = $content->render(); $body[$pick['content_id']]['subject'] = $content->getTitle(); + $body[$pick['content_id']]['object'] = $content; } // $content[$pick['content_id']] = LibertyBase::getLibertyObject(); } if( !empty( $body[$pick['content_id']] ) ) { $pick['url_code'] = md5( $pick['content_id'].$pick['email'].$pick['queue_date'] ); - $gBitSmarty->assign( 'url_code', $pick['url_code'] ); - $unsub = $gBitSmarty->fetch( 'bitpackage:newsletters/unsubscribe_inc.tpl' ); + $unsub = ''; + if( $body[$pick['content_id']]['object']->mNewsletter->mInfo['unsub_msg'] ) { + $gBitSmarty->assign( 'url_code', $pick['url_code'] ); + $unsub = $gBitSmarty->fetch( 'bitpackage:newsletters/unsubscribe_inc.tpl' ); + } $htmlBody = $unsub . $body[$pick['content_id']]['body'] . $unsub . '<img src="'.NEWSLETTERS_PKG_URI.'track.php?sub='.$pick['url_code'].'" alt="" />'; if( !$this->sendMail( $pick, $body[$pick['content_id']]['subject'], $htmlBody ) ) { diff --git a/BitNewsletterEdition.php b/BitNewsletterEdition.php index 1b96f43..239cf66 100644 --- a/BitNewsletterEdition.php +++ b/BitNewsletterEdition.php @@ -1,12 +1,12 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletterEdition.php,v 1.12 2005/12/29 15:31:32 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletterEdition.php,v 1.13 2005/12/29 18:46:39 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.12 2005/12/29 15:31:32 spiderr Exp $ + * $Id: BitNewsletterEdition.php,v 1.13 2005/12/29 18:46:39 spiderr Exp $ * * Class that handles editions of newsletters * @package newsletters @@ -15,7 +15,7 @@ * * @author spiderr <spider@steelsun.com> * - * @version $Revision: 1.12 $ $Date: 2005/12/29 15:31:32 $ $Author: spiderr $ + * @version $Revision: 1.13 $ $Date: 2005/12/29 18:46:39 $ $Author: spiderr $ */ /** @@ -45,10 +45,10 @@ class BitNewsletterEdition extends LibertyAttachable { function verify( &$pParamHash ) { - if( $this->verifyId( $pParamHash['nl_id'] ) ) { + if( @$this->verifyId( $pParamHash['nl_content_id'] ) ) { $pParamHash['edition_store']["nl_content_id"] = $pParamHash['nl_content_id']; } else { - $this->mErrors['nl_id'] = tra( 'No newsletter was selected for this edition.' ); + $this->mErrors['nl_content_id'] = tra( 'No newsletter was selected for this edition.' ); } $pParamHash['edition_store']['is_draft'] = !empty( $pParamHash['is_draft'] ) ? 'y' : NULL; diff --git a/admin/schema_inc.php b/admin/schema_inc.php index cf09edd..ad88f8d 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -16,10 +16,10 @@ $tables = array( 'tiki_newsletters_editions' => " edition_id I4 AUTO PRIMARY, - nl_id I4 NOTNULL, + nl_content_id I4 NOTNULL, is_draft C(1), content_id I4 NOTNULL - CONSTRAINTS ', CONSTRAINT `tiki_nl_ed_nl_ref` FOREIGN KEY (`nl_id`) REFERENCES `".BIT_DB_PREFIX."tiki_newsletters`( `nl_id` ) + CONSTRAINTS ', CONSTRAINT `tiki_nl_ed_nl_con_ref` FOREIGN KEY (`nl_content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` ) , CONSTRAINT `tiki_nl_ed_con_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."tiki_content`( `content_id` )' ", @@ -99,10 +99,9 @@ $gBitInstaller->registerSchemaIndexes( LIBERTY_PKG_NAME, $indices ); // ### Default UserPermissions $gBitInstaller->registerUserPermissions( NEWSLETTERS_PKG_NAME, array( - array('bit_p_admin_newsletters', 'Can admin newsletters', 'editors', 'newsletters'), + array('bit_p_admin_newsletters', 'Can admin and send newsletters', 'editors', 'newsletters'), array('bit_p_create_newsletters', 'Can create newsletters', 'editors', 'newsletters'), array('bit_p_create_editions', 'Can create editions', 'editors', 'newsletters'), - array('bit_p_send_newsletters', 'Can send newsletters', 'editors', 'newsletters'), array('bit_p_subscribe_newsletters', 'Can subscribe to newsletters', 'registered', 'newsletters'), array('bit_p_subscribe_email', 'Can subscribe any email to newsletters', 'editors', 'newsletters'), ) ); diff --git a/admin/send.php b/admin/send.php index 3ee3195..cd9ef8a 100644 --- a/admin/send.php +++ b/admin/send.php @@ -1,6 +1,6 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.9 2005/12/25 02:23:44 spiderr Exp $ +// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.10 2005/12/29 18:46:39 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. @@ -11,6 +11,7 @@ require_once( '../../bit_setup_inc.php' ); include_once( NEWSLETTERS_PKG_PATH.'BitMailer.php' ); $gBitSystem->verifyPackage( 'newsletters' ); +$gBitSystem->verifyPermission( 'tiki_p_admin_newsletters' ); require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_edition_inc.php' ); diff --git a/lookup_newsletter_inc.php b/lookup_newsletter_inc.php index 996f744..8e54cb2 100644 --- a/lookup_newsletter_inc.php +++ b/lookup_newsletter_inc.php @@ -4,7 +4,7 @@ require_once( NEWSLETTERS_PKG_PATH.'BitNewsletter.php' ); if( empty( $gContent ) || !is_object( $gContent ) || !$gContent->isValid() ) { $nlId = !empty( $_REQUEST['nl_id'] ) ? $_REQUEST['nl_id'] : NULL; - $conId = !empty( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL; + $conId = !empty( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : !empty( $_REQUEST['nl_content_id'] ) ? $_REQUEST['nl_content_id'] : NULL; $gContent = new BitNewsletter( $nlId, $conId ); $gContent->load(); $gBitSmarty->assign_by_ref( 'gContent', $gContent ); diff --git a/templates/edit_edition.tpl b/templates/edit_edition.tpl index 50759c8..bace0c6 100644 --- a/templates/edit_edition.tpl +++ b/templates/edit_edition.tpl @@ -23,11 +23,11 @@ {jstab title="Edition Body"} {legend legend="Edition Body"} <div class="row"> - {formlabel label="Newsletter" for="nl_id"} + {formlabel label="Newsletter" for="nl_content_id"} {forminput} - <select name="nl_id" id="nl_id"> - {foreach from=$newsletters item=nl key=nlId} - <option value="{$nlId}" {if $nlId eq $nl_id}selected="selected"{/if}>{$nl.title}</option> + <select name="nl_content_id" id="nl_content_id"> + {foreach from=$newsletters item=nl key=nlConId} + <option value="{$nlConId}" {if $nl.con_id eq $nl_id}selected="selected"{/if}>{$nl.title}</option> {/foreach} </select> {formhelp note="Pick the newsletter you want to post to."} diff --git a/templates/edit_newsletter.tpl b/templates/edit_newsletter.tpl index 4fdad39..affdf5e 100644 --- a/templates/edit_newsletter.tpl +++ b/templates/edit_newsletter.tpl @@ -33,7 +33,7 @@ <div class="row"> {formlabel label="Users can Subscribe" for="allow_user_sub"} {forminput} - <input type="checkbox" name="allow_user_sub" id="allow_user_sub" {if $gContent->mInfo.allow_user_sub eq 'y'}checked="checked"{/if} /> + <input type="checkbox" name="allow_user_sub" id="allow_user_sub" {if !$gContent->isValid() || $gContent->mInfo.allow_user_sub eq 'y'}checked="checked"{/if} /> {formhelp note="Users can subscribe to this list. Disabling this options means that you have to manually add users to the list."} {/forminput} </div> @@ -41,7 +41,7 @@ <div class="row"> {formlabel label="Any e-mail Address" for="allow_any_sub"} {forminput} - <input type="checkbox" name="allow_any_sub" id="allow_any_sub" {if $gContent->mInfo.allow_any_sub eq 'y'}checked="checked"{/if} /> + <input type="checkbox" name="allow_any_sub" id="allow_any_sub" {if !$gContent->isValid() || $gContent->mInfo.allow_any_sub eq 'y'}checked="checked"{/if} /> {formhelp note="Users may subscribe using any email address."} {/forminput} </div> @@ -49,7 +49,7 @@ <div class="row"> {formlabel label="Append Un/Subscribe Instructions" for="unsub_msg"} {forminput} - <input type="checkbox" name="unsub_msg" id="unsub_msg" {if $gContent->mInfo.unsub_msg eq 'y'}checked="checked"{/if} /> + <input type="checkbox" name="unsub_msg" id="unsub_msg" {if !$gContent->isValid() || $gContent->mInfo.unsub_msg eq 'y'}checked="checked"{/if} /> {formhelp note="Append instructions on how to subscribe / unsubscribe to ever outgoing newsletter. This is only useful when users can un / subscribe to the list themselves."} {/forminput} </div> diff --git a/templates/list_editions_inc.tpl b/templates/list_editions_inc.tpl index 22eefa4..7117e0c 100644 --- a/templates/list_editions_inc.tpl +++ b/templates/list_editions_inc.tpl @@ -2,14 +2,16 @@ {foreach from=$editionList key=editionId item=ed} <li class="item {cycle values='odd,even'} {$ed.content_type_guid}"> <div class="floaticon"> - <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/send.php?edition_id={$ed.edition_id}">{biticon ipackage=liberty iname="mail_send" iexplain="Send"}</a> + {if $gBitUser->hasPermission('bit_p_admin_newsletters')} + <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/send.php?edition_id={$ed.edition_id}">{biticon ipackage=liberty iname="mail_send" iexplain="Send"}</a> + {/if} </div> <h2><a href="{$ed.display_url}">{$ed.title}</a></h2> <p> - {$ed.data|truncate:200} + {$ed.data|truncate:200:'...'} <br /> - {tr}in{/tr} <a href="{$smarty.const.NEWSLETTERS_PKG_URL}?nl_id={$ed.nl_id}">{$ed.newsletter_title}</a> + {tr}in{/tr} <a href="{$smarty.const.NEWSLETTERS_PKG_URL}?nl_content_id={$ed.nl_content_id}">{$ed.newsletter_title}</a> </p> </li> {foreachelse} diff --git a/templates/list_newsletters.tpl b/templates/list_newsletters.tpl index 326cf51..1287751 100644 --- a/templates/list_newsletters.tpl +++ b/templates/list_newsletters.tpl @@ -89,11 +89,11 @@ <td>{$nl.data}</td> <td>{$nl.created|bit_short_date}</td> <td>{$nl.last_sent|bit_short_date}</td> - <td><a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/admin_newsletter_subscriptions.php?nl_id={$nlId}"> {$nl.unsub_count|default:0}</a></td> + <td><a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/admin_newsletter_subscriptions.php?nl_id={$nl.nl_id}"> {$nl.unsub_count|default:0}</a></td> <td style="text-align:right;"> - <a href="{$smarty.const.NEWSLETTERS_PKG_URL}edition_edit.php?nl_id={$nlId}">{biticon ipackage=liberty iname=new iexplain="New Edition"}</a> - <a href="{$smarty.const.NEWSLETTERS_PKG_URL}newsletters.php?remove=1&nl_id={$nlId}">{biticon ipackage=liberty iname=delete iexplain=Remove}</a> - <a href="{$smarty.const.NEWSLETTERS_PKG_URL}newsletters.php?&nl_id={$nlId}">{biticon ipackage=liberty iname=edit iexplain=Edit}</a> + <a href="{$smarty.const.NEWSLETTERS_PKG_URL}edition_edit.php?nl_id={$nl.nl_id}">{biticon ipackage=liberty iname=new iexplain="New Edition"}</a> + <a href="{$smarty.const.NEWSLETTERS_PKG_URL}newsletters.php?remove=1&nl_id={$nl.nl_id}">{biticon ipackage=liberty iname=delete iexplain=Remove}</a> + <a href="{$smarty.const.NEWSLETTERS_PKG_URL}newsletters.php?&nl_id={$nl.nl_id}">{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}&object_type={$smarty.const.BITNEWSLETTER_CONTENT_TYPE_GUID}&permType=newsletters&object_id={$nlId}">{biticon ipackage=liberty iname=permissions iexplain=Permissions}</a>{if $nl.individual eq 'y'}){/if} </td> </tr> diff --git a/templates/user_subscriptions.tpl b/templates/user_subscriptions.tpl index 08e7058..0533fa9 100644 --- a/templates/user_subscriptions.tpl +++ b/templates/user_subscriptions.tpl @@ -31,7 +31,7 @@ {formlabel label="Subscriptions"} {forminput} {foreach from=$newsletters key=nlId item=nl} - <input type="checkbox" name="nl_content_id[]" value="{$nlId}" {if !$unsubs.$nlId && !$subInfo.unsubscribe_all}checked="checked"{/if}/> <a href="{$nl.display_url}"/>{$nl.title}</a> <br/> + {if $nl.allow_user_sub}<input type="checkbox" name="nl_content_id[]" value="{$nlId}" {if !$unsubs.$nlId && !$subInfo.unsubscribe_all}checked="checked"{/if}/>{/if} <a href="{$nl.display_url}"/>{$nl.title}</a> <br/> {foreachelse} {tr}No newsletters were found{/tr} {/foreach} diff --git a/templates/view_edition.tpl b/templates/view_edition.tpl index 3ba9247..f134159 100644 --- a/templates/view_edition.tpl +++ b/templates/view_edition.tpl @@ -6,8 +6,9 @@ <a href="{$smarty.const.NEWSLETTERS_PKG_URL}edition_edit.php?edition_id={$gContent->mEditionId}">{biticon ipackage=liberty iname="edit" iexplain="edit"}</a> <a href="{$smarty.const.NEWSLETTERS_PKG_URL}edition_edit.php?edition_id={$gContent->mEditionId}&remove=1">{biticon ipackage=liberty iname="delete" iexplain="delete"}</a> {/if} - - <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/send.php?edition_id={$gContent->mEditionId}">{biticon ipackage=liberty iname="mail_send" iexplain="email this post"}</a> + {if $gBitUser->hasPermission('bit_p_admin_newsletters')} + <a href="{$smarty.const.NEWSLETTERS_PKG_URL}admin/send.php?edition_id={$gContent->mEditionId}">{biticon ipackage=liberty iname="mail_send" iexplain="email this post"}</a> + {/if} </div> <div class="header"> |
