case 'syncmlmanagement':
return $this->_syncmlManagement($ui);
+
+ case 'activesyncmanagement':
+ return $this->_activesyncManagement($ui);
}
return '';
case 'syncmlmanagement':
$this->_updateSyncmlManagement($ui);
break;
+
+ case 'activesyncmanagement':
+ $this->_updateActiveSyncManagement($ui);
+ break;
}
return false;
);
}
}
- $t->set('devices', $devices);
+ $t->set('devices', $partners);
return $t->fetch(HORDE_TEMPLATES . '/prefs/syncml.html');
}
/**
+ * Create code for ActiveSync management.
+ *
+ * @param Horde_Core_Prefs_Ui $ui The UI object.
+ *
+ * @return string HTML UI code.
+ */
+ protected function _activesyncManagement($ui)
+ {
+ if (!empty($GLOBALS['conf']['activesync']['enabled'])) {
+ $state_params = $GLOBALS['conf']['activesync']['state']['params'];
+ $state_params['db'] = $GLOBALS['injector']->getInstance('Horde_Db_Adapter_Base');
+ $stateMachine = new Horde_ActiveSync_State_History($state_params);
+ } else {
+ return _("ActiveSync not activated.");
+ }
+
+ $t = $GLOBALS['injector']->createInstance('Horde_Template');
+ $t->setOption('gettext', true);
+ $devices = $stateMachine->listDevices(Horde_Auth::getAuth());
+ $devs = array();
+ $reseturl = $ui->selfUrl()->add('reset', 1);
+ $i = 1;
+ foreach ($devices as $device) {
+ $device['class'] = fmod($i++, 2) ? 'rowOdd' : 'rowEven';
+ $device['reset'] = $reseturl;
+ $device['ts'] = strftime($GLOBALS['prefs']->getValue('date_format') . ' %H:%M', $stateMachine->getLastSyncTimestamp($device['device_id']));
+ switch ($device['device_rwstatus']) {
+ case Horde_ActiveSync::RWSTATUS_PENDING:
+ $status = '<span class="notice">Wipe is pending</span>';
+ break;
+ case Horde_ActiveSync::RWSTATUS_WIPED:
+ $status = '<span class="notice">Device is wiped</span>';
+ break;
+ default:
+ $status = 'Device is partnered';
+ }
+ $device['status'] = $status . '<br />Device id: ' . $device['device_id'] . '<br />User Agent: ' . $device['device_agent'];
+ $devs[] = $device;
+ }
+
+ $t->set('devices', $devs);
+
+ return $t->fetch(HORDE_TEMPLATES . '/prefs/activesync.html');
+ }
+
+ /**
* Update category related preferences.
*
* @param Horde_Core_Prefs_Ui $ui The UI object.
}
}
+ /**
+ * Update ActiveSync actions
+ *
+ * @param Horde_Core_Prefs_Ui $ui The UI object.
+ */
+ protected function _updateActiveSyncManagement($ui)
+ {
+ $state_params = $GLOBALS['conf']['activesync']['state']['params'];
+ $state_params['db'] = $GLOBALS['injector']->getInstance('Horde_Db_Adapter_Base');
+ $stateMachine = new Horde_ActiveSync_State_History($state_params);
+ if ($ui->vars->wipe) {
+ $stateMachine->setDeviceRWStatus($ui->vars->wipe, Horde_ActiveSync::RWSTATUS_PENDING);
+ $GLOBALS['notification']->push(sprintf(_("A Remote Wipe for device id %s has been initiated. The device will be wiped durint the next SYNC request."), $ui->vars->wipe));
+ } elseif ($ui->vars->reset) {
+ // @TODO
+ //$stateMachine->removeState();
+ }
+ }
}
--- /dev/null
+<div class="smallheader">
+ <gettext>Device Management</gettext>
+</div>
+
+<if:devices>
+<table class="horde-table striped">
+ <tr>
+ <th><gettext>Select for wipe</gettext></th>
+ <th><gettext>Device</gettext></th>
+ <th><gettext>Last Sync Time</gettext></th>
+ <th><gettext>Status</gettext></th>
+ </tr>
+<loop:devices>
+ <tr class="<tag:devices.class />">
+ <td><input type="radio" name="wipe" value="<tag:devices.device_id />" /></td>
+ <td><tag:devices.device_type /></td>
+ <td><tag:devices.ts /></td>
+ <td><tag:devices.status /></td>
+ </tr>
+</loop:devices>
+</table>
+<else:devices>
+<p>
+ <em><gettext>None</gettext></em>
+</p>
+</else:devices></if:devices>
+<p><strong>NOTE: WIPING A DEVICE MAY RESET IT TO FACTORY DEFAULTS. PLEASE MAKE SURE YOU REALLY WANT TO DO THIS BEFORE REQUESTING A WIPE</strong></p>
+
+<div class="smallheader">
+ <gettext>State Management</gettext>
+</div>
+<p><gettext>Reset all device state. This will cause your devices to resyncronize all items.</gettext><a class="button" href="<tag:reset />"><gettext>Reset</gettext></a>
\ No newline at end of file