2019-03-05 15:28:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Addon admin functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Module ACL definitions.
|
|
|
|
$this("acl")->addResource('drone', [
|
|
|
|
'manage.view',
|
|
|
|
'manage.deploy',
|
2019-03-06 12:26:09 +01:00
|
|
|
'manage.settings'
|
2019-03-05 15:28:29 +01:00
|
|
|
]);
|
|
|
|
|
2019-03-06 12:26:09 +01:00
|
|
|
/*
|
|
|
|
* 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");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2019-03-05 15:28:29 +01:00
|
|
|
$app->on('admin.init', function () use ($app) {
|
2019-03-06 12:26:09 +01:00
|
|
|
$settings = $app->storage->findOne('drone/settings');
|
|
|
|
if ($settings && $settings['active']) {
|
2019-03-05 15:28:29 +01:00
|
|
|
// Bind admin routes.
|
|
|
|
$this->bindClass('Drone\\Controller\\Admin', 'drone/deploys');
|
|
|
|
|
2019-03-05 16:45:04 +01:00
|
|
|
if ($app->module('cockpit')->hasaccess('drone', 'manage.view')) {
|
2019-03-05 15:28:29 +01:00
|
|
|
// 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,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2019-03-06 12:26:09 +01:00
|
|
|
|
|
|
|
if ($app->module('cockpit')->hasaccess('drone', 'manage.settings')) {
|
|
|
|
// Add settings
|
|
|
|
$this->bindClass('Drone\\Controller\\Settings', 'drone/settings');
|
|
|
|
}
|
2019-03-05 15:28:29 +01:00
|
|
|
});
|