/**
  *
  * Add an item to the cart in overdrive and then process the cart so it is checked out.
  *
  * @param string $overDriveId
  * @param int $format
  * @param int $lendingPeriod  the number of days that the user would like to have the title chacked out. or -1 to use the default
  * @param User $user
  */
 public function checkoutOverDriveItem($overDriveId, $format, $lendingPeriod, $user)
 {
     global $logger;
     $ch = curl_init();
     $overDriveInfo = $this->_loginToOverDrive($ch, $user);
     $closeSession = true;
     $addCartResult = $this->addItemToOverDriveCart($overDriveId, $format, $user, $overDriveInfo);
     if ($addCartResult['result'] == true) {
         $processCartResult = $this->processOverDriveCart($user, $lendingPeriod, $overDriveInfo);
         if ($processCartResult['result'] == true) {
             //Delete the cache for the record
             global $memCache;
             $memCache->delete('overdrive_record_' . $overDriveId);
             $memCache->delete('overdrive_items_' . $overDriveId);
             //Record that the entry was checked out in strands
             global $configArray;
             $eContentRecord = new EContentRecord();
             $eContentRecord->whereAdd("sourceUrl like '%{$overDriveId}'");
             if ($eContentRecord->find(true)) {
                 if (isset($configArray['Strands']['APID']) && $user->disableRecommendations == 0) {
                     //Get the record for the item
                     $orderId = $user->id . '_' . time();
                     $strandsUrl = "http://bizsolutions.strands.com/api2/event/purchased.sbs?needresult=true&apid={$configArray['Strands']['APID']}&item=econtentRecord{$eContentRecord->id}::0.00::1&user={$user->id}&orderid={$orderId}";
                     $ret = file_get_contents($strandsUrl);
                     /*global $logger;
                     		$logger->log("Strands Checkout\r\n$ret", PEAR_LOG_INFO);*/
                 }
                 //Add the record to the reading history
                 require_once ROOT_DIR . '/Drivers/EContentDriver.php';
                 $eContentDriver = new EContentDriver();
                 $eContentDriver->addRecordToReadingHistory($eContentRecord, $user);
             }
         }
         curl_close($ch);
         return $processCartResult;
     } else {
         curl_close($ch);
         return $addCartResult;
     }
 }