roles_beuser.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',     'oxobject2role', 0, 0, 1 ),
00026                                         )
00027                     );
00031 class ajaxComponent extends ajaxListComponent
00032 {
00038     protected function _getQuery()
00039     {
00040         $myConfig = $this->getConfig();
00041 
00042         // looking for table/view
00043         $sUserTable = getViewName('oxuser');
00044 
00045         $sRoleId      = oxConfig::getParameter( 'oxid' );
00046         $sSynchRoleId = oxConfig::getParameter( 'synchoxid' );
00047 
00048         // category selected or not ?
00049         if ( !$sRoleId) {
00050             // dodger performance
00051             $sQAdd  = " from $sUserTable where 1 ";
00052             if (!$myConfig->getConfigParam( 'blMallUsers' ) )
00053                 $sSelect .= " and oxshopid = '".$myConfig->getShopId()."' ";
00054         } else {
00055             // selected group ?
00056             if ( $sSynchRoleId && $sSynchRoleId != $sRoleId ) {
00057                 $sQAdd  = " from oxobject2group inner join $sUserTable on $sUserTable.oxid = oxobject2group.oxobjectid ";
00058                 $sQAdd .= " where oxobject2group.oxgroupsid = '$sRoleId' ";
00059                 if (!$myConfig->getConfigParam( 'blMallUsers' ) )
00060                     $sQAdd .= " and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
00061             } else {
00062                 $sQAdd  = " from oxobject2role, $sUserTable where oxobject2role.oxtype = 'oxuser' and ";
00063                 $sQAdd .= " oxobject2role.oxroleid = '$sRoleId' and $sUserTable.oxid=oxobject2role.oxobjectid ";
00064             }
00065         }
00066 
00067         if ( $sSynchRoleId && $sSynchRoleId != $sRoleId) {
00068             // dodger performance
00069             $sQAdd .= " and $sUserTable.oxid not in ( select oxobject2role.oxobjectid  from oxobject2role where oxobject2role.oxtype = 'oxuser' and oxobject2role.oxroleid = '$sSynchRoleId' ) ";
00070         }
00071 
00072         return $sQAdd;
00073     }
00074 
00080     public function removeuserfromberoles()
00081     {
00082         $aRemoveGroups = $this->_getActionIds( 'oxobject2role.oxid' );
00083         if ( oxConfig::getParameter( 'all' ) ) {
00084 
00085             $sQ = $this->_addFilter( "delete oxobject2role.* ".$this->_getQuery() );
00086             oxDb::getDb()->Execute( $sQ );
00087 
00088         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00089             $sQ = "delete from oxobject2role where oxobject2role.oxid in ('" . implode( "', '", $aRemoveGroups ) . "') ";
00090             oxDb::getDb()->Execute( $sQ );
00091         }
00092     }
00093 
00099     public function addusertoberoles()
00100     {
00101         $aChosenUsr = $this->_getActionIds( 'oxuser.oxid' );
00102         $soxId      = oxConfig::getParameter( 'synchoxid' );
00103 
00104         if ( oxConfig::getParameter( 'all' ) ) {
00105             $sUserTable = getViewName('oxuser');
00106             $aChosenUsr = $this->_getAll( $this->_addFilter( "select $sUserTable.oxid ".$this->_getQuery() ) );
00107         }
00108         if ( $soxId && $soxId != "-1" && is_array( $aChosenUsr ) ) {
00109             foreach ( $aChosenUsr as $sChosenUsr) {
00110                 $oRiRo = oxNew( "oxbase" );
00111                 $oRiRo->init( "oxobject2role" );
00112                 $oRiRo->oxobject2role__oxobjectid = new oxField($sChosenUsr);
00113                 $oRiRo->oxobject2role__oxroleid   = new oxField($soxId);
00114                 $oRiRo->oxobject2role__oxtype     = new oxField("oxuser");
00115                 $oRiRo->save();
00116             }
00117         }
00118     }
00119 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5