vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   removing specific data from membergroupids (https://vborg.vbsupport.ru/showthread.php?t=244739)

Bobbo 06-16-2010 05:58 PM

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 :rolleyes:

Bobbo 06-22-2010 12:18 PM

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

Bobbo 06-25-2010 07:13 PM

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


All times are GMT. The time now is 01:40 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.01009 seconds
  • Memory Usage 1,711KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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