payment_main_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class payment_main_ajax extends ajaxListComponent
00007 {
00008 
00014     protected $_aColumns = array('container1' => array( // field , table,  visible, multilanguage, ident
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         // looking for table/view
00034         $sGroupTable = $this->_getViewName('oxgroups');
00035         $sGroupId = $this->getConfig()->getRequestParameter('oxid');
00036         $sSynchGroupId = $this->getConfig()->getRequestParameter('synchoxid');
00037         $oDb = oxDb::getDb();
00038 
00039         // category selected or not ?
00040         if (!$sGroupId) {
00041             $sQAdd = " from {$sGroupTable} ";
00042         } else {
00043             $sQAdd = " from {$sGroupTable}, oxobject2group where ";
00044             $sQAdd .= " oxobject2group.oxobjectid = " . $oDb->quote($sGroupId) .
00045                       " and oxobject2group.oxgroupsid = {$sGroupTable}.oxid ";
00046         }
00047 
00048         if (!$sSynchGroupId) {
00049             $sSynchGroupId = $this->getConfig()->getRequestParameter('oxajax_synchfid');
00050         }
00051         if ($sSynchGroupId && $sSynchGroupId != $sGroupId) {
00052             if (!$sGroupId) {
00053                 $sQAdd .= 'where ';
00054             } else {
00055                 $sQAdd .= 'and ';
00056             }
00057             $sQAdd .= " {$sGroupTable}.oxid not in ( select {$sGroupTable}.oxid from {$sGroupTable}, oxobject2group " .
00058                       "where  oxobject2group.oxobjectid = " . $oDb->quote($sSynchGroupId) .
00059                       " and oxobject2group.oxgroupsid = $sGroupTable.oxid ) ";
00060         }
00061 
00062         return $sQAdd;
00063     }
00064 
00068     public function removePayGroup()
00069     {
00070         $aRemoveGroups = $this->_getActionIds('oxobject2group.oxid');
00071         if ($this->getConfig()->getRequestParameter('all')) {
00072 
00073             $sQ = $this->_addFilter("delete oxobject2group.* " . $this->_getQuery());
00074             oxDb::getDb()->Execute($sQ);
00075 
00076         } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00077             $sRemoveGroups = implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups));
00078             $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . $sRemoveGroups . ") ";
00079             oxDb::getDb()->Execute($sQ);
00080         }
00081     }
00082 
00086     public function addPayGroup()
00087     {
00088         $aAddGroups = $this->_getActionIds('oxgroups.oxid');
00089         $soxId = $this->getConfig()->getRequestParameter('synchoxid');
00090 
00091         if ($this->getConfig()->getRequestParameter('all')) {
00092             $sGroupTable = $this->_getViewName('oxgroups');
00093             $aAddGroups = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
00094         }
00095         if ($soxId && $soxId != "-1" && is_array($aAddGroups)) {
00096             foreach ($aAddGroups as $sAddgroup) {
00097                 $oNewGroup = oxNew("oxobject2group");
00098                 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00099                 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
00100                 $oNewGroup->save();
00101             }
00102         }
00103     }
00104 }