ORIENT/modules/backend/controllers/Index.php

67 lines
1.5 KiB
PHP
Raw Normal View History

2014-05-14 13:24:20 +00:00
<?php namespace Backend\Controllers;
use Redirect;
use BackendAuth;
2014-05-14 13:24:20 +00:00
use BackendMenu;
use Backend\Classes\Controller;
use Backend\Widgets\ReportContainer;
/**
* Dashboard controller
*
* @package october\backend
* @author Alexey Bobkov, Samuel Georges
*
*/
class Index extends Controller
{
2014-10-24 06:38:24 +00:00
use \Backend\Traits\InspectableContainer;
2014-05-14 13:24:20 +00:00
/**
* @see checkPermissionRedirect()
*/
public $requiredPermissions = [];
2014-05-14 13:24:20 +00:00
/**
* Constructor.
*/
public function __construct()
{
parent::__construct();
BackendMenu::setContextOwner('October.Backend');
if (BackendAuth::check()) {
new ReportContainer($this);
}
2014-05-14 13:24:20 +00:00
}
public function index()
{
if ($redirect = $this->checkPermissionRedirect()) {
return $redirect;
}
$this->pageTitle = 'backend::lang.dashboard.menu_label';
2014-05-14 13:24:20 +00:00
BackendMenu::setContextMainMenu('dashboard');
}
public function index_onInitReportContainer()
{
return ['#dashReportContainer' => $this->widget->reportContainer->render()];
}
/**
* Custom permissions check that will redirect to the next
* available menu item, if permission to this page is denied.
*/
protected function checkPermissionRedirect()
{
if (!$this->user->hasAccess('backend.access_dashboard')) {
$true = function(){ return true; };
if ($first = array_first(BackendMenu::listMainMenuItems(), $true)) {
return Redirect::intended($first->url);
}
}
}
2014-10-10 21:26:57 +00:00
}