1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00
OwncloudContactsOfficial/appinfo/update.php

26 lines
1.1 KiB
PHP
Raw Normal View History

2012-07-04 22:58:31 +02:00
<?php
$installedVersion=OCP\Config::getAppValue('contacts', 'installed_version');
if (version_compare($installedVersion, '0.2.3', '<')) {
2012-07-04 22:58:31 +02:00
// First set all address books in-active.
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`=0' );
2012-07-04 22:58:31 +02:00
$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\'' );
2012-07-04 22:58:31 +02:00
$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`=?' );
2012-07-04 22:58:31 +02:00
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\'' );
2012-07-04 22:58:31 +02:00
$result = $stmt->execute(array());
}