From: Michael J. Rubinsky Date: Thu, 29 Apr 2010 18:45:01 +0000 (-0400) Subject: initial activesync device management pref screen. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=61dfb8dbfb5c392b3a376f2e433a8906cd9388f3;p=horde.git initial activesync device management pref screen. --- diff --git a/horde/lib/Prefs/Ui.php b/horde/lib/Prefs/Ui.php index 9b344bf70..34bf60e8a 100644 --- a/horde/lib/Prefs/Ui.php +++ b/horde/lib/Prefs/Ui.php @@ -136,6 +136,9 @@ class Horde_Prefs_Ui case 'syncmlmanagement': return $this->_syncmlManagement($ui); + + case 'activesyncmanagement': + return $this->_activesyncManagement($ui); } return ''; @@ -162,6 +165,10 @@ class Horde_Prefs_Ui case 'syncmlmanagement': $this->_updateSyncmlManagement($ui); break; + + case 'activesyncmanagement': + $this->_updateActiveSyncManagement($ui); + break; } return false; @@ -373,12 +380,58 @@ class Horde_Prefs_Ui ); } } - $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 = 'Wipe is pending'; + break; + case Horde_ActiveSync::RWSTATUS_WIPED: + $status = 'Device is wiped'; + break; + default: + $status = 'Device is partnered'; + } + $device['status'] = $status . '
Device id: ' . $device['device_id'] . '
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. @@ -506,4 +559,22 @@ class Horde_Prefs_Ui } } + /** + * 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(); + } + } } diff --git a/horde/templates/prefs/activesync.html b/horde/templates/prefs/activesync.html new file mode 100644 index 000000000..d4e5d6ad0 --- /dev/null +++ b/horde/templates/prefs/activesync.html @@ -0,0 +1,32 @@ +
+ Device Management +
+ + + + + + + + + + + + + + + + + +
Select for wipeDeviceLast Sync TimeStatus
+ +

+ None +

+
+

NOTE: WIPING A DEVICE MAY RESET IT TO FACTORY DEFAULTS. PLEASE MAKE SURE YOU REALLY WANT TO DO THIS BEFORE REQUESTING A WIPE

+ +
+ State Management +
+

Reset all device state. This will cause your devices to resyncronize all items.Reset \ No newline at end of file