Skip to content
5 changes: 0 additions & 5 deletions conf/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

; only for HathiTrust site

[IntoCopyright]
; YYYYMMDDHH
date = 9999999999


[Switches]
fetchAlephHolings = false
onlyHathiHoldings = true
Expand Down
21 changes: 3 additions & 18 deletions services/Record/RecordUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ function record_is_tombstone($rec) {

function is_fullview($rcode, $inUSA = null) {

global $configArray;
if (!isset($inUSA)) {
$session = VFSession::instance();
$inUSA = $session->get('inUSA');
Expand All @@ -199,23 +198,9 @@ function is_fullview($rcode, $inUSA = null) {
// Assume false
$fv = false;

// Newly into copyright? Return true if after the right date
// The munged facet is in Solr.php -- don't forget
// to deal with that, too.

$todays_date = intval(date("YmdH"));
$copyright_active_date = intval($configArray['IntoCopyright']['date']);
if (is_array($rcode) &&
array_search("newly_open", $rcode) &&
$todays_date >= $copyright_active_date
) {
return true;
} else if (is_array($rcode)) { // ditch the newly_open marker
$index = array_search("newly_open", $rcode);
if ($index) {
unset($rcode[$index]);
}
$rcode = $rcode[0];
if (is_array($rcode)) {
// Empty array? Just use default empty string.
$rcode = empty($rcode) ? '' : reset($rcode);
}

// Public domain? return true
Expand Down
21 changes: 0 additions & 21 deletions sys/Solr.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ function filterComponents($ss) {

if ($index == "ht_availability" and $oval == 'Full text') {
$ft = $this->fulltext_filter_base();
$ft = $this->fulltext_filter_add_jan1_rollover($ft);
$ft = $this->fulltext_filter_add_etas_or_resource_sharing($ft);
$rv[] = $ft;
}
Expand Down Expand Up @@ -463,26 +462,6 @@ function fulltext_filter_add_etas_or_resource_sharing($current_ft_filter) {
}
}

function fulltext_filter_add_jan1_rollover($current_ft_filter) {
// Hack into place a change of the full-text only facet
// for the temporary newly_open rightscode value
// but only on or after the date from config.ini

global $configArray;

$todays_date = intval(date("YmdH"));
$copyright_active_date = intval($configArray['IntoCopyright']['date']);

if ($todays_date >= $copyright_active_date) {
$newly_open = $this->quoteFilterValue('newly_open');
return "($current_ft_filter OR ht_rightscode:$newly_open)";
}
else {
return $current_ft_filter;
}
}


/**
* tagIDs($ss)
*
Expand Down
59 changes: 59 additions & 0 deletions test/RecordUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,65 @@ public function test_ht_link_data_from_json_activated_role(): void {
$this->assertEquals(true, $data['has_activated_role']);
$this->assertEquals('resourceSharing', $data['role_name']);
}

/**
* @covers RecordUtils::is_fullview
*/
public function test_is_fullview(): void {
$utils = new RecordUtils();
$examples = [
// Rights fv us? fv non-us?
['pd', true, true],
['ic', false, false],
['op', false, false],
['orph', false, false],
['und', false, false],
// umall is obsolete, test is included to demonstrate behavior
['umall', false, false],
['ic-world', true, true],
['nobody', false, false],
['pdus', true, false],
['cc-by-3.0', true, true],
// skip the rest of the CC 3.0 rights...
['orphcand', false, false],
['cc-zero', true, true],
['und-world', true, true],
['icus', false, true],
['cc-by-4.0', true, true],
// skip the rest of the CC 4.0 rights...
['pd-pvt', false, false],
['supp', false, false],
// Edge cases
['???', false, false],
[[], false, false],
[['pd', 'ic'], true, true]
];
foreach ($examples as $example) {
$this->assertEquals($example[1], $utils->is_fullview($example[0], true));
$this->assertEquals($example[2], $utils->is_fullview($example[0], false));
}
}

/**
* @covers RecordUtils::is_open_to_no_one
*/
public function test_is_open_to_no_one(): void {
$utils = new RecordUtils();
$examples = [
// Rights open to no one?
['pd', false],
['ic', false],
['pd-pvt', true],
['supp', true],
['nobody', true],
[['pd', 'pd-pvt'], true],
[['pd', 'supp'], true],
[['pd', 'nobody'], true]
];
foreach ($examples as $example) {
$this->assertEquals($example[1], $utils->is_open_to_no_one($example[0]));
}
}
}

?>