Go to the documentation of this file.00001 <?php
00002
00006 class newsletter_selection_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', 'oxobject2group', 0, 0, 1),
00023 )
00024 );
00025
00031 protected function _getQuery()
00032 {
00033
00034 $sGroupTable = $this->_getViewName('oxgroups');
00035 $oDb = oxDb::getDb();
00036 $sDiscountId = $this->getConfig()->getRequestParameter('oxid');
00037 $sSynchDiscountId = $this->getConfig()->getRequestParameter('synchoxid');
00038
00039
00040 if (!$sDiscountId) {
00041 $sQAdd = " from $sGroupTable where 1 ";
00042 } else {
00043 $sQAdd = " from oxobject2group left join $sGroupTable on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
00044 $sQAdd .= " where oxobject2group.oxobjectid = " . $oDb->quote($sDiscountId);
00045 }
00046
00047 if ($sSynchDiscountId && $sSynchDiscountId != $sDiscountId) {
00048 $sQAdd .= " and $sGroupTable.oxid not in ( ";
00049 $sQAdd .= " select $sGroupTable.oxid from oxobject2group left join $sGroupTable on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
00050 $sQAdd .= " where oxobject2group.oxobjectid = " . $oDb->quote($sSynchDiscountId) . " ) ";
00051 }
00052
00053
00054 return $sQAdd;
00055 }
00056
00060 public function removeGroupFromNewsletter()
00061 {
00062 $aRemoveGroups = $this->_getActionIds('oxobject2group.oxid');
00063 if ($this->getConfig()->getRequestParameter('all')) {
00064
00065 $sQ = $this->_addFilter("delete oxobject2group.* " . $this->_getQuery());
00066 oxDb::getDb()->Execute($sQ);
00067
00068 } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00069 $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups)) . ") ";
00070 oxDb::getDb()->Execute($sQ);
00071 }
00072 }
00073
00077 public function addGroupToNewsletter()
00078 {
00079 $aAddGroups = $this->_getActionIds('oxgroups.oxid');
00080 $soxId = $this->getConfig()->getRequestParameter('synchoxid');
00081
00082 if ($this->getConfig()->getRequestParameter('all')) {
00083 $sGroupTable = $this->_getViewName('oxgroups');
00084 $aAddGroups = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
00085 }
00086 if ($soxId && $soxId != "-1" && is_array($aAddGroups)) {
00087 foreach ($aAddGroups as $sAddgroup) {
00088 $oNewGroup = oxNew("oxobject2group");
00089 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00090 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
00091 $oNewGroup->save();
00092 }
00093 }
00094 }
00095 }