PDA

View Full Version : Flag a thread as news


Blue Moose Aaron
09-07-2004, 03:26 AM
Currently I am running a portal system on my site that pulls news from certain forums, the usual... Well this doesn't exactly work out for me as the people who post the best news are the regular members rather than my 'reporters'. What I have conceptualized is to come up with a hack that would allow users with permission to moderate to a.) be able to flag a new thread as 'news' or b.) be able to use the edit feature to edit a thread by a regular member as news and be pulled to the main site page.

Is this feasible or even worth the trouble?

CarCdr
09-07-2004, 01:02 PM
Just to be clear, is this an accurate summary of what you are after?

1) The portal system is currently able to pull information from "news" forum(s) but NOT threads.

2) You want the ability to flag any thread as "news worthy" so that it will be extracted/displayed by the portal system as if it were in the "news" forum.

First of all, to make it a little easier, I would not bother with changing the code for adding threads. If the person adding knows it is news, he can post it to the news forum or use the "Thread Admin Tools" menu (read on).

Just add an option to "Thread Admin Tools", a menu that is already access-controlled, to mark a thread as "news worthy". You would have to add a script (or add to an existing script) to be run by your new option (link) in the "Thread Admin Tools" menu.

You would also have to add a new column to the 'thread' table that would be set by your new script code. Let's assume you add a column called "newsworthy".

Finally, you'd have to change your portal script to also search for threads in the thread table with the "newsworthy" flag set.

What does all this add up to?

1. A template change to add option/link to "Thread Admin Tools".

2. A script or script change to add code called by said option.

3. A change to your portal script.

4. A new column in the thread table.

Now, alternatively, you could do this as a less-intrusive kludge (http://www.eps.mcgill.ca/jargon/jargon.html#kludge).

1. Create a "newsworthy" thread icon that is accessible only to your moderators. Note the iconid of the new icon.

2. Using the default "Thread Admin Tools/Edit Thread" option, they can set any thread to have this newsworthy icon.

3. Change the portal script to include any threads it finds with the newsworthy iconid.

The advantage of this approach is that it uses existing code and all you need to do is modify the portal script to look for threads with the newsworthy iconid, which should be a pretty easy mod.

Blue Moose Aaron
09-09-2004, 01:49 AM
That's a really great idea. Now I just need to figure out how to go about doing that!

Blue Moose Aaron
09-09-2004, 02:27 AM
Here is the code used in my portal for the news

// ######################### PROCESS NEWS ############################
// standard news block
if (($vbindex['options'] & VBI_SHOWNEWS) && !($vbindex['options'] & VBI_VBWAR) && !EXTRA_PAGE && $_REQUEST['action'] != 'shoutbox') {

$getnews = $DB_site->query("
## GET NEWS ##
SELECT thread.*,thread.iconid AS threadiconid, threadpost.pagetext AS pagetext,
threadpost.attach AS attachcount,
".iif($vbindex['options'] & VBI_SHOWNEWSAVATAR, 'avatarpath, NOT ISNULL(avatardata) AS customavatar, user.avatarrevision, customavatar.dateline AS customdateline,')."
".iif(($vbindex['options'] & VBI_SUBNEWS) AND $bbuserinfo['userid'], 'NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed,')."
IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."user AS user ON (thread.postuserid = user.userid)
LEFT JOIN ".TABLE_PREFIX."post AS threadpost ON (thread.firstpostid = threadpost.postid)
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
".iif($vbindex['options'] & VBI_SHOWNEWSAVATAR, '
LEFT JOIN '.TABLE_PREFIX.'customavatar AS customavatar ON (customavatar.userid = user.userid)
LEFT JOIN '.TABLE_PREFIX.'avatar AS avatar ON (avatar.avatarid = user.avatarid)'
)."
".iif(($vbindex['options'] & VBI_SUBNEWS) AND $bbuserinfo['userid'], "
LEFT JOIN ".TABLE_PREFIX."subscribethread AS subscribethread ON(subscribethread.threadid = thread.threadid AND subscribethread.userid = $bbuserinfo[userid])"
)."
WHERE forumid IN ($vbindex[newsfid])
AND deletionlog.primaryid IS NULL
AND forumid NOT IN (".implode(',', $limitfids).")
AND thread.open <> 10
AND thread.visible = '1'
$globalignore
$ignorelist
ORDER BY ".iif($vbindex['options'] & VBI_STICKYNEWS, 'thread.sticky DESC,', '')." thread.dateline DESC
LIMIT $vbindex[newsposts]");

while($news = $DB_site->fetch_array($getnews)) {

$news['title'] = fetch_censored_text($news['title']);
$news['time'] = vbdate($vboptions['timeformat'], $news['dateline']);
$news['date'] = vbdate($vboptions['dateformat'], $news['dateline'], 1);
$news['musername'] = fetch_musername($news, 'displaygroupid', 'postusername');
$news['attachcount'] = vb_number_format($news['attachcount']);
$news['replycount'] = vb_number_format($news['replycount']);

if ($news['iconid']) {
$news['showicon'] = true;
$news['threadiconpath'] = &$iconcache["$news[threadiconid]"]['iconpath'];
$news['threadicontitle'] = &$iconcache["$news[threadiconid]"]['title'];
} elseif (!empty($vboptions['showdeficon'])) {
$news['showicon'] = true;
$news['threadiconpath'] = $vboptions['showdeficon'];
$news['threadicontitle'] = $vbphrase['default'];
}

// ## CENSOR NEWS AND PARSE vB CODE ##
$news['pagetext'] = fetch_censored_text(parse_bbcode(strip_bbcode(fetc h_trimmed_title($news['pagetext'], 394), true, true), $news['forumid'], 1));

// ## GET POSTERS AVATAR ##
$news['avatar'] = false;
if ($vbindex['options'] & VBI_SHOWNEWSAVATAR) {

if (!isset($avatarcache["$news[postuserid]"])) {

if ($news['customavatar']) {

if ($vboptions['usefileavatar']) {
$news['avatarurl'] = "$vboptions[avatarurl]/avatar$news[postuserid]_$news[avatarrevision].gif";
} else {
$news['avatarurl'] = "$vboptions[bburl]/image".SCRIPT_EXTENSION."?userid=$news[postuserid]&amp;dateline=$news[customdateline]";
}

$news['avatar'] = true;
$avatarcache["$news[postuserid]"] = $news['avatarurl'];
DEVDEBUG("cached avatar for userid $news[postuserid]");
} elseif (!empty($news['avatarpath'])) {
$news['avatarurl'] = $vboptions['bburl'].'/'.$news['avatarpath'];
$news['avatar'] = true;
$avatarcache["$news[postuserid]"] = $news['avatarurl'];
DEVDEBUG("cached avatar for userid $news[postuserid]");
} elseif (!empty($vbindex['useravatar'])) { // we have a default av specified
$avatarurl = $vbindex['useravatar'];
$avatarcache["$bbuserinfo[userid]"] = $avatarurl;
$news['avatar'] = true;
}

} else {
$news['avatar'] = true;
$news['avatarurl'] = $avatarcache["$news[postuserid]"];
}
}

eval("\$home[news] .= \"".fetch_template('vbindex_newsbit')."\";");
}
// memory saving
unset($news);
$DB_site->free_result($getnews);
}

