PluginProbe
CSS & JavaScript Toolbox / trunk
CSS & JavaScript Toolbox vtrunk
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
← All changes | models/blocks-backups.php +8 -1 6.0trunk View file →
@@ -47,8 +47,11 @@
47 47 * @param mixed $srcBackupId
48 48 * @param mixed $desBackupId
49 49 */
50 50 public function copyBackupBlocks($srcBackupId, $desBackupId) {
51 + // Initialie.
52 + $codeFilesQuery = 'INSERT INTO #__cjtoolbox_block_files (blockId, id, name, description, `type`, code, `order`)
53 + SELECT %d, id, name, description, `type`, code, `order` FROM #__cjtoolbox_block_files WHERE blockId = %d;';
51 54 // Blocks Table & Model..
52 55 require_once CJTOOLBOX_TABLES_PATH . '/blocks.php';
53 56 require_once CJTOOLBOX_TABLES_PATH . '/block-pins.php';
54 57 require_once CJTOOLBOX_MODELS_PATH . '/blocks.php';
@@ -61,9 +64,9 @@
61 64 $blocks['filters']['backupId'] = $srcBackupId;
62 65 $blocks['filters']['types'] = array('block', 'revision');
63 66 // Its important to get revision blocks at the end
64 67 // to create blocks id map.
65 - $blocks['orderBy'] = array('type');
68 + $blocks['orderby'] = array('type');
66 69 $blocks = $blocksModel->getBlocks(null, $blocks['filters'], $blocks['fields'], OBJECT_K, $blocks['orderby']);
67 70 // Prepare vars before copying.
68 71 $desBlockId = $blocksTable->getNextId();
69 72 // For every block give new Id and insert block and pins data.
@@ -97,8 +100,10 @@
97 100 $blocksTable->insert($blockData);
98 101 // Insert block Pins.
99 102 $pinsData = array_intersect_key($block, array_flip(array('pages', 'posts', 'categories')));
100 103 $blockPinsTable->insert($block['id'], $pinsData);
104 + // Copy code files.
105 + $this->dbDriver->insert(sprintf($codeFilesQuery, $block['id'], $id))->processQueue();
101 106 }
102 107 }
103 108
104 109 /**
@@ -165,8 +170,10 @@
165 170 $blocks = $blocksTable->get(null, $blocks['fields'], $blocks['filters']);
166 171 // Delete blocks using its Id.
167 172 $ids = array_keys($blocks);
168 173 $blocksModel->delete($ids);
174 + // Delete code files.
175 + $this->dbDriver->delete('DELETE FROM #__cjtoolbox_block_files where blockId IN (' . implode(',', $ids) . ');');
169 176 // In order for $this->processQueue to work
170 177 // we need to Merge db driver queues into the current
171 178 // local queue.
172 179 $this->dbDriver->merge($blocksModel->dbDriver());