CockpitCMS-Drone/admin.php
Sebastian Frank c1230087e6
extended view
2019-03-08 10:59:56 +01:00

48 lines
1.2 KiB
PHP

<?php
/**
* @file
* Addon admin functions.
*/
// Module ACL definitions.
$this("acl")->addResource('drone', [
'manage.view',
'manage.extended_view',
'manage.deploy',
'manage.settings'
]);
/*
* add menu entry to settings
*/
$this->on('cockpit.view.settings.item', function () {
if ($this->module('cockpit')->hasaccess('drone', 'manage.settings')) {
$this->renderView("drone:views/partials/settings.php");
}
});
$app->on('admin.init', function () use ($app) {
$settings = $app->storage->findOne('drone/settings');
if ($settings && $settings['active']) {
// Bind admin routes.
$this->bindClass('Drone\\Controller\\Admin', 'drone/deploys');
if ($app->module('cockpit')->hasaccess('drone', 'manage.view')) {
// Add to modules menu.
$this('admin')->addMenuItem('modules', [
'label' => 'Drone Deploys',
'icon' => 'drone:icon.svg',
'route' => '/drone/deploys',
'active' => strpos($this['route'], '/drone/deploys') === 0,
]);
}
}
if ($app->module('cockpit')->hasaccess('drone', 'manage.settings')) {
// Add settings
$this->bindClass('Drone\\Controller\\Settings', 'drone/settings');
}
});