deliveryset_users.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,  visible, multilanguage, ident
00004                                         array( 'oxusername',  'oxuser', 1, 0, 0 ),
00005                                         array( 'oxlname',     'oxuser', 0, 0, 0 ),
00006                                         array( 'oxfname',     'oxuser', 0, 0, 0 ),
00007                                         array( 'oxstreet',    'oxuser', 0, 0, 0 ),
00008                                         array( 'oxstreetnr',  'oxuser', 0, 0, 0 ),
00009                                         array( 'oxcity',      'oxuser', 0, 0, 0 ),
00010                                         array( 'oxzip',       'oxuser', 0, 0, 0 ),
00011                                         array( 'oxfon',       'oxuser', 0, 0, 0 ),
00012                                         array( 'oxbirthdate', 'oxuser', 0, 0, 0 ),
00013                                         array( 'oxid',        'oxuser', 0, 0, 1 ),
00014                                         ),
00015                      'container2' => array(
00016                                         array( 'oxusername',  'oxuser', 1, 0, 0 ),
00017                                         array( 'oxlname',     'oxuser', 0, 0, 0 ),
00018                                         array( 'oxfname',     'oxuser', 0, 0, 0 ),
00019                                         array( 'oxstreet',    'oxuser', 0, 0, 0 ),
00020                                         array( 'oxstreetnr',  'oxuser', 0, 0, 0 ),
00021                                         array( 'oxcity',      'oxuser', 0, 0, 0 ),
00022                                         array( 'oxzip',       'oxuser', 0, 0, 0 ),
00023                                         array( 'oxfon',       'oxuser', 0, 0, 0 ),
00024                                         array( 'oxbirthdate', 'oxuser', 0, 0, 0 ),
00025                                         array( 'oxid',     'oxobject2delivery', 0, 0, 1 ),
00026                                         )
00027                     );
00031 class ajaxComponent extends ajaxListComponent
00032 {
00038     protected function _getQuery()
00039     {
00040         $myConfig = $this->getConfig();
00041 
00042         $sId      = oxConfig::getParameter( 'oxid' );
00043         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00044 
00045         $sUserTable = getViewName('oxuser');
00046 
00047         // category selected or not ?
00048         if ( !$sId) {
00049             $sQAdd  = " from $sUserTable where 1 ";
00050             if (!$myConfig->getConfigParam( 'blMallUsers' ) )
00051                 $sQAdd .= "and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
00052         } else {
00053             // selected group ?
00054             if ( $sSynchId && $sSynchId != $sId ) {
00055                 $sQAdd  = " from oxobject2group left join $sUserTable on $sUserTable.oxid = oxobject2group.oxobjectid ";
00056                 $sQAdd .= " where oxobject2group.oxgroupsid = '$sId' ";
00057                 if (!$myConfig->getConfigParam( 'blMallUsers' ) )
00058                     $sQAdd .= "and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
00059 
00060                 // resetting
00061                 $sId = null;
00062             } else {
00063                 $sQAdd  = " from oxobject2delivery, $sUserTable where oxobject2delivery.oxdeliveryid = '$sId' ";
00064                 $sQAdd .= "and oxobject2delivery.oxobjectid = $sUserTable.oxid and oxobject2delivery.oxtype = 'oxdelsetu' ";
00065             }
00066         }
00067 
00068         if ( $sSynchId && $sSynchId != $sId) {
00069             $sQAdd .= "and $sUserTable.oxid not in ( select $sUserTable.oxid from oxobject2delivery, $sUserTable where oxobject2delivery.oxdeliveryid = '$sSynchId' ";
00070             $sQAdd .= "and oxobject2delivery.oxobjectid = $sUserTable.oxid and oxobject2delivery.oxtype = 'oxdelsetu' ) ";
00071         }
00072 
00073         return $sQAdd;
00074     }
00075 
00081     public function removeuserfromset()
00082     {
00083         $aRemoveGroups = $this->_getActionIds( 'oxobject2delivery.oxid' );
00084         if ( oxConfig::getParameter( 'all' ) ) {
00085 
00086             $sQ = $this->_addFilter( "delete oxobject2delivery.* ".$this->_getQuery() );
00087             oxDb::getDb()->Execute( $sQ );
00088 
00089         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00090             $sQ = "delete from oxobject2delivery where oxobject2delivery.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aRemoveGroups ) ) . ") ";
00091             oxDb::getDb()->Execute( $sQ );
00092         }
00093     }
00094 
00100     public function addusertoset()
00101     {
00102         $aChosenUsr = $this->_getActionIds( 'oxuser.oxid' );
00103         $soxId      = oxConfig::getParameter( 'synchoxid' );
00104 
00105         // adding
00106         if ( oxConfig::getParameter( 'all' ) ) {
00107             $sUserTable = getViewName('oxuser');
00108             $aChosenUsr = $this->_getAll( $this->_addFilter( "select $sUserTable.oxid ".$this->_getQuery() ) );
00109         }
00110         if ( $soxId && $soxId != "-1" && is_array( $aChosenUsr ) ) {
00111             foreach ( $aChosenUsr as $sChosenUsr) {
00112                 $oObject2Delivery = oxNew( 'oxbase' );
00113                 $oObject2Delivery->init( 'oxobject2delivery' );
00114                 $oObject2Delivery->oxobject2delivery__oxdeliveryid = new oxField($soxId);
00115                 $oObject2Delivery->oxobject2delivery__oxobjectid   = new oxField($sChosenUsr);
00116                 $oObject2Delivery->oxobject2delivery__oxtype       = new oxField("oxdelsetu");
00117                 $oObject2Delivery->save();
00118             }
00119         }
00120     }
00121 
00122 }