Info.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\User\Block\Role\Tab;
  7. /**
  8. * implementing now
  9. *
  10. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  11. */
  12. class Info extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
  13. {
  14. /**
  15. * Password input filed name
  16. */
  17. const IDENTITY_VERIFICATION_PASSWORD_FIELD = 'current_password';
  18. /**
  19. * @return \Magento\Framework\Phrase
  20. */
  21. public function getTabLabel()
  22. {
  23. return __('Role Info');
  24. }
  25. /**
  26. * @return string
  27. */
  28. public function getTabTitle()
  29. {
  30. return $this->getTabLabel();
  31. }
  32. /**
  33. * @return bool
  34. */
  35. public function canShowTab()
  36. {
  37. return true;
  38. }
  39. /**
  40. * @return bool
  41. */
  42. public function isHidden()
  43. {
  44. return false;
  45. }
  46. /**
  47. * @return $this
  48. */
  49. public function _beforeToHtml()
  50. {
  51. $this->_initForm();
  52. return parent::_beforeToHtml();
  53. }
  54. /**
  55. * @return void
  56. */
  57. protected function _initForm()
  58. {
  59. /** @var \Magento\Framework\Data\Form $form */
  60. $form = $this->_formFactory->create();
  61. $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Role Information')]);
  62. $fieldset->addField(
  63. 'role_name',
  64. 'text',
  65. [
  66. 'name' => 'rolename',
  67. 'label' => __('Role Name'),
  68. 'id' => 'role_name',
  69. 'class' => 'required-entry',
  70. 'required' => true
  71. ]
  72. );
  73. $fieldset->addField('role_id', 'hidden', ['name' => 'role_id', 'id' => 'role_id']);
  74. $fieldset->addField('in_role_user', 'hidden', ['name' => 'in_role_user', 'id' => 'in_role_userz']);
  75. $fieldset->addField('in_role_user_old', 'hidden', ['name' => 'in_role_user_old']);
  76. $verificationFieldset = $form->addFieldset(
  77. 'current_user_verification_fieldset',
  78. ['legend' => __('Current User Identity Verification')]
  79. );
  80. $verificationFieldset->addField(
  81. self::IDENTITY_VERIFICATION_PASSWORD_FIELD,
  82. 'password',
  83. [
  84. 'name' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD,
  85. 'label' => __('Your Password'),
  86. 'id' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD,
  87. 'title' => __('Your Password'),
  88. 'class' => 'input-text validate-current-password required-entry',
  89. 'required' => true
  90. ]
  91. );
  92. $data = ['in_role_user_old' => $this->getOldUsers()];
  93. if ($this->getRole() && is_array($this->getRole()->getData())) {
  94. $data = array_merge($this->getRole()->getData(), $data);
  95. }
  96. $form->setValues($data);
  97. $this->setForm($form);
  98. }
  99. /**
  100. * Get old Users Form Data
  101. *
  102. * @return null|string
  103. */
  104. protected function getOldUsers()
  105. {
  106. return $this->_coreRegistry->registry(
  107. \Magento\User\Controller\Adminhtml\User\Role\SaveRole::IN_ROLE_OLD_USER_FORM_DATA_SESSION_KEY
  108. );
  109. }
  110. }