Skip to content

Commit

Permalink
ListRecords with functioning date ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
jajreijnders committed Nov 23, 2021
1 parent 8acce26 commit bfa1345
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions oai-pmh/oai.php
Expand Up @@ -87,14 +87,14 @@ function($resumptionToken = '') {
},

'ListRecords' =>
function($metadataPrefix, $from = '', $until = '', $set = '', $count = false, $deliveredRecords = 0, $maxItems = 0){
function($metadataPrefix, $from, $until, $set = '', $count = false, $deliveredRecords = 0, $maxItems = 0){
if ($count) {
return 1;
}
if ($set != '') {
throw new OAIException('noSetHierarchy');
}
$records = call_user_func(getTemplates);
$records = call_user_func(getTemplates, $from, $until);
return $records;
},

Expand Down Expand Up @@ -171,7 +171,7 @@ function getSingleTemplate($template_id) {
return $response_record;
}

function getTemplates() {
function getTemplates($from,$until) {
global $xerte_toolkits_site;
$prefix = $xerte_toolkits_site->database_table_prefix;

Expand All @@ -195,7 +195,22 @@ function getTemplates() {
{$prefix}logindetails as ld
where td.template_type_id=otd.template_type_id and td.creator_id=ld.login_id and td.access_to_whom = 'Public'";

$templates = db_query($q);
if($from && $until){
$q = $q . "and td.date_modified between ? and ?";
$templates = db_query($q, array($from,$until));
}
else if($until){
$q = $q . "and td.date_modified <= ?";
$templates = db_query($q, array($until));
}
else if($from){
$q = $q . "and td.date_modified >= ?";
$templates = db_query($q, array($from));
}
else{
$templates = db_query($q);
}

$response = new stdClass();
$response->site_url = $xerte_toolkits_site->site_url;
$response->site_name = $xerte_toolkits_site->site_name;
Expand Down

0 comments on commit bfa1345

Please sign in to comment.