vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Reputation For New Threads and Posts (https://vborg.vbsupport.ru/showthread.php?t=139352)

Sir_Yaro 02-13-2007 10:00 PM

Reputation For New Threads and Posts
 
Hi.
First of all I'm not a coder. So this hack for a professionals might looks like total disaster but it works and that what is important for me... :)
Like I said before I'm not a code therefore I don't give any support cause I barely know how this hack works :D :D :D :D

This is simple version of this hack:
https://vborg.vbsupport.ru/showthread.php?t=78853
It should (?) be compatible with 3.6.x as well.

In specified below forums system will give X reputation points for any new thread and it will send PM to the poster with informatin about it.
Code is clearly described. Take a closer look at places marked by CHANGE IT !.

Have fun

in includes/functions_newpost.php
find:
Code:

                if ($type == 'thread')
                {
                        $vbulletin->url = 'forumdisplay.php?' . $vbulletin->session->vars['sessionurl'] . "f=$foruminfo[forumid]";
                        eval(print_standard_redirect('redirect_duplicatethread', true, true));
                }
                else
                {
                        $vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t=$prevpostthreadid";
                        eval(print_standard_redirect('redirect_duplicatepost', true, true));
                }
        }

If u want to give reputation for new posts and threads add below:
Code:

if ($foruminfo[forumid]>37 AND $foruminfo[forumid]<41)//works only in forums with id  between 37 and 41 (so 38,39 and 40 only) CHANGE IT !
{
    $result = $vbulletin->db->query_first("SELECT reputation FROM user WHERE userid =".$vbulletin->userinfo['userid']." ORDER BY userid ASC");

    $punkty=$result['reputation']+20;//incrase reputation by 20  CHANGE IT !
    $vbulletin->db->query_write("UPDATE user SET reputation=".$punkty." WHERE userid=".$vbulletin->userinfo['userid']);


  $senderpermissions=2;
  $registry =& $vbulletin;
  // create the DM to do error checking and insert the new PM
  $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_SILENT);
    $pmdm->set('fromuserid', 592); //change to admin ID number  CHANGE IT !
    $pmdm->set('fromusername', 'Sir_Yaro'); //change to admin name  CHANGE IT !
    $pmdm->set('title', 'Otrzymales(as) 20 pkt reputacji ');//title  CHANGE IT !
    $pmdm->set('message', "Otrzymales(as) 20 pkt reputacji za umieszczenie urzadzenia na liscie HCL\nDziekujemy bardzo i prosimy o dalsze wpisy :)"); //message  CHANGE IT !
  $pmdm->set_recipients($vbulletin->userinfo['username'], $senderpermissions);
  $pmdm->set('dateline', TIMENOW);
  $pmdm->save();

}

If you want to give reputation only for new threads add below:
Code:

if ($foruminfo[forumid]>37 AND $foruminfo[forumid]<41 AND $postinfo['postid'] == 0)//works only in forums with id  between 37 and 41 (so 38,39 and 40 only) CHANGE IT !
{
    $result = $vbulletin->db->query_first("SELECT reputation FROM user WHERE userid =".$vbulletin->userinfo['userid']." ORDER BY userid ASC");

    $punkty=$result['reputation']+20;//incrase reputation by 20  CHANGE IT !
    $vbulletin->db->query_write("UPDATE user SET reputation=".$punkty." WHERE userid=".$vbulletin->userinfo['userid']);


  $senderpermissions=2;
  $registry =& $vbulletin;
  // create the DM to do error checking and insert the new PM
  $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_SILENT);
    $pmdm->set('fromuserid', 592); //change to admin ID number  CHANGE IT !
    $pmdm->set('fromusername', 'Sir_Yaro'); //change to admin name  CHANGE IT !
    $pmdm->set('title', 'Otrzymales(as) 20 pkt reputacji ');//title  CHANGE IT !
    $pmdm->set('message', "Otrzymales(as) 20 pkt reputacji za umieszczenie urzadzenia na liscie HCL\nDziekujemy bardzo i prosimy o dalsze wpisy :)"); //message  CHANGE IT !
  $pmdm->set_recipients($vbulletin->userinfo['username'], $senderpermissions);
  $pmdm->set('dateline', TIMENOW);
  $pmdm->save();

}

If you want to use it in a few different forums you can use this code instead of previous one:
Code:

$foruminfo[forumid]==37 OR $foruminfo[forumid]==41 OR $foruminfo[forumid]==11
and so on....

EnIgMa1234 02-14-2007 10:50 AM

thanks. nice hack

Mutt 03-12-2007 12:47 AM

hey, I'm not code god either but I did clean this up a little. I'm on 3.64 but I assume it'll work for you too.


create a new plugin at hook "newpost_complete"

Code:

$pointsperreply=1; // repuation points per reply.  0 to disable
$pointsperthread=1; // repuation points per thread.  0 to disable
if ($foruminfo[forumid]!=18 && $foruminfo[forumid]!=6) {
        if ($type == 'thread') {
                $reppoints=$pointsperthread;
        } else {
                $reppoints=$pointsperreply;
        }
        if ($reppoints) {
            $vbulletin->db->query_write("UPDATE user SET reputation=reputation+".$reppoints." WHERE userid=".$vbulletin->userinfo['userid']);
        }
}


this uses only 1 query instead of 2, lets you set different values for threads & replies, and lets you disable either.

still not sure I want to hand out rep points for every post but since I'm using rep points for vBookie, they might need em.

Mutt 03-12-2007 01:01 AM

was just thinking about it and you probably should throw something in there in case it's a guest posting.

Code:

$pointsperreply=1; // repuation points per reply.  0 to disable
$pointsperthread=1; // repuation points per thread.  0 to disable
if ($foruminfo[forumid]!=18 && $foruminfo[forumid]!=6 && $vbulletin->userinfo['usergroupid']>1) {
        if ($type == 'thread') {
                $reppoints=$pointsperthread;
        } else {
                $reppoints=$pointsperreply;
        }
        if ($reppoints) {
            $vbulletin->db->query_write("UPDATE user SET reputation=reputation+".$reppoints." WHERE userid=".$vbulletin->userinfo['userid']);
        }
}

this should do it.

Thr33 03-10-2010 09:49 AM

anyone no of this mod for 4.0 or 4.2?


All times are GMT. The time now is 07:03 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01080 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete