Skip to content

Commit

Permalink
Issue techjoomla#145 feat: Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pravinTek committed Jan 22, 2020
2 parents de65050 + 32f6eac commit ca3356d
Show file tree
Hide file tree
Showing 25 changed files with 637 additions and 206 deletions.
1 change: 1 addition & 0 deletions tjreports/administrator/access.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<action name="core.viewall" title="JACTION_VIEWALL" description="COM_TJREPORTS_ACCESS_VIEWALL_DESC" />
<action name="core.view.own" title="JACTION_VIEW_OWN" description="COM_TJREPORTS_ACCESS_VIEW_OWN_DESC" />
<action name="core.view.subscribe" title="JACTION_VIEW_SUBSCRIBE" description="COM_TJREPORTS_ACCESS_VIEW_SUBSCRIBE_DESC" />
<action name="core.view.piidata" title="COM_TJREPORTS_ACCESS_PIIDATA" description="COM_TJREPORTS_ACCESS_PIIDATA_COMPONENT_DESC" />
</section>

<section name="tjreport">
Expand Down
11 changes: 11 additions & 0 deletions tjreports/administrator/models/tjreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,25 @@ public function getReportPluginData($pluginId, $pluginName = null)
JModelLegacy::addIncludePath(JPATH_SITE . '/plugins/tjreports/' . $pluginName);
$plgModel = JModelLegacy::getInstance($pluginName, 'TjreportsModel');

$defaultColToHide = $plgModel->getState('defaultColToHide');

$params = array();
$params['filter_order'] = $plgModel->getState('list.ordering');
$params['filter_order_Dir'] = $plgModel->getState('list.direction');
$params['limit'] = $plgModel->getState('list.limit');
$params['emailColumn'] = $plgModel->getState('emailColumn');
$params['colToshow'] = $plgModel->getState('colToshow');
$params['colToshow'] = array_combine($params['colToshow'], array_fill(0, count($params['colToshow']), true));

/* Here merge colToshow (array value is true) with defaultColToHide (array value is false) column -
* so false value column not display on report by default.*/
if (!empty($defaultColToHide))
{
$params['colToshow'] = array_merge($params['colToshow'], $defaultColToHide);
}

$params['showHideColumns'] = $plgModel->showhideCols;
$params['piiColumns'] = $plgModel->getState('piiColumns');

$report->param = json_encode($params);
}
Expand Down
2 changes: 1 addition & 1 deletion tjreports/administrator/sql/install.mysql.utf8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ CREATE TABLE IF NOT EXISTS `#__tj_reports` (
`datadenyset` int(11),
`param` text NOT NULL,
PRIMARY KEY (`id`)
) AUTO_INCREMENT=1 ;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;
3 changes: 1 addition & 2 deletions tjreports/administrator/sql/uninstall.mysql.utf8.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

DELETE FROM `#__content_types` WHERE (type_alias LIKE 'com_tjreports.%');
-- DELETE FROM `#__content_types` WHERE (type_alias LIKE 'com_tjreports.%');
9 changes: 9 additions & 0 deletions tjreports/administrator/sql/updates/mysql/1.1.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Change engine
ALTER TABLE `#__tj_reports` ENGINE = InnoDB;

-- Change charset, collation for table #__tj_reports
ALTER TABLE `#__tj_reports` CHANGE `title` `title` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
ALTER TABLE `#__tj_reports` CHANGE `alias` `alias` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
ALTER TABLE `#__tj_reports` CHANGE `plugin` `plugin` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
ALTER TABLE `#__tj_reports` CHANGE `client` `client` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
ALTER TABLE `#__tj_reports` CHANGE `param` `param` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ COM_TJREPORTS_ACCESS_VIEW_SUBSCRIBE_DESC="Allow user to view only subscribed rep
JACTION_VIEW="View"
JACTION_VIEW_COMPONENT_DESC="Allow user to view reports in this extension"
JACTION_EXPORT="Export"
COM_TJREPORTS_ACCESS_PIIDATA="View PII Data"
COM_TJREPORTS_ACCESS_PIIDATA_COMPONENT_DESC="Allow user to see Personally Identifiable Information (PII) data on the report."
JACTION_EXPORT_COMPONENT_DESC="Allow user to export report data in this extension"

