Rename this method getDeviceInfo() -> loadDeviceInfo(), no need to pass
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 12 May 2010 16:22:39 +0000 (12:22 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 12 May 2010 16:22:39 +0000 (12:22 -0400)
username in this form, just get it when processing changes.

framework/ActiveSync/lib/Horde/ActiveSync.php
framework/ActiveSync/lib/Horde/ActiveSync/Request/Base.php
framework/ActiveSync/lib/Horde/ActiveSync/Request/Ping.php
framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php
framework/ActiveSync/lib/Horde/ActiveSync/State/File.php
framework/ActiveSync/lib/Horde/ActiveSync/State/History.php
horde/lib/Prefs/Ui.php
horde/templates/prefs/activesync.html

index a498323..31a434b 100644 (file)
@@ -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 */
index ca053ae..5d9f803 100644 (file)
@@ -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;
          }
index e604dc2..4ca17e4 100644 (file)
@@ -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
index 4e53c91..2a2b4bd 100644 (file)
@@ -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
index e5051d8..a22e783 100644 (file)
@@ -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);
index 553bcc0..5527219 100644 (file)
@@ -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 */
index 2826a79..b80b1f8 100644 (file)
@@ -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());
         }
     }
 
index 9f11dcc..9457767 100644 (file)
@@ -9,7 +9,6 @@
 <input type="hidden" id="removedevice" name="removedevice" />
 <input type="hidden" name="wipeid" id="wipeid" />
 <input type="hidden" name="cancelwipe" id="cancelwipe" />
-<input type="hidden" name="removeuser" id="removeuser" value="<tag:username />" />
 <table class="horde-table striped">
  <tr>
      <th></th>