summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--import.php41
-rw-r--r--library/WT/Controller/Base.php7
-rw-r--r--library/WT/Controller/Simple.php7
3 files changed, 28 insertions, 27 deletions
diff --git a/import.php b/import.php
index 7269e1ee68..96f8c10954 100644
--- a/import.php
+++ b/import.php
@@ -30,21 +30,19 @@
define('WT_SCRIPT_NAME', 'import.php');
require './includes/session.php';
-
require_once WT_ROOT.'includes/functions/functions_import.php';
+$controller=new WT_Controller_Ajax();
+$controller
+ ->requireManagerLogin()
+ ->pageHeader()
+ ->addExternalJavaScript(WT_JQUERY_URL)
+ ->addExternalJavaScript(WT_JQUERYUI_URL);
+
// Don't use ged=XX as we want to be able to run without changing the current gedcom.
// This will let us load several gedcoms together, or to edit one while loading another.
$gedcom_id=safe_GET('gedcom_id');
-if (!userGedcomAdmin(WT_USER_ID, $gedcom_id)) {
- header('HTTP/1.0 403 Forbidden');
- exit;
-}
-
-// AJAX responses require a header
-header('Content-type: text/html; charset=UTF-8');
-
// Don't allow the user to cancel the request. We do not want to be left
// with an incomplete transaction.
ignore_user_abort(true);
@@ -67,11 +65,10 @@ if ($row->import_offset==$row->import_total) {
set_gedcom_setting($gedcom_id, 'imported', true);
// Finished? Show the maintenance links, similar to admin_trees_manage.php
WT_DB::exec("COMMIT");
- echo
- WT_JS_START,
- 'jQuery("#import', $gedcom_id, '").toggle();',
- 'jQuery("#actions', $gedcom_id, '").toggle();',
- WT_JS_END;
+ $controller->addInlineJavaScript(
+ 'jQuery("#import'. $gedcom_id.'").toggle();'.
+ 'jQuery("#actions'.$gedcom_id.'").toggle();'
+ );
exit;
}
@@ -79,11 +76,10 @@ if ($row->import_offset==$row->import_total) {
$percent=100*(($row->import_offset) / $row->import_total);
$status=WT_I18N::translate('Loading data from GEDCOM: %.1f%%', $percent);
-echo
- '<div id="progressbar', $gedcom_id, '"><div style="position:absolute;">', $status, '</div></div>',
- WT_JS_START,
- ' jQuery("#progressbar', $gedcom_id, '").progressbar({value: ', round($percent, 1), '});',
- WT_JS_END;
+echo '<div id="progressbar', $gedcom_id, '"><div style="position:absolute;">', $status, '</div></div>';
+$controller->addInlineJavaScript(
+ 'jQuery("#progressbar'.$gedcom_id.'").progressbar({value: '.round($percent, 1).'});'
+);
flush();
$first_time=($row->import_offset==0);
@@ -148,10 +144,9 @@ for ($end_time=microtime(true)+1.0; microtime(true)<$end_time; ) {
)->execute(array($gedcom_id));
break;
case 'ANSI': // ANSI could be anything. Most applications seem to treat it as latin1.
- echo
- WT_JS_START,
- 'alert("', /* I18N: %1$s and %2$s are the names of character encodings, such as ISO-8859-1 or ASCII */ WT_I18N::translate('This GEDCOM is encoded using %1$s. Assume this to mean %2$s.', $charset, 'ISO-8859-1'), '");',
- WT_JS_END;
+ $controller->addInlineJavaScript(
+ 'alert("', /* I18N: %1$s and %2$s are the names of character encodings, such as ISO-8859-1 or ASCII */ WT_I18N::translate('This GEDCOM is encoded using %1$s. Assume this to mean %2$s.', $charset, 'ISO-8859-1'), '");'
+ );
case 'WINDOWS':
case 'CP1252':
case 'ISO8859-1':
diff --git a/library/WT/Controller/Base.php b/library/WT/Controller/Base.php
index 2029aa9ab2..f424d5b549 100644
--- a/library/WT/Controller/Base.php
+++ b/library/WT/Controller/Base.php
@@ -97,9 +97,12 @@ class WT_Controller_Base {
}
// Restrict access
- public function requireManagerLogin() {
+ public function requireManagerLogin($ged_id=WT_GED_ID) {
require_once WT_ROOT.'includes/functions/functions.php'; // for get_query_url
- if (!WT_USER_GEDCOM_ADMIN) {
+ if (
+ $ged_id==WT_GED_ID && !WT_USER_GEDCOM_ADMIN ||
+ $ged_id!=WT_GED_ID && userGedcomAdmin(WT_USER_ID, $gedcom_id)
+ ) {
header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.get_site_setting('LOGIN_URL', 'login.php').'?url='.rawurlencode(get_query_url()));
exit;
}
diff --git a/library/WT/Controller/Simple.php b/library/WT/Controller/Simple.php
index d579f0793f..d4dc8cd3e0 100644
--- a/library/WT/Controller/Simple.php
+++ b/library/WT/Controller/Simple.php
@@ -50,8 +50,11 @@ class WT_Controller_Simple extends WT_Controller_Base {
}
// Restrict access
- public function requireManagerLogin() {
- if (!WT_USER_GEDCOM_ADMIN) {
+ public function requireManagerLogin($ged_id=WT_GED_ID) {
+ if (
+ $ged_id==WT_GED_ID && !WT_USER_GEDCOM_ADMIN ||
+ $ged_id!=WT_GED_ID && userGedcomAdmin(WT_USER_ID, $gedcom_id)
+ ) {
$this->addInlineJavaScript('opener.window.location.reload(); window.close();');
exit;
}