diff --git a/Controller/ConfigController.php b/Controller/ConfigController.php new file mode 100644 index 0000000..db40769 --- /dev/null +++ b/Controller/ConfigController.php @@ -0,0 +1,40 @@ + 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'))); + } +} diff --git a/Plugin.php b/Plugin.php index 79dc5e1..2c585af 100644 --- a/Plugin.php +++ b/Plugin.php @@ -20,6 +20,10 @@ class Plugin extends Base // 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'); + // 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 // not build the console app. if (php_sapi_name() === 'cli') { @@ -51,7 +55,7 @@ class Plugin extends Base public function getPluginVersion() { - return '1.2.0'; + return '1.3.0'; } public function getPluginHomepage() diff --git a/Template/config/show.php b/Template/config/show.php new file mode 100644 index 0000000..c0b126a --- /dev/null +++ b/Template/config/show.php @@ -0,0 +1,14 @@ +
+ = 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.') ?> +
+ + diff --git a/Template/config/sidebar.php b/Template/config/sidebar.php new file mode 100644 index 0000000..30cfc19 --- /dev/null +++ b/Template/config/sidebar.php @@ -0,0 +1,3 @@ +