diff --git a/build/bump.php b/build/bump.php new file mode 100644 index 0000000..e2ae8e5 --- /dev/null +++ b/build/bump.php @@ -0,0 +1,403 @@ + -c + * + * Examples: + * - php build/bump.php -v 3.6.0-dev + * - php build/bump.php -v 3.6.0-beta1 + * - php build/bump.php -v 3.6.0-beta1-dev + * - php build/bump.php -v 3.6.0-beta2 + * - php build/bump.php -v 3.6.0-rc1 + * - php build/bump.php -v 3.6.0 + * - php build/bump.php -v 3.6.0 -c Unicorn + * - php build/bump.php -v 3.6.0 -c "Custom Codename" + * - /usr/bin/php /path/to/joomla-cms/build/bump.php -v 3.7.0 + * + * @package Techjoomla.Build + * + * @author Techjoomla + * @copyright Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +/** + * Display the use of command + * + * @param string $command The command name + * + * @return void + */ +function usage($command) +{ + echo PHP_EOL; + echo 'Usage: php ' . $command . ' [options]' . PHP_EOL; + echo PHP_TAB . '[options]:' . PHP_EOL; + echo PHP_TAB . PHP_TAB . '-v :' . PHP_TAB . 'Version (ex: 3.6.0-dev, 3.6.0-beta1, 3.6.0-beta1-dev, 3.6.0-rc1, 3.6.0)' . PHP_EOL; + echo PHP_TAB . PHP_TAB . '-c :' . PHP_TAB . 'Codename [optional] (ex: Unicorn)' . PHP_EOL; + echo PHP_EOL; +} + +// Constants. +const PHP_TAB = "\t"; + +// File paths. THe version file path (If applicable) +$versionFile = 'PATH_OF_VERSION_FILE'; + +// This file will vary from component to component +$coreXmlFiles = array( + '/tjreports/tjreports.xml', + '/plugins/actionlog/tjreports/tjreports.xml', + '/plugins/privacy/tjreports/tjreports.xml' +); + +$antJobFile = '/build.xml'; + +$readMeFiles = array( + '/README.md', + '/README.txt', +); + +// Change copyright date exclusions. Some systems may try to scan the .git directory, exclude it. +$directoryLoopExcludeDirectories = array( + '/.git', + '/.gitlab', + '/scripts/ansible-deploy', + '/scripts/gulp', + '/tests/codeception', +); + +$directoryLoopExcludeFiles = array( + '.gitignore', + '/build/bump.php', + '/scripts/phing/build.xml', +); + +// Check arguments (exit if incorrect cli arguments). +$opts = getopt("v:c:"); + +if (empty($opts['v'])) +{ + usage($argv[0]); + die(); +} + +// Check version string (exit if not correct). +$versionParts = explode('-', $opts['v']); + +if (!preg_match('#^[0-9]+\.[0-9]+\.[0-9]+$#', $versionParts[0])) +{ + usage($argv[0]); + die(); +} + +if (isset($versionParts[1]) && !preg_match('#(dev|alpha|beta|rc)[0-9]*#', $versionParts[1])) +{ + usage($argv[0]); + die(); +} + +if (isset($versionParts[2]) && $versionParts[2] !== 'dev') +{ + usage($argv[0]); + die(); +} + +// Make sure we use the correct language and timezone. +setlocale(LC_ALL, 'en_GB'); +date_default_timezone_set('Asia/Kolkata'); + +// Make sure file and folder permissions are set correctly. +umask(022); + +// Get version dev status. +$dev_status = 'Stable'; + +if (!isset($versionParts[1])) +{ + $versionParts[1] = ''; +} +else +{ + if (preg_match('#^dev#', $versionParts[1])) + { + $dev_status = 'Development'; + } + elseif (preg_match('#^alpha#', $versionParts[1])) + { + $dev_status = 'Alpha'; + } + elseif (preg_match('#^beta#', $versionParts[1])) + { + $dev_status = 'Beta'; + } + elseif (preg_match('#^rc#', $versionParts[1])) + { + $dev_status = 'Release Candidate'; + } +} + +if (!isset($versionParts[2])) +{ + $versionParts[2] = ''; +} +else +{ + $dev_status = 'Development'; +} + +// Set version properties. +$versionSubParts = explode('.', $versionParts[0]); + +$version = array( + 'main' => $versionSubParts[0] . '.' . $versionSubParts[1], + 'major' => $versionSubParts[0], + 'minor' => $versionSubParts[1], + 'patch' => $versionSubParts[2], + 'extra' => (!empty($versionParts[1]) ? $versionParts[1] : '') . + (!empty($versionParts[2]) ? (!empty($versionParts[1]) ? '-' : '') . $versionParts[2] : ''), + 'release' => $versionSubParts[0] . '.' . $versionSubParts[1] . '.' . $versionSubParts[2], + 'dev_devel' => $versionSubParts[2] . (!empty($versionParts[1]) ? '-' . + $versionParts[1] : '') . (!empty($versionParts[2]) ? '-' . $versionParts[2] : ''), + 'dev_status' => $dev_status, + 'build' => '', + 'reldate' => date('j-F-Y'), + 'reltime' => date('H:i'), + 'reltz' => 'GMT', + 'credate' => date('jS M Y') + ); + +// Version Codename. +if (!empty($opts['c'])) +{ + $version['codename'] = trim($opts['c']); +} + +// Prints version information. +echo PHP_EOL; +echo 'Version data:' . PHP_EOL; +echo '- Main:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . PHP_EOL; +echo '- Release:' . PHP_TAB . PHP_TAB . $version['release'] . PHP_EOL; +echo '- Full:' . PHP_TAB . PHP_TAB . PHP_TAB . $version['main'] . '.' . $version['dev_devel'] . PHP_EOL; +echo '- Build:' . PHP_TAB . PHP_TAB . $version['build'] . PHP_EOL; +echo '- Dev Level:' . PHP_TAB . PHP_TAB . $version['dev_devel'] . PHP_EOL; +echo '- Dev Status:' . PHP_TAB . PHP_TAB . $version['dev_status'] . PHP_EOL; +echo '- Release date:' . PHP_TAB . PHP_TAB . $version['reldate'] . PHP_EOL; +echo '- Release time:' . PHP_TAB . PHP_TAB . $version['reltime'] . PHP_EOL; +echo '- Release timezone:' . PHP_TAB . $version['reltz'] . PHP_EOL; +echo '- Creation date:' . PHP_TAB . $version['credate'] . PHP_EOL; + +if (!empty($version['codename'])) +{ + echo '- Codename:' . PHP_TAB . PHP_TAB . $version['codename'] . PHP_EOL; +} + +echo PHP_EOL; + +$rootPath = dirname(__DIR__); + +// Updates the version in version class. +if (file_exists($rootPath . $versionFile)) +{ + $fileContents = file_get_contents($rootPath . $versionFile); + $fileContents = preg_replace("#MAJOR_VERSION\s*=\s*[^;]*#", "MAJOR_VERSION = " . $version['major'], $fileContents); + $fileContents = preg_replace("#MINOR_VERSION\s*=\s*[^;]*#", "MINOR_VERSION = " . $version['minor'], $fileContents); + $fileContents = preg_replace("#PATCH_VERSION\s*=\s*[^;]*#", "PATCH_VERSION = " . $version['patch'], $fileContents); + $fileContents = preg_replace("#EXTRA_VERSION\s*=\s*'[^\']*'#", "EXTRA_VERSION = '" . $version['extra'] . "'", $fileContents); + $fileContents = preg_replace("#RELEASE\s*=\s*'[^\']*'#", "RELEASE = '" . $version['main'] . "'", $fileContents); + $fileContents = preg_replace("#DEV_LEVEL\s*=\s*'[^\']*'#", "DEV_LEVEL = '" . $version['dev_devel'] . "'", $fileContents); + $fileContents = preg_replace("#DEV_STATUS\s*=\s*'[^\']*'#", "DEV_STATUS = '" . $version['dev_status'] . "'", $fileContents); + $fileContents = preg_replace("#BUILD\s*=\s*'[^\']*'#", "BUILD = '" . $version['build'] . "'", $fileContents); + $fileContents = preg_replace("#RELDATE\s*=\s*'[^\']*'#", "RELDATE = '" . $version['reldate'] . "'", $fileContents); + $fileContents = preg_replace("#RELTIME\s*=\s*'[^\']*'#", "RELTIME = '" . $version['reltime'] . "'", $fileContents); + $fileContents = preg_replace("#RELTZ\s*=\s*'[^\']*'#", "RELTZ = '" . $version['reltz'] . "'", $fileContents); + + if (!empty($version['codename'])) + { + $fileContents = preg_replace("#CODENAME\s*=\s*'[^\']*'#", "CODENAME = '" . $version['codename'] . "'", $fileContents); + } + + file_put_contents($rootPath . $versionFile, $fileContents); +} + +// + TJ - chanages +// Prints TJ specific information. +$author = 'Techjoomla'; +$authorEmail = 'extensions@techjoomla.com'; +$authorUrl = 'https://techjoomla.com'; +$license = 'http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL'; +$copyright = 'Copyright (C) 2016 - 2018 Techjoomla. All rights reserved.'; + +echo PHP_EOL; + +echo 'Techjoomla copyright info to be added in xml:' . PHP_EOL; +echo '- author:' . PHP_TAB . PHP_TAB . PHP_TAB . $author . PHP_EOL; +echo '- authorEmail:' . PHP_TAB . PHP_TAB . PHP_TAB . $authorEmail . PHP_EOL; +echo '- authorUrl:' . PHP_TAB . PHP_TAB . PHP_TAB . $authorUrl . PHP_EOL; +echo '- license:' . PHP_TAB . PHP_TAB . PHP_TAB . $license . PHP_EOL; +echo '- copyright:' . PHP_TAB . PHP_TAB . PHP_TAB . $copyright . PHP_EOL; + +echo PHP_EOL; + +// + TJ - chanages - end + +// Updates the version and creation date in core xml files. +foreach ($coreXmlFiles as $coreXmlFile) +{ + if (file_exists($rootPath . $coreXmlFile)) + { + // @echo 'Processed xml file: ' .$rootPath . $coreXmlFile . PHP_EOL; + + $fileContents = file_get_contents($rootPath . $coreXmlFile); + + $fileContents = preg_replace('#[^<]*#', '' . $version['main'] . + '.' . $version['dev_devel'] . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $version['credate'] . '', $fileContents + ); + + // + TJ - chanages + $fileContents = preg_replace('#[^<]*#', '' . + $author . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $authorEmail . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $authorUrl . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $license . '', $fileContents + ); + + $fileContents = preg_replace('#[^<]*#', '' . + $copyright . '', $fileContents + ); + + // + TJ - chanages - end + + file_put_contents($rootPath . $coreXmlFile, $fileContents); + } +} + +// Updates the version for the `phpdoc` task in the Ant job file. +if (file_exists($rootPath . $antJobFile)) +{ + $fileContents = file_get_contents($rootPath . $antJobFile); + $fileContents = preg_replace('##', '', $fileContents + ); + file_put_contents($rootPath . $antJobFile, $fileContents); +} + +// Updates the version in readme files. +foreach ($readMeFiles as $readMeFile) +{ + if (file_exists($rootPath . $readMeFile)) + { + $fileContents = file_get_contents($rootPath . $readMeFile); + $fileContents = preg_replace('#Joomla! [0-9]+\.[0-9]+ (|\[)version#', 'Joomla! ' . $version['main'] . ' $1version', $fileContents); + $fileContents = preg_replace('#Joomla_[0-9]+\.[0-9]+_version#', 'Joomla_' . $version['main'] . '_version', $fileContents); + file_put_contents($rootPath . $readMeFile, $fileContents); + } +} + +// Updates the copyright date in core files. +$changedFilesCopyrightDate = 0; +$changedFilesSinceVersion = 0; +$year = date('Y'); +$directory = new \RecursiveDirectoryIterator($rootPath); +$iterator = new \RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST); + +foreach ($iterator as $file) +{ + if ($file->isFile()) + { + $filePath = $file->getPathname(); + $relativePath = str_replace($rootPath, '', $filePath); + + // Exclude certain extensions. + if (preg_match('#\.(png|jpeg|jpg|gif|bmp|ico|webp|svg|woff|woff2|ttf|eot)$#', $filePath)) + { + continue; + } + + // Exclude certain files. + if (in_array($relativePath, $directoryLoopExcludeFiles)) + { + continue; + } + + // Exclude certain directories. + $continue = true; + + foreach ($directoryLoopExcludeDirectories as $excludeDirectory) + { + if (preg_match('#^' . preg_quote($excludeDirectory) . '#', $relativePath)) + { + $continue = false; + break; + } + } + + if ($continue) + { + $changeSinceVersion = false; + $changeCopyrightDate = false; + + // Load the file. + $fileContents = file_get_contents($filePath); + + // Check if need to change the copyright date. + if (preg_match('#2016\s+-\s+[0-9]{4}\s+Techjoomla.\s+All\s+rights#', $fileContents) + && !preg_match('#2016\s+-\s+' . $year . '\s+Techjoomla.\s+All\s+rights#', $fileContents)) + { + $changeCopyrightDate = true; + $fileContents = preg_replace('#2016\s+-\s+[0-9]{4}\s+Techjoomla.\s+All\s+rights#', '2016 - ' . + $year . ' Techjoomla. All rights', $fileContents + ); + $changedFilesCopyrightDate++; + } + + // Check if need to change the since version. + if ($relativePath !== '/build/bump.php' && preg_match('#__DEPLOY_VERSION__#', $fileContents)) + { + $changeSinceVersion = true; + $fileContents = preg_replace('#__DEPLOY_VERSION__#', $version['release'], $fileContents); + $changedFilesSinceVersion++; + } + + // Save the file. + if ($changeCopyrightDate || $changeSinceVersion) + { + file_put_contents($filePath, $fileContents); + } + + // @echo 'Processed file: ' . $filePath . PHP_EOL; + } + } +} + +if ($changedFilesCopyrightDate > 0 || $changedFilesSinceVersion > 0) +{ + if ($changedFilesCopyrightDate > 0) + { + echo '- Copyright Date changed in ' . $changedFilesCopyrightDate . ' files.' . PHP_EOL; + } + + if ($changedFilesSinceVersion > 0) + { + echo '- Since Version changed in ' . $changedFilesSinceVersion . ' files.' . PHP_EOL; + } + + echo PHP_EOL; +} + +echo 'Version bump complete!' . PHP_EOL; diff --git a/plugins/actionlog/tjreports/index.html b/plugins/actionlog/tjreports/index.html new file mode 100644 index 0000000..2efb97f --- /dev/null +++ b/plugins/actionlog/tjreports/index.html @@ -0,0 +1 @@ + diff --git a/plugins/actionlog/tjreports/language/en-GB/en-GB.plg_actionlog_tjreports.ini b/plugins/actionlog/tjreports/language/en-GB/en-GB.plg_actionlog_tjreports.ini new file mode 100644 index 0000000..a2c095e --- /dev/null +++ b/plugins/actionlog/tjreports/language/en-GB/en-GB.plg_actionlog_tjreports.ini @@ -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 {username} added new report {title} using plugin {plugin} for {client}" +PLG_ACTIONLOG_TJREPORTS_REPORT_ADDED="User {username} added new report {title} using plugin {plugin}" +PLG_ACTIONLOG_TJREPORTS_REPORT_UPDATED="User {username} updated the report {title}" +PLG_ACTIONLOG_TJREPORTS_REPORT_DELETED="User {username} deleted the report \"{title}\" " +PLG_ACTIONLOG_TJREPORTS_REPORT_DELETED_WITH_CLIENT="User {username} 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'" diff --git a/plugins/actionlog/tjreports/language/en-GB/en-GB.plg_actionlog_tjreports.sys.ini b/plugins/actionlog/tjreports/language/en-GB/en-GB.plg_actionlog_tjreports.sys.ini new file mode 100644 index 0000000..f36473d --- /dev/null +++ b/plugins/actionlog/tjreports/language/en-GB/en-GB.plg_actionlog_tjreports.sys.ini @@ -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." diff --git a/plugins/actionlog/tjreports/tjreports.php b/plugins/actionlog/tjreports/tjreports.php new file mode 100644 index 0000000..c47aa13 --- /dev/null +++ b/plugins/actionlog/tjreports/tjreports.php @@ -0,0 +1,184 @@ + + * @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); + } +} diff --git a/plugins/actionlog/tjreports/tjreports.xml b/plugins/actionlog/tjreports/tjreports.xml new file mode 100644 index 0000000..d83aebf --- /dev/null +++ b/plugins/actionlog/tjreports/tjreports.xml @@ -0,0 +1,34 @@ + + + plg_actionlog_tjreports + Techjoomla + 16th Nov 2018 + Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + extensions@techjoomla.com + https://techjoomla.com + 1.0.3 + PLG_ACTIONLOG_TJREPORTS_XML_DESCRIPTION + + tjreports.php + index.html + + + en-GB/en-GB.plg_actionlog_tjreports.ini + en-GB/en-GB.plg_actionlog_tjreports.sys.ini + + + +
+ + + + + + + + +
+
+
+
diff --git a/plugins/privacy/tjreports/index.html b/plugins/privacy/tjreports/index.html new file mode 100644 index 0000000..2efb97f --- /dev/null +++ b/plugins/privacy/tjreports/index.html @@ -0,0 +1 @@ + diff --git a/plugins/privacy/tjreports/language/en-GB/en-GB.plg_privacy_tjreports.ini b/plugins/privacy/tjreports/language/en-GB/en-GB.plg_privacy_tjreports.ini new file mode 100644 index 0000000..61e12fb --- /dev/null +++ b/plugins/privacy/tjreports/language/en-GB/en-GB.plg_privacy_tjreports.ini @@ -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)" diff --git a/plugins/privacy/tjreports/language/en-GB/en-GB.plg_privacy_tjreports.sys.ini b/plugins/privacy/tjreports/language/en-GB/en-GB.plg_privacy_tjreports.sys.ini new file mode 100644 index 0000000..0c106e7 --- /dev/null +++ b/plugins/privacy/tjreports/language/en-GB/en-GB.plg_privacy_tjreports.sys.ini @@ -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" diff --git a/plugins/privacy/tjreports/tjreports.php b/plugins/privacy/tjreports/tjreports.php new file mode 100644 index 0000000..b2ba275 --- /dev/null +++ b/plugins/privacy/tjreports/tjreports.php @@ -0,0 +1,163 @@ + + * @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(); + +JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php'); +JLoader::register('PrivacyRemovalStatus', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/removal/status.php'); + +use Joomla\CMS\User\User; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; + +/** + * TJReports Privacy Plugin. + * + * @since 1.0.3 + */ +class PlgPrivacyTjreports extends PrivacyPlugin +{ + /** + * Load the language file on instantiation. + * + * @var boolean + * + * @since 1.0.3 + */ + protected $autoloadLanguage = true; + + /** + * Database object + * + * @var JDatabaseDriver + * @since 1.0.3 + */ + protected $db; + + /** + * Reports the privacy related capabilities for this plugin to site administrators. + * + * @return array + * + * @since 1.0.3 + */ + public function onPrivacyCollectAdminCapabilities() + { + $this->loadLanguage(); + + return array( + Text::_('PLG_PRIVACY_TJREPORTS') => array( + Text::_('PLG_PRIVACY_TJREPORTS_PRIVACY_CAPABILITY_USER_REPORTS_DETAIL') + ) + ); + } + + /** + * Processes an export request for TJReports user data + * + * This event will collect data for the following tables: + * + * - #__tj_reports + * + * @param PrivacyTableRequest $request The request record being processed + * @param JUser $user The user account associated with this request if available + * + * @return PrivacyExportDomain[] + * + * @since 1.0.3 + */ + public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user = null) + { + if (!$user) + { + return array(); + } + + /** @var JTableUser $user */ + $userTable = User::getTable(); + $userTable->load($user->id); + + $domains = array(); + $domains[] = $this->createTJReportsUserReports($userTable); + + return $domains; + } + + /** + * Create the domain for the TJReports user reports + * + * @param JTableUser $user The JTableUser object to process + * + * @return PrivacyExportDomain + * + * @since 1.0.3 + */ + private function createTJReportsUserReports(JTableUser $user) + { + $domain = $this->createDomain('User Reports', 'Reports of user in TJReports'); + + $query = $this->db->getQuery(true) + ->select($this->db->quoteName(array('id', 'title', 'plugin', 'userid', 'client', 'default'))) + ->from($this->db->quoteName('#__tj_reports')) + ->where($this->db->quoteName('userid') . '=' . $user->id); + + $roles = $this->db->setQuery($query)->loadAssocList(); + + if (!empty($roles)) + { + foreach ($roles as $role) + { + $domain->addItem($this->createItemFromArray($role, $role['id'])); + } + } + + return $domain; + } + + /** + * Removes the data associated with a remove information request + * + * This event will pseudoanonymise the user account + * + * @param PrivacyTableRequest $request The request record being processed + * @param JUser $user The user account associated with this request if available + * + * @return void + * + * @since 1.0.3 + */ + public function onPrivacyRemoveData(PrivacyTableRequest $request, JUser $user = null) + { + // This plugin only processes data for registered user accounts + if (!$user) + { + return; + } + + // If there was an error loading the user do nothing here + if ($user->guest) + { + return; + } + + $db = $this->db; + + // 1. Delete data from #__tj_reports + $query = $db->getQuery(true) + ->delete($db->quoteName('#__tj_reports')) + ->where($db->quoteName('userid') . '=' . $user->id) + ->where($db->quoteName('default') . '=' . 0); + + $db->setQuery($query); + $db->execute(); + } +} diff --git a/plugins/privacy/tjreports/tjreports.xml b/plugins/privacy/tjreports/tjreports.xml new file mode 100644 index 0000000..fef7d47 --- /dev/null +++ b/plugins/privacy/tjreports/tjreports.xml @@ -0,0 +1,25 @@ + + + plg_privacy_tjreports + 1.0.3 + 16th Nov 2018 + Techjoomla + extensions@techjoomla.com + https://techjoomla.com + Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + PLG_PRIVACY_TJREPORTS_XML_DESCRIPTION + + tjreports.php + index.html + + + en-GB/en-GB.plg_privacy_tjreports.ini + en-GB/en-GB.plg_privacy_tjreports.sys.ini + + + +
+ + + diff --git a/tjreports/administrator/models/tjreport.php b/tjreports/administrator/models/tjreport.php index 0dd7a00..fc114a2 100644 --- a/tjreports/administrator/models/tjreport.php +++ b/tjreports/administrator/models/tjreport.php @@ -15,6 +15,21 @@ */ class TjreportsModelTjreport extends JModelAdmin { + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * + * @since 3.2 + */ + public function __construct($config = array()) + { + $config['event_after_save'] = 'tjReportsOnAfterReportSave'; + $config['event_after_delete'] = 'tjReportsOnAfterReportDelete'; + + parent::__construct($config); + } + /** * Method to get a table object, load it if necessary. * diff --git a/tjreports/script.tjreports.php b/tjreports/script.tjreports.php new file mode 100755 index 0000000..9eb1e58 --- /dev/null +++ b/tjreports/script.tjreports.php @@ -0,0 +1,230 @@ + + * @package TJReports + * @copyright Copyright (c)2010-2011 Nicholas K. Dionysopoulos + * @license GNU General Public License version 3, or later + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * @version SVN: + * @package TJReports + * @author Techjoomla + * @copyright Copyright (c) 2009-2018 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later. + */ + +defined('_JEXEC') or die( ';)' ); +jimport('joomla.installer.installer'); +jimport('joomla.filesystem.file'); +jimport('joomla.application.component.helper'); + + +/** + * Script file of TJReports component + * + * @since 1.0.0 + **/ +class Com_TjreportsInstallerScript +{ +/** @var array The list of extra modules and plugins to install */ + private $queue = array( + + // plugins => { (folder) => { (element) => (published) }* }* + 'plugins' => array( + 'actionlog' => array( + 'tjreports' => 1 + ), + 'privacy' => array( + 'tjreports' => 1 + ) + ) + ); + + /** + * This method is called after a component is installed. + * + * @param \stdClass $parent Parent object calling this method. + * + * @return void + */ + public function install($parent) + { + } + + /** + * This method is called after a component is uninstalled. + * + * @param \stdClass $parent Parent object calling this method. + * + * @return void + */ + public function uninstall($parent) + { + jimport('joomla.installer.installer'); + + $db = JFactory::getDBO(); + + $status = new JObject; + $status->plugins = array(); + + $src = $parent->getParent()->getPath('source'); + + // Plugins uninstallation + if (count($this->queue['plugins'])) + { + foreach ($this->queue['plugins'] as $folder => $plugins) + { + if (count($plugins)) + { + foreach ($plugins as $plugin => $published) + { + $sql = $db->getQuery(true)->select($db->qn('extension_id')) + ->from($db->qn('#__extensions')) + ->where($db->qn('type') . ' = ' . $db->q('plugin')) + ->where($db->qn('element') . ' = ' . $db->q($plugin)) + ->where($db->qn('folder') . ' = ' . $db->q($folder)); + $db->setQuery($sql); + + $id = $db->loadResult(); + + if ($id) + { + $installer = new JInstaller; + $result = $installer->uninstall('plugin', $id); + $status->plugins[] = array( + 'name' => 'plg_' . $plugin, + 'group' => $folder, + 'result' => $result + ); + } + } + } + } + } + + return $status; + } + + /** + * This method is called after a component is updated. + * + * @param \stdClass $parent Parent object calling object. + * + * @return void + */ + public function update($parent) + { + } + + /** + * Runs just before any installation action is preformed on the component. + * Verifications and pre-requisites should run in this function. + * + * @param string $type Type of PreFlight action. Possible values are: + * - * install + * - * update + * - * discover_install + * @param \stdClass $parent Parent object calling object. + * + * @return void + */ + public function preflight($type, $parent) + { + } + + /** + * Runs right after any installation action is preformed on the component. + * + * @param string $type Type of PostFlight action. Possible values are: + * - * install + * - * update + * - * discover_install + * @param \stdClass $parent Parent object calling object. + * + * @return void + */ + public function postflight($type, $parent) + { + $src = $parent->getParent()->getPath('source'); + + $db = JFactory::getDbo(); + + $status = new JObject; + $status->plugins = array(); + + // Plugins installation + if (count($this->queue['plugins'])) + { + foreach ($this->queue['plugins'] as $folder => $plugins) + { + if (count($plugins)) + { + foreach ($plugins as $plugin => $published) + { + $path = "$src/plugins/$folder/$plugin"; + + if (!is_dir($path)) + { + $path = "$src/plugins/$folder/plg_$plugin"; + } + + if (!is_dir($path)) + { + $path = "$src/plugins/$plugin"; + } + + if (!is_dir($path)) + { + $path = "$src/plugins/plg_$plugin"; + } + + if (!is_dir($path)) + { + continue; + } + + // Was the plugin already installed? + $query = $db->getQuery(true) + ->select('COUNT(*)') + ->from($db->qn('#__extensions')) + ->where($db->qn('element') . ' = ' . $db->q($plugin)) + ->where($db->qn('folder') . ' = ' . $db->q($folder)); + $db->setQuery($query); + $count = $db->loadResult(); + + $installer = new JInstaller; + $result = $installer->install($path); + + $status->plugins[] = array('name' => 'plg_' . $plugin, 'group' => $folder, 'result' => $result); + + if ($published && !$count) + { + $query = $db->getQuery(true) + ->update($db->qn('#__extensions')) + ->set($db->qn('enabled') . ' = ' . $db->q('1')) + ->where($db->qn('element') . ' = ' . $db->q($plugin)) + ->where($db->qn('folder') . ' = ' . $db->q($folder)); + $db->setQuery($query); + $db->execute(); + } + } + } + } + } + } +} diff --git a/tjreports/site/controllers/reports.json.php b/tjreports/site/controllers/reports.json.php index d2da627..2dfa861 100644 --- a/tjreports/site/controllers/reports.json.php +++ b/tjreports/site/controllers/reports.json.php @@ -85,6 +85,14 @@ public function saveQuery() } else { + $id = $db->insertid(); + $insert_object->id = $id; + + $dispatcher = JEventDispatcher::getInstance(); + $extension = JFactory::getApplication()->input->get('option'); + JPluginHelper::importPlugin('tjreports'); + $dispatcher->trigger('tjReportsOnAfterReportSave', array($extension, $insert_object, true)); + $app->enqueueMessage('Data save successfully.'); echo new JResponseJson('Done'); } diff --git a/tjreports/site/models/report.php b/tjreports/site/models/report.php index 846aafe..76fb57e 100644 --- a/tjreports/site/models/report.php +++ b/tjreports/site/models/report.php @@ -33,16 +33,16 @@ public function getTable($type = 'Tjreport', $prefix = 'TjreportsTable', $config return JTable::getInstance($type, $prefix, $config); } -/** - * 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 mixed A JForm object on success, false on failure - * - * @since 1.6 - */ + /** + * 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 mixed A JForm object on success, false on failure + * + * @since 1.6 + */ public function getForm($data = array(), $loadData = true) { // Get the form. @@ -101,11 +101,17 @@ public function delete(&$pks) JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjreports/tables'); $tjrTable = JTable::getInstance('Tjreport', 'TjreportsTable', array('dbo', $db)); $tjrTable->load(array('id' => &$pks)); + $data = $tjrTable; if ($tjrTable->userid == JFactory::getUser()->id) { $tjrTable->delete($pks); + $dispatcher = JEventDispatcher::getInstance(); + $extension = JFactory::getApplication()->input->get('option'); + JPluginHelper::importPlugin('tjreports'); + $dispatcher->trigger('tjReportsOnAfterReportDelete', array($extension, $data)); + return true; } diff --git a/tjreports/tjreports.xml b/tjreports/tjreports.xml index 3adff48..a4dca05 100644 --- a/tjreports/tjreports.xml +++ b/tjreports/tjreports.xml @@ -1,85 +1,81 @@ - com_tjreports - 2016-08-30 - 2016 Parth Lawate - GNU General Public License version 2 or later; see LICENSE.txt - Parth Lawate - contact@techjoomla.com - http://techjoomla.com - 1.0.2 - This component is used to access all the report at single place. - - - - sql/install.mysql.utf8.sql - - - + com_tjreports + Techjoomla + extensions@techjoomla.com + https://techjoomla.com + Copyright (C) 2016 - 2018 Techjoomla. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + 16th Nov 2018 + 1.0.3 + This component is used to access all the report at single place. + + + + sql/install.mysql.utf8.sql + + + sql/updates/mysql - - - sql/uninstall.mysql.utf8.sql - - - - - index.html - tjreports.php - controller.php - views - models - controllers - assets - layouts - - - js - css - - - - en-GB/en-GB.com_tjreports.ini - - - COM_TJREPORTS - + + + + sql/uninstall.mysql.utf8.sql + + + + index.html + tjreports.php + controller.php + views + models + controllers + assets + layouts + + + js + css + + + en-GB/en-GB.com_tjreports.ini + + + COM_TJREPORTS + COM_TJREPORTS_TITLE_TJREPORTS - - - access.xml - config.xml - controller.php - index.html - tjreports.php - controllers - assets - helpers - models - sql - tables - views - - - + + + access.xml + config.xml + controller.php + index.html + tjreports.php + controllers + assets + helpers + models + sql + tables + views + + en-GB/en-GB.com_tjreports.ini en-GB/en-GB.com_tjreports.sys.ini - - - - -
- -
-
-
- - - - + + + script.tjreports.php + + +
+ +
+
+
+ + +
- -