Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[staging] Contact Banned parameters work only from component Options #23569

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 26 additions & 2 deletions components/com_contact/models/rules/contactemail.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,32 @@ public function test(SimpleXMLElement $element, $value, $group = null, Registry
return false;
}

$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_email');
$app = JFactory::getApplication();
$model = JModelLegacy::getInstance('Contact', 'ContactModel');
$stub = $app->input->getString('id');
$contactId = (int) $stub;

$contact = $model->getItem($contactId);

// Get item params, take menu parameters into account if necessary
$active = $app->getMenu()->getActive();
$stateParams = clone $model->getState()->get('params');

// If the current view is the active item and a contact view for this contact, then the menu item params take priority
if ($active && strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id))
{
// $item->params are the contact params, $active->params are the menu item params
// Merge so that the menu item params take priority
$contact->params->merge($active->params);
}
else
{
// Current view is not a single contact displayed by a specific menu item, so the contact params take priority here
$stateParams->merge($contact->params);
$contact->params = $stateParams;
}

$banned = $contact->params->get('banned_email');

if ($banned)
{
Expand Down
28 changes: 26 additions & 2 deletions components/com_contact/models/rules/contactemailmessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,32 @@ class JFormRuleContactEmailMessage extends JFormRule
*/
public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null)
{
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_text');
$app = JFactory::getApplication();
$model = JModelLegacy::getInstance('Contact', 'ContactModel');
$stub = $app->input->getString('id');
$contactId = (int) $stub;

$contact = $model->getItem($contactId);

// Get item params, take menu parameters into account if necessary
$active = $app->getMenu()->getActive();
$stateParams = clone $model->getState()->get('params');

// If the current view is the active item and a contact view for this contact, then the menu item params take priority
if ($active && strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id))
{
// $item->params are the contact params, $active->params are the menu item params
// Merge so that the menu item params take priority
$contact->params->merge($active->params);
}
else
{
// Current view is not a single contact displayed by a specific menu item, so the contact params take priority here
$stateParams->merge($contact->params);
$contact->params = $stateParams;
}

$banned = $contact->params->get('banned_text');

if ($banned)
{
Expand Down
28 changes: 26 additions & 2 deletions components/com_contact/models/rules/contactemailsubject.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,32 @@ class JFormRuleContactEmailSubject extends JFormRule
*/
public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, JForm $form = null)
{
$params = JComponentHelper::getParams('com_contact');
$banned = $params->get('banned_subject');
$app = JFactory::getApplication();
$model = JModelLegacy::getInstance('Contact', 'ContactModel');
$stub = $app->input->getString('id');
$contactId = (int) $stub;

$contact = $model->getItem($contactId);

// Get item params, take menu parameters into account if necessary
$active = $app->getMenu()->getActive();
$stateParams = clone $model->getState()->get('params');

// If the current view is the active item and a contact view for this contact, then the menu item params take priority
if ($active && strpos($active->link, 'view=contact') && strpos($active->link, '&id=' . (int) $contact->id))
{
// $item->params are the contact params, $active->params are the menu item params
// Merge so that the menu item params take priority
$contact->params->merge($active->params);
}
else
{
// Current view is not a single contact displayed by a specific menu item, so the contact params take priority here
$stateParams->merge($contact->params);
$contact->params = $stateParams;
}

$banned = $contact->params->get('banned_subject');

if ($banned)
{
Expand Down