Skip to content

Commit

Permalink
added check for assent in oai-pmh and fixed bug that let learning obj…
Browse files Browse the repository at this point in the history
…ects be harvested when the criteria where not met.
  • Loading branch information
TimoBoer committed Dec 14, 2022
1 parent 8c21b1c commit 8643935
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion oai-pmh/oai.php
Expand Up @@ -235,7 +235,7 @@ function getTemplates($metadataPrefix,$from,$until) {
{
$currentTemplate = $templates[$i];
$tempMetaData = call_user_func('get_meta_data',$currentTemplate['template_id'],$currentTemplate["owner_username"],$currentTemplate["template_type"], $currentTemplate['owner']);
if($tempMetaData->domain != 'unknown' and $tempMetaData->level != "unknown"){
if($tempMetaData->domain != 'unknown' and $tempMetaData->level != "unknown" and $tempMetaData->oaiPmhAgree){
$currentRecord = call_user_func('makeRecordFromTemplate',$metadataPrefix,$currentTemplate, $tempMetaData);
$tmpRecords[] = $currentRecord;
}
Expand Down
16 changes: 14 additions & 2 deletions oai-pmh/xerteobjects.php
Expand Up @@ -81,6 +81,16 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=
$xerteMetaObj->description = (string)$xml['metaDescription'];
else
$xerteMetaObj->description = '';
//TODO check oaiphm....
//compare strings for true /false
//if unset return false
if (isset($xml['oaiPmhAgree']))
if ((string)$xml['oaiPmhAgree'] == 'true' )
$xerteMetaObj->oaiPmhAgree = true;
else
$xerteMetaObj->oaiPmhAgree = false;
else
$xerteMetaObj->oaiPmhAgree = false;
if (isset($xml['metaKeywords']))
$xerteMetaObj->keywords = (string)$xml['metaKeywords'];
else
Expand All @@ -95,6 +105,7 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=
else {
$xerteMetaObj->author = $config['institute'];
}
//TODO check domain ^ level make sure they return "unknown"
if (isset($xml['category']) || isset($xml['metaCategory'])) {
if (isset($xml['metaCategory']))
{
Expand All @@ -104,11 +115,12 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=
{
$cat = (string)$xml['category'];
}

// query oai_categories
$q = "select * from {$xerte_toolkits_site->database_table_prefix}oai_categories where label=?";
$params = array($cat);
$cat = db_query_one($q, $params);
if ($cat !== false) {
if ($cat !== false and $cat !== null) {
$xerteMetaObj->domain = $cat["label"];
$xerteMetaObj->domainId = $cat["taxon"];
$xerteMetaObj->domainSource = $cat["source_url"];
Expand All @@ -126,7 +138,7 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=
$q = "select * from {$xerte_toolkits_site->database_table_prefix}oai_education where label=?";
$params = array((string)$xml["metaEducation"]);
$cat = db_query_one($q, $params);
if ($cat !== false) {
if ($cat !== false and $cat !== null) {
$xerteMetaObj->level = $cat["label"];
$xerteMetaObj->levelId = $cat["term_id"];
}
Expand Down

0 comments on commit 8643935

Please sign in to comment.