Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: elidrissidev/magento-api2basicauth
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.3
Choose a base ref
...
head repository: elidrissidev/magento-api2basicauth
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 2 commits
  • 10 files changed
  • 1 contributor

Commits on Sep 11, 2022

  1. Use short array syntax

    elidrissidev committed Sep 11, 2022
    Copy the full SHA
    b5fefa5 View commit details
  2. Copy the full SHA
    4763581 View commit details
Original file line number Diff line number Diff line change
@@ -19,11 +19,11 @@ class Elidrissidev_Api2BasicAuth_Block_Adminhtml_Restuser_Edit extends Mage_Admi
*/
protected function _prepareLayout()
{
$this->_addButton('save_and_continue', array(
$this->_addButton('save_and_continue', [
'label' => $this->__('Save and Continue Edit'),
'onclick' => 'editForm.submit(\''.$this->_getSaveAndContinueUrl().'\');',
'class' => 'save'
), 10);
], 10);

if (!Mage::getSingleton('admin/session')->isAllowed('system/api/rest_users/delete')) {
$this->_removeButton('delete');
@@ -38,10 +38,10 @@ protected function _prepareLayout()
*/
protected function _getSaveAndContinueUrl()
{
return $this->getUrl('*/*/save', array(
return $this->getUrl('*/*/save', [
'_current' => true,
'back' => 'edit'
));
]);
}

/**
Original file line number Diff line number Diff line change
@@ -17,13 +17,13 @@ protected function _prepareForm()
/** @var Elidrissidev_Api2BasicAuth_Model_Restuser $restuser */
$restuser = Mage::registry('current_restuser');

$params = $restuser->getId() ? array('id' => $restuser->getId()) : array();
$params = $restuser->getId() ? ['id' => $restuser->getId()] : [];

$form = new Varien_Data_Form(array(
$form = new Varien_Data_Form([
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', $params),
'method' => 'post'
));
]);
$form->setUseContainer(true);

$this->setForm($form);
Original file line number Diff line number Diff line change
@@ -26,62 +26,62 @@ protected function _prepareForm()

$form = new Varien_Data_Form;

$fieldset = $form->addFieldset('api2basicauth_restuser_general_form', array(
$fieldset = $form->addFieldset('api2basicauth_restuser_general_form', [
'legend' => $this->__('General')
));
]);

if ($restuser->getId()) {
$fieldset->addField('entity_id', 'hidden', array(
$fieldset->addField('entity_id', 'hidden', [
'name' => 'entity_id',
'value' => $restuser->getId()
));
]);
}

$fieldset->addField('username', 'text', array(
$fieldset->addField('username', 'text', [
'label' => $this->__('Username'),
'class' => 'required-entry validate-length maximum-length-40',
'name' => 'username',
'required' => true,
'value' => $restuser->getUsername()
));
$fieldset->addField('current_password', 'password', array(
]);
$fieldset->addField('current_password', 'password', [
'label' => Mage::helper('adminhtml')->__('Current Admin Password'),
'class' => 'required-entry',
'name' => 'current_password',
'required' => true
));
]);

if ($restuser->getId()) {
$fieldset->addField('new_api_key', 'password', array(
$fieldset->addField('new_api_key', 'password', [
'label' => $this->__('New Api Key'),
'class' => 'validate-length minimum-length-8',
'name' => 'new_api_key',
'note' => $this->__('Api Key must be at least %d characters long.', Elidrissidev_Api2BasicAuth_Model_Restuser::MIN_API_KEY_LENGTH),
'required' => false
));
]);
} else {
$fieldset->addField('api_key', 'password', array(
$fieldset->addField('api_key', 'password', [
'label' => $this->__('Api Key'),
'class' => 'validate-length minimum-length-8',
'name' => 'api_key',
'note' => $this->__('Api Key must be at least %d characters long.', Elidrissidev_Api2BasicAuth_Model_Restuser::MIN_API_KEY_LENGTH),
'required' => true
));
]);
}

$fieldset->addField('api_key_confirmation', 'password', array(
$fieldset->addField('api_key_confirmation', 'password', [
'label' => $this->__('Confirm Api Key'),
'class' => $restuser->getId() ? 'validate-cnew_api_key' : 'validate-capi_key',
'name' => 'api_key_confirmation',
'required' => !$restuser->getId()
));
$fieldset->addField('is_active', 'select', array(
]);
$fieldset->addField('is_active', 'select', [
'label' => $this->__('Active'),
'name' => 'is_active',
'options' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toArray(),
'value' => $restuser->getIsActive(),
'style' => 'width: 80px'
));
]);

$this->setForm($form);

Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ protected function _prepareCollection()
{
/** @var Mage_Api2_Model_Resource_Acl_Global_Role_Collection $collection */
$collection = Mage::getResourceModel('api2/acl_global_role_collection');
$collection->addFieldToFilter('entity_id', array('nin' => Mage_Api2_Model_Acl_Global_Role::getSystemRoles()));
$collection->addFieldToFilter('entity_id', ['nin' => Mage_Api2_Model_Acl_Global_Role::getSystemRoles()]);

$this->setCollection($collection);

@@ -43,20 +43,20 @@ protected function _prepareCollection()
*/
protected function _prepareColumns()
{
$this->addColumn('assigned_user_role', array(
$this->addColumn('assigned_user_role', [
'header_css_class' => 'a-center',
'header' => Mage::helper('api2')->__('Assigned'),
'type' => 'radio',
'html_name' => 'role_id',
'values' => array($this->_getSelectedRole()),
'values' => [$this->_getSelectedRole()],
'align' => 'center',
'index' => 'entity_id'
));
]);

$this->addColumn('role_name', array(
$this->addColumn('role_name', [
'header' => Mage::helper('api2')->__('Role Name'),
'index' => 'role_name'
));
]);

return parent::_prepareColumns();
}
@@ -75,7 +75,7 @@ protected function _addColumnFilterToCollection($column)
if ($column->getFilter()->getValue()) {
$collection->addFieldToFilter('entity_id', $roleId);
} elseif ($roleId) {
$collection->addFieldToFilter('entity_id', array('neq' => $roleId));
$collection->addFieldToFilter('entity_id', ['neq' => $roleId]);
}
} else {
parent::_addColumnFilterToCollection($column);
@@ -91,7 +91,7 @@ protected function _addColumnFilterToCollection($column)
*/
protected function _getSelectedRole()
{
if (is_null($this->_selectedRole)) {
if ($this->_selectedRole === null) {
$restuser = $this->_getRestuser();

if ($restuser->getId()) {
@@ -150,6 +150,6 @@ public function isHidden()
*/
public function getGridUrl()
{
return $this->getUrl('*/*/rolesGrid', array('_current' => true));
return $this->getUrl('*/*/rolesGrid', ['_current' => true]);
}
}
Original file line number Diff line number Diff line change
@@ -35,22 +35,22 @@ protected function _prepareCollection()
*/
protected function _prepareColumns()
{
$this->addColumn('entity_id', array(
$this->addColumn('entity_id', [
'header' => $this->__('ID'),
'index' => 'entity_id',
'type' => 'number',
'width' => '50px'
));
$this->addColumn('username', array(
]);
$this->addColumn('username', [
'header' => $this->__('Username'),
'index' => 'username'
));
$this->addColumn('is_active', array(
]);
$this->addColumn('is_active', [
'header' => $this->__('Active'),
'index' => 'is_active',
'type' => 'options',
'options' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toArray()
));
]);

return parent::_prepareColumns();
}
@@ -64,7 +64,7 @@ public function getRowUrl($item)
if (!Mage::getSingleton('admin/session')->isAllowed('system/api/rest_users/edit')) {
return '';
}
return $this->getUrl('*/*/edit', array('id' => $item->getId()));
return $this->getUrl('*/*/edit', ['id' => $item->getId()]);
}

/**
Original file line number Diff line number Diff line change
@@ -45,9 +45,9 @@ public function saveRoleRelation($restuserId, $roleId)
$write = $this->_getWriteAdapter();

if ($read->fetchOne($select) === false) {
$write->insert($table, array('restuser_id' => $restuserId, 'role_id' => $roleId));
$write->insert($table, ['restuser_id' => $restuserId, 'role_id' => $roleId]);
} else {
$write->update($table, array('role_id' => $roleId), array('restuser_id = ?' => $restuserId));
$write->update($table, ['role_id' => $roleId], ['restuser_id = ?' => $restuserId]);
}

return $this;
@@ -90,8 +90,8 @@ public function getRole($restuserId)
$collection = Mage::getResourceModel('api2/acl_global_role_collection');
$collection->getSelect()
->joinInner(
array('acl_restuser' => $this->getTable('elidrissidev_api2basicauth/acl_restuser')),
'main_table.entity_id = acl_restuser.role_id',
['acl_restuser' => $this->getTable('elidrissidev_api2basicauth/acl_restuser')],
'main_table.entity_id = acl_restuser.role_id'
)
->where('acl_restuser.restuser_id = ?', $restuserId, Zend_Db::INT_TYPE);

Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ public function saveRoleRelation()
*/
public function validate()
{
$errors = array();
$errors = [];

if (!Zend_Validate::is($this->getUsername(), 'NotEmpty')) {
$errors[] = $this->_getHelper()->__('Username is required.');
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ public function saveAction()
}

if ($id) {
$this->_redirect('*/*/edit', array('id' => $id));
$this->_redirect('*/*/edit', ['id' => $id]);
} else {
$this->_redirect('*/*/new');
}
@@ -139,20 +139,20 @@ public function saveAction()
$this->_getSession()->addSuccess($this->__('The user has been saved.'));

if ($back) {
$this->_redirect('*/*/edit', array('id' => $restuser->getId()));
$this->_redirect('*/*/edit', ['id' => $restuser->getId()]);
} else {
$this->_redirect('*/*/');
}
} catch (Mage_Core_Exception $e) {
$this->_getSession()->setRestuserData($postData);
$this->_getSession()->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $id));
$this->_redirect('*/*/edit', ['id' => $id]);
return;
} catch (Exception $e) {
Mage::logException($e);
$this->_getSession()->setRestuserData($postData);
$this->_getSession()->addError($this->__('An error occurred while saving user.'));
$this->_redirect('*/*/edit', array('id' => $id));
$this->_redirect('*/*/edit', ['id' => $id]);
return;
}
}
@@ -192,12 +192,12 @@ public function deleteAction()
$this->_getSession()->addSuccess($this->__('The user has been deleted.'));
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $id));
$this->_redirect('*/*/edit', ['id' => $id]);
return;
} catch (Exception $e) {
Mage::logException($e);
$this->_getSession()->addError($this->__('An error occurred while saving user.'));
$this->_redirect('*/*/edit', array('id' => $id));
$this->_redirect('*/*/edit', ['id' => $id]);
return;
}

Loading