/** * 'add' action handler */ public function performActionAdd() { $oModule = BxDolModule::getInstance('bx_oauth'); bx_import('FormAdd', $oModule->_aModule); $oForm = new BxOAuthFormAdd($oModule); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { // if form is submitted and all fields are valid $iNewId = $oForm->insert(array(), true); // insert record to database if ($iNewId) { $aRes = array('grid' => $this->getCode(false), 'blink' => $iNewId); } else { $aRes = array('msg' => "Error occured"); } // if record adding failed, display error message $this->_echoResultJson($aRes, true); } else { // if form is not submitted or some fields are invalid, display popup with form // we need to use 'transBox' function to properly display 'popup' $s = BxTemplFunctions::getInstance()->transBox('', ' <div class="bx-def-padding bx-def-color-bg-block">' . $oForm->getCode() . '</div> <script> $(document).ready(function () { $("#bx-oauth-add").ajaxForm({ dataType: "json", beforeSubmit: function (formData, jqForm, options) { bx_loading($("#' . $oForm->aFormAttrs['id'] . '"), true); }, success: function (data) { $(".bx-popup-active").dolPopupHide(); glGrids.' . $this->_sObject . '.processJson(data, "add"); } }); }); </script>'); $this->_echoResultJson(array('popup' => array('html' => $s, 'options' => array('closeOnOuterClick' => false))), true); } }
function actionAdministration() { if (!$this->isAdmin()) { $this->_oTemplate->displayAccessDenied(); return; } $this->_oTemplate->pageStart(); bx_import('FormAdd', $this->_aModule); $oForm = new BxOAuthFormAdd($this); $oForm->initChecker(); $sContent = ''; if ($oForm->isSubmittedAndValid()) { $oForm->insert(); $sContent = MsgBox(_t('_Success')); } $sContent .= $oForm->getCode(); $aVars = array('content' => $sContent); echo $this->_oTemplate->adminBlock($this->_oTemplate->parseHtmlByName('default_padding', $aVars), _t('_bx_oauth_add')); if (is_array($_POST['clients']) && $_POST['clients']) { $this->_oDb->deleteClients($_POST['clients']); } bx_import('BxTemplSearchResult'); $sControls = BxTemplSearchResult::showAdminActionsPanel('bx-oauth-form-add', array('bx-oauth-delete' => _t('_Delete')), 'clients'); $aClients = $this->_oDb->getClients(); $aVars = array('bx_repeat:clients' => $aClients, 'controls' => $sControls); echo $this->_oTemplate->adminBlock($this->_oTemplate->parseHtmlByName('clients', $aVars), _t('_bx_oauth_clients')); $aVars = array('content' => _t('_bx_oauth_help_text', BX_DOL_URL_ROOT)); echo $this->_oTemplate->adminBlock($this->_oTemplate->parseHtmlByName('default_padding', $aVars), _t('_bx_oauth_help')); $this->_oTemplate->addCssAdmin('forms_adv.css'); $this->_oTemplate->pageCodeAdmin(_t('_bx_oauth_administration')); }