Skip to content

Commit

Permalink
Fix requesting remote wipe with the MongoDB driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Jun 6, 2014
1 parent 3f73bb1 commit 2ada5d2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions framework/ActiveSync/lib/Horde/ActiveSync/State/Mongo.php
Expand Up @@ -811,16 +811,32 @@ public function setDeviceRWStatus($devId, $status)
{
$query = array(self::MONGO_ID => $devId);
$new_data = array(self::DEVICE_RWSTATUS => $status);
if ($status == Horde_ActiveSync::RWSTATUS_PENDING) {
$new_data[self::DEVICE_USERS_POLICYKEY] = 0;
}
$update = array('$set' => $new_data);
try {
$this->_db->selectCollection(self::COLLECTION_DEVICE)->update($query, $update);
} catch (Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}

if ($status == Horde_ActiveSync::RWSTATUS_PENDING) {
$new_data[self::DEVICE_USERS_POLICYKEY] = 0;
$cursor = $this->_db->selectCollection(self::COLLECTION_DEVICE)->find($query, array('users'));
try {
foreach ($cursor as $row) {
foreach ($row['users'] as $user) {
$this->_db->selectCollection(self::COLLECTION_DEVICE)->update(
array(self::DEVICE_USERS_USER => $user[self::DEVICE_USER]),
array('$set' => array('users.$.device_policykey' => 0)),
array('multiple' => true)
);
}
}
} catch (Exception $e) {
$this->_logger->err($e->getMessage());
throw new Horde_ActiveSync_Exception($e);
}
}
}

/**
Expand Down

0 comments on commit 2ada5d2

Please sign in to comment.