Example #1
0
 /**
  * Executes parent method parent::render(), creates oxlist object and
  * collects user groups information, passes data to Smarty engine,
  * returns name of template file "news_main.tpl".
  *
  * @return string
  */
 public function render()
 {
     $myConfig = $this->getConfig();
     parent::render();
     // all usergroups
     $oGroups = oxNew("oxlist");
     $oGroups->init("oxgroups");
     $oGroups->selectString("select * from " . getViewName("oxgroups", $this->_iEditLang));
     $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
     if ($soxId != "-1" && isset($soxId)) {
         // load object
         $oNews = oxNew("oxnews");
         $oNews->loadInLang($this->_iEditLang, $soxId);
         $oOtherLang = $oNews->getAvailableInLangs();
         if (!isset($oOtherLang[$this->_iEditLang])) {
             // echo "language entry doesn't exist! using: ".key($oOtherLang);
             $oNews->loadInLang(key($oOtherLang), $soxId);
         }
         $this->_aViewData["edit"] = $oNews;
         // remove already created languages
         $this->_aViewData["posslang"] = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
         foreach ($oOtherLang as $id => $language) {
             $oLang = new stdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = clone $oLang;
         }
     }
     if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
         $oNewsMainAjax = oxNew('news_main_ajax');
         $this->_aViewData['oxajax'] = $oNewsMainAjax->getColumns();
         return "popups/news_main.tpl";
     }
     return "news_main.tpl";
 }
 /**
  * returns delivery set id
  *
  * @param string $sTitle delivery name
  *
  * @return string
  */
 public function getIdByName($sTitle)
 {
     $oDb = oxDb::getDb();
     $sQ = "SELECT `oxid` FROM `" . getViewName('oxdeliveryset') . "` WHERE  `oxtitle` = " . $oDb->quote($sTitle);
     $sId = $oDb->getOne($sQ);
     return $sId;
 }
Example #3
0
 /**
  * Adds active promotion check
  *
  * @param array  $aWhere  SQL condition array
  * @param string $sqlFull SQL query string
  *
  * @return $sQ
  */
 protected function _prepareWhereQuery($aWhere, $sqlFull)
 {
     $sQ = parent::_prepareWhereQuery($aWhere, $sqlFull);
     $sDisplayType = (int) oxRegistry::getConfig()->getRequestParameter('displaytype');
     $sTable = getViewName("oxactions");
     //searchong for empty oxfolder fields
     if ($sDisplayType) {
         $sNow = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
         switch ($sDisplayType) {
             case 1:
                 // active
                 $sQ .= " and {$sTable}.oxactivefrom < '{$sNow}' and {$sTable}.oxactiveto > '{$sNow}' ";
                 break;
             case 2:
                 // upcoming
                 $sQ .= " and {$sTable}.oxactivefrom > '{$sNow}' ";
                 break;
             case 3:
                 // expired
                 $sQ .= " and {$sTable}.oxactiveto < '{$sNow}' and {$sTable}.oxactiveto != '0000-00-00 00:00:00' ";
                 break;
         }
     }
     return $sQ;
 }
Example #4
0
 /**
  * Gets voucher from db by given number.
  *
  * @param string $sVoucherNr         Voucher number
  * @param array  $aVouchers          Array of available vouchers (default array())
  * @param bool   $blCheckavalability check if voucher is still reserver od not
  *
  * @throws oxVoucherException exception
  *
  * @return mixed
  */
 public function getVoucherByNr($sVoucherNr, $aVouchers = array(), $blCheckavalability = false)
 {
     $oRet = null;
     if (!empty($sVoucherNr)) {
         $sViewName = $this->getViewName();
         $sSeriesViewName = getViewName('oxvoucherseries');
         $oDb = oxDb::getDb();
         $sQ = "select {$sViewName}.* from {$sViewName}, {$sSeriesViewName} where\n                        {$sSeriesViewName}.oxid = {$sViewName}.oxvoucherserieid and\n                        {$sViewName}.oxvouchernr = " . $oDb->quote($sVoucherNr) . " and ";
         if (is_array($aVouchers)) {
             foreach ($aVouchers as $sVoucherId => $sSkipVoucherNr) {
                 $sQ .= "{$sViewName}.oxid != " . $oDb->quote($sVoucherId) . " and ";
             }
         }
         $sQ .= "( {$sViewName}.oxorderid is NULL || {$sViewName}.oxorderid = '' ) ";
         $sQ .= " and ( {$sViewName}.oxdateused is NULL || {$sViewName}.oxdateused = 0 ) ";
         //voucher timeout for 3 hours
         if ($blCheckavalability) {
             $iTime = time() - $this->_getVoucherTimeout();
             $sQ .= " and {$sViewName}.oxreserved < '{$iTime}' ";
         }
         $sQ .= " limit 1";
         if (!($oRet = $this->assignRecord($sQ))) {
             $oEx = oxNew('oxVoucherException');
             $oEx->setMessage('ERROR_MESSAGE_VOUCHER_NOVOUCHER');
             $oEx->setVoucherNr($sVoucherNr);
             throw $oEx;
         }
     }
     return $oRet;
 }
