Skip to content

Commit

Permalink
Issue techjoomla#48 chore: Log Email details in DB table - Tj Notific…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
punambaravkar committed Jun 21, 2019
1 parent 6527ef1 commit 396a933
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 130 deletions.
4 changes: 0 additions & 4 deletions src/com_tjnotifications/admin/access.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@
<action name="core.export" title="JACTION_EXPORT" description="JACTION_EXPORT_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
</section>
<section name="notifications">
<action name="core.view" title="JACTION_VIEW" description="JACTION_VIEW_COMPONENT_DESC" />
<action name="core.export" title="JACTION_EXPORT" description="JACTION_EXPORT_COMPONENT_DESC" />
</section>
</access>
4 changes: 2 additions & 2 deletions src/com_tjnotifications/admin/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<config>
<fieldset label="COM_TJNOTIFICATION" name="Notifications">
<field name="allow_save" type="radio" class="btn-group btn-group-yesno" default="No" label="COM_TJNOTIFICATIONS_ALLOW_SAVE_OPTION" description="COM_TJNOTIFICATIONS_APPLICATION_OPTION_DESC">
<option value="No">NO</option>
<option value="Yes">YES</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="permissions" description="JCONFIG_PERMISSIONS_DESC" label="JCONFIG_PERMISSIONS_LABEL">
Expand Down
20 changes: 1 addition & 19 deletions src/com_tjnotifications/admin/helpers/tjnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @subpackage com_tjnotifications
* @since 2.2
*/
class TjnotificationsHelper
class TjnotificationsHelper extends JHelperContent
{
/**
* Configure the Linkbar.
Expand Down Expand Up @@ -76,22 +76,4 @@ public static function addSubmenu($view = '')
$view == 'logs'
);
}

/**
* Gets a list of the actions that can be performed.
*
* @param string $component The component name.
* @param string $section The access section name.
* @param integer $id The item ID.
*
* @return JObject
*
* @since 3.2
*/
public static function getActions($component = 'com_tjnotifications', $section = '', $id = 0)
{
$result = parent::getActions($component, $section, $id);

return $result;
}
}
76 changes: 28 additions & 48 deletions src/com_tjnotifications/admin/models/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ public function __construct($config = array())
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id',
'to',
'key',
'from',
'cc',
'provider',
'state',
'subject',
'search',
'id', 'tjl.id',
'to', 'tjl.to',
'key', 'tjl.key',
'from', 'tjl.from',
'cc', 'tjl.cc',
'state', 'tjl.state',
'subject', 'tjl.subject',
'search'
);
}

Expand All @@ -57,41 +56,21 @@ public function __construct($config = array())
*
* @since 1.1.0
*/
protected function populateState($ordering = 'id', $direction = 'asc')
protected function populateState($ordering = 'tjl.id', $direction = 'asc')
{
$app = JFactory::getApplication('administrator');

$ordering = $app->input->get('filter_order', 'id', 'STRING');
$direction = $app->input->get('filter_order_Dir', 'desc', 'STRING');

if (!empty($ordering) && in_array($ordering, $this->filter_fields))
{
$this->setState('list.ordering', $ordering);
}

if (!empty($direction))
{
if (!in_array(strtolower($direction), array('asc', 'desc')))
{
$direction = 'desc';
}

$this->setState('list.direction', $direction);
}
$app = JFactory::getApplication();

// Load the filter search
$search = $app->getUserStateFromRequest($this->context . 'filter.search', 'filter_search');
$this->setState('filter.search', $search);

parent::populateState($ordering, $direction);

$mainframe = JFactory::getApplication();

// Get pagination request variables
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int');
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');

// In case limit has been changed, adjust it
//~ // In case limit has been changed, adjust it
$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);

$this->setState('list.limit', $limit);
Expand All @@ -113,47 +92,48 @@ protected function getListQuery()

// Create the base select statement.
$query->select('*')
->from($db->quoteName('#__tjnotification_logs', 'cs'));
->from($db->quoteName('#__tjnotification_logs', 'tjl'));

$search = $this->getState('filter.search');

if (!empty($search))
{
$like = $db->quote('%' . $search . '%');
$query->where($db->quoteName('subject') . ' LIKE ' . $like . ' OR ' . $db->quoteName('from') . ' LIKE ' . $like . ' OR ' . $db->quoteName('to') . ' LIKE ' . $like);
}

// Filter by client
$client = $this->getState('filter.client');

if ($client)
{
$client = $db->quote($client);
$query->where('client = ' . $client);
$query->where($db->quoteName('tjl.client') . ' = ' . $db->quote($client));
}

// Filter by provider
$provider = $this->getState('filter.provider');

if ($provider)
{
$provider = $db->quote($provider);
$query->where('provider = ' . $provider);
$query->where($db->quoteName('tjl.provider') . ' = ' . $db->quote($provider));
}

// Filter by key
$key = $this->getState('filter.key');

if ($key)
{
$key = $db->quote($key);
$query->where('cs.key = ' . $key);
$query->where($db->quoteName('tjl.key') . ' = ' . $db->quote($key));
}


// Filter by client
$state = $this->getState('filter.state');

$state = $db->quote($state);
$query->where('cs.state = ' . $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');
Expand Down
71 changes: 16 additions & 55 deletions src/com_tjnotifications/admin/views/logs/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Joomla\CMS\Layout\LayoutHelper;
include 'header.html';



JHTML::_('behavior.modal', 'a.modal');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', 'select');
Expand All @@ -25,6 +28,16 @@
overflow-x: auto;}
</style>

<script type="text/javascript">
$(document).ready(function() {
var width = $(window).width();
var height = $(window).height();

//ID of container
$('a#modal_info').attr('rel','{handler: "iframe", size: {x: '+(width-(width*0.10))+', y: '+(height-(height*0.10))+'}}');
});
</script>

<form action="index.php?option=com_tjnotifications&view=logs" method="post" id="adminForm" name="adminForm">
<?php if (!empty($this->sidebar)):?>
<div id="j-sidebar-container" class="span2">
Expand Down Expand Up @@ -111,35 +124,8 @@
?>
</td>
<td class="">
<a data-toggle="modal" href="#bodyModal">
<?php echo htmlspecialchars($row->subject, ENT_COMPAT, 'UTF-8');?>
</a>
</td>
<div class="modal fade" id="bodyModal" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><?php echo
JText::_("COM_TJNOTIFICATIONS_VIEW_EMAIL_BODY");
?></h4>
</div>
<div class="modal-body p-15">
<div class="col-xs-12">
<p><?php
echo $row->body;
//echo htmlspecialchars($row->body, ENT_COMPAT, 'UTF-8');?>
</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo
JText::_("COM_TJNOTIFICATIONS_VIEW_EMAIL_POPUP_CLOSE");
?></button>
</div>
</div>
<a id="modal_info" class="modal" href="<?php echo JRoute::_('index.php?option=com_tjnotifications&tmpl=component&subject=true&view=logs&layout=popup&id='. $row->id); ?>"><?php echo htmlspecialchars($row->subject, ENT_COMPAT, 'UTF-8'); ?></a>

<td class="center">
<?php echo htmlspecialchars($row->to, ENT_COMPAT, 'UTF-8'); ?>
</td>
Expand Down Expand Up @@ -171,34 +157,9 @@
<?php echo htmlspecialchars($row->from, ENT_COMPAT, 'UTF-8'); ?>
</td>
<td class="">
<a data-toggle="modal" href="#paramsModal">
<?php echo "show params"; ?>
<a id="modal_info" class="modal" href="<?php echo JRoute::_('index.php?option=com_tjnotifications&tmpl=component&view=logs&layout=popup&id='. $row->id); ?>"><?php echo JText::_("COM_TJNOTIFICATIONS_VIEW_PARAMS_POPUP");?></a>
</a>
</td>

<div class="modal fade" id="paramsModal" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><?php echo
JText::_("COM_TJNOTIFICATIONS_VIEW_PARAMS_POPUP");
?></h4>
</div>
<div class="modal-body">
<div class="col-xs-12">
<p><?php echo htmlspecialchars($row->params, ENT_COMPAT, 'UTF-8'); ?>
</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo
JText::_("COM_TJNOTIFICATIONS_VIEW_EMAIL_POPUP_CLOSE");
?></button>
</div>
</div>
</tr>
<?php endforeach; ?>
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion src/com_tjnotifications/admin/views/logs/tmpl/default.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="List Logs" option="View">
<layout title="COM_TJNOTIFICATIONS_LIST_LOGS" option="View">
<message>
<![CDATA[List all notifications Logs]]>
</message>
Expand Down
50 changes: 50 additions & 0 deletions src/com_tjnotifications/admin/views/logs/tmpl/popup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* @package Com_Tjnotifications
* @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
*/

// No direct access to this file
defined('_JEXEC') or die;

use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;

$jinput = Factory::getApplication()->input;
$logId = $jinput->get('id', 0, 'INT');
$subject = $jinput->get('subject', 0, 'INT');

Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjnotifications/tables');
$logTable = Table::getInstance('Log', 'TjnotificationsTable');
$logTable->load(array('id' => $logId));

if($subject==="true")
{
?>
<div>
<h4 class="modal-title"><?php echo
JText::_("COM_TJNOTIFICATIONS_FIELD_EMAIL_BODY_LABEL");
?></h4>
</div>
<div class="col-xs-12">
<p><?php echo htmlspecialchars($logTable->body, ENT_COMPAT, 'UTF-8'); ?>
</p>
</div>
</div>
<?php }
else
{?>
<div>
<h4 class="modal-title"><?php echo
JText::_("COM_TJNOTIFICATIONS_VIEW_PARAMS_POPUP");
?></h4>
</div>
<div class="col-xs-12">
<p><?php echo htmlspecialchars($logTable->params, ENT_COMPAT, 'UTF-8'); ?>
</p>
</div>
</div>
<?php
}
?>
2 changes: 1 addition & 1 deletion src/com_tjnotifications/admin/views/logs/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TjnotificationsViewLogs extends HtmlView
*/
public function display($tpl = null)
{
$this->canDo = TjnotificationsHelper::getActions();
$this->canDo = JHelperContent::getActions('com_tjnotifications');

$this->state = $this->get('State');
$this->items = $this->get('Items');
Expand Down

0 comments on commit 396a933

Please sign in to comment.