|
|
@@ -42,53 +42,48 @@ class BxInvGridInvites extends BxTemplGrid
|
|
|
}
|
|
|
$this->_sParamsDivider = '#-#';
|
|
|
}
|
|
|
-
|
|
|
- protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
|
|
|
+
|
|
|
+ public function getFormCallBackUrlAPI($sAction, $iId = 0)
|
|
|
{
|
|
|
- $CNF = $this->_oModule->_oConfig->CNF;
|
|
|
- $sTableInvites = $CNF['TABLE_INVITES'];
|
|
|
-
|
|
|
- if(strpos($sFilter, $this->_sParamsDivider) !== false)
|
|
|
- list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter);
|
|
|
-
|
|
|
- $sFilterSql = "";
|
|
|
- if(isset($this->_sFilter1Value) && $this->_sFilter1Value != ''){
|
|
|
- if ($this->_sFilter1Value == BX_INV_FILTER_STATUS_ACCEPTED){
|
|
|
- $sFilterSql = " AND " . $sTableInvites . ".`joined_account_id` IS NOT NULL";
|
|
|
- }
|
|
|
- else{
|
|
|
- $sFilterSql = " AND " . $sTableInvites . ".`joined_account_id` IS NULL";
|
|
|
- }
|
|
|
- }
|
|
|
- $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString($sFilterSql);
|
|
|
- return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
|
|
|
+ return '/api.php?r=system/perfom_action_api/TemplServiceGrid/¶ms[]=&o=' . $this->_sObject . '&a=' . $sAction;
|
|
|
}
|
|
|
|
|
|
public function performActionAdd()
|
|
|
{
|
|
|
$sAction = 'add';
|
|
|
+
|
|
|
$oForm = $this->_oModule->getFormObjectInvite();
|
|
|
- if (!$oForm)
|
|
|
- return '';
|
|
|
+ if(!$oForm)
|
|
|
+ return $this->_getActionResult([]);
|
|
|
|
|
|
$oForm->aInputs['text']['value'] = _t('_bx_invites_msg_invitation');
|
|
|
$oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?' . bx_encode_url_params($_GET, array('ids', '_r'));
|
|
|
$oForm->initChecker();
|
|
|
-
|
|
|
+
|
|
|
+ $aResult = [];
|
|
|
if($oForm->isSubmittedAndValid()) {
|
|
|
$sResult = $this->_oModule->processFormObjectInvite($oForm);
|
|
|
- $aRes = array('msg' => $sResult);
|
|
|
- echoJson($aRes);
|
|
|
+ if($this->_bIsApi)
|
|
|
+ $aResult = [bx_api_get_msg($sResult)];
|
|
|
+ else
|
|
|
+ $aResult = ['msg' => $sResult];
|
|
|
}
|
|
|
else {
|
|
|
- $sContent = BxTemplFunctions::getInstance()->popupBox('_bx_invites_form_invite', _t('_bx_invites_form_invite'), $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
|
|
|
- 'form_id' => $oForm->id,
|
|
|
- 'form' => $oForm->getCode(true),
|
|
|
- 'object' => $this->_sObject,
|
|
|
- 'action' => $sAction
|
|
|
- )));
|
|
|
- echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => true))));
|
|
|
+ if($this->_bIsApi)
|
|
|
+ $aResult = $this->getFormBlockAPI($oForm, $sAction);
|
|
|
+ else
|
|
|
+ $aResult = ['popup' => [
|
|
|
+ 'html' => BxTemplFunctions::getInstance()->popupBox('_bx_invites_form_invite', _t('_bx_invites_form_invite'), $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
|
|
|
+ 'form_id' => $oForm->id,
|
|
|
+ 'form' => $oForm->getCode(true),
|
|
|
+ 'object' => $this->_sObject,
|
|
|
+ 'action' => $sAction
|
|
|
+ ))),
|
|
|
+ 'options' => ['closeOnOuterClick' => true]
|
|
|
+ ]];
|
|
|
}
|
|
|
+
|
|
|
+ return $this->_getActionResult($aResult);
|
|
|
}
|
|
|
|
|
|
public function performActionDelete($aParams = array())
|
|
|
@@ -173,62 +168,83 @@ class BxInvGridInvites extends BxTemplGrid
|
|
|
|
|
|
protected function _getCellDate($mixedValue, $sKey, $aField, $aRow)
|
|
|
{
|
|
|
+ if($this->_bIsApi)
|
|
|
+ return ['type' => 'time', 'data' => $mixedValue];
|
|
|
+
|
|
|
return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
|
|
|
}
|
|
|
|
|
|
protected function _getCellDateSeen($mixedValue, $sKey, $aField, $aRow)
|
|
|
{
|
|
|
- if ($mixedValue == 'undefined')
|
|
|
+ if($this->_bIsApi)
|
|
|
+ return ['type' => 'time', 'data' => (int)$mixedValue];
|
|
|
+
|
|
|
+ if($mixedValue == 'undefined')
|
|
|
return parent::_getCellDefault('', $sKey, $aField, $aRow);
|
|
|
+
|
|
|
return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
|
|
|
}
|
|
|
|
|
|
protected function _getCellDateJoined($mixedValue, $sKey, $aField, $aRow)
|
|
|
{
|
|
|
- if ($mixedValue == 'undefined')
|
|
|
+ if($this->_bIsApi)
|
|
|
+ return ['type' => 'time', 'data' => (int)$mixedValue];
|
|
|
+
|
|
|
+ if($mixedValue == 'undefined')
|
|
|
return parent::_getCellDefault('', $sKey, $aField, $aRow);
|
|
|
+
|
|
|
return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
|
|
|
}
|
|
|
|
|
|
protected function _getCellWhoSend($mixedValue, $sKey, $aField, $aRow)
|
|
|
{
|
|
|
- $oProfile = BxDolProfile::getInstanceMagic($aRow['profile_id']);
|
|
|
- if ($oProfile)
|
|
|
+ if(($oProfile = BxDolProfile::getInstanceMagic($aRow['profile_id'])) !== false) {
|
|
|
+ if ($this->_bIsApi)
|
|
|
+ return ['type' => 'profile', 'data' => BxDolProfile::getData($aRow['profile_id'])];
|
|
|
+
|
|
|
return $this->_getProfileCell($oProfile, $sKey, $aField, $aRow);
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
return parent::_getCellDefault('', $sKey, $aField, $aRow);
|
|
|
}
|
|
|
|
|
|
protected function _getCellJoinedAccount($mixedValue, $sKey, $aField, $aRow)
|
|
|
{
|
|
|
- if ($aRow['joined_account_id'] == '')
|
|
|
- return parent::_getCellDefault('', $sKey, $aField, $aRow);
|
|
|
-
|
|
|
- $oProfile = BxDolProfile::getInstanceAccountProfile($aRow['joined_account_id']);
|
|
|
- if ($oProfile)
|
|
|
+ if(($iAccountId = (int)$aRow['joined_account_id']) != 0 && ($oProfile = BxDolProfile::getInstanceAccountProfile($iAccountId)) !== false) {
|
|
|
+ if($this->_bIsApi)
|
|
|
+ return ['type' => 'profile', 'data' => BxDolProfile::getData($oProfile)];
|
|
|
+
|
|
|
return $this->_getProfileCell($oProfile, $sKey, $aField, $aRow);
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
return parent::_getCellDefault('', $sKey, $aField, $aRow);
|
|
|
}
|
|
|
|
|
|
protected function _getCellRequest($mixedValue, $sKey, $aField, $aRow)
|
|
|
{
|
|
|
- if ($aRow['request_id'] == '')
|
|
|
+ $CNF = &$this->_oModule->_oConfig->CNF;
|
|
|
+
|
|
|
+ if($aRow['request_id'] == '')
|
|
|
return parent::_getCellDefault('', $sKey, $aField, $aRow);
|
|
|
|
|
|
- $aRequest = $this->_oModule->_oDb->getRequests(array('type' => 'by_id', 'value' => $aRow['request_id']));
|
|
|
- if ($aRequest || true){
|
|
|
- $CNF = &$this->_oModule->_oConfig->CNF;
|
|
|
- $sLink = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($CNF['URL_REQUESTS']));
|
|
|
- $sLink = bx_append_url_params($sLink, array('filter' => $aRequest['email']));
|
|
|
- $sAddon = $this->_oTemplate->parseHtmlByName('account_link.html', array(
|
|
|
- 'href' => $sLink,
|
|
|
- 'title' => _t('_bx_invites_grid_txt_view_request'),
|
|
|
- 'content' => _t('_bx_invites_grid_txt_view_request'),
|
|
|
- 'class' => ''
|
|
|
- ));
|
|
|
+ $aRequest = $this->_oModule->_oDb->getRequests(['type' => 'by_id', 'value' => $aRow['request_id']]);
|
|
|
+ if(!empty($aRequest) && is_array($aRequest)) {
|
|
|
+ $sTitle = _t('_bx_invites_grid_txt_view_request');
|
|
|
+ $sLink = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($CNF['URL_REQUESTS'], ['filter' => $aRequest['email']]));
|
|
|
+
|
|
|
+ if($this->_bIsApi)
|
|
|
+ return ['type' => 'link', 'data' => ['url' => bx_api_get_relative_url($sLink), 'text' => $sTitle]];
|
|
|
+
|
|
|
+ $sAddon = $this->_oTemplate->parseHtmlByName('account_link.html', [
|
|
|
+ 'href' => $sLink,
|
|
|
+ 'title' => bx_html_attribute($sTitle),
|
|
|
+ 'content' => $sTitle,
|
|
|
+ 'class' => ''
|
|
|
+ ]);
|
|
|
+
|
|
|
return parent::_getCellDefault($sAddon, $sKey, $aField, $aRow);
|
|
|
}
|
|
|
+
|
|
|
return parent::_getCellDefault('', $sKey, $aField, $aRow);
|
|
|
}
|
|
|
|
|
|
@@ -263,20 +279,41 @@ class BxInvGridInvites extends BxTemplGrid
|
|
|
{
|
|
|
$sModuleAccounts = 'bx_accounts';
|
|
|
if(!BxDolModuleQuery::getInstance()->isEnabledByName($sModuleAccounts))
|
|
|
- return '';
|
|
|
+ return '';
|
|
|
+
|
|
|
+ $oModuleAccounts = BxDolModule::getInstance($sModuleAccounts);
|
|
|
+ if(!$oModuleAccounts || empty($oModuleAccounts->_oConfig->CNF['URL_MANAGE_ADMINISTRATION']))
|
|
|
+ return 'cccc';
|
|
|
|
|
|
- $oModuleAccounts = BxDolModule::getInstance($sModuleAccounts);
|
|
|
- if(!$oModuleAccounts || empty($oModuleAccounts->_oConfig->CNF['URL_MANAGE_ADMINISTRATION']))
|
|
|
- return 'cccc';
|
|
|
+ $sLink = $oModuleAccounts->_oConfig->CNF['URL_MANAGE_ADMINISTRATION'];
|
|
|
|
|
|
- $sLink = $oModuleAccounts->_oConfig->CNF['URL_MANAGE_ADMINISTRATION'];
|
|
|
+ $sLink = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($sLink));
|
|
|
|
|
|
- $sLink = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($sLink));
|
|
|
-
|
|
|
- if(!empty($sFilter))
|
|
|
- $sLink = bx_append_url_params($sLink, array('filter' => $sFilter));
|
|
|
+ if(!empty($sFilter))
|
|
|
+ $sLink = bx_append_url_params($sLink, array('filter' => $sFilter));
|
|
|
|
|
|
- return $sLink;
|
|
|
+ return $sLink;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
|
|
|
+ {
|
|
|
+ $CNF = $this->_oModule->_oConfig->CNF;
|
|
|
+ $sTableInvites = $CNF['TABLE_INVITES'];
|
|
|
+
|
|
|
+ if(strpos($sFilter, $this->_sParamsDivider) !== false)
|
|
|
+ list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter);
|
|
|
+
|
|
|
+ $sFilterSql = "";
|
|
|
+ if(isset($this->_sFilter1Value) && $this->_sFilter1Value != ''){
|
|
|
+ if ($this->_sFilter1Value == BX_INV_FILTER_STATUS_ACCEPTED){
|
|
|
+ $sFilterSql = " AND " . $sTableInvites . ".`joined_account_id` IS NOT NULL";
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ $sFilterSql = " AND " . $sTableInvites . ".`joined_account_id` IS NULL";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString($sFilterSql);
|
|
|
+ return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
|
|
|
}
|
|
|
}
|
|
|
|