Example #5
0
 /**
  * Get state title by id
  *
  * @param integer|string $iStateId
  *
  * @return string
  */
 public function getTitleById($iStateId)
 {
     $oDb = oxDb::getDb();
     $sQ = "SELECT oxtitle FROM " . getViewName("oxstates") . " WHERE oxid = " . $oDb->quote($iStateId);
     $sStateTitle = $oDb->getOne($sQ);
     return (string) $sStateTitle;
 }
 /**
  * Selects and loads all address for particular user.
  *
  * @param string $sUserId user id
  */
 public function load($sUserId)
 {
     $sViewName = getViewName('oxcountry');
     $oBaseObject = $this->getBaseObject();
     $sSelectFields = $oBaseObject->getSelectFields();
     $sSelect = "\n                SELECT {$sSelectFields}, `oxcountry`.`oxtitle` AS oxcountry\n                FROM oxaddress\n                LEFT JOIN {$sViewName} AS oxcountry ON oxaddress.oxcountryid = oxcountry.oxid\n                WHERE oxaddress.oxuserid = " . oxDb::getDb()->quote($sUserId);
     $this->selectString($sSelect);
 }
Example #7
0
 /**
  * tests save function with special chars
  */
 public function testDescWithHtmlEntity()
 {
     $oLink = oxNew("oxlinks", getViewName('oxlinks'));
     $oLink->load($this->_oxLinks->getId());
     $oLink->oxlinks__oxurldesc = new oxField('Link&, &amp;, !@#$%^&*%$$&@\'.,;p"äüßö', oxField::T_RAW);
     $this->_oxLinks->Save();
     $this->assertEquals('Link&, &amp;, !@#$%^&*%$$&@\'.,;p"äüßö', $oLink->oxlinks__oxurldesc->value);
 }
 /**
  * Builds and returns SQL query string. Adds additional order check.
  *
  * @param object $oListObject list main object.
  *
  * @return string
  */
 protected function _buildSelectString($oListObject = null)
 {
     $sSql = parent::_buildSelectString($oListObject);
     $sPaymentTable = getViewName("oxpayments");
     $sQ = ", `oepaypal_order`.`oepaypal_paymentstatus`, `payments`.`oxdesc` as `paymentname` from `oxorder`\n        LEFT JOIN `oepaypal_order` ON `oepaypal_order`.`oepaypal_orderid` = `oxorder`.`oxid`\n        LEFT JOIN `" . $sPaymentTable . "` AS `payments` on `payments`.oxid=oxorder.oxpaymenttype ";
     $sSql = str_replace('from oxorder', $sQ, $sSql);
     return $sSql;
 }
Example #9
0
 /**
  * Gets list of content pages which could be used for embedding
  * business entity, price specification, and delivery specification data
  *
  * @return oxContentList
  */
 public function getContentList()
 {
     $oContentList = oxNew("oxcontentlist");
     $sTable = getViewName("oxcontents", $this->_iEditLang);
     $oContentList->selectString("SELECT * FROM {$sTable} WHERE OXACTIVE = 1 AND OXTYPE = 0\n                                    AND OXLOADID IN ('oxagb', 'oxdeliveryinfo', 'oximpressum', 'oxrightofwithdrawal')\n                                    AND OXSHOPID = '" . oxRegistry::getConfig()->getRequestParameter("oxid") . "'");
     // $this->getEditObjectId()
     return $oContentList;
 }
