Create a block

Jay Matwichuk - July 1, 2009 - 03:20
Project:User registration notification
Version:6.x-1.11
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Issue tags:Roadmap
Description

For sites that require admin approval before accounts are activated, it would be great to have a block that either showed a list of non-activated accounts, or even just showed a message saying something like '3 user accounts need to be added [link to user page]'.

If you added something like that to this module, it would be much appreciated. Thank you.

#1

rmiddle - July 1, 2009 - 13:14

Interesting Idea? I will have to look into it and see if there is a way to tell who hasn't been approved yet.

Thanks
Robert

#2

Jay Matwichuk - July 1, 2009 - 16:24

I don't know that there is a way to check that directly, but I'm thinking you can do a check for blocked status, combined with a last login date of N/A - or it may be stored as 0 in the database, and displayed as N/A using php, I don't know. But that combination should signify users who have newly logged in.

Although users that have been banned/blocked without ever having logged in would throw up a false positive, but I think that case would be pretty rare.

Anyways, some food for thought.

#3

rmiddle - July 1, 2009 - 19:54

I am not sure. I know on my site there last login == account creation time if they never login but I don't approval login I simple have this module email me when they are created.

Thanks
Robert

#4

rmiddle - July 1, 2009 - 20:34

It might be as simple as showing the last 10 created users in the block. But as I said I need to see if there is a way to show users who are pending ver those that have been reviewed.

Thanks
Robert

#5

Jay Matwichuk - July 3, 2009 - 04:22

I actually just put this together myself. I thought you may want the code I used to add to your own module - feel free to use it if you are interested. It seems to work fine for me, but if you find any bugs, I'd be happy to hear about them.

Anyways, this is what I put together:

<?php
function pending_user_notification_block_block($op, $delta = 0, $edit = array())
{
    if(
$op == 'list')
    {
       
$block = array();
       
$block[0]['info'] = t('Pending User Accounts');
       
$block[0]['cache'] = BLOCK_NO_CACHE;
        return
$block;
    }
    if(
$op == 'view' && user_access('administer users', $account))
    {
       
$query = 'SELECT uid, name FROM users WHERE status = 0 AND created > 0 AND login = 0';
       
$ua_users = db_query($query);
       
       
$block['subject'] = t('Pending User Accounts');
       
$output_start = '<table><thead><tr><th scope="col">' . t('Username') . '</th><th scope="col">' . t('Edit') . '</th><th scope="col">' . t('Delete') . '</th></tr></thead><tbody>';
       
$output_middle = '';
        while(
$user = db_fetch_array($ua_users))
        {
           
$output_middle .= '<tr>';
           
$output_middle .= '<th scope="row">' . l($user['name'], 'user/' . $user['uid']) . '</th>';
           
$output_middle .= '<td>' . l(t('Edit'), 'user/' . $user['uid'] . '/edit') . '</td>';
           
$output_middle .= '<td>' . l(t('Delete'), 'user/' . $user['uid'] . '/delete') . '</td>';
           
$output_middle .= '</tr>';
        }
        if(
$output_middle == '')
        {
            return;
        }
       
$output_end = '</tbody></table>';
       
$block['content'] = $output_start . $output_middle . $output_end;
        return
$block;
    }
}
?>

You will of course have to change the function name to match your module.

#6

rmiddle - July 3, 2009 - 14:41

Hakulicious,

I will certanly look at this code for inclusion in 1.12.

Thanks
Robert

#7

rmiddle - July 3, 2009 - 14:45
Version:6.x-1.9» 6.x-1.11
 
 

Drupal is a registered trademark of Dries Buytaert.