Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Aaron on January 10, 2007, 12:43:06 PM

Title: Modbreak tag
Post by: Aaron on January 10, 2007, 12:43:06 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=622)

This mod adds a modbreak-tag to your forum. A modbreak is basically a tool for your moderators to make a clear statement in a topic, using a fieldset with a legend.

Possible usage:
[modbreak]
You aren't allowed to swear on this forum!
[/modbreak]

Will return (HTML):
<fieldset class="modbreak">
<legend>Modbreak</legend>
You aren't allowed to swear on this forum!
</fieldset>

Another possible use is:
[modbreak=Edit by Aaron]
I removed the link to a warez site!
[/modbreak]

Will return (HTML):
<fieldset class="modbreak">
<legend>Edit by Aaron</legend>
I removed the link to a warez site!
</fieldset>

Should you wish to style the modbreak (which isn't done by default), you can add the following lines to your theme's style.css:

Code: [Select]
.modbreak
{
border: 1px solid #000000;
}

.modbreak legend
{
color: #DD0000;
font-weight: bold;
}

I hope you find this mod useful. ;)
Title: Re: Modbreak tag
Post by: apollonios on January 10, 2007, 03:55:02 PM
Very nice and usefull mod!
I like it!  :) :) :)
Title: Re: Modbreak tag
Post by: Demeandor on January 10, 2007, 04:33:28 PM
Simple and efficient. I like it as welll :)
Title: Re: Modbreak tag
Post by: Skipdawg on January 10, 2007, 09:46:01 PM
This looks like it could be very useful thanks.  ;)
Title: Re: Modbreak tag
Post by: Skipdawg on January 10, 2007, 10:15:54 PM
OK were do you activate this? Installed fine but see no place to make use of it anywhere!  :o :( ::) ???
Title: Re: Modbreak tag
Post by: jasuk70 on January 11, 2007, 05:36:10 AM
Found it useful. Makes it much easier to see that a mod had changed something. Cheers.
Title: Re: Modbreak tag
Post by: Greek on January 11, 2007, 06:39:59 AM
Thanks!

What about if there is a modbreak button, visible only to admin?  ;)
Title: Re: Modbreak tag
Post by: Aaron on January 11, 2007, 09:05:34 AM
OK were do you activate this? Installed fine but see no place to make use of it anywhere!  :o :( ::) ???

You don't have to configure or activate it anywhere - you can just use the BBC-code in the post screen. :)

What about if there is a modbreak button, visible only to admin?  ;)

I might add that in a newer version.
Title: Re: Modbreak tag
Post by: Skipdawg on January 11, 2007, 01:00:19 PM
Well I am not seeing anything from this Mod. Must be conflicting with something else. If you update it for the next version I may take a look at it then. Just don't have the spare time to trouble shoot and figure out what is going on with it. Sounds good though.  ;)
Title: Re: Modbreak tag
Post by: Aaron on January 11, 2007, 01:27:20 PM
Could you try installing it, and then post a message (or preview one) in a random topic, containing:

Code: [Select]
[modbreak]
You aren't allowed to swear on this forum!
[/modbreak]

Then you *should* see it parsed as a fieldset. :)
Title: Re: Modbreak tag
Post by: cave on January 11, 2007, 02:03:34 PM
What about if there is a modbreak button, visible only to admin?  ;)

I might add that in a newer version.

I think it would be better if we could set the permissons for this bbc-code :)
Title: Re: Modbreak tag
Post by: aperseghin on January 11, 2007, 02:28:00 PM
Can i change the word "ModBreak" anywhere??
Title: Re: Modbreak tag
Post by: bigmohi on January 11, 2007, 02:41:43 PM
very nice mod, thank you
if you can update it with permission and button, would be a perfect one!!
Title: Re: Modbreak tag
Post by: Aaron on January 11, 2007, 03:22:54 PM
I think it would be better if we could set the permissons for this bbc-code :)

I thought about that, but then a user wouldn't be able to quote a modbreak properly, if you get what I mean. :-\

Can i change the word "ModBreak" anywhere??

You'd have to manually edit it in Subs.php.
Title: Re: Modbreak tag
Post by: Kris on January 12, 2007, 05:16:12 PM
but it means any user can use this tag?
or only moderators?
Title: Re: Modbreak tag
Post by: Aaron on January 12, 2007, 05:30:18 PM
but it means any user can use this tag?
or only moderators?

Any user. :)
Title: Re: Modbreak tag
Post by: Tanks on January 13, 2007, 05:38:16 AM
Just only tell your moderators about the mod. Any user dont have to know  :D

Thanks for this - i am using it and its really good.

Here is the CSS i use for this mod

.modbreak
{
   border: 1px solid #000000;
background-color: #FFFBEF;
   border-top: 1px solid #333;
   border-left: 1px solid #333;
   border-right: 1px solid #ccc;
   border-bottom: 1px solid #ccc;
   margin: 1px 11px 11px 11px;
   padding: 8px;
   font-weight: bold;
}

.modbreak legend
{
   color: #DD0000;
   font-weight: bold;
}
Title: Re: Modbreak tag
Post by: Mr. Jinx on January 13, 2007, 06:10:43 AM
Just only tell your moderators about the mod. Any user dont have to know  :D

