Skip to content

Commit

Permalink
Merge pull request #113 from techjoomla/feat-privacy-tools
Browse files Browse the repository at this point in the history
Merge `Feat privacy tools` into `master`
  • Loading branch information
manojLondhe authored Nov 16, 2018
2 parents 7d9854d + 58281b4 commit 62a93d0
Show file tree
Hide file tree
Showing 16 changed files with 1,195 additions and 85 deletions.
403 changes: 403 additions & 0 deletions build/bump.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/actionlog/tjreports/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; @package TJReports
; @subpackage Plg_Privacy_TJReports
; @copyright Copyright © 2009-2018 TechJoomla. All rights reserved.
; @license GNU General Public License version 2, or later
; Note: All ini files need to be saved as UTF-8

PLG_ACTIONLOG_TJREPORTS="Action Log - TJReports"
PLG_ACTIONLOG_TJREPORTS_XML_DESCRIPTION="Record the actions of users on the site for TJReports extension so they can be reviewed if required."

PLG_ACTIONLOG_TJREPORTS_REPORT_ADDED_WITH_CLIENT="User <a href=\"{accountlink}\">{username}</a> added new report <a href=\"{itemlink}\">{title}</a> using plugin {plugin} for {client}"
PLG_ACTIONLOG_TJREPORTS_REPORT_ADDED="User <a href=\"{accountlink}\">{username}</a> added new report <a href=\"{itemlink}\">{title}</a> using plugin {plugin}"
PLG_ACTIONLOG_TJREPORTS_REPORT_UPDATED="User <a href=\"{accountlink}\">{username}</a> updated the report <a href=\"{itemlink}\">{title}</a>"
PLG_ACTIONLOG_TJREPORTS_REPORT_DELETED="User <a href=\"{accountlink}\">{username}</a> deleted the report \"{title}\" "
PLG_ACTIONLOG_TJREPORTS_REPORT_DELETED_WITH_CLIENT="User <a href=\"{accountlink}\">{username}</a> deleted the report \"{title}\" for {client} "

PLG_ACTIONLOG_TJREPORTS_LOG_ACTION_REPORT_CREATE="Log action for report creation or update?"
PLG_ACTIONLOG_TJREPORTS_LOG_ACTION_REPORT_DELETE="Log action for report delete?"
PLG_ACTIONLOG_TJREPORTS_LOG_ACTION_COMMON_DESC="This action will be logged only when you set this to 'Yes'"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; @package TJReports
; @subpackage Plg_Privacy_TJReports
; @copyright Copyright © 2009-2018 TechJoomla. All rights reserved.
; @license GNU General Public License version 2, or later
; Note: All ini files need to be saved as UTF-8

PLG_ACTIONLOG_TJREPORTS="Action Log - TJReports"
PLG_ACTIONLOG_TJREPORTS_XML_DESCRIPTION="Record the actions of users on the site for TJReports extension so they can be reviewed if required."
184 changes: 184 additions & 0 deletions plugins/actionlog/tjreports/tjreports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?php
/**
* @package TJReport
* @subpackage PlgActionlogTjreports
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
*/

// No direct access.
defined('_JEXEC') or die();

JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php');

use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;

