PDA

View Full Version : Attachment in first post only. Disable attachments when replying to a thread.


Aurous
04-28-2004, 05:52 PM
I need my users to upload attachments only when making a new thread, so it only shows in the first post. Rest can only reply but not post attachments.

How do I implement this?

Xenon
04-28-2004, 08:21 PM
open newreply.php find this:
$forumperms = fetch_permissions($forumid);
and below add:

$forumperms = $forumperms & ~CANPOSTATTACHMENT;

that should work..

Aurous
04-29-2004, 06:32 AM
That works like a charm!

Thanks a LOT!

May God bless u!

Xenon
04-29-2004, 12:24 PM
:)

You're welcome

Boofo
04-29-2004, 12:51 PM
Stefan, what does this do in front of CANPOSTATTACHMENT?

~

I've never seen that before.

Xenon
04-29-2004, 12:55 PM
i hardle believe you've never seen it before, as it's on every vb3 php file at the top

error_reprtin(E_ALL & ~E_NOTICE);

and it stands for the bit-wise not operator, as permissions are stored in a bitfield, you have to use bitoperators lie & ~ or |

Boofo
04-29-2004, 01:39 PM
i hardle believe you've never seen it before, as it's on every vb3 php file at the top

error_reprtin(E_ALL & ~E_NOTICE);

and it stands for the bit-wise not operator, as permissions are stored in a bitfield, you have to use bitoperators lie & ~ or |

You're right. I guess I never paid that much attention to it before. How do you know which one to use when?

Xenon
04-29-2004, 04:07 PM
Well, it's just binary logic.

You just have to know what you want.

Here for example if you want to know if someone has the permission to add an attachment, you would use this.

if ($forumperms & CANPOSTATTACHMENT)

if you want to know if a user has every permission EXCEPT adding attachments, you would use ~ before.
and so on.

You just have to use it a few times, and then you will get into it :)

Aurous
05-07-2004, 05:14 PM
Also, is it possible to limit this to a few forums not all?

Xenon
05-07-2004, 10:41 PM
if (in_array($foruminfo['forumid'], array(x,y,z)))
{
$forumperms = $forumperms & ~CANPOSTATTACHMENT;
}

replacing the x,y,z with a list of forumids where it's restricted :)

Aurous
05-11-2004, 08:13 AM
well people cant post any attachment while making a new reply, but can always edit the post and add attachments. :rolleyes:

Xenon
05-11-2004, 10:45 AM
you can add the same piece of code into editpost.php as well, which will prevent that as well.

if you chang it a little bit in editpost.php you get exactly, what you want:

if (in_array($foruminfo['forumid'], array(x,y,z)) AND $threadinfo['firstpostid'] != $postinfo['postid'])
{
$forumperms = $forumperms & ~CANPOSTATTACHMENT;
}

Aurous
05-11-2004, 11:07 AM
Thanks a lot. I knew I had to add the same bit in editpost.php but wasnt sure of the firstpost edit.

BTW, you can edit your code so others dont get confused:

$postinfo['postid])

to

$postinfo['postid'])

Xenon
05-11-2004, 12:33 PM
:)
you're welcome

btw: thx, fixed :)