Hide total in columns
This commit is contained in:
34
Controller/FinanceColumnController.php
Normal file
34
Controller/FinanceColumnController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Plugin\FinanceBuddy\Controller;
|
||||
|
||||
use Kanboard\Controller\BaseController;
|
||||
use Kanboard\Core\Controller\AccessForbiddenException;
|
||||
use Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper;
|
||||
|
||||
/**
|
||||
* Toggle a board column's header total on/off from the column dropdown menu. The per-column flag
|
||||
* lives in project metadata; project-manager gated (same scope as enabling FinanceBuddy). Returns
|
||||
* to the board, whose reload re-renders the header with or without the total.
|
||||
*/
|
||||
class FinanceColumnController extends BaseController
|
||||
{
|
||||
public function toggleTotal()
|
||||
{
|
||||
$this->checkCSRFParam();
|
||||
$project = $this->getProject();
|
||||
|
||||
if (! $this->helper->user->hasProjectAccess('ProjectEditController', 'edit', $project['id'])) {
|
||||
throw new AccessForbiddenException();
|
||||
}
|
||||
|
||||
$key = FinanceHelper::HIDE_TOTAL_PREFIX.$this->request->getIntegerParam('column_id');
|
||||
|
||||
// Store the literal 'on'/'off' (both non-empty) rather than 1/0, so the flag is never lost
|
||||
// to PHP's empty("0") === true on the metadata save.
|
||||
$hidden = $this->projectMetadataModel->get($project['id'], $key, FinanceHelper::HIDE_TOTAL_OFF) === FinanceHelper::HIDE_TOTAL_ON;
|
||||
$this->projectMetadataModel->save($project['id'], array($key => $hidden ? FinanceHelper::HIDE_TOTAL_OFF : FinanceHelper::HIDE_TOTAL_ON));
|
||||
|
||||
$this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id'])));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user