Commit 74dfd174 authored by Francois Marier's avatar Francois Marier
Browse files
parents 57c585f4 a66884f3
......@@ -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);
}
}
}
}
......
......@@ -127,21 +127,22 @@ class ArtefactTypeResume extends ArtefactType {
*/
public function commit($updateresumeblocks=true) {
if ($updateresumeblocks) {
foreach (get_records_sql_array('
if ($blockinstances = get_records_sql_array('
SELECT id, view, configdata
FROM {block_instance}
WHERE blocktype = \'entireresume\'
AND "view" IN (
SELECT id
FROM {view}
WHERE "owner" = ?)', array($this->owner)) as $blockinstance) {
$whereobject = (object)array(
'view' => $blockinstance->view,
'artefact' => $this->get('id'),
'block' => $blockinstance->id,
);
ensure_record_exists('view_artefact', $whereobject, $whereobject);
WHERE "owner" = ?)', array($this->owner))) {
foreach ($blockinstances as $blockinstance) {
$whereobject = (object)array(
'view' => $blockinstance->view,
'artefact' => $this->get('id'),
'block' => $blockinstance->id,
);
ensure_record_exists('view_artefact', $whereobject, $whereobject);
}
}
}
parent::commit();
......
......@@ -644,6 +644,15 @@ function upgrade_template_convert_block_to_blockinstance($block, $view) {
));
return $bi;
}
else if ($block->artefacttype == 'folder') {
$bi = new BlockInstance(0, array(
'title' => '',
'blocktype' => 'folder',
'configdata' => serialize(array('artefactid' => $block->artefact)),
'view' => $view->id,
));
return $bi;
}
log_info("Created a placeholder blockinstance for:");
log_info($block);
......
......@@ -28,6 +28,7 @@ defined('INTERNAL') || die();
function xmldb_core_upgrade($oldversion=0) {
ini_set('max_execution_time', 120); // Let's be safe
ini_set('memory_limit', '64M');
$status = true;
......@@ -170,6 +171,14 @@ function xmldb_core_upgrade($oldversion=0) {
drop_field($table, $field);
}
// Add the 'blockinstancecommit' event type
if ($oldversion < 2007082203) {
$event = (object)array(
'name' => 'blockinstancecommit',
);
ensure_record_exists('event_type', $event, $event);
}
if ($oldversion < 2007082201) {
// Rename the community tables to group - mysql version.
// This is really quite hacky. You can't rename columns with a foreign
......@@ -332,11 +341,11 @@ function xmldb_core_upgrade($oldversion=0) {
// needed for the template migration
install_blocktype_categories();
foreach(array(
'textbox',
'file/image', 'file/filedownload',
'textbox', 'externalfeed', 'externalvideo',
'file/image', 'file/filedownload', 'file/folder', 'file/internalmedia',
'blog/blogpost', 'blog/blog', 'blog/recentposts',
'resume/resumefield',
'internal/profileinfo') as $blocktype) {
'resume/resumefield', 'resume/entireresume',
'internal/profileinfo', 'internal/contactinfo') as $blocktype) {
$data = check_upgrades("blocktype.$blocktype");
upgrade_plugin($data);
}
......@@ -403,14 +412,6 @@ function xmldb_core_upgrade($oldversion=0) {
set_config('imagemaxheight', 1024);
}
// Add the 'blockinstancecommit' event type
if ($oldversion < 2007082203) {
$event = (object)array(
'name' => 'blockinstancecommit',
);
ensure_record_exists('event_type', $event, $event);
}
return $status;
}
......
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