47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Addon admin functions.
|
|
*/
|
|
|
|
// Module ACL definitions.
|
|
$this("acl")->addResource('drone', [
|
|
'manage.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');
|
|
}
|
|
});
|