Not logged in. · Lost password · Register
Forum: Customising UNB Modifications and plug-ins RSS
notifications for new threads
gnauck #1
Member since Feb 2006 · 33 posts
Group memberships: Members
Show profile · Link to this post
Subject: notifications for new threads
I consider writing a XMPP plugin which notifies board admins of new created threads. Because I don't like RSS feeds and polling.
Could you give me small guide how to start with that?

Thanks,
Alex
Avatar
Yves (Administrator) #2
User title: UNB developer & webmaster
Member since Jan 2004 · 3855 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I assume that you are familiar with UNB plugin development. You can take a look at the release archive to find some plugins, also some demo ones, and use one of these as a start. You'd then need to connect UNB hooks with your plugin functions to handle the event and perform some action on it. In this case, the "post.postthreadcreate" hook might be useful to you.

You can find all the docs on http://newsboard.unclassified.de/devel/docs/plugins.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
gnauck #3
Member since Feb 2006 · 33 posts
Group memberships: Members
Show profile · Link to this post
I made some progress. I have 2 quetions.

  • how do I get the username of the creator of the thread from the thread object. GetUsername() is always empty.
  • how do I build the Url for the new thread?

Thanks,
Alex
gnauck #4
Member since Feb 2006 · 33 posts
Group memberships: Members
Show profile · Link to this post
have the Url now with the following code:

  1. $threadid   = $thread->GetID();
  2. $t_url   = TrailingSlash(rc('home_url')) . UnbLink('@thread', 'id=' . $threadid, true);
when there is an easier way (like UnbMakePostLink) to get it let me now. Otherwise I vote for adding a new function for this in one of the next version. Only the username of the thread creator is missing then the 1st version of the plugin is done.

Thanks
Avatar
Yves (Administrator) #5
User title: UNB developer & webmaster
Member since Jan 2004 · 3855 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #3
Quote by gnauck:
how do I get the username of the creator of the thread from the thread object. GetUsername() is always empty.

That method is only used to store the user's provided name for guest posting. It's only supposed to be set, valid and used if the user ID is 0. You'll need to get the user ID and retrieve the user yourself to get its full record.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
gnauck #6
Member since Feb 2006 · 33 posts
Group memberships: Members
Show profile · Link to this post
Quote by Yves:
That method is only used to store the user's provided name for guest posting. It's only supposed to be set, valid and used if the user ID is 0. You'll need to get the user ID and retrieve the user yourself to get its full record.

do you have some example code for this?

Thanks,
Alex
Avatar
Yves (Administrator) #7
User title: UNB developer & webmaster
Member since Jan 2004 · 3855 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
  1. $user = new IUser($userId);
  2. $userName = $user->GetName();
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
gnauck #8
Member since Feb 2006 · 33 posts
Group memberships: Members
Show profile · Link to this post
Thanks Yves. Works great now. I have attached the plugin.
It send notifications of new created threads to all board admins with have a JabberId in their profile. I hope its useful for other people as well.

Alex
The author has attached one file to this post:
xmppnotifications.zip 1.6 kBytes
You have no permission to open this file.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
This board is powered by the Unclassified NewsBoard software, 20120620-dev, © 2003-2011 by Yves Goergen
Page created in 187.6 ms (135.9 ms) · 89 database queries in 115.8 ms
Current time: 2013-05-22, 07:14:31 (UTC +02:00)