summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2013-07-13 06:54:14 +0000
committerfisharebest <fisharebest@gmail.com>2013-07-13 06:54:14 +0000
commit3d5a9b6f3466027684aba3e57e2aefa139e4df41 (patch)
tree38c238ffd24e641e410c18b9903e7cb1a2aadaa1
parentbc9aad78de5d6494e2002f6707d856cddeb41879 (diff)
downloadwebtrees-3d5a9b6f3466027684aba3e57e2aefa139e4df41.tar.gz
webtrees-3d5a9b6f3466027684aba3e57e2aefa139e4df41.tar.bz2
webtrees-3d5a9b6f3466027684aba3e57e2aefa139e4df41.zip
Create separate edit actions for "add child" and "add inlinked indi". They need different access checks and do different things
-rw-r--r--admin_site_other.php2
-rw-r--r--edit_interface.php93
-rw-r--r--js/webtrees-1.5.0.js11
3 files changed, 73 insertions, 33 deletions
diff --git a/admin_site_other.php b/admin_site_other.php
index 127f0c7c6b..d919c2acf0 100644
--- a/admin_site_other.php
+++ b/admin_site_other.php
@@ -46,7 +46,7 @@ $controller
<table id="other">
<tr>
<td>
- <a href="#" onclick="addnewchild(''); return false;">
+ <a href="#" onclick="add_unlinked_indi(); return false;">
<?php echo /* I18N: An individual that is not linked to any other record */ WT_I18N::translate('Create a new individual'); ?>
</a>
</td>
diff --git a/edit_interface.php b/edit_interface.php
index 1f970aae66..271a2addb5 100644
--- a/edit_interface.php
+++ b/edit_interface.php
@@ -406,25 +406,31 @@ case 'addchild':
$famid = safe_GET('famid', WT_REGEX_XREF);
$family = WT_Family::getInstance($famid);
+ check_record_access($family);
- if ($family) {
- check_record_access($family);
- $controller->setPageTitle($family->getFullName() . ' - ' . WT_I18N::translate('Add a new child'));
- } else {
- $controller->setPageTitle(WT_I18N::translate('Add an unlinked person'));
- }
- $controller->pageHeader();
+ $controller
+ ->setPageTitle($family->getFullName() . ' - ' . WT_I18N::translate('Add a new child'))
+ ->pageHeader();
print_indi_form('addchildaction', null, $family, null, 'CHIL', $gender);
break;
////////////////////////////////////////////////////////////////////////////////
+case 'add_unlinked_indi':
+ $controller
+ ->requireManagerLogin()
+ ->setPageTitle(WT_I18N::translate('Add an unlinked person'))
+ ->pageHeader();
+
+ print_indi_form('add_unlinked_indi_action', null, null, null, null, null);
+ break;
+
+////////////////////////////////////////////////////////////////////////////////
case 'addspouse':
$famtag = safe_GET('famtag', '(HUSB|WIFE)');
$xref = safe_GET('xref', WT_REGEX_XREF);
$family = WT_Family::getInstance($xref);
-
check_record_access($family);
if ($famtag=='WIFE') {
@@ -1064,15 +1070,12 @@ case 'addchildaction':
$gedrec.=addNewFact($match);
}
}
- if ($family) {
- // $family is not set when creating unlinked individuals
- if (isset($_REQUEST['PEDI'])) {
- $PEDI = $_REQUEST['PEDI'];
- } else {
- $PEDI = '';
- }
- $gedrec .= "\n".WT_Gedcom_Code_Pedi::createNewFamcPedi($PEDI, $famid);
+ if (isset($_REQUEST['PEDI'])) {
+ $PEDI = $_REQUEST['PEDI'];
+ } else {
+ $PEDI = '';
}
+ $gedrec .= "\n".WT_Gedcom_Code_Pedi::createNewFamcPedi($PEDI, $famid);
if (safe_POST_bool('SOUR_INDI')) {
$gedrec = handle_updates($gedrec);
} else {
@@ -1082,22 +1085,21 @@ case 'addchildaction':
// Create the new child
$new_child = WT_GedcomRecord::createRecord($gedrec, WT_GED_ID);
- if ($family) {
- // Insert new child at the right place
- foreach ($family->getFacts('CHIL') as $fact) {
- $old_child = $fact->getTarget();
- if ($old_child && WT_Date::Compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate())<0) {
- // Insert before this child
- $family->updateFact($fact->getFactId(), "1 CHIL @" . $new_child->getXref()."@\n" . $fact->getGedcom(), !$keep_chan);
- $done = true;
- break;
- }
- }
- if (!$done) {
- // Append to end
- $family->updateFact(null, "1 CHIL @" . $new_child->getXref()."@\n", !$keep_chan);
+ // Insert new child at the right place
+ $done = false;
+ foreach ($family->getFacts('CHIL') as $fact) {
+ $old_child = $fact->getTarget();
+ if ($old_child && WT_Date::Compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate())<0) {
+ // Insert before this child
+ $family->updateFact($fact->getFactId(), "1 CHIL @" . $new_child->getXref()."@\n" . $fact->getGedcom(), !$keep_chan);
+ $done = true;
+ break;
}
}
+ if (!$done) {
+ // Append child at end
+ $family->updateFact(null, "1 CHIL @" . $new_child->getXref()."@\n", !$keep_chan);
+ }
if (safe_POST('goto')=='new') {
$controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");');
@@ -1107,6 +1109,37 @@ case 'addchildaction':
break;
////////////////////////////////////////////////////////////////////////////////
+case 'add_unlinked_indi_action':
+ $controller
+ ->requireManagerLogin()
+ ->setPageTitle(WT_I18N::translate('Add an unlinked person'))
+ ->pageHeader();
+
+ splitSOUR();
+ $gedrec ="0 @REF@ INDI";
+ $gedrec.=addNewName();
+ $gedrec.=addNewSex ();
+ if (preg_match_all('/([A-Z0-9_]+)/', $QUICK_REQUIRED_FACTS, $matches)) {
+ foreach ($matches[1] as $match) {
+ $gedrec.=addNewFact($match);
+ }
+ }
+ if (safe_POST_bool('SOUR_INDI')) {
+ $gedrec = handle_updates($gedrec);
+ } else {
+ $gedrec = updateRest($gedrec);
+ }
+
+ $new_indi = WT_GedcomRecord::createRecord($gedrec, WT_GED_ID);
+
+ if (safe_POST('goto')=='new') {
+ $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_indi->getRawUrl() . '");');
+ } else {
+ $controller->addInlineJavascript('closePopupAndReloadParent();');
+ }
+ break;
+
+////////////////////////////////////////////////////////////////////////////////
case 'addspouseaction':
$famid = safe_POST('famid', WT_REGEX_XREF); // Add a spouse to this family
$sex = safe_POST('SEX', '[MFU]');
diff --git a/js/webtrees-1.5.0.js b/js/webtrees-1.5.0.js
index f587c85487..4508789351 100644
--- a/js/webtrees-1.5.0.js
+++ b/js/webtrees-1.5.0.js
@@ -392,11 +392,18 @@ function add_new_record(xref, fact) {
return false;
}
-function addnewchild(xref, gender) {
+function addnewchild(famid, gender) {
edit_interface({
"action": "addchild",
"gender": gender,
- "xref": xref
+ "famid": famid
+ });
+ return false;
+}
+
+function add_unlinked_indi() {
+ edit_interface({
+ "action": "add_unlinked_indi",
});
return false;
}