_oModule->_oConfig->CNF; $this->_oPayment = BxDolPayments::getInstance(); $this->_iSeller = $this->_aGroupContentInfo[$CNF['FIELD_AUTHOR']]; $this->_iClient = bx_get_logged_profile_id(); $this->_iClientRole = $this->_oModule->getRole($this->_iGroupProfileId, $this->_iClient); $this->_bTypeSingle = $this->_oPayment->isAcceptingPayments($this->_iSeller, BX_PAYMENT_TYPE_SINGLE); $this->_bTypeRecurring = $this->_oPayment->isAcceptingPayments($this->_iSeller, BX_PAYMENT_TYPE_RECURRING); } public function performActionChoose() { $CNF = &$this->_oModule->_oConfig->CNF; $aIds = $this->_getIds(); if($aIds === false) return echoJson(array()); $aItem = $this->_oModule->_oDb->getPrices(array('type' => 'by_id', 'value' => $aIds[0])); if(!is_array($aItem) || empty($aItem) || (float)$aItem['price'] != 0) return echoJson(array()); $aResult = array(); if($this->_oModule->setRole($this->_iGroupProfileId, $this->_iClient, $aItem['role_id'], array('period' => $aItem['period'], 'period_unit' => $aItem['period_unit']))) $aResult = array('grid' => $this->getCode(false), 'blink' => $aItem['id'], 'msg' => _t($CNF['T']['msg_performed'])); else $aResult = array('msg' => _t($CNF['T']['err_cannot_perform'])); return echoJson($aResult); } public function getCode($isDisplayHeader = true) { return $this->_oPayment->getCartJs() . parent::getCode($isDisplayHeader); } protected function _getCellRoleId($mixedValue, $sKey, $aField, $aRow) { return parent::_getCellDefault($this->_aRoles[$mixedValue], $sKey, $aField, $aRow); } protected function _getActionChoose ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) { if((float)$aRow['price'] != 0 || $this->_oModule->getRole($this->_iGroupProfileId, $this->_iClient) === (int)$aRow['role_id']) return ''; return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow); } protected function _getActionBuy ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) { $CNF = &$this->_oModule->_oConfig->CNF; if((float)$aRow['price'] == 0 || !$this->_bTypeSingle || $this->_bTypeRecurring) return ''; $aJs = $this->_oPayment->getAddToCartJs($this->_iSeller, $this->_sModule, $aRow['id'], 1, true); if(!empty($aJs) && is_array($aJs)) { list($sJsCode, $sJsMethod) = $aJs; $a['attr'] = array( 'title' => bx_html_attribute(_t($CNF['T']['txt_buy_title'])), 'onclick' => $sJsMethod ); } return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow); } protected function _getActionSubscribe ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) { $CNF = &$this->_oModule->_oConfig->CNF; if((float)$aRow['price'] == 0 || !$this->_bTypeRecurring) return ''; $aJs = $this->_oPayment->getSubscribeJs($this->_iSeller, '', $this->_sModule, $aRow['id'], 1); if(!empty($aJs) && is_array($aJs)) { list($sJsCode, $sJsMethod) = $aJs; $a['attr'] = array( 'title' => bx_html_attribute(_t($CNF['T']['txt_subscribe_title'])), 'onclick' => $sJsMethod ); } return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow); } } /** @} */