Esempio n. 1
0
 function preview($key = null, $urlVar = null)
 {
     $model = $this->getModel();
     $table = $model->getTable();
     $id = JRequest::getInt('id', 0);
     $to_yourself = JRequest::getString('to_yourself', 'off');
     $yourself = strtolower($to_yourself) == 'on';
     $to_addresses = JRequest::getString('to_addresses', '');
     $to_addresses = str_replace(' ', '', $to_addresses);
     jincimport('utility.inputchecker');
     $addresses = explode(',', $to_addresses);
     foreach (array_reverse($addresses, true) as $key => $email) {
         if (!InputChecker::checkMail($email)) {
             unset($addresses[$key]);
         }
     }
     if (empty($key)) {
         $key = $table->getKeyName();
     }
     if (empty($urlVar)) {
         $urlVar = $key;
     }
     $result = $model->preview($id, $yourself, $addresses);
     if ($result === false) {
         $this->setError(JText::sprintf('COM_JINC_ERR001', JText::_($model->getError())));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect('index.php?option=com_jinc&view=message&layout=preview&tmpl=component&id=' . $id, $msg);
         return false;
     }
     $tostring = count($result) > 0 ? implode(',', $result) : JText::_('COM_JINC_ANYONE');
     $msg = JText::sprintf('COM_JINC_INF002', $tostring);
     $this->setRedirect('index.php?option=com_jinc&view=message&layout=preview&id=' . $id, $msg);
     return true;
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 function display($tpl = null)
 {
     $layout = $this->getLayout();
     if ($layout == 'multisubscription') {
         $this->newsletters = array();
         if (isset($this->mmsg)) {
             jincimport('utility.servicelocator');
             $servicelocator = ServiceLocator::getInstance();
             $logger = $servicelocator->getLogger();
             jincimport('core.newsletterfactory');
             $ninstance = NewsletterFactory::getInstance();
             foreach ($this->mmsg as $news_id => $text) {
                 if ($newsletter = $ninstance->loadNewsletter($news_id, true)) {
                     $this->newsletters[$news_id] = $newsletter;
                 }
             }
         }
     } else {
         $news_id = JRequest::getInt('id', 0);
         jincimport('core.newsletterfactory');
         $ninstance = NewsletterFactory::getInstance();
         if ($newsletter = $ninstance->loadNewsletter($news_id, true)) {
             $this->newsletter = $newsletter;
         }
     }
     parent::display($tpl);
 }
Esempio n. 4
0
 /**
  * Update method to register message sending events.
  *
  * @access	public
  * @param $args['news_id'] Newsletter identifier refferring to the event.
  * * @param $args['msg_id'] Message identifier refferring to the event.
  * @return  false if something wrong.
  * @since	0.6
  */
 function update(&$args)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (!isset($args['news_id']) || !isset($args['msg_id'])) {
         return false;
     }
     $news_id = (int) $args['news_id'];
     $msg_id = (int) $args['msg_id'];
     $dbo =& JFactory::getDBO();
     $query = 'UPDATE #__jinc_newsletter SET lastsent = now() ' . 'WHERE id = ' . (int) $news_id;
     $dbo->setQuery($query);
     $logger->debug('SentMsgEvent: executing query: ' . $query);
     if (!$dbo->query()) {
         $logger->error('SentMsgEvent: error updating last newsletter dispatch date');
         return false;
     }
     $query = 'UPDATE #__jinc_message SET datasent = now() ' . 'WHERE id = ' . (int) $msg_id;
     $dbo->setQuery($query);
     $logger->debug('SentMsgEvent: executing query: ' . $query);
     if (!$dbo->query()) {
         $logger->error('SentMsgEvent: error updating last message dispatch date');
         return false;
     }
     return true;
 }
