Go to the documentation of this file.00001 <?php
00002
00006 class actions_groups_ajax extends ajaxListComponent
00007 {
00008
00014 protected $_aColumns = array('container1' => array(
00015 array('oxtitle', 'oxgroups', 1, 0, 0),
00016 array('oxid', 'oxgroups', 0, 0, 0),
00017 array('oxid', 'oxgroups', 0, 0, 1),
00018 ),
00019 'container2' => array(
00020 array('oxtitle', 'oxgroups', 1, 0, 0),
00021 array('oxid', 'oxgroups', 0, 0, 0),
00022 array('oxid', 'oxobject2action', 0, 0, 1),
00023 )
00024 );
00025
00031 protected function _getQuery()
00032 {
00033
00034 $sGroupTable = $this->_getViewName('oxgroups');
00035 $oDb = oxDb::getDb();
00036
00037 $sId = oxRegistry::getConfig()->getRequestParameter('oxid');
00038 $sSynchId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00039
00040
00041 if (!$sId) {
00042 $sQAdd = " from {$sGroupTable} where 1 ";
00043 } else {
00044 $sQAdd .= " from oxobject2action, {$sGroupTable} where {$sGroupTable}.oxid=oxobject2action.oxobjectid " .
00045 " and oxobject2action.oxactionid = " . $oDb->quote($sId) .
00046 " and oxobject2action.oxclass = 'oxgroups' ";
00047 }
00048
00049 if ($sSynchId && $sSynchId != $sId) {
00050 $sQAdd .= " and {$sGroupTable}.oxid not in ( select {$sGroupTable}.oxid " .
00051 "from oxobject2action, {$sGroupTable} where $sGroupTable.oxid=oxobject2action.oxobjectid " .
00052 " and oxobject2action.oxactionid = " . $oDb->quote($sSynchId) .
00053 " and oxobject2action.oxclass = 'oxgroups' ) ";
00054 }
00055
00056 return $sQAdd;
00057 }
00058
00062 public function removePromotionGroup()
00063 {
00064 $aRemoveGroups = $this->_getActionIds('oxobject2action.oxid');
00065 if (oxRegistry::getConfig()->getRequestParameter('all')) {
00066 $sQ = $this->_addFilter("delete oxobject2action.* " . $this->_getQuery());
00067 oxDb::getDb()->Execute($sQ);
00068 } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00069 $sRemoveGroups = implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups));
00070 $sQ = "delete from oxobject2action where oxobject2action.oxid in (" . $sRemoveGroups . ") ";
00071 oxDb::getDb()->Execute($sQ);
00072 }
00073 }
00074
00078 public function addPromotionGroup()
00079 {
00080 $aChosenGroup = $this->_getActionIds('oxgroups.oxid');
00081 $soxId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00082
00083 if (oxRegistry::getConfig()->getRequestParameter('all')) {
00084 $sGroupTable = $this->_getViewName('oxgroups');
00085 $aChosenGroup = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
00086 }
00087 if ($soxId && $soxId != "-1" && is_array($aChosenGroup)) {
00088 foreach ($aChosenGroup as $sChosenGroup) {
00089 $oObject2Promotion = oxNew("oxbase");
00090 $oObject2Promotion->init('oxobject2action');
00091 $oObject2Promotion->oxobject2action__oxactionid = new oxField($soxId);
00092 $oObject2Promotion->oxobject2action__oxobjectid = new oxField($sChosenGroup);
00093 $oObject2Promotion->oxobject2action__oxclass = new oxField("oxgroups");
00094 $oObject2Promotion->save();
00095 }
00096 }
00097 }
00098 }