Exemplo n.º 1
0
 /**
  * Initialize the sync process
  *
  * @return void
  */
 public function start()
 {
     // Check for a valid token. If invalid, send a 403 with the error message.
     JSession::checkToken('request') or $this->sendResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
     // Put in a buffer to silence noise.
     ob_start();
     // Initiate an empty state
     CmcSyncerState::resetState();
     $state = CmcSyncerState::getState();
     $input = JFactory::getApplication()->input;
     $lists = $input->getString('lists');
     $chimp = new CmcHelperChimp();
     $listStats = $chimp->lists(array('list_id' => $lists));
     $names = array();
     foreach ($listStats['data'] as $key => $list) {
         $state->lists[$key] = array();
         $state->lists[$key]['mc_id'] = $list['id'];
         $state->lists[$key]['name'] = $list['name'];
         $state->lists[$key]['toSync'] = $list['stats']['member_count'];
         $names[] = $list['name'];
         // Delete the old list info
         CmcHelperList::delete($list['id']);
         // Add the new list info
         $listModel = $this->getModel('List', 'cmcModel');
         $listModel->save($list);
         // Add the joomla list id
         $state->lists[$key]['id'] = $listModel->getState('list.id');
         // Delete users in that list
         CmcHelperUsers::delete($list['id']);
     }
     $state->header = JText::sprintf('COM_CMC_LISTS_TO_SYNC', count($state->lists));
     $state->message = JText::sprintf('COM_CMC_LISTS_TO_SYNC_DESC', '"' . implode('", "', $names) . '"', $state->lists[0]['name']);
     $state->offset = 0;
     CmcSyncerState::setState($state);
     $this->sendResponse($state);
 }
Exemplo n.º 2
0
/**
 * @author     Daniel Dimitrov <*****@*****.**>
 * @date       28.08.13
 *
 * @copyright  Copyright (C) 2008 - 2012 compojoom.com . All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */
defined('_JEXEC') or die('Restricted access');
CompojoomHtmlBehavior::bootstrap31(true, true, true, false);
jimport('joomla.filter.output');
JHTML::_('stylesheet', 'media/com_cmc/backend/css/cmc.css');
JHTML::_('script', 'media/com_cmc/backend/js/sync.js');
// Load bootstrap
$chimp = new CmcHelperChimp();
$lists = $chimp->lists();
?>

<script type="text/javascript">
	jQuery(document).ready(function () {
		new cmcSync();
	});
</script>
<div class="compojoom-bootstrap" style="clear: both">
	<div class="box-info">

		<h2 id="cmc-progress-header"><?php 
echo JText::_('COM_CMC_SYNCER_HEADER_INIT');
?>
</h2>