1
Cuidiu
New Members - Group
  • 2006/6/24 2:06

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


I would like to modify the following code to show only members from a certain group id. Is that possible? I've been able to alter setOrder and setSort but all attempts fail at anything more complicated. The groupid # is 4.
modules/system/blocks/system_blocks.php:
function b_system_newmembers_show($options)
{
    
$block = array();
    
$criteria = new CriteriaCompo(new Criteria('level'0'>'));
    
$limit = (!empty($options[0])) ? $options[0] : 10;
    
$criteria->setOrder('DESC');
    
$criteria->setSort('user_regdate');
    
$criteria->setLimit($limit);
    
$member_handler =& xoops_gethandler('member');
    
$newmembers =& $member_handler->getUsers($criteria);
    
$count count($newmembers);
    for (
$i 0$i $count$i++) {
        if ( 
$options[1] == ) {
            
$block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') != 'blank.gif' XOOPS_UPLOAD_URL.'/'.$newmembers[$i]->getVar('user_avatar') : '';
        } else {
            
$block['users'][$i]['avatar'] = '';
        }
        
$block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
        
$block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
        
$block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
    }
    return 
$block;
}


Can someone help?
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

2
Cuidiu
[Solved] Re: New Members - Group
  • 2006/6/24 23:37

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


I figured it out. I added a new criteria and that seems to work fine.
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

3
larceniii
Re: [Solved] Re: New Members - Group
  • 2006/7/6 15:38

  • larceniii

  • Just popping in

  • Posts: 11

  • Since: 2005/6/14


Not going to post the answer?
And What version of xoops?

I need help with this and I'm not sure where to look....

4
Cuidiu
Re: [Solved] Re: New Members - Group
  • 2006/7/6 18:50

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


larceniii wrote:
Not going to post the answer?
I wasn't sure if I should since it's a core hack.

And What version of xoops?
XOOPS version is in my sig at the bottom - 2.2.4. Are you using the same?

I need help with this and I'm not sure where to look....
I'll help if I can but I ended up adding criteria instead of separating by group so that probably isn't what you want. I added a custom field in the extended profiles (this is for a new site) and then added the new criteria in the code to show those with that criteria. If this sounds like what you need and you have the same version, I'm happy to post more.
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

5
larceniii
Re: [Solved] Re: New Members - Group
  • 2006/7/7 16:30

  • larceniii

  • Just popping in

  • Posts: 11

  • Since: 2005/6/14


Yes! Please post more, because if anything else at least maybe I'll start to understand whats going on.

I see your sig, and after I posted asking what version of XOOPS you had I saw your sig in your profile, but I went back to the fourm to check if I missed it, and your sig wasn't loading for two days. But now it is soo.... ???

I don't want to lose my new members block unless I have to.

How would I go about making a new module to list members of a group, and show the extended profile fields and my own manner.

And here's the biggest question...

Why hasn't this been done yet? It seems EVERYONE has been requesting it? I feel like I'm the only one who doesn't know, I keep searching but I can find anything anywhere (Module wise) where someone uses the extended profiles....

Thank you in advance for your time. :)

6
Cuidiu
Re: [Solved] Re: New Members - Group
  • 2006/7/7 17:21

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


Hi larceniii,

I have no idea why my sig wasn't showing. Very strange...

I have a meeting to attend. I will post how I modified the code in a hour or so.

Cuidiu
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

7
Cuidiu
Re: [Solved] Re: New Members - Group
  • 2006/7/7 19:48

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


Disclaimer / Notice: This was done because my post was not answered and I needed a solution. If there are problems in the code, please do step in and point them out. I am not a coder. I have no idea if this is inefficient or causes undue strain on the server/database.

Please use at your own risk and be sure to back up any files (db, template, system, etc.) before modifying them.

System New Members block mod/clone -
In modules/system/blocks/system_blocks.php, add this code after the b_system_topposters_edit block of code (not sure if it matters where it's placed):

function b_system_yourvariable_show($options)
{
    
$block = array();
    
$criteria = new CriteriaCompo(new Criteria('level'0'>'));
$criteria->add(new Criteria('fieldname'1));    
$limit = (!empty($options[0])) ? $options[0] : 10;
     
$criteria->setOrder('ASC');
 
$criteria->setSort('uname');
    
$criteria->setLimit($limit);
$profile_handler =& xoops_gethandler('profile');
$fields =& $profile_handler->loadFields();
    
$member_handler =& xoops_gethandler('member');
    
$yourvariable =& $member_handler->getUsers($criteria);
    
$count count($yourvariable);
  for (
$i 0$i $count$i++) {
        if (
$options[1] == ) {
            
$block['users'][$i]['avatar'] = $yourvariable[$i]->getVar('user_avatar') != 'blank.gif' XOOPS_UPLOAD_URL.'/'.$yourvariable[$i]->getVar('user_avatar') : '';
        } else {
            
$block['users'][$i]['avatar'] = '';
        }
        
$block['users'][$i]['id'] = $yourvariable[$i]->getVar('uid');
        
$block['users'][$i]['name'] = $yourvariable[$i]->getVar('uname');
  
$block['users'][$i]['field_title'] = $yourvariable[$i]->getVar('field_name');
   
$block['users'][$i]['field_title2'] = $yourvariable[$i]->getVar('field_name2');
    }
    return 
$block;
}

Replace all instances of "yourvariable" with your own title. Replace all instances of field_name field_title with the name/title of your custom field(s) used in extended profiles module. Along with other criteria, it pulls users meeting this:
$criteria->add(new Criteria('fieldname', 1));
Which is a yes/no radio button I set as a custom field.

After function b_system_newmembers_edit($options) code block add:
function b_system_yourvariable_edit($options)
{
    
$inputtag ".$options[0]."' />";
    
$form sprintf(_MB_SYSTEM_DISPLAY,$inputtag);
    
$form .= ""._MB_SYSTEM_DISPLAYA.;
    if ( 
$options[1] == ) {
        
$form .= " checked='checked'";
    }
    
$form .= " /> "._YES.";
    if ( 
$options[1] == ) {
        
$form .= " checked='checked'";
    }
    
$form .= " /> "._NO."";
    return 
$form;
}

Next in - system/xoops_version.php above the comment // Profile fields - add:
// Your_title Block
$modversion['blocks'][14]['file'] = "system_blocks.php";
$modversion['blocks'][14]['name'] = _MI_SYSTEM_BNAME15;
$modversion['blocks'][14]['description'] = "Your Description";
$modversion['blocks'][14]['show_func'] = "b_system_yourvariable_show";
$modversion['blocks'][14]['options'] = "10|1";
$modversion['blocks'][14]['edit_func'] = "b_system_yourvariable_edit";
$modversion['blocks'][14]['template'] = 'system_block_yourvariable.html';


Make sure the _MI_SYSTEM_BNAME is the correct # for your system then modify the system/language/english/modinfo.php file to incorporate _MI_SYSTEM_BNAME#.

Add the system_block_yourvariable.html to modules/system/templates/blocks/ directory. If I remember correctly, I copied system_block_newusers.html and modified it to suit my needs - using <{$user.field_title}> in the template.

Update the system module.

You should now be able to add and set the parameters of the new block in your blocks admin.

Good luck!
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

Login

Who's Online

360 user(s) are online (240 user(s) are browsing Support Forums)


Members: 0


Guests: 360


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits