Skip to content

Commit

Permalink
管理员管理,首页和侧边栏修改
Browse files Browse the repository at this point in the history
  • Loading branch information
xsir317 committed Nov 25, 2014
1 parent 635f0a3 commit 2a55228
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
25 changes: 25 additions & 0 deletions publisher/app/controllers/UsersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

class UsersController extends BaseController {
//用户列表
public function all()
{
if(!Auth::user()->is_superadmin)
{
App::abort(403, 'Unauthorized action.');
}
return View::make("users/list",array("users"=>User::all()));
}

//添加用户
public function edit()
{

}

//改密码
public function changepwd()
{

}
}
7 changes: 6 additions & 1 deletion publisher/app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@
Route::get('projects/srclog',array('before' => 'auth', 'uses' => 'ProjectsController@getSrclog'));
Route::post('projects/dopublish',array('before' => 'auth', 'uses' => 'ProjectsController@dopublish'));
Route::post('projects/querystatus',array('before' => 'auth', 'uses' => 'ProjectsController@queryStatus'));

//服务器
Route::any('servers/add',array('before' => 'auth', 'uses' => 'ServersController@editServer'));
Route::any('servers/edit',array('before' => 'auth', 'uses' => 'ServersController@editServer'));

//用户
Route::get('users/index',array('before' => 'auth', 'uses' => 'UsersController@all'));
Route::any('users/edit',array('before' => 'auth', 'uses' => 'UsersController@edit'));
Route::any('users/add',array('before' => 'auth', 'uses' => 'UsersController@edit'));
Route::any('users/password',array('before' => 'auth', 'uses' => 'UsersController@changepwd'));
//登入登出
Route::any('login','HomeController@login');
Route::get('logout',function(){
Expand Down
14 changes: 8 additions & 6 deletions publisher/app/views/sidebar.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

<?php
$sidebar = array(
array('首页','/','index','uk-icon-home'),
array('项目','/projects/index','projects','uk-icon-gear'),
//array('服务器','/servers/index','servers','uk-icon-laptop'),
array('用户管理','/admin/users','users','uk-icon-male'),
array('权限分配','/admin/index','roles','uk-icon-users'),
array('登出','/logout','logout','uk-icon-sign-out'),
//显示名称、URL、菜单项、图标、管理员显示
array('首页','/','index','uk-icon-home',false),
array('项目','/projects/index','projects','uk-icon-gear',false),
array('用户管理','/users/index','users','uk-icon-male',true),
array('修改密码','/users/password','pwd','uk-icon-asterisk',false),
array('权限分配','/admin/index','roles','uk-icon-users',false),
array('登出','/logout','logout','uk-icon-sign-out',false),
);
?>
<nav class="uk-panel uk-panel-box">
<ul class="uk-nav uk-nav-side">
<?php foreach($sidebar as $row):?>
<?php if($row[4] && !Auth::user()->is_superadmin) continue;?>
<li<?php if($row[2] == $currpage):?> class="uk-active"<?php endif; ?>><a href="<?php echo $row[1];?>"><i class="<?php echo $row[3]?>"></i>&nbsp;&nbsp;<?php echo $row[0];?></a></li>
<?php endforeach;?>
<ul>
Expand Down
32 changes: 32 additions & 0 deletions publisher/app/views/users/list.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@extends('layouts.master')
@section('title')
管理员列表 @parent @stop
@section('sidebar')
@include('sidebar', array('currpage'=>'users'))
@stop

@section('content')
<table class="uk-table">
<caption>所有管理员&nbsp;&nbsp;<a href="/users/add" class="uk-button uk-button-primary">添加管理员</a></caption>
<thead>
<tr>
<th>登录名</th>
<th>最后登录IP</th>
<th>超级管理员</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($users as $row):?>
<tr>
<td><?php echo $row->username;?></td>
<td><?php echo $row->login_ip;?></td>
<td><?php echo $row->is_superadmin ? '':'';?></td>
<td>
<a href="/users/edit?id=<?php echo $row->id;?>" class="uk-button">编辑</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
@stop

0 comments on commit 2a55228

Please sign in to comment.