Example #10
0
 /**
  * @param      $sId             oxManufacturer oxId
  * @param int  $iAmount         amount of articles to be loaded
  */
 public function loadRandomManufacturerArticles($sId, $iAmount = 1)
 {
     //var_dump($sId);
     //var_dump($iAmount);
     $sArticleTable = getViewName('oxarticles');
     $sSelect = "SELECT * FROM {$sArticleTable} WHERE oxmanufacturerid = '{$sId}' AND  oxactive = 1 and oxissearch = 1  ORDER BY RAND() LIMIT {$iAmount}";
     $this->selectString($sSelect);
 }
Example #11
0
 /**
  * Executes parent method parent::render(), creates oxCategoryList object,
  * passes it's data to Smarty engine and returns name of template file
  * "selectlist_main.tpl".
  *
  * @return string
  */
 public function render()
 {
     parent::render();
     $sOxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
     $sArticleTable = getViewName('oxarticles');
     //create empty edit object
     $this->_aViewData["edit"] = oxNew("oxselectlist");
     if (isset($sOxId) && $sOxId != "-1") {
         // generating category tree for select list
         // A. hack - passing language by post as lists uses only language passed by POST/GET/SESSION
         $_POST["language"] = $this->_iEditLang;
         $this->_createCategoryTree("artcattree", $sOxId);
         // load object
         $oAttr = oxNew("oxselectlist");
         $oAttr->loadInLang($this->_iEditLang, $sOxId);
         $aFieldList = $oAttr->getFieldList();
         if (is_array($aFieldList)) {
             foreach ($aFieldList as $key => $oField) {
                 if ($oField->priceUnit == '%') {
                     $oField->price = $oField->fprice;
                 }
             }
         }
         $oOtherLang = $oAttr->getAvailableInLangs();
         if (!isset($oOtherLang[$this->_iEditLang])) {
             // echo "language entry doesn't exist! using: ".key($oOtherLang);
             $oAttr->loadInLang(key($oOtherLang), $sOxId);
         }
         $this->_aViewData["edit"] = $oAttr;
         // Disable editing for derived items.
         if ($oAttr->isDerived()) {
             $this->_aViewData['readonly'] = true;
         }
         // remove already created languages
         $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
         if (count($aLang)) {
             $this->_aViewData["posslang"] = $aLang;
         }
         foreach ($oOtherLang as $id => $language) {
             $oLang = new stdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = clone $oLang;
         }
         $iErr = oxRegistry::getSession()->getVariable("iErrorCode");
         if (!$iErr) {
             $iErr = ERR_SUCCESS;
         }
         $this->_aViewData["iErrorCode"] = $iErr;
         oxRegistry::getSession()->setVariable("iErrorCode", ERR_SUCCESS);
     }
     if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
         $oSelectlistMainAjax = oxNew('selectlist_main_ajax');
         $this->_aViewData['oxajax'] = $oSelectlistMainAjax->getColumns();
         return "popups/selectlist_main.tpl";
     }
     return "selectlist_main.tpl";
 }
 /**
  * Modifying SQL query to load additional article and customer data
  *
  * @param object $oListObject list main object
  *
  * @return string
  */
 protected function _buildSelectString($oListObject = null)
 {
     $sViewName = getViewName("oxarticles", (int) $this->getConfig()->getConfigParam("sDefaultLang"));
     $sSql = "select psarticlerequest.*, {$sViewName}.oxtitle AS articletitle, ";
     $sSql .= "oxuser.oxlname as userlname, oxuser.oxfname as userfname ";
     $sSql .= "from psarticlerequest left join {$sViewName} on {$sViewName}.oxid = psarticlerequest.oxartid ";
     $sSql .= "left join oxuser on oxuser.oxid = psarticlerequest.oxuserid WHERE 1 ";
     return $sSql;
 }
 /**
  * Executes parent method parent::render(), creates oxCategoryList object,
  * passes it's data to Smarty engine and returns name of template file
  * "selectlist_main.tpl".
  *
  * @return string
  */
 public function render()
 {
     $myConfig = $this->getConfig();
     parent::render();
     $sOxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
     $sArticleTable = getViewName('oxarticles');
     //create empty edit object
     $this->_aViewData["edit"] = oxNew("oxselectlist");
     if ($sOxId != "-1" && isset($sOxId)) {
         // generating category tree for select list
         // A. hack - passing language by post as lists uses only language passed by POST/GET/SESSION
         $_POST["language"] = $this->_iEditLang;
         $sChosenArtCat = $this->_getCategoryTree("artcattree", $sChosenArtCat, $sOxId);
         // load object
         $oAttr = oxNew("oxselectlist");
         $oAttr->loadInLang($this->_iEditLang, $sOxId);
         $aFieldList = $oAttr->getFieldList();
         if (is_array($aFieldList)) {
             foreach ($aFieldList as $key => $oField) {
                 if ($oField->priceUnit == '%') {
                     $oField->price = $oField->fprice;
                 }
             }
         }
         $oOtherLang = $oAttr->getAvailableInLangs();
         if (!isset($oOtherLang[$this->_iEditLang])) {
             // echo "language entry doesn't exist! using: ".key($oOtherLang);
             $oAttr->loadInLang(key($oOtherLang), $sOxId);
         }
         $this->_aViewData["edit"] = $oAttr;
         // remove already created languages
         $aLang = array_diff(oxLang::getInstance()->getLanguageNames(), $oOtherLang);
         if (count($aLang)) {
             $this->_aViewData["posslang"] = $aLang;
         }
         foreach ($oOtherLang as $id => $language) {
             $oLang = new oxStdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = clone $oLang;
         }
         $iErr = oxSession::getVar("iErrorCode");
         if (!$iErr) {
             $iErr = ERR_SUCCESS;
         }
         $this->_aViewData["iErrorCode"] = $iErr;
         oxSession::setVar("iErrorCode", ERR_SUCCESS);
     }
     if (oxConfig::getParameter("aoc")) {
         $aColumns = array();
         include_once 'inc/' . strtolower(__CLASS__) . '.inc.php';
         $this->_aViewData['oxajax'] = $aColumns;
         return "popups/selectlist_main.tpl";
     }
     return "selectlist_main.tpl";
 }
