Make sure we record the user when updating the map table. Fixes Bug: 9168.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 10 Aug 2010 23:59:00 +0000 (19:59 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 10 Aug 2010 23:59:50 +0000 (19:59 -0400)
framework/ActiveSync/lib/Horde/ActiveSync/Connector/Importer.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

index 5a42a73..7882760 100644 (file)
@@ -114,7 +114,7 @@ class Horde_ActiveSync_Connector_Importer
             $change['id'] = $id;
             // mod is 0 to force a re-synch in the case of server failure. This
             // is updated after the change succeeds in the next updateState()
-            $change['mod'] = 0; 
+            $change['mod'] = 0;
             $change['parent'] = $this->_folderId;
             $change['flags'] = (isset($message->read)) ? $message->read : 0;
             $this->_state->updateState('change', $change, Horde_ActiveSync::CHANGE_ORIGIN_NA);
@@ -133,7 +133,7 @@ class Horde_ActiveSync_Connector_Importer
         }
 
         /* Record the state of the message */
-        $this->_state->updateState('change', $stat, Horde_ActiveSync::CHANGE_ORIGIN_PIM);
+        $this->_state->updateState('change', $stat, Horde_ActiveSync::CHANGE_ORIGIN_PIM, $this->_backend->getUser());
 
         return $stat['id'];
     }
@@ -161,7 +161,7 @@ class Horde_ActiveSync_Connector_Importer
         $change['id'] = $id;
         $change['mod'] = time();
         $change['parent'] = $this->_folderId;
-        $this->_state->updateState('delete', $change, Horde_ActiveSync::CHANGE_ORIGIN_PIM, $this->_folderId);
+        $this->_state->updateState('delete', $change, Horde_ActiveSync::CHANGE_ORIGIN_PIM, $this->_backend->getUser());
 
         /* If server wins the conflict, don't import change - it will be
          * detected on next sync and sent back to PIM (since we updated the PIM
index 1f05d37..2c6e0e3 100644 (file)
@@ -483,10 +483,11 @@ abstract class Horde_ActiveSync_State_Base
      * @param string $type     The type of change (change, delete, flags)
      * @param array $change    A stat/change hash describing the change
      * @param integer $origin  Flag to indicate the origin of the change.
+     * @param string $user     The current synch user
      *
      * @return void
      */
-    abstract public function updateState($type, $change, $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA);
+    abstract public function updateState($type, $change, $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA, $user = null);
 
     /**
      * Save folder data for a specific device. This is needed for BC with older
index 3b2a778..1b6777f 100644 (file)
@@ -175,7 +175,7 @@ class Horde_ActiveSync_State_File extends Horde_ActiveSync_State_Base
      *
      * @return void
      */
-    public function updateState($type, $change, $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA)
+    public function updateState($type, $change, $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA, $user = null)
     {
         if (empty($this->_stateCache)) {
             $this->_stateCache = array();
index 66e5432..4337fdf 100644 (file)
@@ -243,15 +243,17 @@ class Horde_ActiveSync_State_History extends Horde_ActiveSync_State_Base
      * @param string $type     The type of change (change, delete, flags)
      * @param array $change    A stat/change hash describing the change
      * @param integer $origin  Flag to indicate the origin of the change.
+     * @param string $user     The current sync user, only needed if change
+     *                         origin is CHANGE_ORIGIN_PIM
      *
      * @return void
      */
-    public function updateState($type, $change, $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA)
+    public function updateState($type, $change, $origin = Horde_ActiveSync::CHANGE_ORIGIN_NA, $user = null)
     {
         if ($origin == Horde_ActiveSync::CHANGE_ORIGIN_PIM) {
-            $sql = 'INSERT INTO ' . $this->_syncMapTable . ' (message_uid, sync_modtime, sync_key, sync_devid, sync_folderid) VALUES (?, ?, ?, ?, ?)';
+            $sql = 'INSERT INTO ' . $this->_syncMapTable . ' (message_uid, sync_modtime, sync_key, sync_devid, sync_folderid, sync_user) VALUES (?, ?, ?, ?, ?, ?)';
             try {
-               $this->_db->insert($sql, array($change['id'], $change['mod'], $this->_syncKey, $this->_devId, $change['parent']));
+               $this->_db->insert($sql, array($change['id'], $change['mod'], $this->_syncKey, $this->_devId, $change['parent'], $user));
             } catch (Horde_Db_Exception $e) {
                 $this->_logger->err($e->getMessage());
                throw new Horde_ActiveSync_Exception($e);