49         $oReservations = 
oxNew(
'oxuserbasket');
 
   50         $aWhere = array(
'oxuserbaskets.oxuserid' => $sBasketId, 
'oxuserbaskets.oxtitle' => 
'reservations');
 
   53         if (!$oReservations->assignRecord($oReservations->buildSelectString($aWhere))) {
 
   54             $oReservations->oxuserbaskets__oxtitle = 
new oxField(
'reservations');
 
   55             $oReservations->oxuserbaskets__oxuserid = 
new oxField($sBasketId);
 
   57             $oReservations->setIsNewBasket();
 
   60         return $oReservations;
 
   70         if ($this->_oReservations) {
 
   90         if (isset($this->_aCurrentlyReserved)) {
 
   99         $this->_aCurrentlyReserved = array();
 
  100         foreach ($oReserved->getItems(
false, 
false) as $oItem) {
 
  101             if (!isset($this->_aCurrentlyReserved[$oItem->oxuserbasketitems__oxartid->value])) {
 
  102                 $this->_aCurrentlyReserved[$oItem->oxuserbasketitems__oxartid->value] = 0;
 
  104             $this->_aCurrentlyReserved[$oItem->oxuserbasketitems__oxartid->value] += $oItem->oxuserbasketitems__oxamount->value;
 
  120         if (isset($aCurrentlyReserved[$sArticleId])) {
 
  121             return $aCurrentlyReserved[$sArticleId];
 
  139             $sProdId = $oItem->getProductId();
 
  140             if (!isset($aDiff[$sProdId])) {
 
  141                 $aDiff[$sProdId] = -$oItem->getAmount();
 
  143                 $aDiff[$sProdId] -= $oItem->getAmount();
 
  159         $blAllowNegativeStock = $this->
getConfig()->getConfigParam(
'blAllowNegativeStock');
 
  162         foreach ($aBasketDiff as $sId => $dAmount) {
 
  164                 $oArticle = 
oxNew(
'oxarticle');
 
  165                 if ($oArticle->load($sId)) {
 
  166                     $oArticle->reduceStock(-$dAmount, $blAllowNegativeStock);
 
  167                     $oReserved->addItemToBasket($sId, -$dAmount);
 
  171         $this->_aCurrentlyReserved = null;
 
  198         if ($dReserved < $dAmount) {
 
  199             $dAmount = $dReserved;
 
  202         $oArticle = 
oxNew(
'oxarticle');
 
  203         $oArticle->load($sArticleId);
 
  206         $oArticle->beforeUpdate();
 
  207         $oArticle->updateSoldAmount($dAmount);
 
  208         $this->_aCurrentlyReserved = null;
 
  221             $oArticle = 
oxNew(
'oxarticle');
 
  222             if ($oArticle->load($sArticleId)) {
 
  223                 $oArticle->reduceStock(-$dReserved, 
true);
 
  225                 $this->_aCurrentlyReserved = null;
 
  238         if ($this->_oReservations) {
 
  239             $this->_oReservations->delete();
 
  240             $this->_oReservations = null;
 
  241             $this->_aCurrentlyReserved = null;
 
  256         $iStartTime = 
oxRegistry::get(
"oxUtilsDate")->getTime() - (int) $this->
getConfig()->getConfigParam(
'iPsBasketReservationTimeout');
 
  257         $oRs = $oDb->select(
"select oxid from oxuserbaskets where oxtitle = 'reservations' and oxupdate <= $iStartTime limit $iLimit", 
false, 
false);
 
  261         $aFinished = array();
 
  263             $aFinished[] = $oDb->quote($oRs->fields[
'oxid']);
 
  266         $oRs = $oDb->select(
"select oxartid, oxamount from oxuserbasketitems where oxbasketid in (" . implode(
",", $aFinished) . 
")", 
false, 
false);
 
  268             $oArticle = 
oxNew(
'oxarticle');
 
  269             if ($oArticle->load($oRs->fields[
'oxartid'])) {
 
  270                 $oArticle->reduceStock(-$oRs->fields[
'oxamount'], 
true);
 
  274         $oDb->execute(
"delete from oxuserbasketitems where oxbasketid in (" . implode(
",", $aFinished) . 
")");
 
  275         $oDb->execute(
"delete from oxuserbaskets where oxid in (" . implode(
",", $aFinished) . 
")");
 
  278         $oDb->execute(
"delete from oxuserbaskets where oxtitle = 'savedbasket' and oxupdate <= $iStartTime");
 
  280         $this->_aCurrentlyReserved = null;
 
  290         $iTimeout = $this->
getConfig()->getConfigParam(
'iPsBasketReservationTimeout');
 
  293             if ($oRev && $oRev->getId()) {
 
  294                 $iTimeout -= (
oxRegistry::get(
"oxUtilsDate")->getTime() - (int) $oRev->oxuserbaskets__oxupdate->value);
 
  295                 oxRegistry::getSession()->setVariable(
"iBasketReservationTimeout", $oRev->oxuserbaskets__oxupdate->value);
 
  297                 $iTimeout -= (
oxRegistry::get(
"oxUtilsDate")->getTime() - (int) $iSessionTimeout);
 
  300             return $iTimeout < 0 ? 0 : $iTimeout;
 
  313             $oReserved->oxuserbaskets__oxupdate = 
new oxField($iTime);