article_rights_visible.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         $sGroupTable = getViewName('oxgroups');
00027 
00028         $sRRId = null;
00029         $iAction = 1;
00030 
00031         $sArtId      = oxConfig::getParameter( 'oxid' );
00032         $sSynchArtId = oxConfig::getParameter( 'synchoxid' );
00033 
00034         // category selected or not ?
00035         if ( !$sArtId ) {
00036             $sSelect  = " from $sGroupTable where 1 ";
00037         } else {
00038             // fetching article RR view index
00039             $sQAdd   = " from $sGroupTable, oxobjectrights where ";
00040             $sQAdd  .= " oxobjectrights.oxobjectid = '$sArtId' and ";
00041             $sQAdd  .= " oxobjectrights.oxoffset = ($sGroupTable.oxrrid div 31) and ";
00042             $sQAdd  .= " oxobjectrights.oxgroupidx & (1 << ($sGroupTable.oxrrid mod 31)) and oxobjectrights.oxaction = $iAction ";
00043         }
00044 
00045         if ( $sSynchArtId && $sSynchArtId != $sArtId ) {
00046             $sQAdd  = " from $sGroupTable left join oxobjectrights on  oxobjectrights.oxoffset = ( $sGroupTable.oxrrid div 31 ) and ";
00047             $sQAdd .= " oxobjectrights.oxgroupidx & (1 << ( $sGroupTable.oxrrid mod 31 ) ) and oxobjectrights.oxobjectid='$sSynchArtId' and oxobjectrights.oxaction = $iAction ";
00048             $sQAdd .= " where oxobjectrights.oxobjectid != '$sSynchArtId' or ( oxobjectid is null ) ";
00049         }
00050 
00051         return $sQAdd;
00052     }
00053 
00059     public function removegroupfromview()
00060     {
00061         $aGroups = $this->_getActionIds( 'oxgroups.oxrrid' );
00062         $soxId   = oxConfig::getParameter( 'oxid');
00063         $iAction = 1;
00064 
00065         // removing all
00066         if ( oxConfig::getParameter( 'all' ) ) {
00067             $sGroupTable = getViewName('oxgroups');
00068             $aGroups = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxrrid ".$this->_getQuery() ) );
00069         }
00070 
00071         if ( $soxId != "-1" && isset( $soxId) && is_array($aGroups) && count($aGroups)) {
00072             $aIndexes = array();
00073             foreach ($aGroups 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 article
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 
00102     public function addgrouptoview()
00103     {
00104         $aGroups = $this->_getActionIds( 'oxgroups.oxrrid' );
00105         $soxId   = oxConfig::getParameter( 'synchoxid');
00106         $iAction = 1;
00107 
00108         // adding
00109         if ( oxConfig::getParameter( 'all' ) ) {
00110             $sGroupTable = getViewName('oxgroups');
00111             $aGroups = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxrrid ".$this->_getQuery() ) );
00112         }
00113 
00114         if ( $soxId != "-1" && isset( $soxId) && is_array($aGroups) && count($aGroups)) {
00115             $aIndexes = array();
00116             foreach ($aGroups 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