Esempio n. 5
0
 /**
  * The newsletter importer. It imports newsletter subscribers from a CSV file.
  *
  * @access	public
  * @param	integer $newsletter a newsletter object.
  * @param	string  $csvfile_name the CSV file name.
  * @return  array containing import results.
  * @since	0.6
  * @see     Newsletter
  */
 function ImportFromCSV($newsletter, $csvfile_name)
 {
     jincimport('utility.jincjoomlahelper');
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (!($handle = @fopen($csvfile_name, "r"))) {
         $logger->finer('NewsletterImporter: unable to open ' . $csvfile_name);
         return false;
     }
     $result = array();
     while (($data = fgetcsv($handle, $this->_LINE_MAX_LENGTH, ",")) !== FALSE) {
         $logger->finer('NewsletterImporter: importing ' . implode(', ', $data));
         $info = $newsletter->getSubscriptionInfo();
         $subscriber_info = array();
         $attributes = array();
         for ($i = 0; $i < count($info); $i++) {
             $prefix = substr($info[$i], 0, 5);
             if ($prefix == 'attr_') {
                 $suffix = substr($info[$i], 5);
                 $attributes[$suffix] = isset($data[$i]) ? $data[$i] : '';
             } else {
                 $subscriber_info[$info[$i]] = $data[$i];
             }
         }
         $sub_result = array();
         $sub_result['data'] = implode(', ', $subscriber_info);
         switch ($newsletter->getType()) {
             case NEWSLETTER_PUBLIC_NEWS:
                 $subscriber_info['noptin'] = true;
                 break;
             case NEWSLETTER_PRIVATE_NEWS:
                 $user_id = $subscriber_info['user_id'];
                 $user_info = JINCJoomlaHelper::getUserInfo($user_id);
                 if (empty($user_info)) {
                     $user_info = JINCJoomlaHelper::getUserInfoByUsername($user_id);
                     if (empty($user_info)) {
                         $user_info = JINCJoomlaHelper::getUserInfoByUsermail($user_id);
                         if (!empty($user_info)) {
                             $subscriber_info['user_id'] = $user_info['id'];
                         }
                     } else {
                         $subscriber_info['user_id'] = $user_info['id'];
                     }
                 }
                 break;
             default:
                 break;
         }
         if ($newsletter->subscribe($subscriber_info, $attributes)) {
             $sub_result['result'] = 'OK';
         } else {
             $sub_result['result'] = $newsletter->getError();
         }
         array_push($result, $sub_result);
     }
     fclose($handle);
     return $result;
 }
Esempio n. 6
0
 /**
  * Redefine setError method inherited from Joomla! JObject class
  *
  * @access	public
  * @since	0.6
  */
 function setError($error)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $logger->finer(get_class($this) . ': ' . JText::_($error));
     parent::setError($error);
 }
Esempio n. 7
0
 protected function getInput()
 {
     jincimport('core.newsletterfactory');
     $themes = array();
     $ninstance = NewsletterFactory::getInstance();
     if ($themes = $ninstance->loadThemes()) {
         return JHTML::_('select.genericlist', $themes, $this->name, 'class="inputbox"', 'value', 'id', $this->value, $this->id);
     }
     return false;
 }
Esempio n. 8
0
 public function getInfo()
 {
     if ($item = parent::getItem()) {
         jincimport('core.newsletterfactory');
         $ninstance = NewsletterFactory::getInstance();
         if ($newsletter = $ninstance->loadNewsletter($item->news_id)) {
             return $newsletter->getSubscriber($item->id);
         }
     }
     return false;
 }
Esempio n. 9
0
 function getData()
 {
     jincimport('core.newsletterfactory');
     $id = JRequest::getInt('id', 0, 'GET');
     $ninstance = NewsletterFactory::getInstance();
     if (!($notice = $ninstance->loadNotice($id))) {
         $this->setError('COM_JINC_ERR023');
         return false;
     }
     return $notice;
 }
Esempio n. 10
0
 protected function addToolbar()
 {
     JHTML::stylesheet('administrator/components/com_jinc/assets/css/jinc_admin.css');
     JToolBarHelper::title(JText::_('COM_JINC_MENU_SUBSCRIBERS'), 'jinc');
     $bar = JToolBar::getInstance('toolbar');
     $bar->appendButton('Popup', 'addsubscriber', 'COM_JINC_ADDSUBSCRIBER', 'index.php?option=com_jinc&amp;view=newsletter&amp;tmpl=component&amp;layout=addsubscriber', 875, 550, 0, 0, '');
     JToolBarHelper::custom('subscribers.approve', 'approve', 'approve', 'COM_JINC_APPROVE', true);
     JToolBarHelper::deleteList(JText::_('COM_JINC_WARNING_DELETE_ITEMS'), 'subscribers.delete');
     jincimport('utility.jinchelper');
     JINCHelper::helpOnLine(98);
 }