Example #14
0
 /**
  * Loads article variants data, passes it to Smarty engine and returns name of
  * template file "article_variant.tpl".
  *
  * @return string
  */
 public function render()
 {
     parent::render();
     $soxId = $this->getEditObjectId();
     $sSLViewName = getViewName('oxselectlist');
     // all selectlists
     $oAllSel = oxNew("oxlist");
     $oAllSel->init("oxselectlist");
     $sQ = "select * from {$sSLViewName}";
     $oAllSel->selectString($sQ);
     $this->_aViewData["allsel"] = $oAllSel;
     $oArticle = oxNew("oxArticle");
     $this->_aViewData["edit"] = $oArticle;
     if (isset($soxId) && $soxId != "-1") {
         // load object
         $oArticle->loadInLang($this->_iEditLang, $soxId);
         if ($oArticle->isDerived()) {
             $this->_aViewData['readonly'] = true;
         }
         $_POST["language"] = $_GET["language"] = $this->_iEditLang;
         $oVariants = $oArticle->getAdminVariants($this->_iEditLang);
         $this->_aViewData["mylist"] = $oVariants;
         // load object in other languages
         $oOtherLang = $oArticle->getAvailableInLangs();
         if (!isset($oOtherLang[$this->_iEditLang])) {
             // echo "language entry doesn't exist! using: ".key($oOtherLang);
             $oArticle->loadInLang(key($oOtherLang), $soxId);
         }
         foreach ($oOtherLang as $id => $language) {
             $oLang = new stdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = clone $oLang;
         }
         if ($oArticle->oxarticles__oxparentid->value) {
             $this->_aViewData["parentarticle"] = $this->_getProductParent($oArticle->oxarticles__oxparentid->value);
             $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
             $this->_aViewData["issubvariant"] = 1;
             // A. disable variant information editing for variant
             $this->_aViewData["readonly"] = 1;
         }
         $this->_aViewData["editlanguage"] = $this->_iEditLang;
         $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
         if (count($aLang)) {
             $this->_aViewData["posslang"] = $aLang;
         }
         foreach ($oOtherLang as $id => $language) {
             $oLang = new stdClass();
             $oLang->sLangDesc = $language;
             $oLang->selected = $id == $this->_iEditLang;
             $this->_aViewData["otherlang"][$id] = $oLang;
         }
     }
     return "article_variant.tpl";
 }
 /**
  * DiscountMainAjax::_getQuery() test case
  *
  * @return null
  */
 public function testGetQuerySynchoxid()
 {
     $sSynchoxid = '_testSynchoxid';
     $this->setRequestParameter("synchoxid", $sSynchoxid);
     $sTable = getViewName("oxcountry");
     $oView = oxNew('discount_main_ajax');
     $sQuery = "from {$sTable} where {$sTable}.oxactive = '1' and";
     $sQuery .= " {$sTable}.oxid not in ( select {$sTable}.oxid from oxobject2discount, {$sTable} where {$sTable}.oxid=oxobject2discount.oxobjectid";
     $sQuery .= " and oxobject2discount.oxdiscountid = '_testSynchoxid' and oxobject2discount.oxtype = 'oxcountry' )";
     $this->assertEquals($sQuery, trim($oView->UNITgetQuery()));
 }
