2026-07-05 10:20:45 -03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Kanboard\Plugin\OrganonTweaks\Controller;
|
|
|
|
|
|
|
|
|
|
use Kanboard\Controller\BaseController;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Settings page for the OrganonTweaks plugin: one toggle per tweak.
|
|
|
|
|
*/
|
|
|
|
|
class ConfigController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
public function show()
|
|
|
|
|
{
|
|
|
|
|
$this->response->html($this->helper->layout->config('organonTweaks:config/show', array(
|
|
|
|
|
'title' => t('Settings').' > '.t('Organon Tweaks'),
|
|
|
|
|
'values' => array(
|
|
|
|
|
'organon_tweaks_always_comment_icon' => (int) $this->configModel->get('organon_tweaks_always_comment_icon', 1),
|
2026-07-06 21:12:26 -03:00
|
|
|
'organon_tweaks_keep_scroll' => (int) $this->configModel->get('organon_tweaks_keep_scroll', 1),
|
2026-07-06 22:27:33 -03:00
|
|
|
'organon_tweaks_quick_click_only' => (int) $this->configModel->get('organon_tweaks_quick_click_only', 1),
|
2026-07-07 09:40:51 -03:00
|
|
|
'organon_tweaks_enhance_recurrence' => (int) $this->configModel->get('organon_tweaks_enhance_recurrence', 1),
|
2026-07-08 09:00:50 -03:00
|
|
|
'organon_tweaks_emphasize_duedate_default' => (int) $this->configModel->get('organon_tweaks_emphasize_duedate_default', 0),
|
2026-07-08 21:09:30 -03:00
|
|
|
'organon_tweaks_show_all_filter' => (int) $this->configModel->get('organon_tweaks_show_all_filter', 1),
|
2026-07-09 06:49:15 -03:00
|
|
|
'organon_tweaks_month_filters' => (int) $this->configModel->get('organon_tweaks_month_filters', 1),
|
2026-07-05 10:20:45 -03:00
|
|
|
),
|
|
|
|
|
'errors' => array(),
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function save()
|
|
|
|
|
{
|
|
|
|
|
$values = $this->request->getValues();
|
|
|
|
|
|
|
|
|
|
$alwaysCommentIcon = isset($values['organon_tweaks_always_comment_icon']) ? 1 : 0;
|
2026-07-06 21:12:26 -03:00
|
|
|
$keepScroll = isset($values['organon_tweaks_keep_scroll']) ? 1 : 0;
|
2026-07-06 22:27:33 -03:00
|
|
|
$quickClickOnly = isset($values['organon_tweaks_quick_click_only']) ? 1 : 0;
|
2026-07-08 09:13:07 -03:00
|
|
|
$enhanceRecurrence = isset($values['organon_tweaks_enhance_recurrence']) ? 1 : 0;
|
2026-07-08 09:00:50 -03:00
|
|
|
$emphasizeDueDateDefault = isset($values['organon_tweaks_emphasize_duedate_default']) ? 1 : 0;
|
2026-07-08 21:09:30 -03:00
|
|
|
$showAllFilter = isset($values['organon_tweaks_show_all_filter']) ? 1 : 0;
|
2026-07-09 06:49:15 -03:00
|
|
|
$monthFilters = isset($values['organon_tweaks_month_filters']) ? 1 : 0;
|
2026-07-05 10:20:45 -03:00
|
|
|
|
2026-07-06 21:12:26 -03:00
|
|
|
if ($this->configModel->save(array(
|
|
|
|
|
'organon_tweaks_always_comment_icon' => $alwaysCommentIcon,
|
|
|
|
|
'organon_tweaks_keep_scroll' => $keepScroll,
|
2026-07-06 22:27:33 -03:00
|
|
|
'organon_tweaks_quick_click_only' => $quickClickOnly,
|
2026-07-08 09:13:07 -03:00
|
|
|
'organon_tweaks_enhance_recurrence' => $enhanceRecurrence,
|
2026-07-08 09:00:50 -03:00
|
|
|
'organon_tweaks_emphasize_duedate_default' => $emphasizeDueDateDefault,
|
2026-07-08 21:09:30 -03:00
|
|
|
'organon_tweaks_show_all_filter' => $showAllFilter,
|
2026-07-09 06:49:15 -03:00
|
|
|
'organon_tweaks_month_filters' => $monthFilters,
|
2026-07-06 21:12:26 -03:00
|
|
|
))) {
|
2026-07-05 10:20:45 -03:00
|
|
|
$this->flash->success(t('Settings saved successfully.'));
|
|
|
|
|
} else {
|
|
|
|
|
$this->flash->failure(t('Unable to save your settings.'));
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-09 06:49:15 -03:00
|
|
|
// Apply each filter-group toggle across all boards immediately: on -> (re)create the group's
|
|
|
|
|
// reserved-name filters everywhere, off -> remove them (they are plugin-managed).
|
2026-07-08 21:09:30 -03:00
|
|
|
$projectHelper = new \Kanboard\Plugin\OrganonTweaks\Helper\OrganonProjectHelper($this->container);
|
|
|
|
|
|
|
|
|
|
if ($showAllFilter === 1) {
|
2026-07-09 06:49:15 -03:00
|
|
|
$projectHelper->addGroupToAllProjects($projectHelper::GROUP_SHOW_ALL);
|
2026-07-08 21:09:30 -03:00
|
|
|
} else {
|
2026-07-09 06:49:15 -03:00
|
|
|
$projectHelper->removeGroup($projectHelper::GROUP_SHOW_ALL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($monthFilters === 1) {
|
|
|
|
|
$projectHelper->addGroupToAllProjects($projectHelper::GROUP_MONTH);
|
|
|
|
|
} else {
|
|
|
|
|
$projectHelper->removeGroup($projectHelper::GROUP_MONTH);
|
2026-07-08 21:09:30 -03:00
|
|
|
}
|
|
|
|
|
|
2026-07-05 10:20:45 -03:00
|
|
|
$this->response->redirect($this->helper->url->to('ConfigController', 'show', array('plugin' => 'OrganonTweaks')));
|
|
|
|
|
}
|
|
|
|
|
}
|