From 114ba01a0badc43999b068cfd03b14d15eaa663c Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Wed, 12 May 2010 12:22:39 -0400 Subject: [PATCH] Rename this method getDeviceInfo() -> loadDeviceInfo(), no need to pass username in this form, just get it when processing changes. --- framework/ActiveSync/lib/Horde/ActiveSync.php | 2 +- framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php | 2 +- framework/ActiveSync/lib/Horde/ActiveSync/Request/Ping.php | 2 +- framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php | 2 +- framework/ActiveSync/lib/Horde/ActiveSync/State/File.php | 6 +++--- framework/ActiveSync/lib/Horde/ActiveSync/State/History.php | 4 ++-- horde/lib/Prefs/Ui.php | 9 +++++---- horde/templates/prefs/activesync.html | 1 - 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/framework/ActiveSync/lib/Horde/ActiveSync.php b/framework/ActiveSync/lib/Horde/ActiveSync.php index a49832370..31a434bf3 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync.php @@ -862,7 +862,7 @@ class Horde_ActiveSync $state->setDeviceInfo($device); } elseif (!empty($devId)) { // @TODO: Check if the empty check is necessary - $device = $state->getDeviceInfo($devId, $this->_driver->getUser()); + $device = $state->loadDeviceInfo($devId, $this->_driver->getUser()); } /* Load the request handler to handle the request */ diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php index ca053aeea..5d9f803a9 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php @@ -149,7 +149,7 @@ abstract class Horde_ActiveSync_Request_Base * header - which is against the specification. Check the user agent * for Android (maybe need version sniffing in the future) and set the * policykey to null for those devices. */ - $this->_device = $this->_state->getDeviceInfo($this->_device->id, $this->_driver->getUser()); + $this->_device = $this->_state->loadDeviceInfo($this->_device->id, $this->_driver->getUser()); if (strpos($this->_device->userAgent, 'Android') !== false) { $sentKey = null; } diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Ping.php b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Ping.php index e604dc21f..4ca17e4cb 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/Request/Ping.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/Request/Ping.php @@ -84,7 +84,7 @@ class Horde_ActiveSync_Request_Ping extends Horde_ActiveSync_Request_Base /* Initialize the state machine */ $this->_state = &$this->_driver->getStateObject(); - $this->_state->getDeviceInfo($this->_device->id, $this->_driver->getUser()); + $this->_state->loadDeviceInfo($this->_device->id, $this->_driver->getUser()); /* See if we have an existing PING state. Need to do this here, before * we read in the PING request since the PING request is allowed to omit diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php b/framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php index 4e53c91fb..2a2b4bd4a 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php @@ -558,7 +558,7 @@ abstract class Horde_ActiveSync_State_Base * * @return StdClass */ - abstract public function getDeviceInfo($device, $user); + abstract public function loadDeviceInfo($device, $user); /** * Check that a given device id is known to the server. This is regardless diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php b/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php index e5051d8f1..a22e78388 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/State/File.php @@ -343,7 +343,7 @@ class Horde_ActiveSync_State_File extends Horde_ActiveSync_State_Base * @return object The device info object * @throws Horde_ActiveSync_Exception */ - public function getDeviceInfo($devId, $user) + public function loadDeviceInfo($devId, $user) { $this->_devId = $devId; $file = $this->_stateDir . '/' . $user . '/info-' . $devId; @@ -502,7 +502,7 @@ class Horde_ActiveSync_State_File extends Horde_ActiveSync_State_Base */ public function setPolicyKey($devId, $key) { - $info = $this->getDeviceInfo($devId); + $info = $this->loadDeviceInfo($devId); $info->policykey = $key; $this->setDeviceInfo($info); $this->_logger->info('[' . $devId . '] New policykey saved: ' . $key); @@ -518,7 +518,7 @@ class Horde_ActiveSync_State_File extends Horde_ActiveSync_State_Base */ public function setDeviceRWStatus($devId, $status) { - $info = $this->getDeviceInfo($devId); + $info = $this->loadDeviceInfo($devId); $info->rwstatus = $status; $this->setDeviceInfo($info); $this->_logger->info('[' . $devId . '] Setting DeviceRWStatus: ' . $status); diff --git a/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php b/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php index 553bcc0db..552721933 100644 --- a/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php +++ b/framework/ActiveSync/lib/Horde/ActiveSync/State/History.php @@ -394,7 +394,7 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base */ public function initPingState($device) { - /* This would normally already be loaded by getDeviceInfo() but we + /* This would normally already be loaded by loadDeviceInfo() but we * should verify we have the correct device loaded etc... */ if (!isset($this->_pingState) || $this->_devId !== $device->id) { throw new Horde_ActiveSync_Exception('Device not loaded'); @@ -414,7 +414,7 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base * @return object The device obejct * @throws Horde_ActiveSync_Exception */ - public function getDeviceInfo($devId, $user) + public function loadDeviceInfo($devId, $user) { //@TODO - combine _devId and _deviceInfo /* See if we have it already */ diff --git a/horde/lib/Prefs/Ui.php b/horde/lib/Prefs/Ui.php index 2826a7911..b80b1f860 100644 --- a/horde/lib/Prefs/Ui.php +++ b/horde/lib/Prefs/Ui.php @@ -416,13 +416,12 @@ class Horde_Prefs_Ui $t->setOption('gettext', true); $selfurl = $ui->selfUrl(); $t->set('reset', $selfurl->copy()->add('reset', 1)); - $t->set('username', Horde_Auth::getAuth()); $devices = $stateMachine->listDevices(Horde_Auth::getAuth()); $devs = array(); $i = 1; foreach ($devices as $device) { $device['class'] = fmod($i++, 2) ? 'rowOdd' : 'rowEven'; - $stateMachine->getDeviceInfo($device['device_id'], Horde_Auth::getAuth()); + $stateMachine->loadDeviceInfo($device['device_id'], Horde_Auth::getAuth()); $ts = $stateMachine->getLastSyncTimestamp(); $device['ts'] = empty($ts) ? _("None") : strftime($GLOBALS['prefs']->getValue('date_format') . ' %H:%M', $ts); switch ($device['device_rwstatus']) { @@ -696,19 +695,21 @@ class Horde_Prefs_Ui $stateMachine = new Horde_ActiveSync_State_History($state_params); $stateMachine->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger')); if ($ui->vars->wipeid) { + $stateMachine->loadDeviceInfo($ui->vars->wipeid, Horde_Auth::getAuth()); $stateMachine->setDeviceRWStatus($ui->vars->wipeid, Horde_ActiveSync::RWSTATUS_PENDING); $GLOBALS['notification']->push(sprintf(_("A Remote Wipe for device id %s has been initiated. The device will be wiped during the next SYNC request."), $ui->vars->wipe)); } elseif ($ui->vars->cancelwipe) { + $stateMachine->loadDeviceInfo($ui->vars->cancelwipe, Horde_Auth::getAuth()); $stateMachine->setDeviceRWStatus($ui->vars->cancelwipe, Horde_ActiveSync::RWSTATUS_OK); $GLOBALS['notification']->push(sprintf(_("The Remote Wipe for device id %s has been cancelled."), $ui->vars->wipe)); } elseif ($ui->vars->reset) { $devices = $stateMachine->listDevices(Horde_Auth::getAuth()); foreach ($devices as $device) { - $stateMachine->removeState(null, $device['device_id'], $ui->vars->removeuser); + $stateMachine->removeState(null, $device['device_id'], Horde_Auth::getAuth()); } $GLOBALS['notification']->push(_("All state removed for your devices. They will resynchronize next time they connect to the server.")); } elseif ($ui->vars->removedevice) { - $stateMachine->removeState(null, $ui->vars->removedevice, $ui->vars->removeuser); + $stateMachine->removeState(null, $ui->vars->removedevice, Horde_Auth::getAuth()); } } diff --git a/horde/templates/prefs/activesync.html b/horde/templates/prefs/activesync.html index 9f11dcc06..945776721 100644 --- a/horde/templates/prefs/activesync.html +++ b/horde/templates/prefs/activesync.html @@ -9,7 +9,6 @@ - -- 2.11.0