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

Reply
 
Thread Tools Display Modes
  #1  
Old 06-16-2010, 05:58 PM
Bobbo Bobbo is offline
 
Join Date: Feb 2003
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default removing specific data from membergroupids

I've got a plugin that extends many of the VB permissions out to an external datasource.

One of the things I am trying to do is make updates to the membergroupids column of the user table based on logic in my plugin.

I'm unsure how exactly to read the contents of membergroupids for a user and strip out only a single id number without changing the rest. So for example is user A has membergroupids set to 9,10, 11 and my plugin determines that this user should no longer have access to 10, I want to update that value to be 9,11.

Does anyone have some insight on an easy method to accomplish this?

Thanks!

Bobbo
Reply With Quote
  #2  
Old 06-22-2010, 12:18 PM
Bobbo Bobbo is offline
 
Join Date: Feb 2003
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone have some thoughts on this one?

I think what I am trying to do is update the array, but if I try to unset one of the values using a foreach statement it doesnt work.

I suspect someone with more php knowledge than myself would know how to do this.

I'd really appreciate any help.

Thanks.

B
Reply With Quote
  #3  
Old 06-25-2010, 07:13 PM
Bobbo Bobbo is offline
 
Join Date: Feb 2003
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I think I got this one licked...

I can tell the interest level by the high level of responses... lol. ;-)

Anyhow, I'm doing something like this.

Code:
eval('$getids = array ('.$vbulletin->userinfo['membergroupids'].');');
$dropid = "12"; //in my real code, this value is determined by an external MS SQL lookup
for($i=0;$i<count($getids);$i++) {
if($getids[$i] == $dropid) {
unset($getids[$i]);
}
}
$idupdate = implode(",", $getids);
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET membergroupids = '" . $idupdate . "' WHERE email = '" . $username . "' LIMIT 1 ");
So basically, i'm reading the contents of the membergroupids into an array, reading through the array until I find a usergroup id match, I then unset that array element, implode the array into a variable, and write it back to the database.

Seems to work really well. Not sure if there are any 'gotchas' or reasons why this would be a problem. If anyone has any feedback, I'd apprecaite it.

Maybe it will help someone else...

Bobbo
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:11 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.03954 seconds
  • Memory Usage 2,171KB
  • 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
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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