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 20, 2019
1 parent 24280a0 commit d3efc7c
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 123 deletions.
11 changes: 1 addition & 10 deletions src/com_tjnotifications/admin/access.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@
<access component="com_tjnotifications">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.view" title="JACTION_VIEW" description="JACTION_VIEW_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.export" title="JACTION_EXPORT" description="JACTION_EXPORT_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
<action name="core.viewall" title="JACTION_VIEWALL" description="COM_TJNOTIFICATIONS_ACCESS_VIEWALL_DESC" />
<action name="core.view.own" title="JACTION_VIEW_OWN" description="COM_TJNOTIFICATIONS_ACCESS_VIEW_OWN_DESC" />
<action name="core.view.subscribe" title="JACTION_VIEW_SUBSCRIBE" description="COM_TJNOTIFICATIONS_ACCESS_VIEW_SUBSCRIBE_DESC" />
</section>

<section name="notifications">
<action name="core.viewall" title="JACTION_VIEWALL" description="COM_TJNOTIFICATIONS_ACCESS_VIEWALL_DESC" />
<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>
2 changes: 1 addition & 1 deletion src/com_tjnotifications/admin/config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-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_JOURNEY_APPLICATION_OPTION_DESC">
<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>
</field>
Expand Down
32 changes: 31 additions & 1 deletion 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 @@ -63,5 +63,35 @@ public static function addSubmenu($view = '')
}
}
}

JHtmlSidebar::addEntry(
JText::_('COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONS'),
'index.php?option=com_tjnotifications&view=notifications',
$view == 'rounds'
);

