From 0eb4a46050f687a94b14a10c04e2d587eb88c369 Mon Sep 17 00:00:00 2001 From: Manoj L Date: Mon, 8 Jun 2020 15:38:04 +0530 Subject: [PATCH] Issue #48 chore: Log Email details in DB table - Tj Notification --- src/com_tjnotifications/admin/access.xml | 22 +-- .../admin/assets/css/tjnotifcations.css | 3 + src/com_tjnotifications/admin/config.xml | 6 + .../admin/controllers/log.php | 23 +++ .../admin/controllers/logs.php | 40 ++++ .../admin/helpers/tjnotifications.php | 14 +- .../admin/models/forms/filter_logs.xml | 23 +++ src/com_tjnotifications/admin/models/log.php | 62 +++++++ src/com_tjnotifications/admin/models/logs.php | 157 ++++++++++++++++ .../admin/sql/install.mysql.utf8.sql | 25 ++- .../admin/sql/updates/mysql/1.2.0.sql | 21 +++ src/com_tjnotifications/admin/tables/log.php | 32 ++++ .../admin/views/logs/index.html | 1 + .../admin/views/logs/tmpl/body.php | 38 ++++ .../admin/views/logs/tmpl/default.php | 172 ++++++++++++++++++ .../admin/views/logs/tmpl/default.xml | 8 + .../admin/views/logs/tmpl/index.html | 1 + .../admin/views/logs/tmpl/param.php | 36 ++++ .../admin/views/logs/view.csv.php | 34 ++++ .../admin/views/logs/view.html.php | 94 ++++++++++ src/com_tjnotifications/tjnotifications.xml | 9 + 21 files changed, 807 insertions(+), 14 deletions(-) create mode 100644 src/com_tjnotifications/admin/assets/css/tjnotifcations.css create mode 100644 src/com_tjnotifications/admin/controllers/log.php create mode 100644 src/com_tjnotifications/admin/controllers/logs.php create mode 100644 src/com_tjnotifications/admin/models/forms/filter_logs.xml create mode 100644 src/com_tjnotifications/admin/models/log.php create mode 100644 src/com_tjnotifications/admin/models/logs.php create mode 100644 src/com_tjnotifications/admin/tables/log.php create mode 100644 src/com_tjnotifications/admin/views/logs/index.html create mode 100644 src/com_tjnotifications/admin/views/logs/tmpl/body.php create mode 100644 src/com_tjnotifications/admin/views/logs/tmpl/default.php create mode 100644 src/com_tjnotifications/admin/views/logs/tmpl/default.xml create mode 100644 src/com_tjnotifications/admin/views/logs/tmpl/index.html create mode 100644 src/com_tjnotifications/admin/views/logs/tmpl/param.php create mode 100644 src/com_tjnotifications/admin/views/logs/view.csv.php create mode 100644 src/com_tjnotifications/admin/views/logs/view.html.php diff --git a/src/com_tjnotifications/admin/access.xml b/src/com_tjnotifications/admin/access.xml index 6f332e3e..8aa6b153 100644 --- a/src/com_tjnotifications/admin/access.xml +++ b/src/com_tjnotifications/admin/access.xml @@ -1,18 +1,18 @@
- - - - - - - - - - - + + + + + + + + + + +
diff --git a/src/com_tjnotifications/admin/assets/css/tjnotifcations.css b/src/com_tjnotifications/admin/assets/css/tjnotifcations.css new file mode 100644 index 00000000..bbb6f4eb --- /dev/null +++ b/src/com_tjnotifications/admin/assets/css/tjnotifcations.css @@ -0,0 +1,3 @@ +.minwidth-150px{min-width:150px} +.minwidth-100px{min-width:100px} +.table-responsive{width:100%;margin-bottom:15px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar} diff --git a/src/com_tjnotifications/admin/config.xml b/src/com_tjnotifications/admin/config.xml index ccbd80c3..11f2b961 100644 --- a/src/com_tjnotifications/admin/config.xml +++ b/src/com_tjnotifications/admin/config.xml @@ -1,5 +1,11 @@ +
+ + + + +
diff --git a/src/com_tjnotifications/admin/controllers/log.php b/src/com_tjnotifications/admin/controllers/log.php new file mode 100644 index 00000000..8e61b5e2 --- /dev/null +++ b/src/com_tjnotifications/admin/controllers/log.php @@ -0,0 +1,23 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\MVC\Controller\FormController; + +/** + * Log Controller + * + * @since 1.1.0 + */ +class TjnotificationsControllerLog extends FormController +{ +} diff --git a/src/com_tjnotifications/admin/controllers/logs.php b/src/com_tjnotifications/admin/controllers/logs.php new file mode 100644 index 00000000..75d6cdec --- /dev/null +++ b/src/com_tjnotifications/admin/controllers/logs.php @@ -0,0 +1,40 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\MVC\Controller\AdminController; + +/** + * Logs controller class. + * + * @since 1.1.0 + */ +class TjnotificationsControllerLogs extends AdminController +{ + /** + * Proxy for getModel. + * + * @param string $name The name of the model. + * @param string $prefix The prefix for the PHP class name. + * @param array $config Array of configuration parameters. + * + * @return JModelLegacy + * + * @since 1.1.0 + */ + public function getModel($name = 'log', $prefix = 'TjnotificationsModel', $config = array('ignore_request' => true)) + { + $model = parent::getModel($name, $prefix, $config); + + return $model; + } +} diff --git a/src/com_tjnotifications/admin/helpers/tjnotifications.php b/src/com_tjnotifications/admin/helpers/tjnotifications.php index 3f009a3d..8152c2d5 100644 --- a/src/com_tjnotifications/admin/helpers/tjnotifications.php +++ b/src/com_tjnotifications/admin/helpers/tjnotifications.php @@ -21,7 +21,7 @@ * @subpackage com_tjnotifications * @since 2.2 */ -class TjnotificationsHelper +class TjnotificationsHelper extends JHelperContent { /** * Configure the Linkbar. @@ -66,5 +66,17 @@ public static function addSubmenu($view = '') } } } + + /*JHtmlSidebar::addEntry( + JText::_('COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONS'), + 'index.php?option=com_tjnotifications&view=notifications', + $view == 'notifications' + ); + + JHtmlSidebar::addEntry( + JText::_('COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONLOGS'), + 'index.php?option=com_tjnotifications&view=logs', + $view == 'logs' + );*/ } } diff --git a/src/com_tjnotifications/admin/models/forms/filter_logs.xml b/src/com_tjnotifications/admin/models/forms/filter_logs.xml new file mode 100644 index 00000000..918df1d7 --- /dev/null +++ b/src/com_tjnotifications/admin/models/forms/filter_logs.xml @@ -0,0 +1,23 @@ + +
+ + + + + + + + + + + + + + + + + + + + +
diff --git a/src/com_tjnotifications/admin/models/log.php b/src/com_tjnotifications/admin/models/log.php new file mode 100644 index 00000000..45c557c5 --- /dev/null +++ b/src/com_tjnotifications/admin/models/log.php @@ -0,0 +1,62 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +jimport('joomla.application.component.model'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\Table\Table; + +/** + * Log model. + * + * @since 1.1.0 + */ +class TjnotificationsModelLog extends AdminModel +{ + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * + * @return JForm|boolean A JForm object on success, false on failure + * + * @since 1.1.0 + */ + public function getForm($data = array(), $loadData = true) + { + // Get the form. + $form = $this->loadForm('com_tjnotifications.log', 'log', array('control' => 'jform', 'load_data' => $loadData)); + + if (empty($form)) + { + return false; + } + + return $form; + } + + /** + * Returns a Table object, always creating it. + * + * @param string $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + */ + public function getTable($type = 'Log', $prefix = 'TjnotificationsTable', $config = array()) + { + return Table::getInstance($type, $prefix, $config); + } +} diff --git a/src/com_tjnotifications/admin/models/logs.php b/src/com_tjnotifications/admin/models/logs.php new file mode 100644 index 00000000..845c8e99 --- /dev/null +++ b/src/com_tjnotifications/admin/models/logs.php @@ -0,0 +1,157 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access to this file +defined('_JEXEC') or die; + +jimport('joomla.application.component.model'); + +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\ListModel; + +/** + * notifications model. + * + * @since 1.1.0 + */ +class TjnotificationsModelLogs extends ListModel +{ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * + * @see JController + * @since 1.1.0 + */ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'id', 'tjl.id', + 'to', 'tjl.to', + 'key', 'tjl.key', + 'from', 'tjl.from', + 'cc', 'tjl.cc', + 'state', 'tjl.state', + 'subject', 'tjl.subject', + 'search' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + * @since 1.1.0 + */ + protected function populateState($ordering = 'tjl.id', $direction = 'desc') + { + $app = Factory::getApplication(); + + // Load the filter search + $search = $app->getUserStateFromRequest($this->context . 'filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + parent::populateState($ordering, $direction); + + // Get pagination request variables + $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); + $limitstart = Factory::getApplication()->input->post->get('limitstart'); + + // In case limit has been changed, adjust it + $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); + + $this->setState('list.limit', $limit); + $this->setState('list.start', $limitstart); + } + + /** + * Build an SQL query to load the list data. + * + * @return JDatabaseQuery + * + * @since 1.1.0 + */ + protected function getListQuery() + { + // Initialize variables. + $db = Factory::getDbo(); + $query = $db->getQuery(true); + + // Create the base select statement. + $query->select('*') + ->from($db->quoteName('#__tj_notification_logs', 'tjl')); + + $search = $this->getState('filter.search'); + + // Filter by client + $client = $this->getState('filter.client'); + + if ($client) + { + $query->where($db->quoteName('tjl.client') . ' = ' . $db->quote($client)); + } + + // Filter by provider + $provider = $this->getState('filter.provider'); + + if ($provider) + { + $query->where($db->quoteName('tjl.provider') . ' = ' . $db->quote($provider)); + } + + // Filter by key + $key = $this->getState('filter.key'); + + if ($key) + { + $query->where($db->quoteName('tjl.key') . ' = ' . $db->quote($key)); + } + + // Filter by client + $state = $this->getState('filter.state'); + + if (is_numeric($state)) + { + $query->where($db->quoteName('tjl.state') . ' = ' . $db->quote($state)); + } + + if (!empty($search)) + { + $like = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%')); + $query->where( + $db->quoteName('tjl.subject') . ' LIKE ' . $like . ' + OR ' . $db->quoteName('tjl.from') . ' LIKE ' . $like . ' + OR ' . $db->quoteName('tjl.to') . ' LIKE ' . $like + ); + } + + $orderCol = $this->getState('list.ordering'); + $orderDirn = $this->getState('list.direction'); + + if ($orderCol && $orderDirn) + { + $query->order($db->quoteName($orderCol) . ' ' . $db->escape($orderDirn)); + } + + return $query; + } +} diff --git a/src/com_tjnotifications/admin/sql/install.mysql.utf8.sql b/src/com_tjnotifications/admin/sql/install.mysql.utf8.sql index bffb9b76..5675d1b3 100644 --- a/src/com_tjnotifications/admin/sql/install.mysql.utf8.sql +++ b/src/com_tjnotifications/admin/sql/install.mysql.utf8.sql @@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS `#__tj_notification_templates` ( UNIQUE KEY `client_2` (`client`,`key`), KEY `client` (`client`), KEY `key` (`key`) -)AUTO_INCREMENT=1 ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; +) AUTO_INCREMENT=1 ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `#__tj_notification_template_configs` ( `id` int(11) NOT NULL AUTO_INCREMENT, @@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS `#__tj_notification_template_configs` ( `is_override` int(1) NOT NULL, PRIMARY KEY (`id`), CONSTRAINT `#__tj_notification_template_configs` FOREIGN KEY (`template_id`) REFERENCES `#__tj_notification_templates` (`id`) -)AUTO_INCREMENT=1 ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; +) AUTO_INCREMENT=1 ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `#__tj_notification_user_exclusions` ( `user_id` int(11) NOT NULL, @@ -47,3 +47,24 @@ CREATE TABLE IF NOT EXISTS `#__tj_notification_template_configs` ( KEY `provider` (`provider`), CONSTRAINT `#__tj_notification_user_exclusions_ibfk_1` FOREIGN KEY (`provider`) REFERENCES `#__tj_notification_providers` (`provider`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__tj_notification_logs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `key` varchar(100) NOT NULL, + `client` varchar(100) NOT NULL, + `provider` varchar(50) NOT NULL, + `subject` varchar(250) NOT NULL, + `title` varchar(100) NOT NULL, + `body` text NOT NULL, + `from` varchar(500) NOT NULL, + `to` text NOT NULL, + `cc` text NOT NULL, + `bcc` text NOT NULL, + `date` datetime NOT NULL, + `state` tinyint(2) NOT NULL, + `params` text NOT NULL, + `priority`int(11) NOT NULL, + `message` text NOT NULL, + `category` text NOT NULL, + PRIMARY KEY (`id`) +) AUTO_INCREMENT=1 ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/src/com_tjnotifications/admin/sql/updates/mysql/1.2.0.sql b/src/com_tjnotifications/admin/sql/updates/mysql/1.2.0.sql index 98bd9010..b61d46ee 100644 --- a/src/com_tjnotifications/admin/sql/updates/mysql/1.2.0.sql +++ b/src/com_tjnotifications/admin/sql/updates/mysql/1.2.0.sql @@ -18,3 +18,24 @@ CREATE TABLE IF NOT EXISTS `#__tj_notification_template_configs` ( ALTER TABLE `#__tj_notification_templates` MODIFY `created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'; ALTER TABLE `#__tj_notification_templates` MODIFY `updated_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'; + +CREATE TABLE IF NOT EXISTS `#__tj_notification_logs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `key` varchar(100) NOT NULL, + `client` varchar(100) NOT NULL, + `provider` varchar(50) NOT NULL, + `subject` varchar(250) NOT NULL, + `title` varchar(100) NOT NULL, + `body` text NOT NULL, + `from` varchar(500) NOT NULL, + `to` text NOT NULL, + `cc` text NOT NULL, + `bcc` text NOT NULL, + `date` datetime NOT NULL, + `state` tinyint(2) NOT NULL, + `params` text NOT NULL, + `priority`int(11) NOT NULL, + `message` text NOT NULL, + `category` text NOT NULL, + PRIMARY KEY (`id`) +) AUTO_INCREMENT=1 ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/src/com_tjnotifications/admin/tables/log.php b/src/com_tjnotifications/admin/tables/log.php new file mode 100644 index 00000000..0221bc86 --- /dev/null +++ b/src/com_tjnotifications/admin/tables/log.php @@ -0,0 +1,32 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access to this file +defined('_JEXEC') or die; + +use Joomla\CMS\Table\Table; + +/** + * table class for notification + * + * @since 1.1.0 + */ +class TjnotificationsTableLog extends Table +{ + /** + * Constructor + * + * @param JDatabase &$db A database connector object + */ + public function __construct(&$db) + { + parent::__construct('#__tj_notification_logs', 'id', $db); + } +} diff --git a/src/com_tjnotifications/admin/views/logs/index.html b/src/com_tjnotifications/admin/views/logs/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/body.php b/src/com_tjnotifications/admin/views/logs/tmpl/body.php new file mode 100644 index 00000000..7f2cb50b --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/body.php @@ -0,0 +1,38 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access to this file +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Table\Table; + +$jinput = Factory::getApplication()->input; +$logId = $jinput->get('id', 0, 'INT'); + +if ($logId) +{ + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjnotifications/tables'); + $logTable = Table::getInstance('Log', 'TjnotificationsTable'); + $logTable->load(array('id' => $logId)); +} +?> +
+ id) : ?> + +
+ body; ?> +
+ +
+ diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/default.php b/src/com_tjnotifications/admin/views/logs/tmpl/default.php new file mode 100644 index 00000000..8e4d603c --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/default.php @@ -0,0 +1,172 @@ + +* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. +* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +*/ + +// No direct access to this file +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Language\Text; + +HTMLHelper::_('behavior.modal', 'a.modal'); +HTMLHelper::_('formbehavior.chosen', 'select'); + +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); + +$doc = Factory::getDocument(); +$doc->addStyleSheet(JUri::root() . 'administrator/components/com_tjnotifications/assets/css/tjnotifcations.css'); +?> + + + +
+sidebar)) : ?> +
+ sidebar; ?> +
+
+ +
+ + $this, 'options' => array('filterButton' => 1,'filtersHidden' => 0))); + ?> +
+ + pagination->getLimitBox(); ?> +
+
+ + + + + + + + + + + + + + + + + + + + items)) : ?> + items as $i => $row) :?> + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ id); ?> + + subject, ENT_COMPAT, 'UTF-8'); ?> + + + + + + ', $row->to); ?> + + ', $row->cc); ?> + + ', $row->bcc); ?> + + date, ENT_COMPAT, 'UTF-8'); ?> + + state == 1) ? Text::_('COM_TJNOTIFICATIONS_STATE_SENT') : Text::_('COM_TJNOTIFICATIONS_STATE_FAILED'); + ?> + + key, ENT_COMPAT, 'UTF-8'); ?> + + provider, ENT_COMPAT, 'UTF-8'); ?> + + from, ENT_COMPAT, 'UTF-8'); ?> + + params)): ?> + + + + + + + + id, ENT_COMPAT, 'UTF-8'); ?> +
+
+ pagination->getListFooter(); ?> + + + + + +
+
+
diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/default.xml b/src/com_tjnotifications/admin/views/logs/tmpl/default.xml new file mode 100644 index 00000000..c2620b17 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/default.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/index.html b/src/com_tjnotifications/admin/views/logs/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/param.php b/src/com_tjnotifications/admin/views/logs/tmpl/param.php new file mode 100644 index 00000000..a616cb37 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/param.php @@ -0,0 +1,36 @@ + +* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. +* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +*/ +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Table\Table; + +$jinput = Factory::getApplication()->input; +$logId = $jinput->get('id', 0, 'INT'); + +if ($logId) +{ + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjnotifications/tables'); + $logTable = Table::getInstance('Log', 'TjnotificationsTable'); + $logTable->load(array('id' => $logId)); +} +?> +
+ id) : ?> + +
+ params; ?> +
+ +
diff --git a/src/com_tjnotifications/admin/views/logs/view.csv.php b/src/com_tjnotifications/admin/views/logs/view.csv.php new file mode 100644 index 00000000..76bab208 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/view.csv.php @@ -0,0 +1,34 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die('Restricted access'); + +jimport('techjoomla.view.csv'); + +/** + * View class for a list of notifications logs. + * + * @since 1.1.0 + */ +class TjnotificationsViewLogs extends TjExportCsv +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return mixed A string if successful, otherwise an Error object. + */ + public function display($tpl = null) + { + parent::display(); + } +} diff --git a/src/com_tjnotifications/admin/views/logs/view.html.php b/src/com_tjnotifications/admin/views/logs/view.html.php new file mode 100644 index 00000000..35e11f41 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/view.html.php @@ -0,0 +1,94 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +JLoader::register('TjnotificationsHelper', JPATH_ADMINISTRATOR . '/components/com_tjnotifications/helpers/tjnotifications.php'); + +use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Toolbar\Toolbar; + +/** + * View class for a list of notifications logs. + * + * @since 1.1.0 + */ +class TjnotificationsViewLogs extends HtmlView +{ + /** + * Display the view + * + * @param string $tpl Template name + * + * @return void + * + * @throws Exception + */ + public function display($tpl = null) + { + $this->state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->filterForm = $this->get('FilterForm'); + $this->activeFilters = $this->get('ActiveFilters'); + //die; + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + JError::raiseError(500, implode('
', $errors)); + + return false; + } + + $this->canDo = JHelperContent::getActions('com_tjnotifications'); + + TjnotificationsHelper::addSubmenu('logs'); + $this->addToolBar(); + $this->sidebar = JHtmlSidebar::render(); + + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * + * @since 1.1.0 + */ + protected function addToolBar() + { + ToolbarHelper::title(Text::_('COM_TJNOTIFICATIONS_LOGS'), 'list'); + + if ($this->canDo->get('core.export')) + { + // Adding techjoomla library for csv Export + jimport('techjoomla.tjtoolbar.button.csvexport'); + + $bar = Toolbar::getInstance('toolbar'); + + $message = array(); + $message['success'] = Text::_("COM_TJNOTIFICATIONS_EXPORT_FILE_SUCCESS"); + $message['error'] = Text::_("COM_TJNOTIFICATIONS_EXPORT_FILE_ERROR"); + $message['inprogress'] = Text::_("COM_TJNOTIFICATIONS_EXPORT_FILE_NOTICE"); + + $bar->appendButton('CsvExport', $message); + } + + if ($this->canDo->get('core.delete')) + { + ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE'); + } + } +} diff --git a/src/com_tjnotifications/tjnotifications.xml b/src/com_tjnotifications/tjnotifications.xml index 2b9fcc58..9ba411bb 100644 --- a/src/com_tjnotifications/tjnotifications.xml +++ b/src/com_tjnotifications/tjnotifications.xml @@ -56,5 +56,14 @@ en-GB.com_tjnotifications.sys.ini + + + +
+ + +
+
+ install.tjnotifications.php