/** * put your comment there... * * @param mixed $backupId * @param boolean Dont delete master blocks with backupId = NULL. This is very important in case $id param is null for any reason! */ public function deleteBackupBlocks($backupId = null, $deleteMaster = false) { if (!$backupId && !$deleteMaster) { throw new Exception('Trying to delete master blocks while deleting normal backup'); } // Blocks Table & Model.. require_once CJTOOLBOX_TABLES_PATH . '/blocks.php'; require_once CJTOOLBOX_MODELS_PATH . '/blocks.php'; // Get blocks Table & Model instances. $blocksTable = new CJTBlocksTable($this->dbDriver); $blocksModel = new CJTBlocksModel(); // Get backup blocks Ids. $blocks['fields'] = array('id'); $blocks['filters']['backupId'] = $backupId; // Don't delete 'metabox' blocks as its not part of the backup anyway! $blocks['filters']['types'] = array('block', 'revision'); // Query backup blocks. $blocks = $blocksTable->get(null, $blocks['fields'], $blocks['filters']); // Delete blocks using its Id. $ids = array_keys($blocks); $blocksModel->delete($ids); // Delete code files. $this->dbDriver->delete('DELETE FROM #__cjtoolbox_block_files where blockId IN (' . implode(',', $ids) . ');'); // In order for $this->processQueue to work // we need to Merge db driver queues into the current // local queue. $this->dbDriver->merge($blocksModel->dbDriver()); }