Esempio n. 11
0
 protected function addToolbar()
 {
     $state = $this->get('State');
     JHTML::stylesheet('administrator/components/com_jinc/assets/css/jinc_admin.css');
     JToolBarHelper::title(JText::_('COM_JINC_MENU_TEMPLATES'), 'jinc');
     JToolBarHelper::addNew('template.add', 'JTOOLBAR_NEW');
     JToolBarHelper::editList('template.edit', 'JTOOLBAR_EDIT');
     JToolBarHelper::deleteList(JText::_('COM_JINC_WARNING_DELETE_ITEMS'), 'templates.delete');
     jincimport('utility.jinchelper');
     JINCHelper::helpOnLine(95);
 }
Esempio n. 12
0
 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;
 }
Esempio n. 13
0
 /**
  * Method to render a statistical chart using built-in image.
  *
  * @return false if someting wrong
  */
 function render()
 {
     jincimport("graphics.gchart");
     jincimport("graphics.gimage");
     $chart = new GChart($this->get('legend'), 700, 200);
     $chart->addLine($this->get('values'));
     $chart->setXMargin(25);
     $chart->setYMargin(25);
     $chart->setGridColor(192, 192, 192);
     $c = new GImage(750, 250);
     $c->display($chart);
     $c->close();
 }
