summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/fix-unfiled-tags.php
diff options
context:
space:
mode:
authorGravatar Christian Weiske2011-08-06 10:38:44 +0200
committerGravatar Christian Weiske2011-08-06 10:38:44 +0200
commitd2e437b4db84300e2b543c5827d8f517a81afaef (patch)
tree7863a0a733514684bef0917ccf3ebf3b2a0aac5a /scripts/fix-unfiled-tags.php
parent5743a34a6c7757d3030479f96326f09fe5dce0b2 (diff)
parent097ecf9c510e1435d02be7843bc7e865570338ac (diff)
downloadscuttle-d2e437b4db84300e2b543c5827d8f517a81afaef.tar.gz
scuttle-d2e437b4db84300e2b543c5827d8f517a81afaef.zip
Merge branch '0.98'
Diffstat (limited to 'scripts/fix-unfiled-tags.php')
-rw-r--r--scripts/fix-unfiled-tags.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/fix-unfiled-tags.php b/scripts/fix-unfiled-tags.php
new file mode 100644
index 0000000..8a5238e
--- /dev/null
+++ b/scripts/fix-unfiled-tags.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * SemanticScuttle from approximately 0.94 up to 0.98.2, system:unfiled
+ * tags were not created when adding new bookmarks with the web interface.
+ *
+ * This script adds system:unfiled tags for all bookmarks that have no
+ * tags.
+ */
+require_once dirname(__FILE__) . '/../src/SemanticScuttle/header-standalone.php';
+
+//needed to load the database object
+$bt = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
+$db = SemanticScuttle_Service_Factory::getDb();
+
+$query = <<<SQL
+SELECT b.bId
+FROM sc_bookmarks AS b
+ LEFT JOIN sc_bookmarks2tags AS bt ON b.bId = bt.bId
+WHERE bt.bId IS NULL
+SQL;
+
+if (!($dbresult = $db->sql_query($query))) {
+ die('Strange SQL error');
+}
+while ($row = $db->sql_fetchrow($dbresult)) {
+ $db->sql_query(
+ 'INSERT INTO ' . $bt->getTableName() . ' '
+ . $db->sql_build_array(
+ 'INSERT',
+ array('bId' => $row['bId'], 'tag' => 'system:unfiled')
+ )
+ );
+}
+$db->sql_freeresult($dbresult);
+?> \ No newline at end of file