Skip to content

Commit

Permalink
Starting to get mailings section to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Ancona Novelo committed Aug 12, 2010
1 parent a655ba3 commit 7722117
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 104 deletions.
43 changes: 0 additions & 43 deletions admin/mailings/mailing_status.php

This file was deleted.

25 changes: 14 additions & 11 deletions admin/mailings/admin_mailings.php → admin_mailings.php
Expand Up @@ -21,22 +21,25 @@
/**********************************
INITIALIZATION METHODS
*********************************/
require('../../bootstrap.php');
Pommo::requireOnce($pommo->_baseDir.'inc/helpers/mailings.php');
require('bootstrap.php');
require_once(Pommo::$_baseDir.'classes/Pommo_Mailing.php');

$pommo->init();
$logger = & $pommo->_logger;
$dbo = & $pommo->_dbo;
Pommo::init();
$logger = & Pommo::$_logger;
$dbo = & Pommo::$_dbo;

/**********************************
SETUP TEMPLATE, PAGE
*********************************/
Pommo::requireOnce($pommo->_baseDir.'inc/classes/template.php');
$smarty = new PommoTemplate();
require_once(Pommo::$_baseDir.'classes/Pommo_Template.php');
$smarty = new Pommo_Template();

if (PommoMailing::isCurrent())
Pommo::kill(sprintf(Pommo::_T('A Mailing is currently processing. Visit the %sStatus%s page to check its progress.'),'<a href="mailing_status.php">','</a>'));
if (Pommo_Mailing::isCurrent())
{
Pommo::kill(sprintf(Pommo::_T('A Mailing is currently processing. Visit the
%sStatus%s page to check its progress.'),
'<a href="mailing_status.php">', '</a>'));
}

$smarty->display('admin/mailings/admin_mailings.tpl');
Pommo::kill();
?>

46 changes: 19 additions & 27 deletions inc/helpers/mailings.php → classes/Pommo_Mailing.php
Expand Up @@ -19,7 +19,7 @@
*/

// include the mailing prototype object
$GLOBALS['pommo']->requireOnce($GLOBALS['pommo']->_baseDir. 'inc/classes/prototypes.php');
require_once(Pommo::$_baseDir.'inc/classes/prototypes.php');

/**
* Mailing: A poMMo Mailing
Expand Down Expand Up @@ -48,7 +48,8 @@
* current_status (enum) 'started', 'stopped' (default)
*/

class PommoMailing {
class Pommo_Mailing
{

// make a mailing template
// accepts a mailing template (assoc array)
Expand All @@ -58,7 +59,7 @@ function & make($in = array(), $current = FALSE) {
$o = ($current) ?
PommoType::mailingCurrent() :
PommoType::mailing();
return PommoAPI::getParams($o, $in);
return Pommo_Api::getParams($o, $in);
}

// make a mailing template based off a database row (mailing* schema)
Expand Down Expand Up @@ -94,23 +95,22 @@ function & makeDB(&$row) {
}

$o = ($row['status'] == 1) ?
PommoAPI::getParams(PommoType::mailingCurrent(),$in) :
PommoAPI::getParams(PommoType::mailing(),$in);
Pommo_Api::getParams(PommoType::mailingCurrent(),$in) :
Pommo_Api::getParams(PommoType::mailing(),$in);
return $o;
}

// mailing validation
// accepts a mailing object (array)
// returns true if mailing ($in) is valid, false if not
function validate(&$in) {
global $pommo;
$logger =& $pommo->_logger;
$logger =& Pommo::$_logger;

$invalid = array();

if (empty($in['fromemail']) || !PommoHelper::isEmail($in['fromemail']))
if (empty($in['fromemail']) || !Pommo_Helper::isEmail($in['fromemail']))
$invalid[] = 'fromemail';
if (empty($in['frombounce']) || !PommoHelper::isEmail($in['frombounce']))
if (empty($in['frombounce']) || !Pommo_Helper::isEmail($in['frombounce']))
$invalid[] = 'frombounce';
if (empty($in['subject']))
$invalid[] = 'subject';
Expand Down Expand Up @@ -176,10 +176,9 @@ function validate(&$in) {
// returns an array of mailings. Array key(s) correlates to mailing ID.
function & get($p = array()) {
$defaults = array('active' => false, 'noBody' => false, 'id' => null, 'code' => null, 'sort' => null, 'order' => null, 'limit' => null, 'offset' => null);
$p = PommoAPI :: getParams($defaults, $p);
$p = Pommo_Api :: getParams($defaults, $p);

global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

$p['active'] = ($p['active']) ? 1 : null;

Expand Down Expand Up @@ -221,8 +220,7 @@ function & get($p = array()) {
// OR if the mailing is a current mailing (status == 1), returns
// the security code of the mailing. FALSE if failed
function add(&$in) {
global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

// set the start time if not provided
if (empty($in['start']))
Expand Down Expand Up @@ -276,7 +274,7 @@ function add(&$in) {
// insert current if applicable
if (!empty($in['status']) && $in['status'] == 1) {
if(empty($in['code']))
$in['code'] = PommoHelper::makeCode();
$in['code'] = Pommo_Helper::makeCode();

$query = "
INSERT INTO " . $dbo->table['mailing_current'] . "
Expand Down Expand Up @@ -305,8 +303,7 @@ function add(&$in) {
// accepts a single ID (int) or array of IDs
// returns the # of deleted subscribers (int). 0 (false) if none.
function delete(&$id) {
global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

$query = "
DELETE
Expand Down Expand Up @@ -336,8 +333,7 @@ function delete(&$id) {
// checks if a mailing is processing
// returns (bool) - true if current mailing
function isCurrent() {
global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

$query = "
SELECT count(mailing_id)
Expand All @@ -349,8 +345,7 @@ function isCurrent() {
// gets the number of mailings
// returns mailing tally (int)
function tally() {
global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

$query = "
SELECT count(mailing_id)
Expand All @@ -364,8 +359,7 @@ function tally() {
// returns an array of notices, if timestamp set to true, array will contain an array of keys that are timestamps, and value is an array of notices
// e.g. array('<timestamp>' => array('notice1','notice2'))
function & getNotices($id,$limit = 50, $timestamp = FALSE) {
global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

$limit = intval($limit);
if($limit == 0)
Expand Down Expand Up @@ -395,8 +389,7 @@ function & getNotices($id,$limit = 50, $timestamp = FALSE) {

// returns the # of sent mails for a mailing
function getSent($id) {
global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

$query = "
SELECT sent FROM ".$dbo->table['mailings']
Expand All @@ -407,8 +400,7 @@ function getSent($id) {

// returns the Subject of a Mailing
function getSubject($id) {
global $pommo;
$dbo =& $pommo->_dbo;
$dbo =& Pommo::$_dbo;

$query = "
SELECT subject FROM ".$dbo->table['mailings']
Expand Down
File renamed without changes.
47 changes: 28 additions & 19 deletions admin/mailings/mailings_start.php → mailings_start.php
Expand Up @@ -21,40 +21,49 @@
/**********************************
INITIALIZATION METHODS
*********************************/
require ('../../bootstrap.php');
Pommo::requireOnce($pommo->_baseDir.'inc/helpers/mailings.php');
require ('bootstrap.php');
require_once(Pommo::$_baseDir.'classes/Pommo_Mailing.php');

$pommo->init();
$logger = & $pommo->_logger;
$dbo = & $pommo->_dbo;
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;

/**********************************
SETUP TEMPLATE, PAGE
*********************************/
Pommo::requireOnce($pommo->_baseDir.'inc/classes/template.php');
$smarty = new PommoTemplate();
require_once(Pommo::$_baseDir.'classes/Pommo_Template.php');
$smarty = new Pommo_Template();

if (PommoMailing::isCurrent())
Pommo::kill(sprintf(Pommo::_T('A Mailing is currently processing. Visit the %sStatus%s page to check its progress.'),'<a href="mailing_status.php">','</a>'));
if (Pommo_Mailing::isCurrent())
{
Pommo::kill(sprintf(Pommo::_T('A Mailing is currently processing. Visit the
%sStatus%s page to check its progress.'),
'<a href="mailing_status.php">', '</a>'));
}

if ($pommo->_config['demo_mode'] == 'on')
$logger->addMsg(sprintf(Pommo::_T('%sDemonstration Mode%s is on -- no Emails will actually be sent. This is good for testing settings.'),'<a href="'.$pommo->_baseUrl.'admin/setup/setup_configure.php#mailings">','</a>'));
if (Pommo::$_config['demo_mode'] == 'on')
{
$logger->addMsg(sprintf(Pommo::_T('%sDemonstration Mode%s is on -- no Emails
will actually be sent. This is good for testing settings.'),
'<a href="'.Pommo::$_baseUrl.
'admin/setup/setup_configure.php#mailings">', '</a>'));
}


// WYSIWYG JavaScript Includes
Pommo::requireOnce($pommo->_baseDir.'themes/wysiwyg/editors.php');
require_once(Pommo::$_baseDir.'themes/wysiwyg/editors.php');
$editors = new PommoWYSIWYG();
$editor = $editors->loadEditor();
if (!$editor)
{
die('Could not find requested WYSIWYG editor ('.$editor.') in editors.php');
$smarty->assign('wysiwygJS',$editor);
}
$smarty->assign('wysiwygJS', $editor);

// translation assignments for dialg titles...
$smarty->assign('t_personalization',Pommo::_T('Personalization'));
$smarty->assign('t_testMailing',Pommo::_T('Test Mailing'));
$smarty->assign('t_saveTemplate',Pommo::_T('Save Template'));
$smarty->assign('t_personalization', Pommo::_T('Personalization'));
$smarty->assign('t_testMailing', Pommo::_T('Test Mailing'));
$smarty->assign('t_saveTemplate', Pommo::_T('Save Template'));


$smarty->display('admin/mailings/mailings_start.tpl');
Pommo::kill();
?>

2 changes: 1 addition & 1 deletion themes/default/admin/admin.tpl
Expand Up @@ -27,7 +27,7 @@

<div id="boxMenu">

<div><a href="{$url.base}admin/mailings/admin_mailings.php"><img src="{$url.theme.shared}images/icons/mailing.png" alt="envelope icon" class="navimage" /> {t}Mailings{/t}</a> - {t}Send mailings to the entire list or to a subset of subscribers. Mailing status and history can also be viewed from here.{/t}</div>
<div><a href="{$url.base}admin_mailings.php"><img src="{$url.theme.shared}images/icons/mailing.png" alt="envelope icon" class="navimage" /> {t}Mailings{/t}</a> - {t}Send mailings to the entire list or to a subset of subscribers. Mailing status and history can also be viewed from here.{/t}</div>

<div><a href="{$url.base}admin_subscribers.php"><img src="{$url.theme.shared}images/icons/subscribers.png" alt="people icon" class="navimage" /> {t}Subscribers{/t}</a> - {t}Here you can list, add, delete, import, export, and update your subscribers. You can also create groups (subsets) of your subsribers from here.{/t}</div>

Expand Down
6 changes: 3 additions & 3 deletions themes/default/admin/mailings/admin_mailings.tpl
Expand Up @@ -6,13 +6,13 @@
<div id="boxMenu">

<div>
<a href="{$url.base}admin/mailings/mailings_start.php"><img src="{$url.theme.shared}images/icons/typewritter.png" alt="typewritter icon" class="navimage" />{t}Send{/t}</a> - {t}Create and send a mailing.{/t}
<a href="{$url.base}mailings_start.php"><img src="{$url.theme.shared}images/icons/typewritter.png" alt="typewritter icon" class="navimage" />{t}Send{/t}</a> - {t}Create and send a mailing.{/t}
</div>

<div>
<a href="{$url.base}admin/mailings/mailings_history.php"><img src="{$url.theme.shared}images/icons/history.png" alt="calendar icon" class="navimage" />{t}History{/t}</a> - {t}View mailings that have already been sent.{/t}
<a href="{$url.base}mailings_history.php"><img src="{$url.theme.shared}images/icons/history.png" alt="calendar icon" class="navimage" />{t}History{/t}</a> - {t}View mailings that have already been sent.{/t}
</div>

</div>

{include file="inc/admin.footer.tpl"}
{include file="inc/admin.footer.tpl"}

0 comments on commit 7722117

Please sign in to comment.