PDA

View Full Version : Mod for Geek's hack Article


Allan
04-18-2005, 10:18 AM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For this hack (https://vborg.vbsupport.ru/showthread.php?t=75916&highlight=geek+article)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Would it be possible to carry out a MOD which makes it possible to see in the postbit the number of articles written by the user ?

and if possible that one can click above to go directly to the articles ;)

Allan
04-19-2005, 11:40 AM
nobody ??

Lizard King
04-19-2005, 03:04 PM
I think it is impossible because the articles are also regular threads so i cannot imagine a way to count this special threads.

Allan
04-19-2005, 03:12 PM
I the opinion of front Geek waits, but it is a pity :(

The Geek
04-19-2005, 03:25 PM
Actually - I dont think it would be very difficult to do.

Here is one way of doing it:
1- Create a new userprofile field
2- Add an update to that userprofile field in the insert_new_article function of functions_geekarticles (in the if branch that has the INSERT statement - meaning it was a new article).
3- You would have to do the same for when a thread gets deleted that is in an article forum (currently - GAS doesnt go there).
4- I would recommend creating a script that would pull all userids from threads that are posted in gas forums. THen look through to override the userprofile field. This can be a one off 'importer' and/or an occasional cron job to make sure you are in sync.
5- As a userprofile field - its a bit o cake to pull that info into the postbit
6- Link to search.php to search GAS forums by userid.

Seriously - wouldnt be that big of a job. I would do it if I wasnt already swamped. I am more than happy to assist anyone wanting to do it.

Telkman
04-19-2005, 03:34 PM
Not got the time to do a full hack for this, but hopefully this quick example will get you started...

This example is only changing showthread.php, if you wanted to make the same changes to showpost.php, announcement.php and others that use the postbit, it's easy enough. I'm trying to keep this as simple as possible, so this is just a replace in showthread.php rather than a $post[...] value. It will add one additional query, which could probably be avoided, but again, I'm in a hurry and trying to keep it simple.

In showthread.php:

Find both occurences of:
$postbits .= construct_postbit($post, $template);


Add below each:
$acs[$post[userid]] = intval($post[userid]);


Then find:
$postbit = construct_postbit($post, $template);

Add below:
$acs[$post[userid]] = intval($post[userid]);

Then find:
eval('print_output("' . fetch_template('SHOWTHREAD') . '");');
}
// === /GAS step 615 ===


Add above:
$acs2 = implode(",", array_values($acs));
$act = $DB_site->query("SELECT COUNT(threadid) AS threads, postuserid AS userid FROM " . TABLE_PREFIX . "thread WHERE postuserid IN ($acs2) AND forumid IN (" . $GAS_setting['forums'] . ") GROUP BY postuserid");
while ($act2 = $DB_site->fetch_array($act))
{
$search[] = "ac[$act2[userid]]";
$replace[] = vb_number_format($act2[threads]);
unset($acs[$act2[userid]]);
}
foreach ($acs as $acid)
{
$search[] = "ac[$acid]";
$replace[] = 0;
}
$postbits = str_replace($search, $replace, $postbits);


In your postbit template you would then need:
<if condition="THIS_SCRIPT == 'showthread'"><div><a href="search.php?$session[sessionurl]do=process&amp;showposts=0&amp;starteronly=1&amp;exactname=1&amp;s earchuser=$post[username]&amp;forumchoice=*****">Articles Written: ac[$post[userid]]</a></div></if>

Replace ***** with the article forumid. If you need more than one forumid, use forumchoice[]=*****&amp;forumchoice[]=***** etc for each forumid. This could be generated from $GAS_setting['forums'] fairly easily if you wanted to.

Having reread it, it doesn't make a huge deal of sense, but hopefully you can find your way though it if it's of use to you.

The Geek
04-19-2005, 04:00 PM
Here is something else you can either add to, or alter how you see fit.

Edit search.php

Find:

// ################################################## ###########################
if ($_REQUEST['do'] == 'finduser')
{
globalize($_REQUEST, array('userid' => INT, 'forumid' => INT));


replace with:

// ################################################## ###########################
if ($_REQUEST['do'] == 'finduser')
{
globalize($_REQUEST, array('userid' => INT, 'forumid' => INT,'GAS'=>INT));

if($GAS AND !$forumid){
$GAS_result=$DB_site->query_first("SELECT data FROM " . TABLE_PREFIX . "datastore WHERE title='GAS_settings'");
$GAS_setting=unserialize($GAS_result['data']);
if ($GAS_setting['forums']){
$forumid=explode(",",$GAS_setting['forums']);
}
}

Then you can stick something like:

<a href="search.php?do=finduser&u=$bbuserinfo[userid]&GAS=1">Find all of $bbuserinfo[username]'s articles</a>


I know that wont get you the article count - but its alomst there ;)