ACP Module - View User Styles

Post your MODs, receive and provide feedback!
Topics in this forum are not for MOD support, they are for giving the author feedback.
Forum rules
The topics in this forum are not for general MOD support, they are for giving the MOD author some feedback, ideas and bug reports.
Post Reply
Elglobo
Past Contributor
Past Contributor
Posts: 119
Joined: 15 Jul 2008, 19:42

ACP Module - View User Styles

Post by Elglobo »

This post was originally posted by Kenny at 6 String MODs, I have made some minor adjustments.

Created from a request made by [url=http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=254148]JasonWade[/url] in [url=http://www.phpbb.com/community/viewtopic.php?f=72&t=1198695]this topic[/url] on phpBB.com
This snippet adds a new page to the ACP, listing all users and which style they are currently using. I recommend adding this module to the 'Users & Groups' section of the ACP :)

adm/style/acp_user_styles.html

Code: Select all

<!-- INCLUDE overall_header.html -->

<a name="maincontent"></a>


   <h1>{L_ACP_VIEW_USERS_STYLE}</h1>
   <p>{L_ACP_VIEW_USERS_STYLE_EXPLAIN}</p>

   <fieldset class="tabulated">

   <legend>{L_ACP_VIEW_USERS_STYLE}</legend>

   <table cellspacing="1">
   <thead>
   <tr>
      <th>{L_USERNAME}</th>
      <th>{L_USER_STYLE}</th>
   </tr>
   </thead>

   <!-- IF .users -->
   <tbody>
   <!-- BEGIN users -->

      <!-- IF mod.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF -->
         <td style="text-align: center;">{users.USERNAME_FULL}</td>
         <td style="text-align: center;"><a href="{users.U_PREVIEW_STYLE}" title="{L_VIEW_STYLE}">{users.USER_STYLE}</a></td>
      </tr>

   <!-- END users-->

   </tbody>
   </table>

   <!-- ELSE -->

   </table>

   <div class="errorbox">
      <p><strong>{L_NO_USERS_ACP}</strong></p>
      <br />
   </div>

<!-- ENDIF -->

<!-- IF PAGINATION or TOTAL_USERS -->
   <div class="pagination">
      {TOTAL_USERS}<!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF -->
   </div>

<!-- ENDIF -->

   </fieldset>

<!-- INCLUDE overall_footer.html -->

includes/acp/info/acp_user_styles.php

Code: Select all

<?php
/**
*
* @package acp
* @version $Id: acp_user_styles.php, 0002 16:34 21/09/2008 cherokee red Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @package module_install
*/
class acp_user_styles_info
{
    function module()
    {
        return array(
            'filename'            => 'acp_user_styles',
            'title'                => 'ACP_USER_STYLES',
            'version'            => '1.0.0',
            'modes'                => array(
                'acp_user_styles'    => array('title' => 'ACP_USER_STYLES',        'auth' => 'acl_a_user',     'cat' => array('ACP_CAT_USERS')),
            ),
        );
    }

    function install()
    {
    }

    function uninstall()
    {
    }

}

?>

includes/acp/acp_user_styles.php

Code: Select all

<?php
/** 
*
* @package acp
* @version $Id: acp_user_styles.php,0024 09:28 01/09/2008 cherokee red Exp $
* @copyright (c) 2007 phpBB Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
    exit;
}

/**
* @package acp
*/
class acp_user_styles
{
    var $u_action;

