diff --git a/tjreports/administrator/access.xml b/tjreports/administrator/access.xml index 2e45095..85ca516 100755 --- a/tjreports/administrator/access.xml +++ b/tjreports/administrator/access.xml @@ -13,6 +13,7 @@ +
diff --git a/tjreports/administrator/models/tjreport.php b/tjreports/administrator/models/tjreport.php index ece6446..5ed7eeb 100644 --- a/tjreports/administrator/models/tjreport.php +++ b/tjreports/administrator/models/tjreport.php @@ -173,6 +173,8 @@ 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'); @@ -180,7 +182,16 @@ public function getReportPluginData($pluginId, $pluginName = null) $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); } diff --git a/tjreports/administrator/sql/install.mysql.utf8.sql b/tjreports/administrator/sql/install.mysql.utf8.sql index 26a7e86..70bd55f 100755 --- a/tjreports/administrator/sql/install.mysql.utf8.sql +++ b/tjreports/administrator/sql/install.mysql.utf8.sql @@ -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; diff --git a/tjreports/administrator/sql/uninstall.mysql.utf8.sql b/tjreports/administrator/sql/uninstall.mysql.utf8.sql index d31a636..94f5d88 100755 --- a/tjreports/administrator/sql/uninstall.mysql.utf8.sql +++ b/tjreports/administrator/sql/uninstall.mysql.utf8.sql @@ -1,2 +1 @@ - -DELETE FROM `#__content_types` WHERE (type_alias LIKE 'com_tjreports.%'); \ No newline at end of file +-- DELETE FROM `#__content_types` WHERE (type_alias LIKE 'com_tjreports.%'); diff --git a/tjreports/administrator/sql/updates/mysql/1.1.2.sql b/tjreports/administrator/sql/updates/mysql/1.1.2.sql new file mode 100644 index 0000000..b4c54ee --- /dev/null +++ b/tjreports/administrator/sql/updates/mysql/1.1.2.sql @@ -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; diff --git a/tjreports/languages/administrator/en-GB/en-GB.com_tjreports.ini b/tjreports/languages/administrator/en-GB/en-GB.com_tjreports.ini index c57d742..cfbb861 100755 --- a/tjreports/languages/administrator/en-GB/en-GB.com_tjreports.ini +++ b/tjreports/languages/administrator/en-GB/en-GB.com_tjreports.ini @@ -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 diff --git a/tjreports/plugins/actionlog/tjreports/tjreports.xml b/tjreports/plugins/actionlog/tjreports/tjreports.xml index 314baeb..58e7c09 100644 --- a/tjreports/plugins/actionlog/tjreports/tjreports.xml +++ b/tjreports/plugins/actionlog/tjreports/tjreports.xml @@ -2,12 +2,12 @@ plg_actionlog_tjreports Techjoomla - 12th Jul 2019 + 11th Nov 2019 Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL extensions@techjoomla.com https://techjoomla.com - 1.1.1 + 1.1.4 PLG_ACTIONLOG_TJREPORTS_XML_DESCRIPTION tjreports.php diff --git a/tjreports/plugins/api/reports/language/en-GB/en-GB.plg_api_reports.ini b/tjreports/plugins/api/reports/language/en-GB/en-GB.plg_api_reports.ini new file mode 100644 index 0000000..c01b6f1 --- /dev/null +++ b/tjreports/plugins/api/reports/language/en-GB/en-GB.plg_api_reports.ini @@ -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" diff --git a/tjreports/plugins/api/reports/language/en-GB/en-GB.plg_api_reports.sys.ini b/tjreports/plugins/api/reports/language/en-GB/en-GB.plg_api_reports.sys.ini new file mode 100644 index 0000000..5dc53f0 --- /dev/null +++ b/tjreports/plugins/api/reports/language/en-GB/en-GB.plg_api_reports.sys.ini @@ -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" diff --git a/tjreports/plugins/api/reports/reports.php b/tjreports/plugins/api/reports/reports.php new file mode 100644 index 0000000..5d4a54b --- /dev/null +++ b/tjreports/plugins/api/reports/reports.php @@ -0,0 +1,43 @@ + + * @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); + } +} diff --git a/tjreports/plugins/api/reports/reports.xml b/tjreports/plugins/api/reports/reports.xml new file mode 100644 index 0000000..6bf8411 --- /dev/null +++ b/tjreports/plugins/api/reports/reports.xml @@ -0,0 +1,21 @@ + + + PLG_API_REPORTS + 1.0 + 28th May 2018 + Techjoomla + extensions@techjoomla.com + https://techjoomla.com + Techjoomla. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + PLG_API_REPORTS_DESCRIPTION + + reports.php + reports + language + + + en-GB/en-GB.plg_api_reports.ini + en-GB/en-GB.plg_api_reports.sys.ini + + diff --git a/tjreports/plugins/api/reports/reports/filters.php b/tjreports/plugins/api/reports/reports/filters.php new file mode 100644 index 0000000..c6ff182 --- /dev/null +++ b/tjreports/plugins/api/reports/reports/filters.php @@ -0,0 +1,61 @@ + + * @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); + } +} diff --git a/tjreports/plugins/api/reports/reports/report.php b/tjreports/plugins/api/reports/reports/report.php new file mode 100644 index 0000000..3ba048c --- /dev/null +++ b/tjreports/plugins/api/reports/reports/report.php @@ -0,0 +1,97 @@ + + * @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); + } +} diff --git a/tjreports/plugins/content/tjreportsfields/tjreportsfields.xml b/tjreports/plugins/content/tjreportsfields/tjreportsfields.xml index f7f33d5..90250ec 100644 --- a/tjreports/plugins/content/tjreportsfields/tjreportsfields.xml +++ b/tjreports/plugins/content/tjreportsfields/tjreportsfields.xml @@ -5,10 +5,10 @@ Techjoomla extensions@techjoomla.com https://techjoomla.com - 12th Jul 2019 + 11th Nov 2019 Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 1.1.1 + 1.1.4 tjreportsfields.php diff --git a/tjreports/plugins/privacy/tjreports/tjreports.xml b/tjreports/plugins/privacy/tjreports/tjreports.xml index 45d6501..db63cec 100644 --- a/tjreports/plugins/privacy/tjreports/tjreports.xml +++ b/tjreports/plugins/privacy/tjreports/tjreports.xml @@ -1,8 +1,8 @@ plg_privacy_tjreports - 1.1.1 - 12th Jul 2019 + 1.1.4 + 11th Nov 2019 Techjoomla extensions@techjoomla.com https://techjoomla.com diff --git a/tjreports/plugins/user/tjreportsindexer/sql/tjreportsindexer.install.sql b/tjreports/plugins/user/tjreportsindexer/sql/tjreportsindexer.install.sql index 4e64539..d79fa56 100755 --- a/tjreports/plugins/user/tjreportsindexer/sql/tjreportsindexer.install.sql +++ b/tjreports/plugins/user/tjreportsindexer/sql/tjreportsindexer.install.sql @@ -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; diff --git a/tjreports/plugins/user/tjreportsindexer/sql/updates/mysql/1.1.2.sql b/tjreports/plugins/user/tjreportsindexer/sql/updates/mysql/1.1.2.sql new file mode 100644 index 0000000..7977427 --- /dev/null +++ b/tjreports/plugins/user/tjreportsindexer/sql/updates/mysql/1.1.2.sql @@ -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; diff --git a/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.php b/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.php index 533eab9..e43c79d 100644 --- a/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.php +++ b/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.php @@ -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']); @@ -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 diff --git a/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.xml b/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.xml index 568f885..4b2e249 100644 --- a/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.xml +++ b/tjreports/plugins/user/tjreportsindexer/tjreportsindexer.xml @@ -5,10 +5,10 @@ Techjoomla extensions@techjoomla.com https://techjoomla.com - 12th Jul 2019 + 11th Nov 2019 Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 1.1.1 + 1.1.4 sql/tjreportsindexer.install.sql diff --git a/tjreports/script.tjreports.php b/tjreports/script.tjreports.php index 7d95be2..1585029 100755 --- a/tjreports/script.tjreports.php +++ b/tjreports/script.tjreports.php @@ -59,6 +59,9 @@ class Com_TjreportsInstallerScript ), 'user' => array( 'tjreportsindexer' => 0 + ), + 'api' => array( + 'reports' => 1 ) ) ); diff --git a/tjreports/site/assets/js/tjrContentUI.js b/tjreports/site/assets/js/tjrContentUI.js index 5c16ad2..a76c1af 100755 --- a/tjreports/site/assets/js/tjrContentUI.js +++ b/tjreports/site/assets/js/tjrContentUI.js @@ -49,11 +49,11 @@ jQuery.extend(tjrContentUI.report, { // If sendEmail plug is enabled then try to add a column of checkboxes if ( - typeof tjutilitysendemail != 'undefined' && + typeof window.tjSendEmail != 'undefined' && jQuery('body').find('.td-sendemail').length > 0 ) { - tjutilitysendemail.addColumn('report-table'); + window.tjemail = new window.tjSendEmail.UI("report-table", "td-sendemail", "cid"); } // Reinitialze some js like for calandar, tooltip, chosen diff --git a/tjreports/site/models/reports.php b/tjreports/site/models/reports.php index ef0f72a..4385512 100755 --- a/tjreports/site/models/reports.php +++ b/tjreports/site/models/reports.php @@ -10,10 +10,19 @@ // No direct access defined('_JEXEC') or die('Restricted access'); +Use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Factory; +Use Joomla\Registry\Registry; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\HTML\HTMLHelper; + jimport('joomla.application.component.modellist'); // Load TJReports db helper JLoader::import('database', JPATH_SITE . '/components/com_tjreports/helpers'); +JLoader::import('components.com_tjreports.helpers.tjreports', JPATH_ADMINISTRATOR); use Joomla\CMS\Date\Date; @@ -22,7 +31,7 @@ * * @since 1.0.0 */ -class TjreportsModelReports extends JModelList +class TjreportsModelReports extends ListModel { // Default ordering of Data protected $default_order = ''; @@ -39,6 +48,9 @@ class TjreportsModelReports extends JModelList // Columns array contain columns data public $columns = array(); + // Columns array contain PII columns + private $piiColumns = array(); + // Columns array contain email columns private $emailColumn = ''; @@ -46,7 +58,10 @@ class TjreportsModelReports extends JModelList public $showhideCols = array(); // Columns which will be displayed by default - private $defaultColToShow = array(); + public $defaultColToShow = array(); + + // Columns which will be hide by default + private $defaultColToHide = array(); // Columns which are sortable with or without query statement public $sortableColumns = array(); @@ -74,6 +89,17 @@ class TjreportsModelReports extends JModelList protected $tjreportsDbHelper; + private $piiPermission; + + private $filterShowhideCols = array(); + + private $filterPiiColumns = array(); + + public $filterParamColToshow = array(); + + // Used to get the columns which are hide by default in load params + public $filterDefaultColToHide = array(); + /** * Constructor. * @@ -102,12 +128,18 @@ public function __construct($config = array()) array_map( function ($ar) { - return $ar['emailColumn']; + if (!empty($ar['emailColumn'])) + { + return $ar['emailColumn']; + } }, $this->columns ) ); + // Check PII data permission + $this->piiPermission = $this->canViewPiiData(); + $this->initData(); parent::__construct($config); @@ -135,7 +167,7 @@ protected function setCustomFieldsColumns() } // Get column name, type for custom fields index table - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $columnsDetails = $db->getTableColumns($this->customFieldsTable); // If no columns, return @@ -159,18 +191,10 @@ protected function setCustomFieldsColumns() // Set columns from custom fields table into tjreports plugin's column list foreach ($columnNames as $columnName) { - // Skip primary key, record_id of indexed table - // As those are not part of custom fields - if (!isset($columnLabels[$columnName])) - { - continue; - } - $customField = array ( - 'title' => $columnLabels[$columnName], - 'table_column' => $this->customFieldsTableAlias . '.' . $columnName - - // , 'disable_sorting' => true + 'title' => isset($columnLabels[$columnName]) ? $columnLabels[$columnName] : $columnName, + 'table_column' => $this->customFieldsTableAlias . '.' . $columnName, + 'not_show_hide' => false ); // Eg. tuf.dob @@ -203,7 +227,7 @@ protected function setCustomFieldsDisplayFilters(&$displayFilters) } // Get column name, type for custom fields index table - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $columnsDetails = $db->getTableColumns($this->customFieldsTable); // If no columns, return @@ -264,13 +288,13 @@ protected function setCustomFieldsDisplayFilters(&$displayFilters) $this->customFieldsTableAlias . '.' . $key . '_from' => array ( 'attrib' => array ( 'placeholder' => 'YYYY-MM-DD', - 'onChange' => 'tjrContentUI.report.attachCalSubmit(this);' + 'onChange' => 'tjrContentUI.report.attachCalSubmit(this);' ) ), $this->customFieldsTableAlias . '.' . $key . '_to' => array ( 'attrib' => array ( 'placeholder' => 'YYYY-MM-DD', - 'onChange' => 'tjrContentUI.report.attachCalSubmit(this);' + 'onChange' => 'tjrContentUI.report.attachCalSubmit(this);' ) ) ); @@ -317,14 +341,14 @@ protected function setCustomFieldsDisplayFilters(&$displayFilters) */ protected function getCustomFieldsDisplayFilterOptions($column) { - $objArray = array(); - $obj = new stdClass; - $obj->text = JText::_('- Select ' . $column . ' -'); - $obj->value = ''; - $objArray[] = $obj; + $objArray = array(); + $obj = new stdClass; + $obj->text = Text::_('- Select ' . $column . ' -'); + $obj->value = ''; + $objArray[] = $obj; // Get column name, type for custom fields index table - $db = JFactory::getDbo(); + $db = Factory::getDbo(); // Get column labels from #__fields table for all indexed custom fields from this table $query = $db->getQuery(true); @@ -348,17 +372,20 @@ protected function getCustomFieldsDisplayFilterOptions($column) * */ private function initData() { - $columns = $this->columns; - $columnsKeys = array_keys($columns); + $columns = $this->columns; + $columnsKeys = array_keys($columns); + $this->sortableWoQuery = array(); + $this->defaultColToShow = $this->sortableColumns = $this->showhideCols = array_combine($columnsKeys, $columnsKeys); - $this->sortableWoQuery = array(); foreach ($columns as $key => $column) { if ((isset($column['not_show_hide']) && $column['not_show_hide'] === true) || (strpos($key, '::') !== false && !isset($column['not_show_hide']))) { + // If column not_show_hide = true then this column hide from show/hide list as well as on the report unset($this->showhideCols[$key]); + unset($this->defaultColToShow[$key]); } if ((isset($column['disable_sorting']) && $column['disable_sorting']) @@ -367,6 +394,11 @@ private function initData() unset($this->sortableColumns[$key]); } + if (isset($column['isPiiColumn']) && $column['isPiiColumn'] === true) + { + array_push($this->piiColumns, $key); + } + if (!isset($column['disable_sorting']) && (!isset($column['table_column']) || !in_array($key, $this->sortableColumns))) { array_push($this->sortableWoQuery, $key); @@ -375,14 +407,19 @@ private function initData() if (!isset($column['title']) || (strpos($key, '::') !== false) || (isset($column['not_show_hide']) && $column['not_show_hide'] === false)) { + /* If column not_show_hide = false then column does not show on the report + * but shows on Hide / show column list dropdown with unchecking the checkbox.*/ + array_push($this->defaultColToHide, $key); unset($this->defaultColToShow[$key]); } } + $this->piiColumns = array_values($this->piiColumns); $this->showhideCols = array_values($this->showhideCols); $this->sortableColumns = array_values($this->sortableColumns); $this->sortableWoQuery = array_values($this->sortableWoQuery); $this->defaultColToShow = array_values($this->defaultColToShow); + $this->defaultColToHide = array_values($this->defaultColToHide); } /** @@ -407,9 +444,12 @@ public function getTJRMessages() public function getValidRequestVars() { $validVars = array( - 'colToshow' => 'ARRAY', 'filters' => 'ARRAY', - 'limit' => 'INT', 'limitstart' => 'INT', - 'filter_order' => 'STRING', 'filter_order_Dir' => 'STRING' + 'colToshow' => 'ARRAY', + 'filters' => 'ARRAY', + 'limit' => 'INT', + 'limitstart' => 'INT', + 'filter_order' => 'STRING', + 'filter_order_Dir' => 'STRING' ); return $validVars; @@ -501,8 +541,8 @@ protected function _getList($query, $limitstart = 0, $limit = 0) protected function populateState($ordering = '', $direction = 'ASC') { // List state information - $app = JFactory::getApplication(); - $input = JFactory::getApplication()->input; + $app = Factory::getApplication(); + $input = $app->input; if (!($reportId = $input->get('reportId', 0, 'uint'))) { @@ -519,8 +559,14 @@ protected function populateState($ordering = '', $direction = 'ASC') if (empty($colToshow)) { $reportParams = $this->getReportParams($reportId); + $colToshow = (array) $reportParams->get("colToshow"); + $piiColumns = (array) $reportParams->get("piiColumns"); + $piiColumns = array_flip($piiColumns); - $colToshow = $reportParams->get("colToshow"); + if (!empty($piiColumns)) + { + $colToshow = (object) array_diff_key($colToshow, $piiColumns); + } } $this->filterReportColumns($reportId, $colToshow); @@ -532,7 +578,7 @@ protected function populateState($ordering = '', $direction = 'ASC') $this->setState('colToshow', $colToshow); - $filters = $input->get('filters', array(), 'ARRAY'); + $filters = $input->get('filters', array(), 'ARRAY'); $this->setState('filters', $filters); // List state information @@ -542,11 +588,23 @@ protected function populateState($ordering = '', $direction = 'ASC') $value = $input->get('limitstart', 0, 'uint'); $this->setState('list.start', $value); + if (!empty($this->piiColumns)) + { + $this->setState('piiColumns', $this->piiColumns); + } + if ($this->emailColumn) { $this->setState('emailColumn', $this->emailColumn); } + if ($this->defaultColToHide) + { + // Array set hide column in param as false value + $defaultColToHide = array_combine($this->defaultColToHide, array_fill(0, count($this->defaultColToHide), false)); + $this->setState('defaultColToHide', $defaultColToHide); + } + // Ordering $this->default_order = $input->get('filter_order', $this->default_order, 'STRING'); @@ -579,7 +637,7 @@ protected function populateState($ordering = '', $direction = 'ASC') */ protected function getListQuery() { - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $filters = (array) $this->getState('filters'); $displayFilters = (array) $this->displayFilters(); @@ -723,9 +781,9 @@ protected function sortCustomColumns($items) if (!empty($items) && !empty($sortKey) && in_array($sortKey, $this->sortableWoQuery) && $limit) { - $orderDir = $this->getState('list.direction', $this->default_order_dir); + $orderDir = $this->getState('list.direction', $this->default_order_dir); $this->multi_d_sort($items, $sortKey, $orderDir); - $items = array_splice($items, $limitstart, $limit); + $items = array_splice($items, $limitstart, $limit); } return $items; @@ -770,7 +828,7 @@ private function multi_d_sort(&$array, $column, $order) * * @param INT $reportToBuild report to build * - * @return object + * @return Mixed * * @since 1.0 */ @@ -778,7 +836,7 @@ public function getSavedQueries($user_id, $reportToBuild) { if (!empty($reportToBuild) && !empty($user_id)) { - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select('*'); $query->from('#__tj_reports'); @@ -804,7 +862,7 @@ public function getSavedQueries($user_id, $reportToBuild) */ public function getQueryData($queryId) { - $ol_user = JFactory::getUser()->id; + $ol_user = Factory::getUser()->id; $query = $this->_db->getQuery(true); $query->select('*'); $query->from('#__tj_reports'); @@ -820,23 +878,23 @@ public function getQueryData($queryId) /** * Get all plugins names * - * @return object + * @return Array * * @since 1.0 */ public function getenableReportPlugins() { - $user = JFactory::getUser(); - $input = JFactory::getApplication()->input; + $user = Factory::getUser(); + $input = Factory::getApplication()->input; $client = $input->get('client', '', 'STRING'); // Get all report plugin $dispatcher = JEventDispatcher::getInstance(); - $plugins = JPluginHelper::getPlugin('tjreports'); + $plugins = PluginHelper::getPlugin('tjreports'); $pluginExists = json_decode(json_encode($plugins), true); - $pluginNames = array_column($pluginExists, 'name'); + $pluginNames = array_column($pluginExists, 'name'); - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select(array('id as reportId, title, plugin, ordering')); @@ -866,7 +924,10 @@ public function getenableReportPlugins() // In view layouts - reports[0] is used, and since array indexes are unset above, // Let's re-arrange index accordingly - $reports = array_values($reports); + if (is_array($reports)) + { + $reports = array_values($reports); + } return $reports; } @@ -880,7 +941,7 @@ public function getenableReportPlugins() */ public function getUserFilter() { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); $query->select('u.id,u.username'); @@ -890,13 +951,13 @@ public function getUserFilter() $db->setQuery($query); $users = $db->loadObjectList(); - $userFilter[] = JHTML::_('select.option', '', JText::_('COM_TJREPORTS_FILTER_SELECT_USER')); + $userFilter[] = HTMLHelper::_('select.option', '', Text::_('COM_TJREPORTS_FILTER_SELECT_USER')); if (!empty($users)) { foreach ($users as $eachUser) { - $userFilter[] = JHTML::_('select.option', $eachUser->id, $eachUser->username); + $userFilter[] = HTMLHelper::_('select.option', $eachUser->id, $eachUser->username); } } @@ -913,9 +974,9 @@ public function getUserFilter() public function getreportoptions() { // Initialize variables. - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $user_id = JFactory::getUser()->id; + $db = Factory::getDbo(); + $query = $db->getQuery(true); + $user_id = Factory::getUser()->id; $clients = $this->getState('client'); @@ -945,29 +1006,44 @@ public function getreportoptions() $db->setQuery($query); $reports = $db->loadObjectList(); - $options[] = JHTML::_('select.option', 0, JText::_('COM_TJREPORTS_SELONE_REPORTS')); + $options[] = HTMLHelper::_('select.option', 0, Text::_('COM_TJREPORTS_SELONE_REPORTS')); foreach ($reports as $repo) { - $options[] = JHtml::_('select.option', $repo->value, $repo->text); + $options[] = HTMLHelper::_('select.option', $repo->value, $repo->text); } return $options; } + /** + * Check for permissions + * + * @return boolean + * + * @since 1.0 + */ + + public function canViewPiiData() + { + $canDo = TjreportsHelper::getActions(); + + return $canDo->get('core.view.piidata'); + } + /** * Check for permissions * * @param INT $reportId report id * - * @return object + * @return Mixed * - * @since 1.0 + * @since 1.0 */ public function checkpermissions($reportId) { - $user = JFactory::getUser(); + $user = Factory::getUser(); if ($reportId) { @@ -988,8 +1064,8 @@ public function checkpermissions($reportId) */ public function getUserGroupFilter($includeSuperAdmin = true) { - $groups = JHtml::_('user.groups', $includeSuperAdmin); - array_unshift($groups, JHtml::_('select.option', '', JText::_('JGLOBAL_FILTER_GROUPS_LABEL'))); + $groups = HTMLHelper::_('user.groups', $includeSuperAdmin); + array_unshift($groups, HTMLHelper::_('select.option', '', Text::_('JGLOBAL_FILTER_GROUPS_LABEL'))); return $groups; } @@ -1003,25 +1079,25 @@ public function getUserGroupFilter($includeSuperAdmin = true) */ public function datadenyset() { - $input = JFactory::getApplication()->input; + $input = Factory::getApplication()->input; $reportId = $input->get('reportId', '0', 'int'); if ($reportId) { $this->model = $this->getModel('reports'); - $reportData = $this->model->getReportNameById($reportId); - $reportName = $reportData->title; + $reportData = $this->model->getReportNameById($reportId); + $reportName = $reportData->title; } else { return false; } - $user_id = JFactory::getUser()->id; + $user_id = Factory::getUser()->id; if ($reportName && $user_id && $reportId) { - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select(array('param')); $query->from($db->quoteName('#__tj_reports')); @@ -1059,7 +1135,7 @@ public function loadLanguage($name, $type = 'tjreports', $extension = '', $baseP } $extension = strtolower($extension); - $lang = JFactory::getLanguage(); + $lang = Factory::getLanguage(); // If language already loaded, don't load it again. if ($lang->getPaths($extension)) @@ -1074,8 +1150,8 @@ public function loadLanguage($name, $type = 'tjreports', $extension = '', $baseP /** * Method to Process parent Report columns * - * @param string $queryId Query Id - * @param ARRAY &$selColToshow Columns to show + * @param INT $queryId Query Id + * @param ARRAY &$selColToshow Columns to show * * @return Void * @@ -1089,78 +1165,101 @@ private function filterReportColumns($queryId, &$selColToshow) } $query = $this->_db->getQuery(true); - $showhideCols = $paramColToshow = array(); + $this->filterDefaultColToHide = $this->filterShowhideCols = $this->filterPiiColumns = $this->filterParamColToshow = array(); + + // $this->filterSelColToshow = $selColToshow; // Process plugin params - $parentId = $this->processSavedReportColumns($queryId, $showhideCols, $paramColToshow, $selColToshow); + $parentId = $this->processSavedReportColumns($queryId, $selColToshow); // Process if user has saved query is for a plugin if (!empty($parentId)) { - $this->processSavedReportColumns($parentId, $showhideCols, $paramColToshow, $selColToshow); + $this->processSavedReportColumns($parentId, $selColToshow); } // If plugin has save any column assign that otherwise default plugin param will be applied - if ($paramColToshow) + if ($this->filterParamColToshow) { // If show hide column changes, check if there is any must to hide column if ($selColToshow) { - $selColToshow = array_intersect($selColToshow, $paramColToshow); - $selColToshow = $selColToshow ? $selColToshow : $paramColToshow; + $selColToshow = array_intersect($selColToshow, $this->filterParamColToshow); + $selColToshow = $selColToshow ? $selColToshow : $this->filterParamColToshow; } else { - $selColToshow = $paramColToshow; + $selColToshow = $this->filterParamColToshow; } } - if (!empty($showhideCols)) + // Used to get the columns which are hide by default in load params + if (!empty($this->filterDefaultColToHide)) { - $this->showhideCols = $showhideCols; + $this->defaultColToHide = $this->filterDefaultColToHide; + } + + if (!empty($this->filterShowhideCols)) + { + $this->showhideCols = $this->filterShowhideCols; } if (!empty($emailColumn)) { $this->emailColumn = $emailColumn; } + + if (!empty($this->filterPiiColumns)) + { + $this->piiColumns = $this->filterPiiColumns; + } } /** * Method to Process parent Report columns * * @param INT $queryId Query Id - * @param ARRAY &$showhideCols Show Hide columns - * @param ARRAY &$colToshow Columns to show * @param ARRAY &$selColToshow Selected Cols * - * @return Void + * @return INTEGER * * @since 3.0 */ - private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow, &$selColToshow) + private function processSavedReportColumns($queryId, &$selColToshow) { $query = $this->_db->getQuery(true); $query->select(array('param', 'parent')) ->from('#__tj_reports') ->where('id=' . (int) $queryId); $this->_db->setQuery($query); - $queryData = $this->_db->loadObject(); - $i = $parent = 0; + $queryData = $this->_db->loadObject(); + $i = $parent = 0; if (!empty($queryData->param)) { - $param = json_decode($queryData->param, true); + $param = json_decode($queryData->param, true); if (isset($param['showHideColumns'])) { - if (empty($showhideCols)) + if (empty($this->filterShowhideCols)) + { + $this->filterShowhideCols = (array) $param['showHideColumns']; + } + else + { + $this->filterShowhideCols = array_intersect($this->filterShowhideCols, (array) $param['showHideColumns']); + } + } + + if (isset($param['piiColumns'])) + { + if (empty($this->filterPiiColumns)) { - $showhideCols = (array) $param['showHideColumns']; + $this->filterPiiColumns = (array) $param['piiColumns']; } else { - $showhideCols = array_intersect($showhideCols, (array) $param['showHideColumns']); + $this->filterPiiColumns = array_intersect($this->filterPiiColumns, (array) $param['piiColumns']); } } @@ -1170,20 +1269,44 @@ private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow { if ($show !== false || in_array($cols, $selColToshow)) { - $colToshow[$cols] = $cols; + $this->filterParamColToshow[$cols] = $cols; + } + else + { + // Used to get the columns which are hide (false) by default in load params + $this->filterDefaultColToHide[$cols] = $cols; } if (!empty($param['showHideColumns']) && !in_array($cols, $param['showHideColumns']) && !empty($selColToshow)) { array_splice($selColToshow, $i, 0, $cols); $i++; - $colToshow[$cols] = $cols; + $this->filterParamColToshow[$cols] = $cols; } } } + // Check PII permission + if (!empty($param['piiColumns']) && !$this->piiPermission) + { + /* Checked the columns which are hide(false) in load params & if set them as piiColumns + * then it only returns the columns which are not available in piiColumns. */ + $this->filterDefaultColToHide = array_diff($this->filterDefaultColToHide, $param['piiColumns']); + $this->filterParamColToshow = array_diff($this->filterParamColToshow, $param['piiColumns']); + $this->filterShowhideCols = array_diff($this->filterShowhideCols, $param['piiColumns']); + } + $parent = $queryData->parent; } + else + { + // Check PII permission if load params not set + if (!empty($this->piiColumns) && !$this->piiPermission) + { + $this->defaultColToShow = array_diff($this->defaultColToShow, $this->piiColumns); + $this->showhideCols = array_diff($this->showhideCols, $this->piiColumns); + } + } return $parent; } @@ -1193,15 +1316,15 @@ private function processSavedReportColumns($queryId, &$showhideCols, &$colToshow * * @param INT $reportId Report Id * - * @return Object + * @return Mixed * * @since 3.0 */ public function getReportNameById($reportId) { - $db = JFactory::getDBO(); - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); - $reportTable = JTable::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); + $db = Factory::getDBO(); + Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); + $reportTable = Table::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); $reportTable->load(array('id' => $reportId)); return $reportTable; @@ -1219,9 +1342,8 @@ public function getReportNameById($reportId) */ public function getReportLink($reportToLink, $filters) { - $user = JFactory::getUser(); - - $reports = $this->getPluginReport($reportToLink); + $user = Factory::getUser(); + $reports = $this->getPluginReport($reportToLink); $filterLink = ''; foreach ($filters as $key => $value) @@ -1247,18 +1369,18 @@ public function getReportLink($reportToLink, $filters) * * @param STRING $reportId Report Id * - * @return Integer + * @return Object * * @since 1.1.0 */ public function getReportParams($reportId) { - $db = JFactory::getDBO(); - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); - $reportTable = JTable::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); + $db = Factory::getDBO(); + Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); + $reportTable = Table::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); $reportTable->load($reportId); - return new JRegistry($reportTable->param); + return new Registry($reportTable->param); } /** @@ -1272,9 +1394,9 @@ public function getReportParams($reportId) */ public function getDefaultReport($pluginName) { - $db = JFactory::getDBO(); - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); - $reportTable = JTable::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); + $db = Factory::getDBO(); + Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); + $reportTable = Table::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); $reportTable->load(array('plugin' => $pluginName, 'default' => 1)); return $reportTable->id; @@ -1295,7 +1417,7 @@ public function getPluginReport($pluginName) if (!isset($reports[$pluginName])) { - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select(array('id as reportId', 'client')); $query->from($db->quoteName('#__tj_reports')); @@ -1357,7 +1479,7 @@ public function getPluginInstallationDetail($pluginName) if ($pluginName && !isset($clients[$pluginName])) { $clients[$pluginName] = ''; - $model = $this->getPluginModel($pluginName); + $model = $this->getPluginModel($pluginName); if ($model) { @@ -1375,7 +1497,7 @@ public function getPluginInstallationDetail($pluginName) */ public function addTjReportsPlugins() { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( $db->quoteName( @@ -1407,21 +1529,21 @@ public function addTjReportsPlugins() foreach ($plugins as $plugin) { - $pluginName = $plugin->name; - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); - $reportTable = JTable::getInstance('Tjreport', 'TjreportsTable'); - $details = $this->getPluginInstallationDetail($pluginName); + $pluginName = $plugin->name; + Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); + $reportTable = Table::getInstance('Tjreport', 'TjreportsTable'); + $details = $this->getPluginInstallationDetail($pluginName); $reportTable->load(array('plugin' => $pluginName, 'userid' => 0)); if (!$reportTable->id) { - $data = array(); - $data['title'] = $details['title']; + $data = array(); + $data['title'] = $details['title']; $data['plugin'] = $pluginName; - $data['alias'] = $pluginName; + $data['alias'] = $pluginName; $data['client'] = $details['client']; $data['parent'] = 0; - $data['default'] = 1; + $data['default'] = 1; $reportTable->save($data); $count++; diff --git a/tjreports/site/views/reports/tmpl/default.php b/tjreports/site/views/reports/tmpl/default.php index b63d2b3..284e142 100644 --- a/tjreports/site/views/reports/tmpl/default.php +++ b/tjreports/site/views/reports/tmpl/default.php @@ -10,11 +10,18 @@ // no direct access defined('_JEXEC') or die; -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); +use Joomla\CMS\Factory; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filter\OutputFilter; + +HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html'); $emailColmClass = 'td-sendemail'; -$app = JFactory::getApplication(); +$app = Factory::getApplication(); $headerLevel = $this->headerLevel; $this->listOrder = $this->state->get('list.ordering'); $this->listDirn = $this->state->get('list.direction'); @@ -32,25 +39,25 @@ } } -$input = JFactory::getApplication()->input; +$input = Factory::getApplication()->input; $displayFilters = $this->userFilters; $totalHeadRows = count($displayFilters); $reportId = $app->getUserStateFromRequest('reportId', 'reportId', ''); -$user = JFactory::getUser(); +$user = Factory::getUser(); $userAuthorisedExport = $user->authorise('core.export', 'com_tjreports.tjreport.' . $reportId); -if ($app->isSite()) +if ($app->isClient('site')) { - $siteUrl = JUri::root(); - $message = array(); - $message['success'] = JText::_("COM_TJREPORTS_EXPORT_FILE_SUCCESS"); - $message['error'] = JText::_("COM_TJREPORTS_EXPORT_FILE_ERROR"); - $message['inprogress'] = JText::_("COM_TJREPORTS_EXPORT_FILE_NOTICE"); - $message['text'] = JText::_("COM_TJREPORTS_CSV_EXPORT"); + $siteUrl = Uri::root(); + $message = array(); + $message['success'] = Text::_("COM_TJREPORTS_EXPORT_FILE_SUCCESS"); + $message['error'] = Text::_("COM_TJREPORTS_EXPORT_FILE_ERROR"); + $message['inprogress'] = Text::_("COM_TJREPORTS_EXPORT_FILE_NOTICE"); + $message['text'] = Text::_("COM_TJREPORTS_CSV_EXPORT"); - JHtml::script(JUri::base() . 'libraries/techjoomla/assets/js/tjexport.js'); - $document = JFactory::getDocument(); - $csv_url = 'index.php?option=' . $input->get('option') . '&view=' . $input->get('view') . '&format=csv'; + HTMLHelper::script(Uri::base() . 'libraries/techjoomla/assets/js/tjexport.js'); + $document = Factory::getDocument(); + $csv_url = 'index.php?option=' . $input->get('option') . '&view=' . $input->get('view') . '&format=csv'; $document->addScriptDeclaration("var csv_export_url='{$csv_url}';"); $document->addScriptDeclaration("var csv_export_success='{$message['success']}';"); @@ -75,14 +82,14 @@ isSite() && isset($this->reportData->title)) + if ($app->isClient('site') && isset($this->reportData->title)) { ?>

