Modified:
/trunk/wolf/plugins/backup_restore/BackupRestoreController.php
/trunk/wolf/plugins/backup_restore/index.php
/trunk/wolf/plugins/backup_restore/readme.txt
/trunk/wolf/plugins/backup_restore/views/documentation.php
/trunk/wolf/plugins/backup_restore/views/restore.php
/trunk/wolf/plugins/backup_restore/views/sidebar.php
=======================================
--- /trunk/wolf/plugins/backup_restore/BackupRestoreController.php Sun Oct
17 12:17:26 2010
+++ /trunk/wolf/plugins/backup_restore/BackupRestoreController.php Fri Dec
24 19:26:52 2010
@@ -102,10 +102,26 @@
$settings = Plugin::getAllSettings('backup_restore');
// All of the tablesnames that belong to Wolf CMS core.
- $tablenames =
array('layout', 'page', 'page_part', 'page_tag', 'permission',
- 'plugin_settings', 'setting', 'snippet', 'tag', 'user',
- 'user_permission'
- );
+ $tablenames = array();
+
+ if (strpos(DB_DSN,'mysql') !== false) {
+ $sql = 'show tables';
+ }
+
+ if (strpos(DB_DSN,'sqlite') !== false) {
+ $sql = 'SELECT name FROM SQLITE_MASTER WHERE type="table"
ORDER BY name';
+ }
+
+ if (strpos(DB_DSN,'pgsql') !== false) {
+ $sql = "select tablename from pg_tables where
schemaname='public'";
+ }
+
+ $pdo = Record::getConnection();
+ $result = $pdo->query($sql);
+
+ while ($col = $result->fetchColumn()) {
+ $tablenames[] = $col;
+ }
// All fields that should be wrapped as CDATA
$cdata_fields = array('content', 'content_html');
@@ -208,10 +224,26 @@
$settings = Plugin::getAllSettings('backup_restore');
// All of the tablesnames that belong to Wolf CMS core.
- $tablenames =
array('layout', 'page', 'page_part', 'page_tag', 'permission',
- 'plugin_settings', 'setting', 'snippet', 'tag', 'user',
- 'user_permission'
- );
+ $tablenames = array();
+
+ if (strpos(DB_DSN,'mysql') !== false) {
+ $sql = 'show tables';
+ }
+
+ if (strpos(DB_DSN,'sqlite') !== false) {
+ $sql = 'SELECT name FROM SQLITE_MASTER WHERE type="table"
ORDER BY name';
+ }
+
+ if (strpos(DB_DSN,'pgsql') !== false) {
+ $sql = "select tablename from pg_tables where
schemaname='public'";
+ }
+
+ $pdo = Record::getConnection();
+ $result = $pdo->query($sql);
+
+ while ($col = $result->fetchColumn()) {
+ $tablenames[] = $col;
+ }
// All fields that should be wrapped as CDATA
$cdata_fields = array('content', 'content_html');
@@ -235,7 +267,13 @@
$container = $tablename.'s';
if (array_key_exists($container, $xml) &&
count($xml->$container->$tablename) > 0) {
- if (false ===
$__CMS_CONN__->exec('TRUNCATE '.TABLE_PREFIX.$tablename)) {
+ if (strpos(DB_DSN,'sqlite') !== false) {
+ $sql = 'DELETE FROM '.TABLE_PREFIX.$tablename;
+ }
+ else {
+ $sql = 'TRUNCATE '.TABLE_PREFIX.$tablename;
+ }
+ if (false === $__CMS_CONN__->exec($sql)) {
Flash::set('error', __('Unable to truncate current
table :tablename.', array(':tablename' => TABLE_PREFIX.$tablename)));
redirect(get_url('plugin/backup_restore'));
}
=======================================
--- /trunk/wolf/plugins/backup_restore/index.php Sun Mar 21 12:16:09 2010
+++ /trunk/wolf/plugins/backup_restore/index.php Fri Dec 24 19:26:52 2010
@@ -40,7 +40,7 @@
*/
-if (!defined('BR_VERSION')) { define('BR_VERSION', '0.6.0'); }
+if (!defined('BR_VERSION')) { define('BR_VERSION', '0.7.0'); }
/**
*
* Root location where Comment plugin lives.
=======================================
--- /trunk/wolf/plugins/backup_restore/readme.txt Sun Mar 21 11:01:05 2010
+++ /trunk/wolf/plugins/backup_restore/readme.txt Fri Dec 24 19:26:52 2010
@@ -13,10 +13,10 @@
* To use the settings and documentation pages, you will first need to
enable
the plugin!
-* This plugin is only useable by people with the 'administrator' role.
+* This plugin is only useable by the user with user id '1'.
== LICENSE ==
-Copyright 2009, Martijn van der Kleijn. <martij...@gmail.com>
+Copyright 2009-2010, Martijn van der Kleijn. <martij...@gmail.com>
This plugin is licensed under the GPLv3 License.
<http://www.gnu.org/licenses/gpl.html>
=======================================
--- /trunk/wolf/plugins/backup_restore/views/documentation.php Sun Mar 21
12:16:09 2010
+++ /trunk/wolf/plugins/backup_restore/views/documentation.php Fri Dec 24
19:26:52 2010
@@ -42,8 +42,8 @@
<h1><?php echo __('Documentation'); ?></h1>
<p>
The Backup/Restore plugin allows you to create complete backups of the
Wolf
- CMS core database. It generates an XML file that contains all records
for each
- of the Wolf CMS core database tables.
+ CMS database. It generates an XML file that contains all records for
each
+ of the Wolf CMS database tables.
</p>
<h2><?php echo __('Creating the backup'); ?></h2>
<p>
@@ -68,9 +68,3 @@
<p>
Example: <password/>
</p>
-<h2><?php echo __('Notes'); ?></h2>
-<p>
- Database tables that are created by plugins are currently
<strong>not</strong>
- backed up through this mechanism. However, plugin settings for plugins
that use the settings
- functionality provided by Wolf CMS <strong>are</strong> backed up.
-</p>
=======================================
--- /trunk/wolf/plugins/backup_restore/views/restore.php Sun Mar 21
12:16:09 2010
+++ /trunk/wolf/plugins/backup_restore/views/restore.php Fri Dec 24
19:26:52 2010
@@ -49,11 +49,11 @@
<em>version</em> as you are restoring it to.
</p>
<p>
- Please be aware that <strong>all</strong> Wolf CMS
<em>core</em> database tables will be truncated when
+ Please be aware that <strong>all</strong> the database tables
will be truncated when
performing a restore. Truncating a table means that all
records in that table are deleted.
</p>
<p>
- As such, the contents of your backup file will replace the
contents of your core Wolf CMS database tables.
+ As such, the contents of your backup file will replace the
contents of your Wolf CMS database tables.
</p>
<p style="text-align: center;"><strong>
Do NOT upload a zip file, only upload a plain text XML file!
=======================================
--- /trunk/wolf/plugins/backup_restore/views/sidebar.php Sun Mar 21
12:16:09 2010
+++ /trunk/wolf/plugins/backup_restore/views/sidebar.php Fri Dec 24
19:26:52 2010
@@ -50,6 +50,6 @@
</p>
<p>
<?php echo __('Version'); ?> - <?php echo BR_VERSION; ?><br />
-<?php echo __('Designed for Wolf
version').' '.Plugin::getSetting('wolfversion', 'backup_restore'); ?><br />
+<?php echo __('Designed for Wolf
version').' '.Plugin::getSetting('wolfversion', 'backup_restore'); ?> and
upwards.<br />
</p>
</div>