Latest News:
Latest Mods: Latest Tutorials:


 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Add a column to managegroup under group memberships (custom profile field)
Author Message
b.h.
Proud Paid Member


Posts: 67
Joined: Aug 2009
Reputation: 0
Post: #1
[Solved] Add a column to managegroup under group memberships (custom profile field)
I'm trying to add in some custom profile field data in a new column where it lists the members of a group for the group leader.

Where it shows: Username, Contact, Pm, Registered date, posts and checkbox, I'd like to add something like their facebook page link in a column.

I need the sql statement for the managegroup.php file. and where it goes

just for arguments sake the field would be named 'fid4' in the userfields table.

Can anyone help me with this?
(This post was last modified: 05-20-2011, 12:32 AM by b.h.)
05-18-2011, 03:50 AM


TeraByTe
PHP Coder


Posts: 53
Joined: Mar 2011
Reputation: 1
Post: #2
RE: Add a column to managegroup under group memberships (custom profile field)
if your still connected to mybb then you would want to
...


Select XXX from XXX Where manager = "mybbuserID"

O.o I know thats not the right Syntax but thats what you would want to do.

[]Hallway Insider Forums - Join Now. [/]
Goals :
✔ = Complete X = Incomplete
[X] 1 Rep
[X] 5 Rep
[✔] 50 posts
[X] 100 Posts
05-18-2011, 07:45 AM
b.h.
Proud Paid Member


Posts: 67
Joined: Aug 2009
Reputation: 0
Post: #3
RE: Add a column to managegroup under group memberships (custom profile field)
(05-18-2011 07:45 AM)TeraByTe Wrote:  if your still connected to mybb then you would want to
...


Select XXX from XXX Where manager = "mybbuserID"

O.o I know thats not the right Syntax but thats what you would want to do.

not exactly what I was looking for...

here is the code that creates the list from managegroup.php, it definitely connected to the users table but I need to join it to the Userfields table as well:

PHP Code:
switch($db->type)
    {
        case 
"pgsql":
        case 
"sqlite":
            
$query $db->simple_select("users""*""','||additionalgroups||',' LIKE '%,".$mybb->input['gid'].",%' OR usergroup='".$mybb->input['gid']."'", array('order_by' => 'username'));
            break;
        default:
            
$query $db->simple_select("users""*""CONCAT(',',additionalgroups,',') LIKE '%,".$mybb->input['gid'].",%' OR usergroup='".$mybb->input['gid']."'", array('order_by' => 'username'));
    } 


A little bit further into the code this is where it seems to be pulling the actual fields, so , somewhere here I think, is where I need to pull the data from 'fid4'


PHP Code:
while($user $db->fetch_array($query))
    {
        
$altbg alt_trow();
        
$regdate my_date($mybb->settings['dateformat'].", ".$mybb->settings['timeformat'], $user['regdate']);
        
$post $user;
        
$sendpm $email '';
        if(
$mybb->settings['enablepms'] == && $post['receivepms'] != && $mybb->usergroup['cansendpms'] == && my_strpos(",".$post['ignorelist'].","",".$mybb->user['uid'].",") === false)
        {
            eval(
"\$sendpm = \"".$templates->get("postbit_pm")."\";");
        }
        
        if(
$user['hideemail'] != 1)
        {
            eval(
"\$email = \"".$templates->get("postbit_email")."\";");
        }
        else
        {
            
$email '';
        } 

Can anyone give me the actual code?
05-18-2011, 04:41 PM
b.h.
Proud Paid Member


Posts: 67
Joined: Aug 2009
Reputation: 0
Post: #4
RE: Add a column to managegroup under group memberships (custom profile field)
So I Changed the default to what you see below, and it seems to work when I call $field from the template:

PHP Code:
$field $user['fid4']; 


Anyway: One of you php/mySql Experts look at this and tell me if this is ok or is going to cause me trouble when I change this:

PHP Code:
default:
            
$query $db->simple_select("users""*""CONCAT(',',additionalgroups,',') LIKE '%,".$mybb->input['gid'].",%' OR usergroup='".$mybb->input['gid']."'", array('order_by' => 'username'));
    } 


to This:

PHP Code:
    default:
            
$query $db->query("
        SELECT u.*,f.*
        FROM "
.TABLE_PREFIX."users u
        LEFT JOIN "
.TABLE_PREFIX."userfields f ON (u.uid=f.ufid)
        WHERE u.usergroup='"
.$mybb->input['gid']."' OR u.additionalgroups='".$mybb->input['gid']."'
        ORDER BY u.username ASC"
);
    } 

I'm not really sure about the LIKE statement??? and if I need it??
(This post was last modified: 05-19-2011, 07:45 PM by b.h.)
05-19-2011, 07:44 PM
b.h.
Proud Paid Member


Posts: 67
Joined: Aug 2009
Reputation: 0
Post: #5
RE: Add a column to managegroup under group memberships (custom profile field)
Well it seems as though I found my answer To the "LIKE" statement.... Not that anyone around here seems interested, but I thought I'd document this just for some other poor soul down the line that might want to do this.

Anyway it seems the "LIKE" statement is needed because it filters through the additionalgroup field because it you are a member of more than 1 additional group then it is in that field seperated by commas. So now I have to figure out the correct php mysql statement to get that working, and I should have the entire mystery solved
Solved: someone can move this to tutorials if they like

Here's the correct query for the default:


PHP Code:
    $query $db->query("
        SELECT u.*,f.*
        FROM "
.TABLE_PREFIX."users u
        LEFT JOIN "
.TABLE_PREFIX."userfields f ON (u.uid=f.ufid)
        WHERE CONCAT(',',u.additionalgroups,',') LIKE '%,"
.$mybb->input['gid'].",%' OR u.usergroup='".$mybb->input['gid']."'
        ORDER BY u.username ASC"
);
    } 

you'll have to add some strings to pull the data from your templates

I added 3 Field strings:
PHP Code:
    {
        
$altbg alt_trow();
        
$regdate my_date($mybb->settings['dateformat'].", ".$mybb->settings['timeformat'], $user['regdate']);
        
$field $user['fid4'];// facebook address
        
$field2 =$user['fid11'];// User Name
        
$field3 =$user['fid12'];// phone number
        
$post $user
        
$sendpm $email '';
        if(
$mybb->settings['enablepms'] == && $post['receivepms'] != && $mybb->usergroup['cansendpms'] == && my_strpos(",".$post['ignorelist'].","",".$mybb->user['uid'].",") === false)
        {
            eval(
"\$sendpm = \"".$templates->get("postbit_pm")."\";");
        } 

then edited 2 templates under manage group Templates

First add column header names in the managegroup template

Then add the the field strings in the managegroup_user template

That's it
(This post was last modified: 05-20-2011, 12:30 AM by b.h.)
05-19-2011, 11:39 PM
 




User(s) browsing this thread: 2 Guest(s)