Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to set backend locale per every admin user #3087

Merged
merged 7 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/code/core/Mage/Admin/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ public function login($username, $password, $request = null)
$this->setIsFirstPageAfterLogin(true);
$this->setUser($user);
$this->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
if ($backendLocale = $user->getBackendLocale()) {
Mage::getSingleton('adminhtml/session')->setLocale($backendLocale);
}

$alternativeUrl = $this->_getRequestUri($request);
$redirectUrl = $this->_urlPolicy->getRedirectUrl($user, $request, $alternativeUrl);
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<config>
<modules>
<Mage_Admin>
<version>1.6.1.4</version>
<version>1.6.1.5</version>
</Mage_Admin>
</modules>
<global>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* OpenMage
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* @category Mage
* @package Mage_Admin
* @copyright Copyright (c) 2023 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/** @var Mage_Core_Model_Resource_Setup $installer */
$installer = $this;
$installer->startSetup();

$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'backend_locale', 'varchar(8) NULL');

$installer->endSetup();
87 changes: 49 additions & 38 deletions app/code/core/Mage/Adminhtml/Block/System/Account/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,59 +40,70 @@ protected function _prepareForm()
$fieldset = $form->addFieldset('base_fieldset', ['legend' => Mage::helper('adminhtml')->__('Account Information')]);

$fieldset->addField('username', 'text', [
'name' => 'username',
'label' => Mage::helper('adminhtml')->__('User Name'),
'title' => Mage::helper('adminhtml')->__('User Name'),
'required' => true,
]);
'name' => 'username',
'label' => Mage::helper('adminhtml')->__('User Name'),
'title' => Mage::helper('adminhtml')->__('User Name'),
'required' => true,
]);

$fieldset->addField('firstname', 'text', [
'name' => 'firstname',
'label' => Mage::helper('adminhtml')->__('First Name'),
'title' => Mage::helper('adminhtml')->__('First Name'),
'required' => true,
]);
'name' => 'firstname',
'label' => Mage::helper('adminhtml')->__('First Name'),
'title' => Mage::helper('adminhtml')->__('First Name'),
'required' => true,
]);

$fieldset->addField('lastname', 'text', [
'name' => 'lastname',
'label' => Mage::helper('adminhtml')->__('Last Name'),
'title' => Mage::helper('adminhtml')->__('Last Name'),
'required' => true,
]);
'name' => 'lastname',
'label' => Mage::helper('adminhtml')->__('Last Name'),
'title' => Mage::helper('adminhtml')->__('Last Name'),
'required' => true,
]);

$fieldset->addField('user_id', 'hidden', [
'name' => 'user_id',
]);
'name' => 'user_id',
]);

$fieldset->addField('email', 'text', [
'name' => 'email',
'label' => Mage::helper('adminhtml')->__('Email'),
'title' => Mage::helper('adminhtml')->__('User Email'),
'required' => true,
]);
'name' => 'email',
'label' => Mage::helper('adminhtml')->__('Email'),
'title' => Mage::helper('adminhtml')->__('User Email'),
'required' => true,
]);

$fieldset->addField('current_password', 'obscure', [
'name' => 'current_password',
'label' => Mage::helper('adminhtml')->__('Current Admin Password'),
'title' => Mage::helper('adminhtml')->__('Current Admin Password'),
'required' => true,
]);
'name' => 'current_password',
'label' => Mage::helper('adminhtml')->__('Current Admin Password'),
'title' => Mage::helper('adminhtml')->__('Current Admin Password'),
'required' => true,
]);

$minAdminPasswordLength = Mage::getModel('admin/user')->getMinAdminPasswordLength();
$fieldset->addField('password', 'password', [
'name' => 'new_password',
'label' => Mage::helper('adminhtml')->__('New Password'),
'title' => Mage::helper('adminhtml')->__('New Password'),
'class' => 'input-text validate-admin-password min-admin-pass-length-' . $minAdminPasswordLength,
'note' => Mage::helper('adminhtml')
->__('Password must be at least of %d characters.', $minAdminPasswordLength),
]);
'name' => 'new_password',
'label' => Mage::helper('adminhtml')->__('New Password'),
'title' => Mage::helper('adminhtml')->__('New Password'),
'class' => 'input-text validate-admin-password min-admin-pass-length-' . $minAdminPasswordLength,
'note' => Mage::helper('adminhtml')
->__('Password must be at least of %d characters.', $minAdminPasswordLength),
]);

$fieldset->addField('confirmation', 'password', [
'name' => 'password_confirmation',
'label' => Mage::helper('adminhtml')->__('Password Confirmation'),
'class' => 'input-text validate-cpassword',
]);
'name' => 'password_confirmation',
'label' => Mage::helper('adminhtml')->__('Password Confirmation'),
'class' => 'input-text validate-cpassword',
]);

$locales = Mage::app()->getLocale()->getTranslatedOptionLocales();
$locales = array_column($locales, 'label', 'value');
array_unshift($locales, '');
$fieldset->addField('backend_locale', 'select', [
'name' => 'backend_locale',
'label' => Mage::helper('adminhtml')->__('Backend Locale'),
'class' => 'input-select',
'options' => $locales,
'required' => false,
]);

$form->setValues($user->getData());
$form->setAction($this->getUrl('*/system_account/save'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public function indexAction()
public function saveAction()
{
$userId = Mage::getSingleton('admin/session')->getUser()->getId();
$pwd = null;

$user = Mage::getModel("admin/user")->load($userId);

$user->setId($userId)
Expand All @@ -67,6 +65,10 @@ public function saveAction()
$user->setPasswordConfirmation($this->getRequest()->getParam('password_confirmation', false));
}

$backendLocale = $this->getRequest()->getParam('backend_locale', false);
$backendLocale = $backendLocale == 0 ? null : $backendLocale;
$user->setBackendLocale($backendLocale);

//Validate current admin password
$currentPassword = $this->getRequest()->getParam('current_password', null);
$this->getRequest()->setParam('current_password', null);
Expand Down
1 change: 1 addition & 0 deletions app/locale/en_US/Mage_Adminhtml.csv
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"BINARY","BINARY"
"Back","Back"
"Back to Login","Back to Login"
"Backend Locale","Backend Locale"
"Backup","Backup"
"Backup Name","Backup Name"
"Backup options","Backup options"
Expand Down