Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,8 @@ public function deleteUnexistingFiles()
'/administrator/templates/hathor/html/mod_menu',
'/administrator/components/com_messages/layouts/toolbar',
'/administrator/components/com_messages/layouts',
// Joomla! __DEPLOY_VERSION__
'/components/com_fields/controllers',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this targetting a folder. Should be the file.
'/components/com_fields/controllers/field.php',

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This folder has only one file, so better to remove it completely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comment says, deleting only the folder may not work when ftp is used.
It is safer to at least delete the file.

);

jimport('joomla.filesystem.file');
Expand Down
38 changes: 0 additions & 38 deletions administrator/components/com_fields/controllers/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,44 +46,6 @@ public function __construct($config = array())
$this->component = $parts ? $parts[0] : null;
}

/**
* Stores the form data into the user state.
*
* @return void
*
* @since 3.7.0
*/
public function storeform()
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

$app = JFactory::getApplication();
$data = $this->input->get($this->input->get('formcontrol', 'jform'), array(), 'array');

$parts = FieldsHelper::extract($this->input->getCmd('context'));

if ($parts)
{
$app->setUserState($parts[0] . '.edit.' . $parts[1] . '.data', $data);
}

if ($this->input->get('userstatevariable'))
{
$app->setUserState($this->input->get('userstatevariable'), $data);
}

$redirectUrl = base64_decode($this->input->get->getBase64('return'));

// Don't redirect to an external URL.
If (!JUri::isInternal($redirectUrl))
{
$redirectUrl = 'index.php';
}

$app->redirect($redirectUrl);
$app->close();
}

/**
* Method override to check if you can add a new record.
*
Expand Down
22 changes: 1 addition & 21 deletions administrator/components/com_fields/helpers/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,25 +314,6 @@ public static function prepareForm($context, JForm $form, $data)
*/
if ($form->getField('catid') && $parts[0] != 'com_fields')
{
// The uri to submit to
$uri = clone JUri::getInstance('index.php');

/*
* Removing the catid parameter from the actual URL and set it as
* return
*/
$returnUri = clone JUri::getInstance();
$returnUri->setVar('catid', null);
$uri->setVar('return', base64_encode($returnUri->toString()));

// Setting the options
$uri->setVar('option', 'com_fields');
$uri->setVar('task', 'field.storeform');
$uri->setVar('context', $parts[0] . '.' . $parts[1]);
$uri->setVar('formcontrol', $form->getFormControl());
$uri->setVar('view', null);
$uri->setVar('layout', null);

/*
* Setting the onchange event to reload the page when the category
* has changed
Expand All @@ -345,8 +326,7 @@ function categoryHasChanged(element) {
var cat = jQuery(element);
if (cat.val() == '" . $assignedCatids . "')return;
Joomla.loadingLayer('show');
jQuery('input[name=task]').val('field.storeform');
element.form.action='" . $uri . "';
jQuery('input[name=task]').val('" . $section . ".reload');
element.form.submit();
}
jQuery( document ).ready(function() {
Expand Down
49 changes: 0 additions & 49 deletions components/com_fields/controllers/field.php

This file was deleted.

98 changes: 98 additions & 0 deletions libraries/legacy/controller/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,4 +844,102 @@ public function save($key = null, $urlVar = null)

return true;
}

/**
* Method to reload a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function reload($key = null, $urlVar = null)
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

$app = JFactory::getApplication();
$model = $this->getModel();
$data = $this->input->post->get('jform', array(), 'array');

// Determine the name of the primary key for the data.
if (empty($key))
{
$key = $model->getTable()->getKeyName();
}

// To avoid data collisions the urlVar may be different from the primary key.
if (empty($urlVar))
{
$urlVar = $key;
}

$recordId = $this->input->getInt($urlVar);

if (!$this->allowEdit($data, $key))
{
$this->setRedirect(
JRoute::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. $this->getRedirectToListAppend(), false
)
);
$this->redirect();
}

// Populate the row id from the session.
$data[$key] = $recordId;

// The redirect url
$redirectUrl = JRoute::_(
'index.php?option=' . $this->option . '&view=' . $this->view_item .
$this->getRedirectToItemAppend($recordId, $urlVar),
false
);

// Validate the posted data.
// Sometimes the form needs some posted data, such as for plugins and modules.
$form = $model->getForm($data, false);

if (!$form)
{
$app->enqueueMessage($model->getError(), 'error');

$this->setRedirect($redirectUrl);
$this->redirect();
}

// Test whether the data is valid.
$validData = $model->validate($form, $data);

// Check for validation errors.
if ($validData === false)
{
// Get the validation messages.
$errors = $model->getErrors();

// Push up to three validation messages out to the user.
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++)
{
if ($errors[$i] instanceof Exception)
{
$app->enqueueMessage($errors[$i]->getMessage(), 'warning');
}
else
{
$app->enqueueMessage($errors[$i], 'warning');
}
}
}
else
{
// Save the data in the session.
$app->setUserState($this->option . '.edit.' . $this->context . '.data', $validData);
}

$this->setRedirect($redirectUrl);
$this->redirect();
}
}