Esempio n. 14
0
    function setTemplate($id)
    {
        if (empty($id)) {
            return;
        }
        $app = JFactory::getApplication();
        $cssurl = rtrim(JURI::root(), '/') . '/' . 'administrator/index.php?option=com_jinc&task=templatecss.loadcss&format=css&id=' . $id . '&time=' . time();
        $filepath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'templates' . DS . $id . '.css';
        $filepath = str_replace('/', DS, $filepath);
        $name = $this->myEditor->get('_name');
        if ($name == 'tinymce') {
            $this->editorConfig = array('content_css_custom' => $cssurl, 'content_css' => '0');
        } elseif ($name == 'jckeditor' || $name == 'fckeditor') {
            $this->editorConfig = array('content_css_custom' => $filepath, 'content_css' => '0', 'editor_css' => '0');
        } else {
            $fileurl = 'administrator/components/com_jinc/assets/templates/' . $id . '.css';
            $this->editorConfig = array('custom_css_url' => $cssurl, 'custom_css_file' => $fileurl, 'custom_css_path' => $filepath);
            JRequest::setVar('jinc_cssfile', $fileurl);
            if ($name == 'jce') {
                $jcepath = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jce' . DS . 'models' . DS;
                if (file_exists($jcepath . 'editor.php')) {
                    jimport('joomla.filesystem.file');
                    $content = JFile::read($jcepath . 'editor.php');
                    if (!strpos($content, 'jinc_cssfile')) {
                        $jinccode = '
			if(JRequest::getCmd(\'option\') == \'com_jinc\'){
				$jinc_cssfile = JRequest::getString(\'jinc_cssfile\');
				if(!empty($jinc_cssfile)) $settings[\'content_css\'] = $jinc_cssfile;
			}
			';
                        $content = preg_replace('#(\\$settings\\[\'content_css\'\\][^=]*= *\\$this->getStyleSheets\\(\\);)#', '$1' . $jinccode, $content);
                        jincimport('utility.servicelocator');
                        $servicelocator = ServiceLocator::getInstance();
                        $logger = $servicelocator->getLogger();
                        if (strpos($content, 'jinc_cssfile')) {
                            if (!file_exists($jcepath . 'editor_jbackup.php')) {
                                if (JFile::copy($jcepath . 'editor.php', $jcepath . 'editor_jbackup.php') !== true) {
                                    $logger->info('JINCEditor - Could not copy the file from ' . $jcepath . 'editor.php to ' . $jcepath . 'editor_jbackup.php', 'error');
                                }
                            }
                            if (JFile::write($jcepath . 'editor.php', $content) !== true) {
                                $logger->info('Could not write in ' . $jcepath . 'editor.php <br/> Please make sure this folder is writable', 'error');
                            }
                        }
                    }
                }
            }
        }
    }
Esempio n. 15
0
 function display($tpl = null)
 {
     JHTML::stylesheet('administrator/components/com_jinc/assets/css/jinc_admin.css');
     JToolBarHelper::title(JText::_('COM_JINC_CPANEL_JINC'), 'jinc');
     JToolBarHelper::preferences('com_jinc', '550');
     jincimport('utility.jinchelper');
     JINCHelper::helpOnLine(87);
     $version = JINCHelper::getJINCVersion();
     $copyright = JINCHelper::getJINCCopyright();
     $license = JINCHelper::getJINCLicense();
     $this->assignRef('version', $version);
     $this->assignRef('copyright', $copyright);
     $this->assignRef('license', $license);
     parent::display($tpl);
 }
Esempio n. 16
0
 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;
 }
Esempio n. 17
0
 protected function addToolbar()
 {
     JHTML::stylesheet('administrator/components/com_jinc/assets/css/jinc_admin.css');
     JToolBarHelper::title(JText::_('COM_JINC_MENU_NEWSLETTERS'), 'jinc');
     $bar = JToolBar::getInstance('toolbar');
     $bar->appendButton('Popup', 'attributes', 'COM_JINC_ATTRIBUTES', 'index.php?option=com_jinc&amp;view=attributes&amp;tmpl=component', 875, 550, 0, 0, '');
     JToolBarHelper::divider();
     JToolBarHelper::addNew('newsletter.add', 'JTOOLBAR_NEW');
     JToolBarHelper::editList('newsletter.edit', 'JTOOLBAR_EDIT');
     JToolBarHelper::deleteList(JText::_('COM_JINC_WARNING_DELETE_ITEMS'), 'newsletters.delete');
     JToolBarHelper::divider();
     JToolBarHelper::custom('newsletters.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
     JToolBarHelper::custom('newsletters.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
     jincimport('utility.jinchelper');
     JINCHelper::helpOnLine(88);
 }
Esempio n. 18
0
 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();
 }
Esempio n. 19
0
 /**
  * Update method to register statistical events.
  *
  * @access	public
  * @param $args['news_id'] Newsletter identifier refferring to the event.
  * @return  false if something wrong.
  * @since	0.6
  */
 function update(&$args)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if ($this->_type < 0 || !isset($args['news_id'])) {
         return false;
     }
     $query = 'INSERT INTO `#__jinc_stats_event` ' . '(`type`, `date`, `news_id`) VALUES ' . '(' . (int) $this->_type . ', now(), ' . (int) $args['news_id'] . ')';
     $logger->debug('StatisticalEvent: Executing query: ' . $query);
     $dbo =& JFactory::getDBO();
     $dbo->setQuery($query);
     if (!$dbo->query()) {
         return false;
     }
     return true;
 }
Esempio n. 20
0
 protected function addToolbar()
 {
     $state = $this->get('State');
     JHTML::stylesheet('administrator/components/com_jinc/assets/css/jinc_admin.css');
     JToolBarHelper::title(JText::_('COM_JINC_MENU_MESSAGES'), 'jinc');
     // $bar = JToolBar::getInstance('toolbar');
     // $bar->appendButton('Popup', 'jincpreview', 'COM_JINC_JTOOLBAR_PREVIEW', 'index.php?option=com_jinc&amp;view=message&amp;tmpl=component&amp;layout=preview', 875, 550, 0, 0, '');
     JToolBarHelper::custom('message.previewPage', 'jincpreview', 'jincpreview', 'COM_JINC_JTOOLBAR_PREVIEW', false);
     JToolBarHelper::custom('message.sendPage', 'jincsend', 'jincsend', 'COM_JINC_JTOOLBAR_SEND', false);
     JToolBarHelper::custom('message.history', 'jinchistory', 'jinchistory', 'COM_JINC_JTOOLBAR_HISTORY', false);
     JToolBarHelper::divider();
     JToolBarHelper::addNew('message.add', 'JTOOLBAR_NEW');
     JToolBarHelper::editList('message.edit', 'JTOOLBAR_EDIT');
     JToolBarHelper::deleteList(JText::_('COM_JINC_WARNING_DELETE_ITEMS'), 'messages.delete');
     jincimport('utility.jinchelper');
     JINCHelper::helpOnLine(89);
 }
Esempio n. 21
0
 /**
  * Method to get a single record.
  *
  * @param	integer	The id of the primary key.
  *
  * @return	mixed	Object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $item = parent::getItem($pk);
     if (strlen($item->cssfile) > 0) {
         $item->cssfile_abs = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'templates' . DS . $item->cssfile;
         $logger->debug('JINCModelTemplate - Reading CSS file ' . $item->cssfile_abs);
         $item->cssfile_content = is_readable($item->cssfile_abs) ? file_get_contents($item->cssfile_abs) : false;
         if (!$item->cssfile_content) {
             $logger->debug('JINCModelTemplate - Error reading CSS file ' . $item->cssfile_abs);
         }
     }
     return $item;
 }
Esempio n. 22
0
 function getDefaultTemplate()
 {
     header("Content-Type: text/plain; charset=UTF-8");
     jincimport('core.newsletterfactory');
     jincimport('utility.jsonresponse');
     jincimport('utility.jinchtmlhelper');
     $id = JRequest::getInt('id', 0);
     $tem_id = 0;
     $tag_string = '';
     $ninstance = NewsletterFactory::getInstance();
     if ($newsletter = $ninstance->loadNewsletter($id, false)) {
         $tem_id = $newsletter->get('default_template');
     }
     // Building JSON response
     $response = new JSONResponse();
     $response->set('tem_id', (int) $tem_id);
     echo $response->toString();
 }
Esempio n. 23
0
 protected function addToolbar()
 {
     JRequest::setVar('hidemainmenu', true);
     JHTML::stylesheet('administrator/components/com_jinc/assets/css/jinc_admin.css');
     $isNew = $this->item->id == 0;
     $text = $isNew ? JText::_('NEW') : JText::_('EDIT');
     JToolBarHelper::title(JText::_('COM_JINC_TEMPLATE') . ': <small><small>[ ' . $text . ' ]</small></small>', 'jinc');
     JToolBarHelper::apply('template.apply', 'JTOOLBAR_APPLY');
     JToolBarHelper::save('template.save', 'JTOOLBAR_SAVE');
     JToolBarHelper::addNew('template.save2new', 'JTOOLBAR_SAVE_AND_NEW');
     if (empty($this->item->id)) {
         JToolBarHelper::cancel('template.cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::cancel('template.cancel', 'JTOOLBAR_CLOSE');
     }
     jincimport('utility.jinchelper');
     JINCHelper::helpOnLine(95);
 }
Esempio n. 24
0
 function stats()
 {
     jincimport('statistics.statisticfactory');
     jincimport('core.newsletterfactory');
     $session = JFactory::getSession();
     $config = JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $id = JRequest::getInt('id', 0);
     $stat_type = JRequest::getInt('stat_type', 0);
     $time_type = JRequest::getInt('time_type', 0);
     $start_date = JRequest::getString('start_date');
     $end_date = JRequest::getString('end_date');
     $sdate = JFactory::getDate($start_date, $tzoffset);
     $edate = JFactory::getDate($end_date, $tzoffset);
     $stat = StatisticFactory::getStatistic($stat_type, $time_type, $sdate->toUNIX(), $edate->toUNIX(), $id);
     $values = $stat->getValues();
     $legend = $stat->getTimeValues();
     $session->set('stats.values', $values);
     $session->set('stats.legend', $legend);
     $timeline = $stat->getTimeLine();
     JRequest::setVar('start_date', $timeline->getStartTime());
     JRequest::setVar('end_date', $timeline->getEndTime());
     $stattypes = StatisticFactory::getTypeList();
     $timetypes = StatisticFactory::getTimeList();
     $time_format = $timeline->getJFormat();
     JRequest::setVar('view', 'stats');
     $view = $this->getView('stats', 'html');
     $ninstance = NewsletterFactory::getInstance();
     if ($newsletters = $ninstance->loadNames()) {
         $empty_filter = array("id" => "0", "name" => JText::_('COM_JINC_SELECT_NEWSLETTER'));
         array_unshift($newsletters, $empty_filter);
     } else {
         $newsletters = array(array("id" => "0", "name" => JText::_('COM_JINC_SELECT_NEWSLETTER')));
     }
     $view->assignRef('time_format', $time_format);
     $view->assignRef('stattypes', $stattypes);
     $view->assignRef('timetypes', $timetypes);
     $view->assignRef('newsletters', $newsletters);
     parent::display();
 }
Esempio n. 25
0
 function display($tpl = null)
 {
     jincimport('statistics.statisticfactory');
     JHTML::stylesheet('administrator/components/com_jinc/assets/css/jinc_admin.css');
     JToolBarHelper::title(JText::_('COM_JINC_STATISTICS'), 'jinc');
     jincimport('utility.jinchelper');
     JINCHelper::helpOnLine(91);
     $session =& JFactory::getSession();
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $this->news_id = JRequest::getInt('id', 0);
     $this->stat_type = JRequest::getInt('stat_type', STATISTICFACTORY_SUBS_TYPE);
     $this->time_type = JRequest::getInt('time_type', STATISTICFACTORY_STAT_DAILY);
     $start_date = JRequest::getFloat('start_date', time());
     $end_date = JRequest::getFloat('end_date', time());
     $sdate =& JFactory::getDate($start_date, $tzoffset);
     $edate =& JFactory::getDate($end_date, $tzoffset);
     $this->start_time = $sdate;
     $this->end_time = $edate;
     $this->values = $session->get('stats.values');
     $this->legend = $session->get('stats.legend');
     parent::display($tpl);
 }
 /**
  * Update method to register subscription notify event.
  *
  * @access	public
  * @param $args['news_name'] Newsletter name refferring to the event.
  * @param $args['subs_name'] Name of the subscriber just registered.
  * @return  false if something wrong.
  * @since	0.8
  */
 function update(&$args)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     if (isset($args['news_notify']) && $args['news_notify']) {
         $logger->finer('SubscriptionNotifyEvent: Notifying subscription for ' . $args['news_name']);
         if (!isset($args['subs_name']) || !isset($args['news_name'])) {
             return false;
         }
         $news_name = $args['news_name'];
         $subs_name = $args['subs_name'];
         $dbo =& JFactory::getDBO();
         //get all super administrator
         $query = 'SELECT name, email, sendEmail FROM `#__users` u INNER JOIN ' . '`#__user_usergroup_map` m on u.id = m.user_id INNER JOIN ' . '`#__usergroups` g on m.group_id = g.id ' . 'WHERE lower(g.title) = "super users"';
         $logger->debug('SubscriptionNotifyEvent: executing query: ' . $query);
         $dbo->setQuery($query);
         if ($rows = $dbo->loadObjectList()) {
             // Sending notification to all administrators
             $subject = sprintf(JText::_('COM_JINC_MAIL_NOTIFY_SUBJECT'), $news_name);
             $subject = html_entity_decode($subject, ENT_QUOTES);
             foreach ($rows as $row) {
                 if ($row->sendEmail) {
                     $body = sprintf(JText::_('COM_JINC_MAIL_NOTIFY_BODY'), $row->name, $news_name, $subs_name);
                     $body = html_entity_decode($body, ENT_QUOTES);
                     $message =& JFactory::getMailer();
                     $message->setSubject($subject);
                     $message->setBody($body);
                     $message->addRecipient($row->email);
                     $logger->finer('SubscriptionNotifyEvent: Sending notification mail to ' . $row->email);
                     $message->send();
                 }
             }
         }
     }
     return true;
 }
Esempio n. 27
0
 /**
  * The notice loader. It loads a notice from its identifier.
  *
  * @access	public
  * @param	integer $id the notice identifier.
  * @return  The notice object or false if something wrong.
  * @since	0.9
  * @see     Newsletter
  */
 function loadNotice($id)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $query = 'SELECT name, title, bdesc, conditions ' . 'FROM #__jinc_notice nt ' . 'WHERE id = ' . (int) $id;
     $logger->debug('NewsletterFactory: Executing query: ' . $query);
     $dbo =& JFactory::getDBO();
     $dbo->setQuery($query);
     // Loading notice information from database
     if ($result = $dbo->loadAssocList()) {
         if (empty($result)) {
             // Newsletter not found in database
             $logger->finer('NewsletterFactory: Notice not found');
             return false;
         }
         $notice = $result[0];
     } else {
         return false;
     }
     $ntObj = new Notice($id);
     // Setting newsletter properties
     $ntObj->set('name', $notice['name']);
     $ntObj->set('title', $notice['title']);
     $ntObj->set('bdesc', $notice['bdesc']);
     $ntObj->set('conditions', $notice['conditions']);
     return $ntObj;
 }