Very usefull mod, however my users will find out about this tag anyway.
If they just quote a topic, they will see the tags and abuse them.
Title: Re: Modbreak tag
Post by: Tanks on January 13, 2007, 06:54:38 AM
So make it in your rules that this tag is only to be used by mods and that mods will take actions against any abuse.  ;)

Or just dont use it  :D
Title: Re: Modbreak tag
Post by: THE BRA1N on January 13, 2007, 09:08:14 PM
Very nice. Would be great if the use of it could be restricted in the future though.
Title: Re: Modbreak tag
Post by: Kris on January 14, 2007, 04:10:31 AM
So make it in your rules that this tag is only to be used by mods and that mods will take actions against any abuse.  ;)

Or just dont use it  :D

(http://www.simplemachines.org/community/Themes/default/images/post/thumbup.gif)
Title: Re: Modbreak tag
Post by: DaBoROE09 on January 14, 2007, 09:19:13 AM
love this mod
Title: Re: Modbreak tag
Post by: Tanix on January 15, 2007, 10:53:29 PM
Excellent mod, thank you.

And I agree with Knat and Kris: you can't and shouldn't try to code for every eventuality. A simple rule should be enough.
Title: Re: Modbreak tag
Post by: edi67 on January 16, 2007, 01:08:52 AM
very useful mod and very useful if will be possible have BBC button for apply it , visible only to Staff
Title: Re: Modbreak tag
Post by: 0uK^- on January 16, 2007, 01:22:48 AM
Hi there.

I want this mod but is only normal bbcode.

Can you do it like this mod for phpbb:

Moderation BBCode (http://www.phpbbhacks.com/download/812)

Thanks
Title: Re: Modbreak tag
Post by: Farmacija on January 16, 2007, 03:59:32 AM
yes its needed button which is visible just for moderators and only then this mod will be completely usefull
Title: Re: Modbreak tag
Post by: [Lucien] on January 31, 2007, 09:57:39 AM
Aäron, thank you very much for this wonderfull mod, i really love it!!

Just only tell your moderators about the mod. Any user dont have to know  :D

Thanks for this - i am using it and its really good.

Here is the CSS i use for this mod

.modbreak
{
   border: 1px solid #000000;
background-color: #FFFBEF;
   border-top: 1px solid #333;
   border-left: 1px solid #333;
   border-right: 1px solid #ccc;
   border-bottom: 1px solid #ccc;
   margin: 1px 11px 11px 11px;
   padding: 8px;
   font-weight: bold;
}

.modbreak legend
{
   color: #DD0000;
   font-weight: bold;
}

And thank you for posting this, i only removed the background color, it looks so cool now :D
 
Title: Re: Modbreak tag
Post by: Vinspire on January 31, 2007, 10:15:05 PM
Any screenshot for this mod ? Thanks :)
Title: Re: Modbreak tag
Post by: Tanks on February 01, 2007, 06:28:42 AM
screenshot is in Danish but i think you get the picture  ;)

(http://img209.imageshack.us/img209/3697/modbreakyl6.th.jpg) (http://img209.imageshack.us/my.php?image=modbreakyl6.jpg)
Title: Re: Modbreak tag
Post by: buhaychat.com on February 01, 2007, 01:10:42 PM
Very useful mod, really great - I installed it ages ago but only really used it today... helpful! Thanks for it!
Title: Re: Modbreak tag
Post by: Farmacija on February 02, 2007, 07:10:57 AM
still button is needed

Title: Re: Modbreak tag
Post by: perplexed on February 06, 2007, 10:21:40 AM
ok so as I understand it, it adds bbc code to enable a mod to add the break thingy in a post as per screenshot, but theres no button, so you have to tell the mods what the code is, and anyone who knows the code, can use it?  I suppose that would work as people are less inclined to use something if there's no button, no one is going to use it unless they want to cause trouble right?  So a rule about misusing it should suffice.
Title: Re: Modbreak tag
Post by: Tanix on February 06, 2007, 02:06:08 PM
ok so as I understand it, it adds bbc code to enable a mod to add the break thingy in a post as per screenshot, but theres no button, so you have to tell the mods what the code is, and anyone who knows the code, can use it?  I suppose that would work as people are less inclined to use something if there's no button, no one is going to use it unless they want to cause trouble right?  So a rule about misusing it should suffice.

Got it in one - and yes, a rule should suffice. That's the way I'm using the mod.
Title: Re: Modbreak tag
Post by: Assistance on February 06, 2007, 02:25:20 PM
if (in_array('1',$GLOBALS['user_info']['groups']) || in_array('2',$GLOBALS['user_info']['groups']))
{

before the array to show only to admins mods

sure someone could do that eh
Title: Re: Modbreak tag
Post by: Mr. Jinx on February 06, 2007, 03:13:50 PM
So make it in your rules that this tag is only to be used by mods and that mods will take actions against any abuse.  ;)

Or just dont use it  :D

(http://www.simplemachines.org/community/Themes/default/images/post/thumbup.gif)

Yeah rite, then my mods have to check if people are abusing this mod. What a stupid idea :o ???
Title: Re: Modbreak tag
Post by: perplexed on February 07, 2007, 08:01:53 AM
I suppose that would be easy to spot since they should be reading the posts anyway and would see if a non-mod was using it

I would still be happier if it was based on permissions
Title: Re: Modbreak tag
Post by: aperseghin on February 07, 2007, 11:04:52 AM
thnx
 
Title: Re: Modbreak tag
Post by: Aaron on February 07, 2007, 12:29:06 PM
I'll see what I can do regarding the feature requests for the next version. I think I'll implement the following two:

I can't promise an exact date, as I'm rather busy in real life, but I'll do my best. :)
Title: Re: Modbreak tag
Post by: perplexed on February 07, 2007, 01:43:39 PM
cool aaron :)
Title: Re: Modbreak tag
Post by: detportal on March 17, 2007, 05:45:59 AM
you can use the BBCode Permission Mod to control which membergroups can use it.
and to change "modbreak" you edit the legend variable in subs.php


 
Title: Re: Modbreak tag
Post by: Aaron on March 18, 2007, 05:52:47 AM
you can use the BBCode Permission Mod to control which membergroups can use it.

Nice, thanks for sharing.

and to change "modbreak" you edit the legend variable in subs.php

Not necessarily. Using [modbreak=Type your legend here]text[/modbreak] will suffice. ;)
Title: Re: Modbreak tag
Post by: [Lucien] on May 09, 2007, 02:08:13 PM
Can this mod please be updated for 1.1.2 ?  ;) Recently moved to another server and i want to reinstall this mod.