reportData->title, ENT_COMPAT, 'UTF-8'); ?>

-
+
@@ -115,7 +122,7 @@
isAdmin()) + if (!$app->isClient('administrator')) { echo $this->pagination->getPaginationLinks('joomla.pagination.links', array('showPagesLinks' => false,'showLimitStart' => false)); } @@ -136,7 +143,7 @@ { ?>
- savedQueries, "queryId", 'class="" size="1" onchange="tjrContentUI.report.getQueryResult(this.value);" name="filter_saveQuery"', "value", "text", $this->queryId); + savedQueries, "queryId", 'class="" size="1" onchange="tjrContentUI.report.getQueryResult(this.value);" name="filter_saveQuery"', "value", "text", $this->queryId); ?> queryId) @@ -153,7 +160,7 @@ isSite()) + if ($app->isClient('site')) { if ($this->isExport) { @@ -165,7 +172,7 @@ - +
@@ -183,7 +190,7 @@ ?>
@@ -192,7 +199,7 @@ ?>
- +
    showHideColumns as $colKey) @@ -210,13 +217,13 @@ if (in_array($colKey, $this->colToshow)) { - $checked = 'checked="checked"'; + $checked = 'checked="checked"'; } ?>
  • isAdmin() && $userAuthorisedExport && $user) + if (!$app->isClient('administrator') && $userAuthorisedExport && $user) { ?> srButton !== -1) { ?> - -
@@ -323,15 +330,15 @@ echo ''; - $colTitle = JText::sprintf($subTextTitle, $keyDetails[1]) ; + $colTitle = Text::sprintf($subTextTitle, $keyDetails[1]) ; if (in_array($subKey, $this->sortable)) { - echo $sortHtml = JHtml::_('grid.sort', $colTitle, $subKey, $this->listDirn, $this->listOrder); + echo $sortHtml = HTMLHelper::_('grid.sort', $colTitle, $subKey, $this->listDirn, $this->listOrder); } else { - echo '
' . JText::_($colTitle) . '
'; + echo '
' . Text::_($colTitle) . '
'; } echo ''; @@ -340,7 +347,7 @@ else { $colKey = $detail; - $colKeyClass = JFilterOutput::stringURLSafe($colKey); + $colKeyClass = OutputFilter::stringURLSafe($colKey); if (!isset($this->columns[$colKey]['title'])) { $colTitle = 'PLG_TJREPORTS_' . strtoupper($this->pluginName . '_' . $colKey . '_TITLE'); @@ -359,11 +366,11 @@ if (in_array($colKey, $this->sortable)) { - echo $sortHtml = JHtml::_('grid.sort', $colTitle, $colKey, $this->listDirn, $this->listOrder); + echo $sortHtml = HTMLHelper::_('grid.sort', $colTitle, $colKey, $this->listDirn, $this->listOrder); } else { - echo '
' . JText::_($colTitle) . '
'; + echo '
' . Text::_($colTitle) . '
'; } if ($hasFilter) { @@ -434,7 +441,8 @@ else { $isSendEmailClass = ($key == $this->emailColumn) ? $emailColmClass : ''; - echo "{$item[$key]}"; + $value = isset($item[$key]) ? $item[$key] : ''; + echo "{$value}"; } } @@ -463,7 +471,7 @@
isAdmin()) + if (!$app->isClient('administrator')) { echo $this->pagination->getPaginationLinks('joomla.pagination.links', array('showLimitBox' => false)); } @@ -483,7 +491,7 @@ - +
diff --git a/tjreports/site/views/reports/view.base.php b/tjreports/site/views/reports/view.base.php index d8809a9..a355165 100644 --- a/tjreports/site/views/reports/view.base.php +++ b/tjreports/site/views/reports/view.base.php @@ -13,6 +13,9 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; + jimport('joomla.application.component.view'); JLoader::import('components.com_tjreports.helpers.tjreports', JPATH_ADMINISTRATOR); JLoader::import('components.com_tjreports.models.tjreports', JPATH_SITE); @@ -38,12 +41,28 @@ class ReportsViewBase extends JViewLegacy protected $reportData; - protected $savedQueries = array(); + protected $headerLevel; protected $reportId = 0; protected $queryId = 0; + protected $savedQueries = array(); + + protected $defaultColToHide; + + protected $columns; + + protected $showhideCols; + + protected $filterParamColToshow; + + protected $defaultColToShow; + + protected $sortableColumns; + + protected $showSearchResetButton; + /** * Execute and display a template script. * @@ -53,15 +72,14 @@ class ReportsViewBase extends JViewLegacy */ public function processData($type = 'html') { - $app = JFactory::getApplication(); - $canDo = TjreportsHelper::getActions(); - $input = JFactory::getApplication()->input; - $user = JFactory::getUser(); + $canDo = TjreportsHelper::getActions(); + $input = Factory::getApplication()->input; + $user = Factory::getUser(); $this->reportId = $input->get('reportId', 0, 'INT'); - $this->model = $this->getModel('reports'); + $this->model = $this->getModel('reports'); - $reports = $this->model->getenableReportPlugins(); + $reports = $this->model->getenableReportPlugins(); $this->reportId = $this->reportId ? $this->reportId : (isset($reports['0']['reportId']) ? $reports['0']['reportId'] : ''); $this->reportData = $this->model->getReportNameById($this->reportId); @@ -81,7 +99,11 @@ public function processData($type = 'html') } $this->model = $this->getModel($this->pluginName); - $this->setModel($this->model, true); + + if ($this->model) + { + $this->setModel($this->model, true); + } if ($this->reportId) { @@ -131,8 +153,8 @@ public function processData($type = 'html') if (!empty($savedQueries)) { - $qOptions = array(); - $qOptions[] = JHTML::_('select.option', '', JText::_('COM_TJREPORTS_SELONE_QUERY')); + $qOptions = array(); + $qOptions[] = JHTML::_('select.option', '', JText::_('COM_TJREPORTS_SELONE_QUERY')); foreach ($savedQueries as $savedQuery) { @@ -154,25 +176,46 @@ public function processData($type = 'html') } $this->model->loadLanguage($this->pluginName); - $this->state = $this->get('State'); - $this->items = $this->model->getItems(); - $this->pagination = $this->get('pagination'); - - $this->headerLevel = $this->model->headerLevel; - $this->columns = $this->model->columns; + $this->state = $this->get('State'); + $this->items = $this->model->getItems(); + $this->pagination = $this->get('pagination'); + $this->headerLevel = $this->model->headerLevel; + + // Array_key - defaultColToHide column are present then get the key as value. + $defaultColToHide = (array) $this->model->getState('defaultColToHide'); + $this->defaultColToHide = array_keys($defaultColToHide); + $this->columns = $this->model->columns; + + /* Array_merge - here colToshow means get all true value array so want to mearg defaultColToHide column and then using + * array_intersect - only remove those column which is force fully added in load param in showhideCols config + */ $this->showHideColumns = $this->model->showhideCols; - $this->sortable = $this->model->sortableColumns; - $this->emailColumn = $this->model->getState('emailColumn'); - $this->srButton = $this->model->showSearchResetButton; - $this->colToshow = $this->model->getState('colToshow'); - $this->filterValues = $this->model->getState('filters'); + /* To get the columns from loadparams*/ + $this->defaultColToshow = $this->model->filterParamColToshow; + + /* Check the columns in loadparams are available or not & show plugin level columns & custom field columns + * in case if load params are not available*/ + if (empty($this->defaultColToshow)) + { + $this->defaultColToshow = $this->model->defaultColToShow; + } + + if (!empty($this->defaultColToHide)) + { + $this->showHideColumns = array_intersect($this->model->showhideCols, array_merge($this->defaultColToshow, $this->defaultColToHide)); + } - $this->userFilters = $this->model->displayFilters(); - $this->messages = $this->model->getTJRMessages(); + $this->sortable = $this->model->sortableColumns; + $this->emailColumn = $this->model->getState('emailColumn'); + $this->srButton = $this->model->showSearchResetButton; + $this->colToshow = $this->model->getState('colToshow'); + $this->filterValues = $this->model->getState('filters'); + $this->userFilters = $this->model->displayFilters(); + $this->messages = $this->model->getTJRMessages(); $this->enableReportPlugins = $this->model->getenableReportPlugins($this->client); - $this->isExport = $user->authorise('core.export', 'com_tjreports.tjreport.' . $this->reportId); + $this->isExport = $user->authorise('core.export', 'com_tjreports.tjreport.' . $this->reportId); return true; } @@ -184,14 +227,14 @@ public function processData($type = 'html') * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * - * @return JModelLegacy|boolean Model object on success; otherwise false on failure. + * @return BaseDatabaseModel|boolean Model object on success; otherwise false on failure. * * @since 3.0 */ public function getModel($name = '', $prefix = '', $config = array()) { - JModelLegacy::addIncludePath(JPATH_SITE . '/plugins/tjreports/' . $name); + BaseDatabaseModel::addIncludePath(JPATH_SITE . '/plugins/tjreports/' . $name); - return JModelLegacy::getInstance($name, 'TjreportsModel', $config); + return BaseDatabaseModel::getInstance($name, 'TjreportsModel', $config); } } diff --git a/tjreports/tjreports.xml b/tjreports/tjreports.xml index 3ddde42..ae12368 100644 --- a/tjreports/tjreports.xml +++ b/tjreports/tjreports.xml @@ -6,8 +6,8 @@ https://techjoomla.com Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 12th Jul 2019 - 1.1.1 + 11th Nov 2019 + 1.1.4 This component is used to access all the report at single place.