// if vBwar is enabled then show that instead
if ((($vbindex['options'] & VBI_VBWAR) && !($vbindex['options'] & VBI_SHOWNEWS)) && !EXTRA_PAGE && $_REQUEST['action'] != 'shoutbox') {

require_once('./vnews.php');

}


Can anyone help me make this work?

CarCdr
09-09-2004, 09:55 AM
Start by checking out the AdminCP interface for post icons. You should be able to create a simple graphic to mean "new worthy". How about a tiny graphic of a newspaper. You should be able to find that with google or through an online graphics/icon library.

Find or make an icon about the same size as the other post icons. A little bigger is OK too, but not so big that it messes up the postbit display.

Create a usergroup called "News Moderator" that has the privileges you need to allow them to edit threads in forums. Then install the new post icon graphic via AdminCP, giving access to use it to moderators. You will see the iconid displayed when you install the new post icon.

The query should be an easy change. Where it says "WHERE forumid IN ($vbindex[newsfid])" you will add code to select threads with the proper icon -- thread.iconid, not post icons.

If noboy else pipes up about your query, I'll post the query you will need later. Gotta go to work... sigh.

CarCdr
09-09-2004, 04:16 PM
Here's how you would change your query to catch threads with the "newsworthy" iconid. It is vital that your moderators use "Edit Thread" to set the thread icon, not the first post or any other post to set the post icon.

Change this line:

WHERE forumid IN ($vbindex[newsfid])

to:

WHERE (forumid IN ($vbindex[newsfid]) OR thread.iconid=###)

where "###" is replaced with the actual iconid that you noted when you added it.

Since the thread table has an iconid KEY, this should be quite performant.

Blue Moose Aaron
09-10-2004, 12:43 AM
Thanks so very much for your help. I never thought it would be that simple, and it worked like a charm. You can see it in action at http://www.thekryptonian.com

Thanks again! :)

CarCdr
09-10-2004, 01:11 AM
Looks good. You're welcome.

Blue Moose Aaron
09-11-2004, 01:56 AM
This may be a little more difficult, but I've seen it done on other forums (only wiht images) where the post bit displays the number of items a person has posted.

I would like to somehow display the number of news items a user has posted in hopes of sparking the users to post more news worthy subjects.

CarCdr
09-16-2004, 09:43 PM
Well, you have a couple of choices. You need to associate the counter with a user, so you can add a column to the 'user' table or make a new table keyed on userid. That's the easy part -- having a place to store the counter.

The other easy part is displaying the information. It would be easy enough to modify the PHP function that assembles the information for use by the 'postbit' template to also make available your new counter. Then, in postbit you would just check to see if it is greater than zero and, if so, display it somewhere in the user information.

The harder part is:

1) Figuring out what triggers should be used to increment/decrement the counter. (design)

2) Figuring out where in the vBulletin scripts one has to add code to implement the triggers.

Given your approach of using simple thread icons, you could modify newthread.php and postings.php (edit thread action) to note when a thread is being flagged as news so that the user table counter can be incremented.

I would recommend a kludge here -- only increment the counter -- only track when a thread is being flagged as news. This would be easier and still give you the feedback you are after.

Blue Moose Aaron
09-23-2004, 04:35 AM
I think my head is going to explode. I'm not sure how to do any of that. Im in over my head!