array(
'title' => t('Access default users list'),
'description' => t('Access default users list.'),
),
'access default UC roles expiration list' => array(
'title' => t('access default UC roles expiration list'),
'description' => t('access default UC roles expiration list.'),
),
'access duplicate mails list' => array(
'title' => t('access duplicate mails list'),
'description' => t('access duplicate mails list.'),
),
);
}
/**
* Implements hook_menu().
*/
function materio_admin_menu() {
$items['admin/users/duplicatemails'] = array(
'title' => "Duplicate mails",
'page callback' => 'materio_duplicatemails',
'access callback' => 'user_access',
'access arguments' => array('access duplicate mails list'),
'type' => MENU_LOCAL_TASK
);
if(module_exists('simplenews')){
$cats = simplenews_category_list();
// dsm($cats, 'cats');
foreach ($cats as $tid => $name) {
// $items['node/%node/simplenews'] = array(
// 'title' => 'Newsletter',
// 'type' => MENU_LOCAL_TASK,
// 'access callback' => 'simplenews_node_tab_access',
// 'access arguments' => array(1),
// 'page callback' => 'simplenews_node_tab_page',
// 'page arguments' => array(1),
// 'context' => MENU_LOCAL_TASK,
// 'file' => 'includes/simplenews.admin.inc',
// 'weight' => 2,
// );
$items['node/add/simplenews/'.$tid] = array(
'title' => $name,
'title callback' => 'check_plain',
'page callback' => 'node_add',
'page arguments' => array('simplenews'),
'access callback' => 'node_access',
'access arguments' => array('create', 'simplenews'),
'file path' => drupal_get_path('module', 'node'),
'file' => 'node.pages.inc',
);
}
}
return $items;
}
function materio_duplicatemails(){
$mails = db_query('SELECT mail FROM {users} GROUP BY mail HAVING count(mail) > 1')->fetchCol();
// Bail out early if there are no duplicates.
if (!$mails) {
return t('All accounts have unique email addresses.');
}
// Grab all the user data for accounts with addresses identified as
// duplicates. This is a little convoluted, but it lets us grab all the user
// data in one shot.
$uids = db_select('users', 'u')
->fields('u', array('uid'))
->condition('mail', $mails, 'IN')
->orderBy('access', 'DESC')
->execute()
->fetchCol();
$duplicate_users = user_load_multiple($uids);
$duplicate_mails = array();
foreach ($duplicate_users as $duplicate_user) {
$duplicate_mails[$duplicate_user->mail][] = $duplicate_user;
}
// Turn the data we've got into markup.
$output = t('Accounts with duplicate email address:') . '
';
$output = "