public function performActionShowTo()
 {
     $sAction = 'show_to';
     $aItem = $this->_getItem('getItems');
     if ($aItem === false) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-nav-item-create', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&set=' . $this->sSet, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_menu_items', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $aItem['id'], 'db' => array('pass' => 'Int')), 'visible_for' => array('type' => 'select', 'name' => 'visible_for', 'caption' => _t('_adm_nav_txt_items_visible_for'), 'info' => '', 'value' => $aItem['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 'values' => array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_nav_txt_items_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_nav_txt_items_visible_for_selected'))), 'required' => '0', 'attrs' => array('onchange' => $this->getJsObject() . '.onChangeVisibleFor(this)'), 'db' => array('pass' => 'Xss')), 'visible_for_levels' => array('type' => 'checkbox_set', 'name' => 'visible_for_levels', 'caption' => _t('_adm_nav_txt_items_visible_for_levels'), 'info' => _t('_adm_nav_dsc_items_visible_for_levels'), 'value' => '', 'values' => array(), 'tr_attrs' => array('style' => $aItem['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''), 'db' => array('pass' => 'Int')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_nav_btn_items_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_nav_btn_items_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     BxDolStudioUtils::getVisibilityValues($aItem['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->updateWithVisibility($aItem['id']) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $aItem['id']);
         } else {
             $aRes = array('msg' => _t('_adm_nav_err_items_show_to'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-nav-item-hide-from-popup', _t('_adm_nav_txt_items_show_to_popup', _t($aItem['title'])), $this->_oTemplate->parseHtmlByName('nav_add_item.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => $sContent), true);
     }
 }
 protected function getSettingsVisibility($aPage = array(), $bCreate = true, $bInputsOnly = false)
 {
     $iVisibleForLevels = isset($aPage['visible_for_levels']) ? (int) $aPage['visible_for_levels'] : BX_DOL_INT_MAX;
     if (isset($aPage['visible_for_levels_editable']) && (int) $aPage['visible_for_levels_editable'] == 0) {
         $aInputs = array('visible_for_levels' => array('type' => 'custom', 'name' => 'visible_for_levels', 'content' => MsgBox(_t('_adm_bp_err_page_visible_for_levels'))));
     } else {
         $aInputs = array('visible_for' => array('type' => 'select', 'name' => 'visible_for', 'caption' => _t('_adm_bp_txt_block_visible_for'), 'info' => '', 'value' => $iVisibleForLevels == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 'values' => array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_bp_txt_block_visible_for_selected'))), 'required' => '0', 'attrs' => array('onchange' => $this->getPageJsObject() . '.onChangeVisibleFor(this)'), 'db' => array('pass' => 'Xss')), 'visible_for_levels' => array('type' => 'checkbox_set', 'name' => 'visible_for_levels', 'caption' => _t('_adm_bp_txt_page_visible_for_levels'), 'info' => _t('_adm_bp_dsc_page_visible_for_levels'), 'value' => '', 'values' => array(), 'tr_attrs' => array('style' => $iVisibleForLevels == BX_DOL_INT_MAX ? 'display:none' : ''), 'db' => array('pass' => 'Int')));
     }
     $aForm = array('form_attrs' => array('id' => 'adm-bp-settings-visibility'), 'params' => array('remove_form' => '1', 'csrf' => array('disable' => true)), 'inputs' => $aInputs);
     BxDolStudioUtils::getVisibilityValues($iVisibleForLevels, $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
     if ($bInputsOnly) {
         return $aForm['inputs'];
     }
     $oForm = new BxTemplStudioFormView($aForm);
     return $oForm->getCode();
 }
 protected function onLoadBlock(&$oForm, &$aBlock)
 {
     $oForm->aFormAttrs['action'] = sprintf($this->sPageUrl, $this->sType, $this->sPage) . '&bp_action=' . $this->sActionBlockEdit;
     $oForm->aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_bp_txt_select_module')), BxDolStudioUtils::getModules());
     $aDBoxes = array();
     $this->oDb->getDesignBoxes(array('type' => 'ordered'), $aDBoxes, false);
     foreach ($aDBoxes as $aDBox) {
         $oForm->aInputs['designbox_id']['values'][] = array('key' => $this->sSelectKeyPrefix . $aDBox['id'], 'value' => _t($aDBox['title']));
     }
     $oForm->aInputs['visible_for']['value'] = $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED;
     $oForm->aInputs['visible_for']['values'] = array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_bx_dev_bp_txt_block_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_bx_dev_bp_txt_block_visible_for_selected')));
     $oForm->aInputs['visible_for']['attrs']['onchange'] = $this->getPageJsObject() . '.onChangeVisibleFor(this)';
     $oForm->aInputs['visible_for_levels']['tr_attrs']['style'] = $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : '';
     BxDolStudioUtils::getVisibilityValues($aBlock['visible_for_levels'], $oForm->aInputs['visible_for_levels']['values'], $oForm->aInputs['visible_for_levels']['value']);
     $aBlock['visible_for_levels'] = $oForm->aInputs['visible_for_levels']['value'];
     $oForm->aInputs = $this->addInArray($oForm->aInputs, 'visible_for_levels', $this->getBlockContent($aBlock));
     $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_bp_btn_block_save');
     $oForm->aInputs['controls'][2]['attrs']['onclick'] = $this->getPageJsObject() . ".deleteBlock(" . $aBlock['id'] . ")";
     if ($aBlock['type'] == BX_DOL_STUDIO_BP_BLOCK_SERVICE) {
         $aBlock['content'] = BxDevFunctions::unserializeString($aBlock['content']);
     }
     if ((int) $aBlock['designbox_id'] != 0) {
         $aBlock['designbox_id'] = $this->sSelectKeyPrefix . $aBlock['designbox_id'];
     }
 }
 public function performActionShowTo()
 {
     $sAction = 'show_to';
     $aIds = bx_get('ids');
     if (!$aIds || !is_array($aIds)) {
         $iId = (int) bx_get('id');
         if (!$iId) {
             $this->_echoResultJson(array());
             exit;
         }
         $aIds = array($iId);
     }
     $iId = $aIds[0];
     $aField = array();
     $this->oDb->getInputs(array('type' => 'by_object_id', 'object' => $this->sObject, 'id' => (int) $iId), $aField, false);
     if (empty($aField) || !is_array($aField)) {
         $this->_echoResultJson(array());
         exit;
     }
     $aForm = array('form_attrs' => array('id' => 'adm-form-field-visibility', 'action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&object=' . $this->sObject . '&display=' . $this->sDisplay, 'method' => 'post'), 'params' => array('db' => array('table' => 'sys_form_display_inputs', 'key' => 'id', 'uri' => '', 'uri_title' => '', 'submit_name' => 'do_submit')), 'inputs' => array('id' => array('type' => 'hidden', 'name' => 'id', 'value' => $iId, 'db' => array('pass' => 'Int')), 'visible_for' => array('type' => 'select', 'name' => 'visible_for', 'caption' => _t('_adm_form_txt_field_visible_for'), 'info' => '', 'value' => $aField['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 'values' => array(array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_form_txt_field_visible_for_all')), array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_form_txt_field_visible_for_selected'))), 'required' => '0', 'attrs' => array('onchange' => $this->getJsObject() . '.onChangeVisibleFor(this)'), 'db' => array('pass' => 'Xss')), 'visible_for_levels' => array('type' => 'checkbox_set', 'name' => 'visible_for_levels', 'caption' => _t('_adm_form_txt_field_visible_for_levels'), 'info' => _t('_adm_form_dsc_field_visible_for_levels'), 'value' => '', 'values' => array(), 'tr_attrs' => array('style' => $aField['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : ''), 'db' => array('pass' => 'Int')), 'controls' => array('name' => 'controls', 'type' => 'input_set', array('type' => 'submit', 'name' => 'do_submit', 'value' => _t('_adm_form_btn_field_save')), array('type' => 'reset', 'name' => 'close', 'value' => _t('_adm_form_btn_field_cancel'), 'attrs' => array('onclick' => "\$('.bx-popup-applied:visible').dolPopupHide()", 'class' => 'bx-def-margin-sec-left')))));
     BxDolStudioUtils::getVisibilityValues($aField['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']);
     bx_import('BxTemplStudioFormView');
     $oForm = new BxTemplStudioFormView($aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         if ($oForm->updateWithVisibility($iId) !== false) {
             $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
         } else {
             $aRes = array('msg' => _t('_adm_form_err_field_show_to'));
         }
         $this->_echoResultJson($aRes, true);
     } else {
         bx_import('BxTemplStudioFunctions');
         $sContent = BxTemplStudioFunctions::getInstance()->popupBox('adm-form-field-show-to-popup', _t('_adm_form_txt_field_show_to_popup', _t($aField['caption_system'])), $this->_oTemplate->parseHtmlByName('form_add_field.html', array('form_id' => $aForm['form_attrs']['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction)));
         $this->_echoResultJson(array('popup' => $sContent), true);
     }
 }