How to correctly make a hook?
Posted by Panu
How to correctly make a hook? May 17, 2003 12:27PM |
Registered: 22 years ago Posts: 1,076 |
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
$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 |
Admin Registered: 21 years ago Posts: 9,240 |
Re: How to correctly make a hook? May 18, 2003 05:11AM |
Registered: 22 years ago Posts: 1,076 |
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
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 |
Admin Registered: 21 years ago Posts: 9,240 |
Re: How to correctly make a hook? May 18, 2003 10:53AM |
Registered: 22 years ago Posts: 1,076 |
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
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 |
Registered: 22 years ago Posts: 1,076 |
Re: How to correctly make a hook? May 18, 2003 09:57PM |
Admin Registered: 23 years ago Posts: 4,495 |
Re: How to correctly make a hook? May 19, 2003 07:11AM |
Registered: 22 years ago Posts: 1,076 |
Sorry, only registered users may post in this forum.