Example #16
0
 /**
  * Loads all relevant articles into the current list object
  *
  * @param int    $currPage The current page
  * @param int    $pageSize The page size
  * @param string $skuFilter A single SKU / OXARTNUM
  * @param string $categoryFilter A single oxcategory ID
  */
 public function loadArticles($currPage = 1, $pageSize = 10, $skuFilter = '', $categoryFilter = '')
 {
     //has module?
     $myConfig = $this->getConfig();
     $this->_aArray = array();
     $currPage = $currPage - 1;
     $values = array();
     $sArticleTable = getViewName('oxarticles');
     if ($myConfig->getConfigParam('blNewArtByInsert')) {
         $sType = 'oxinsert';
     } else {
         $sType = 'oxtimestamp';
     }
     $sSelect = "SELECT {$sArticleTable}.* from {$sArticleTable}";
     $sWhere = " WHERE {$sArticleTable}.oxparentid = '' AND " . $this->getBaseObject()->getSqlActiveSnippet() . " AND {$sArticleTable}.oxissearch = 1 AND {$sArticleTable}.oxpic1 != '' ";
     if ($skuFilter) {
         $sWhere .= ' AND $sArticleTable.oxartnum=?';
         $values[] = $skuFilter;
     }
     if ($categoryFilter) {
         /**
                     $oCatList = oxNew('oxcategorylist');
                     $oCatList->buildTree($categoryFilter);
                     $cat_arr = array();
                     foreach($oCatList as $cat){
                         $cat_arr[] = $cat->getId();
                     }
                     $catids = '"'.(implode('","',$cat_arr)).'"';
                     **/
         $sJoin = " JOIN oxobject2category o2c ON " . $sArticleTable . ".oxid = o2c.oxobjectid JOIN oxcategories cat on cat.oxid = o2c.oxcatnid";
         $sWhere .= ' AND cat.oxid IN(';
         /**
                     foreach($cat_arr as $cat){
                         $sWhere .= '?,';
                         $values[] = $cat;
                     }
                     $sWhere = rtrim($sWhere,',').')';
                     **/
         // Used this query instead of the oxid tree function cause they didnt return a proper tree ...
         $sWhere .= "SELECT OXID from oxcategories WHERE OXID = '" . $categoryFilter . "' OR OXPARENTID = '" . $categoryFilter . "' OR OXROOTID = '" . $categoryFilter . "')";
     }
     $sOrder = " ORDER by {$sArticleTable}." . $sType . " DESC ";
     if (!($iLimit = (int) $pageSize)) {
         $iLimit = $myConfig->getConfigParam('iNrofNewcomerArticles');
     }
     $iStart = $currPage;
     if ($iStart > 0) {
         $iStart = $iStart * $iLimit;
     }
     $selectString = $sSelect . $sJoin . $sWhere . $sOrder;
     $this->_aSqlLimit[0] = $iStart;
     $this->_aSqlLimit[1] = $iLimit;
     $this->selectString($selectString, $values);
 }
 /**
  * DiscountUsersAjax::_getQuery() test case
  */
 public function testGetQuerySynchoxid()
 {
     $sSynchoxid = '_testSynchoxid';
     $this->setRequestParameter("synchoxid", $sSynchoxid);
     $sUserTable = getViewName("oxuser");
     $oView = oxNew('discount_users_ajax');
     $sQuery = "from {$sUserTable} where 1  and oxshopid = '" . $this->getShopId() . "'  and";
     $sQuery .= " {$sUserTable}.oxid not in ( select {$sUserTable}.oxid from oxobject2discount, {$sUserTable} where {$sUserTable}.oxid=oxobject2discount.oxobjectid ";
     $sQuery .= " and oxobject2discount.oxdiscountid = '_testSynchoxid' and oxobject2discount.oxtype = 'oxuser' )";
     $this->assertEquals($sQuery, trim($oView->UNITgetQuery()));
 }
 /**
  * Collects and returns user group list.
  *
  * @return object
  */
 public function setUserGroups()
 {
     if ($this->_oGroups === null) {
         $this->_oGroups = oxNew('oxlist');
         $this->_oGroups->init('oxgroups');
         $sViewName = getViewName("oxgroups");
         $sSelect = "select gr.* from {$sViewName} as gr, oxobject2group as o2g where\n                         o2g.oxobjectid = " . oxDb::getDb()->quote($this->getId()) . " and gr.oxid = o2g.oxgroupsid ";
         $this->_oGroups->selectString($sSelect);
     }
     return $this->_oGroups;
 }
