Disable image/link posting for unregistered user? (Design/Themes)

by AlmostAnonymous, Friday, February 15, 2019, 17:46 (1890 days ago)

Hello, I've installed and been using MLF for a very small community for a couple of months.

Is there any way to disable the posting of outside links or graphics by an unregistered user? IE, restrict a visitor to text+font effects only?

I don't want visitors to post: links, images via the [ img ] tag, or flash.

I'm prepared to make the changes to the code myself. If that is what I need to do, can you please direct me to the relevant source files? I know PHP but Smarty templates are very new to me.

Thanks.

Avatar

Disable image/link posting for unregistered user?

by Micha ⌂, Saturday, February 16, 2019, 10:05 (1889 days ago) @ AlmostAnonymous

Hello,

I'm prepared to make the changes to the code myself.

The posting is parsed by the BBCodeParser-Class using the function html_format, here and here. A possible modification of the html_format may be the following, which adds an additional argument:

function html_format($string, $userType) {
//...
}

Dependent on the argument $userType you can enanble/disable the parser, e.g,

function html_format($string, $userType) {
//...
if($settings['bbcode_img']==1 && $userType > 0) {
  //...
}
}

If you changed the signature of the function, you have to modify the function all. Instead of using html_format($txt) you should use

html_format($txt, isset($_SESSION[$settings['session_prefix'] . 'user_type']) ? $_SESSION[$settings['session_prefix'] . 'user_type'] : -1)

in posting.inc.php.

Beside the adjusted php sources, you have to modify the SMARTY code, to restrict the buttons.


/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Disable image/link posting for unregistered user?

by AlmostAnonymous, Wednesday, February 20, 2019, 19:26 (1885 days ago) @ Micha

Thank you. That's very helpful and I think I understand that mod.

Is this code sample called at posting time or at the time the post is displayed on the forum? It appears to be at posting time.

Beside the adjusted php sources, you have to modify the SMARTY code, to restrict the buttons.

Or I could allow unregistered users to post images and simply allow the parsing to eat the disallowed tags, right?

If this button change really is necessary - As I mentioned I'm not conversant with smarty so it's nearly impossible at my current level of understanding to find that code. Can you at least list the source file and the identifier(s) near where I would do this?

Avatar

Disable image/link posting for unregistered user?

by Micha ⌂, Thursday, February 21, 2019, 07:03 (1884 days ago) @ AlmostAnonymous

Hi,

Is this code sample called at posting time or at the time the post is displayed on the forum?

You are rigth. The code is called during the submission of the posting and not on displaying.

Or I could allow unregistered users to post images and simply allow the parsing to eat the disallowed tags, right?

Yes.

If this button change really is necessary

No, it is an optical part. The img-button becomes useless for unregistered users.

Can you at least list the source file and the identifier(s) near where I would do this?

Each pho file has its corresponding template file, e.g. posting.inc.tpl. In line 170ff, the bb-codes button are defined. Using a if-else condition, you can restrict displaying the button.

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

RSS Feed of thread