|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Venustheme |
| 4 | + * |
| 5 | + * NOTICE OF LICENSE |
| 6 | + * |
| 7 | + * This source file is subject to the Venustheme.com license that is |
| 8 | + * available through the world-wide-web at this URL: |
| 9 | + * http://www.venustheme.com/license-agreement.html |
| 10 | + * |
| 11 | + * DISCLAIMER |
| 12 | + * |
| 13 | + * Do not edit or add to this file if you wish to upgrade this extension to newer |
| 14 | + * version in the future. |
| 15 | + * |
| 16 | + * @category Venustheme |
| 17 | + * @package Lof_ChatSystem |
| 18 | + * @copyright Copyright (c) 2018 Venustheme (http://www.venustheme.com/) |
| 19 | + * @license http://www.venustheme.com/LICENSE-1.0.html |
| 20 | + */ |
| 21 | +namespace Lof\ChatSystem\Block\Adminhtml\Chat\Edit\Tab; |
| 22 | + |
| 23 | + |
| 24 | +use Magento\Framework\UrlInterface; |
| 25 | +/** |
| 26 | + * @SuppressWarnings(PHPMD.DepthOfInheritance) |
| 27 | + */ |
| 28 | +class Blacklist extends \Magento\Backend\Block\Widget\Form\Generic implements |
| 29 | + \Magento\Backend\Block\Widget\Tab\TabInterface |
| 30 | +{ |
| 31 | + |
| 32 | + /** |
| 33 | + * @var UrlInterface |
| 34 | + */ |
| 35 | + protected $urlBuilder; |
| 36 | + |
| 37 | + protected $order; |
| 38 | + |
| 39 | + protected $orderRepository; |
| 40 | + /** |
| 41 | + * @param \Magento\Backend\Block\Template\Context $context |
| 42 | + * @param \Magento\Framework\Registry $registry |
| 43 | + * @param \Magento\Framework\Data\FormFactory $formFactory |
| 44 | + * @param \Magento\Theme\Model\Layout\Source\Layout $pageLayout |
| 45 | + * @param \Magento\Framework\View\Customer Information\Theme\LabelFactory $labelFactory |
| 46 | + * @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder |
| 47 | + * @param array $data |
| 48 | + */ |
| 49 | + public function __construct( |
| 50 | + \Magento\Backend\Block\Template\Context $context, |
| 51 | + \Magento\Framework\Registry $registry, |
| 52 | + UrlInterface $urlBuilder, |
| 53 | + \Magento\Sales\Model\Order $order, |
| 54 | + \Magento\Framework\Data\FormFactory $formFactory, |
| 55 | + \Magento\Sales\Api\OrderRepositoryInterface $orderRepository, |
| 56 | + array $data = [] |
| 57 | + ) { |
| 58 | + $this->orderRepository = $orderRepository; |
| 59 | + $this->order = $order; |
| 60 | + $this->urlBuilder = $urlBuilder; |
| 61 | + parent::__construct($context, $registry, $formFactory, $data); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Prepare form tab configuration |
| 66 | + * |
| 67 | + * @return void |
| 68 | + */ |
| 69 | + protected function _construct() |
| 70 | + { |
| 71 | + parent::_construct(); |
| 72 | + $this->setShowGlobalIcon(true); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Initialise form fields |
| 77 | + * |
| 78 | + * @return $this |
| 79 | + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) |
| 80 | + */ |
| 81 | + protected function _prepareForm() |
| 82 | + { |
| 83 | + /* |
| 84 | + * Checking if user have permissions to save information |
| 85 | + */ |
| 86 | + $isElementDisabled = !$this->_isAllowedAction('Lof_ChatSystem::chat_edit'); |
| 87 | + /** @var \Magento\Framework\Data\Form $form */ |
| 88 | + $form = $this->_formFactory->create(['data' => ['html_id_prefix' => 'chat_']]); |
| 89 | + |
| 90 | + $model = $this->_coreRegistry->registry('lofchatsystem_chat'); |
| 91 | + |
| 92 | + $fieldset = $form->addFieldset( |
| 93 | + 'base_fieldset', |
| 94 | + ['legend' => __('Blacklist'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled] |
| 95 | + ); |
| 96 | + $fieldset->addField( |
| 97 | + 'customer_id', |
| 98 | + 'text', |
| 99 | + [ |
| 100 | + 'name' => 'customer_id', |
| 101 | + 'label' => __('Customer Id'), |
| 102 | + 'required' => false, |
| 103 | + 'title' => __('Customer Id') |
| 104 | + ] |
| 105 | + ); |
| 106 | + $fieldset->addField( |
| 107 | + 'ip', |
| 108 | + 'text', |
| 109 | + [ |
| 110 | + 'name' => 'ip', |
| 111 | + 'label' => __('IP address'), |
| 112 | + 'title' => __('IP address'), |
| 113 | + 'required' => false, |
| 114 | + 'class' => 'ip' |
| 115 | + ] |
| 116 | + ); |
| 117 | + $fieldset->addField( |
| 118 | + 'customer_email', |
| 119 | + 'text', |
| 120 | + [ |
| 121 | + 'name' => 'customer_email', |
| 122 | + 'label' => __('Customer Email'), |
| 123 | + 'title' => __('Customer Email') |
| 124 | + ] |
| 125 | + ); |
| 126 | + $form->setValues($model->getData()); |
| 127 | + |
| 128 | + $this->setForm($form); |
| 129 | + |
| 130 | + return parent::_prepareForm(); |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Prepare label for tab |
| 135 | + * |
| 136 | + * @return \Magento\Framework\Phrase |
| 137 | + */ |
| 138 | + public function getTabLabel() |
| 139 | + { |
| 140 | + return __('Blacklist Information'); |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Prepare title for tab |
| 145 | + * |
| 146 | + * @return \Magento\Framework\Phrase |
| 147 | + */ |
| 148 | + public function getTabTitle() |
| 149 | + { |
| 150 | + return __('Blacklist Information'); |
| 151 | + } |
| 152 | + |
| 153 | + /** |
| 154 | + * {@inheritdoc} |
| 155 | + */ |
| 156 | + public function canShowTab() |
| 157 | + { |
| 158 | + return true; |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * {@inheritdoc} |
| 163 | + */ |
| 164 | + public function isHidden() |
| 165 | + { |
| 166 | + return false; |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Check permission for passed action |
| 171 | + * |
| 172 | + * @param string $resourceId |
| 173 | + * @return bool |
| 174 | + */ |
| 175 | + protected function _isAllowedAction($resourceId) |
| 176 | + { |
| 177 | + return $this->_authorization->isAllowed($resourceId); |
| 178 | + } |
| 179 | +} |
0 commit comments