roles_begroups.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( 'oxid',     'oxgroups', 0, 0, 1 ),
00007                                         ),
00008                      'container2' => array(
00009                                         array( 'oxtitle',  'oxgroups', 1, 0, 0 ),
00010                                         array( 'oxid',     'oxgroups', 0, 0, 0 ),
00011                                         array( 'oxid',     'oxobject2role', 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         $sRoleId      = oxConfig::getParameter( 'oxid' );
00030         $sSynchRoleId = oxConfig::getParameter( 'synchoxid' );
00031 
00032         // category selected or not ?
00033         if ( !$sRoleId ) {
00034             $sQAdd  = " from $sGroupTable where 1 ";
00035         } else {
00036             $sQAdd  = " from oxobject2role, $sGroupTable where oxobject2role.oxtype = 'oxgroups' and ";
00037             $sQAdd .= " oxobject2role.oxroleid = '$sRoleId' and $sGroupTable.oxid=oxobject2role.oxobjectid ";
00038         }
00039 
00040         if ( $sSynchRoleId && $sSynchRoleId != $sRoleId ) {
00041             $sQAdd .= " and $sGroupTable.oxid not in ( ";
00042             $sQAdd .= " select oxobject2role.oxobjectid from oxobject2role where oxobject2role.oxtype = 'oxgroups' and ";
00043             $sQAdd .= " oxobject2role.oxroleid = '$sSynchRoleId' ) ";
00044         }
00045 
00046         return $sQAdd;
00047     }
00048 
00054     public function removegroupfromberoles()
00055     {
00056         $aRemoveGroups = $this->_getActionIds( 'oxobject2role.oxid' );
00057         if ( oxConfig::getParameter( 'all' ) ) {
00058 
00059             $sQ = $this->_addFilter( "delete oxobject2role.* ".$this->_getQuery() );
00060             oxDb::getDb()->Execute( $sQ );
00061 
00062         } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00063             $sQ = "delete from oxobject2role where oxobject2role.oxid in ('" . implode( "', '", $aRemoveGroups ) . "') ";
00064             oxDb::getDb()->Execute( $sQ );
00065         }
00066     }
00067 
00073     public function addgrouptoberoles()
00074     {
00075         $aChosenCat = $this->_getActionIds( 'oxgroups.oxid' );
00076         $soxId       = oxConfig::getParameter( 'synchoxid' );
00077         if ( oxConfig::getParameter( 'all' ) ) {
00078             $sGroupTable = getViewName('oxgroups');
00079             $aChosenCat = $this->_getAll( $this->_addFilter( "select $sGroupTable.oxid ".$this->_getQuery() ) );
00080         }
00081         if ( $soxId && $soxId != "-1" && is_array( $aChosenCat ) ) {
00082             foreach ( $aChosenCat as $sChosenCat) {
00083                 $oRiRo = oxNew( "oxbase" );
00084                 $oRiRo->init( "oxobject2role" );
00085                 $oRiRo->oxobject2role__oxobjectid = new oxField($sChosenCat);
00086                 $oRiRo->oxobject2role__oxroleid   = new oxField($soxId);
00087                 $oRiRo->oxobject2role__oxtype     = new oxField("oxgroups");
00088                 $oRiRo->save();
00089             }
00090         }
00091     }
00092 }

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