Thnx!
Title: Re: Modbreak tag
Post by: nuva on May 15, 2007, 03:43:43 PM
THNX Aäron i first tryed to make one with custom BBC
but this one is much better!!! ;)
Title: Re: Modbreak tag
Post by: Tanks on May 21, 2007, 03:29:21 PM
I want to thank you again i found a great use for your mod..  THANK YOU !  ;D

I never really used the modbreak because i simply forgot about it.. and i didnt have a bbc button for it..

Anyway i needed a tag for passwords because we post many password protected files on my board..

(http://pixfarm.net/upload/2/originals/e1/e1e0ebb829234109a8a7bcd70bfeb9be.jpg)
http://pixfarm.net/upload/2/originals/e1/e1e0ebb829234109a8a7bcd70bfeb9be.jpg
So i made my first bbc button  :)

(http://pixfarm.net/upload/2/originals/51/51aa937be92d210d916089d9db575e51.jpg)
http://pixfarm.net/upload/2/originals/51/51aa937be92d210d916089d9db575e51.jpg
To insert this code

(http://pixfarm.net/upload/2/originals/04/043da3d051f8bb11007aa9574bedc11e.jpg)
http://pixfarm.net/upload/2/originals/04/043da3d051f8bb11007aa9574bedc11e.jpg
And this is how it looks after its posted  8)

Very useful to my community ...  :P

somehow this forum makes images smaller so click the links to see original images  >:(

Title: Re: Modbreak tag
Post by: Hµïkámà on October 11, 2007, 09:59:16 AM
Hhm, Tanks, do you have some sort of .htaccess trick to cancel al the images at other pages, because I only see an img with PixFarm.net

And, my problem was: I can't use this in 1.1.3?
Title: Re: Modbreak tag
Post by: MinasC on October 11, 2007, 11:29:37 AM
it's a great mod but it REALLY needs to work in 1.1.3 , have a button , and be permission based (not for all users to use) ! i hope aaron gets those soon !
Title: Re: Modbreak tag
Post by: dave007 on November 24, 2007, 08:13:12 AM
it doesn't work for me. ..
Title: Re: Modbreak tag
Post by: Aaron on December 01, 2007, 08:52:13 AM
It should be working in both SMF 1.1.3 and SMF 1.1.4. Could you give some more information, e.g. errors?

it's a great mod but it REALLY needs to work in 1.1.3 , have a button , and be permission based (not for all users to use) ! i hope aaron gets those soon !

I definitely agree, but I'm afraid I simply don't have time to look into that now. I'll put it on my todo list for the next version of the mod though. :)
Title: Re: Modbreak tag
Post by: MinasC on December 01, 2007, 12:04:44 PM
fair enough , thnx !
Title: Re: Modbreak tag
Post by: [Lucien] on December 07, 2007, 11:44:45 AM
Quote

I definitely agree, but I'm afraid I simply don't have time to look into that now. I'll put it on my todo list for the next version of the mod though. :)

Yes thank you! Really want to use this mod again  :)
Title: Re: Modbreak tag
Post by: Aaron on March 18, 2008, 02:39:29 AM
Added a package for use with SMF 2.0 beta 3 public to the mod site. Haven't had time for any other updates yet.
Title: Re: Modbreak tag
Post by: GreenStork on September 03, 2008, 08:35:10 AM
Aäron - thank you very much for this mod! (http://s.rimg.info/5962bb18d0aff8d7b1a22b492ef7b499.gif)
Title: Re: Modbreak tag
Post by: Frozt on October 14, 2008, 09:01:07 AM
work in 2.0 Beta 4

thanks!
Title: Re: Modbreak tag
Post by: edi67 on October 24, 2008, 05:05:48 AM
thx work perfectly look screen  ;)
Title: Re: Modbreak tag
Post by: Relemar on October 29, 2008, 06:40:51 PM
how do i make it so only specified groups can use it like moderator, super moderator and admin.

everyone can use it :/ but its good, thanks mate
Title: Re: Modbreak tag
Post by: Cal O'Shaw on January 28, 2009, 12:44:17 AM
Aaron,

Imagine you're still quite busy, but is it possible to look at adding the ability to change the default text?  Ideally, I'd like to see the default be something like "Moderation Warning" and perhaps be able to change the css setting via AdminCP.  I know I can edit, and it isn't hard to do, but my concern is if I have to back this out for some reason, such as a new version (which is why it might be helpful to have each new version of this MOD include the version number in the package filename, to allow uploading the new version and a quick uninstall old/install new operation).

To be honest, setting the BBC for permissions would be nice, but what happens when a post with a modbreak gets quoted?  Would permissions break the quote?  Wouldn't the quoter see the BBC?  So, as annoying as it may be to some, the easiest solution is to tell members if they use it, they are in BIG trouble.

Now, if a BBC BUTTON only appears if the poster has the permission to use it, THAT would make things much easier for the moderators who don't use it that often.  But I don't see how the actual BBC can be restricted.  And that may be a lot more work than changing the AdminCP to insert a value into $legend (which will likely need to be redefined globally as $modbreak_legend to avoid anyone walking on it ;) ).

