Skip to content

Commit

Permalink
removed unnecessary ACL checks (pagebreak, article XTD btns & content)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivioCavallo committed Sep 3, 2017
1 parent cbff398 commit c855a9b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 56 deletions.
22 changes: 0 additions & 22 deletions components/com_content/content.php
Expand Up @@ -13,28 +13,6 @@
JLoader::register('ContentHelperQuery', JPATH_SITE . '/components/com_content/helpers/query.php');
JLoader::register('ContentHelperAssociation', JPATH_SITE . '/components/com_content/helpers/association.php');

$input = JFactory::getApplication()->input;
$user = JFactory::getUser();

if ($input->get('view') === 'article' && $input->get('layout') === 'pagebreak')
{
if (!$user->authorise('core.create', 'com_content'))
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');

return;
}
}
elseif ($input->get('view') === 'articles' && $input->get('layout') === 'modal')
{
if (!$user->authorise('core.create', 'com_content'))
{
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');

return;
}
}

$controller = JControllerLegacy::getInstance('Content');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
26 changes: 9 additions & 17 deletions plugins/editors-xtd/article/article.php
Expand Up @@ -35,25 +35,17 @@ class PlgButtonArticle extends JPlugin
*/
public function onDisplay($name)
{
$link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&'
. JSession::getFormToken() . '=1&editor=' . $name;

$user = JFactory::getUser();

if ($user->authorise('core.create', 'com_content')
|| $user->authorise('core.edit', 'com_content')
|| $user->authorise('core.edit.own', 'com_content'))
{
$link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&'
. JSession::getFormToken() . '=1&editor=' . $name;

$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
$button->name = 'file-add';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
$button->name = 'file-add';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";

return $button;
}
}
}
27 changes: 10 additions & 17 deletions plugins/editors-xtd/pagebreak/pagebreak.php
Expand Up @@ -35,24 +35,17 @@ class PlgButtonPagebreak extends JPlugin
*/
public function onDisplay($name)
{
$user = JFactory::getUser();
JFactory::getDocument()->addScriptOptions('xtd-pagebreak', array('editor' => $name));
$link = 'index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=' . $name;

if ($user->authorise('core.create', 'com_content')
|| $user->authorise('core.edit', 'com_content')
|| $user->authorise('core.edit.own', 'com_content'))
{
JFactory::getDocument()->addScriptOptions('xtd-pagebreak', array('editor' => $name));
$link = 'index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=' . $name;
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
$button->name = 'copy';
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";

$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
$button->name = 'copy';
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";

return $button;
}
return $button;
}
}

0 comments on commit c855a9b

Please sign in to comment.