/**
* TJReports Actions Logging Plugin.
*
* @since 1.0.3
*/
class PlgActionlogTjreports extends CMSPlugin
{
/**
* Application object.
*
* @var JApplicationCms
* @since 1.0.3
*/
protected $app;

/**
* Database object.
*
* @var JDatabaseDriver
* @since 1.0.3
*/
protected $db;

/**
* Load plugin language file automatically so that it can be used inside component
*
* @var boolean
* @since 1.0.3
*/
protected $autoloadLanguage = true;

/**
* Proxy for ActionlogsModelUserlog addLog method
*
* This method adds a record to #__action_logs contains (message_language_key, message, date, context, user)
*
* @param array $messages The contents of the messages to be logged
* @param string $messageLanguageKey The language key of the message
* @param string $context The context of the content passed to the plugin
* @param int $userId ID of user perform the action, usually ID of current logged in user
*
* @return void
*
* @since 1.0.3
*/
protected function addLog($messages, $messageLanguageKey, $context, $userId = null)
{
JLoader::register('ActionlogsModelActionlog', JPATH_ADMINISTRATOR . '/components/com_actionlogs/models/actionlog.php');

/* @var ActionlogsModelActionlog $model */
$model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
$model->addLog($messages, $messageLanguageKey, $context, $userId);
}

/**
* On saving report data logging method
*
* Method is called after user data is stored in the database.
* This method logs who created/edited any user's data
*
* @param String $context com_tjreports
* @param Object $table Holds the new report data.
* @param Boolean $isNew True if a new report is stored.
*
* @return void
*
* @since 1.0.3
*/
public function tjReportsOnAfterReportSave($context, $table, $isNew)
{
if (!$this->params->get('logActionForReportCreate', 1))
{
return;
}

$context = JFactory::getApplication()->input->get('option');

$user = JFactory::getUser();

if ($isNew && !empty($table->client))
{
$messageLanguageKey = 'PLG_ACTIONLOG_TJREPORTS_REPORT_ADDED_WITH_CLIENT';
$action = 'add';
}
elseif($isNew && empty($table->client))
{
$messageLanguageKey = 'PLG_ACTIONLOG_TJREPORTS_REPORT_ADDED';
$action = 'add';
}
else
{
$messageLanguageKey = 'PLG_ACTIONLOG_TJREPORTS_REPORT_UPDATED';
$action = 'update';
}

if ($table->client)
{
$language = JFactory::getLanguage();
$language->load($table->client);
}

$message = array(
'action' => $action,
'id' => $table->id,
'title' => $table->title,
'plugin' => $table->plugin,
'client' => JText::_(strtoupper($table->client)),
'itemlink' => 'index.php?option=com_tjreports&task=tjreport.edit&id=' . $table->id,
'userid' => $user->id,
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
);

$this->addLog(array($message), $messageLanguageKey, $context, $user->id);
}

/**
* On saving report data logging method
*
* Method is called after user data is stored in the database.
* This method logs who created/edited any user's data
*
* @param String $context com_tjreports
* @param Object $table Holds the new report data.
*
* @return void
*
* @since 1.0.3
*/
public function tjReportsOnAfterReportDelete($context, $table)
{
if (!$this->params->get('logActionForReportDelete', 1))
{
return;
}

$context = JFactory::getApplication()->input->get('option');
$user = JFactory::getUser();

if (!empty($table->client))
{
$language = JFactory::getLanguage();
$language->load($table->client);

$messageLanguageKey = 'PLG_ACTIONLOG_TJREPORTS_REPORT_DELETED_WITH_CLIENT';
}
else
{
$messageLanguageKey = 'PLG_ACTIONLOG_TJREPORTS_REPORT_DELETED';
}

$message = array(
'action' => 'delete',
'id' => $table->id,
'title' => $table->title,
'plugin' => $table->plugin,
'client' => JText::_(strtoupper($table->client)),
'userid' => $user->id,
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
);

$this->addLog(array($message), $messageLanguageKey, $context, $user->id);
}
}
34 changes: 34 additions & 0 deletions plugins/actionlog/tjreports/tjreports.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension version="3.9" type="plugin" group="actionlog" method="upgrade">
<name>plg_actionlog_tjreports</name>
<author>Techjoomla</author>
<creationDate>16th Nov 2018</creationDate>
<copyright>Copyright (C) 2016 - 2018 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<version>1.0.3</version>
<description>PLG_ACTIONLOG_TJREPORTS_XML_DESCRIPTION</description>
<files>
<filename plugin="tjreports">tjreports.php</filename>
<filename>index.html</filename>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_actionlog_tjreports.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_actionlog_tjreports.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="logActionForReportCreate" type="radio" label="PLG_ACTIONLOG_TJREPORTS_LOG_ACTION_REPORT_CREATE" description="PLG_ACTIONLOG_TJREPORTS_LOG_ACTION_COMMON_DESC" default="1" class="btn-group btn-group-yesno">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="logActionForReportDelete" type="radio" label="PLG_ACTIONLOG_TJREPORTS_LOG_ACTION_REPORT_DELETE" description="PLG_ACTIONLOG_TJREPORTS_LOG_ACTION_COMMON_DESC" default="1" class="btn-group btn-group-yesno">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</config>
</extension>
1 change: 1 addition & 0 deletions plugins/privacy/tjreports/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; @package TJReports
; @subpackage Plg_Privacy_TJReports
; @copyright Copyright © 2009-2018 TechJoomla. All rights reserved.
; @license GNU General Public License version 2, or later
; Note: All ini files need to be saved as UTF-8

PLG_PRIVACY_TJREPORTS="Privacy - TJReports"
PLG_PRIVACY_TJREPORTS_XML_DESCRIPTION="TJReports privacy plugin"

PLG_PRIVACY_TJREPORTS_PRIVACY_CAPABILITY_USER_REPORTS_DETAIL="User Reports Information :- TJReports takes some personal data of users while creating the report (User id)"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; @package TJReports
; @subpackage Plg_Privacy_TJReports
; @copyright Copyright © 2009-2018 TechJoomla. All rights reserved.
; @license GNU General Public License version 2, or later
; Note: All ini files need to be saved as UTF-8

PLG_PRIVACY_TJREPORTS="Privacy - TJReports"
PLG_PRIVACY_TJREPORTS_XML_DESCRIPTION="TJReports privacy plugin"
Loading

0 comments on commit 62a93d0

Please sign in to comment.