vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Convert Secondary UserGroup to Primary UserGroup (https://vborg.vbsupport.ru/showthread.php?t=73782)

JustAskJulie 01-04-2005 09:51 PM

Convert Secondary UserGroup to Primary UserGroup
 
I'm looking for an easy way to convert a secondary usergroup to the primary usergroup for a group of members. All are in the same usergroup, but are currently listed as secondary users. In order to be able to build a mailing list or mail the users, they have to be listed as primary users of the group, so I need to know how to convert their primary usergroup.

They are currently listed as primary usergroup: Registered
with secondary usergroup: Club Owner

I need their primary usergroup to be Club Owner.

Marco van Herwaarden 01-05-2005 03:30 AM

If people in this group have a custom usertitle of for example Club Owner, you might wanna select on that.

JustAskJulie 01-05-2005 09:02 PM

Quote:

Originally Posted by MarcoH64
you might wanna select on that.

Not sure what you mean.

JustAskJulie 01-05-2005 09:33 PM

I figured out what you mean, you can build a mailing list based on a user title. I tried that and out of about 200 users that are in that user group (both primary and secondary users) that pulled about 69 (about 9 more than are listed as primary users) :(

I need some way to just convert all those secondary users to primary users, short of going through each one individually and doing it by hand.

Marco van Herwaarden 01-05-2005 09:34 PM

I mean that you can select on the user title when generating a mail list, so if this group got a unique user title, you could use that to select the members for the mailing.

Marco van Herwaarden 01-06-2005 04:09 PM

I got a better solution for you :D

Do the following modifications in your includes/adminfunctions_user.php (2 edits) and you will be able to select your users for the mailing also based on secondary membergroups.

In file includes/adminfunctions_user.php

Find:
PHP Code:

        print_membergroup_row($vbphrase['primary_usergroup'], 'user[usergroupid]'2$userarray); 

Add under:
PHP Code:

        // Start hack MarcoH64
        
print_membergroup_row($vbphrase['additional_usergroups'], 'user[membergroupids]'2$userarray);
        
// End hack MarcoH64 

In the same file find:
PHP Code:

    if (is_array($user['usergroupid']))
    { 
// for emails
        
foreach($user['usergroupid'] AS $id)
        {
            
$u_condition[] = "usergroupid = $id";
        } 

REPLACE by:
PHP Code:

    // Start hack MarcoH64
    
if (is_array($user['usergroupid']) OR is_array($user['membergroupids']))
    { 
// for emails
        
if (is_array($user['usergroupid']))
        {
            foreach(
$user['usergroupid'] AS $id)
            {
                
$u_condition[] = "usergroupid = $id";
            }
        }
        if (
is_array($user['membergroupids']))
        {
            foreach(
$user['membergroupids'] AS $id)
            {
                
$u_condition[] = "find_in_set($id, membergroupids)";
            }
        }
        
// End hack MarcoH64 

As usual test first on a test board, only limited tested by me.

Marco van Herwaarden 01-08-2005 07:26 AM

No feedback? Did this solve your problem?

JustAskJulie 01-10-2005 03:45 PM

Thanks, I'll give it a try.

trulylowcarb 03-04-2005 10:15 PM

I tried another hack for this that didn't work; I will try yours soon and will definitely come back with feedback. This is a much-needed feature... I can't believe it's not part of VB, for some reason I was under the impression it was, - right up until I actually needed it... what a rude awakening that was.
I have already changed the one group by hand, 224 of them, but I would still like to be able to email other now-secondary groups....
cross everything! :D

I got
Quote:

Parse error: parse error, unexpected T_ELSE in /includes/adminfunctions_user.php on line 279
when I tried to Send mail ...

Running vb3.07 and CMPS 1.0...1? (newest one...)

Marco van Herwaarden 03-05-2005 09:05 AM

I think you missed something in the second change in the file.

Please double check you edit

trulylowcarb 03-06-2005 02:45 AM

I probably had a piece of the first hack left, Huang's, which I have since gotten to work.... thanks!

Cyricx 04-07-2005 02:59 PM

This works like a charm Marcoh!

Any idea how to do the check box that turns them all on or all off like the primary group has?

Thanks so much man!

Marco van Herwaarden 04-07-2005 04:14 PM

Quote:

Originally Posted by Cyricx
This works like a charm Marcoh!

Any idea how to do the check box that turns them all on or all off like the primary group has?

Thanks so much man!

In you includes/adminfunctions_user.php, find:
PHP Code:

// Start hack MarcoH64 
        
print_membergroup_row($vbphrase['additional_usergroups'], 'user[membergroupids]'2$userarray); 
        
// End hack MarcoH64 

Replace by:
PHP Code:

  // Start hack MarcoH64 
?>
<script type="text/javascript">
function check_all_additional_usergroups(formobj, toggle_status)
{
 for (var i = 0; i < formobj.elements.length; i++)
 {
  var elm = formobj.elements[i];
  if (elm.type == "checkbox" && elm.name == 'user[membergroupids][]')
  {
   elm.checked = toggle_status;
  }
 }
}
</script>
<?php
  print_checkbox_row
($vbphrase['all_usergroups'] . " (Additional)"'usergroup_additional_all'0, -1$vbphrase['all_usergroups'] . " (Additional)"'check_all_additional_usergroups(this.form, this.checked);');
    
print_membergroup_row($vbphrase['additional_usergroups'], 'user[membergroupids]'2$userarray); 
    
// End hack MarcoH64

Again please test on a testboard first.

Marco van Herwaarden 04-07-2005 04:16 PM

Quote:

Originally Posted by JustAskJulie
Thanks, I'll give it a try.

Still no feedback? It was made for you ;)

arob42 05-16-2005 02:18 AM

Well, I added this to my website and it works great! I'll check out your Thread of the Week Hack next. Thanks!

Marco van Herwaarden 05-16-2005 07:56 AM

Thanks, maybe i should release this as a hack instead of just an answer in a thread.

henken 09-08-2005 02:45 PM

Quote:

Originally Posted by MarcoH64
No feedback? Did this solve your problem?


This works great. Thank you very much MarcoH64. Much appreciated. This should be noted by the vB staff and added as a next function in their upcoming releases :)

Marco van Herwaarden 09-08-2005 07:52 PM

Hehe, a bit late for 3.5, but nice that it works for you. :D

Boofo 09-08-2005 08:18 PM

Quote:

Originally Posted by MarcoH64
Hehe, a bit late for 3.5, but nice that it works for you. :D

Can you do this for 3.5? ;)

Marco van Herwaarden 09-09-2005 03:14 AM

I might have a look at it. Bump me again if i forget. :D

steven s 10-11-2005 01:22 AM

Quote:

Originally Posted by MarcoH64
I might have a look at it. Bump me again if i forget. :D

Bumping. Think this will work in 3.5?

Edit: I figured I'd give it a go. It seems to work.:)

axi 02-16-2006 12:25 PM

works like a dream xcept one of my primary users in that group wont get the message, why is that?? wierdf!

Marco van Herwaarden 02-16-2006 12:46 PM

If only 1 didn't get the message, the problem must be on his side.

axi 02-16-2006 02:55 PM

no no, you know how in vBulletin it shows who has been emailed, well over there.. it didnt list his name... why?? he is primary of that group.

Marco van Herwaarden 02-20-2006 10:54 AM

Sorry i don't understand you.

Warlock40 04-17-2006 06:50 PM

great hack. thought it was working on 3.5.4
but get this error when try to send out an email

Code:

Database error in vBulletin 3.5.4:

Invalid SQL:

                                SELECT user.userid, user.usergroupid, user.username, user.email, user.joindate,
                                        useractivation.activationid
                                FROM user AS user
                                LEFT JOIN userfield AS userfield ON (userfield.userid = user.userid)
                                LEFT JOIN usertextfield AS usertextfield ON (usertextfield.userid = user.userid)
                                LEFT JOIN useractivation AS useractivation ON (useractivation.userid = user.userid AND useractivation.type = 0)
                                WHERE
                1=1 AND (usergroupid = 6 OR usergroupid = 7 OR usergroupid = 50 OR usergroupid = 46 OR usergroupid = 51 OR usergroupid = 2 OR find_in_set(6, membergroupids) OR find_in_set(7, membergroupids) OR find_in_set(50, membergroupids) OR find_in_set(46, membergroupids) OR find_in_set(51, membergroupids) OR find_in_set(2, membergroupids))
                AND user.email <> ''
               
                                ORDER BY userid
                                LIMIT 0, 500;

MySQL Error  : Column: 'usergroupid' in where clause is ambiguous
Error Number : 1052


Warlock40 04-19-2006 05:04 PM

no support? No worries. removed the code from my forum. Good idea. Wish I could get it to go with 3.5.4.

tylneyt 04-25-2006 01:22 AM

Quote:

Originally Posted by MarcoH64
I got a better solution for you :D

Do the following modifications in your includes/adminfunctions_user.php (2 edits) and you will be able to select your users for the mailing also based on secondary membergroups.

In file includes/adminfunctions_user.php

Find:
PHP Code:

        print_membergroup_row($vbphrase['primary_usergroup'], 'user[usergroupid]'2$userarray); 

Add under:
PHP Code:

        // Start hack MarcoH64
        
print_membergroup_row($vbphrase['additional_usergroups'], 'user[membergroupids]'2$userarray);
        
// End hack MarcoH64 

In the same file find:
PHP Code:

    if (is_array($user['usergroupid']))
    { 
// for emails
        
foreach($user['usergroupid'] AS $id)
        {
            
$u_condition[] = "usergroupid = $id";
        } 

REPLACE by:
PHP Code:

    // Start hack MarcoH64
    
if (is_array($user['usergroupid']) OR is_array($user['membergroupids']))
    { 
// for emails
        
if (is_array($user['usergroupid']))
        {
            foreach(
$user['usergroupid'] AS $id)
            {
                
$u_condition[] = "usergroupid = $id";
            }
        }
        if (
is_array($user['membergroupids']))
        {
            foreach(
$user['membergroupids'] AS $id)
            {
                
$u_condition[] = "find_in_set($id, membergroupids)";
            }
        }
        
// End hack MarcoH64 

As usual test first on a test board, only limited tested by me.

there needs to be a line added for 3.5.4, then it works just fine:

REPLACE by:
PHP Code:

// Start hack MarcoH64 
    
if (is_array($user['usergroupid']) OR is_array($user['membergroupids'])) 
    { 
// for emails
// start addition, by tylneyt
// this line is necessary to create the variable in this scope
//
        
$u_condition = array();
// end addition 
        
if (is_array($user['usergroupid'])) 
        { 
            foreach(
$user['usergroupid'] AS $id
            { 
                
$u_condition[] = "usergroupid = $id"
            } 
        } 
        if (
is_array($user['membergroupids'])) 
        { 
            foreach(
$user['membergroupids'] AS $id
            { 
                
$u_condition[] = "find_in_set($id, membergroupids)"
            } 
        } 
        
// End hack MarcoH64 


hope that helps, should actually be a standard feature of next vB if you ask me!

smdani 06-01-2006 10:59 AM

I’ve same problem https://vborg.vbsupport.ru/showthrea...473#post975473
MySQL Error : Column: 'usergroupid' in where clause is ambiguous
Error Number : 1052

Tylneyt I’d hoped that your add will help me but after the code modification, the problem persists
?Any idea of what I would do?
I’m running vb 3.5.0 with MarcoH64’s modification

I don’t want to undo the MarcoH64’s code edition as it is very useful in my forum, but now I can’t send mails to primarygruop members :(

Panzer Max 06-09-2006 12:50 AM

That works beautifully! One would think this would be standard issue with vB.

Thanks!

s.blair 06-13-2006 02:45 PM

I've tried this hack, but when I only select an Additional Usergroup that only has 6 people in it, it instead emails all 1600 users.

Running v3.5.4 here with the hacks as listed by Marco and tylneyt.

I had to leave these lines below commented out as otherwise they would cause the crash smdani was seeing above.

$condition .= ' AND (' . implode(' OR ', $u_condition) . ')';
unset($u_condition);

Any help??

Thanks.
Scott

Warlock40 07-21-2006 05:02 PM

Quote:

Originally Posted by tylneyt
there needs to be a line added for 3.5.4, then it works just fine:

REPLACE by:
PHP Code:

// Start hack MarcoH64 
    
if (is_array($user['usergroupid']) OR is_array($user['membergroupids'])) 
    { 
// for emails
// start addition, by tylneyt
// this line is necessary to create the variable in this scope
//
        
$u_condition = array();
// end addition 
        
if (is_array($user['usergroupid'])) 
        { 
            foreach(
$user['usergroupid'] AS $id
            { 
                
$u_condition[] = "usergroupid = $id"
            } 
        } 
        if (
is_array($user['membergroupids'])) 
        { 
            foreach(
$user['membergroupids'] AS $id
            { 
                
$u_condition[] = "find_in_set($id, membergroupids)"
            } 
        } 
        
// End hack MarcoH64 


hope that helps, should actually be a standard feature of next vB if you ask me!

Thanks for the update. I'm going to wait for 3.6 stable before I tackle this one again. I still love the idea and agree it should be a standard option in VB.

makaiguy 08-16-2006 11:29 PM

Now that 3.6.0 is out, does anybody have any experience with this hack in 3.6.0?

johnmont 08-24-2006 05:04 PM

I had to do this for 3.5.4 -- its also apparently good practice to add intval to the condition....

REPLACE by:
PHP Code:

// Start hack MarcoH64 
if (is_array($user['usergroupid']) OR is_array($user['membergroupids'])) 
    { 
// for emails 
        
if (is_array($user['usergroupid'])) 
        { 
            foreach(
$user['usergroupid'] AS $id
            { 
                
$u_condition[] = "{$prefix}usergroupid = " intval($id);
            } 
        } 
        if (
is_array($user['membergroupids'])) 
        { 
            foreach(
$user['membergroupids'] AS $id
            { 
                
$u_condition[] = "FIND_IN_SET('" intval($id) . "', {$prefix}membergroupids)";
            } 
        } 
// End hack MarcoH64 



All times are GMT. The time now is 04:34 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.02489 seconds
  • Memory Usage 1,875KB
  • 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
  • (13)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (34)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