| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * CC-BY License - http://creativecommons.org/licenses/by/3.0/
- *
- * @defgroup BaseProfile Base classes for profile modules
- * @ingroup DolphinModules
- *
- * @{
- */
- bx_import('BxBaseModGeneralGridAdministration');
- class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministration
- {
- protected $_sFilter1Name;
- protected $_sFilter1Value;
- protected $_aFilter1Values;
- public function __construct ($aOptions, $oTemplate = false)
- {
- parent::__construct ($aOptions, $oTemplate);
- $CNF = &$this->_oModule->_oConfig->CNF;
- $this->_sFilter1Name = 'filter1';
- $this->_aFilter1Values = array(
- 'active' => $CNF['T']['filter_item_active'],
- 'pending' => $CNF['T']['filter_item_pending'],
- 'suspended' => $CNF['T']['filter_item_suspended'],
- );
- $sFilter1 = bx_get($this->_sFilter1Name);
- if(!empty($sFilter1)) {
- $this->_sFilter1Value = bx_process_input($sFilter1);
- $this->_aQueryAppend[$this->_sFilter1Name] = $this->_sFilter1Value;
- }
- }
- public function performActionSetAclLevel()
- {
- bx_import('BxDolMenu');
- $oMenu = BxDolMenu::getObjectInstance('sys_set_acl_level');
- $aIds = bx_get('ids');
- if(!$aIds || !is_array($aIds) || !$oMenu) {
- $this->_echoResultJson(array());
- return;
- }
- $aIdsResult = array();
- foreach($aIds as $iId) {
- $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
- if($this->_oModule->checkAllowedSetMembership($aContentInfo) !== CHECK_ACTION_RESULT_ALLOWED)
- continue;
- $aIdsResult[] = $this->_getProfileId($iId);
- }
- if(empty($aIdsResult)) {
- $this->_echoResultJson(array());
- return;
- }
- if(count($aIdsResult) == 1)
- $aIdsResult = $aIdsResult[0];
- $sContent = $this->_oTemplate->parseHtmlByName('bx_div.html', array(
- 'bx_repeat:attrs' => array(
- array('key' => 'class', 'value' => 'bx-def-padding')
- ),
- 'content' => $oMenu->getCode($aIdsResult)
- ));
- bx_import('BxTemplFunctions');
- $sContent = BxTemplFunctions::getInstance()->transBox($this->_oModule->_oConfig->getName() . 'set_acl_level_popup', $sContent);
- $this->_echoResultJson(array('popup' => $sContent), true);
- }
- public function performActionDeleteWithContent()
- {
- $this->performActionDelete(array('with_content' => true));
- }
- protected function _switcherChecked2State($isChecked)
- {
- return $isChecked ? 'active' : 'suspended';
- }
- protected function _switcherState2Checked($mixedState)
- {
- return 'active' == $mixedState ? true : false;
- }
- protected function _enable ($mixedId, $isChecked)
- {
- $iAction = BX_PROFILE_ACTION_MANUAL;
- $oProfile = $this->_getProfileObject($mixedId);
- return $isChecked ? $oProfile->activate($iAction) : $oProfile->suspend($iAction);
- }
- protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
- {
- if(strpos($sFilter, $this->_sParamsDivider) !== false)
- list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter);
- if(!empty($this->_sFilter1Value))
- $this->_aOptions['source'] .= $this->_oModule->_oDb->prepare(" AND `tp`.`status`=?", $this->_sFilter1Value);
- return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
- }
- //--- Layout methods ---//
- protected function _getFilterControls()
- {
- parent::_getFilterControls();
- return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) . $this->_getSearchInput();
- }
- protected function _getCellFullname($mixedValue, $sKey, $aField, $aRow)
- {
- $oProfile = $this->_getProfileObject($aRow['id']);
- $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
- 'href' => $oProfile->getUrl(),
- 'title' => $mixedValue,
- 'bx_repeat:attrs' => array(),
- 'content' => $mixedValue
- ));
- return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
- }
- protected function _getCellLastOnline($mixedValue, $sKey, $aField, $aRow)
- {
- return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
- }
- protected function _getProfileObject($iId)
- {
- bx_import('BxDolProfile');
- $oProfile = BxDolProfile::getInstanceByContentAndType((int)$iId, $this->_oModule->_oConfig->getName());
- if (!$oProfile) {
- bx_import('BxDolProfileUndefined');
- $oProfile = BxDolProfileUndefined::getInstance();
- }
- return $oProfile;
- }
- protected function _getProfileId($iId)
- {
- return $this->_getProfileObject($iId)->id();
- }
- protected function _onDelete($iId, $aParams = array())
- {
- if(isset($aParams['with_content']) && $aParams['with_content'] === true) {
- //TODO: delete content after profile deletion
- }
- return parent::_onDelete($iId, $aParams);
- }
-
- }
- /** @} */
|