Skip to content

Commit

Permalink
Bug #45 fix: Error 414 displayed on the site when user use 'com_tc' o…
Browse files Browse the repository at this point in the history
…ption 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
  • Loading branch information
paritshivani authored Mar 4, 2020
1 parent 0f06690 commit 04f8e73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/components/com_tc/administrator/models/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -18,7 +19,7 @@
*
* @since 1.6
*/
class TcModelContent extends JModelAdmin
class TcModelContent extends AdminModel
{
/**
* @var string The prefix to use with controller messages.
Expand All @@ -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
*/
Expand All @@ -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(
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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<mixed,mixed>
*
* @since 1.6
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -370,7 +370,7 @@ public function hasUserAcceptedTC($loggedInUserId, $tcId)
*
* @param INT $tcId TC id
*
* @return void
* @return boolean
*
* @since 1.6
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."

0 comments on commit 04f8e73

Please sign in to comment.