2012-07-04 22:58:31 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$installedVersion=OCP\Config::getAppValue('contacts', 'installed_version');
|
2013-05-23 13:17:19 +02:00
|
|
|
if (version_compare($installedVersion, '0.2.5', '>=')) {
|
|
|
|
// Set all address books active as (de)activating went awol at rewrite.
|
|
|
|
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`= 1' );
|
|
|
|
$result = $stmt->execute(array());
|
|
|
|
}
|
|
|
|
elseif (version_compare($installedVersion, '0.2.4', '==')) {
|
2012-07-04 22:58:31 +02:00
|
|
|
// First set all address books in-active.
|
2012-08-25 01:52:27 +02:00
|
|
|
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*contacts_addressbooks` SET `active`=0' );
|
2012-07-04 22:58:31 +02:00
|
|
|
$result = $stmt->execute(array());
|
2012-09-07 14:32:45 +02:00
|
|
|
|
2012-07-04 22:58:31 +02:00
|
|
|
// Then get all the active address books.
|
2012-08-25 01:52:27 +02:00
|
|
|
$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());
|
2012-09-07 14:32:45 +02:00
|
|
|
|
2012-07-04 22:58:31 +02:00
|
|
|
// Prepare statement for updating the new 'active' field.
|
2012-08-25 01:52:27 +02:00
|
|
|
$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']));
|
|
|
|
}
|
|
|
|
}
|
2012-09-07 14:32:45 +02:00
|
|
|
|
2012-07-04 22:58:31 +02:00
|
|
|
// Remove the old preferences.
|
2012-08-25 01:52:27 +02:00
|
|
|
$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());
|
|
|
|
}
|