. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Functions\FunctionsPrint; define('WT_SCRIPT_NAME', 'inverselink.php'); require './includes/session.php'; $controller = new SimpleController; $controller ->restrictAccess(Auth::isEditor($WT_TREE)) ->setPageTitle(I18N::translate('Link to an existing media object')) ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) ->addInlineJavascript('autocomplete();') ->pageHeader(); //-- page parameters and checking $linktoid = Filter::get('linktoid', WT_REGEX_XREF); $mediaid = Filter::get('mediaid', WT_REGEX_XREF); $linkto = Filter::get('linkto', 'person|source|family|manage|repository|note'); $action = Filter::get('action', 'choose|update', 'choose'); // If GedFAct_assistant/_MEDIA/ installed ====================== if ($linkto == 'manage' && Module::getModuleByName('GEDFact_assistant')) { require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/_MEDIA/media_0_inverselink.php'; } else { //-- check for admin $paramok = true; if (!empty($linktoid)) { $paramok = GedcomRecord::getInstance($linktoid, $WT_TREE)->canShow(); } if ($action == "choose" && $paramok) { echo '
'; } elseif ($action == "update" && $paramok) { $record = GedcomRecord::getInstance($linktoid, $WT_TREE); $record->createFact('1 OBJE @' . $mediaid . '@', true); $controller->addInlineJavascript('closePopupAndReloadParent();'); } echo ''; }