Example #19
0
 /**
  * Returns item discount product title
  *
  * @return string
  */
 public function getItemDiscountProductTitle()
 {
     $sTitle = false;
     $sOxId = $this->getEditObjectId();
     if ($sOxId != "-1" && isset($sOxId)) {
         $sViewName = getViewName("oxarticles", $this->_iEditLang);
         $oDb = oxDb::getDb();
         $sQ = "select concat( {$sViewName}.oxartnum, ' ', {$sViewName}.oxtitle ) from oxdiscount\n                   left join {$sViewName} on {$sViewName}.oxid=oxdiscount.oxitmartid\n                   where oxdiscount.oxitmartid != '' and oxdiscount.oxid=" . $oDb->quote($sOxId);
         $sTitle = $oDb->getOne($sQ, false, false);
     }
     return $sTitle ? $sTitle : " -- ";
 }
 /**
  * PriceAlarm_List::BuildWhere() test case
  *
  * @return null
  */
 public function testBuildWhere()
 {
     $this->setRequestParameter('where', array("oxpricealarm" => array("oxprice" => 15), "oxarticles" => array("oxprice" => 15)));
     $sViewName = getViewName("oxpricealarm");
     $sArtViewName = getViewName("oxarticles");
     $oView = $this->getMock("PriceAlarm_List", array("_authorize"));
     $oView->expects($this->any())->method('_authorize')->will($this->returnValue(true));
     $oView->init();
     $queryWhereParts = $oView->buildWhere();
     $this->assertEquals('%15%', $queryWhereParts[$sViewName . '.oxprice']);
     $this->assertEquals('%15%', $queryWhereParts[$sArtViewName . '.oxprice']);
 }
Example #21
0
 /**
  * Adds filtering conditions to query string
  *
  * @param array  $aWhere filter conditions
  * @param string $sSql   query string
  *
  * @return string
  */
 protected function _prepareWhereQuery($aWhere, $sSql)
 {
     $sSql = parent::_prepareWhereQuery($aWhere, $sSql);
     $sArtTable = getViewName('oxarticles', $this->_iEditLang);
     $sArtTitleField = "{$sArtTable}.oxtitle";
     // if searching in article title field, updating sql for this case
     if ($this->_aWhere[$sArtTitleField]) {
         $sSqlForTitle = " (CONCAT( {$sArtTable}.oxtitle, if(isnull(oxparentarticles.oxtitle), '', oxparentarticles.oxtitle), {$sArtTable}.oxvarselect)) ";
         $sSql = getStr()->preg_replace("/{$sArtTable}\\.oxtitle\\s+like/", "{$sSqlForTitle} like", $sSql);
     }
     return $sSql;
 }
