<?php // Returns the campaign content for Campaign Monitor's Servers $campaignFileId = $_GET['cid']; if (!is_numeric($campaignFileId)) { die; } $campaignFile = $campaignFileId . '.html'; require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php'; require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'; require_once MODX_CONNECTORS_PATH . 'index.php'; $corePath = $modx->getOption('cmx.core_path', null, $modx->getOption('core_path') . 'components/cmx/'); require_once $corePath . 'model/cmx/cmx.class.php'; $modx->cmx = new cmx($modx); // CM Create Send Handler if (!$modx->loadClass('CMHandler', $corePath . 'model/cmx/', true, true)) { $modx->log(modX::LOG_LEVEL_ERROR, '[CMx] Could not load CMHandler class.'); return ''; } $cm = new CMHandler($modx); $content = $cm->getCampaignCache($campaignFile); if (is_string($content)) { echo $content; } else { echo ''; }
<?php $refresh = $modx->getOption('refresh', $_REQUEST, false); $isLimit = !empty($_REQUEST['limit']); $start = $modx->getOption('start', $_REQUEST, 0); $limit = $modx->getOption('limit', $_REQUEST, 20); $sort = $modx->getOption('sort', $_REQUEST, ''); $dir = $modx->getOption('dir', $_REQUEST, 'ASC'); $cm = new CMHandler($modx, $refresh); $list = $cm->getScheduledCampaigns(); $list = $cm->searchResults($list, ''); $list = $cm->sortResults($list, $sort, $dir); $list = array_slice($list, $start, $limit); $count = $cm->getCount(); return $this->outputArray($list, $count);
<?php $campaignid = $modx->getOption('id', $_REQUEST, '0'); $cm = new CMHandler($modx); return $cm->getCampaignCache($campaignid);
<?php $refresh = $modx->getOption('refresh', $_REQUEST, false); FB::log($refresh); $isLimit = !empty($_REQUEST['limit']); $start = $modx->getOption('start', $_REQUEST, 0); $limit = $modx->getOption('limit', $_REQUEST, 20); $sort = $modx->getOption('sort', $_REQUEST, ''); $dir = $modx->getOption('dir', $_REQUEST, 'ASC'); $cm = new CMHandler($modx, $refresh); $list = $cm->getDraftCampaigns(); $list = $cm->searchResults($list, ''); $list = $cm->sortResults($list, $sort, $dir); $list = array_slice($list, $start, $limit); $count = $cm->getCount(); return $this->outputArray($list, $count);
<?php // // Save selected users // $pnaelInformation['users'] = $modx->toJSON( $scriptProperties['users'] ); // // Get selected users as comma seperate list // $pnaelInformation['users'] = implode(',',$pnaelInformation['users']); // $results = array(); // $results[] = array('ListID'=>'1234','Name'=>'Cool List'); // $results[] = array('ListID'=>'5678','Name'=>'Rad List'); // $count = count($results); // return $this->outputArray($results, $count); $cm = new CMHandler($modx); $list = $cm->getLists(); $count = $cm->getCount(); return $this->outputArray($list, $count);
$campaign['ReplyTo'] = $modx->getOption('replyto', $_POST, ''); $listids = $modx->getOption('lists', $_POST, array('')); $segmentids = $modx->getOption('segments', $_POST, array('')); if ($listids[0] === '' && $segmentids[0] === '') { return $modx->error->failure('Select a list or segment for this campaign'); } if ($listids[0] !== '') { $campaign['ListIDs'] = $listids; } if ($segmentids[0] !== '') { $campaign['SegmentIDs'] = $segmentids; } $content = $modx->getOption('content', $_POST, ''); $content = str_replace('<p> </p>', '<br/>', $content); // CM doesn't like that non breaking space TinyMCE adds between the p tags $cm = new CMHandler($modx); $fileId = $cm->setCampaignFiles($content); if (!$fileId) { return $modx->error->failure('Problem saving cache file'); } $url = 'http://' . $_SERVER['HTTP_HOST'] . $modx->getOption('cmx.assets_url') . 'cache/'; $campaign['TextUrl'] = $url . $fileId . '.txt'; $campaign['HtmlUrl'] = $url . $fileId . '.html'; FB::log($campaign); $results = $cm->createCampaign($campaign); $cm->removeCampaignFiles($fileId); if ($results->http_status_code == 201) { // grab campaign ID $campaignID = $results->response; FB::log($campaignID); // save a copy of everything in cache since we can't get this through the API
<?php $cid = $_REQUEST['id']; $cm = new CMHandler($modx); $results = $cm->getCampaignSummary($cid); foreach ($results as $label => $result) { $output[$label] = $result; } $count = $cm->getCount(); return $this->outputArray($output, 1);
<?php $campaignID = $modx->getOption('id', $_REQUEST, ''); if (!empty($campaignID)) { $cm = new CMHandler($modx); $results = $cm->removeCampaign($campaignID); FB::log($results); if ($results->http_status_code == '200') { return $modx->error->success('', $results); } else { return $modx->error->failure('Problem deleting campaign: ' . $results->response->Message); } } else { return $modx->error->failure('Invalid Campaign ID'); }
<?php $campaignId = $modx->getOption('id', $_REQUEST, null); $recipients = $modx->getOption('recipients', $_REQUEST, null); $recipients = explode(',', $recipients); FB::log($campaignId); FB::log($recipients); $cm = new CMHandler($modx); $response = $cm->sendPreview($campaignId, $recipients); FB::log($response); return $modx->error->success('Successfully sent', $success);
<?php $campaignid = $modx->getOption('id', $_REQUEST, ''); $cm = new CMHandler($modx); $response = $cm->unschedule($campaignid); FB::log($response); if ($response->http_status_code == '200') { // success return $modx->error->success('', $response); } else { return $modx->error->failure('' . $response); }
<?php $campaignId = $modx->getOption('id', $_REQUEST, ''); $confirmationEmail = $modx->getOption('confirmation_email', $_REQUEST, ''); $publishAt = $modx->getOption('publish_at', $_REQUEST, ''); if ($publishAt === '') { $publishAt = 'Immediately'; } else { $publishAt = str_replace('T', ' ', $publishAt); } FB::log($_REQUEST); // $confirmationEmail = '*****@*****.**'; $schedule = array('ConfirmationEmail' => $confirmationEmail, 'SendDate' => $publishAt); FB::log($campaignId); FB::log($schedule); $cm = new CMHandler($modx); $response = $cm->sendCampaign($campaignId, $schedule); FB::log($response); return $modx->error->success('', $response);
<?php // // Save selected users // $pnaelInformation['users'] = $modx->toJSON( $scriptProperties['users'] ); // // Get selected users as comma seperate list // $pnaelInformation['users'] = implode(',',$pnaelInformation['users']); // $results = array(); // $results[] = array('ListID'=>'1234','Name'=>'Cool List'); // $results[] = array('ListID'=>'5678','Name'=>'Rad List'); // $count = count($results); // return $this->outputArray($results, $count); $cm = new CMHandler($modx); $list = $cm->getSegments(); $count = $cm->getCount(); return $this->outputArray($list, $count);
<?php /** * Get a list of Bounces * * @package cmx * @subpackage processors */ $refresh = $modx->getOption('refresh', $_REQUEST, false); $campaign_id = $modx->getOption('campaign_id', $_REQUEST, 0); $sent_date = $modx->getOption('sent_date', $_REQUEST, 0); $count = $modx->getOption('count', $_REQUEST, 0); $isLimit = !empty($_REQUEST['limit']); $start = (int) $modx->getOption('start', $_REQUEST, 0); $limit = (int) $modx->getOption('limit', $_REQUEST, 20); $sort = $modx->getOption('sort', $_REQUEST, null); $dir = $modx->getOption('dir', $_REQUEST, null); $page_number = (int) floor($start / $limit) + 1; $cm = new CMHandler($modx); $list = $cm->getCampaignBounces($campaign_id, $sent_date, 1, $limit, $sort, $dir); return $this->outputArray($list, $count);