Firefox PHP

Help needed with a complicated mod!

Posted by Mandingo 
Help needed with a complicated mod!
July 10, 2004 09:42PM
O.K. So I'm brave enough to try to do this mod with the 'Subscribe to this thread' option. I want it so a user can subscribe to a thread regardless of whether they've posted on that thread or not. I've set it up so an option appears on the first message of every thread. Like this



I've added this in 'Read.tpl' -


{IF MESSAGES->parent_id 0}<a class="PhorumNavLink" href="{MESSAGES->email_reply}">{LANG->EmailReplies}</a>{/IF}</td>


& this in 'read.php' at the bottomn of the section that starts with "// this stuff is used in threaded and non threaded." -

$row["email_reply"] = phorum_get_url(PHORUM_READ_URL, $row["thread"], $row["message_id"], "subthreads=1");


It works in the read.tpl template, and when you click on a link it seems to go somewhere, but it doesn't show up in the 'subscribed threads' in the Control Center. Obviously I'm missing something somewhere. Any ideas where I'm going wrong?
I know this mod isn't to everyones taste, and is maybe 'unnecessary' but it might be useful to some, besides, I've started doing it now and I'm determined! ;-) Any help would be greatly appreciated.

BTW, it's not 'bookmarking' I'm doing, despite what it says in the graphic (I was just playing around with the lang script) it's just a case of changing the way you subscribe to a thread.



Edited 1 time(s). Last edit at 07/10/2004 09:51PM by Mandingo.
Re: Help needed with a complicated mod!
July 11, 2004 11:22AM
It's really not that complicated. You just need to call the function
phorum_user_subscribe( $user_id, $forum_id, $thread, $type )
when the link is clicked.


> I've added this in 'Read.tpl' -
>
> {IF MESSAGES->parent_id 0}<a class="PhorumNavLink" href="{MESSAGES->email_reply}">{LANG->EmailReplies}</a>{/IF}</td>

good... you should also check that the user is logged in. ie {IF LOGGEDIN}...

> & this in 'read.php' at the bottomn of the
> section that starts with "// this stuff is used in
> threaded and non threaded." -
>
> $row["email_reply"] = phorum_get_url(PHORUM_READ_URL, $row["thread"], $row["message_id"], "subthreads=1");

good. So the URL is set up properly. Now what is read.php going to do when it's called with the subthreads=1 argument?

Near the top of read.php, you should put something like this:
// check for subscription request
if(!empty($PHORUM["args"]["subthreads"]) && $PHORUM["DATA"]["LOGGEDIN"]) {
    phorum_user_subscribe($PHORUM["user"]["user_id"], $PHORUM['forum_id'], $thread, PHORUM_SUBSCRIPTION_MESSAGE);
}
Hope that helps.

PS: hi Mike...
Re: Help needed with a complicated mod!
July 11, 2004 11:30AM
Well done mate ;-) Nice to see you here! :-D



Edited 1 time(s). Last edit at 07/11/2004 11:31AM by Mandingo.
Re: Help needed with a complicated mod!
July 11, 2004 12:00PM
Please, make a real module of it so you don't need to edit read.php, just put the code in a module for the common_hook and call it only on the read-page (i.e. check the phorum_page constant).


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Help needed with a complicated mod!
July 11, 2004 12:31PM
o.k. I suppose that's worth doing.

How would you prevent this option sending actual emails out? Say if it were just an option to bookmark? At the moment, if I have it set up this way, its' both bookmarking and sending out emails, I'd like users to be able to choose between the two options.

If we can get it together like this, I'll have a go at setting it up as a seperate mod.
Re: Help needed with a complicated mod!
July 11, 2004 01:04PM
the function you use, phorum_user_subscribe, is for subscribing to a thread ONLY for email-notifications.
it doesn't support something like bookmarks.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Help needed with a complicated mod!
July 11, 2004 04:37PM
So you'd have to add a function somehow, say PHORUM_USERS_SAVE or something to get that to work?
Re: Help needed with a complicated mod!
July 11, 2004 04:43PM
You could probably use a custom field and still using the internal-functions but also you would need to put an additional page in the controlcenter to show the bookmarked threads.


Thomas Seifert
Phorum Development Team / Mysnip-Solutions.de
Custom Phorum and general software development
worry-free Phorum Hosting
Re: Help needed with a complicated mod!
July 11, 2004 05:03PM
Ah, o.k. good idea. So that would essentially involve adding a custom field via the admin controls called 'USER_SAVE' (or something), and call it from there, that would work, potentially?



Edited 1 time(s). Last edit at 07/11/2004 05:41PM by Mandingo.
Re: Help needed with a complicated mod!
July 11, 2004 05:50PM
Right, so I've created a custom field via the admin control called 'user_save'. The additional lines I now have are:

In 'read.php' =


$row["user_save"] = phorum_get_url(PHORUM_READ_URL, $row["thread"], $row["message_id"], "save=1");

and

// check for subscription request
if(!empty($PHORUM["args"]["save"]) && $PHORUM["DATA"]["LOGGEDIN"]) {
phorum_user_subscribe($PHORUM["user"]["user_id"], $PHORUM['forum_id'], $thread, PHORUM_SUBSCRIPTION_MESSAGE);

and in 'read.tpl'=

{if LOGGEDIN true}{IF MESSAGES->parent_id 0}<a class="PhorumNavLink" href="{MESSAGES->user_save}">{LANG->ThreadSave}</a>{/if}{/IF}</td>


But I guess that doesn't change anything, since I still have 'phorum_user_subscribe' in there?







Edited 2 time(s). Last edit at 07/11/2004 05:51PM by Mandingo.
Sorry, only registered users may post in this forum.

Click here to login