roles_fegroups.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,  visible, multilanguage, ident
00004                                         array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00005                                         array( 'oxid',    'oxgroups', 0, 0, 0 ),
00006                                         array( 'oxrrid',  'oxgroups', 0, 0, 1 ),
00007                                         ),
00008                      'container2' => array(
00009                                         array( 'oxtitle', 'oxgroups', 1, 0, 0 ),
00010                                         array( 'oxid',    'oxgroups', 0, 0, 0 ),
00011                                         array( 'oxrrid',  'oxgroups', 0, 0, 1 ),
00012                                         )
00013                     );
00017 class ajaxComponent extends ajaxListComponent
00018 {
00024     protected function _getQuery()
00025     {
00026         // looking for table/view
00027         $sGroupTable = getViewName('oxgroups');
00028 
00029         $sId      = oxConfig::getParameter( 'oxid' );
00030         $sSynchId = oxConfig::getParameter( 'synchoxid' );
00031 
00032         $iAction = 1;
00033         // category selected or not ?
00034         if ( !$sId) {
00035             $sQAdd  = " from $sGroupTable where 1 ";
00036         } else {
00037             $sQAdd   = " from $sGroupTable, oxobjectrights where ";
00038             $sQAdd  .= " oxobjectrights.oxobjectid = '$sId' and ";
00039             $sQAdd  .= " oxobjectrights.oxoffset = ($sGroupTable.oxrrid div 31) and ";
00040             $sQAdd  .= " oxobjectrights.oxgroupidx & (1 << ($sGroupTable.oxrrid mod 31)) and oxobjectrights.oxaction = $iAction ";
00041         }
00042 
00043         if ( $sSynchId && $sSynchId != $sId) {
00044             $sQAdd   = " from $sGroupTable left join oxobjectrights on ";
00045             $sQAdd  .= " oxobjectrights.oxoffset = ($sGroupTable.oxrrid div 31) and ";
00046             $sQAdd  .= " oxobjectrights.oxgroupidx & (1 << ($sGroupTable.oxrrid mod 31)) and oxobjectrights.oxobjectid='$sSynchId' and oxobjectrights.oxaction = $iAction ";
00047             $sQAdd  .= " where oxobjectrights.oxobjectid != '$sSynchId' or (oxobjectid is null) ";
00048         }
00049 
00050         return $sQAdd;
00051     }
00052 
00058     public function removegroupfromferoles()
00059     {
00060         $aChosenGrp = $this->_getActionIds( 'oxgroups.oxrrid' );
00061         $soxId      = oxConfig::getParameter( 'oxid');
00062 
00063         $iAction    = 1;
00064 
00065         // removing all
00066         if ( oxConfig::getParameter( 'all' ) ) {
00067             $sGroupTable = getViewName('oxgroups');
00068             $aChosenGrp = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxrrid ".$this->_getQuery() ) );
00069         }
00070 
00071         if ( isset( $soxId) && $soxId != "-1" && is_array( $aChosenGrp ) && $aChosenGrp ) {
00072             $aIndexes = array();
00073             foreach ($aChosenGrp as $iRRIdx) {
00074                 $iOffset = ( int ) ( $iRRIdx / 31 );
00075                 $iBitMap = 1 << ( $iRRIdx % 31 );
00076 
00077                 // summing indexes
00078                 if ( !isset( $aIndexes[ $iOffset ] ) )
00079                     $aIndexes[ $iOffset ] = $iBitMap;
00080                 else
00081                     $aIndexes[ $iOffset ] = $aIndexes [ $iOffset ] | $iBitMap;
00082             }
00083 
00084             // iterating through indexes and applying to (sub)categories R&R
00085             foreach ( $aIndexes as $iOffset => $sIdx ) {
00086                 // processing category
00087                 $sQ  = "update oxobjectrights set oxgroupidx = oxgroupidx & ~$sIdx where oxobjectid = '$soxId' and oxoffset = $iOffset and oxaction = $iAction ";
00088                 oxDb::getDb()->Execute( $sQ );
00089             }
00090 
00091             // removing cleared
00092             $sQ = "delete from oxobjectrights where oxgroupidx = 0";
00093             oxDb::getDb()->Execute( $sQ );
00094 
00095         }
00096     }
00097 
00103     public function addgrouptoferoles()
00104     {
00105         $aChosenCat = $this->_getActionIds( 'oxgroups.oxrrid' );
00106         $soxId      = oxConfig::getParameter( 'synchoxid' );
00107 
00108         $iAction    = 1;
00109         if ( oxConfig::getParameter( 'all' ) ) {
00110             $sGroupTable = getViewName('oxgroups');
00111             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxrrid ".$this->_getQuery() ) );
00112         }
00113 
00114         if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenCat) && $aChosenCat) {
00115             $aIndexes = array();
00116             foreach ( $aChosenCat as $iRRIdx) {
00117                 $iOffset = ( int ) ( $iRRIdx / 31 );
00118                 $iBitMap = 1 << ( $iRRIdx % 31 );
00119 
00120                 // summing indexes
00121                 if ( !isset( $aIndexes[ $iOffset ] ) )
00122                     $aIndexes[ $iOffset ] = $iBitMap;
00123                 else
00124                     $aIndexes[ $iOffset ] = $aIndexes [ $iOffset ] | $iBitMap;
00125             }
00126 
00127             // iterating through indexes and applying to (sub)categories R&R
00128             foreach ( $aIndexes as $iOffset => $sIdx ) {
00129                 // processing category
00130                 $sQ  = "insert into oxobjectrights (oxid, oxobjectid, oxgroupidx, oxoffset, oxaction) ";
00131                 $sQ .= "values ('".oxUtilsObject::getInstance()->generateUID()."', '$soxId', $sIdx, $iOffset,  $iAction ) on duplicate key update oxgroupidx = (oxgroupidx | $sIdx ) ";
00132                 oxDb::getDb()->Execute( $sQ );
00133             }
00134         }
00135     }
00136 }

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