Loads up to 4 history (normally recently seen) articles from session, and adds $sArtId to history.
Returns article id array.

@param string $sArtId Article ID
@param int    $iCnt   product count
176888
public function loadHistoryArticles($sArtId, $iCnt = 4)
    {
        $aHistoryArticles = $this->getHistoryArticles();
        $aHistoryArticles[] = $sArtId;

        // removing duplicates
        $aHistoryArticles = array_unique($aHistoryArticles);
        if (count($aHistoryArticles) > ($iCnt + 1)) {
            array_shift($aHistoryArticles);
        }

        $this->setHistoryArticles($aHistoryArticles);

        //remove current article and return array
        //asignment =, not ==
        if (($iCurrentArt = array_search($sArtId, $aHistoryArticles)) !== false) {
            unset($aHistoryArticles[$iCurrentArt]);
        }

        $aHistoryArticles = array_values($aHistoryArticles);
        $this->loadIds($aHistoryArticles);
        $this->sortByIds($aHistoryArticles);
    }
870958
public function read($sessID) { 
       $hander 	= 	is_array($this->hander)?$this->hander[1]:$this->hander;
       $res 	= 	mysql_query('SELECT session_data AS data FROM '.$this->sessionTable." WHERE session_id = '$sessID'   AND session_expire >".time(),$hander); 
       if($res) {
           $row = 	mysql_fetch_assoc($res);
           return $row['data']; 
       }
       return ""; 
   }
736462
public function aForm($id, $sessid, $comm, $comt)
    {
        $this->form->create(
            ["id" => __CLASS__, "legend" => "Uppdatera ditt konto"],
            [   "sessid" => ["type"  => "hidden", "value" => $sessid],
                "id" => ["type"  => "hidden", "value" => $id],
                "parentid" => ["type"  => "hidden", "value" => $comm->parentid],
                "title" => ["type" => "text", "validation" => ["not_empty"], "value" => $comm->title],
                "comment" => ["type" => "textarea", "validation" => ["not_empty"], "value" => $comt],
                "submit" => ["type" => "submit", "value" => "Spara", "callback" => [$this, "callbackSubmit"]],
                "reset" => ["type"      => "reset"],
            ]
        );
    }
652671
public function getAttributeAssigns($sArtId)
    {
        if ($sArtId) {
            $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

            $sSelect = "select o2a.oxid from oxobject2attribute as o2a ";
            $sSelect .= "where o2a.oxobjectid = " . $oDb->quote($sArtId) . " order by o2a.oxpos";

            $aIds = [];
            $rs = $oDb->select($sSelect);
            if ($rs != false && $rs->count() > 0) {
                while (!$rs->EOF) {
                    $aIds[] = $rs->fields[0];
                    $rs->fetchRow();
                }
            }

            return $aIds;
        }
    }
773741
protected function _onChangeResetCounts($sOxid, $sVendorId = null, $sManufacturerId = null)
    {
        $myUtilsCount = \OxidEsales\Eshop\Core\Registry::getUtilsCount();

        if ($sVendorId) {
            $myUtilsCount->resetVendorArticleCount($sVendorId);
        }

        if ($sManufacturerId) {
            $myUtilsCount->resetManufacturerArticleCount($sManufacturerId);
        }

        $aCategoryIds = $this->getCategoryIds();
        //also reseting category counts
        foreach ($aCategoryIds as $sCatId) {
            $myUtilsCount->resetCatArticleCount($sCatId);
        }
    }
167480
public function setCatArticleCount($aCache, $sCatId, $sActIdent)
    {
        $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
        $sTable = $oArticle->getViewName();
        $sO2CView = getViewName('oxobject2category');
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        // we use distinct if article is assigned to category twice
        $sQ = "SELECT COUNT( DISTINCT $sTable.`oxid` )
               FROM $sO2CView
                   INNER JOIN $sTable ON $sO2CView.`oxobjectid` = $sTable.`oxid` AND $sTable.`oxparentid` = ''
               WHERE $sO2CView.`oxcatnid` = " . $oDb->quote($sCatId) . " AND " . $oArticle->getSqlActiveSnippet();

        $aCache[$sCatId][$sActIdent] = $oDb->getOne($sQ);

        $this->_setCatCache($aCache);

        return $aCache[$sCatId][$sActIdent];
    }
