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] category field readonly when editing an existing item in frontend #24216

Merged
merged 3 commits into from Mar 22, 2019
Merged
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
14 changes: 12 additions & 2 deletions administrator/components/com_content/models/article.php
Expand Up @@ -370,6 +370,8 @@ public function getItem($pk = null)
*/
public function getForm($data = array(), $loadData = true)
{
$app = JFactory::getApplication();

// Get the form.
$form = $this->loadForm('com_content.article', 'article', array('control' => 'jform', 'load_data' => $loadData));

Expand All @@ -395,7 +397,16 @@ public function getForm($data = array(), $loadData = true)
$form->setFieldAttribute('catid', 'action', 'core.edit');

// Existing record. Can only edit own articles in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit.own');
if ($app->isClient('administrator'))
{
$form->setFieldAttribute('catid', 'action', 'core.edit.own');
}
else
// Existing record. We can't edit the category in frontend.
{
$form->setFieldAttribute('catid', 'readonly', 'true');
$form->setFieldAttribute('catid', 'filter', 'unset');
}
}
else
{
Expand Down Expand Up @@ -427,7 +438,6 @@ public function getForm($data = array(), $loadData = true)
}

// Prevent messing with article language and category when editing existing article with associations
$app = JFactory::getApplication();
$assoc = JLanguageAssociations::isEnabled();

// Check if article is associated
Expand Down