Estrarre tutti i nomi utente in tabella ordinabile e paginabile
Creare al volo un piccolo modulo Member List, creato e testato per Drupal 6.x:
FILE INSTALL:
<?php
// $Id: member_list.install,v 1.1 2010/11/20 14:11:59 danzisiweb Exp $
/**
* Implementation of hook_install().
* Inserts the member_list module's schema in the SQL database.
*/
function member_list_install() {
drupal_set_message(t('All install correctly member_list'));
watchdog("faq","All install correctly member_list");
}
/**
* Implementation of hook_uninstall().
* Remove the variables, nodes and schema corresponding to the member_list module.
*/
function member_list_uninstall() {
// Clear the cache tables.
cache_clear_all('*', 'cache', TRUE);
cache_clear_all('*', 'cache_filter', TRUE);
cache_clear_all('*', 'cache_menu', TRUE);
cache_clear_all('*', 'cache_page', TRUE);
drupal_set_message(t('All Unistalled'));
watchdog("member_list","All Unistalled member_list");
}
FILE INFO
; $Id: member_list.info,v 1.0 2010/11/20 14:11:59 danzisiweb Exp $
name = Lista utenti
description = Modulo che mostra elenco di utenti.
dependencies[] = user
core = 6.x
; Information added by danzisiweb packaging script on 2010/11/20
version = "6.x-1.4"
core = "6.x"
project = "member_list"
datestamp = "1290259619"
FILE MODULE:
<?php
/**
* Display help and module information
* @param path which path of the site we're displaying help
* @param arg array that holds the current path as would be returned from arg()
* @return help text for the path
*/
function member_list_help($path, $arg) {
$output = '';
switch ($path) {
case "admin/help#member_list":
$output = '<p>'. t("Permette di gestire il modulo member_list") .'</p>';
break;
}
return $output;
}
/**
* Valid permissions for this module
* @return array An array of valid permissions for the member_list module
*/
function member_list_perm() {
return array('access member_list', 'administer member_list');
}
function member_list_menu() {
$items = array();
$items['memberlist'] = array(
'title' => t('Lista utenti'),
'page callback' => 'drupal_get_form',
'page arguments' => array('member_list_main'),
'access arguments' => array('access member_list'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function member_list_main() {
global $language, $db_prefix;
$sqlcount = db_query("SELECT COUNT(uid) AS counter FROM {users}");
$obj = db_fetch_object($sqlcount);
$counter = $obj->counter;
drupal_set_title(t("Mostra users tot: %counter", array('%counter' => $counter)));
$header = array(
array('data' => t('Uid'), 'field' => 'uid', 'sort' => 'asc'),
array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
array('data' => t('Pass'), 'field' => 'pass', 'sort' => 'asc'),
array('data' => t('Mail'), 'field' => 'mail', 'sort' => 'asc'),
array('data' => t('Mode'), 'field' => 'mode', 'sort' => 'asc'),
array('data' => t('Sort'), 'field' => 'sort', 'sort' => 'asc'),
array('data' => t('Threshold'), 'field' => 'threshold', 'sort' => 'asc'),
array('data' => t('Theme'), 'field' => 'theme', 'sort' => 'asc'),
array('data' => t('Signature'), 'field' => 'signature', 'sort' => 'asc'),
array('data' => t('Signature_format'), 'field' => 'signature_format', 'sort' => 'asc'),
array('data' => t('Created'), 'field' => 'created', 'sort' => 'asc'),
array('data' => t('Access'), 'field' => 'access', 'sort' => 'asc'),
array('data' => t('Login'), 'field' => 'login', 'sort' => 'asc'),
array('data' => t('Status'), 'field' => 'status', 'sort' => 'asc'),
array('data' => t('Timezone'), 'field' => 'timezone', 'sort' => 'asc'),
array('data' => t('Language'), 'field' => 'language', 'sort' => 'asc'),
array('data' => t('Picture'), 'field' => 'picture', 'sort' => 'asc'),
array('data' => t('Init'), 'field' => 'init', 'sort' => 'asc'),
array('data' => t('Data'), 'field' => 'data', 'sort' => 'asc'),
array('data' => t('Timezone_name'), 'field' => 'timezone_name', 'sort' => 'asc'),
);
$query = 'SELECT * FROM {users}';
$query .= tablesort_sql($header);
$result = pager_query($query, 50);
while ($row = db_fetch_array($result)) {
// $rows[] = $row;
$rows[] = array($row['uid'], $row['name'], $row['pass'], $row['mail'], $row['mode'], $row['sort'], $row['threshold'], $row['theme'], $row['signature'], $row['signature_format'], $row['created'], $row['access'], $row['login'], $row['status'], $row['timezone'], $row['language'], $row['picture'], $row['init'], $row['data'], $row['timezone_name']);
}
if (!$rows) {
$rows[] = array(array('data' => t('Non ci sono record in questa tabella'), 'colspan' => 20));
}
$output .= "<div style="overflow-x:scroll">";
$output .= theme('table', $header, $rows);
$output .= "</div>";
$output .= theme('pager', NULL, 50, 0);
print theme('page', $output);
exit;
}
In allegato trovate il file member_list.zip
Allegato | Dimensione |
---|---|
![]() | 2.25 KB |
Argomenti:
- Accedi o registrati per inserire commenti.