Integrations hardening -- Set up dimmed off RecoReco/FinanceBuddy; honest Disable (v0.6.0)
This commit is contained in:
@@ -120,6 +120,18 @@ class QualKardHelper extends Base
|
|||||||
return (int) $this->projectMetadataModel->get($project_id, 'qualkard_col_'.$role, 0);
|
return (int) $this->projectMetadataModel->get($project_id, 'qualkard_col_'.$role, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is FinanceBuddy enabled on this board? QualKard refuses to convert a FinanceBuddy board (its
|
||||||
|
* restructure would wreck the finance columns).
|
||||||
|
*
|
||||||
|
* @param int $project_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function fbEnabled($project_id)
|
||||||
|
{
|
||||||
|
return (int) $this->projectMetadataModel->get($project_id, 'financebuddy_enabled', 0) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the inert RecoReco config for a card: move-mode to Study, fire from anywhere but Done,
|
* Write the inert RecoReco config for a card: move-mode to Study, fire from anywhere but Done,
|
||||||
* daily (innocuous -- QualKard sets the due date on each grade), anchor 0 so RecoReco skips it
|
* daily (innocuous -- QualKard sets the due date on each grade), anchor 0 so RecoReco skips it
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '0.5.0';
|
return '0.6.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
@@ -1,28 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
// QualKard is inside the shared Integrations form, so the buttons use formaction (NOT nested <form>s)
|
||||||
|
// to post to QualKard's own controller. Set up is destructive; disabling only stops the automation.
|
||||||
|
$has = $this->QualKardHelper->hasRecoReco();
|
||||||
|
$fb = $this->QualKardHelper->fbEnabled($project['id']);
|
||||||
|
$enabled = $this->QualKardHelper->isEnabled($project['id']);
|
||||||
|
$blocked = ! $has || $fb;
|
||||||
|
?>
|
||||||
<h3><i class="fa fa-graduation-cap fa-fw" aria-hidden="true"></i> <?= t('QualKard') ?></h3>
|
<h3><i class="fa fa-graduation-cap fa-fw" aria-hidden="true"></i> <?= t('QualKard') ?></h3>
|
||||||
<div class="listing">
|
<div class="listing">
|
||||||
<?php if (! $this->QualKardHelper->hasRecoReco()): ?>
|
<?php if ($enabled): ?>
|
||||||
|
|
||||||
<p class="form-help"><?= t('QualKard needs the RecoReco plugin (its move engine). Install RecoReco to use QualKard.') ?></p>
|
<p class="form-help"><?= t('QualKard is enabled on this board.') ?></p>
|
||||||
|
<div class="form-actions">
|
||||||
<?php elseif (! $this->QualKardHelper->isEnabled($project['id'])): ?>
|
<button type="submit" class="btn" formaction="<?= $this->url->href('QualKardController', 'reset', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>" onclick="return confirm('<?= t('Reset every card to unread and move them to Drafts. Continue?') ?>');"><?= t('Reset all cards') ?></button>
|
||||||
|
<button type="submit" class="btn btn-red" formaction="<?= $this->url->href('QualKardController', 'disable', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>"><?= t('Disable QualKard machinery') ?></button>
|
||||||
<p class="form-help"><?= t('Turn this project into a spaced-repetition study board. This restructures the columns to Drafts | Study | Hairy | Hard | Medium | Easy | Done and moves every card to Drafts.') ?></p>
|
</div>
|
||||||
<form method="post" action="<?= $this->url->href('QualKardController', 'setup', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>" onsubmit="return confirm('<?= t('This restructures the board and moves all cards to Drafts. Continue?') ?>');">
|
<p class="form-help"><?= t('"Disable" only stops the QualKard automation -- it does not restructure the board or touch your cards.') ?></p>
|
||||||
<?= $this->form->csrf() ?>
|
|
||||||
<button type="submit" class="btn btn-blue"><?= t('Set up QualKard study board') ?></button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<p class="form-help"><?= t('QualKard is enabled on this board.') ?></p>
|
<p class="form-help">
|
||||||
<form method="post" style="display:inline" action="<?= $this->url->href('QualKardController', 'reset', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>" onsubmit="return confirm('<?= t('Reset every card to unread and move them to Drafts. Continue?') ?>');">
|
<?php if (! $has): ?>
|
||||||
<?= $this->form->csrf() ?>
|
<?= t('QualKard needs the RecoReco plugin (its move engine).') ?>
|
||||||
<button type="submit" class="btn"><?= t('Reset all cards') ?></button>
|
<?php elseif ($fb): ?>
|
||||||
</form>
|
<?= t('Disabled while FinanceBuddy is enabled here -- QualKard would restructure the columns.') ?>
|
||||||
<form method="post" style="display:inline" action="<?= $this->url->href('QualKardController', 'disable', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>">
|
<?php else: ?>
|
||||||
<?= $this->form->csrf() ?>
|
<?= t('Set up turns this project into a study board: columns become Drafts | Study | Hairy | Hard | Medium | Easy | Done and every card moves to Drafts.') ?>
|
||||||
<button type="submit" class="btn btn-red"><?= t('Disable QualKard') ?></button>
|
<?php endif ?>
|
||||||
</form>
|
</p>
|
||||||
|
<div class="form-actions"<?= $blocked ? ' style="opacity:0.5"' : '' ?>>
|
||||||
|
<button type="submit" class="btn btn-blue" <?= $blocked ? 'disabled="disabled"' : '' ?> formaction="<?= $this->url->href('QualKardController', 'setup', array('plugin' => 'QualKard', 'project_id' => $project['id'])) ?>" onclick="return confirm('<?= t('This restructures the board and moves all cards to Drafts. Continue?') ?>');"><?= t('Set up QualKard study board') ?></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user