00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
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 = 2;
00030
00031 $sArtId = oxConfig::getParameter( 'oxid' );
00032 $sSynchArtId = oxConfig::getParameter( 'synchoxid' );
00033
00034
00035 if ( !$sArtId) {
00036 $sQAdd = " from $sGroupTable where 1 ";
00037 } else {
00038
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 = 2;
00064
00065
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
00078 if ( !isset( $aIndexes[ $iOffset ] ) )
00079 $aIndexes[ $iOffset ] = $iBitMap;
00080 else
00081 $aIndexes[ $iOffset ] = $aIndexes [ $iOffset ] | $iBitMap;
00082 }
00083
00084
00085 foreach ( $aIndexes as $iOffset => $sIdx ) {
00086
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
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 = 2;
00107
00108
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
00121 if ( !isset( $aIndexes[ $iOffset ] ) )
00122 $aIndexes[ $iOffset ] = $iBitMap;
00123 else
00124 $aIndexes[ $iOffset ] = $aIndexes [ $iOffset ] | $iBitMap;
00125 }
00126
00127
00128 foreach ( $aIndexes as $iOffset => $sIdx ) {
00129
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 }