00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
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', 'oxobject2group', 0, 0, 1 ),
00026 )
00027 );
00031 class ajaxComponent extends ajaxListComponent
00032 {
00038 protected function _getQuery()
00039 {
00040 $myConfig = $this->getConfig();
00041
00042
00043 $sUserTable = getViewName( 'oxuser' );
00044
00045 $sRoleId = oxConfig::getParameter( 'oxid' );
00046 $sSynchRoleId = oxConfig::getParameter( 'synchoxid' );
00047
00048
00049 if ( !$sRoleId ) {
00050 $sQAdd = " from $sUserTable where 1 ";
00051 } else {
00052 $sQAdd = " from $sUserTable, oxobject2group where $sUserTable.oxid=oxobject2group.oxobjectid and ";
00053 $sQAdd .= " oxobject2group.oxgroupsid = '$sRoleId' ";
00054 }
00055
00056 if ( $sSynchRoleId && $sSynchRoleId != $sRoleId) {
00057 $sQAdd .= " and $sUserTable.oxid not in ( select $sUserTable.oxid from $sUserTable, oxobject2group where $sUserTable.oxid=oxobject2group.oxobjectid and ";
00058 $sQAdd .= " oxobject2group.oxgroupsid = '$sSynchRoleId' ";
00059 if (!$myConfig->getConfigParam( 'blMallUsers' ) )
00060 $sQAdd .= " and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
00061 $sQAdd .= " ) ";
00062 }
00063
00064 if ( !$myConfig->getConfigParam( 'blMallUsers' ) )
00065 $sQAdd .= " and $sUserTable.oxshopid = '".$myConfig->getShopId()."' ";
00066
00067 return $sQAdd;
00068 }
00069
00075 public function removeuserfromugroup()
00076 {
00077 $aRemoveGroups = $this->_getActionIds( 'oxobject2group.oxid' );
00078
00079 if ( oxConfig::getParameter( 'all' ) ) {
00080
00081 $sQ = $this->_addFilter( "delete oxobject2group.* ".$this->_getQuery() );
00082 oxDb::getDb()->Execute( $sQ );
00083
00084 } elseif ( $aRemoveGroups && is_array( $aRemoveGroups ) ) {
00085 $sQ = "delete from oxobject2group where oxobject2group.oxid in ('" . implode( "', '", $aRemoveGroups ) . "') ";
00086 oxDb::getDb()->Execute( $sQ );
00087 }
00088 }
00089
00095 public function addusertougroup()
00096 {
00097 $aAddUsers = $this->_getActionIds( 'oxuser.oxid' );
00098 $soxId = oxConfig::getParameter( 'synchoxid' );
00099
00100 if ( oxConfig::getParameter( 'all' ) ) {
00101 $sUserTable = getViewName( 'oxuser' );
00102 $aAddUsers = $this->_getAll( $this->_addFilter( "select $sUserTable.oxid ".$this->_getQuery() ) );
00103 }
00104 if ( $soxId && $soxId != "-1" && is_array( $aAddUsers ) ) {
00105 foreach ($aAddUsers as $sAdduser) {
00106 $oNewGroup = oxNew( "oxobject2group" );
00107 $oNewGroup->oxobject2group__oxobjectid = new oxField($sAdduser);
00108 $oNewGroup->oxobject2group__oxgroupsid = new oxField($soxId);
00109 $oNewGroup->save();
00110 }
00111 }
00112 }
00113 }