src/ShopBundle/pkgExtranet/objects/db/TShopDataExtranetUser.class.php
public function AddArticleIdToNoticeList($iArticleId, $iAmount = 1)
    {
        $dNewAmountOnList = 0;

        if (is_null($this->aNoticeList)) {
            $this->GetNoticeListArticles();
        }
        // check if the item being pushed is already in the end of the queue
        $iMaxQueueLength = 1000;

        $queNotEmpty = (count($this->aNoticeList) > 0);

        if (array_key_exists($iArticleId, $this->aNoticeList)) {
            // we do not allow placing an article more than once on the notice list
            $dNewAmountOnList = false;
        } else {
            $oNoticeListItem = TdbShopUserNoticeList::GetNewInstance();
            /** @var $oNoticeListItem TdbShopUserNoticeList */
            $aData = array('shop_article_id' => $iArticleId, 'date_added' => date('Y-m-d H:i:s'), 'data_extranet_user_id' => $this->id, 'amount' => $iAmount);
            $oNoticeListItem->LoadFromRow($aData);
            if (!is_null($this->id) && $this->IsLoggedIn()) {
                $oNoticeListItem->Save();
            }
            $this->aNoticeList[$oNoticeListItem->fieldShopArticleId] = $oNoticeListItem->sqlData;
        }

        if (false !== $dNewAmountOnList) {
            // remove item if amount drops to zero
            if ($this->aNoticeList[$iArticleId]['amount'] <= 0) {
                unset($this->aNoticeList[$iArticleId]);
            } else {
                $dNewAmountOnList = $this->aNoticeList[$iArticleId]['amount'];
            }

            // if the list is full, remove last item
            if (count($this->aNoticeList) > $iMaxQueueLength) {
                array_pop($this->aNoticeList);
            }

            // save list to cookie for users not signed in
            if (!$this->IsLoggedIn()) {
                $this->CommitNoticeListToCookie();
            }
        }

        return $dNewAmountOnList;
    }
public function AddArticleIdToNoticeList($iArticleId, $iAmount = 1)
    {
        $dNewAmountOnList = 0;

        if (is_null($this->aNoticeList)) {
            $this->GetNoticeListArticles();
        }
        // check if the item being pushed is already in the end of the queue
        $iMaxQueueLength = 1000;

        $queNotEmpty = (count($this->aNoticeList) > 0);

        if (array_key_exists($iArticleId, $this->aNoticeList)) {
            // we do not allow placing an article more than once on the notice list
            $dNewAmountOnList = false;
        } else {
            $oNoticeListItem = TdbShopUserNoticeList::GetNewInstance();
            /** @var $oNoticeListItem TdbShopUserNoticeList */
            $aData = array('shop_article_id' => $iArticleId, 'date_added' => date('Y-m-d H:i:s'), 'data_extranet_user_id' => $this->id, 'amount' => $iAmount);
            $oNoticeListItem->LoadFromRow($aData);
            if (!is_null($this->id) && $this->IsLoggedIn()) {
                $oNoticeListItem->Save();
            }
            $this->aNoticeList[$oNoticeListItem->fieldShopArticleId] = $oNoticeListItem->sqlData;
        }

        if (false !== $dNewAmountOnList) {
            // remove item if amount drops to zero
            if ($this->aNoticeList[$iArticleId]['amount'] <= 0) {
                unset($this->aNoticeList[$iArticleId]);
            } else {
                $dNewAmountOnList = $this->aNoticeList[$iArticleId]['amount'];
            }

            // if the list is full, remove last item
            if (count($this->aNoticeList) > $iMaxQueueLength) {
                array_pop($this->aNoticeList);
            }

            // save list to cookie for users not signed in
            if (!$this->IsLoggedIn()) {
                $this->CommitNoticeListToCookie();
            }
        }

        return $dNewAmountOnList;
    }
public function AddArticleIdToNoticeList ( $ iArticleId , $ iAmount = 1 ) { $ dNewAmountOnList = 0 ; if ( is_null ( $ this -> aNoticeList ) ) { $ this -> GetNoticeListArticles ( ) ; } // check if the item being pushed is already in the end of the queue $ iMaxQueueLength = 1000 ; $ queNotEmpty = ( count ( $ this -> aNoticeList ) > 0 ) ; if ( array_key_exists ( $ iArticleId , $ this -> aNoticeList ) ) { // we do not allow placing an article more than once on the notice list $ dNewAmountOnList = false ; } else { $ oNoticeListItem = TdbShopUserNoticeList :: GetNewInstance ( ) ; /** @var $oNoticeListItem TdbShopUserNoticeList */ $ aData = array ( 'shop_article_id' => $ iArticleId , 'date_added' => date ( 'Y-m-d H:i:s' ) , 'data_extranet_user_id' => $ this -> id , 'amount' => $ iAmount ) ; $ oNoticeListItem -> LoadFromRow ( $ aData ) ; if ( ! is_null ( $ this -> id ) && $ this -> IsLoggedIn ( ) ) { $ oNoticeListItem -> Save ( ) ; } $ this -> aNoticeList [ $ oNoticeListItem -> fieldShopArticleId ] = $ oNoticeListItem -> sqlData ; } if ( false !== $ dNewAmountOnList ) { // remove item if amount drops to zero if ( $ this -> aNoticeList [ $ iArticleId ] [ 'amount' ] <= 0 ) { unset ( $ this -> aNoticeList [ $ iArticleId ] ) ; } else { $ dNewAmountOnList = $ this -> aNoticeList [ $ iArticleId ] [ 'amount' ] ; } // if the list is full, remove last item if ( count ( $ this -> aNoticeList ) > $ iMaxQueueLength ) { array_pop ( $ this -> aNoticeList ) ; } // save list to cookie for users not signed in if ( ! $ this -> IsLoggedIn ( ) ) { $ this -> CommitNoticeListToCookie ( ) ; } } return $ dNewAmountOnList ; }
add an article to the notice list.

@param int   $iArticleId
@param float $iAmount

@return float - new amount on list
add an article to the notice list .