diff options
| author | fisharebest <fisharebest@gmail.com> | 2011-10-20 14:38:22 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2011-10-20 14:38:22 +0000 |
| commit | 560dda5637ee9d7d535e46dd2ba0ce1ff2aace5c (patch) | |
| tree | ec7bf5dcde7837615c46ecac880ef8a4ad994998 | |
| parent | 2e92139d15275a64a33e314039a779583ac675a2 (diff) | |
| download | webtrees-560dda5637ee9d7d535e46dd2ba0ce1ff2aace5c.tar.gz webtrees-560dda5637ee9d7d535e46dd2ba0ce1ff2aace5c.tar.bz2 webtrees-560dda5637ee9d7d535e46dd2ba0ce1ff2aace5c.zip | |
Use consistent access when filtering data for export/download
| -rw-r--r-- | includes/functions/functions_export.php | 32 | ||||
| -rw-r--r-- | library/WT/GedcomRecord.php | 15 | ||||
| -rw-r--r-- | modules_v3/clippings/clippings_ctrl.php | 8 |
3 files changed, 14 insertions, 41 deletions
diff --git a/includes/functions/functions_export.php b/includes/functions/functions_export.php index 87d7484ae7..5adc0eb095 100644 --- a/includes/functions/functions_export.php +++ b/includes/functions/functions_export.php @@ -200,7 +200,7 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { $access_level=WT_PRIV_PUBLIC; break; case 'none': - $access_level=WT_USER_ACCESS_LEVEL; + $access_level=WT_PRIV_HIDE; break; } @@ -218,11 +218,7 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { " FROM `##individuals` WHERE i_file=? ORDER BY i_id" )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { - if ($exportOptions['privatize']=='none') { - $rec=$row['gedrec']; - } else { - list($rec)=WT_Person::getInstance($row)->privatizeGedcom($access_level); - } + list($rec)=WT_Person::getInstance($row)->privatizeGedcom($access_level); if ($exportOptions['noCustomTags']=='yes') { $rec=remove_custom_tags($rec); } @@ -241,11 +237,7 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { " FROM `##families` WHERE f_file=? ORDER BY f_id" )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { - if ($exportOptions['privatize']=='none') { - $rec=$row['gedrec']; - } else { - list($rec)=WT_Family::getInstance($row)->privatizeGedcom($access_level); - } + list($rec)=WT_Family::getInstance($row)->privatizeGedcom($access_level); if ($exportOptions['noCustomTags']=='yes') { $rec=remove_custom_tags($rec); } @@ -264,11 +256,7 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { " FROM `##sources` WHERE s_file=? ORDER BY s_id" )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { - if ($exportOptions['privatize']=='none') { - $rec=$row['gedrec']; - } else { - list($rec)=WT_Source::getInstance($row)->privatizeGedcom($access_level); - } + list($rec)=WT_Source::getInstance($row)->privatizeGedcom($access_level); if ($exportOptions['noCustomTags']=='yes') { $rec=remove_custom_tags($rec); } @@ -287,11 +275,7 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { " FROM `##other` WHERE o_file=? AND o_type!=? AND o_type!=? ORDER BY o_id" )->execute(array($ged_id, 'HEAD', 'TRLR'))->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { - if ($exportOptions['privatize']=='none') { - $rec=$row['gedrec']; - } else { - list($rec)=WT_GedcomRecord::getInstance($row)->privatizeGedcom($access_level); - } + list($rec)=WT_GedcomRecord::getInstance($row)->privatizeGedcom($access_level); if ($exportOptions['noCustomTags']=='yes') { $rec=remove_custom_tags($rec); } @@ -310,11 +294,7 @@ function export_gedcom($gedcom, $gedout, $exportOptions) { " FROM `##media` WHERE m_gedfile=? ORDER BY m_media" )->execute(array($ged_id))->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { - if ($exportOptions['privatize']=='none') { - $rec=$row['gedrec']; - } else { - list($rec)=WT_Media::getInstance($row)->privatizeGedcom($access_level); - } + list($rec)=WT_Media::getInstance($row)->privatizeGedcom($access_level); $rec = convert_media_path($rec, $exportOptions['path'], $exportOptions['slashes']); if ($exportOptions['noCustomTags']=='yes') { $rec=remove_custom_tags($rec); diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php index 4b2ffdac9e..8e988facbe 100644 --- a/library/WT/GedcomRecord.php +++ b/library/WT/GedcomRecord.php @@ -408,16 +408,11 @@ class WT_GedcomRecord { public function privatizeGedcom($access_level) { global $global_facts, $person_facts; - if ($this->canDisplayDetails($access_level)) { + if ($access_level==WT_PRIV_HIDE) { + // We may need the original record, for example when downloading a GEDCOM or clippings cart + return array($this->_gedrec, ''); + } elseif ($this->canDisplayDetails($access_level)) { // The record is not private, but the individual facts may be. - if ( - !strpos($this->_gedrec, "\n2 RESN") && - !isset($person_facts[$this->xref]) && - !preg_match('/\n1 (?:'.implode('|', array_keys($global_facts)).')/', $this->_gedrec) - ) { - // Nothing to indicate fact privacy needed - return array($this->_gedrec, ''); - } // Include the entire first line (for NOTE records) list($gedrec)=explode("\n", $this->_gedrec, 2); @@ -434,6 +429,8 @@ class WT_GedcomRecord { } return array($gedrec, $private_gedrec); } else { + // We cannot display the details, but we may be able to display + // limited data, such as links to other records. return array($this->createPrivateGedcomRecord($access_level), ''); } } diff --git a/modules_v3/clippings/clippings_ctrl.php b/modules_v3/clippings/clippings_ctrl.php index 1cc103e872..572b39ddf8 100644 --- a/modules_v3/clippings/clippings_ctrl.php +++ b/modules_v3/clippings/clippings_ctrl.php @@ -212,7 +212,7 @@ class WT_Controller_Clippings extends WT_Controller_Base { $access_level=WT_PRIV_PUBLIC; break; case 'none': - $access_level=WT_USER_ACCESS_LEVEL; + $access_level=WT_PRIV_HIDE; break; } @@ -220,11 +220,7 @@ class WT_Controller_Clippings extends WT_Controller_Base { $clipping = $cart[$i]; if ($clipping['gedcom'] == WT_GEDCOM) { $object=WT_GedcomRecord::getInstance($clipping['id']); - if ($this->privatize_export=='none') { - $record=find_gedcom_record($clipping['id'], WT_GED_ID); - } else { - list($record)=$object->privatizeGedcom($access_level); - } + list($record)=$object->privatizeGedcom($access_level); // Remove links to objects that aren't in the cart preg_match_all('/\n1 '.WT_REGEX_TAG.' @('.WT_REGEX_XREF.')@/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { |
