BBCODE Only for Staff
3 posters
Page 1 of 1
BBCODE Only for Staff
Hi guys! Like always I want to thank you all for helping me.
Today my question is about BBCode.
I added these BBCode with a nice look:
and buttons:
But how can make them work only for staff? (admin+moderators)
I want that guest or normal users can't see the bbcode buttons in SCeditor, and they can't even manually add them just typing the code "[success=Risolto][/success]"
Is that possible?
Here's the codes:
Today my question is about BBCode.
I added these BBCode with a nice look:
and buttons:
But how can make them work only for staff? (admin+moderators)
I want that guest or normal users can't see the bbcode buttons in SCeditor, and they can't even manually add them just typing the code "[success=Risolto][/success]"
Is that possible?
Here's the codes:
- Spoiler:
- Code:
jQuery(function(){
jQuery(function(){
jQuery('<a class="sceditor-button sceditor-button-sucesso" unselectable="on" title="Sucesso"><div unselectable="on" style="background-image:url(https://i.imgur.com/EISZPwN.png)">Sucesso</div></a>').insertBefore('.sceditor-button-size').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[success=Risolto]","[/success]");
});
jQuery('<a class="sceditor-button sceditor-button-alerta" unselectable="on" title="Alerta"><div unselectable="on" style="background-image:url(https://i.imgur.com/lMsD0nE.png)">Alerta</div></a>').insertAfter('.sceditor-button-sucesso').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[alert=Avverimento]","[/alert]");
});
jQuery('<a class="sceditor-button sceditor-button-aviso" unselectable="on" title="Aviso"><div unselectable="on" style="background-image:url(https://i.imgur.com/cI8SnOI.png)">Aviso</div></a>').insertAfter('.sceditor-button-alerta').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[warn=Attenzione]","[/warn]");
});
jQuery('<a class="sceditor-button sceditor-button-info" unselectable="on" title="Informação"><div unselectable="on" style="background-image:url(https://i.imgur.com/40zM1qS.png)">Informação</div></a>').insertAfter('.sceditor-button-aviso').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[info=Informazioni]","[/info]");
});
});
});
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'guest',
close: true,
replacement: '<div class="guest">{content}</div>',
replace: function(option, content) {
if (_userdata.session_logged_in < 1) {
return 'You need to be logged in to view this content';
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
- Code:
/*
[tags] Nei post per lo staff
*/
.notice {
background: url(https://i.imgur.com/VWRy0Mc.png) repeat-x 0 0;
color: #FFF;
width: 83%;
font-weight: normal;
padding: 13px 15px;
margin-bottom: 2.5em;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,.4);
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,.4);
box-shadow: 1px 1px 2px rgba(0,0,0,.4);
position: relative;
left: 34px;
}
.notice p {
margin-bottom: 1.5em;
}
.notice p:last-child {
margin-bottom: 0;
}
.notice h5 {
font-size: 14px;
font-weight: bold;
margin-bottom: .65em;
}
.notice:before {
content: "";
background: url(https://i.imgur.com/PcLYd52.png) no-repeat 100% 0;
width: 33px;
height: 40px;
position: absolute;
left: -34px;
top: 9px;
}
.notice-success {
background-color: #EEF4D4;
color: #596C26;
border: 1px solid #8FAD3D;
}
.notice-success:before {
background-position: 100% 0;
}
.notice-warn {
background-color: #FFEA97;
color: #796100;
border: 1px solid #E1B500;
}
.notice-warn:before {
background-position: 100% -800px;
}
.notice-alert {
background-color: #EFCEC9;
color: #933628;
border: 1px solid #AE3F2F;
}
.notice-alert:before {
background-position: 100% -400px;
}
.notice-info {
background-color: #C6D8F0;
color: #285797;
border: 1px solid #4381CD;
}
.notice-info:before {
background-position: 100% -1200px;
}
.sucesso, .alerta, .aviso, .infos {
padding: 8px 8px 8px 40px;
width: 99%;
text-shadow: 0 1px 0 #FFFAF1;
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
font-weight: bold;
border-radius: 3px 3px 3px 3px;
}
.sucesso {
background: url('http://cdn3.iconfinder.com/data/icons/fatcow/32x32_0020/accept.png') no-repeat 6px #effeb9;
border: 1px solid #9ac601;
color: #4F8A10;
}
.alerta {
background: url('http://cdn1.iconfinder.com/data/icons/nuvola2/32x32/actions/messagebox_warning.png') no-repeat 6px #fccac3;
border: 1px solid #db3f23;
color: #D8000C;
}
.aviso {
background: url('http://cdn3.iconfinder.com/data/icons/fatcow/32x32_0400/error.png') no-repeat 6px #ffeaa9;
border: 1px solid #f9b516;
color: #9F6000;
}
.infos {
background: url('http://cdn1.iconfinder.com/data/icons/musthave/24/Information.png') no-repeat 6px #d1e4f3;
border: 1px solid #4d8fcb;
color: #00529B;
}
Re: BBCODE Only for Staff
Hi! Actually i don't remember, I followed a tutorial long time ago, but I don't think was on the italian forum.
Re: BBCODE Only for Staff
@Simone Boi replace the first script you posted with this one:
That should make the buttons appear only to moderators. The addition to it is the 3rd line in there.
check, is looking for ordinary members. If the member has level 0 (which is simple members) it returns the editor as the default one. Otherwise it adds the buttons for members who are moderators or administrators.
I hope this is what you were looking for.
Regards,
TC.
- Code:
jQuery(function(){
if (_userdata.user_level === 0 || !document.getElementById('text_editor_textarea')) return;
jQuery(function(){
jQuery('<a class="sceditor-button sceditor-button-sucesso" unselectable="on" title="Sucesso"><div unselectable="on" style="background-image:url(https://i.imgur.com/EISZPwN.png)">Sucesso</div></a>').insertBefore('.sceditor-button-size').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[success=Risolto]","[/success]");
});
jQuery('<a class="sceditor-button sceditor-button-alerta" unselectable="on" title="Alerta"><div unselectable="on" style="background-image:url(https://i.imgur.com/lMsD0nE.png)">Alerta</div></a>').insertAfter('.sceditor-button-sucesso').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[alert=Avverimento]","[/alert]");
});
jQuery('<a class="sceditor-button sceditor-button-aviso" unselectable="on" title="Aviso"><div unselectable="on" style="background-image:url(https://i.imgur.com/cI8SnOI.png)">Aviso</div></a>').insertAfter('.sceditor-button-alerta').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[warn=Attenzione]","[/warn]");
});
jQuery('<a class="sceditor-button sceditor-button-info" unselectable="on" title="Informação"><div unselectable="on" style="background-image:url(https://i.imgur.com/40zM1qS.png)">Informação</div></a>').insertAfter('.sceditor-button-aviso').click(function(){
jQuery('#text_editor_textarea').sceditor("instance").insertText("[info=Informazioni]","[/info]");
});
});
});
That should make the buttons appear only to moderators. The addition to it is the 3rd line in there.
- Code:
if (_userdata.user_level === 0 || !document.getElementById('text_editor_textarea')) return;
|
I hope this is what you were looking for.
Regards,
TC.
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
SarkZKalie and Simone Boi like this post
Re: BBCODE Only for Staff
Hi TheCrow! That worked for buttons, thanks a lot! But if an user type the code manually, like "[success=Risolto][/success]", without using the button, still gets the effect, there is a way to negate the code for no-staff users?
Re: BBCODE Only for Staff
You cannot prevent someone from typing it manually. That will affect your quotes and all afterwards.
If for example, you type the yellow one to say Please don't double post and I use the quote to say Sorry it won't happen again. in the quote it will display as bbcode and not as quote because it is taken as if the member is typing it manually. Therefore that would make a little mess.
My suggestion to you would be to have them as they are now, and if someone uses them, give a fair warning not to use them again otherwise there will be punishments as they are only reserved for staff.
Regards,
TC.
If for example, you type the yellow one to say Please don't double post and I use the quote to say Sorry it won't happen again. in the quote it will display as bbcode and not as quote because it is taken as if the member is typing it manually. Therefore that would make a little mess.
My suggestion to you would be to have them as they are now, and if someone uses them, give a fair warning not to use them again otherwise there will be punishments as they are only reserved for staff.
Regards,
TC.
Forum of the Forums Forumotion Rules | Tips & Tricks | FAQ | Did you forget your password? |
*** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
No support via PM!
Simone Boi likes this post
Re: BBCODE Only for Staff
Oh, I guess I should just do like you say then, hope there will be a way to prevent users from use it in future, anyway thank you a lot! Atleast I can hide buttons!
Re: BBCODE Only for Staff
Problem solved & topic archived.
|
Similar topics
» How can add the BBCode Button on the title bar of BBCode Table?
» How to add bbcode?
» BBcode
» bbcode
» How do I add custom BBCode?
» How to add bbcode?
» BBcode
» bbcode
» How do I add custom BBCode?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum