usergroup_main_ajax.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class usergroup_main_ajax extends ajaxListComponent
00007 {
00008 
00014     protected $_aColumns = array('container1' => array( // field , table,  visible, multilanguage, ident
00015         array('oxusername', 'oxuser', 1, 0, 0),
00016         array('oxlname', 'oxuser', 0, 0, 0),
00017         array('oxfname', 'oxuser', 0, 0, 0),
00018         array('oxstreet', 'oxuser', 0, 0, 0),
00019         array('oxstreetnr', 'oxuser', 0, 0, 0),
00020         array('oxcity', 'oxuser', 0, 0, 0),
00021         array('oxzip', 'oxuser', 0, 0, 0),
00022         array('oxfon', 'oxuser', 0, 0, 0),
00023         array('oxbirthdate', 'oxuser', 0, 0, 0),
00024         array('oxid', 'oxuser', 0, 0, 1),
00025     ),
00026                                  'container2' => array(
00027                                      array('oxusername', 'oxuser', 1, 0, 0),
00028                                      array('oxlname', 'oxuser', 0, 0, 0),
00029                                      array('oxfname', 'oxuser', 0, 0, 0),
00030                                      array('oxstreet', 'oxuser', 0, 0, 0),
00031                                      array('oxstreetnr', 'oxuser', 0, 0, 0),
00032                                      array('oxcity', 'oxuser', 0, 0, 0),
00033                                      array('oxzip', 'oxuser', 0, 0, 0),
00034                                      array('oxfon', 'oxuser', 0, 0, 0),
00035                                      array('oxbirthdate', 'oxuser', 0, 0, 0),
00036                                      array('oxid', 'oxobject2group', 0, 0, 1),
00037                                  )
00038     );
00039 
00045     protected function _getQuery()
00046     {
00047         $myConfig = $this->getConfig();
00048 
00049         // looking for table/view
00050         $sUserTable = $this->_getViewName('oxuser');
00051         $oDb = oxDb::getDb();
00052         $sRoleId = oxRegistry::getConfig()->getRequestParameter('oxid');
00053         $sSynchRoleId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00054 
00055         // category selected or not ?
00056         if (!$sRoleId) {
00057             $sQAdd = " from $sUserTable where 1 ";
00058         } else {
00059             $sQAdd = " from $sUserTable, oxobject2group where $sUserTable.oxid=oxobject2group.oxobjectid and ";
00060             $sQAdd .= " oxobject2group.oxgroupsid = " . $oDb->quote($sRoleId);
00061         }
00062 
00063         if ($sSynchRoleId && $sSynchRoleId != $sRoleId) {
00064             $sQAdd .= " and $sUserTable.oxid not in ( select $sUserTable.oxid from $sUserTable, oxobject2group where $sUserTable.oxid=oxobject2group.oxobjectid and ";
00065             $sQAdd .= " oxobject2group.oxgroupsid = " . $oDb->quote($sSynchRoleId);
00066             if (!$myConfig->getConfigParam('blMallUsers')) {
00067                 $sQAdd .= " and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
00068             }
00069             $sQAdd .= " ) ";
00070         }
00071 
00072         if (!$myConfig->getConfigParam('blMallUsers')) {
00073             $sQAdd .= " and $sUserTable.oxshopid = '" . $myConfig->getShopId() . "' ";
00074         }
00075 
00076         return $sQAdd;
00077     }
00078 
00082     public function removeUserFromUGroup()
00083     {
00084         $aRemoveGroups = $this->_getActionIds('oxobject2group.oxid');
00085 
00086         if (oxRegistry::getConfig()->getRequestParameter('all')) {
00087 
00088             $sQ = $this->_addFilter("delete oxobject2group.* " . $this->_getQuery());
00089             oxDb::getDb()->Execute($sQ);
00090 
00091         } elseif ($aRemoveGroups && is_array($aRemoveGroups)) {
00092             $sQ = "delete from oxobject2group where oxobject2group.oxid in (" . implode(", ", oxDb::getInstance()->quoteArray($aRemoveGroups)) . ") ";
00093             oxDb::getDb()->Execute($sQ);
00094         }
00095     }
00096 
00100     public function addUserToUGroup()
00101     {
00102         $aAddUsers = $this->_getActionIds('oxuser.oxid');
00103         $soxId = oxRegistry::getConfig()->getRequestParameter('synchoxid');
00104 
00105         if (oxRegistry::getConfig()->getRequestParameter('all')) {
00106             $sUserTable = $this->_getViewName('oxuser');
00107             $aAddUsers = $this->_getAll($this->_addFilter("select $sUserTable.oxid " . $this->_getQuery()));
00108         }
00109         if ($soxId && $soxId != "-1" && is_array($aAddUsers)) {
00110             foreach ($aAddUsers as $sAdduser) {
00111                 $oNewGroup = oxNew("oxobject2group");
00112                 $oNewGroup->oxobject2group__oxobjectid = new oxField($sAdduser);
00113                 $oNewGroup->oxobject2group__oxgroupsid = new oxField($soxId);
00114                 $oNewGroup->save();
00115             }
00116         }
00117     }
00118 }