Commit 0c504f40 authored by Nigel McNie's avatar Nigel McNie
Browse files

Only make sure about resume artefacts being in the block instance if the...

Only make sure about resume artefacts being in the block instance if the instance is _actually_ an entireresume blocktype.
parent 53ca3b54
......@@ -100,29 +100,31 @@ class PluginBlocktypeEntireresume extends PluginBlocktype {
* blockinstance at blockinstance commit time
*/
public static function ensure_resume_artefacts_in_blockinstance($event, $blockinstance) {
safe_require('artefact', 'resume');
$artefacttypes = implode(', ', array_map('db_quote', PluginArtefactResume::get_artefact_types()));
if ($blockinstance->get('blocktype') == 'entireresume') {
safe_require('artefact', 'resume');
$artefacttypes = implode(', ', array_map('db_quote', PluginArtefactResume::get_artefact_types()));
// Get all artefacts that are resume related and belong to the correct owner
$artefacts = get_records_sql_array('
SELECT id
FROM {artefact}
WHERE artefacttype IN(' . $artefacttypes . ')
AND owner = (
SELECT owner
FROM {view}
WHERE id = ?
)', array($blockinstance->get('view')));
// Get all artefacts that are resume related and belong to the correct owner
$artefacts = get_records_sql_array('
SELECT id
FROM {artefact}
WHERE artefacttype IN(' . $artefacttypes . ')
AND owner = (
SELECT owner
FROM {view}
WHERE id = ?
)', array($blockinstance->get('view')));
if ($artefacts) {
// Make sure they're registered as being in this view
foreach ($artefacts as $artefact) {
$record = (object)array(
'view' => $blockinstance->get('view'),
'artefact' => $artefact->id,
'block' => $blockinstance->get('id'),
);
ensure_record_exists('view_artefact', $record, $record);
if ($artefacts) {
// Make sure they're registered as being in this view
foreach ($artefacts as $artefact) {
$record = (object)array(
'view' => $blockinstance->get('view'),
'artefact' => $artefact->id,
'block' => $blockinstance->get('id'),
);
ensure_record_exists('view_artefact', $record, $record);
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment