Skip to content

Commit b269c7b

Browse files
bembelimenKubik-Rubik
authored andcommitted
Add access checks to the plugin parameter Fixes #8147
1 parent 319b19b commit b269c7b

File tree

3 files changed

+80
-125
lines changed

3 files changed

+80
-125
lines changed

administrator/language/en-GB/en-GB.plg_editors_tinymce.ini

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ PLG_TINY_FIELD_ADVIMAGE_DESC="Turn on/off a more advanced image dialog."
1212
PLG_TINY_FIELD_ADVIMAGE_LABEL="Advanced Image"
1313
PLG_TINY_FIELD_ADVLIST_DESC="Turn on/off to enable to set number formats and bullet types in ordered and unordered lists."
1414
PLG_TINY_FIELD_ADVLIST_LABEL="Advanced List"
15-
PLG_TINY_FIELD_ALIGN_DESC="Turn on/off to enable the alignment of the text. Only works in Extended mode."
15+
PLG_TINY_FIELD_ALIGN_DESC="Turn on/off to enable the alignment of the text."
1616
PLG_TINY_FIELD_ALIGN_LABEL="Text Alignment"
1717
PLG_TINY_FIELD_BLOCKQUOTE_DESC="Turn on/off blockquotes."
1818
PLG_TINY_FIELD_BLOCKQUOTE_LABEL="Blockquote"
19-
PLG_TINY_FIELD_COLORS_DESC="Show or hide the Colours control buttons. Only works in Extended mode."
20-
PLG_TINY_FIELD_COLORS_LABEL="Colours"
19+
PLG_TINY_FIELD_COLORS_DESC="Show or hide the Colors control buttons."
20+
PLG_TINY_FIELD_COLORS_LABEL="Colors"
2121
PLG_TINY_FIELD_CONTEXTMENU_DESC="Turn on/off Context Menu."
2222
PLG_TINY_FIELD_CONTEXTMENU_LABEL="Context Menu"
2323
PLG_TINY_FIELD_CSS_DESC="By default the Plugin looks for an editor.css file. If it can't find one in the default template CSS folder, it loads the editor.css file from the system template."
@@ -30,7 +30,7 @@ PLG_TINY_FIELD_CUSTOMPLUGIN_DESC="Add custom plugin(s)."
3030
PLG_TINY_FIELD_CUSTOMPLUGIN_LABEL="Custom Plugin"
3131
PLG_TINY_FIELD_CUSTOM_PATH_DESC="Provide a directory for the images to be uploaded. If nothing provided images will be uploaded at /images."
3232
PLG_TINY_FIELD_CUSTOM_PATH_LABEL="Images directory"
33-
PLG_TINY_FIELD_DATE_DESC="Show or hide the Insert Date button. Only works in Extended mode."
33+
PLG_TINY_FIELD_DATE_DESC="Show or hide the Insert Date button."
3434
PLG_TINY_FIELD_DATE_LABEL="Insert Date"
3535
PLG_TINY_FIELD_DIRECTION_DESC="Choose default text direction."
3636
PLG_TINY_FIELD_DIRECTION_LABEL="Text Direction"
@@ -40,9 +40,9 @@ PLG_TINY_FIELD_ELEMENTS_DESC="Allows the addition of specific valid elements to
4040
PLG_TINY_FIELD_ELEMENTS_LABEL="Extended Valid Elements"
4141
PLG_TINY_FIELD_ENCODING_DESC="Controls how HTML entities are encoded. Recommended setting is 'raw'. 'named' = used named entity encoding (for example, '<'). 'numeric' = use numeric HTML encoding (for example, '%03c'). raw = Do not encode HTML entities. Note that searching content may not work properly if setting is not 'raw'."
4242
PLG_TINY_FIELD_ENCODING_LABEL="Entity Encoding"
43-
PLG_TINY_FIELD_FONTS_DESC="Show or hide the Font control selectors. Only applies in Extended mode."
43+
PLG_TINY_FIELD_FONTS_DESC="Show or hide the Font control selectors."
4444
PLG_TINY_FIELD_FONTS_LABEL="Fonts"
45-
PLG_TINY_FIELD_FULLSCREEN_DESC="Show or hide the Fullscreen button. Only applies in Extended mode."
45+
PLG_TINY_FIELD_FULLSCREEN_DESC="Show or hide the Fullscreen button."
4646
PLG_TINY_FIELD_FULLSCREEN_LABEL="Fullscreen"
4747
PLG_TINY_FIELD_FUNCTIONALITY_DESC="Select level of functionality."
4848
PLG_TINY_FIELD_FUNCTIONALITY_LABEL="Functionality"
@@ -59,46 +59,46 @@ PLG_TINY_FIELD_LANGCODE_DESC="Editor UI Language. The value will be used if Auto
5959
PLG_TINY_FIELD_LANGCODE_LABEL="Language Code"
6060
PLG_TINY_FIELD_LANGSELECT_DESC="If Yes, editor language will automatically match selected UI language. If the tiny language does not exist, the editor language will default to English."
6161
PLG_TINY_FIELD_LANGSELECT_LABEL="Automatic Language Selection"
62-
PLG_TINY_FIELD_LINK_DESC="Select to enable the link icons. Only applies in Extended mode."
62+
PLG_TINY_FIELD_LINK_DESC="Select to enable the Link icons."
6363
PLG_TINY_FIELD_LINK_LABEL="Links"
64-
PLG_TINY_FIELD_MEDIA_DESC="Show or hide the Media button. Only applies in Extended mode."
64+
PLG_TINY_FIELD_MEDIA_DESC="Show or hide the Media button."
6565
PLG_TINY_FIELD_MEDIA_LABEL="Media"
6666
PLG_TINY_FIELD_MOBILE_DESC="This mode puts any mobile devices into the simple functionality with enlarged buttons for easy access."
6767
PLG_TINY_FIELD_MOBILE_LABEL="Mobile Mode"
68-
PLG_TINY_FIELD_NAME_EXTENDED_LABEL="<strong>Extended Mode Options</strong><br />These options only work in Extended mode."
68+
PLG_TINY_FIELD_NAME_EXTENDED_LABEL="<strong>Extended Mode Options</strong><br />Below you can set the access level for each one of the fields individually.<br />Please keep in mind that these options will only have an effect in <strong>Extended</strong> mode."
6969
PLG_TINY_FIELD_NEWLINES_DESC="New lines will be created using the selected option."
7070
PLG_TINY_FIELD_NEWLINES_LABEL="New Lines"
7171
PLG_TINY_FIELD_NONBREAKING_DESC="Insert non-breaking space entities."
7272
PLG_TINY_FIELD_NONBREAKING_LABEL="Non-breaking"
73-
PLG_TINY_FIELD_PASTE_DESC="Show or hide the Paste buttons. Only applies in Extended mode."
73+
PLG_TINY_FIELD_PASTE_DESC="Show or hide the Paste button."
7474
PLG_TINY_FIELD_PASTE_LABEL="Paste"
7575
PLG_TINY_FIELD_PATH_DESC="If set to ON, it displays the set classes for the marked text."
7676
PLG_TINY_FIELD_PATH_LABEL="Element Path"
77-
PLG_TINY_FIELD_PRINT_DESC="Turn on/off the print and print preview icons in the editor. Only applies in Extended mode."
77+
PLG_TINY_FIELD_PRINT_DESC="Turn on/off the print and print preview icons in the editor."
7878
PLG_TINY_FIELD_PRINT_LABEL="Print/Preview"
7979
PLG_TINY_FIELD_PROHIBITED_DESC="Elements that will be cleaned from the text. Do not leave empty - if you do not want to prohibit anything enter dummy text eg cms."
8080
PLG_TINY_FIELD_PROHIBITED_LABEL="Prohibited Elements"
8181
PLG_TINY_FIELD_RESIZE_HORIZONTAL_DESC="Enable/disable the horizontal resizing."
8282
PLG_TINY_FIELD_RESIZE_HORIZONTAL_LABEL="Horizontal resizing"
8383
PLG_TINY_FIELD_RESIZING_DESC="Enable/disable the resizing of the editor area (vertically and also horizontally if 'Horizontal Resizing' is enabled)."
8484
PLG_TINY_FIELD_RESIZING_LABEL="Resizing"
85-
PLG_TINY_FIELD_RTL_DESC="Select whether to display the RTL button. Only applies in Extended mode."
85+
PLG_TINY_FIELD_RTL_DESC="Select whether to display the RTL button."
8686
PLG_TINY_FIELD_RTL_LABEL="Directionality"
8787
PLG_TINY_FIELD_SAVEWARNING_DESC="Save Warning: gives warning if you cancel without saving changes."
8888
PLG_TINY_FIELD_SAVEWARNING_LABEL="Save Warning"
89-
PLG_TINY_FIELD_SEARCH-REPLACE_DESC="Show or hide the Search &amp; Replace button. Only applies in Extended mode."
89+
PLG_TINY_FIELD_SEARCH-REPLACE_DESC="Show or hide the Search &amp; Replace button."
9090
PLG_TINY_FIELD_SEARCH-REPLACE_LABEL="Search &amp; Replace"
9191
PLG_TINY_FIELD_SKIN_ADMIN_DESC="Select skin for the Administrator Backend interface."
9292
PLG_TINY_FIELD_SKIN_ADMIN_LABEL="Administrator Skin"
9393
PLG_TINY_FIELD_SKIN_DESC="Select skin for the Frontend interface."
9494
PLG_TINY_FIELD_SKIN_INFO_DESC="Copy your new skins to: /media/editors/tinymce/skins."
9595
PLG_TINY_FIELD_SKIN_INFO_LABEL="For customised skins go to: <a href="_QQ_"http://skin.tinymce.com"_QQ_" target="_QQ_"_blank"_QQ_">Skin Creator</a>"
9696
PLG_TINY_FIELD_SKIN_LABEL="Site Skin"
97-
PLG_TINY_FIELD_SMILIES_DESC="Show or hide the smilies buttons. Only applies in Extended mode."
97+
PLG_TINY_FIELD_SMILIES_DESC="Show or hide the Smilies buttons."
9898
PLG_TINY_FIELD_SMILIES_LABEL="Smilies"
99-
PLG_TINY_FIELD_TABLE_DESC="Show or hide the table control buttons. Only applies in Extended mode."
99+
PLG_TINY_FIELD_TABLE_DESC="Show or hide the Table control buttons."
100100
PLG_TINY_FIELD_TABLE_LABEL="Table"
101-
PLG_TINY_FIELD_TEMPLATE_DESC="Show or hide the Insert predefined template content button. Only applies in Extended mode."
101+
PLG_TINY_FIELD_TEMPLATE_DESC="Show or hide the Insert predefined template content button."
102102
PLG_TINY_FIELD_TEMPLATE_LABEL="Template"
103103
PLG_TINY_FIELD_URLS_DESC="URL behaviour."
104104
PLG_TINY_FIELD_URLS_LABEL="URLs"
@@ -135,4 +135,4 @@ PLG_TINY_TEMPLATE_LAYOUT1_DESC="HTML layout."
135135
PLG_TINY_TEMPLATE_LAYOUT1_TITLE="Layout"
136136
PLG_TINY_TEMPLATE_SNIPPET1_DESC="Simple HTML snippet."
137137
PLG_TINY_TEMPLATE_SNIPPET1_TITLE="Simple Snippet"
138-
PLG_TINY_XML_DESCRIPTION="TinyMCE is a platform independent web based JavaScript HTML WYSIWYG Editor."
138+
PLG_TINY_XML_DESCRIPTION="TinyMCE is a platform independent web based JavaScript HTML WYSIWYG Editor."