Esempio n. 28
0
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   JINC is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with JINC.  If not, see <http://www.gnu.org/licenses/>.
 */
defined('_JEXEC') or die('Restricted access');
isset($this->items) or die('Items not defined');
JHtml::_('behavior.modal');
jincimport('utility.jinchtmlhelper');
jincimport('core.newsletter');
JINCHTMLHelper::hint('SUBSCRIBERS_LIST', 'SUBSCRIBERS_LIST_TITLE');
$listOrder = $this->state->get('list.ordering');
$listDirn = $this->state->get('list.direction');
?>
<form action="index.php" method="post" name="adminForm">
    <fieldset id="filter-bar">
        <div class="filter-search fltlft">
            <label class="filter-search-lbl" for="filter_search"><?php 
echo JText::_('JSEARCH_FILTER_LABEL');
?>
</label>
            <input type="text" name="filter_search" id="filter_search" value="<?php 
echo $this->escape($this->state->get('filter.search'));
?>
" title="<?php 
Esempio n. 29
0
 /**
  * Check if every mandatory attribute are avaivalable for subscription purpose.
  *
  * @access	protected
  * @param   integer $attributes list of attribute values
  * @since	0.7
  * @abstract
  */
 function checkMandatoryAttributes($attributes)
 {
     jincimport('utility.servicelocator');
     $servicelocator = ServiceLocator::getInstance();
     $logger = $servicelocator->getLogger();
     $news_attributes = $this->attributes;
     foreach ($news_attributes->toArray() as $attr_name => $attr_cardinality) {
         if ($attr_cardinality == ATTRIBUTE_MANDATORY) {
             if (!in_array($attr_name, array_keys($attributes)) || strlen(trim($attributes[$attr_name])) == 0) {
                 $logger->finer("Newsletter. Mandatory attribute not defined: " . $attr_name);
                 return false;
             }
         }
     }
     return true;
 }