Example #22
0
 /**
  * Returns list of user groups assigned to current news object
  *
  * @return oxlist
  */
 public function getGroups()
 {
     if ($this->_oGroups == null && ($sOxid = $this->getId())) {
         // usergroups
         $this->_oGroups = oxNew('oxlist', 'oxgroups');
         $sViewName = getViewName("oxgroups", $this->getLanguage());
         $sSelect = "select {$sViewName}.* from {$sViewName}, oxobject2group ";
         $sSelect .= "where oxobject2group.oxobjectid='{$sOxid}' ";
         $sSelect .= "and oxobject2group.oxgroupsid={$sViewName}.oxid ";
         $this->_oGroups->selectString($sSelect);
     }
     return $this->_oGroups;
 }
Example #23
0
 /**
  * Returns current state list
  *
  * @return array
  */
 public function getStates()
 {
     if (!is_null($this->_aStates)) {
         return $this->_aStates;
     }
     $sCountryId = $this->getId();
     $sViewName = getViewName("oxstates", $this->getLanguage());
     $sQ = "select * from {$sViewName} where `oxcountryid` = '{$sCountryId}' order by `oxtitle`  ";
     $this->_aStates = oxNew("oxlist");
     $this->_aStates->init("oxstate");
     $this->_aStates->selectString($sQ);
     return $this->_aStates;
 }
Example #24
0
 /**
  * Shop_List::BuildWhere() test case
  */
 public function testBuildWhere()
 {
     // Force to set shop ID, as this method rewrite session value. So next line would be lost otherwise.
     $this->getConfig()->getShopId();
     $this->getSession()->setVariable("malladmin", null);
     $this->getSession()->setVariable("actshop", "testShopId");
     $sViewName = getViewName("oxshops");
     // testing..
     $oView = oxNew('Shop_List');
     $aWhere = $oView->buildWhere();
     $this->assertTrue(isset($aWhere[$sViewName . '.oxid']));
     $this->assertEquals("testShopId", $aWhere[$sViewName . '.oxid']);
 }
Example #25
0
 /**
  * @param      $sId             oxCategory oxId
  * @param bool $blFullCatTree   true = browse full category tree instead single category
  */
 public static function getRandomArticle($blFullCatTree = null, $sId = null)
 {
     //var_dump($sId);
     //var_dump($iAmount);
     //var_dump($blFullCatTree);
     $oDb = oxDb::getDb(true);
     $sSelect = "SELECT a.oxid FROM " . getViewName('oxarticles') . " a " . " JOIN oxobject2category b ON a.oxid = b.oxobjectid" . " JOIN oxcategories c ON b.oxcatnid = c.oxid" . " WHERE c.oxid = " . $oDb->qstr($this->getId());
     if ($blFullCatTree) {
         $sSelect .= " OR c.oxrootid = " . $oDb->qstr($sId) . " OR c.oxrootid = " . $oDb->qstr(oxCategory::getRootId($sId));
     }
     $sSelect .= " AND a.oxactive = 1 AND a.oxissearch = 1 ORDER BY RAND() LIMIT {$iAmount}";
     //var_dump($sSelect);
     $aIds = $oDb->getCol($sSelect);
     $this->loadIds($aIds);
 }
 /**
  * Loads payments from db and adds images if exists
  *
  * @param int $iLang language id
  *
  * @return array
  */
 protected function _loadPaymentList($iLang)
 {
     $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
     $sTable = getViewName('oxpayments', $iLang);
     $aPayments = $oDb->getAll("SELECT {$sTable}.* FROM {$sTable} WHERE {$sTable}.OXACTIVE = 1");
     $aPaymentList = array();
     if (is_array($aPayments) && !empty($aPayments)) {
         foreach ($aPayments as $aPayment) {
             $sPaymentId = $aPayment["OXID"];
             $aPayment["OXPAYMENTIMAGE"] = $this->_getImageUrl($sPaymentId, $iLang);
             $aPaymentList[$sPaymentId] = $aPayment;
         }
     }
     return $aPaymentList;
 }
