vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   userdata_postsave hook query (https://vborg.vbsupport.ru/showthread.php?t=98955)

Nullifi3d 10-21-2005 03:11 PM

userdata_postsave hook query
 
PHP Code:

$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 100 WHERE userid = " $this->registry->userinfo['userid']); 

This query gives users impressions each time they make a new post. I would like to change it so that it gives a different amount of impressions according to whether it's a new post or a new thread. How would I go about doing this?

Nullifi3d 10-27-2005 04:55 PM

Any help on this? I have posted this twice now with no reply and it seems to be a simple fix. I just don't know the variabled to use for this hook.

Paul M 10-27-2005 05:12 PM

Try checking the variable $type, I think that should be set to 'thread' or 'post'.

Nullifi3d 10-27-2005 06:37 PM

i updated the hook from (which works)
PHP Code:

$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 100 WHERE userid = " $this->registry->userinfo['userid']); 

to
PHP Code:

if ($type == "thread") {
    
$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 100 WHERE userid = " $this->registry->userinfo['userid']);
} else if (
$type == "post") {
    
$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 10 WHERE userid = " $this->registry->userinfo['userid']);


After updating it does nothing for posts and threads.

Nullifi3d 11-01-2005 11:17 PM

Can someone at least tell me which php document contains this hook so I can find the answer myself?

Marco van Herwaarden 11-02-2005 09:21 AM

Sorry but i don't know the hook called 'userpost_datasave'.

Nullifi3d 11-08-2005 08:43 PM

Sorry it's userdata_postsave.

Andreas 11-08-2005 10:24 PM

A Hook "userpost_datasave" does not exist, at least not in standard vBulletin 3.5.1 code.

Nullifi3d 11-09-2005 10:46 AM

Well I found class_dm_user.hp thanks to Andreas, but after taking a look I couldn't find anything relevant to defining whether or not the post is a new thread or just a post. While functions_newpost.php does contain the variable $type which seems to store thread or reply it allways adds 10 (does the else) if I change:
PHP Code:

$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 10 WHERE userid = " $this->registry->userinfo['userid']); 

To:
PHP Code:

if ($type == 'thread') {
    
$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 100 WHERE userid = " $this->registry->userinfo['userid']);
} else {
    
$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 10 WHERE userid = " $this->registry->userinfo['userid']);



Nullifi3d 01-05-2006 09:35 PM

Can anyone help me with this? I can't get it.

Nullifi3d 01-09-2006 04:38 PM

I managed to temporarily fix this by using different hooks and code, but no I have to have 3 different hooks for what could be done with one (i think).
- ajax_complete
- newreply_post_complete
- newthread_post_complete

Can anyone fix the code below to work with userdata_postsave (or another 1 hook solution):
PHP Code:

if ($type == 'thread') {
    
$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 100 WHERE userid = " $this->registry->userinfo['userid']);
} else {
    
$this->registry->db->query_write("UPDATE " TABLE_PREFIX "banners SET available = available + 10 WHERE userid = " $this->registry->userinfo['userid']);




All times are GMT. The time now is 10:15 PM.

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.02512 seconds
  • Memory Usage 1,747KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)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