Skip to content

Commit

Permalink
Fix resetting state when changing sync_book prefs and device has forc…
Browse files Browse the repository at this point in the history
…ed multiplex.
  • Loading branch information
mrubinsk committed Apr 2, 2016
1 parent 24357c1 commit 769a20b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions config/prefs.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,22 @@
$ui->prefs['sync_books']['enum'] = $enum;
},
'on_change' => function() {
if ($GLOBALS['conf']['activesync']['enabled'] && !$GLOBALS['prefs']->getValue('activesync_no_multiplex')) {
if ($GLOBALS['conf']['activesync']['enabled']) {
try {
$sm = $GLOBALS['injector']->getInstance('Horde_ActiveSyncState');
$sm->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger'));
$devices = $sm->listDevices($GLOBALS['registry']->getAuth());
foreach ($devices as $device) {
$sm->removeState(array(
'devId' => $device['device_id'],
'id' => Horde_Core_ActiveSync_Driver::CONTACTS_FOLDER_UID,
'user' => $GLOBALS['registry']->getAuth()
));
$device_ob = $sm->loadDeviceInfo($device['device_id'], $device['device_user']);
if (!$GLOBALS['prefs']->getValue('activesync_no_multiplex') ||
($device_ob->multiplex & Horde_ActiveSync_Device::MULTIPLEX_CONTACTS)) {
$map = $sm->getFolderUidToBackendIdMap();
$sm->removeState(array(
'devId' => $device['device_id'],
'id' => (!empty($map[Horde_Core_ActiveSync_Driver::CONTACTS_FOLDER_UID]) ? $map[Horde_Core_ActiveSync_Driver::CONTACTS_FOLDER_UID] : Horde_Core_ActiveSync_Driver::CONTACTS_FOLDER_UID),
'user' => $GLOBALS['registry']->getAuth()
));
}
}
$GLOBALS['notification']->push(_("All state removed for your ActiveSync devices. They will resynchronize next time they connect to the server."));
} catch (Horde_ActiveSync_Exception $e) {
Expand Down

0 comments on commit 769a20b

Please sign in to comment.