Go to the documentation of this file.00001 <?php
00002
00006 class user_main_ajax extends ajaxListComponent
00007 {
00008
00014 protected $_aColumns = array('container1' => array(
00015 array('oxtitle', 'oxgroups', 1, 0, 0),
00016 array('oxid', 'oxgroups', 0, 0, 0),
00017 array('oxid', 'oxgroups', 0, 0, 1),
00018 ),
00019 'container2' => array(
00020 array('oxtitle', 'oxgroups', 1, 0, 0),
00021 array('oxid', 'oxgroups', 0, 0, 0),
00022 array('oxid', 'oxobject2group', 0, 0, 1),
00023 )
00024 );
00025
00031 protected function _getQuery()
00032 {
00033
00034 $sGroupTable = $this->_getViewName('oxgroups');
00035 $oDb = oxDb::getDb();
00036 $sDeldId = oxRegistry::getConfig()->getRequestParameter('oxid');
00037 $sSynchDelId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00038
00039
00040 if (!$sDeldId) {
00041 $sQAdd = " from $sGroupTable where 1 ";
00042 } else {
00043 $sQAdd = " from $sGroupTable left join oxobject2group on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
00044 $sQAdd .= " where oxobject2group.oxobjectid = " . $oDb->quote($sDeldId);
00045 }
00046
00047 if ($sSynchDelId && $sSynchDelId != $sDeldId) {
00048 $sQAdd .= " and $sGroupTable.oxid not in ( select $sGroupTable.oxid from $sGroupTable left join oxobject2group on oxobject2group.oxgroupsid=$sGroupTable.oxid ";
00049 $sQAdd .= " where oxobject2group.oxobjectid = " . $oDb->quote($sSynchDelId) . " ) ";
00050 }
00051
00052 return $sQAdd;
00053 }
00054
00058 public function removeUserFromGroup()
00059 {
00060 $aRemoveGroups = $this->_getActionIds('oxobject2group.oxid');
00061 if (oxRegistry::getConfig()->getRequestParameter('all')) {
00062
00063 $sQ = $this->_addFilter("delete oxobject2group.* " . $this->_getQuery());
00064 oxDb::getDb()->Execute($sQ);
00065
00066 } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00067 $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups)) . ") ";
00068 oxDb::getDb()->Execute($sQ);
00069 }
00070 }
00071
00075 public function addUserToGroup()
00076 {
00077 $aAddGroups = $this->_getActionIds('oxgroups.oxid');
00078 $soxId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00079
00080 if (oxRegistry::getConfig()->getRequestParameter('all')) {
00081 $sGroupTable = $this->_getViewName('oxgroups');
00082 $aAddGroups = $this->_getAll($this->_addFilter("select $sGroupTable.oxid " . $this->_getQuery()));
00083 }
00084 if ($soxId && $soxId != "-1" && is_array($aAddGroups)) {
00085 foreach ($aAddGroups as $sAddgroup) {
00086 $oNewGroup = oxNew("oxobject2group");
00087 $oNewGroup->oxobject2group__oxobjectid = new oxField($soxId);
00088 $oNewGroup->oxobject2group__oxgroupsid = new oxField($sAddgroup);
00089 $oNewGroup->save();
00090 }
00091 }
00092 }
00093 }