Another great MOD Aaron!

Grazie mille!

Cal
Title: Re: Modbreak tag
Post by: SgtMic on February 06, 2009, 04:52:17 PM
Still hoping for a permission based modbreak.
Title: Re: Modbreak tag
Post by: Cal O'Shaw on February 06, 2009, 06:32:06 PM
I've used the BBC Moderation MOD in combination with Modbreak but the permission MOD has a bug (do NOT click to enable all, that disables all).  It would be better not to use that MOD.
Title: Re: Modbreak tag
Post by: Cal O'Shaw on February 16, 2009, 02:02:36 AM
Aaron,

Hoping to not sound presumptive, but an example of the AdminCP code needed to edit the CSS for Modbreak can be found in the PM Informer MOD located here (http://custom.simplemachines.org/mods/index.php?mod=1202).
Title: Re: Modbreak tag
Post by: d0brin on February 19, 2009, 03:30:36 PM
Can this mode be update for smf 1.1.8 pls :)
Title: Re: Modbreak tag
Post by: Aaron on February 20, 2009, 04:42:17 AM
Can this mode be update for smf 1.1.8 pls :)

It doesn't need to be updated. It'll work just fine on SMF 1.1.8. ;)
Title: Re: Modbreak tag
Post by: PerryM on February 20, 2009, 01:28:05 PM
Nice feature but can it be called something besides [modbreak]
 
How about [Moderator Comment]
 
My users and I speak English and Geek Speak is something we try to avoid.
Title: Re: Modbreak tag
Post by: Propaganistas on March 01, 2009, 09:12:52 AM
Nice feature but can it be called something besides [modbreak]
 
How about [Moderator Comment]
 
My users and I speak English and Geek Speak is something we try to avoid.

Sure,
to install it using your tag, unzip and open install.xml, or if you have it already installed open Sources/Subs.php:

Code: (find) [Select]
$legend = 'modbreak';
Code: (replace) [Select]
$legend = 'Moderator Comment';
Execute this twice, as there are two of these pieces:
Code: (find) [Select]
'tag' => 'modbreak',
Code: (replace) [Select]
'tag' => 'Moderator Comment',
Additionally, if you want it to be only used by Moderators, take a look at this post (http://www.simplemachines.org/community/index.php?topic=293440.msg1935373#msg1935373). This actually erases the tag when a non-moderator tries to edit his/her post.  It only works for the normal tag (without equation mark) though.

Greetz
Title: Re: Modbreak tag
Post by: Pandabeer on April 27, 2009, 07:31:10 AM
nvm i made this:

// Modbreak function
function get_modbreak($content, $name = null)
{
global $txt, $settings, $context, $modSettings;

$legend = 'Modbreak by ' . $name;

    if(empty($name))
return 'Im a noob because i fake a modbreak =)';

return '
<fieldset class="modbreak"><legend>' . $legend . '</legend>' . $content . '</fieldset>';
}
Title: Re: Modbreak tag
Post by: TheDeath on May 15, 2009, 07:58:06 AM
Hello all.

1: Thank Aäron for this great mod.
I have this installed on SMF2.0 RC1 and the moderator's of the board are very happy ;).

2: Many people have question about BBC-Button.
The code at the end, add the BBC-Button in SMF2.0 RC1.
All user with permission "moderate_board" can see the button.

3: You must create a new BBC-Button Image,  and copy it to your
./Themes/default/images/bbc   directory.
The name of button image must be "modbreak.gif".
I have rename another bbc button for test.

4: Maybe someone can create a new button and post it in thread, thanks.


$sourcedir/Subs-Editor.php 
search:
Code: [Select]
// Show the toggle?
if (empty($modSettings['disable_wysiwyg']))
{
$context['bbc_tags'][1][] = array();
$context['bbc_tags'][1]['unformat'] = array('code' => 'unformat', 'before' => '', 'description' => $txt['unformat_text']);
$context['bbc_tags'][1]['toggle'] = array('code' => 'toggle', 'before' => '', 'description' => $txt['toggle_view']);
}

add after:
Code: [Select]

// ######## BBC Button for MODBREAK ######################################################################################################
if (allowedTo('moderate_board'))
{
$context['bbc_tags'][1][] = array();
$context['bbc_tags'][1]['modbreak'] = array('code' => 'modbreak', 'before' => '[modbreak]', 'after' => '[/modbreak]', 'description' => $txt['modbreak']);
}
// #######################################################################################################################################



./Themes/default/languages/post.english.php
search:
Code: [Select]
$txt['unformat_text'] = 'Remove Formatting';

add after:
Code: [Select]
$txt['modbreak'] = 'Moderator Break';

./Themes/default/languages/Post.german-utf8.php
search:
Code: [Select]
$txt['unformat_text'] = 'Formatierung entfernen';

add after:
Code: [Select]
$txt['modbreak'] = 'Moderator Kommentar';


Sorry for my bad english. ;)
Title: Re: Modbreak tag
Post by: Cal O'Shaw on May 16, 2009, 02:19:38 AM
How could that 'moderate_board" conditional be added to the 1.1.x code?

