Firefox PHP

How to correctly make a hook?

Posted by Panu 
How to correctly make a hook?
May 17, 2003 12:27PM
I haven't heard anything about post_post_hook so I tried to put it in the source myself. Looking at the other hooks I figured it must be something like:

$message = phorum_hook("post_post", $message);

I'm not sure how critical the plcement is but I put it inside

if($success && empty($error)){

in the end of post.php

I also needed a checkbox in the post_form so I had to add it, and then I had to import that post-value into $message-array in post.php. I'm not sure why I could not read that value in my function directly from $_POST?

Question: Is there some way to add that checkbox on the fly (or others), so no manual modification of the template would be needed? I restricted the use of this mod to admin so the html needed is like:
{IF POST->show_special true}
<tr>
<td colspan="2"><input type="checkbox" name="news_post" value="1" /> {LANG->Newspost}</td>
</tr>
{/IF}

The label of the checkbox must be added to the lang-file by hand, the same question, how can it be added on the fly not modifiying the template.

And last but not least, how to add custom error handler if something goes wrong? I could put some flag into message-array but the handling of it is something else.

If someone is interested about the mod let me know. I think it still needs some cleanup etc. to better integrate into Phorum.

Thanks and keep up the good work.

Panu
Re: How to correctly make a hook?
May 17, 2003 03:51PM
I don't see a simple way to add text to the templates without modifying it. the more as it will need localization for the languages.

I didn't really understand if you succeded to create the mod or not.
At all, your way to do this sounds correct.
Re: How to correctly make a hook?
May 18, 2003 05:11AM
Yes I have it working as we speak. I still have the problem where I can't make myself an administrator. (that prevents the usage of my mod for anyone else but the actual admin :(

I have tried to locate/modify the correct settings directly in the DB but everything seems to be exactly the same way as admin user.

So the actual question is how to make $show_special true for other users than the actual admin.

Panu


Re: How to correctly make a hook?
May 18, 2003 08:52AM
no other users shouldn't get show_special as they could post stickies and announcements then, which is not intended.

for admin-user you need to set admin to 1 in the users-table.
Re: How to correctly make a hook?
May 18, 2003 10:53AM
Yes, thats correct. The problem is that the admin-user and my normal users settings are identical in users-table.

When I log on as a admin I have all admin functions available, if I log on as my normal user (which should have admin = 1 in DB) I don't have admin functions.

I have also checked the groups and xref groups etc. all remotely relevant tables but I can't see anything special.

i have had a supeusers group which had access level 30 in my only forum, but user(s) in that group didn't have any extra permissions available either.

I try to figure out how the permission system works and where the specific flags are set, maybe I can figure it out.

Anyway, feel free to quess where the problem is and help out thou :-)

Panu
Re: How to correctly make a hook?
May 18, 2003 11:26AM
Ok, I found out why my profile didn't have the correct permissions. The user cache file was not updated with correct information.

I removed all files from /cache/usrs and logged in and became an admin-user.

So near term problem solved :)

Panu
Re: How to correctly make a hook?
May 18, 2003 09:57PM
Whoa, user caching, do we have that turned on?
Re: How to correctly make a hook?
May 19, 2003 07:11AM
At least I had those files there :) I have since turned that option of from admin.

Panu
Sorry, only registered users may post in this forum.

Click here to login