registry->router->getModel("acajoomjlite");
// Get subscription form data
$subscrictionData = $model->getSubscriptionFormData();
if($subscrictionData !== false){
$this->registry->template->subscriptionFormActive = 1;
$this->registry->template->subscriptionFormDetails = $subscrictionData;
} else {
$this->registry->template->subscriptionFormActive = 0;
}
// Gather data for newsletter statistics
$subscribers = $model->getSubscribers( 0, 25, '', $subscriberTotal);
$this->registry->template->subscriberAmount = $subscriberTotal;
$this->registry->template->newsletterAmount = $model->getNewsletterAmount();
$this->registry->template->newslettersSent = $model->getTotalHTMLEmailsSent();
$this->registry->template->css = 'css/admin.css';
$this->registry->template->title = 'Newsletter';
$this->registry->template->show('acajoom');
} // End function: index
public function subscribers(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Retrieve user inputs
$page = (int)JRequest::getVar('page', 1);
$amount = (int)JRequest::getVar('amount', 25);
$search = JRequest::getVar('emailsearch', '');
// Calculate the start page - the MySQL offset
if($page >= 2){ $start = ($page - 1) * $amount; } else { $start = 0; }
// Display all if amount is set to zero
if($amount == 0){ $amount = -1; }
$this->registry->template->subscribers = $model->getSubscribers($start, $amount, $search, $total);
$this->registry->template->resultPage = $page;
$this->registry->template->resultAmount = $amount;
$this->registry->template->subscriberTotal = $total;
$this->registry->template->resultsearch = $search;
$this->registry->template->css = 'css/admin.css';
$this->registry->template->js = 'js/joomla.js';
$this->registry->template->title = 'Newsletter';
$this->registry->template->show('subscriber');
} // End function: subscribers
public function removeSubscriber(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Retrieve user inputs
$id_list = JRequest::getVar('cid', false);
foreach($id_list as $id){
$model->deleteSubscriber($id);
}
$this->registry->router->redirect("?section=acajoom&task=subscribers","The subscriber or subscribers have successfully been deleted.");
} // End function: removeSubscriber()
public function addSubscriber(){
$this->registry->template->css = 'css/admin.css';
$this->registry->template->js = 'js/joomla.js';
$this->registry->template->title = 'Newsletter';
$this->registry->template->show('subscriberAdd');
} // End function: addSubscriber()
public function insertSubscriber(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Add user
$res = $model->addSubscriber();
if($res){
$this->registry->router->redirect("?section=acajoom&task=subscribers","New Subscriber successfully added.");
} else {
$this->registry->router->redirect("?section=acajoom&task=subscribers",'New Subscriber could not be added.');
}
} // End function: insertSubscriber()
public function newsletter(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Retrieve user inputs
$page = (int)JRequest::getVar('page', 1);
$amount = (int)JRequest::getVar('amount', 25);
$search = JRequest::getVar('newslettersearch', '');
// Calculate the start page - the MySQL offset
if($page >= 2){ $start = ($page - 1) * $amount; } else { $start = 0; }
// Display all if amount is set to zero
if($amount == 0){ $amount = -1; }
$this->registry->template->newsletters = $model->getNewsletters($start, $amount, $search, $total);
$this->registry->template->resultPage = $page;
$this->registry->template->resultAmount = $amount;
$this->registry->template->newsletterTotal = $total;
$this->registry->template->resultsearch = $search;
$this->registry->template->css = 'css/admin.css';
$this->registry->template->js = 'js/joomla.js';
$this->registry->template->title = 'Newsletter';
$this->registry->template->show('newsletter');
} // End function: newsletter
public function newsletterPreview(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Get newsletter id
$id = (int)JRequest::getVar('newsletter', false);
if($id !== false){
$this->registry->template->newsletter = $model->getNewsletter($id);
} else {
$this->registry->router->redirect("?section=acajoom&task=newsletter",'Failure retrieving Newsletter..');
exit;
}
$this->registry->template->css = 'css/admin.css';
$this->registry->template->js = 'js/joomla.js';
$this->registry->template->title = 'Newsletter';
$this->registry->template->show('newsletterPreview');
} // End function: newsletterPreview
public function addNewsletter(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Get the list - which defines newsletter defaults
$list = $model->getList();
// Pass data into view
$this->registry->template->NLsubject = '';
$this->registry->template->NLsenderName = $list->sendername;
$this->registry->template->NLsenderEmail = $list->senderemail;
$this->registry->template->NLreplyAddress = $list->bounceadres;
$editor =& JFactory::getEditor();
$this->registry->template->editor = $editor->display('content', htmlspecialchars($list->layout, ENT_QUOTES, 'UTF-8'), '600', '400', '60', '40', false);
$this->registry->template->css = 'css/admin.css';
$this->registry->template->js = 'js/joomla.js';
$this->registry->template->title = 'Newsletter';
$this->registry->template->show('newsletterAdd');
} // End function: addNewsletter()
public function insertNewsletter(){
$model =& $this->registry->router->getModel("acajoomjlite");
$result = $model->insertNewsletter();
if($result){
$this->registry->router->redirect("?section=acajoom&task=newsletter","Newsletter successfully created.");
} else {
$this->registry->router->redirect("?section=acajoom&task=newsletter","Failure creating newsletter.");
}
} // End function: insertNewsletter()
public function editNewsletter(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Get ID
$id = JRequest::getVar('newsletter', false);
if($id === false){
// Return to newsletters with message
}
$newsletter = $model->getNewsletter($id);
// Pass data into view
$this->registry->template->NLid = $id;
$this->registry->template->NLsubject = $newsletter->subject;
$this->registry->template->NLsenderName = $newsletter->fromname;
$this->registry->template->NLsenderEmail = $newsletter->fromemail;
$this->registry->template->NLreplyAddress = $newsletter->frombounce;
$editor =& JFactory::getEditor();
$this->registry->template->editor = $editor->display('content', htmlspecialchars($newsletter->htmlcontent, ENT_QUOTES, 'UTF-8'), '600', '400', '60', '40', false);
$this->registry->template->css = 'css/admin.css';
$this->registry->template->js = 'js/joomla.js';
$this->registry->template->title = 'Newsletter';
$this->registry->template->show('newsletterEdit');
}// End function - editNewsletter()
public function updateNewsletter(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Get ID
$id = JRequest::getVar('newsletter', false);
$result = $model->updateNewsletter($id);
if($result){
$this->registry->router->redirect("?section=acajoom&task=newsletter","Newsletter successfully updated.");
} else {
$this->registry->router->redirect("?section=acajoom&task=newsletter","Failure updating newsletter.");
}
} // End function: updateNewsletter()
public function removeNewsletter(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Retrieve user inputs
$id_list = JRequest::getVar('cid', false);
foreach($id_list as $id){
$res = $model->deleteNewsletter($id);
}
$this->registry->router->redirect("?section=acajoom&task=newsletter","The newsletter or newsletters have successfully been deleted.");
} // End function: removeNewsletter()
public function sendNewsletter(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Retrieve User input
$newsletterId = JRequest::getVar('newsletter', false);
$result = $model->sendNewsletter($newsletterId, 1, $errorMessage);
if($result){
// Mark newsletter as sent
$model->markNewsletterPublished($newsletterId);
$this->registry->router->redirect("?section=acajoom&task=newsletter","Your newsletter was successfully sent.");
} else {
$this->registry->router->redirect("?section=acajoom&task=newsletter","{$errorMessage}");
}
} // End function: sendNewsletter
public function updateSubscriptionForm(){
$model =& $this->registry->router->getModel("acajoomjlite");
// Get user inputs
$activated = (int)JRequest::getVar('activateSubs', 0);
$processOptions = JRequest::getVar('processOptions', false);
if($processOptions){
$headerActive = JRequest::getVar('activateHead', 0);
$header = JRequest::getVar('header', '');
$descActive = JRequest::getVar('activateDesc', 0);
$desc = JRequest::getVar('description', '');
$position = JRequest::getVar('position', 'right');
$model->updateSubscriptionForm($headerActive, $header, $descActive, $desc, $position);
}
// Update module published value
$model->updateSubFormStatus($activated);
$this->registry->router->redirect("?section=acajoom","Subscription form successfully updated.");
} // End function: updateSubscriptionForm
}// End class - acajoomControl