The bloody PERMISSIONS MOD keeps breaking other mods that utilise permissions and the only reason I installed the blasted PERMISSIONS MOD is to protect MODBREAK from abuse.  If this "moderate_board" check could be implemented I could get rid of PERMISSIONS MOD and not get frantic emails that all the formatting tags are disabled (because PERMISSIONS felt like it).

Grazie,

Cal (using 1.1.8)
Title: Re: Modbreak tag
Post by: TheDeath on May 16, 2009, 08:27:54 AM
HI Cal,

you can it make so. I have testet with SMF 1.1.8.

./Themes/default/Post.template.php
search:
Code: [Select]
'list' => array('code' => 'list', 'before' => '[list]\n[li]', 'after' => '[/li]\n[li][/li]\n[/list]', 'description' => $txt[261]),
);

add after:
Code: [Select]

// ######## BBC Button for MODBREAK ######################################################################################################
if (allowedTo('moderate_board'))
{
$context['bbc_tags'][1][] = array();
$context['bbc_tags'][1]['modbreak'] = array('code' => 'modbreak', 'before' => '[modbreak]', 'after' => '[/modbreak]', 'description' => $txt['modbreak']);
}
// #######################################################################################################################################
Title: Re: Modbreak tag
Post by: Cal O'Shaw on May 17, 2009, 12:56:21 AM
Hello,

I'm sorry, I didn't make clear what I needed to do.

Your fix certainly does take care of not displaying a MODBREAK BBC icon unless one is authorised to moderate that board.

Unfortunately, someone NOT a moderator can type the characters "[modbreak]I am not authorised but here is a MODBREAK BOX anyway![/modbreak]" and create the MODBREAK anyway.


But perhaps the allowedTo logic can be used where the MODBREAK BBC tag gets processed?


In the meantime it looks like the PERMISSION MOD continues to be used... foo...

Cal
Title: Re: Modbreak tag
Post by: Cal O'Shaw on May 17, 2009, 02:12:09 AM
And now I turn around and say grazie mille TheDeath!

I took the allowedTo logic and made an absurdly simple fix to limit MODBREAK making boxes only where the author is allowed to do it.  And where they can't, such as moderators trying to do it in a board they don't moderate, it resolves to an error message.

This is in Sources/Subs.php