Example #27
0
 /**
  * Builds and returns array of SQL WHERE conditions
  *
  * @return array
  */
 public function buildWhere()
 {
     $this->_aWhere = parent::buildWhere();
     $sViewName = getViewName("oxpricealarm");
     $sArtViewName = getViewName("oxarticles");
     // updating price fields values for correct search in DB
     if (isset($this->_aWhere[$sViewName . '.oxprice'])) {
         $sPriceParam = (double) str_replace(array('%', ','), array('', '.'), $this->_aWhere[$sViewName . '.oxprice']);
         $this->_aWhere[$sViewName . '.oxprice'] = '%' . $sPriceParam . '%';
     }
     if (isset($this->_aWhere[$sArtViewName . '.oxprice'])) {
         $sPriceParam = (double) str_replace(array('%', ','), array('', '.'), $this->_aWhere[$sArtViewName . '.oxprice']);
         $this->_aWhere[$sArtViewName . '.oxprice'] = '%' . $sPriceParam . '%';
     }
     return $this->_aWhere;
 }
Example #28
0
 /**
  * Setting up users
  */
 protected function setupUsers()
 {
     $myDB = oxDb::getDB();
     $sTable = getViewName('oxuser');
     $iLastCustNr = (int) $myDB->getOne('select max( oxcustnr ) from ' . $sTable) + 1;
     $this->_oUser = oxNew('oxuser');
     $this->_oUser->oxuser__oxshopid = new oxField($this->getConfig()->getShopId(), oxField::T_RAW);
     $this->_oUser->oxuser__oxactive = new oxField(1, oxField::T_RAW);
     $this->_oUser->oxuser__oxrights = new oxField('user', oxField::T_RAW);
     $this->_oUser->oxuser__oxusername = new oxField('*****@*****.**', oxField::T_RAW);
     $this->_oUser->oxuser__oxpassword = new oxField(crc32('*****@*****.**'), oxField::T_RAW);
     $this->_oUser->oxuser__oxcustnr = new oxField($iLastCustNr + 1, oxField::T_RAW);
     $this->_oUser->oxuser__oxcountryid = new oxField("testCountry", oxField::T_RAW);
     $this->_oUser->save();
     $sQ = 'insert into oxaddress ( oxid, oxuserid, oxaddressuserid, oxcountryid ) values ( "test_user", "' . $this->_oUser->getId() . '", "' . $this->_oUser->getId() . '", "testCountry" ) ';
     $myDB->Execute($sQ);
 }
 /**
  * Loads article tags from DB. Returns true on success.
  *
  * @param string $articleId article id
  *
  * @return bool
  */
 public function load($articleId)
 {
     $this->setArticleId($articleId);
     $database = oxDb::getDb();
     $viewName = getViewName('oxartextends', $this->getLanguage());
     $query = "select oxtags from {$viewName} where oxid = " . $database->quote($articleId);
     $this->set('');
     // adding tags to list. Tags does not need to be checked again, but dashes needs to be removed
     $tags = explode($this->get()->getSeparator(), $database->getOne($query));
     foreach ($tags as $tag) {
         $oxTag = oxNew('oxtag');
         $oxTag->set($tag, false);
         $oxTag->removeUnderscores();
         $this->addTag($oxTag);
     }
     return $this->_isLoaded = true;
 }
Example #30
0
 /**
  * Loads article tags from DB. Returns true on success.
  *
  * @param string $sArticleId article id
  *
  * @return bool
  */
 public function load($sArticleId)
 {
     $this->setArticleId($sArticleId);
     $oDb = oxDb::getDb();
     $sViewName = getViewName("oxartextends", $this->getLanguage());
     $sQ = "select oxtags from {$sViewName} where oxid = " . $oDb->quote($sArticleId);
     $this->set("");
     // adding tags to list. Tags does not need to be checked again, but dashes needs to be removed
     $aTags = explode($this->get()->getSeparator(), $oDb->getOne($sQ));
     foreach ($aTags as $sTag) {
         $oTag = oxNew("oxtag");
         $oTag->set($sTag, false);
         $oTag->removeUnderscores();
         $this->addTag($oTag);
     }
     return $this->_isLoaded = true;
 }