diff options
| author | Greg Roach <fisharebest@gmail.com> | 2014-01-09 19:51:12 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2014-01-09 19:51:12 +0000 |
| commit | aa5831434fc2e7fe85fae99610f29e24b5f38b5f (patch) | |
| tree | 7c1203ef7aba38bd0c73ccf92ce80cff5b2d53a0 | |
| parent | 882552f9e25d5ea134b8f298c2afcf6a6cdb5ce8 (diff) | |
| download | webtrees-aa5831434fc2e7fe85fae99610f29e24b5f38b5f.tar.gz webtrees-aa5831434fc2e7fe85fae99610f29e24b5f38b5f.tar.bz2 webtrees-aa5831434fc2e7fe85fae99610f29e24b5f38b5f.zip | |
Sources/repositories without a TITL/NAME record cause fatal error
| -rw-r--r-- | js/webtrees-1.5.1.js | 14 | ||||
| -rw-r--r-- | library/WT/Controller/Repository.php | 8 | ||||
| -rw-r--r-- | library/WT/Controller/Source.php | 8 |
3 files changed, 23 insertions, 7 deletions
diff --git a/js/webtrees-1.5.1.js b/js/webtrees-1.5.1.js index a407ebf5d6..842a063620 100644 --- a/js/webtrees-1.5.1.js +++ b/js/webtrees-1.5.1.js @@ -263,6 +263,14 @@ function edit_record(xref, fact_id) { }); } +function add_fact(xref, fact) { + return edit_interface({ + "action": "add", + "xref": xref, + "fact": fact + }); +} + function edit_raw(xref) { return edit_interface({ "action": "editraw", @@ -283,11 +291,7 @@ function add_record(xref, fact_field) { if (fact == "OBJE") { window.open('addmedia.php?action=showmediaform&linkid=' + encodeURIComponent(xref) + '&ged=' + encodeURIComponent(WT_GEDCOM), '_blank', edit_window_specs); } else { - return edit_interface({ - "action": "add", - "xref": xref, - "fact": fact - }); + return add_fact(xref, fact); } } return false; diff --git a/library/WT/Controller/Repository.php b/library/WT/Controller/Repository.php index 0e8aa1df4c..2ce5a45204 100644 --- a/library/WT/Controller/Repository.php +++ b/library/WT/Controller/Repository.php @@ -53,7 +53,13 @@ class WT_Controller_Repository extends WT_Controller_GedcomRecord { if (WT_USER_CAN_EDIT) { $fact = $this->record->getFirstFact('NAME'); $submenu = new WT_Menu(WT_I18N::translate('Edit repository'), '#', 'menu-repo-edit'); - $submenu->addOnclick('return edit_record(\'' . $this->record->getXref() . '\', \'' . $fact->getFactId() . '\');'); + if ($fact) { + // Edit existing name + $submenu->addOnclick('return edit_record(\'' . $this->record->getXref() . '\', \'' . $fact->getFactId() . '\');'); + } else { + // Add new name + $submenu->addOnclick('return add_fact(\'' . $this->record->getXref() . '\', \'NAME\');'); + } $menu->addSubmenu($submenu); } diff --git a/library/WT/Controller/Source.php b/library/WT/Controller/Source.php index 3444c052ce..2fca4cf32d 100644 --- a/library/WT/Controller/Source.php +++ b/library/WT/Controller/Source.php @@ -53,7 +53,13 @@ class WT_Controller_Source extends WT_Controller_GedcomRecord { if (WT_USER_CAN_EDIT) { $fact = $this->record->getFirstFact('TITL'); $submenu = new WT_Menu(WT_I18N::translate('Edit source'), '#', 'menu-sour-edit'); - $submenu->addOnclick('return edit_record(\''.$this->record->getXref().'\', \'' . $fact->getFactId() . '\');'); + if ($fact) { + // Edit existing name + $submenu->addOnclick('return edit_record(\''.$this->record->getXref().'\', \'' . $fact->getFactId() . '\');'); + } else { + // Add new name + $submenu->addOnclick('return add_fact(\''.$this->record->getXref().'\', \'TITL\');'); + } $menu->addSubmenu($submenu); } |
