Go to the documentation of this file.00001 <?php
00002
00006 class actions_article_ajax extends ajaxListComponent
00007 {
00008
00014 protected $_blAllowExtColumns = true;
00015
00021 protected $_aColumns = array('container1' => array(
00022 array('oxartnum', 'oxarticles', 1, 0, 0),
00023 array('oxtitle', 'oxarticles', 1, 1, 0),
00024 array('oxean', 'oxarticles', 1, 0, 0),
00025 array('oxmpn', 'oxarticles', 0, 0, 0),
00026 array('oxprice', 'oxarticles', 0, 0, 0),
00027 array('oxstock', 'oxarticles', 0, 0, 0),
00028 array('oxid', 'oxarticles', 0, 0, 1)
00029 )
00030 );
00031
00037 protected function _getQuery()
00038 {
00039 $myConfig = $this->getConfig();
00040 $oDb = oxDb::getDb();
00041 $sArticleTable = $this->_getViewName('oxarticles');
00042 $sViewName = $this->_getViewName('oxobject2category');
00043
00044 $sSelId = oxRegistry::getConfig()->getRequestParameter('oxid');
00045 $sSynchSelId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00046
00047
00048 if (!$sSelId) {
00049 $sQAdd = " from $sArticleTable where 1 ";
00050 $sQAdd .= $myConfig->getConfigParam('blVariantsSelection') ? '' : " and $sArticleTable.oxparentid = '' ";
00051 } else {
00052
00053 if ($sSynchSelId) {
00054 $blVariantsSelectionParameter = $myConfig->getConfigParam('blVariantsSelection');
00055 $sSqlIfTrue = " ({$sArticleTable}.oxid=oxobject2category.oxobjectid " .
00056 "or {$sArticleTable}.oxparentid=oxobject2category.oxobjectid)";
00057 $sSqlIfFalse = " {$sArticleTable}.oxid=oxobject2category.oxobjectid ";
00058 $sVariantSelection = $blVariantsSelectionParameter ? $sSqlIfTrue : $sSqlIfFalse;
00059 $sQAdd = " from {$sViewName} as oxobject2category left join {$sArticleTable} on " . $sVariantSelection .
00060 " where oxobject2category.oxcatnid = " . $oDb->quote($sSelId) . " ";
00061 }
00062 }
00063
00064 $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00065
00066
00067 $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote($sSynchSelId) . " ";
00068
00069 return $sQAdd;
00070 }
00071
00079 protected function _addFilter($sQ)
00080 {
00081 $sArtTable = $this->_getViewName('oxarticles');
00082 $sQ = parent::_addFilter($sQ);
00083
00084
00085 $sQ .= $this->getConfig()->getConfigParam('blVariantsSelection') ? ' group by ' . $sArtTable . '.oxid ' : '';
00086
00087 return $sQ;
00088 }
00089
00093 public function removeActionArticle()
00094 {
00095 $sActionId = oxRegistry::getConfig()->getRequestParameter('oxid');
00096
00097
00098 $oDb = oxDb::getDb();
00099
00100 $oDb->Execute(
00101 'delete from oxobject2action '
00102 . 'where oxactionid=' . $oDb->quote($sActionId)
00103 . ' and oxclass = "oxarticle"'
00104 );
00105 }
00106
00110 public function setActionArticle()
00111 {
00112 $sArticleId = oxRegistry::getConfig()->getRequestParameter('oxarticleid');
00113 $sActionId = oxRegistry::getConfig()->getRequestParameter('oxid');
00114 $oDb = oxDb::getDb();
00115
00116 $oDb->Execute(
00117 'delete from oxobject2action '
00118 . 'where oxactionid=' . $oDb->quote($sActionId)
00119 . ' and oxclass = "oxarticle"'
00120 );
00121
00122 $oObject2Promotion = oxNew("oxbase");
00123 $oObject2Promotion->init('oxobject2action');
00124 $oObject2Promotion->oxobject2action__oxactionid = new oxField($sActionId);
00125 $oObject2Promotion->oxobject2action__oxobjectid = new oxField($sArticleId);
00126 $oObject2Promotion->oxobject2action__oxclass = new oxField("oxarticle");
00127 $oObject2Promotion->save();
00128 }
00129 }