plugins/editors/tinymce/tinymce.php

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ public function onInit()
213213
$valid_elements = $this->params->get('valid_elements', '');
214214

215215
// Advanced Options
216+
$access = JFactory::getUser()->getAuthorisedViewLevels();
217+
218+
// Flip for performance, so we can direct check for the key isset($access[$key])
219+
$access = array_flip($access);
220+
216221
$html_height = $this->params->get('html_height', '550');
217222
$html_width = $this->params->get('html_width', '');
218223

@@ -224,7 +229,7 @@ public function onInit()
224229
// Image advanced options
225230
$image_advtab = $this->params->get('image_advtab', 1);
226231

227-
if ($image_advtab)
232+
if (isset($access[$image_advtab]))
228233
{
229234
$image_advtab = "true";
230235
}
@@ -280,7 +285,7 @@ public function onInit()
280285
// Alignment buttons
281286
$alignment = $this->params->get('alignment', 1);
282287

283-
if ($alignment)
288+
if (isset($access[$alignment]))
284289
{
285290
$toolbar1_add[] = '|';
286291
$toolbar1_add[] = 'alignleft';
@@ -297,7 +302,7 @@ public function onInit()
297302
// Fonts
298303
$fonts = $this->params->get('fonts', 1);
299304

300-
if ($fonts)
305+
if (isset($access[$fonts]))
301306
{
302307
$toolbar1_add[] = 'fontselect';
303308
$toolbar1_add[] = 'fontsizeselect';
@@ -306,7 +311,7 @@ public function onInit()
306311
// Search & replace
307312
$searchreplace = $this->params->get('searchreplace', 1);
308313

309-
if ($searchreplace)
314+
if (isset($access[$searchreplace]))
310315
{
311316
$plugins[] = 'searchreplace';
312317
$toolbar2_add[] = 'searchreplace';
@@ -326,7 +331,7 @@ public function onInit()
326331
// Insert date and/or time plugin
327332
$insertdate = $this->params->get('insertdate', 1);
328333

329-
if ($insertdate)
334+
if (isset($access[$insertdate]))
330335
{
331336
$plugins[] = 'insertdatetime';
332337
$toolbar4_add[] = 'inserttime';
@@ -335,7 +340,7 @@ public function onInit()
335340
// Link plugin
336341
$link = $this->params->get('link', 1);
337342

338-
if ($link)
343+
if (isset($access[$link]))
339344
{
340345
$plugins[] = 'link';
341346
$toolbar2_add[] = 'link';
@@ -347,10 +352,10 @@ public function onInit()
347352
$toolbar2_add[] = '|';
348353
$toolbar2_add[] = 'code';
349354

350-
// Colours
351-
$colours = $this->params->get('colours', 1);
355+
// Colors
356+
$colors = $this->params->get('colors', 1);
352357

353-
if ($colours)
358+
if (isset($access[$colors]))
354359
{
355360
$toolbar2_add[] = '|';
356361
$toolbar2_add[] = 'forecolor,backcolor';
@@ -359,7 +364,7 @@ public function onInit()
359364
// Fullscreen
360365
$fullscreen = $this->params->get('fullscreen', 1);
361366

362-
if ($fullscreen)
367+
if (isset($access[$fullscreen]))
363368
{
364369
$plugins[] = 'fullscreen';
365370
$toolbar2_add[] = '|';
@@ -369,7 +374,7 @@ public function onInit()
369374
// Table
370375
$table = $this->params->get('table', 1);
371376

372-
if ($table)
377+
if (isset($access[$table]))
373378
{
374379
$plugins[] = 'table';
375380
$toolbar3_add[] = 'table';
@@ -384,7 +389,7 @@ public function onInit()
384389
// Emotions
385390
$smilies = $this->params->get('smilies', 1);
386391

387-
if ($smilies)
392+
if (isset($access[$smilies]))
388393
{
389394
$plugins[] = 'emoticons';
390395
$toolbar3_add[] = 'emoticons';
@@ -393,7 +398,7 @@ public function onInit()
393398
// Media plugin
394399
$media = $this->params->get('media', 1);
395400

396-
if ($media)
401+
if (isset($access[$media]))
397402
{
398403
$plugins[] = 'media';
399404
$toolbar3_add[] = 'media';
@@ -402,7 +407,7 @@ public function onInit()
402407
// Horizontal line
403408
$hr = $this->params->get('hr', 1);
404409

405-
if ($hr)
410+
if (isset($access[$hr]))
406411
{
407412
$plugins[] = 'hr';
408413
$elements[] = 'hr[id|title|alt|class|width|size|noshade]';
@@ -416,7 +421,7 @@ public function onInit()
416421
// RTL/LTR buttons
417422
$directionality = $this->params->get('directionality', 1);
418423

419-
if ($directionality)
424+
if (isset($access[$directionality]))
420425
{
421426
$plugins[] = 'directionality';
422427
$toolbar3_add[] = 'ltr rtl';
@@ -433,7 +438,7 @@ public function onInit()
433438
// Paste
434439
$paste = $this->params->get('paste', 1);
435440

436-
if ($paste)
441+
if (isset($access[$paste]))
437442
{
438443
$plugins[] = 'paste';
439444
$toolbar4_add[] = 'paste';
@@ -444,7 +449,7 @@ public function onInit()
444449
// Visualchars
445450
$visualchars = $this->params->get('visualchars', 1);
446451

447-
if ($visualchars)
452+
if (isset($access[$visualchars]))
448453
{
449454
$plugins[] = 'visualchars';
450455
$toolbar4_add[] = 'visualchars';
@@ -453,7 +458,7 @@ public function onInit()
453458
// Visualblocks
454459
$visualblocks = $this->params->get('visualblocks', 1);
455460

456-
if ($visualblocks)
461+
if (isset($access[$visualblocks]))
457462
{
458463
$plugins[] = 'visualblocks';
459464
$toolbar4_add[] = 'visualblocks';
@@ -462,7 +467,7 @@ public function onInit()
462467
// Non-breaking
463468
$nonbreaking = $this->params->get('nonbreaking', 1);
464469

465-
if ($nonbreaking)
470+
if (isset($access[$nonbreaking]))
466471
{
467472
$plugins[] = 'nonbreaking';
468473
$toolbar4_add[] = 'nonbreaking';
@@ -471,15 +476,15 @@ public function onInit()
471476
// Blockquote
472477
$blockquote = $this->params->get('blockquote', 1);
473478

474-
if ($blockquote)
479+
if (isset($access[$blockquote]))
475480
{
476481
$toolbar4_add[] = 'blockquote';
477482
}
478483

479484
// Template
480485
$template = $this->params->get('template', 1);
481486

482-
if ($template)
487+
if (isset($access[$template]))
483488
{
484489
$plugins[] = 'template';
485490
$toolbar4_add[] = 'template';
@@ -547,7 +552,7 @@ public function onInit()
547552
// Print
548553
$print = $this->params->get('print', 1);
549554

550-
if ($print)
555+
if (isset($access[$print]))
551556
{
552557
$plugins[] = 'print';
553558
$toolbar4_add[] = '|';
@@ -558,7 +563,7 @@ public function onInit()
558563
// Spellchecker
559564
$spell = $this->params->get('spell', 0);
560565

561-
if ($spell)
566+
if (isset($access[$spell]))
562567
{
563568
$plugins[] = 'spellchecker';
564569
$toolbar4_add[] = '|';
@@ -568,31 +573,31 @@ public function onInit()
568573
// Wordcount
569574
$wordcount = $this->params->get('wordcount', 1);
570575

571-
if ($wordcount)
576+
if (isset($access[$wordcount]))
572577
{
573578
$plugins[] = 'wordcount';
574579
}
575580

576581
// Advlist
577582
$advlist = $this->params->get('advlist', 1);
578583

579-
if ($advlist)
584+
if (isset($access[$advlist]))
580585
{
581586
$plugins[] = 'advlist';
582587
}
583588

584589
// Autosave
585590
$autosave = $this->params->get('autosave', 1);
586591

587-
if ($autosave)
592+
if (isset($access[$autosave]))
588593
{
589594
$plugins[] = 'autosave';
590595
}
591596

592597
// Context menu
593598
$contextmenu = $this->params->get('contextmenu', 1);
594599

595-
if ($contextmenu)
600+
if (isset($access[$contextmenu]))
596601
{
597602
$plugins[] = 'contextmenu';
598603
}

0 commit comments

Comments
 (0)