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')));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user