/Quản lý website trường trung học phổ thông PHP/lc1/modules/users/admin/main.php
PHP | 231 lines | 196 code | 29 blank | 6 comment | 28 complexity | 56690c0fd3ee75a4786a7c12d4c190e3 MD5 | raw file
- <?php
- /**
- * @Project NUKEVIET CMS 3.0
- * @Author VINADES (contact@vinades.vn)
- * @Copyright(C) 2010 VINADES. All rights reserved
- * @Createdate 04/05/2010
- */
- if ( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' );
- $page_title = $table_caption = $lang_module['list_module_title'];
- $asel = $nv_Request->get_int( 'asel', 'get', 0 );
- $asel = ( ( defined( "NV_IS_GODADMIN" ) or ( defined( "NV_IS_SPADMIN" ) and $global_config['spadmin_add_admin'] == 1 ) ) and ! empty( $asel ) ) ? "&asel=1" : "";
- $sql = "FROM `" . NV_USERS_GLOBALTABLE . "`";
- $base_url = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel;
- $methods = array( //
- 'userid' => array(
- 'key' => 'userid', 'value' => $lang_module['search_id'], 'selected' => ''
- ), //
- 'username' => array(
- 'key' => 'username', 'value' => $lang_module['search_account'], 'selected' => ''
- ), //
- 'full_name' => array(
- 'key' => 'full_name', 'value' => $lang_module['search_name'], 'selected' => ''
- ), //
- 'email' => array(
- 'key' => 'email', 'value' => $lang_module['search_mail'], 'selected' => ''
- ) //
- );
- $method = $nv_Request->isset_request( 'method', 'post' ) ? $nv_Request->get_string( 'method', 'post', '' ) : ( $nv_Request->isset_request( 'method', 'get' ) ? urldecode( $nv_Request->get_string( 'method', 'get', '' ) ) : '' );
- $methodvalue = $nv_Request->isset_request( 'value', 'post' ) ? $nv_Request->get_string( 'value', 'post' ) : ( $nv_Request->isset_request( 'value', 'get' ) ? urldecode( $nv_Request->get_string( 'value', 'get', '' ) ) : '' );
- $orders = array(
- 'userid', 'username', 'full_name', 'email', 'regdate'
- );
- $orderby = $nv_Request->get_string( 'sortby', 'get', 'userid' );
- $ordertype = $nv_Request->get_string( 'sorttype', 'get', 'DESC' );
- if ( $ordertype != "ASC" ) $ordertype = "DESC";
- if ( ! empty( $method ) and isset( $methods[$method] ) and ! empty( $methodvalue ) )
- {
- $sql .= " WHERE `" . $method . "` LIKE '%" . $db->dblikeescape( $methodvalue ) . "%'";
- $base_url .= "&method=" . urlencode( $method ) . "&value=" . urlencode( $methodvalue );
- $methods[$method]['selected'] = " selected=\"selected\"";
- $table_caption = $lang_module['search_page_title'];
- }
- if ( ! empty( $orderby ) and in_array( $orderby, $orders ) )
- {
- $sql .= " ORDER BY `" . $orderby . "` " . $ordertype;
- $base_url .= "&sortby=" . $orderby . "&sorttype=" . $ordertype;
- }
- $page = $nv_Request->get_int( 'page', 'get', 0 );
- $per_page = 30;
- $sql2 = "SELECT SQL_CALC_FOUND_ROWS * " . $sql . " LIMIT " . $page . ", " . $per_page;
- $query2 = $db->sql_query( $sql2 );
- $result = $db->sql_query( "SELECT FOUND_ROWS()" );
- list( $all_page ) = $db->sql_fetchrow( $result );
- $users_list = array();
- $admin_in = array();
- while ( $row = $db->sql_fetchrow( $query2 ) )
- {
- $users_list[$row['userid']] = array( //
- 'userid' => ( int )$row['userid'], //
- 'username' => ( string )$row['username'], //
- 'full_name' => ( string )$row['full_name'], //
- 'email' => ( string )$row['email'], //
- 'regdate' => date( "d/m/Y H:i", $row['regdate'] ), //
- 'checked' => ( int )$row['active'] ? " checked=\"checked\"" : "", //
- 'disabled' => " onclick=\"nv_chang_status(" . $row['userid'] . ");\"", //
- 'is_edit' => true, //
- 'is_delete' => true, //
- 'level' => $lang_module['level0'], //
- 'is_admin' => false //
- );
- $admin_in[] = $row['userid'];
- }
- if ( $admin_in )
- {
- $admin_in = implode( ",", $admin_in );
- $sql = "SELECT `admin_id`, `lev` FROM `" . NV_AUTHORS_GLOBALTABLE . "` WHERE `admin_id` IN (" . $admin_in . ")";
- $query = $db->sql_query( $sql );
- while ( $row = $db->sql_fetchrow( $query ) )
- {
- $is_my = ( $admin_info['admin_id'] == $row['admin_id'] ) ? true : false;
- $superadmin = ( $row['lev'] == 1 or $row['lev'] == 2 ) ? true : false;
-
- $users_list[$row['admin_id']]['checked'] = " checked=\"checked\"";
- $users_list[$row['admin_id']]['disabled'] = " disabled=\"disabled\"";
- $users_list[$row['admin_id']]['is_edit'] = false;
- $users_list[$row['admin_id']]['is_delete'] = false;
- if ( $row['lev'] == 1 )
- {
- $users_list[$row['admin_id']]['level'] = $lang_module['level1'];
- $users_list[$row['admin_id']]['img'] = 'admin1';
- }
- elseif ( $row['lev'] == 2 )
- {
- $users_list[$row['admin_id']]['level'] = $lang_module['level2'];
- $users_list[$row['admin_id']]['img'] = 'admin2';
- }
- else
- {
- $users_list[$row['admin_id']]['level'] = $lang_module['level3'];
- $users_list[$row['admin_id']]['img'] = 'admin3';
- }
-
- $users_list[$row['admin_id']]['is_admin'] = true;
-
- if ( defined( 'NV_IS_GODADMIN' ) )
- {
- $users_list[$row['admin_id']]['is_edit'] = true;
- }
- elseif ( defined( 'NV_IS_SPADMIN' ) and ( $is_my or ! $superadmin ) )
- {
- $users_list[$row['admin_id']]['is_edit'] = true;
- }
- elseif ( $is_my )
- {
- $users_list[$row['admin_id']]['is_edit'] = true;
- }
- }
- }
- $generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page );
- $head_tds = array();
- $head_tds['userid']['title'] = $lang_module['userid'];
- $head_tds['userid']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel . "&sortby=userid&sorttype=ASC";
- $head_tds['username']['title'] = $lang_module['account'];
- $head_tds['username']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel . "&sortby=username&sorttype=ASC";
- $head_tds['full_name']['title'] = $lang_module['name'];
- $head_tds['full_name']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel . "&sortby=full_name&sorttype=ASC";
- $head_tds['email']['title'] = $lang_module['email'];
- $head_tds['email']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel . "&sortby=email&sorttype=ASC";
- $head_tds['regdate']['title'] = $lang_module['register_date'];
- $head_tds['regdate']['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel . "&sortby=regdate&sorttype=ASC";
- foreach ( $orders as $order )
- {
- if ( $orderby == $order and $ordertype == 'ASC' )
- {
- $head_tds[$order]['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel . "&sortby=" . $order . "&sorttype=DESC";
- $head_tds[$order]['title'] .= " ↓";
- }
- elseif ( $orderby == $order and $ordertype == 'DESC' )
- {
- $head_tds[$order]['href'] = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel . "&sortby=" . $order . "&sorttype=ASC";
- $head_tds[$order]['title'] .= " ↑";
- }
- }
- $xtpl = new XTemplate( "main.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
- $xtpl->assign( 'LANG', $lang_module );
- $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel );
- $xtpl->assign( 'SORTURL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . $asel );
- $xtpl->assign( 'SEARCH_VALUE', $methodvalue );
- $xtpl->assign( 'TABLE_CAPTION', $table_caption );
- if ( defined( 'NV_IS_USER_FORUM' ) )
- {
- $xtpl->parse( 'main.is_forum' );
- }
- foreach ( $methods as $m )
- {
- $xtpl->assign( 'METHODS', $m );
- $xtpl->parse( 'main.method' );
- }
- foreach ( $head_tds as $head_td )
- {
- $xtpl->assign( 'HEAD_TD', $head_td );
- $xtpl->parse( 'main.head_td' );
- }
- foreach ( $users_list as $u )
- {
- $xtpl->assign( 'CONTENT_TD', $u );
- $xtpl->assign( 'NV_BASE_SITEURL', NV_BASE_SITEURL );
- $xtpl->assign( 'NV_ADMIN_THEME', $global_config['admin_theme'] );
- if ( $u['is_admin'] )
- {
- $xtpl->parse( 'main.xusers.is_admin' );
- }
- if ( ! empty( $asel ) )
- {
- if ( ! $u['is_admin'] )
- {
- $xtpl->assign( 'ASEL_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=authors&" . NV_OP_VARIABLE . "=add&userid=" . $u['userid'] );
- $xtpl->parse( 'main.xusers.asel' );
- }
- }
- elseif ( !defined( 'NV_IS_USER_FORUM' ) )
- {
- if ( $u['is_edit'] )
- {
- $xtpl->assign( 'EDIT_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=edit&userid=" . $u['userid'] );
- $xtpl->parse( 'main.xusers.edit' );
- }
- if ( $u['is_delete'] )
- {
- $xtpl->parse( 'main.xusers.del' );
- }
- }
-
- $xtpl->parse( 'main.xusers' );
- }
- if ( ! empty( $generate_page ) )
- {
- $xtpl->assign( 'GENERATE_PAGE', $generate_page );
- $xtpl->parse( 'main.generate_page' );
- }
- $xtpl->parse( 'main' );
- $contents = $xtpl->text( 'main' );
- include ( NV_ROOTDIR . "/includes/header.php" );
- echo nv_admin_theme( $contents );
- include ( NV_ROOTDIR . "/includes/footer.php" );
- ?>