Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #50 from damian-pastorini/magento-1.9.0.1
Browse files Browse the repository at this point in the history
Magento 1.9.0.1
  • Loading branch information
Aleksey Razbakov authored Dec 5, 2016
2 parents e0d217c + 4d961a2 commit 40c941d
Show file tree
Hide file tree
Showing 170 changed files with 7,947 additions and 1,816 deletions.
34 changes: 24 additions & 10 deletions app/code/core/Mage/Admin/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
class Mage_Admin_Model_Observer
{
const FLAG_NO_LOGIN = 'no-login';

/**
* Handler for controller_action_predispatch event
*
Expand All @@ -42,16 +43,14 @@ class Mage_Admin_Model_Observer
*/
public function actionPreDispatchAdmin($observer)
{
$session = Mage::getSingleton('admin/session');
/** @var $session Mage_Admin_Model_Session */
$session = Mage::getSingleton('admin/session');

/**
* @var $request Mage_Core_Controller_Request_Http
*/
/** @var $request Mage_Core_Controller_Request_Http */
$request = Mage::app()->getRequest();
$user = $session->getUser();

$requestedActionName = $request->getActionName();
$requestedActionName = strtolower($request->getActionName());
$openActions = array(
'forgotpassword',
'resetpassword',
Expand All @@ -67,11 +66,26 @@ public function actionPreDispatchAdmin($observer)
}
if (!$user || !$user->getId()) {
if ($request->getPost('login')) {
$postLogin = $request->getPost('login');
$username = isset($postLogin['username']) ? $postLogin['username'] : '';
$password = isset($postLogin['password']) ? $postLogin['password'] : '';
$session->login($username, $password, $request);
$request->setPost('login', null);

/** @var Mage_Core_Model_Session $coreSession */
$coreSession = Mage::getSingleton('core/session');

if ($coreSession->validateFormKey($request->getPost("form_key"))) {
$postLogin = $request->getPost('login');
$username = isset($postLogin['username']) ? $postLogin['username'] : '';
$password = isset($postLogin['password']) ? $postLogin['password'] : '';
$session->login($username, $password, $request);
$request->setPost('login', null);
} else {
if ($request && !$request->getParam('messageSent')) {
Mage::getSingleton('adminhtml/session')->addError(
Mage::helper('adminhtml')->__('Invalid Form Key. Please refresh the page.')
);
$request->setParam('messageSent', true);
}
}

$coreSession->renewFormKey();
}
if (!$request->getInternallyForwarded()) {
$request->setInternallyForwarded();
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Admin/Model/Redirectpolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function getRedirectUrl(Mage_Admin_Model_User $user, Zend_Controller_Requ
if (empty($request)) {
return;
}
$countRequiredParams = $this->_urlModel->useSecretKey() ? 1 : 0;
$countRequiredParams = ($this->_urlModel->useSecretKey()
&& $request->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME)) ? 1 : 0;
$countGetParams = count($request->getUserParams()) + count($request->getQuery());

return ($countGetParams > $countRequiredParams) ?
Expand Down
24 changes: 19 additions & 5 deletions app/code/core/Mage/Admin/Model/Resource/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $user)
*/
protected function _afterSave(Mage_Core_Model_Abstract $user)
{
$user->setExtra(unserialize($user->getExtra()));
$this->_unserializeExtraData($user);
return $this;
}

Expand All @@ -189,10 +189,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $user)
*/
protected function _afterLoad(Mage_Core_Model_Abstract $user)
{
if (is_string($user->getExtra())) {
$user->setExtra(unserialize($user->getExtra()));
}
return parent::_afterLoad($user);
return parent::_afterLoad($this->_unserializeExtraData($user));
}

/**
Expand Down Expand Up @@ -459,4 +456,21 @@ public function saveExtra($object, $data)

return $this;
}

/**
* Unserializes user extra data
*
* @param Mage_Core_Model_Abstract $user
* @return Mage_Core_Model_Abstract
*/
protected function _unserializeExtraData(Mage_Core_Model_Abstract $user)
{
try {
$unsterilizedData = Mage::helper('core/unserializeArray')->unserialize($user->getExtra());
$user->setExtra($unsterilizedData);
} catch (Exception $e) {
$user->setExtra(false);
}
return $user;
}
}
11 changes: 8 additions & 3 deletions app/code/core/Mage/Admin/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public function getStartupPageUrl()
*/
public function validate()
{
$errors = array();
$errors = new ArrayObject();

if (!Zend_Validate::is($this->getUsername(), 'NotEmpty')) {
$errors[] = Mage::helper('adminhtml')->__('User Name is required field.');
Expand Down Expand Up @@ -551,16 +551,21 @@ public function validate()
if ($this->hasPasswordConfirmation() && $this->getNewPassword() != $this->getPasswordConfirmation()) {
$errors[] = Mage::helper('adminhtml')->__('Password confirmation must be same as password.');
}

Mage::dispatchEvent('admin_user_validate', array(
'user' => $this,
'errors' => $errors,
));
}

if ($this->userExists()) {
$errors[] = Mage::helper('adminhtml')->__('A user with the same user name or email aleady exists.');
}

if (empty($errors)) {
if (count($errors) === 0) {
return true;
}
return $errors;
return (array)$errors;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
*/
class Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Gallery_Content extends Mage_Adminhtml_Block_Widget
{
/**
* Type of uploader block
*
* @var string
*/
protected $_uploaderType = 'uploader/multiple';

public function __construct()
{
Expand All @@ -44,17 +50,17 @@ public function __construct()
protected function _prepareLayout()
{
$this->setChild('uploader',
$this->getLayout()->createBlock('adminhtml/media_uploader')
$this->getLayout()->createBlock($this->_uploaderType)
);

$this->getUploader()->getConfig()
->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/catalog_product_gallery/upload'))
->setFileField('image')
->setFilters(array(
'images' => array(
'label' => Mage::helper('adminhtml')->__('Images (.gif, .jpg, .png)'),
'files' => array('*.gif', '*.jpg','*.jpeg', '*.png')
)
$this->getUploader()->getUploaderConfig()
->setFileParameterName('image')
->setTarget(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/catalog_product_gallery/upload'));

$browseConfig = $this->getUploader()->getButtonConfig();
$browseConfig
->setAttributes(array(
'accept' => $browseConfig->getMimeTypesByExtensions('gif, png, jpeg, jpg')
));

Mage::dispatchEvent('catalog_product_gallery_prepare_layout', array('block' => $this));
Expand All @@ -65,7 +71,7 @@ protected function _prepareLayout()
/**
* Retrive uploader block
*
* @return Mage_Adminhtml_Block_Media_Uploader
* @return Mage_Uploader_Block_Multiple
*/
public function getUploader()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,24 @@
* @package Mage_Adminhtml
* @author Magento Core Team <[email protected]>
*/
class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Uploader extends Mage_Adminhtml_Block_Media_Uploader
class Mage_Adminhtml_Block_Cms_Wysiwyg_Images_Content_Uploader extends Mage_Uploader_Block_Multiple
{
/**
* Uploader block constructor
*/
public function __construct()
{
parent::__construct();
$params = $this->getConfig()->getParams();
$type = $this->_getMediaType();
$allowed = Mage::getSingleton('cms/wysiwyg_images_storage')->getAllowedExtensions($type);
$labels = array();
$files = array();
foreach ($allowed as $ext) {
$labels[] = '.' . $ext;
$files[] = '*.' . $ext;
}
$this->getConfig()
->setUrl(Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload', array('type' => $type)))
->setParams($params)
->setFileField('image')
->setFilters(array(
'images' => array(
'label' => $this->helper('cms')->__('Images (%s)', implode(', ', $labels)),
'files' => $files
)
$this->getUploaderConfig()
->setFileParameterName('image')
->setTarget(
Mage::getModel('adminhtml/url')->addSessionParam()->getUrl('*/*/upload', array('type' => $type))
);
$this->getButtonConfig()
->setAttributes(array(
'accept' => $this->getButtonConfig()->getMimeTypesByExtensions($allowed)
));
}

Expand Down
Loading

0 comments on commit 40c941d

Please sign in to comment.