Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2008, 07:39 PM
Kiros72 Kiros72 is offline
 
Join Date: Apr 2006
Location: Albany, LA - USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help: Time Var (Edit - Reputation Modify Not Working)

I would like to add a variable to the $userinfo array within $vbulletin. For reference, the variable would probably be called $lastmodify (i.e. $vbulletin->userinfo['lastmodify']).

This variable would be just like $lastvisit or $lastactivity (an integer that holds a time).

I know that I would put this in the physical files. What I don't know is how I would go about setting and checking it.

See, I want vBulletin to add something to a user every 24 hours if they are logged in (or if they login 24 hours after the last time something was added). So that's why I need to add this additional variable - to define the last time that their account was modified.

Refer to next post for problem vvv

Thanks in advance

--------------- Added [DATE]1223915141[/DATE] at [TIME]1223915141[/TIME] ---------------

I've gotten the time thing worked out, I believe. I added the new variable to the $userinfo array, but it's not working. I'm thinking that this might be because it's in the PHP files but it's not in the user table in the SQL database.

I'm not quite sure how to create another row in the MySQL database that is similar to lastvisit. I've checked out the Insert option in phpMyAdmin, but that's just becoming confusing. Can anyone give me some basic instruction?
Reply With Quote
  #2  
Old 10-13-2008, 03:48 PM
Guest190829
Guest
 
Posts: n/a
Default

I'm not sure exactly what you are trying to do, but you need to add another column to the usertable to store this new variable. Then you need to work out how to update the value and when.
Reply With Quote
  #3  
Old 10-13-2008, 03:57 PM
Kiros72 Kiros72 is offline
 
Join Date: Apr 2006
Location: Albany, LA - USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the response!

I've worked out how to update the variable, but it hasn't been updating because it wasn't in the database. I thought that what I needed was a new row, not a new column. Aren't lastvisit and lastactivity rows? If so, then I need a new row, because I need to store a time like those values. I wouldn't know how to add a row - if it is a row. Hopefully, I've just got the two terms confused.

--------------- Added [DATE]1223918858[/DATE] at [TIME]1223918858[/TIME] ---------------

Well, I managed to figure out how to just add a row. I added the row lastrepadd to the user table. It has the properties of the other time variables, like lastvisit.

This is the PHP code that I've got planted in the index.php file. I can't figure out why it's not working.

PHP Code:
if ( $vbulletin->userinfo['usergroup'] == OR $vbulletin->userinfo['usergroup'] > )
{
    if (
TIMENOW $vbulletin->userinfo['lastrepadd'] >= 86400)
    {
        
$reputationlevel $db->query_first_slave("
            SELECT reputationlevelid
            FROM " 
TABLE_PREFIX "reputationlevel
            WHERE " 
$vbulletin->userinfo['reputation'] + " >= minimumreputation
            ORDER BY minimumreputation
            DESC LIMIT 1
        "
);

        
$userdata =& datamanager_init('User'$vbulletinERRTYPE_STANDARD);
        
$userdata->set_existing($vbulletin->userinfo);
        
$userdata->set('lastrepadd'TIMENOW);
        
$userdata->set('reputation'$vbulletin->userinfo['reputation'] + 1);
        
$userdata->set('reputationlevelid'intval($reputationlevel['reputationlevelid']));
        
$userdata->save();
    }

What I'm trying to do with this is give a user 1 reputation point every day as long as they login (or are already logged in and just visit). Any ideas as to why this isn't working?
Reply With Quote
  #4  
Old 10-14-2008, 07:40 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Column = a field in a table
Row = is a record (row) in a table.
Reply With Quote
  #5  
Old 10-15-2008, 04:02 AM
Kiros72 Kiros72 is offline
 
Join Date: Apr 2006
Location: Albany, LA - USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, that's what I thought, but now I have a new problem. I made the new row and everything, but it's not really saving... Here's the PHP code I put in the index.php.

PHP Code:
if ( $vbulletin->userinfo['usergroup'] == OR $vbulletin->userinfo['usergroup'] > 

    if (
TIMENOW $vbulletin->userinfo['lastrepadd'] >= 86400
    { 
        
$reputationlevel $db->query_first_slave(
            SELECT reputationlevelid 
            FROM " 
TABLE_PREFIX "reputationlevel 
            WHERE " 
$vbulletin->userinfo['reputation'] + " >= minimumreputation 
            ORDER BY minimumreputation 
            DESC LIMIT 1 
        "
); 

        
$userdata =& datamanager_init('User'$vbulletinERRTYPE_STANDARD); 
        
$userdata->set_existing($vbulletin->userinfo); 
        
$userdata->set('lastrepadd'TIMENOW); 
        
$userdata->set('reputation'$vbulletin->userinfo['reputation'] + 1); 
        
$userdata->set('reputationlevelid'intval($reputationlevel['reputationlevelid'])); 
        
$userdata->save(); 
    } 

I have added lastrepadd to the $userinfo array. I added a row in the vb_user table called lastrepadd. Why isn't that saving the lastrepadd variable? What am I doing wrong?
Reply With Quote
  #6  
Old 10-15-2008, 04:04 AM
Guest190829
Guest
 
Posts: n/a
Default

Have you added the lastrepadd to the datamanager? It won't allow you to save unless you do so.
Reply With Quote
  #7  
Old 10-15-2008, 04:18 AM
Kiros72 Kiros72 is offline
 
Join Date: Apr 2006
Location: Albany, LA - USA
Posts: 215
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, here's the little bit that I added it in:

PHP Code:
        'joindate'           => array(TYPE_UNIXTIME,   REQ_AUTO),
        
'lastvisit'          => array(TYPE_UNIXTIME,   REQ_NO),
        
'lastactivity'       => array(TYPE_UNIXTIME,   REQ_NO),
        
'lastrepadd'         => array(TYPE_UNIXTIME,   REQ_NO),
        
'lastpost'           => array(TYPE_UNIXTIME,   REQ_NO),
        
'lastpostid'         => array(TYPE_UINT,       REQ_NO)
..... 
and
PHP Code:
        // time fields
        
foreach (array('joindate''lastvisit''lastactivity''lastrepadd') AS $datefield)
        {
            if (!isset(
$this->user["$datefield"]))
            {
                
$this->set($datefieldTIMENOW);
            }
        } 
Reply With Quote
  #8  
Old 10-15-2008, 04:35 AM
Guest190829
Guest
 
Posts: n/a
Default

Okay, do a pre_save() check with the manager and see if there are errors popping up.
Reply With Quote
  #9  
Old 10-15-2008, 08:00 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should not edit any files to add a field to the allowed fields list.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04301 seconds
  • Memory Usage 2,263KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (6)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete