global "Run now" scheduler button on new Settings page (v1.3)
This commit is contained in:
40
Controller/ConfigController.php
Normal file
40
Controller/ConfigController.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Plugin\RecoReco\Controller;
|
||||||
|
|
||||||
|
use Kanboard\Controller\BaseController;
|
||||||
|
use Kanboard\Plugin\RecoReco\Model\RecoRecoModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global settings page for RecoReco.
|
||||||
|
*
|
||||||
|
* Admin-only for free: the application ACL is keyed by the SHORT controller name, and core maps
|
||||||
|
* 'ConfigController' => APP_ADMIN (AuthenticationProvider::getApplicationAccessMap), so every action
|
||||||
|
* on a controller named ConfigController requires an application administrator -- plugin included.
|
||||||
|
* Keep admin-only actions in THIS controller; a differently-named controller would default to
|
||||||
|
* APP_USER (any logged-in user).
|
||||||
|
*/
|
||||||
|
class ConfigController extends BaseController
|
||||||
|
{
|
||||||
|
public function show()
|
||||||
|
{
|
||||||
|
$this->response->html($this->helper->layout->config('recoReco:config/show', array(
|
||||||
|
'title' => t('Settings').' > '.t('RecoReco'),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the scheduler now -- the same pass cron runs: spawn every template card whose occurrence
|
||||||
|
* is due, across all boards. Idempotent (an occurrence is never spawned twice), so it is safe to
|
||||||
|
* trigger at any time.
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$this->checkCSRFForm();
|
||||||
|
|
||||||
|
$count = (new RecoRecoModel($this->container))->run();
|
||||||
|
|
||||||
|
$this->flash->success(t('RecoReco: spawned %d card(s).', $count));
|
||||||
|
$this->response->redirect($this->helper->url->to('ConfigController', 'show', array('plugin' => 'RecoReco')));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,10 @@ class Plugin extends Base
|
|||||||
// Board card icon: black on a recurring template, white (inverse) on a generated copy.
|
// Board card icon: black on a recurring template, white (inverse) on a generated copy.
|
||||||
$this->template->hook->attach('template:board:task:icons', 'recoReco:board/task_icon');
|
$this->template->hook->attach('template:board:task:icons', 'recoReco:board/task_icon');
|
||||||
|
|
||||||
|
// Global settings page (Settings -> RecoReco) with a manual "Run now" button that triggers
|
||||||
|
// the same scheduler pass as cron. Admin-only for free via the shared 'ConfigController' ACL.
|
||||||
|
$this->template->hook->attach('template:config:sidebar', 'recoReco:config/sidebar');
|
||||||
|
|
||||||
// The scheduling engine runs from the CLI (cron). Registered CLI-only so web requests do
|
// The scheduling engine runs from the CLI (cron). Registered CLI-only so web requests do
|
||||||
// not build the console app.
|
// not build the console app.
|
||||||
if (php_sapi_name() === 'cli') {
|
if (php_sapi_name() === 'cli') {
|
||||||
@@ -51,7 +55,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '1.2.0';
|
return '1.3.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
14
Template/config/show.php
Normal file
14
Template/config/show.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<div class="page-header">
|
||||||
|
<h2><?= t('RecoReco') ?></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="form-help">
|
||||||
|
<?= t('Run the recurring-card scheduler now. This spawns every template card whose occurrence is due, on all boards -- the same pass the cron job runs. It is safe to run at any time: an occurrence is never spawned twice.') ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form method="post" action="<?= $this->url->href('ConfigController', 'run', array('plugin' => 'RecoReco')) ?>">
|
||||||
|
<?= $this->form->csrf() ?>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="submit" class="btn btn-blue"><?= t('Run now') ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
3
Template/config/sidebar.php
Normal file
3
Template/config/sidebar.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<li <?= $this->app->checkMenuSelection('ConfigController', 'show', 'RecoReco') ?>>
|
||||||
|
<?= $this->url->link(t('RecoReco'), 'ConfigController', 'show', array('plugin' => 'RecoReco')) ?>
|
||||||
|
</li>
|
||||||
Reference in New Issue
Block a user