    function main($id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;

        $user->add_lang('mods/user_styles');

        // Set up general vars
        $action = request_var('action', '');
        $start = request_var('start', 0);

        // Set up the page
        $this->tpl_name     = 'acp_user_styles';
        $this->page_title     = 'ACP_USER_STYLES';

        $form_name = 'acp_user_styles';
        add_form_key($form_name);


        // How many userss do we have?
        $sql = 'SELECT COUNT(user_id) AS total_users
        FROM '
 . USERS_TABLE . '
                WHERE user_type = '
. USER_NORMAL .'
                OR user_type = '
 . USER_FOUNDER .'
            ORDER BY user_id'
;
        $result = $db->sql_query($sql);
        $total_users = (int) $db->sql_fetchfield('total_users');
        $db->sql_freeresult($result);    


        
// Pull users & styles from the database
        $sql = $db->sql_build_query('SELECT', array(
            'SELECT'    => 'u.user_id, u.username, u.username_clean, u.user_colour, u.user_style, u.user_type, s.style_id, s.style_name',

            'FROM'        => array(
                USERS_TABLE        => 'u',
                STYLES_TABLE        => 's'
            ),

            'WHERE'        => 'u.user_style = s.style_id AND (u.user_type = '. USER_NORMAL .' or u.user_type = ' . USER_FOUNDER .')',

            'ORDER_BY'    => 'u.user_id ASC'
        ));
        
        $result 
= $db->sql_query_limit($sql, $config['topics_per_page'], $start);


        while ($row = $db->sql_fetchrow($result)) 
        
{
            $style_id = $row['style_id'];
            $template->assign_block_vars('users', array(
                'STYLE_ID'            => $style_id,
                'USER_STYLE'        => $row['style_name'],
                'USERNAME_FULL'        => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
                'USERNAME'            => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
                'USER_COLOR'        => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
                'U_VIEW_PROFILE'    => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
                'U_PREVIEW_STYLE'    => generate_board_url() . "/index.$phpEx?style=$style_id",
            ));    
        
}
        $db->sql_freeresult($result);

        $pagination_url = $this->u_action;

        $template->assign_vars(array( 
            
'PAGINATION'    =>  generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start, true),
            'S_ON_PAGE'        => on_page($total_users, $config['topics_per_page'], $start),
            'TOTAL_USERS'    => ($total_users == 1) ? $user->lang['USER_COUNT'] : sprintf($user->lang['USER_COUNTS'], $total_users),
            'U_ACTION'        => $this->u_action)
        );
    }
}

?>

language/en/mods/user_styles.php

Code: Select all

<?php
/** 
*
*
* @package language
* @version $Id: users_styles.php 0005 16:35 21/09/2008 cherokee red $
* @copyright (c) 2005 phpBB Group 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* DO NOT CHANGE
*/
if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

// View User Styles
$lang = array_merge($lang, array(
    'ACP_VIEW_USERS_STYLE'            => 'View User Styles',
    'ACP_VIEW_USERS_STYLE_EXPLAIN'    => 'See which style each user is currently using.',

    'NO_USERS_ACP'        => 'There are currently no users on your forum',

    'USERNAME'        => 'Username',
    'USER_STYLE'    => 'Users Style',
    'VIEW_STYLE'    => 'View Style',

    'USER_COUNT'    => '1 user',
    'USER_COUNTS'    => '%d users',
));

?>

OPEN: language/en/acp/common.php
FIND:

Code: Select all

   'ACP_USER_SIG'               => 'Signature',

AFTER ADD:

Code: Select all

   'ACP_USER_STYLES'            => 'View User Styles',

Once all the files have been uploaded and edited accordingly, add the new module to your ACP.
Follow these intructions on how to do that: http://wiki.phpbb.com/display/MODDOCS/Tutorial.Adding+modules
User avatar
tumba25
Supporter
Supporter
Posts: 1052
Joined: 24 Oct 2007, 13:10
Real name: Jari Kanerva
Location: Kokkola, Finland.
Contact:

Re: ACP Module - View User Styles

Post by tumba25 »

And this is submitted to the MODDB for validation. And a github repo created. https://github.com/phpbbmodders/ACP-User-Styles
Elglobo
Past Contributor
Past Contributor
Posts: 119
Joined: 15 Jul 2008, 19:42

Re: ACP Module - View User Styles

Post by Elglobo »

Great ;)
phpBB-Services.com: L'hébergement et l'assistance de votre forum phpBB en toute tranquillité.

Myff.fr - My First forum, créer votre forum phpBB3 facilement !
Elglobo
Past Contributor
Past Contributor
Posts: 119
Joined: 15 Jul 2008, 19:42

Re: ACP Module - View User Styles

Post by Elglobo »

This MOD has been validated into the MOD Database.
phpBB-Services.com: L'hébergement et l'assistance de votre forum phpBB en toute tranquillité.

Myff.fr - My First forum, créer votre forum phpBB3 facilement !
Post Reply