diff options
| author | Greg Roach <fisharebest@gmail.com> | 2015-02-10 13:46:37 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2015-02-10 13:46:37 +0000 |
| commit | a2da417c23376d75976404ccb470482b238cdad5 (patch) | |
| tree | 2fdd10b9d05b974399c315aea4654c08db39279e | |
| parent | 061f419f307374c2d49b3de303f1fd460672cf87 (diff) | |
| download | webtrees-a2da417c23376d75976404ccb470482b238cdad5.tar.gz webtrees-a2da417c23376d75976404ccb470482b238cdad5.tar.bz2 webtrees-a2da417c23376d75976404ccb470482b238cdad5.zip | |
Use parameter binding
| -rw-r--r-- | modules_v3/googlemap/module.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/modules_v3/googlemap/module.php b/modules_v3/googlemap/module.php index 40bdd4237e..e8c84225f9 100644 --- a/modules_v3/googlemap/module.php +++ b/modules_v3/googlemap/module.php @@ -148,7 +148,7 @@ class googlemap_WT_Module extends Module implements ModuleConfigInterface, Modul public function getTabContent() { global $controller; - if ($this->checkMapData()) { + if ($this->checkMapData($controller->record)) { ob_start(); echo '<link type="text/css" href ="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/css/wt_v3_googlemap.css" rel="stylesheet">'; echo '<table border="0" width="100%"><tr><td>'; @@ -1814,19 +1814,33 @@ class googlemap_WT_Module extends Module implements ModuleConfigInterface, Modul } /** + * Does an individual (or their spouse-families) have any facts with places? + * + * @oaram Individual $individual + * * @return string */ - private function checkMapData() { - global $controller; - $xrefs = "'" . $controller->record->getXref() . "'"; - $families = $controller->record->getSpouseFamilies(); - foreach ($families as $family) { - $xrefs .= ", '" . $family->getXref() . "'"; + private function checkMapData(Individual $individual) { + $statement = Database::prepare( + "SELECT COUNT(*) FROM `##placelinks` WHERE pl_gid = :xref AND pl_file = :tree_id" + ); + $args = array( + 'xref' => $individual->getXref(), + 'tree_id' => $individual->getTree()->getTreeId(), + ); + + if ($statement->execute($args)->fetchOne()) { + return true; } - return Database::prepare( - "SELECT COUNT(*) AS tot FROM `##placelinks` WHERE pl_gid IN (" . $xrefs . ") AND pl_file=?" - )->execute(array(WT_GED_ID))->fetchOne(); + foreach ($individual->getSpouseFamilies() as $family) { + $args['xref'] = $family->getXref(); + if ($statement->execute($args)->fetchOne()) { + return true; + } + } + + return false; } /** |
