Skip to content

Commit 8acabc8

Browse files
infograf768rdeutz
authored andcommitted
3.6.3: Allow author to use xtd-editors (#12353)
1 parent 3e2ac1b commit 8acabc8

File tree

4 files changed

+66
-67
lines changed

4 files changed

+66
-67
lines changed

components/com_content/content.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,6 @@
1212
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
1313
JLoader::register('ContentHelperQuery', JPATH_SITE . '/components/com_content/helpers/query.php');
1414

15-
$input = JFactory::getApplication()->input;
16-
$user = JFactory::getUser();
17-
18-
if ($input->get('view') === 'article' && $input->get('layout') === 'pagebreak')
19-
{
20-
if (!$user->authorise('core.edit', 'com_content'))
21-
{
22-
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');
23-
24-
return;
25-
}
26-
}
27-
elseif ($input->get('view') === 'articles' && $input->get('layout') === 'modal')
28-
{
29-
if (!$user->authorise('core.edit', 'com_content'))
30-
{
31-
JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'warning');
32-
33-
return;
34-
}
35-
}
36-
3715
$controller = JControllerLegacy::getInstance('Content');
38-
$controller->execute($input->get('task'));
16+
$controller->execute(JFactory::getApplication()->input->get('task'));
3917
$controller->redirect();

plugins/editors-xtd/article/article.php

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,43 @@ public function onDisplay($name)
3939
* jSelectArticle creates the link tag, sends it to the editor,
4040
* and closes the select frame.
4141
*/
42-
$js = "
43-
function jSelectArticle(id, title, catid, object, link, lang)
42+
$user = JFactory::getUser();
43+
44+
if ($user->authorise('core.create', 'com_content')
45+
|| $user->authorise('core.edit', 'com_content')
46+
|| $user->authorise('core.edit.own', 'com_content'))
4447
{
45-
var hreflang = '';
46-
if (lang !== '')
48+
$js = "
49+
function jSelectArticle(id, title, catid, object, link, lang)
4750
{
48-
var hreflang = ' hreflang = \"' + lang + '\"';
49-
}
50-
var tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';
51-
jInsertEditorText(tag, '" . $name . "');
52-
jModalClose();
53-
}";
51+
var hreflang = '';
52+
if (lang !== '')
53+
{
54+
var hreflang = ' hreflang = \"' + lang + '\"';
55+
}
56+
var tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';
57+
jInsertEditorText(tag, '" . $name . "');
58+
jModalClose();
59+
}";
5460

55-
$doc = JFactory::getDocument();
56-
$doc->addScriptDeclaration($js);
61+
$doc = JFactory::getDocument();
62+
$doc->addScriptDeclaration($js);
5763

58-
/*
59-
* Use the built-in element view to select the article.
60-
* Currently uses blank class.
61-
*/
62-
$link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
64+
/*
65+
* Use the built-in element view to select the article.
66+
* Currently uses blank class.
67+
*/
68+
$link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
6369

64-
$button = new JObject;
65-
$button->modal = true;
66-
$button->class = 'btn';
67-
$button->link = $link;
68-
$button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
69-
$button->name = 'file-add';
70-
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
70+
$button = new JObject;
71+
$button->modal = true;
72+
$button->class = 'btn';
73+
$button->link = $link;
74+
$button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
75+
$button->name = 'file-add';
76+
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
7177

72-
return $button;
78+
return $button;
79+
}
7380
}
7481
}

plugins/editors-xtd/module/module.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,24 @@ public function onDisplay($name)
3838
* Use the built-in element view to select the module.
3939
* Currently uses blank class.
4040
*/
41-
$link = 'index.php?option=com_modules&amp;view=modules&amp;layout=modal&amp;tmpl=component&amp;editor='
42-
. $name . '&amp;' . JSession::getFormToken() . '=1';
41+
$user = JFactory::getUser();
4342

44-
$button = new JObject;
45-
$button->modal = true;
46-
$button->class = 'btn';
47-
$button->link = $link;
48-
$button->text = JText::_('PLG_MODULE_BUTTON_MODULE');
49-
$button->name = 'file-add';
50-
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
43+
if ($user->authorise('core.create', 'com_content')
44+
|| $user->authorise('core.edit', 'com_content')
45+
|| $user->authorise('core.edit.own', 'com_content'))
46+
{
47+
$link = 'index.php?option=com_modules&amp;view=modules&amp;layout=modal&amp;tmpl=component&amp;editor='
48+
. $name . '&amp;' . JSession::getFormToken() . '=1';
5149

52-
return $button;
50+
$button = new JObject;
51+
$button->modal = true;
52+
$button->class = 'btn';
53+
$button->link = $link;
54+
$button->text = JText::_('PLG_MODULE_BUTTON_MODULE');
55+
$button->name = 'file-add';
56+
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
57+
58+
return $button;
59+
}
5360
}
5461
}

plugins/editors-xtd/pagebreak/pagebreak.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,23 @@ class PlgButtonPagebreak extends JPlugin
3333
*/
3434
public function onDisplay($name)
3535
{
36-
$link = 'index.php?option=com_content&amp;view=article&amp;layout=pagebreak&amp;tmpl=component&amp;e_name=' . $name;
36+
$user = JFactory::getUser();
3737

38-
$button = new JObject;
39-
$button->modal = true;
40-
$button->class = 'btn';
41-
$button->link = $link;
42-
$button->text = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
43-
$button->name = 'copy';
44-
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";
38+
if ($user->authorise('core.create', 'com_content')
39+
|| $user->authorise('core.edit', 'com_content')
40+
|| $user->authorise('core.edit.own', 'com_content'))
41+
{
42+
$link = 'index.php?option=com_content&amp;view=article&amp;layout=pagebreak&amp;tmpl=component&amp;e_name=' . $name;
4543

46-
return $button;
44+
$button = new JObject;
45+
$button->modal = true;
46+
$button->class = 'btn';
47+
$button->link = $link;
48+
$button->text = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
49+
$button->name = 'copy';
50+
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";
51+
52+
return $button;
53+
}
4754
}
4855
}

0 commit comments

Comments
 (0)