15438
protected function _initArticle($sHeapTable, $iCnt, & $blContinue)
    {
        $oRs = $this->getDb()->selectLimit("select oxid from $sHeapTable", 1, $iCnt);
        if ($oRs != false && $oRs->count() > 0) {
            $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
            $oArticle->setLoadParentData(true);

            $oArticle->setLanguage(\OxidEsales\Eshop\Core\Registry::getSession()->getVariable("iExportLanguage"));

            if ($oArticle->load($oRs->fields[0])) {
                // if article exists, do not stop export
                $blContinue = true;
                // check price
                $dMinPrice = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("sExportMinPrice");
                if (!isset($dMinPrice) || (isset($dMinPrice) && ($oArticle->getPrice()->getBruttoPrice() >= $dMinPrice))) {
                    //Saulius: variant title added
                    $sTitle = $oArticle->oxarticles__oxvarselect->value ? " " . $oArticle->oxarticles__oxvarselect->value : "";
                    $oArticle->oxarticles__oxtitle->setValue($oArticle->oxarticles__oxtitle->value . $sTitle);

                    $oArticle = $this->updateArticle($oArticle);

                    return $oArticle;
                }
            }
        }
    }
865220
public function AddArticle($sArticleId, $dAmount = 1, $sComment = null)
    {
        $dNewAmount = 0;
        $aItemData = array();
        $oItem = TdbPkgShopWishlistArticle::GetNewInstance();
        /** @var $oItem TdbPkgShopWishlistArticle */
        if ($oItem->LoadFromFields(array('pkg_shop_wishlist_id' => $this->id, 'shop_article_id' => $sArticleId))) {
            $aItemData = $oItem->sqlData;
            $aItemData['amount'] += $dAmount;
        } else {
            $aItemData['pkg_shop_wishlist_id'] = $this->id;
            $aItemData['shop_article_id'] = $sArticleId;
            $aItemData['amount'] = $dAmount;
            $aItemData['datecreated'] = date('Y-m-d H:i:s');
        }
        if (!is_null($sComment)) {
            $aItemData['comment'] = $oItem->LoadFromRow($aItemData);
        }
        $oItem->LoadFromRow($aItemData);
        $oItem->AllowEditByAll(true);
        $oItem->Save();
        $dNewAmount = $aItemData['amount'];

        return $dNewAmount;
    }
478454
public function loadActionArticles($sActionID, $iLimit = null)
    {
        // Performance
        if (!trim($sActionID)) {
            return;
        }

        $sShopID = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId();
        $sActionID = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote(strtolower($sActionID));

        //echo $sSelect;
        $oBaseObject = $this->getBaseObject();
        $sArticleTable = $oBaseObject->getViewName();
        $sArticleFields = $oBaseObject->getSelectFields();

        $oBase = oxNew(\OxidEsales\Eshop\Application\Model\Actions::class);
        $sActiveSql = $oBase->getSqlActiveSnippet();
        $sViewName = $oBase->getViewName();

        $sLimit = ($iLimit > 0) ? "limit " . $iLimit : '';

        $sSelect = "select $sArticleFields from oxactions2article
                              left join $sArticleTable on $sArticleTable.oxid = oxactions2article.oxartid
                              left join $sViewName on $sViewName.oxid = oxactions2article.oxactionid
                              where oxactions2article.oxshopid = '$sShopID' and oxactions2article.oxactionid = $sActionID and $sActiveSql
                              and $sArticleTable.oxid is not null and " . $oBaseObject->getSqlActiveSnippet() . "
                              order by oxactions2article.oxsort $sLimit";

        $this->selectString($sSelect);
    }
989105
public function incrementPostCount($post, $new_tid)
    {
        Container::get('hooks')->fire('model.post.increment_post_count_start', $post, $new_tid);

        if (!User::get()->is_guest) {
            $increment = DB::forTable('users')
                            ->where('id', User::get()->id)
                            ->find_one()
                            ->set('last_post', $post['time'])
                            ->set_expr('num_posts', 'num_posts+1');
            $increment = Container::get('hooks')->fireDB('model.post.increment_post_count_query', $increment);
            $increment = $increment->save();

            // Promote this user to a new group if enabled
            if (User::get()->g_promote_next_group != 0 &&
                User::get()->num_posts + 1 >= User::get()->g_promote_min_posts) {
                $new_group_id = User::get()->g_promote_next_group;
                $promote = DB::forTable('users')
                            ->where('id', User::get()->id)
                            ->find_one()
                            ->set('group_id', $new_group_id);
                $promote = Container::get('hooks')->fireDB('model.post.increment_post_count_query', $promote);
                $promote = $promote->save();
            }

            // Topic tracking stuff...
            $tracked_topics = Track::getTrackedTopics();
            $tracked_topics['topics'][$new_tid] = time();
            Track::setTrackedTopics($tracked_topics);
        } else {
            // Update the last_post field for guests
            $last_post = DB::forTable('online')
                            ->where('ident', Utils::getIp())
                            ->find_one()
                            ->set('last_post', $post['time']);
            $last_post = Container::get('hooks')->fireDB('model.post.increment_post_count_last_post', $last_post);
            $last_post = $last_post->save();
        }

        Container::get('hooks')->fire('model.post.increment_post_count');
    }