Esempio n. 30
0
    function statChart()
    {
        jincimport('utility.parameterprovider');
        jincimport('graphics.chartrenderer');
        $chart_system = ParameterProvider::getChartSystem();
        if ($chart_system == STATSRENDERER_BUILTIN) {
            echo '<img align="center" src="index.php?option=com_jinc&task=newsletter.statsRender&format=json" alt="Chart">';
        } else {
            jincimport('graphics.openflashrenderer');
            $session = JFactory::getSession();
            $values = $session->get('stats.values');
            $legend = $session->get('stats.legend');
            $renderer = new OpenFlashRenderer($values, $legend);
            $chart = $renderer->render();
            ?>
<br>
<script type="text/javascript" src="components/com_jinc/assets/js/json2.js"></script>
<script type="text/javascript" src="components/com_jinc/assets/js/swfobject.js"></script>
<script type="text/javascript">
    swfobject.embedSWF("components/com_jinc/assets/flash/open-flash-chart.swf", "my_chart", "750", "250", "9.0.0");
</script>
<script type="text/javascript">

    function ofc_ready() {
    }

    function open_flash_chart_data() {
        return JSON.stringify(data);
    }

    function findSWF(movieName) {
        if (navigator.appName.indexOf("Microsoft")!= -1) {
            return window[movieName];
        } else {
            return document[movieName];
        }
    }

    var data = <?php 
            echo $chart->toPrettyString();
            ?>
;

</script>
<div id="my_chart"></div>
        <?php 
        }
    }