summaryrefslogtreecommitdiff
path: root/app/Module/ResearchTaskModule.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-07-07 09:45:44 +0100
committerGreg Roach <fisharebest@webtrees.net>2018-07-07 09:45:44 +0100
commite490cd80ad2d75f9f6adf9b41698ad3f3f058276 (patch)
treef818c8913c94e793e92551fc7adb27e56adce39c /app/Module/ResearchTaskModule.php
parentd57f6cd5c26c4243009eb8e9a3abb84847850682 (diff)
downloadwebtrees-e490cd80ad2d75f9f6adf9b41698ad3f3f058276.tar.gz
webtrees-e490cd80ad2d75f9f6adf9b41698ad3f3f058276.tar.bz2
webtrees-e490cd80ad2d75f9f6adf9b41698ad3f3f058276.zip
Remove global variables from blocks
Diffstat (limited to 'app/Module/ResearchTaskModule.php')
-rw-r--r--app/Module/ResearchTaskModule.php23
1 files changed, 13 insertions, 10 deletions
diff --git a/app/Module/ResearchTaskModule.php b/app/Module/ResearchTaskModule.php
index 8876ef91f3..e3246fae51 100644
--- a/app/Module/ResearchTaskModule.php
+++ b/app/Module/ResearchTaskModule.php
@@ -20,6 +20,7 @@ use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
+use Fisharebest\Webtrees\Tree;
/**
* Class ResearchTaskModule
@@ -43,14 +44,15 @@ class ResearchTaskModule extends AbstractModule implements ModuleBlockInterface
/**
* Generate the HTML content of this block.
*
+ * @param Tree $tree
* @param int $block_id
* @param bool $template
* @param string[] $cfg
*
* @return string
*/
- public function getBlock($block_id, $template = true, $cfg = []): string {
- global $ctype, $WT_TREE;
+ public function getBlock(Tree $tree, int $block_id, bool $template = true, array $cfg = []): string {
+ global $ctype;
$show_other = $this->getBlockSetting($block_id, 'show_other', self::DEFAULT_SHOW_OTHER);
$show_unassigned = $this->getBlockSetting($block_id, 'show_unassigned', self::DEFAULT_SHOW_UNASSIGNED);
@@ -64,12 +66,12 @@ class ResearchTaskModule extends AbstractModule implements ModuleBlockInterface
"SELECT DISTINCT d_gid FROM `##dates`" .
" WHERE d_file = :tree_id AND d_fact = '_TODO' AND d_julianday1 < :jd"
)->execute([
- 'tree_id' => $WT_TREE->getTreeId(),
+ 'tree_id' => $tree->getTreeId(),
'jd' => $end_jd,
])->fetchOneColumn();
- $records = array_map(function ($xref) use ($WT_TREE) {
- return GedcomRecord::getInstance($xref, $WT_TREE);
+ $records = array_map(function ($xref) use ($tree) {
+ return GedcomRecord::getInstance($xref, $tree);
}, $xrefs);
$tasks = [];
@@ -91,10 +93,10 @@ class ResearchTaskModule extends AbstractModule implements ModuleBlockInterface
}
if ($template) {
- if ($ctype === 'gedcom' && Auth::isManager($WT_TREE)) {
- $config_url = route('tree-page-block-edit', ['block_id' => $block_id, 'ged' => $WT_TREE->getName()]);
+ if ($ctype === 'gedcom' && Auth::isManager($tree)) {
+ $config_url = route('tree-page-block-edit', ['block_id' => $block_id, 'ged' => $tree->getName()]);
} elseif ($ctype === 'user' && Auth::check()) {
- $config_url = route('user-page-block-edit', ['block_id' => $block_id, 'ged' => $WT_TREE->getName()]);
+ $config_url = route('user-page-block-edit', ['block_id' => $block_id, 'ged' => $tree->getName()]);
} else {
$config_url = '';
}
@@ -129,11 +131,12 @@ class ResearchTaskModule extends AbstractModule implements ModuleBlockInterface
/**
* An HTML form to edit block settings
*
- * @param int $block_id
+ * @param Tree $tree
+ * @param int $block_id
*
* @return void
*/
- public function configureBlock($block_id) {
+ public function configureBlock(Tree $tree, int $block_id) {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$this->setBlockSetting($block_id, 'show_other', Filter::postBool('show_other'));
$this->setBlockSetting($block_id, 'show_unassigned', Filter::postBool('show_unassigned'));