Code: (locate) [Select]
// Modbreak function
function get_modbreak($content, $legend = null)
{
global $txt, $settings, $context, $modSettings;

if (empty($legend))
$legend = 'Modbreak';


Code: ( add after) [Select]
if (allowedTo('moderate_board'))

Code: (locate) [Select]
return '
<fieldset class="modbreak"><legend>' . $legend . '</legend>' . $content . '</fieldset>';

Code: (add after) [Select]
else return '<span style="color: red;">Sorry, you are not authorised to use MODBREAK here.</span>
';


I'm pretty sure this is solid, after testing with users, moderators, and global moderators, but if anyone wants to double-check.

Aaron, if this meets with your approval, would you consider integrating it formally into MODBREAK?  (This didn't work right... it hides MODBREAKs from regular members)

Many thanks to Aaron for creating MODBREAK and TheDeath for giving me the pieces to find a fix.

Now I can get rid of PERMISSIONS MOD!!!

Cal
Title: Re: Modbreak tag
Post by: TheDeath on May 17, 2009, 09:25:57 AM
Hi Cal,

then I use your change, the user that can't moderate board see "Sorry, you are not authorised to use MODBREAK here" and not the Modbreak that have a moderator wrote.


About your code, you can it write so:
Code: [Select]

if (empty($legend))
$legend = 'Moderator Comment';

if (!allowedTo('moderate_board'))
return '<span style="color: red;">Sorry, you are not authorised to use MODBREAK here.</span>';

return '<fieldset class="modbreak"><legend>' . $legend . '</legend>' . $content . '</fieldset>';

Title: Re: Modbreak tag
Post by: Cal O'Shaw on May 18, 2009, 04:00:32 AM
This is what I get for not testing every permutation.  Regular members can't see the MODBREAK.

There is clearly a way to prevent posters from using the modbreak tag.  I suspect that if the allowedTo test can be performed where the modbreak tag is defined into 2 arrays, then I can stop regular members from using it.

Here is the MODBREAK BBC definition code in the Subs.php file:
Code: (MODBREAK BBC definition arrays) [Select]
array(
'tag' => 'modbreak',
'type' => 'unparsed_content',
'content' => '$1',
'block_level' => true,
'validate' => create_function('&$tag, &$data, $disabled', '$data = get_modbreak(parse_bbc($data, ' . ($smileys ? 'true' : 'false') . ',\'' . $cache_id . '\'));'),
),
array(
'tag' => 'modbreak',
'type' => 'unparsed_equals_content',
'content' => '$1',
'block_level' => true,
'validate' => create_function('&$tag, &$data, $disabled', '$data[0] = get_modbreak(parse_bbc($data[0], ' . ($smileys ? 'true' : 'false') . ',\'' . $cache_id . '\'), $data[1]);'),
),

I don't know PHP well enough to edit the array entries to add the allowedTo logic. 

However, it seems the place to use the allowedTo is on the 'validate' line in the create_function.  But just adding 'if (!allowedTo('moderate_board'))' before '$date[0]=' or after it breaks the code, so I know there is a bit more (global allowedTo()?).

Does that make sense?  Will this stop people trying to create posts from using MODBREAK but still allow everyone to see the MODBREAK?

I do appreciate all the time you are spending on this.

Grazie,

Cal
Title: Re: Modbreak tag
Post by: TheDeath on May 18, 2009, 04:59:08 AM
Hello Cal,

in the File "./Sources/Subs-Post.php" is a function with name
function preparsecode(&$message, $previewing = false)
The function Parses some bbc before sending into the database.

A other good position is in "./Sources/Post.php".

Search for:
// Check the subject and message.
if (!isset($_POST['subject']) || $func['htmltrim']($_POST['subject']) === '')
$post_errors[] = 'no_subject';
if (!isset($_POST['message']) || $func['htmltrim']($_POST['message']) === '')
$post_errors[] = 'no_message';
elseif (!empty($modSettings['max_messageLength']) && $func['strlen']($_POST['message']) > $modSettings['max_messageLength'])
$post_errors[] = 'long_message';
else
{
// Prepare the message a bit for some additional testing.
$_POST['message'] = $func['htmlspecialchars']($_POST['message'], ENT_QUOTES);

// Preparse code. (Zef)
if ($user_info['is_guest'])
$user_info['name'] = $_POST['guestname'];
preparsecode($_POST['message']);    // <-- her is the function, that check BBC-Code !!!!

// Let's see if there's still some content left without the tags.
if ($func['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), '<img>')) === '')
$post_errors[] = 'no_message';
}


How can parse messagetext for modbreak an can generate a errormessage.

When I have time, I show how can eliminate modbreak tag for regular members.
Title: Re: Modbreak tag
Post by: Mr. Jinx on May 23, 2009, 08:19:40 AM
@Cal O'Shaw:
Did you take a look at this mod?
http://www.simplemachines.org/community/index.php?topic=293440.0
Works for me, allowing only moderators to use the modbreak tag.

Sources/Subs-Post.php

Code: (find) [Select]
if (!$previewing && strpos($parts[$i], '[html]') !== false)
{
if (allowedTo('admin_forum'))
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'&#13;\', \'  \' => \' &#32;\')) . \'[/html]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
{
while (strpos($parts[$i], '[html]') !== false)
$parts[$i] = preg_replace('~\[[/]?html\]~i', '', $parts[$i]);
}
}



Code: (replace with) [Select]
if (!$previewing && strpos($parts[$i], '[html]') !== false)
{
if (allowedTo('admin_forum'))
$parts[$i] = preg_replace('~\[html\](.+?)\[/html\]~ise', '\'[html]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'&#13;\', \'  \' => \' &#32;\')) . \'[/html]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
{
while (strpos($parts[$i], '[html]') !== false)
$parts[$i] = preg_replace('~\[[/]?html\]~i', '', $parts[$i]);
}
}

    if (!$previewing && strpos($parts[$i], '[modbreak]') !== false)
{
if (allowedTo('moderate_board'))
$parts[$i] = preg_replace('~\[modbreak\](.+?)\[/modbreak\]~ise', '\'[modbreak]\' . strtr(un_htmlspecialchars(\'$1\'), array("\n" => \'&#13;\', \'  \' => \' &#32;\')) . \'[/modbreak]\'', $parts[$i]);
// We should edit them out, or else if an admin edits the message they will get shown...
else
{
while (strpos($parts[$i], '[modbreak]') !== false)
$parts[$i] = preg_replace('~\[[/]?modbreak\]~i', '', $parts[$i]);
}
}
Title: Re: Modbreak tag
Post by: Cal O'Shaw on May 24, 2009, 05:58:35 PM
@Mr. Jinx,

That did the trick!  Grazie!

So, now...

Aaron, would you consider adding the code to modify Subs-post.php as given in Reply #72 above?  It would be greatly appreciated.

Cal
Title: Re: Modbreak tag
Post by: Arantor on June 02, 2009, 10:49:45 AM
The above code in Reply #72 is good but it doesn't have the additional ability to filter out [modbreak=title] comments.

Code: (remove) [Select]
while (strpos($parts[$i], '[modbreak]') !== false)
$parts[$i] = preg_replace('~\##/]?modbreak\]~i', '', $parts[$i]);

Code: (replace with) [Select]
$parts[$i] = preg_replace('~\##/]?modbreak(=[^\]]*)?\]~i', '', $parts[$i]);

Note: the two # symbols should be replaced with [ symbols - the wiki links mod prevented me from posting otherwise.
Title: Re: Modbreak tag
Post by: coldy316 on June 08, 2009, 01:57:33 PM
I understand all that but where in the style.css do you add the code
this part
Code: [Select]
.modbreak
{
border: 1px solid #000000;
}

.modbreak legend
{
color: #DD0000;
font-weight: bold;
}
Title: Re: Modbreak tag
Post by: Mr. Jinx on June 12, 2009, 12:06:59 PM
Code: (replace with) [Select]
$parts[$i] = preg_replace('~\##/]?modbreak(=[^\]]*)?\]~i', '', $parts[$i]);

Thanks Arantor!
Title: Re: Modbreak tag
Post by: Blinker on July 05, 2009, 06:57:29 AM
I was looking for a way to restrict non admins or mods using the modbreak tag (I haven't bothered with a button yet). I read through a bunch of posts and thought "there must be an easier way".

Did anyone try this mod - http://custom.simplemachines.org/mods/index.php?mod=449 ? It installed just fine on 1.1.9 (although it says 1.1.2). I simply unticked modbreak from the list of BBCode in the permissions for my main membergroups and that was it. Simple.

Forgive me if this has been discussed already, I didn't notice it.
Title: Re: Modbreak tag
Post by: Arantor on July 05, 2009, 06:58:56 AM
Blinker - the modifications I mention above do just that.
Title: Re: Modbreak tag
Post by: Blinker on July 05, 2009, 07:11:28 AM
Was that the subs-post edits? Cool.

The BBC Permissions mod also works for [modbreak=Custom Title] instances and I guess the added benefit is I can use it for any future custom BBC I choose to add.

Quick question Arantor - does the subs-post edit option simply show the unparsed code or does it stop the user with an error message? Stopping them entirely would be preferable so let me know and I may switch to that hack instead.
Title: Re: Modbreak tag
Post by: Arantor on July 05, 2009, 07:48:14 AM
It strips it, exactly as it would if the user tried to use [ html ] in their post.
Title: Re: Modbreak tag
Post by: Cal O'Shaw on July 06, 2009, 01:02:47 AM
Blinker,

Regarding the BBC Permissions MOD... WARNING

The BBC permissions MOD has known bugs:

1) NEVER, EVER click on the 'select all' checkbox.  That will DISABLE ALL BBcodes for that group.

2) If you add or remove a MOD that involves permissions, check all groups BY TESTING, not by looking at Permissions, to see if the BBCodes are disabled for one or more groups.  If so, you must then uninstall the BBC Permissions MOD, install the MOD that you are adding that uses permissions, and then install the BBC Permissions MOD.


This is why, back at Reply 72, and updated by Arantor's adjustment in Reply 74, you see the work that was done trying to find a way to assign permissions within the MOD itself, rather than using the BBC Permissions MOD (and hoping that when Aaron has the opportunity, he'll integrate this already developed code into the official version of this MOD).

You really do NOT want to use the BBC Permissions MOD unless you have the time to make sure it does not break permissions for other groups whenever you alter any Permissions.

Just trying to save you a lot of pain...

Cal
Title: Re: Modbreak tag
Post by: Blinker on July 06, 2009, 02:56:34 AM
Hey Cal

Thanks for the heads up. I hate it when things are too good to be true.

In an effort to avoid everything you mentioned I think I'll uninstall the BBC Permissions mod and update the subs code from those posts.

To be honest no one has actually tried to use modbreak, in fact, only those members who may have clicked modify on their posts AFTER I'd used modbreak on it would even know about the tag in the first place. LOL, I guess I was just launching a pre-emptive strike...;)

Thanks

Blinker
Title: Re: Modbreak tag
Post by: Relemar on August 16, 2009, 10:12:33 AM
how to change the <modbreak></modbreak to just <mod> </mod>
Title: Re: Modbreak tag
Post by: Arantor on August 16, 2009, 10:29:00 AM
It depends; are you using the basic version of the BBcode as per the mod itself, or are you looking to use the additional tweaks others have included (such as my modification that blocks non-admin and non-moderator use)?
Title: Re: Modbreak tag
Post by: Relemar on August 16, 2009, 03:01:37 PM
It depends; are you using the basic version of the BBcode as per the mod itself, or are you looking to use the additional tweaks others have included (such as my modification that blocks non-admin and non-moderator use)?

Urm, i use latest smf 2 version and just installed your modbreak.. customised it a bit though, visually. so not sure at the mo we type <modbreak>fefe</modbreak> but really is long winded.

i want it the same thing just change from <modbreak> to <mod>. i want the mod to work the same, just what we type, different

superb mod btw :)
Title: Re: Modbreak tag
Post by: Relemar on August 16, 2009, 03:28:37 PM
sorted was in subs.php :) just changed bbc code cheers.
Title: Re: Modbreak tag
Post by: Arantor on August 16, 2009, 04:07:49 PM
I haven't touched this mod. I simply pointed out a few changes to it that might help stop users abusing it.

The reason I specifically asked if you were using the patches I suggested - that delete the tag should a non-admin/non-mod use it - is because it requires another change elsewhere in SMF's source.
Title: Re: Modbreak tag
Post by: Mr. Jinx on September 28, 2009, 08:26:25 AM
The above code in Reply #72 is good but it doesn't have the additional ability to filter out [modbreak=title] comments.
Code: (replace with) [Select]
$parts[$i] = preg_replace('~\##/]?modbreak(=[^\]]*)?\]~i', '', $parts[$i]);
Note: the two # symbols should be replaced with [ symbols - the wiki links mod prevented me from posting otherwise.

I just noticed that users can still use the [modbreak=message]text[/modbreak] tag.
Should the above preg_replace syntax be the correct one?
Title: Re: Modbreak tag
Post by: Arantor on September 28, 2009, 08:28:40 AM
Yes. That patch would also fix [modbreak=message] syntax from being broken.

Alternatively, you could try my variation, Moderator and Administrator Comment Tags (http://custom.simplemachines.org/mods/index.php?mod=2104), which creates three tags, [mod], [gmod] and [admin] and gives permissons to each (the first is a board specific permission, for individual board moderators, the other two are general usergroup permisisons), as well as enforcing the permissions in this way.
Title: Re: Modbreak tag
Post by: simplebeer on November 08, 2009, 11:52:12 AM
The above code in Reply #72 is good but it doesn't have the additional ability to filter out [modbreak=title] comments.
Code: (replace with) [Select]
$parts[$i] = preg_replace('~\##/]?modbreak(=[^\]]*)?\]~i', '', $parts[$i]);
Note: the two # symbols should be replaced with [ symbols - the wiki links mod prevented me from posting otherwise.

I just noticed that users can still use the [modbreak=message]text[/modbreak] tag.
Should the above preg_replace syntax be the correct one?

Were did i have to put that? Can you write all? Find? Replace?

sorted was in subs.php :) just changed bbc code cheers.

i wanted that to, my mods cant remember the word modbreak, what did you change exactly in:

Code: [Select]
// The current time with offset.
function forum_time($use_user_offset = true, $timestamp = null)
{

Add Before: [Selecteer]


// Modbreak function
function get_modbreak($content, $legend = null)
{
global $txt, $settings, $context, $modSettings;

if (empty($legend))
$legend = 'Modbreak';

return '
<fieldset class="modbreak"><legend>' . $legend . '</legend>' . $content . '</fieldset>';
}


Find: [Selecteer]


array(
'tag' => 'white',
'before' => '<span style="color: white;">',
'after' => '</span>',
),

Add After: [Selecteer]


array(
'tag' => 'modbreak',
'type' => 'unparsed_content',
'content' => '$1',
'block_level' => true,
'validate' => create_function('&$tag, &$data, $disabled', '$data = get_modbreak(parse_bbc($data, ' . ($smileys ? 'true' : 'false') . ',\'' . $cache_id . '\'));'),
),
array(
'tag' => 'modbreak',
'type' => 'unparsed_equals_content',
'content' => '$1',
'block_level' => true,
'validate' => create_function('&$tag, &$data, $disabled', '$data[0] = get_modbreak(parse_bbc($data[0], ' . ($smileys ? 'true' : 'false') . ',\'' . $cache_id . '\'), $data[1]);'),
),


Thanx!
Title: Re: Modbreak tag
Post by: Mr. Jinx on November 08, 2009, 02:34:12 PM
Were did i have to put that? Can you write all? Find? Replace?

First take a look at this: http://www.simplemachines.org/community/index.php?topic=141374.msg2073924#msg2073924
And then this reply: http://www.simplemachines.org/community/index.php?topic=141374.msg2090204#msg2090204
Title: Re: Modbreak tag
Post by: Arantor on November 08, 2009, 02:36:17 PM
I did actually do an updated version that included these fixes, plus made it permissions driven, but in a fit of madness last night I removed it from the mod site. I'll get it re-added ASAP.
Title: Re: Modbreak tag
Post by: Aaron on November 09, 2009, 02:14:46 PM
I'm removing this mod from the mod site, as I don't have enough time to keep maintaining it, and Arantor's Moderator and Administrator Comment Tags (http://custom.simplemachines.org/mods/index.php?mod=2104) mod is a much more complete alternative anyway.

Thanks to all who've used this mod, and Arantor for developing its successor. :)