From 04f8e7385b77e26a581177885de71c98c0270797 Mon Sep 17 00:00:00 2001 From: paritshivani <58217306+paritshivani@users.noreply.github.com> Date: Wed, 4 Mar 2020 11:08:09 +0530 Subject: [PATCH] Bug #45 fix: Error 414 displayed on the site when user use 'com_tc' option while adding Terms & Conditions. (#46) * Bug #158200 fix: Error 414 displayed on the site when user use 'com_tc' option while adding Terms & Conditions. * Bug #158200 fix: Scrutinizer fix * Bug #158200 fix: Scrutinizer fix * Bug #158200 fix: Scrutinizer fix * Bug #158200 fix: Scrutinizer fix * Bug #158200 fix: Scrutinizer fix * Bug #158200 fix: Scrutinizer fix * Bug #158200 fix: Resolved comments --- .../com_tc/administrator/models/content.php | 24 ++++++++++++------- .../administrator/en-GB/en-GB.com_tc.ini | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/components/com_tc/administrator/models/content.php b/src/components/com_tc/administrator/models/content.php index 7960010..e6b88a7 100755 --- a/src/components/com_tc/administrator/models/content.php +++ b/src/components/com_tc/administrator/models/content.php @@ -10,6 +10,7 @@ // No direct access. defined('_JEXEC') or die; use Joomla\CMS\Factory; +Use Joomla\CMS\MVC\Model\AdminModel; jimport('joomla.application.component.modeladmin'); @@ -18,7 +19,7 @@ * * @since 1.6 */ -class TcModelContent extends JModelAdmin +class TcModelContent extends AdminModel { /** * @var string The prefix to use with controller messages. @@ -45,7 +46,7 @@ class TcModelContent extends JModelAdmin * @param string $prefix A prefix for the table class name. Optional. * @param array $config Configuration array for model. Optional. * - * @return JTable A database object + * @return Joomla\CMS\Table\Table A database object * * @since 1.6 */ @@ -67,7 +68,6 @@ public function getTable($type = 'Content', $prefix = 'TcTable', $config = array public function getForm($data = array(), $loadData = true) { // Initialise variables. - $app = Factory::getApplication(); // Get the form. $form = $this->loadForm( @@ -233,7 +233,7 @@ public function save($data) * @param STRING $tcVersion TC version * @param STRING $tcClient TC client * - * @return void + * @return boolean|string * * @since 3.0 */ @@ -281,7 +281,7 @@ public function checkDuplicateAndLatestVersionTC($tcVersion,$tcClient) * @param STRING $option component option name * @param STRING $view component view name * - * @return void + * @return array|array * * @since 1.6 */ @@ -315,7 +315,7 @@ public function getMatchingTCs($option, $view) * @param INT $loggedInUserId logged in used id * @param INT $tcId TC id * - * @return void + * @return array * * @since 1.6 */ @@ -370,7 +370,7 @@ public function hasUserAcceptedTC($loggedInUserId, $tcId) * * @param INT $tcId TC id * - * @return void + * @return boolean * * @since 1.6 */ @@ -585,7 +585,7 @@ public function isUserAcceptedTC($loggedInUserId, $tcId) * @param array $data The data to validate. * @param string $group The name of the group(defaults to null). * - * @return mixed Array of filtered data if valid, false otherwise. + * @return mixed array of filtered data if valid, false otherwise. * * @since 1.1 */ @@ -599,6 +599,14 @@ public function validate($form, $data, $group=null) $option = $pattern['option']; $view = $pattern['view']; + // Don't allow to add T&C for same component. + if (($option == 'com_tc') && ($view == 'content')) + { + $this->setError(JText::_('COM_TC_INVALID_URL_PATTERN')); + + return false; + } + if ($global == 0 && (empty($option) || empty($view))) { $this->setError(JText::_('COM_TC_ENTER_URL_PATTERN')); diff --git a/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini b/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini index be6a009..37d4726 100755 --- a/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini +++ b/src/components/com_tc/languages/administrator/en-GB/en-GB.com_tc.ini @@ -120,3 +120,4 @@ COM_TC_USERS_SEARCH_FILTER_DESC="Search by User name, Terms and Conditions or T& COM_TC_ENTER_URL_PATTERN="Please fill URL Pattern" COM_TC_MSG_SUCCESS_SAVE_CONTENT="Terms and conditions saved successfully" COM_TC_INVALID_DATA="Invalid form" +COM_TC_INVALID_URL_PATTERN="Use correct URL pattern, added URL pattern is of Terms & Conditions manager." \ No newline at end of file