116045
public function AddArticleIdToViewHistory($iArticleId)
    {
        if (is_null($this->aArticleViewHistory)) {
            $this->GetArticleViewHistory();
        }
        $iMaxQueueLength = 100;
        $shop = $this->getShopService()->getActiveShop();
        if ($shop->fieldDataExtranetUserShopArticleHistoryMaxArticleCount < $iMaxQueueLength && $shop->fieldDataExtranetUserShopArticleHistoryMaxArticleCount > 0) {
            $iMaxQueueLength = $shop->fieldDataExtranetUserShopArticleHistoryMaxArticleCount;
        }

        // check if the item being pushed is already in the end of the queue
        // if the item is on the queue, then we want to move it to the front
        reset($this->aArticleViewHistory);
        $item = null;
        $iKey = null;
        foreach (array_keys($this->aArticleViewHistory) as $histKey) {
            if (is_null($iKey) && $this->aArticleViewHistory[$histKey]['shop_article_id'] === $iArticleId) {
                $item = $this->aArticleViewHistory[$histKey];
                $iKey = $histKey;
                break;
            }
        }

        if (!is_null($iKey)) {
            unset($this->aArticleViewHistory[$iKey]);
            $item['datecreated'] = date('Y-m-d H:i:s');
            $itemObject = TdbDataExtranetUserShopArticleHistory::GetNewInstance($item);
            if (!is_null($this->id) && $this->IsLoggedIn()) {
                $itemObject->Save();
            }
            array_unshift($this->aArticleViewHistory, $item);
        } else {
            $itemObject = TdbDataExtranetUserShopArticleHistory::GetNewInstance();
            $aData = array('shop_article_id' => $iArticleId, 'datecreated' => date('Y-m-d H:i:s'), 'data_extranet_user_id' => $this->id);
            $itemObject->LoadFromRow($aData);
            if (!is_null($this->id) && $this->IsLoggedIn()) {
                $itemObject->Save();
            }
            array_unshift($this->aArticleViewHistory, $itemObject->sqlData);
        }

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

        // if the user is logged in, we need to make sure the list does not go over the limit set in the shop config
        if (!is_null($this->id) && $this->IsLoggedIn()) {
            if ($shop->fieldDataExtranetUserShopArticleHistoryMaxArticleCount > 0) {
                TdbDataExtranetUserShopArticleHistoryList::ReducedListForUser($shop->fieldDataExtranetUserShopArticleHistoryMaxArticleCount, $this->id);
            }
        }

        // save list to cookie for users not signed in
        if (SHOP_ALLOW_SAVING_ARTICLE_HISTORY_IN_COOKIE && !$this->IsLoggedIn()) {
            if (0 !== $shop->fieldDataExtranetUserShopArticleHistoryMaxCookieSize) {
                reset($this->aArticleViewHistory);
                $aHistory = array();
                foreach (array_keys($this->aArticleViewHistory) as $iHistKey) {
                    $aHistory[] = $this->aArticleViewHistory[$iHistKey];
                }
                $sHistory = json_encode($aHistory);
                $sHistory = base64_encode($sHistory);
                $dByteLength = mb_strlen($sHistory, '8bit');
                $dKByteLength = $dByteLength / 1024;

                if ($dKByteLength > $shop->fieldDataExtranetUserShopArticleHistoryMaxCookieSize) {
                    if (is_array($this->aArticleViewHistory)) {
                        array_pop($this->aArticleViewHistory);
                    }
                    reset($this->aArticleViewHistory);
                    foreach (array_keys($this->aArticleViewHistory) as $iHistKey) {
                        $aHistory[] = $this->aArticleViewHistory[$iHistKey];
                    }
                    $sHistory = json_encode($aHistory);
                    $sHistory = base64_encode($sHistory);
                    $dByteLength = mb_strlen($sHistory, '8bit');
                    $dKByteLength = $dByteLength / 1024;
                }
            }
            $aHistory = array();
            reset($this->aArticleViewHistory);
            foreach (array_keys($this->aArticleViewHistory) as $iHistKey) {
                $aHistory[] = $this->aArticleViewHistory[$iHistKey];
            }
            $sHistory = json_encode($aHistory);
            $sHistory = base64_encode($sHistory);
            $iLifeTime = 31536000; // 1 year
            if ($iLifeTime > CHAMELEON_MAX_COOKIE_LIFETIME) {
                $iLifeTime = CHAMELEON_MAX_COOKIE_LIFETIME;
            }
            $expireTime = $iLifeTime + time();
            $domain = TCMSSmartURLData::GetActive()->sOriginalDomainName;
            // drop 'www' subdomain
            if ('www.' == substr($domain, 0, 4)) {
                $domain = substr($domain, 4);
            }
            setcookie(TdbDataExtranetUser::COOKIE_NAME_HISTORY, $sHistory, $expireTime, '/', '.'.$domain, false, true);
        }
    }
