]> source.dussan.org Git - nextcloud-server.git/commitdiff
Missing update script.
authorThomas Tanghus <thomas@tanghus.net>
Wed, 4 Jul 2012 20:58:31 +0000 (22:58 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Wed, 4 Jul 2012 20:58:31 +0000 (22:58 +0200)
apps/contacts/appinfo/update.php [new file with mode: 0644]

diff --git a/apps/contacts/appinfo/update.php b/apps/contacts/appinfo/update.php
new file mode 100644 (file)
index 0000000..873899f
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+$installedVersion=OCP\Config::getAppValue('contacts', 'installed_version');
+if (version_compare($installedVersion, '0.2.90', '<')) {
+       // First set all address books in-active.
+       $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET active=0' );
+       $result = $stmt->execute(array());
+       
+       // Then get all the active address books.
+       $stmt = OCP\DB::prepare( 'SELECT userid,configvalue FROM *PREFIX*preferences WHERE appid=\'contacts\' AND configkey=\'openaddressbooks\'' );
+       $result = $stmt->execute(array());
+       
+       // Prepare statement for updating the new 'active' field.
+       $stmt = OCP\DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET active=? WHERE id=? AND userid=?' );
+       while( $row = $result->fetchRow()) {
+               $ids = explode(';', $row['configvalue']);
+               foreach($ids as $id) {
+                       $r = $stmt->execute(array(1, $id, $row['userid']));
+               }
+       }
+       
+       // Remove the old preferences.
+       $stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*preferences WHERE appid=\'contacts\' AND configkey=\'openaddressbooks\'' );
+       $result = $stmt->execute(array());
+}