;tjreport lms
Expand Down
4 changes: 2 additions & 2 deletions tjreports/plugins/actionlog/tjreports/tjreports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="3.9" type="plugin" group="actionlog" method="upgrade">
<name>plg_actionlog_tjreports</name>
<author>Techjoomla</author>
<creationDate>12th Jul 2019</creationDate>
<creationDate>11th Nov 2019</creationDate>
<copyright>Copyright (C) 2016 - 2019 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.1.1</version>
<version>1.1.4</version>
<description>PLG_ACTIONLOG_TJREPORTS_XML_DESCRIPTION</description>
<files>
<filename plugin="tjreports">tjreports.php</filename>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; @package Com_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_API_REPORTS_REPORT_NAME_MISSSING="Please enter report name"
PLG_API_REPORTS_REPORT_NAME_INVALID="Please enter valid report name"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
; @package Com_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_API_REPORTS="TJ Reports Api Plugin"
PLG_API_REPORTS_DESCRIPTION="TJ Reports Api Plugin"
43 changes: 43 additions & 0 deletions tjreports/plugins/api/reports/reports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* @package Tjreports
* @subpackage com_api
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

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

jimport('joomla.plugin.plugin');
JLoader::import('components.com_tjreports.models.report', JPATH_SITE);

/**
* Tjreports API plugin
*
* @since 1.0
*/
class PlgAPIReports extends ApiPlugin
{
/**
* Constructor
*
* @param STRING &$subject subject
* @param array $config config
*
* @since 1.0
*/
public function __construct(&$subject, $config = array())
{
parent::__construct($subject, $config = array());

// Set resource path
ApiResource::addIncludePath(dirname(__FILE__) . '/reports');

// Load language files
$lang = JFactory::getLanguage();
$lang->load('plg_api_reports', JPATH_SITE . "/plugins/api/reports/", 'en-GB', true);
}
}
21 changes: 21 additions & 0 deletions tjreports/plugins/api/reports/reports.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0.0" type="plugin" group="api" method="upgrade">
<name>PLG_API_REPORTS</name>
<version>1.0</version>
<creationDate>28th May 2018</creationDate>
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<copyright>Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>PLG_API_REPORTS_DESCRIPTION</description>
<files>
<filename plugin="reports">reports.php</filename>
<folder>reports</folder>
<folder>language</folder>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_api_reports.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_api_reports.sys.ini</language>
</languages>
</extension>
61 changes: 61 additions & 0 deletions tjreports/plugins/api/reports/reports/filters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* @package Tjreports
* @subpackage com_api
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

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

/**
* Tjreports API report class
*
* @since 1.0.0
*/
class ReportsApiResourceFilters extends ApiResource
{
/**
* Function get filters data
*
* @return boolean
*/
public function get()
{
$app = JFactory::getApplication();
$jinput = $app->input;
$reportName = $jinput->getString('id');

if (!isset($reportName))
{
ApiError::raiseError(400, JText::_('PLG_API_REPORTS_REPORT_NAME_MISSSING'), 'APIValidationException');
}

$lang = JFactory::getLanguage();
//load default joomla language file
$lang->load('', JPATH_ADMINISTRATOR, 'en-GB', true);

// Make object of the tjreports plugin to load filters for
JLoader::import('plugins.tjreports.' . $reportName . "." . $reportName, JPATH_SITE);
$className = 'TjreportsModel' . ucfirst($reportName);

if (!class_exists($className))
{
ApiError::raiseError(400, JText::_('PLG_API_REPORTS_REPORT_NAME_INVALID'), 'APIValidationException');
}

$reportPlugin = new $className;

$filters = $reportPlugin->displayFilters();
$filter_array = [];
foreach ($filters[0] as $key => $value) {
$value['name'] = $key;
$filter_array[] = $value;
}

$this->plugin->setResponse($filter_array);
}
}
97 changes: 97 additions & 0 deletions tjreports/plugins/api/reports/reports/report.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
/**
* @package Tjreports
* @subpackage com_api
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

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

/**
* Tjreports API report class
*
* @since 1.0.0
*/
class ReportsApiResourceReport extends ApiResource
{
/**
* Function to get report data from tjreports plugin
*
* @return json
*/
public function post()
{
$app = JFactory::getApplication();
$jinput = $app->input;
$formData = $jinput->post;
$reportName = $app->input->getString('id');

if (empty($reportName))
{
$reportName = $formData->getString('report');
}

if (!isset($reportName))
{
ApiError::raiseError(400, JText::_('PLG_API_REPORTS_REPORT_NAME_MISSSING'), 'APIValidationException');
}

// Create object of tjreports plugin class

JLoader::import('plugins.tjreports.' . $reportName . "." . $reportName, JPATH_SITE);
$className = 'TjreportsModel' . ucfirst($reportName);

if (!class_exists($className))
{
ApiError::raiseError(400, JText::_('PLG_API_REPORTS_REPORT_NAME_INVALID'), 'APIValidationException');
}

$reportPlugin = new $className;

// Load language files
$lang = JFactory::getLanguage();
$lang->load('com_tjreports', JPATH_ADMINISTRATOR, 'en-GB', true);
$lang->load('plg_tjreports_' . $reportName, JPATH_SITE . "/plugins/tjreports/" . $reportName, 'en-GB', true);

// Get filters and cols
$reportId = $reportPlugin->getDefaultReport($reportName);
$reportFilters = ($formData->get('filters')) ? $formData->get('filters') : [];
$reportCols = ($formData->get('colToshow')) ? $formData->get('colToshow') : [];

$reportPlugin->setState('filters', $reportFilters);
$reportPlugin->setState('colToshow', $reportCols);
$reportPlugin->setState('reportId', $reportId);

// Get results and errors if any
$report = $reportPlugin->getItems();
$errors = $reportPlugin->getTJRMessages();

if (!empty($errors))
{
ApiError::raiseError(400, $errors[0], 'APIValidationException');
}

// @TODO Handle else condition first to reduce nesting
if (!empty($reportCols))
{
foreach ($report as $key => $value)
{
foreach ($value as $k => $v)
{
if (!in_array($k, $reportCols))
{
unset($value[$k]);
}
}

$report[$key] = $value;
}
}

$this->plugin->setResponse($report);
}
}
4 changes: 2 additions & 2 deletions tjreports/plugins/content/tjreportsfields/tjreportsfields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<creationDate>12th Jul 2019</creationDate>
<creationDate>11th Nov 2019</creationDate>
<copyright>Copyright (C) 2016 - 2019 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<version>1.1.1</version>
<version>1.1.4</version>

<files>
<filename plugin="tjreportsfields">tjreportsfields.php</filename>
Expand Down
4 changes: 2 additions & 2 deletions tjreports/plugins/privacy/tjreports/tjreports.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.4" type="plugin" group="privacy" method="upgrade">
<name>plg_privacy_tjreports</name>
<version>1.1.1</version>
<creationDate>12th Jul 2019</creationDate>
<version>1.1.4</version>
<creationDate>11th Nov 2019</creationDate>
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE TABLE IF NOT EXISTS `#__tjreports_com_users_user` (
`record_id` int(11) NOT NULL
`record_id` int(11) NOT NULL,
`username_hash` VARCHAR(100) NOT NULL,
`email_hash` VARCHAR(100) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE `#__tjreports_com_users_user` ADD username_hash VARCHAR(100) NOT NULL AFTER record_id;
ALTER TABLE `#__tjreports_com_users_user` ADD email_hash VARCHAR(100) NOT NULL AFTER username_hash;
15 changes: 4 additions & 11 deletions tjreports/plugins/user/tjreportsindexer/tjreportsindexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ class PlgUserTjreportsindexer extends JPlugin
*/
public function onUserAfterSave($user, $isNew, $success, $msg)
{
/*
[com_fields] => Array
(
[job-position] => Developer
)*/

if (empty($user['com_fields']))
{
return;
}

// Delete existing user-data entry
// Here record_id = user_id
$this->deleteIndexerEntry($user['id']);
Expand Down Expand Up @@ -153,6 +142,10 @@ protected function addIndexerEntry($user)
$values[] = $db->quote($value);
}

// Add username & email hash values
array_push($columns, 'username_hash', 'email_hash');
array_push($values, "'" . md5($user['username']) . "'", "'" . md5($user['email']) . "'");

// Prepare the insert query
$query = $db->getQuery(true);
$query
Expand Down
4 changes: 2 additions & 2 deletions tjreports/plugins/user/tjreportsindexer/tjreportsindexer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<creationDate>12th Jul 2019</creationDate>
<creationDate>11th Nov 2019</creationDate>
<copyright>Copyright (C) 2016 - 2019 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<version>1.1.1</version>
<version>1.1.4</version>
<install>
<sql>
<file driver="mysql" charset="utf8">sql/tjreportsindexer.install.sql</file>
Expand Down
Loading

0 comments on commit ca3356d

Please sign in to comment.