public function BlockEditor::revertDBBLocks in Forena Reports 8
Same name and namespace in other branches
- 7.5 src/Editor/BlockEditor.php \Drupal\forena\Editor\BlockEditor::revertDBBLocks()
Writes blocks from the old db structure to the new one.
File
- src/
Editor/ BlockEditor.php, line 169
Class
Namespace
Drupal\forena\EditorCode
public function revertDBBLocks() {
$block = array();
$fo = FrxAPI::DataFile();
if (db_table_exists('forena_data_blocks') && is_writable($fo->dir)) {
// Get all blocks from the db.
$sql = 'SELECT * FROM {forena_data_blocks} order by repository, block_name';
$rs = db_query($sql);
$empty_table = TRUE;
foreach ($rs as $b) {
$block = array(
'repository' => $b->repository,
'block_name' => $b->block_name,
'type' => $b->block_type,
'file' => $b->src,
'builder' => $b->builder,
'access' => $b->access,
'title' => $b->title,
'locked' => $b->locked,
'modified' => $b->modified,
);
$d = $this
->dataManager()
->repository($b->repository);
$block = array_merge($block, $d
->parseSQLFile($block['file']));
if ($block['builder']) {
$block['builder'] = unserialize($block['builder']);
}
$path = $b->repository . '/' . $b->block_name;
$this
->dataManager()
->saveBlock($path, $block);
if (FrxAPI::DataFile()
->isCustom($path . '.sql')) {
db_delete('forena_data_blocks')
->condition('repository', $b->repository)
->condition('block_name', $b->block_name)
->execute();
}
$empty_table = FALSE;
}
if ($empty_table) {
db_drop_table('forena_data_blocks');
}
$fo
->validateAllCache();
}
}