Skip to content

Commit

Permalink
Issue #48 chore: Log Email details in DB table - Tj Notification (#95)
Browse files Browse the repository at this point in the history
* Issue #48 chore: Log Email details in DB table - Tj Notification

* Issue #48 chore: Log Email details in DB table - Tj Notification
  • Loading branch information
manojLondhe authored Jun 8, 2020
1 parent 1591458 commit e03faa4
Show file tree
Hide file tree
Showing 22 changed files with 867 additions and 23 deletions.
22 changes: 11 additions & 11 deletions src/com_tjnotifications/admin/access.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<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.export" title="JACTION_EXPORT" description="JACTION_EXPORT_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_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.viewlist" title="JACTION_VIEW_LIST" description="JACTION_VIEW_LIST_DESC" />
<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.create" title="JACTION_CREATE" description="JACTION_CREATE_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.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.view" title="JACTION_VIEW" description="JACTION_VIEW_COMPONENT_DESC" />
<action name="core.viewlist" title="JACTION_VIEW_LIST" description="JACTION_VIEW_LIST_DESC" />
<action name="core.emailstatus" title="JACTION_EMAIL_STATUS" description="JACTION_EMAIL_STATUS_DESC" />
<action name="core.usercontrol" title="JACTION_USER_CONTROL" description="JACTION_USER_CONTROL_DESC" />
<action name="core.export" title="JACTION_EXPORT" description="JACTION_EXPORT_COMPONENT_DESC" />
</section>
</access>
3 changes: 3 additions & 0 deletions src/com_tjnotifications/admin/assets/css/tjnotifcations.css
Original file line number Diff line number Diff line change
@@ -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}
6 changes: 6 additions & 0 deletions src/com_tjnotifications/admin/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset label="COM_TJNOTIFICATION" name="Notifications">
<field name="enable_logs" type="radio" class="btn-group btn-group-yesno" default="0" label="COM_TJNOTIFICATIONS_ALLOW_SAVE_OPTION" description="COM_TJNOTIFICATIONS_APPLICATION_OPTION_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="permissions" description="JCONFIG_PERMISSIONS_DESC" label="JCONFIG_PERMISSIONS_LABEL">
<field name="rules" type="rules" component="com_tjnotifications" class="inputbox" filter="rules" validate="rules" label="JCONFIG_PERMISSIONS_LABEL" section="component" />
</fieldset>
Expand Down
23 changes: 23 additions & 0 deletions src/com_tjnotifications/admin/controllers/log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* @package TJNotifications
* @subpackage com_tjnotifications
*
* @author Techjoomla <[email protected]>
* @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
{
}
40 changes: 40 additions & 0 deletions src/com_tjnotifications/admin/controllers/logs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* @package TJNotifications
* @subpackage com_tjnotifications
*
* @author Techjoomla <[email protected]>
* @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;
}
}
14 changes: 13 additions & 1 deletion src/com_tjnotifications/admin/helpers/tjnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @subpackage com_tjnotifications
* @since 2.2
*/
class TjnotificationsHelper
class TjnotificationsHelper extends JHelperContent
{
/**
* Configure the Linkbar.
Expand Down Expand Up @@ -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'
);*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ COM_TJNOTIFICATIONS_TAGS_DESC="Enter the tag given on left in to the editor thes
COM_TJNOTIFICATIONS_REPLACEMENT_TAGS="Replacement Tag"
COM_TJNOTIFICATIONS_REPLACEMENT_TAGS_DESC="Description"

; Since __DEPLOY_VERSION__
JACTION_VIEW_LIST="View List"
JACTION_VIEW_LIST_DESC="Allow users in the group to view the contents in this extension"
JACTION_EMAIL_STATUS="Email Status"
JACTION_EMAIL_STATUS_DESC="Allow users in the group to enable or disable the contents in this extension"
JACTION_USER_CONTROL="User Control"
JACTION_USER_CONTROL_DESC="Allow users in the group to enable or disable the contents in this extension"

; Since v_1.2.0
COM_TJNOTIFICATIONS_NOTIFICATION_LANGUAGE_DESC="Choose language"
COM_TJNOTIFICATIONS_TEMPLATE_ERR_MSG_TEMPLATE_EXISTS="Template you are creating for this component and language is already created, please create for another Language"
Expand All @@ -119,8 +111,67 @@ COM_TJNOTIFICATIONS_FIELD_EMAIL_FROM_EMAIL_DESC="Enter From email for notificati
; SMS fields
COM_TJNOTIFICATIONS_SMS_FIELDS_DESC="SMS Fields Description"
COM_TJNOTIFICATIONS_SMS_FIELDS="SMS Fields"
; List view
; Templates - List view
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_TRANSLATED_IN="Translated In"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_TRANSLATED_NOT_IN="Not Translated In"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_EMAIL_TITLE="Email"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_SMS_TITLE="SMS"
; Permissions
JACTION_EMAIL_STATUS="Email Status"
JACTION_EMAIL_STATUS_DESC="Allow users in the group to enable or disable the contents in this extension"
JACTION_EXPORT="Export"
JACTION_EXPORT_COMPONENT_DESC="Allow user to export notifications logs data"
JACTION_USER_CONTROL="User Control"
JACTION_USER_CONTROL_DESC="Allow users in the group to enable or disable the contents in this extension"
JACTION_VIEW="View"
JACTION_VIEW_COMPONENT_DESC="Allow user to view notifications logs"
JACTION_VIEW_LIST="View List"
JACTION_VIEW_LIST_DESC="Allow users in the group to view the contents in this extension"
; Settings
COM_TJNOTIFICATION="Notifications"
COM_TJNOTIFICATIONS_ALLOW_SAVE_OPTION="Enable logs?"
; Logs list
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_SUBJECT="Subject"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_KEY="Key"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_TITLE="Title"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_PROVIDER="Provider"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_FROM="From"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_TO="To"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_CC="CC"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_BCC="BCC"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_DATE="Date"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_STATE="State"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_PARAMS="Params"
COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONS="Notifications"
COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONLOGS="Notifications Logs"
COM_TJNOTIFICATIONS_LOGS="Logs"
COM_TJNOTIFICATIONS_EXPORT_FILE_SUCCESS="Download complete"
COM_TJNOTIFICATIONS_VIEW_EMAIL_BODY="Email Body"
COM_TJNOTIFICATIONS_VIEW_EMAIL_POPUP_CLOSE="Close"
COM_TJNOTIFICATIONS_VIEW_PARAMS_POPUP="Show Params"
COM_TJNOTIFICATIONS_FIELD_PROVIDER_LABEL="Provider"
COM_TJNOTIFICATIONS_FIELD_PROVIDER_DESC="The provider that is defining the notifications"
COM_TJNOTIFICATIONS_PROVIDER_EMAIL="Email"
COM_TJNOTIFICATIONS_PROVIDER_SMS="SMS"
COM_TJNOTIFICATIONS_PROVIDER_PUSH="Push Message"
COM_TJNOTIFICATIONS_FIELD_KEY_LABEL="Key"
COM_TJNOTIFICATIONS_FIELD_KEY_DESC="The key that is defining the notifications"
COM_TJNOTIFICATIONS_FIELD_KEY_OPTION="-- Select Key --"
COM_TJNOTIFICATIONS_EXPORT_FILE_SUCCESS="Download Complete"
COM_TJNOTIFICATIONS_EXPORT_FILE_ERROR="<strong>Something went wrong.</strong>"
COM_TJNOTIFICATIONS_EXPORT_FILE_NOTICE="<strong>Do not click anywhere or refresh the page until CSV download successfully.</strong>"
COM_TJNOTIFICATIONS_FIELD_STATE_LABEL="State"
COM_TJNOTIFICATIONS_FIELD_STATE_OPTION="-- Select State --"
COM_TJNOTIFICATIONS_STATE_SENT="Sent"
COM_TJNOTIFICATIONS_STATE_FAILED="Failed"
COM_TJNOTIFICATIONS_LIST_LOGS="List Logs"
COM_TJNOTIFICATIONS_EMPTY_PARAMS="-"
COM_TJNOTIFICATIONS_APPLICATION_OPTION_DESC="Enable logs?"
COM_TJNOTIFICATIONS_PROVIDER_WEB="Web"
COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_BODY="Body"
COM_TJNOTIFICATIONS_TITLE_VIEW_CONTENTS="View Content"
COM_TJNOTIFICATIONS_STATE_SENT="Sent"
COM_TJNOTIFICATIONS_STATE_FAILED="Failed"
COM_TJNOTIFICATIONS_FIELD_NOTIFICATION_BODY_LABEL="Notification Body"
COM_TJNOTIFICATIONS_LIST_LOGS_DESC="List all notification logs"

23 changes: 23 additions & 0 deletions src/com_tjnotifications/admin/models/forms/filter_logs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field name="search" type="text" label="search" hint="search" class="js-stools-search-string" />
<field name="client" label="COM_TJNOTIFICATIONS_FIELD_CLIENT_LABEL" 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" default="email" description="COM_TJNOTIFICATIONS_FIELD_PROVIDER_DESC" onchange="this.form.submit();" key_field="provider" value_field="provider">
<option value="email">COM_TJNOTIFICATIONS_PROVIDER_EMAIL</option>
<option value="sms">COM_TJNOTIFICATIONS_PROVIDER_SMS</option>
<option value="push">COM_TJNOTIFICATIONS_PROVIDER_PUSH</option>
<option value="web">COM_TJNOTIFICATIONS_PROVIDER_WEB</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 DISTINCT(`key`) AS `tmpkey` FROM `#__tj_notification_templates`" 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="">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>
62 changes: 62 additions & 0 deletions src/com_tjnotifications/admin/models/log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* @package TJNotifications
* @subpackage com_tjnotifications
*
* @author Techjoomla <[email protected]>
* @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);
}
}
Loading

0 comments on commit e03faa4

Please sign in to comment.