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 06-17-2007, 02:48 AM
Tourmeister Tourmeister is offline
 
Join Date: Nov 2005
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Query format to alter displaygroupid for members of usergroup?

Howdy,

Here is what I have. I have a usergroup called "Forum Supporter". When members use the VB subscription feature to donate to the site, they are made "Additional Members" of the Forum Supporter usergroup for a period of 30 days. What I want is for these member's usernames to be green on the Who's Online List. However, username markups only affect "Primary Members" of a usergroup. IF a particular member of the Forum Supporter usergroup happens to have enough snap to look in the User CP, they can choose to identify themselves with the Forum Supporter usergroup and then the markup works. The problem is, few even know about that feature, nor would they mess with it if I mentioned it.

I want to keep the users as Additional members of the Forum Supporter usergroup but I want to force their profile to identify them with the Forum Supporter usergroup. The only way I can think to do this is to run a manual query on the "user" table. However, I cannot figure out the structure of the query and this site:

http://dev.mysql.com/doc/mysql/en/index.html,

is pretty worthless in my opinion for someone trying to learn the basics. No, I am not a programmer. I am a pathetic user struggling to learn this stuff

Anyway, looking at the user table, I think I have figured out what needs to be done, just not specifically how to accomplish it.

Currently, for users that are Forum Supporters, I have these conditions:

usergroupid = 2 (Registered User)
membergrouids = 13 (Forum Supporter)
displaygroupid = 2

and I want to change that for all Forum Supporters to the following:

usergroupid = 2 (Registered User)
membergrouids = 13 (Forum Supporter)
displaygroupid = 13

It is crucial that the query check to ensure that the usergroupid = 2 AND membergroupids = 13 before making the update to usergroupid because there are some other usergroups that might get selected and I don't want to mess with their displaygroupid.

I would really like to have this as a PHP script so that I can add it to the Scheduled Task manager to run once a day for new members of the Forum Supporter usergroup. It would be sweet if it could be done via the subscription creation, but there is no option for controlling the displaygroupid that I know of.

I would really appreciate anyone being able to help me out.
Reply With Quote
  #2  
Old 06-17-2007, 04:25 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[sql]UPDATE `" . TABLE_PREFIX . "user`
SET `displaygroupid` = 13
WHERE `usergroupid` = 2
AND `membergroupids` = 13[/sql]
Reply With Quote
  #3  
Old 06-17-2007, 06:43 AM
Tourmeister Tourmeister is offline
 
Join Date: Nov 2005
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks.

How would I incorporate that into a PHP script that I could run from my browser or the task scheduler in the Admin CP? Wouldn't it need to include the config.php or something to be sure that it could log into the database? Lastly, would the "TABLE_PREFIX" variable work within the PHP script file?
Reply With Quote
  #4  
Old 06-17-2007, 06:50 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tourmeister View Post
Thanks.

How would I incorporate that into a PHP script that I could run from my browser or the task scheduler in the Admin CP? Wouldn't it need to include the config.php or something to be sure that it could log into the database?
Yes, you will need to include global.php and use $vbulletin->db>query_write("QUERY");.
Quote:
Originally Posted by Tourmeister View Post
Lastly, would the "TABLE_PREFIX" variable work within the PHP script file?
It only works within PHP files that have global.php included.
Reply With Quote
  #5  
Old 06-18-2007, 01:40 PM
Tourmeister Tourmeister is offline
 
Join Date: Nov 2005
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So would this be what I want for my PHP script? Also, would I place it in the /forums directory (that is where my forum site resides)

Quote:
<?php

require_once('./global.php');

$vbulletin->db>query_write("

UPDATE `" . TABLE_PREFIX . "user`
SET `displaygroupid` = 13
WHERE `usergroupid` = 2
AND `membergroupids` = 13

");

?>
Reply With Quote
  #6  
Old 06-19-2007, 07:33 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes.
Reply With Quote
  #7  
Old 06-22-2007, 03:23 AM
Tourmeister Tourmeister is offline
 
Join Date: Nov 2005
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm.... Got this as the result on my test forum

Quote:
Fatal error: Call to undefined function: query_write() in /home/vbscott/public_html/forums/update_fs_displaygroupid.php on line 5
using the file exactly as shown in my previous post. I am sure I am missing something really obvious... I have a disturbing knack for that

Ahhh.... as always...

There was no "-" after the $db in the line I cut/pasted from your post, hehe.

I should have looked closer. Anyway, I added it and the script seems to work perfectly. Thanks!

If I want to add this to my Scheduled Task Manager and place the script in the /includes/cron directory, can I leave out the this line:

require_once('./global.php');

since it is already in the cron.php file?
Reply With Quote
  #8  
Old 06-22-2007, 06:17 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It doesn't matter (notice "once"), keep it in there just incase.
Reply With Quote
  #9  
Old 06-23-2007, 01:43 AM
Tourmeister Tourmeister is offline
 
Join Date: Nov 2005
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, thanks! The Forum Supporter members really like the change!
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 10:58 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.05819 seconds
  • Memory Usage 2,240KB
  • Queries Executed 11 (?)
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_quote
  • (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
  • (9)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_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