473040
public function ChangePageAjax($iListIdent = null)
    {
        $oResponse = new MTShopArticleListResponse();
        /** @var $oResponse MTShopArticleListResponse */
        if (null === $iListIdent) {
            $oGlobal = TGlobal::instance();
            $iListIdent = $oGlobal->GetUserData(TdbShopArticleList::URL_LIST_KEY_NAME);
        }

        $oListItem = $this->oList;
        if (null !== $oListItem) {
            $bViewNameExists = false;
            $bViewTypeExists = false;
            $bCallTimeVarsExists = false;

            $aItemRawData = TdbShopArticleList::GetInstanceDataFromSession($iListIdent);
            if (is_array($aItemRawData)) {
                $bViewNameExists = (array_key_exists('sViewName', $aItemRawData));
                $bViewTypeExists = (array_key_exists('sViewType', $aItemRawData));
                $bCallTimeVarsExists = (array_key_exists('aCallTimeVars', $aItemRawData));
            }
            if ($bViewNameExists && $bViewTypeExists && $bCallTimeVarsExists) {
                // fetch data for requested item
                $oResponse->iNumberOfResults = $oListItem->GetNumberOfRecordsForCurrentPage();
                $oResponse->bHasNextPage = $oListItem->HasNextPage();
                $oResponse->bHasPreviousPage = $oListItem->HasPreviousPage();
                $oResponse->sItemPage = $oListItem->Render($aItemRawData['sViewName'], $aItemRawData['sViewType'], $aItemRawData['aCallTimeVars']);
                $oResponse->iListKey = $iListIdent;
            }
        }

        $_SESSION['iLastPageNumber'] = $oListItem->GetCurrentPageNumber() - 1;

        return $oResponse;
    }
763108
private function getStockItemId($prodId, $stockId)
    {
        $query = $this->qbGetStockItem->build();
        $conn = $query->getConnection();
        $bind = [
            OwnQbGetStockItem::BND_PROD_ID => $prodId,
            OwnQbGetStockItem::BND_STOCK_ID => $stockId
        ];
        $result = $conn->fetchOne($query, $bind);
        return $result;
    }
447941
public function read($sessID)
    {
        $hander = is_array($this->hander) ? $this->hander[1] : $this->hander;
        $res = mysqli_query($hander, "SELECT session_data AS data FROM " . $this->sessionTable . " WHERE session_id = '$sessID'   AND session_expire >" . time());
        if ($res) {
            $row = mysqli_fetch_assoc($res);
            return $row['data'];
        }
        return "";
    }
237503
protected function _resetCategoriesCounter($sArticleId)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sQ = "select oxcatnid from oxobject2category where oxobjectid = " . $oDb->quote($sArticleId);
        $oRs = $oDb->select($sQ);
        if ($oRs !== false && $oRs->count() > 0) {
            while (!$oRs->EOF) {
                $this->resetCounter("catArticle", $oRs->fields[0]);
                $oRs->fetchRow();
            }
        }
    }
44865
public function write($sessID, $sessData) {
		return $this->handle->set($this->sessionName.$sessID, $sessData, 0, $this->lifeTime);
	}
588220
public function hasArticleId($sArtId)
    {
        if ($this->getArticleId() == $sArtId) {
            return true;
        }

        $aSubvariants = $this->getMdSubvariants();
        foreach ($aSubvariants as $oSubvariant) {
            if ($oSubvariant->hasArticleId($sArtId)) {
                return true;
            }
        }

        return false;
    }