/** * Method to get an array of data items. * * @return mixed An array of data items on success, false on failure. * @since 1.6 */ public function getItems() { $items = array(); $news_id = JRequest::getInt('news_id', 0); if ($news_id != 0) { jincimport('core.newsletterfactory'); $ninstance = NewsletterFactory::getInstance(); if ($newsletter = $ninstance->loadNewsletter($news_id, false)) { $items = $newsletter->getTagsList(); } } $msg_id = JRequest::getInt('msg_id', 0); if ($msg_id != 0) { jincimport('core.messagefactory'); $minstance = MessageFactory::getInstance(); if ($message = $minstance->loadMessage($msg_id)) { $news_id = $message->get('news_id'); jincimport('core.newsletterfactory'); $ninstance = NewsletterFactory::getInstance(); if ($newsletter = $ninstance->loadNewsletter($news_id, false)) { $items = $newsletter->getTagsList(); if ($message->getType() == MESSAGE_TYPE_MASSIVE) { unset($items['USER']); } unset($items['OPTIN']); } } } return $items; }
function getData() { jincimport('core.messagefactory'); $msg_id = JRequest::getInt('id', 0, 'GET'); $minstance = MessageFactory::getInstance(); if (!($message = $minstance->loadMessage($msg_id))) { $this->setError('COM_JINC_ERR035'); return false; } return $message; }
function loadcss() { $doc = JFactory::getDocument(); // $doc->setMimeEncoding('text/css'); $tem_id = JRequest::getInt('id', 0); jincimport('core.messagefactory'); $minstance = MessageFactory::getInstance(); if (!($template = $minstance->loadTemplate($tem_id))) { return ''; } if (!($cssfile_content = $template->getCSSFileContent())) { return ''; } echo $cssfile_content; }
function getTemplateInfo() { header("Content-Type: text/plain; charset=UTF-8"); jincimport('core.messagefactory'); jincimport('utility.jsonresponse'); $tem_id = JRequest::getInt('id', 0); $minstance = MessageFactory::getInstance(); if (!($template = $minstance->loadTemplate($tem_id))) { $template = new MessageTemplate(0); } // Building JSON response $response = new JSONResponse(); $response->set('subject', $template->get('subject')); $response->set('body', $template->get('body')); echo $response->toString(); }
/** * The template loader. It load template associated to the message * * @access public * @param boolean $reload true to force newsletter info reloading * @return The loaded template * @since 1.0 * @see MessageFactory */ function loadTemplate($reload = false) { if (is_null($this->_template) || $reload) { $minstance = MessageFactory::getInstance(); $this->_template = $minstance->loadTemplate($this->get('tem_id')); if (!$this->_template) { $this->_template = null; } } return $this->_template; }
function deleteReport($proc_id) { jincimport('core.messagefactory'); jincimport('utility.jsonresponse'); jincimport('utility.servicelocator'); $servicelocator = ServiceLocator::getInstance(); $logger = $servicelocator->getLogger(); $response = new JSONResponse(); $minstance = MessageFactory::getInstance(); if ($minstance->deleteReport($proc_id)) { $response->set('status', 0); } else { $response->set('status', -1); } $logger->debug('JSON: ' . $response->toString()); return $response->toString(); }
/** * Play the process. It execute the next process step sending the message * to the next subscriber(s) * * @param string $client_id Client identifier * @return false if something wrong * @since 0.7 */ function play($client_id = '', $restart = false, $continue_on_error = false) { jincimport('core.messagefactory'); jincimport('utility.jsonresponse'); jincimport('utility.servicelocator'); $servicelocator = ServiceLocator::getInstance(); $logger = $servicelocator->getLogger(); $dbo = JFactory::getDBO(); if ($this->status == PROCESS_STATUS_RUNNING && $this->client_id != $client_id) { $this->setError('COM_JINC_ERR042'); return false; } $start_time = 0; if ($this->status != PROCESS_STATUS_RUNNING) { if ($this->client_id == '') { $start_time = time(); $this->start_time = $start_time; } if ($this->status == PROCESS_STATUS_STOPPED) { $start_time = time(); $this->start_time = $start_time; $this->last_subscriber_time = 0; $this->last_update_time = 0; $this->sent_messages = 0; $this->sent_success = 0; } if ($this->client_id != $client_id) { if (!$this->updateStatus(PROCESS_STATUS_RUNNING, $client_id)) { return false; } } } $msg_id = $this->msg_id; $minstance = MessageFactory::getInstance(); if ($message = $minstance->loadMessage($msg_id)) { if ($newsletter = $message->loadNewsletter()) { $this->tot_recipients = $newsletter->countSubscribers(); if ($this->tot_recipients < 0) { $this->setError('COM_JINC_ERR007'); return false; } } else { $this->setError('COM_JINC_ERR001'); return false; } } else { $this->setError('COM_JINC_ERR035'); return false; } $logger->finer('Sending process: ' . $this->last_subscriber_time . ' - ' . $this->last_subscriber_id); $news_id = $newsletter->get('id'); if ($send_result = $message->send($this->last_subscriber_time, $this->last_subscriber_id, $continue_on_error)) { $this->storeReportData($message->reported_recipients); $last_time = $send_result['last_time']; $last_id = $send_result['last_id']; $this->sent_messages = $this->sent_messages + $send_result['nmessages']; $this->sent_success = $this->sent_success + $send_result['nsuccess']; if ($send_result['nmessages'] == 0) { $this->updateStatus(PROCESS_STATUS_FINISHED); $logger->finer('Process: triggering message sent event'); $dispatcher = JDispatcher::getInstance(); $params = array('news_id' => $news_id, 'msg_id' => $msg_id); $result = $dispatcher->trigger('jinc_sent', $params); } $query = 'UPDATE #__jinc_process ' . 'SET last_subscriber_time = FROM_UNIXTIME(' . $last_time . '), ' . 'last_update_time = NOW(), ' . 'last_subscriber_id = ' . $last_id . ', ' . 'sent_success = ' . $this->sent_success . ', ' . 'sent_messages = ' . $this->sent_messages . ' '; if ($start_time > 0) { $query .= ', start_time = FROM_UNIXTIME(' . $start_time . ') '; } $query .= 'WHERE id = ' . $this->id; $dbo->setQuery($query); $logger->debug('Process: executing query: ' . $query); if (!$dbo->query()) { $this->setError('COM_JINC_ERR039'); return false; } if (!$this->reloadStatus()) { $this->setError('COM_JINC_ERR039'); return false; } $this->last_subscriber_time = $last_time; $this->last_subscriber_id = $last_id; $this->mail_system_error = $message->get('mail_system_error'); } else { $this->storeReportData($message->reported_recipients); $logger->finer('StandardProcess: Error sending messages.'); if (!$this->updateStatus(PROCESS_STATUS_PAUSED)) { $this->setError('COM_JINC_ERR040'); } $this->setError($message->getError()); $this->mail_system_error = $message->get('mail_system_error'); return false; } return true; }