Skip to content

Commit

Permalink
Reset aoi_pmh consent flag on import
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed Jul 1, 2022
1 parent 8408628 commit 4151226
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
13 changes: 2 additions & 11 deletions modules/site/duplicate_template.php
Expand Up @@ -122,12 +122,12 @@ function duplicate_template_site($folder_name_id,$id_to_copy,$tutorial_id_from_p
// Remove oai-pmh consent flag if present from
if (file_exists($new_path . "preview.xml"))
{
change_copied_xml_site($new_path . "preview.xml");
change_copied_xml($new_path . "preview.xml");
}
// Remove oai-pmh consent flag if present from
if (file_exists($new_path . "data.xml"))
{
change_copied_xml_site($new_path . "data.xml");
change_copied_xml($new_path . "data.xml");
}

return true;
Expand Down Expand Up @@ -156,12 +156,3 @@ function duplicate_template_site($folder_name_id,$id_to_copy,$tutorial_id_from_p

}

function change_copied_xml_site($xmlfile)
{
$xml = simplexml_load_file($xmlfile);
if ((string)$xml['oaiPmhAgree'] === 'true')
{
$xml['oaiPmhAgree'] = 'false';
}
$xml->asXML($xmlfile);
}
13 changes: 2 additions & 11 deletions modules/xerte/duplicate_template.php
Expand Up @@ -124,12 +124,12 @@ function duplicate_template_xerte($folder_name_id,$id_to_copy,$tutorial_id_from_
// Remove oai-pmh consent flag if present from
if (file_exists($new_path . "preview.xml"))
{
change_copied_xml_xerte($new_path . "preview.xml");
change_copied_xml($new_path . "preview.xml");
}
// Remove oai-pmh consent flag if present from
if (file_exists($new_path . "data.xml"))
{
change_copied_xml_xerte($new_path . "data.xml");
change_copied_xml($new_path . "data.xml");
}

return true;
Expand Down Expand Up @@ -158,12 +158,3 @@ function duplicate_template_xerte($folder_name_id,$id_to_copy,$tutorial_id_from_

}

function change_copied_xml_xerte($xmlfile)
{
$xml = simplexml_load_file($xmlfile);
if ((string)$xml['oaiPmhAgree'] === 'true')
{
$xml['oaiPmhAgree'] = 'false';
}
$xml->asXML($xmlfile);
}
16 changes: 14 additions & 2 deletions website_code/php/import/import.php
Expand Up @@ -135,14 +135,26 @@ function make_new_template($type, $zip_path)
* Make the folders and copy the files in
*/

$new_path = $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short . ($lastid) . "-" . $_SESSION['toolkits_logon_username'] . "-" . $type;
receive_message($_SESSION['toolkits_logon_username'], "ADMIN", "SUCCESS", "Created new template record for the database", $query_for_new_template . " " . $query_for_template_rights);

mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short . ($lastid) . "-" . $_SESSION['toolkits_logon_username'] . "-" . $type);
mkdir($new_path);

chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short . ($lastid) . "-" . $_SESSION['toolkits_logon_username'] . "-" . $type, 0777);
chmod($new_path);

copy_loop($zip_path, $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short . ($lastid) . "-" . $_SESSION['toolkits_logon_username'] . "-" . $type . "/");

// Remove oai-pmh consent flag if present from
if (file_exists($new_path . "/preview.xml"))
{
change_copied_xml($new_path . "/preview.xml");
}
// Remove oai-pmh consent flag if present from
if (file_exists($new_path . "/data.xml"))
{
change_copied_xml($new_path . "/data.xml");
}

echo IMPORT_SUCCESS . "****";

/*
Expand Down
10 changes: 10 additions & 0 deletions website_code/php/template_library.php
Expand Up @@ -193,3 +193,13 @@ function get_template_data_as_xml($template_id, $creator_user_name="", $template
}
return $xml;
}

function change_copied_xml($xmlfile)
{
$xml = simplexml_load_file($xmlfile);
if ((string)$xml['oaiPmhAgree'] === 'true')
{
$xml['oaiPmhAgree'] = 'false';
}
$xml->asXML($xmlfile);
}

0 comments on commit 4151226

Please sign in to comment.