JHtmlSidebar::addEntry(
JText::_('COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONLOGS'),
'index.php?option=com_tjnotifications&view=logs',
$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;
}
}
43 changes: 43 additions & 0 deletions src/com_tjnotifications/admin/models/forms/filter_logs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,54 @@
description="COM_TJNOTIFICATIONS_FIELD_CLIENT_DESC"
onchange="this.form.submit();"
type="sql"
class="inputbox"
query="SELECT DISTINCT(client) FROM `#__tj_notification_templates`"
key_field="client"
value_field="client"
>
<option value=''>COM_TJNOTIFICATIONS_FIELD_CLIENT_OPTION</option>
</field>
<field
name="provider"
type="list"
class="inputbox"
label="COM_TJNOTIFICATIONS_FIELD_PROVIDER_LABEL"
description="COM_TJNOTIFICATIONS_FIELD_PROVIDER_DESC"
onchange="this.form.submit();"
key_field="provider"
value_field="provider"
>
<option value="">COM_TJNOTIFICATIONS_FIELD_PROVIDER_OPTION</option>
<option value="Email">COM_TJNOTIFICATIONS_PROVIDER_EMAIL</option>
<option value="Sms">COM_TJNOTIFICATIONS_PROVIDER_SMS</option>
<option value="Push Message">COM_TJNOTIFICATIONS_PROVIDER_PUSH</option>
</field>
<field
name="key"
label="COM_TJNOTIFICATIONS_FIELD_KEY_LABEL"
description="COM_TJNOTIFICATIONS_FIELD_KEY_DESC"
onchange="this.form.submit();"
type="sql"
class="inputbox"
query="SELECT notemp.key as tmpkey FROM `#__tj_notification_templates` as notemp"
key_field="tmpkey"
value_field="tmpkey"
>
<option value=''>COM_TJNOTIFICATIONS_FIELD_KEY_OPTION</option>
</field>
<field
name="state"
type="list"
class="inputbox"
label="COM_TJNOTIFICATIONS_FIELD_STATE_LABEL"
description="COM_TJNOTIFICATIONS_FIELD_STATE_DESC"
onchange="this.form.submit();"
key_field="provider"
value_field="provider"
>
<option value="1">COM_TJNOTIFICATIONS_FIELD_STATE_OPTION</option>
<option value="1">COM_TJNOTIFICATIONS_STATE_SENT</option>
<option value="0">COM_TJNOTIFICATIONS_STATE_FAILED</option>
</field>
</fields>
</form>
93 changes: 32 additions & 61 deletions src/com_tjnotifications/admin/models/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ public function __construct($config = array())
{
$config['filter_fields'] = array(
'id',
'client',
'to',
'key',
'from',
'cc',
'provider',
'state',
'subject',
'search',
Expand Down Expand Up @@ -79,9 +82,6 @@ protected function populateState($ordering = 'id', $direction = 'asc')
// Load the filter search
$search = $app->getUserStateFromRequest($this->context . 'filter.search', 'filter_search');
$this->setState('filter.search', $search);
// Load the filter state
$published = $app->getUserStateFromRequest($this->context . 'filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $published);

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

Expand All @@ -107,47 +107,54 @@ protected function populateState($ordering = 'id', $direction = 'asc')
*/
protected function getListQuery()
{
$extension = JFactory::getApplication()->input->get('extension', '', 'word');
$parts = explode('.', $extension);

// Extract the component name
$this->setState('filter.component', $parts[0]);

// Extract the optional section name
$this->setState('filter.section', (count($parts) > 1) ? $parts[1] : null);

// Initialize variables.
$db = JFactory::getDbo();
$query = $db->getQuery(true);

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

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

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

if ($extension)
// Filter by client
$client = $this->getState('filter.client');
if ($client)
{
$query->where($db->quoteName('client') . ' = ' . $db->quote($extension));
$client = $db->quote($client);
$query->where('client = ' . $client);
}
else

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

if ($provider)
{
// Filter by client
$client = $this->getState('filter.client');
$key = $this->getState('filter.key');
$provider = $db->quote($provider);
$query->where('provider = ' . $provider);
}

if (!empty($client) && empty($key))
{
$query->where($db->quoteName('client') . ' = ' . $db->quote($client));
}
// Filter by key
$key = $this->getState('filter.key');
if ($key)
{
$key = $db->quote($key);
$query->where('cs.key = ' . $key);
}

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

$state = $db->quote($state);
$query->where('cs.state = ' . $state);


$orderCol = $this->getState('list.ordering');
$orderDirn = $this->getState('list.direction');

Expand All @@ -158,40 +165,4 @@ protected function getListQuery()

return $query;
}

/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.1.0
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}


/**
* Method to get a list of articles.
* Overridden to add a check for access levels.
*
* @return mixed An array of data items on success, false on failure.
*
* @since 1.1.0
*/
public function getItems()
{
$items = parent::getItems();
return $items;
}
}
1 change: 1 addition & 0 deletions src/com_tjnotifications/admin/sql/install.mysql.utf8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ CREATE TABLE IF NOT EXISTS `#__tjnotification_logs` (
`client` varchar(100) NOT NULL,
`provider` varchar(100) NOT NULL,
`subject` varchar(250) NOT NULL,
`title` varchar(100) NOT NULL,
`body` text NOT NULL,
`from` varchar(100) NOT NULL,
`to` varchar(100) NOT NULL,
Expand Down
1 change: 1 addition & 0 deletions src/com_tjnotifications/admin/sql/updates/mysql/1.1.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ CREATE TABLE IF NOT EXISTS `#__tjnotification_logs` (
`client` varchar(100) NOT NULL,
`provider` varchar(100) NOT NULL,
`subject` varchar(250) NOT NULL,
`title` varchar(100) NOT NULL,
`body` text NOT NULL,
`from` varchar(100) NOT NULL,
`to` varchar(100) NOT NULL,
Expand Down
3 changes: 2 additions & 1 deletion src/com_tjnotifications/admin/tables/log.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\Table\Table;

/**
* table class for notification
*
* @since 1.6
*/
class TjnotificationsTableLog extends JTable
class TjnotificationsTableLog extends Table
{
/**
* Constructor
Expand Down
Loading

0 comments on commit d3efc7c

Please sign in to comment.