Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
#814: Create admin group controller with index and edit actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Jan 16, 2013
1 parent 6719828 commit 636e5c6
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 1 deletion.
71 changes: 71 additions & 0 deletions src/FluxBB/Controllers/Admin/Groups.php
@@ -0,0 +1,71 @@
<?php
/**
* FluxBB - fast, light, user-friendly PHP forum software
* Copyright (C) 2008-2012 FluxBB.org
* based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public license for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category FluxBB
* @package Core
* @copyright Copyright (c) 2008-2012 FluxBB (http://fluxbb.org)
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
*/

namespace FluxBB\Controllers\Admin;

use App;
use View;
use FluxBB\Models\GroupRepositoryInterface;

class Groups extends Base
{

/**
* The groups repository
*
* @var GroupRepositoryInterface
*/
protected $groups;


public function __construct(GroupRepositoryInterface $groups)
{
$this->groups = $groups;
}

public function get_index()
{
$groups = $this->groups->getHierarchy();

return View::make('fluxbb::admin.groups.index')
->with('groups', $groups);
}

public function get_edit($id)
{
$group = $this->groups->find($id);
$perms = $this->groups->getPermissions($id);

if (is_null($group))
{
App::abort(404);
}

return View::make('fluxbb::admin.groups.edit')
->with('group', $group)
->with('perms', $perms);
}

}
6 changes: 5 additions & 1 deletion src/FluxBB/Core/CoreServiceProvider.php
Expand Up @@ -26,6 +26,7 @@
namespace FluxBB\Core;

use Illuminate\Support\ServiceProvider;
use FluxBB\Models\GroupRepository;

class CoreServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -57,7 +58,10 @@ public function boot()
*/
public function register()
{
//
$this->app->bind('FluxBB\Models\GroupRepositoryInterface', function($app)
{
return new GroupRepository($app['cache']);
});
}

/**
Expand Down
8 changes: 8 additions & 0 deletions src/routes.php
Expand Up @@ -121,5 +121,13 @@
'as' => 'admin',
'uses' => 'FluxBB\Controllers\Admin\Dashboard@get_index',
));
Route::get('admin/groups', array(
'as' => 'admin_groups',
'uses' => 'FluxBB\Controllers\Admin\Groups@get_index',
));
Route::get('admin/groups/{id}', array(
'as' => 'admin_groups_edit',
'uses' => 'FluxBB\Controllers\Admin\Groups@get_edit',
));
});

17 changes: 17 additions & 0 deletions src/views/admin/groups/edit.blade.php
@@ -0,0 +1,17 @@
@extends('fluxbb::admin.layout.main')

@section('main')

<h1>ADMIN groups</h1>

{{ $group->title }}

<h3>Permissions</h3>

<ul>
@foreach ($perms as $permission)
<li>{{ $permission }}</li>
@endforeach
</ul>

@stop
11 changes: 11 additions & 0 deletions src/views/admin/groups/index.blade.php
@@ -0,0 +1,11 @@
@extends('fluxbb::admin.layout.main')

@section('main')

<h1>ADMIN groups</h1>

@foreach ($groups as $group)
<p><a href="{{ route('admin_groups_edit', array('id' => $group->id)) }}">{{ $group->title }}</a></p>
@endforeach

@stop

0 comments on commit 636e5c6

Please sign in to comment.