diff --git a/STATUS.txt b/STATUS.txt index ac41677749..da8753d8a6 100644 --- a/STATUS.txt +++ b/STATUS.txt @@ -1,19 +1,233 @@ -This file tracks the status of Magento in the 1.1.x branch. +This file tracks the status of Magento in the 1.2.x branch. FIXED BUGS: + #6341: Duble subject line in e-mail + #7162: Wrong div class used in 'mini compared products box + #7400: In order view (admin panel) statuses history is different in tabs 'Information' and 'Comments History' + #7423: Cart Rules - Condition Limit Error + #7472: Invoices Report + #7612: Products are displayed in categories they are not included in + #7636: Catalog Product Attribute -> Catalog Input Type -> Dropdown + #8020: Custom catalog attributes created as "price" not displaying correctly + #8159: One page checkout :: doesn't work when inline translation was enabled + #8366: Not possible to translate tax identifier for two store views + #8411: (assign users to role) + #8413: Mass Delete through product update screen does not work + #8439: The checkout-process-page has no pagetitle + #8452: Layout Update Problem (Mage_Core_Model_Config) + #8492: Custom Options percentage Price Type: price rounded off unwantedly + #8503: Bundle products and decimal places in options quantity + #8523: Analytics does not show revenue with configurable products + #8573: lifetime sale incorrect when refunding order with discount code applied + #8595: Many numeric-only searches in Admin/Autocomplete + #8657: Spelling mistake in error msg - "Selected currency code () is not compatabile with PayPal" + #8674: User doesn't subscribed to newsletter. + #8726: Mage_Core_Model_Resource_Setup::getAllAttributeSetIds() belongs in another class + #8762: Filter settings on Sales - Orders not saved + #8770: [MAC, Safari] Unable to create new order in the admin with new customer creating & #8771: [MAC, Safari] Unable to create new order in the admin + #8784: Send product to a friend not under store configuration + #8803: Remove "Yes, No, Any" dropdown filter on Google Base Items + #8893: Trace error after clicking button "Search" + #8896: Applying unable coupons in the empty shopping cart + #8898: Free Shipping: 'For matching items only' cart rule doesn't work with UPS XML type method + #8903: SQL error when sorting Online Customers by Type attribute + #8925: Locale settings not applied after installation + #8928: Unable to create rule for Not logged in customer. + #8943: Import is not working in Safari + #8966: Google Base API - Mass Insert / Update -> CAPTCHA challenge issued + #8968: Category save process is very slow for big catalog + #8974: Content type validation + #8977: Google Analytics reports wrong URL when URL has no query string OR store resides in subfolder... + #8980: Shopping cart discount error + #8992: Mage_Sitemap / Varien_Io_File Bug - Destination not writeable error + #8993: 'No Data Found' for Web Site + #8995: Search does not return correct URL key for additional store view (e.g. 2nd language) + #9109: Sales Report disregards currency rates + #9135: Advanced search by price doesn't work at all + #9139: Admin: menu items not readable when images are disabled + #9166: Unable to add image to all types of product + #9167: AJAX will freeze during 'quick simple product creation' + #9171: Product's table doesn't hide after select products for adding SKU + #9172: Free Shipping: 'For matching items only' cart rule doesn't work with DHL type method + #9173: Calendar's button doesn't work in rules + #9195: [admin - reports - sales - tax] - no data + #9207: Field country is not marked as required + #9208: Unable to add bundle items to bundle product + #9228: cart error after product delete + #9248: On admin page, search function does not work + #9250: Import doesn't work + #9278: Peruvian Nuevo Sol Shown as PES (Peruvian Sol) + #9279: Catalog price rules do not apply when attribute selected has Catalog Input Type for Store Owner ='Multiple Select' + #9296: Customer DOB saved not correctly + #9324: Bad counting products + #9326: Verification in "Contact Us" + #9348: Sales Tax Reports Give False Results (No Results) + #9354: Date Format + #9358: Unable add products to Google Base after filtering + #9359: Google Analytics Revenue Not Working + #9375: Fatal error: Call to a member function getItemsCollection() in Address.php + #9389: SQL-error while creating custom option forproduct + #9390: In "Advanced Search" all text is not displayed + #9392: The field is too broad insert text + #9440: Error subscription to newsletter + #9452: Email Reply Address + #9468: The same group name in an attribute set can be created but it can NOT be saved + #9470: Gift message is not moved over on an order edit + #9479: Reorder / shipping method price doesn't displayed in the "Order Totals" area + #9481: Broken design of the Expiration Date field for CC payment method + #9492: Dataflow export doesn't recognize absolute path + #9493: Buggy Sorting in Manage Tax Rates - Mantis + #9505: Missing echo statement in blank/default/template/shipping/tracking/popup.phtml + #9517: Impossible to set custom admin theme in configuration + #9536: User permissions - Manage Attributes setup + #9540: Google Base Adding SID to urls in multi domain environmnet + #9544: Zero tax total folding/unfolding + #9556: Fatal error during Store View creating + #9566: table rate shipping uploading csv broken + #9596: Store-specific payment method name not in order email + #9611: Not correct message, when you remove the product. + #9619: On front-end Serch is not working + #9622: Unable to add Configurable product to the shopping cart + #9639: Design crushing and SQL-error in admin Dashboard + #9649: Fatal error after reordering orders that contains gift message + #9651: Total revenu always 0 on Google Analytics + #9657: Email to a friend -> User can send more than 5 emails in an hour + #9659: Email to a Friend -> "Add Recipient" button doesn't work + #9660: newsletter subscribers: "Select All" working as select visible + #9665: Export action on Manage Customers and Newsletter Subscribers exports only visible page content + #9683: Orders: Function "Move to shopping cart" does not work. + #9684: Orders: Action "Hold" leads to fatal error. + #9685: No tax data in Reports - Sales - Tax + #9688: Incorrect update qty of the bundle product in the shopping cart + #9695: Manage Attribute Sets: Does not create new group + #9696: Unable to assign existing products to any web sites + #9697: Enable/Disable status works incorrect + #9699: Blank theme :: Pay Pal's Review page :: button doesn't work + products names doesn't shows + #9700: Search synonym does not work + #9707: Customers->Manage Customers->*user* - orders with DP doesn't displayed + #9708: Manage Attribute Sets: Error when creating and deleting groups + #9711: Google checkout are returning Comments History with HTML tags + #9712: Parameter "Maximum Package Weight ", leads to error 404. + #9716: Creating of Bundle Product -> SQLSTATE error + #9717: "Shipment email not sent" status does not change when you send a letter. + #9738: Downloadable product + Tax Rules = error 404 + #9742: Notice on products sitemap + #9743: Wrong count of related products, upsells and crosssells in admin + #9760: Free Shipping : 'For matching items only' incorrect works with USPS + FedEx method + Fixed Bundle with custom options final price calculation + Fixed CatalogSearch events + Fixed EAV attribute save bug + Fixed EAV use joinAttribute method in conditions addAttributeToFilter method + Fixed MySQL 4.1 bug with NO_AUTO_VALUE_ON_ZERO mode and ALTER TABLE command + Fixed Online customers + Fixed REQUEST_URI for GA + Fixed Varieb_Db_Select::resetJoinLeft (find tables in conditions) + Fixed Varien_Data_Collection_Db::getSelectCountSql + Fixed _joinAttributeToSelect for abstract catalog collection (using attribute in select result and filter condition) + Fixed adding product to shopping cart + Fixed admin notification window block ACL + Fixed autobinding unescaped SQL variables + Fixed bug with categories tree interface after switching store + Fixed catalog price rule validation (case if rule is wrong: need to remove existing generated price changes) + Fixed cleanup call in catalog index + Fixed command line installation with index.php + Fixed customer and product grid performance in admin + Fixed cybersource payment for virtual order + Fixed generate xml string for config cache (0 value was ignored) + Fixed getting table names during installation + Fixed refreshing catalog rewrites after save catalog configuration and url resource model for getting static attributes value + Fixed reindex prices after saving catalog configuration section + Fixed reorder of grouped products + Fixed tax data joining (join tax classes just for special cases) + Fixed tierprice rendering for different product types + Fixed translations in permissions titles + Fixed PayPalUk Redirect url wrong type + Fixed create unique index in install + Fixed catalog product index + Fixed session validate and re-validate sent cookie + Added customer group id for price condition in advanced search, replaced 'or' on 'in' for price layered navigation condition + Fixed Google Checkout displaying of button when it is disabled + Fixed PayPal css/html + Fixed USPS Express Mail free shipping + Fixed applying catalog price rule with empty from date + Fixed catalog search in multistore setup + Fixed checkout crosssell block: when there are no products in cart, the filter was working incorrect + Fixed displaying of shipping name in orders history (if there are only downloadable or virtual products in orders) + Fixed displaying of uploaded files; changed redirecting after log in action while trying to download is not shearable link + Fixed downloadable products renderers for multishipping checkout + Fixed fixed amount product taxes + Fixed foreign key upgrade in core DB upgrade 0.8.10-0.8.11 + Fixed getting massaction_key from POST + Fixed issues with applying coupon codes + Fixed js error in manage rules interface + Fixed downlodable products admin interface in IE + Updated Flex-Javascript bridge, fixed IE/Safari issues + Added applying frontend translation when sending emails from admin + Fixed recreating new instances of Flex-Ajax bridges on hide/display flash objects + Fixed category selection in URL-rewrites management form + Fixed fatal error in downloader + Fixed command line installer + Fixed fixed amount product taxes for products without discounts + Fixed hiding of flex uploader after removing row of downloadbale sample|link + Fixed FPT editing for bundle products + Fixed generatting filenames for create custom extensions interface in Windows + Fixed calling final step of dataflow import + Fixed bundle js for calculating children with FPT + Fixed grid to select products SKU in price rules in IE6/7 + Fixed duplicate diplaying prices in bundle product price ranges + Fixed displaying category image in blank theme + Fixed cross sells issues on frontend + Fixed serialized data checking when reading FPT data from order item + Fixed checking order status for downloadable products to become available + Fixed #9757: Paypal Payment Pro Direct not visible -RESOLVED BUGS: +CHANGES: - -IMPORTANT CHANGES: - - - -KNOWN ISSUES: - + Upgraded ZF library to version 1.7.2 (r13445 from http://framework.zend.com/svn/framework/standard/trunk/library/Zend) + Added downlodable product type + Implented fulltext search + Added layred navigation to search results + Added option to disable google checkout for selected products + Added fixed amount product taxes + Moved information about product visibility to catalog_product_category_index + Changed Mage::app()->isInstalled to Mage::isInstalled to prevent db upgrades + Removed session ID encryption + Changed catalogindex price to store prices per website + Changed modules dependencies: Mage_Shipment and Mage_Payment now depend on Mage_Catalog, Mage_GoogleCheckout depends on Mage_Payment, Mage_CatalogInventory doesn't depend on Mage_Sales + Added "Add Field with URL" option for product export + Added configuration field to include some additional output on the HTML page before head closing tag + Added Spanish - Costa Rica locale + Extended Mage_Adminhtml_Controller_Action->_prepareDownloadResponse() to avoid copy-pasting in admin controllers + Removed adding ?ft parameter in admin to prevent the issues it caused + Made category URL suffix to be .html by default + Added setting body class on
tag for admin pages (similar to frontend - full action name separated by dashes) + Added local.xml.additional file to list/explain possible additional configuration nodes/values for local.xml + Added currency rates into order info box in backend + Added ability to display form buttons on bottom in admin container widget, fixed button levels + Added ability to use memcached to store sessions and to be used as cache backend + Added additional permissions to WS api, fixed bugs with custom permissions + Added option "Disable Guest Checkout if cart contains downloadable items" + Removed store view name from page titles on catalog pages + Commented out required_once in lib/Zend + Added permanent redirect option for URL Rewrites + Added ability to display custom child blocks on success page + Added collecting results of non-asynchronous event handlers in adminhtml/events.js + Added confirmation dialog before switching from 'Images' and 'Downloadable Information' tabs in product edit form to prevent losing selected files + Added firing 'tabChangeBefore' event before switching tab in adminhtml/tabs.js (event handler can return 'cannotchange' to prevent switching) + Rewritten URL Rewrite Management interface + Added checking of file size before uploading + Added downloadable order items pdf renderers + Added downloadable products templates to blank, iphone, modern theme + Added flex uploader source code + Added support of allowed tags into Mage_Core_Helper_Abstract->htmlEscape() method + Added unquoting autobinded quoted values in SQL adapter + Added validation for selected, but not uploaded files + Updated downloader version to 1.2.0 + Changed app/etc/local.xml* license to AFL + Added autoguessing mime type of a file if mimemagic extension is not installed NOTES: diff --git a/app/Mage.php b/app/Mage.php index 9753d8b692..01da359fee 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -82,7 +82,7 @@ final class Mage { public static function getVersion() { - return '1.1.8'; + return '1.2.0'; } /** @@ -149,6 +149,9 @@ public static function registry($key) */ public static function setRoot($appRoot='') { + if (self::registry('appRoot')) { + return ; + } if (''===$appRoot) { // automagically find application root by dirname of Mage.php $appRoot = dirname(__FILE__); @@ -455,11 +458,18 @@ public static function run($code = '', $type = 'store', $options=array()) } catch (Mage_Core_Model_Store_Exception $e) { $baseUrl = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/'); - header('Location: ' . $baseUrl.'/404/'); + if (!headers_sent()) { + header('Location: ' . $baseUrl.'/404/'); + } + else { + print ''; + } die(); } catch (Exception $e) { - if (self::app()->isInstalled() || self::$_isDownloader) { + if (self::isInstalled() || self::$_isDownloader) { self::printException($e); exit(); } @@ -478,6 +488,43 @@ public static function run($code = '', $type = 'store', $options=array()) } } + /** + * Retrieve application installation flag + * + * @param string|array $options + * @return bool + */ + public static function isInstalled($options = array()) + { + $isInstalled = self::registry('_is_installed'); + if ($isInstalled === null) { + self::setRoot(); + + if (is_string($options)) { + $options = array( + 'etc_dir' => $options + ); + } + $etcDir = 'etc'; + if (!empty($options['etc_dir'])) { + $etcDir = $options['etc_dir']; + } + $localConfigFile = self::getRoot() . DS . $etcDir . DS . 'local.xml'; + + $isInstalled = false; + + if (is_readable($localConfigFile)) { + $localConfig = simplexml_load_file($localConfigFile); + date_default_timezone_set('UTC'); + if (($date = $localConfig->global->install->date) && strtotime($date)) { + $isInstalled = true; + } + } + self::register('_is_installed', $isInstalled); + } + return $isInstalled; + } + /** * log facility (??) * diff --git a/app/code/core/Mage/Admin/Model/Roles.php b/app/code/core/Mage/Admin/Model/Roles.php index 35f1839b8c..736f2d45fa 100644 --- a/app/code/core/Mage/Admin/Model/Roles.php +++ b/app/code/core/Mage/Admin/Model/Roles.php @@ -19,7 +19,7 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Mage - * @package Mage_Permissions + * @package Mage_Admin * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -62,7 +62,7 @@ public function getRoleUsers() return $this->getResource()->getRoleUsers($this); } - protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null, $parentName=null, $level=0, $represent2Darray=null, $rawNodes = false) + protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null, $parentName=null, $level=0, $represent2Darray=null, $rawNodes = false, $module = 'adminhtml') { static $result; if (is_null($resource)) { @@ -73,15 +73,25 @@ protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null, $resourceName = $parentName; if ($resource->getName()!='title' && $resource->getName()!='sort_order' && $resource->getName() != 'children') { $resourceName = (is_null($parentName) ? '' : $parentName.'/').$resource->getName(); + + //assigning module for its' children nodes + if ($resource->getAttribute('module')) { + $module = (string)$resource->getAttribute('module'); + } + if ($rawNodes) { $resource->addAttribute("aclpath", $resourceName); + $resource->addAttribute("module_c", $module); } - if (!(string)$resource->title) { - return array(); - } + + //if (!(string)$resource->title) { + // return array(); + //} + + $resource->title = Mage::helper($module)->__((string)$resource->title); if ( is_null($represent2Darray) ) { - $result[$resourceName]['name'] = Mage::helper('adminhtml')->__((string)$resource->title); + $result[$resourceName]['name'] = (string)$resource->title; $result[$resourceName]['level'] = $level; } else { $result[] = $resourceName; @@ -98,7 +108,7 @@ protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null, } } foreach ($children as $child) { - $this->_buildResourcesArray($child, $resourceName, $level+1, $represent2Darray, $rawNodes); + $this->_buildResourcesArray($child, $resourceName, $level+1, $represent2Darray, $rawNodes, $module); } if ($rawNodes) { return $resource; diff --git a/app/code/core/Mage/Admin/Model/Session.php b/app/code/core/Mage/Admin/Model/Session.php index 145fe76888..5e80ac643c 100644 --- a/app/code/core/Mage/Admin/Model/Session.php +++ b/app/code/core/Mage/Admin/Model/Session.php @@ -1,147 +1,182 @@ - - */ -class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract -{ - public function __construct() - { - $this->init('admin'); - } - - public function login($username, $password, $request=null) - { - if (empty($username) || empty($password)) { - return; - } - - $user = Mage::getModel('admin/user')->login($username, $password); - if ( $user->getId() && $user->getIsActive() != '1' ) { - if ($request && !$request->getParam('messageSent')) { - Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Your Account has been deactivated.')); - $request->setParam('messageSent', true); - } - } elseif (!Mage::getModel('admin/user')->hasAssigned2Role($user->getId())) { - if ($request && !$request->getParam('messageSent')) { - Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Access Denied.')); - $request->setParam('messageSent', true); - } - } else { - if ($user->getId()) { - $session = Mage::getSingleton('admin/session'); - $session->setIsFirstVisit(true); - $session->setUser($user); - $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl()); - if ($request) { - /** - * Added hack as $_GET['ft'] param for redirecting to dashboard - * if _prepareDownloadResponse used when user is not logged in - */ - $requestUriInfo = parse_url($request->getRequestUri()); - if (isset($requestUriInfo['query']) && $requestUriInfo['query'] != '') { - $requestUriPostfix = '&ft'; - } else { - $requestUriPostfix = '?ft'; - } - - header('Location: '.$request->getRequestUri() . $requestUriPostfix); - exit; - } - } else { - if ($request && !$request->getParam('messageSent')) { - Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Invalid Username or Password.')); - $request->setParam('messageSent', true); - } - } - } - return $user; - } - - public function refreshAcl($user=null) - { - if (is_null($user)) { - $user = $this->getUser(); - } - if (!$user) { - return $this; - } - if (!$this->getAcl() || $user->getReloadAclFlag()) { - $this->setAcl(Mage::getResourceModel('admin/acl')->loadAcl()); - } - if ($user->getReloadAclFlag()) { - $user->unsetData('password'); - $user->setReloadAclFlag('0')->save(); - } - return $this; - } - - /** - * Check current user permission on resource and privilege - * - * Mage::getSingleton('admin/session')->isAllowed('admin/catalog') - * Mage::getSingleton('admin/session')->isAllowed('catalog') - * - * @param string $resource - * @param string $privilege - * @return bool - */ - public function isAllowed($resource, $privilege=null) - { - $user = $this->getUser(); - $acl = $this->getAcl(); - - if ($user && $acl) { - if (!preg_match('/^admin/', $resource)) { - $resource = 'admin/'.$resource; - } - - try { - if ($acl->isAllowed($user->getAclRole(), 'all', null)){ - return true; - } - } catch (Exception $e) {} - - try { - return $acl->isAllowed($user->getAclRole(), $resource, $privilege); - } catch (Exception $e) { - return false; - } - } - return false; - } - - public function isLoggedIn() - { - return $this->getUser() && $this->getUser()->getId(); - } + + */ +class Mage_Admin_Model_Session extends Mage_Core_Model_Session_Abstract +{ + + /** + * Whether it is the first page after successfull login + * + * @var boolean + */ + protected $_isFirstPageAfterLogin; + + /** + * Class constructor + * + */ + public function __construct() + { + $this->init('admin'); + } + + /** + * Try to login user in admin + * + * @param string $username + * @param string $password + * @param Mage_Core_Controller_Request_Http $request + * @return Mage_Admin_Model_User|null + */ + public function login($username, $password, $request=null) + { + if (empty($username) || empty($password)) { + return; + } + + $user = Mage::getModel('admin/user')->login($username, $password); + if ( $user->getId() && $user->getIsActive() != '1' ) { + if ($request && !$request->getParam('messageSent')) { + Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Your Account has been deactivated.')); + $request->setParam('messageSent', true); + } + } elseif (!Mage::getModel('admin/user')->hasAssigned2Role($user->getId())) { + if ($request && !$request->getParam('messageSent')) { + Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Access Denied.')); + $request->setParam('messageSent', true); + } + } else { + if ($user->getId()) { + $session = Mage::getSingleton('admin/session'); + $session->setIsFirstVisit(true); + $session->setUser($user); + $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl()); + if ($request) { + header('Location: ' . $request->getRequestUri()); + exit; + } + + } else { + if ($request && !$request->getParam('messageSent')) { + Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Invalid Username or Password.')); + $request->setParam('messageSent', true); + } + } + } + return $user; + } + + /** + * Refresh ACL resources stored in session + * + * @param Mage_Admin_Model_User $user + * @return Mage_Admin_Model_Session + */ + public function refreshAcl($user=null) + { + if (is_null($user)) { + $user = $this->getUser(); + } + if (!$user) { + return $this; + } + if (!$this->getAcl() || $user->getReloadAclFlag()) { + $this->setAcl(Mage::getResourceModel('admin/acl')->loadAcl()); + } + if ($user->getReloadAclFlag()) { + $user->unsetData('password'); + $user->setReloadAclFlag('0')->save(); + } + return $this; + } + + /** + * Check current user permission on resource and privilege + * + * Mage::getSingleton('admin/session')->isAllowed('admin/catalog') + * Mage::getSingleton('admin/session')->isAllowed('catalog') + * + * @param string $resource + * @param string $privilege + * @return boolean + */ + public function isAllowed($resource, $privilege=null) + { + $user = $this->getUser(); + $acl = $this->getAcl(); + + if ($user && $acl) { + if (!preg_match('/^admin/', $resource)) { + $resource = 'admin/'.$resource; + } + + try { + if ($acl->isAllowed($user->getAclRole(), 'all', null)){ + return true; + } + } catch (Exception $e) {} + + try { + return $acl->isAllowed($user->getAclRole(), $resource, $privilege); + } catch (Exception $e) { + return false; + } + } + return false; + } + + /** + * Check if user is logged in + * + * @return boolean + */ + public function isLoggedIn() + { + return $this->getUser() && $this->getUser()->getId(); + } + + /** + * Check if it is the first page after successfull login + * + * @return boolean + */ + public function isFirstPageAfterLogin() + { + if (is_null($this->_isFirstPageAfterLogin)) { + $this->_isFirstPageAfterLogin = $this->getData('is_first_visit', true); + } + return $this->_isFirstPageAfterLogin; + } + } \ No newline at end of file diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php index f648a091b6..b80af6f995 100644 --- a/app/code/core/Mage/Admin/Model/User.php +++ b/app/code/core/Mage/Admin/Model/User.php @@ -1,256 +1,307 @@ -_init('admin/user'); - } - - public function save() { - - $data = array( - 'firstname' => $this->getFirstname(), - 'lastname' => $this->getLastname(), - 'email' => $this->getEmail(), - 'modified' => now(), - 'extra' => serialize($this->getExtra()) - ); - - if($this->getId() > 0) { - $data['user_id'] = $this->getId(); - } - - if( $this->getUsername() ) { - $data['username'] = $this->getUsername(); - } - - if ($this->getPassword()) { - $data['password'] = $this->_getEncodedPassword($this->getPassword()); - } - - if ($this->getNewPassword()) { - $data['password'] = $this->_getEncodedPassword($this->getNewPassword()); - } - - if ( !is_null($this->getIsActive()) ) { - $data['is_active'] = intval($this->getIsActive()); - } - - $this->setData($data); - $this->_getResource()->save($this); - return $this; - } - - public function delete() - { - $this->_getResource()->delete($this); - return $this; - } - - public function saveRelations() - { - $this->_getResource()->_saveRelations($this); - return $this; - } - - public function getRoles() - { - return $this->_getResource()->_getRoles($this); - } - - public function deleteFromRole() - { - $this->_getResource()->deleteFromRole($this); - return $this; - } - - public function roleUserExists() - { - $result = $this->_getResource()->roleUserExists($this); - return ( is_array($result) && count($result) > 0 ) ? true : false; - } - - public function add() - { - $this->_getResource()->add($this); - return $this; - } - - public function userExists() - { - $result = $this->_getResource()->userExists($this); - return ( is_array($result) && count($result) > 0 ) ? true : false; - } - - public function getCollection() { - return Mage::getResourceModel('admin/user_collection'); - } - - /** - * Send email with new user password - * - * @return Mage_Admin_Model_User - */ - public function sendNewPasswordEmail() - { - $translate = Mage::getSingleton('core/translate'); - /* @var $translate Mage_Core_Model_Translate */ - $translate->setTranslateInline(false); - - Mage::getModel('core/email_template') - ->setDesignConfig(array('area'=>'adminhtml', 'store'=>$this->getStoreId())) - ->sendTransactional( - Mage::getStoreConfig(self::XML_PATH_FORGOT_EMAIL_TEMPLATE), - Mage::getStoreConfig(self::XML_PATH_FORGOT_EMAIL_IDENTITY), - $this->getEmail(), - $this->getName(), - array('user'=>$this, 'password'=>$this->getPlainPassword())); - - $translate->setTranslateInline(true); - - return $this; - } - - public function getName($separator=' ') - { - return $this->getFirstname().$separator.$this->getLastname(); - } - - public function getId() - { - return $this->getUserId(); - } - - /** - * Get user ACL role - * - * @return string - */ - public function getAclRole() - { - return 'U'.$this->getUserId(); - } - - /** - * Authenticate user name and password and save loaded record - * - * @param string $username - * @param string $password - * @return boolean - */ - public function authenticate($username, $password) - { - $this->loadByUsername($username); - if (!$this->getId()) { - return false; - } - $auth = Mage::helper('core')->validateHash($password, $this->getPassword()); - if ($auth) { - return true; - } else { - $this->unsetData(); - return false; - } - } - - /** - * Login user - * - * @param string $login - * @param string $password - * @return Mage_Admin_Model_User - */ - public function login($username, $password) - { - if ($this->authenticate($username, $password)) { - $this->getResource()->recordLogin($this); - } - - return $this; - } - - public function reload() - { - $id = $this->getId(); - $this->setId(null); - $this->load($id); - return $this; - } - - public function loadByUsername($username) - { - $this->setData($this->getResource()->loadByUsername($username)); - return $this; - } - - public function hasAssigned2Role($user) - { - return $this->getResource()->hasAssigned2Role($user); - } - - protected function _getEncodedPassword($pwd) - { - return Mage::helper('core')->getHash($pwd, 2); - } - - public function findFirstAvailableMenu($parent=null, $path='', $level=0) - { - if ($parent == null) { - $parent = Mage::getConfig()->getNode('adminhtml/menu'); - } - foreach ($parent->children() as $childName=>$child) { - $aclResource = 'admin/'.$path.$childName; - if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) { - if (!$child->children) { - return (string)$child->action; - } else if ($child->children) { - $action = $this->findFirstAvailableMenu($child->children, $path.$childName.'/', $level+1); - return $action?$action:(string)$child->action; - } - } - } - } - - public function getStatrupPageUrl() - { - $startupPage = Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE); - $aclResource = 'admin/'.$startupPage; - if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) { - $nodePath = 'adminhtml/menu/' . join('/children/', split('/', $startupPage)) . '/action'; - if ($url = Mage::getConfig()->getNode($nodePath)) { - return $url; - } - } - - return $this->findFirstAvailableMenu(); - } -} \ No newline at end of file + + */ +class Mage_Admin_Model_User extends Mage_Core_Model_Abstract +{ + + const XML_PATH_FORGOT_EMAIL_TEMPLATE = 'admin/emails/forgot_email_template'; + const XML_PATH_FORGOT_EMAIL_IDENTITY = 'admin/emails/forgot_email_identity'; + const XML_PATH_STARTUP_PAGE = 'admin/startup/page'; + + /** + * Varien constructor + */ + protected function _construct() + { + $this->_init('admin/user'); + } + + /** + * Save user + * + * @return Mage_Admin_Model_User + */ + public function save() + { + $data = array( + 'firstname' => $this->getFirstname(), + 'lastname' => $this->getLastname(), + 'email' => $this->getEmail(), + 'modified' => now(), + 'extra' => serialize($this->getExtra()) + ); + + if($this->getId() > 0) { + $data['user_id'] = $this->getId(); + } + + if( $this->getUsername() ) { + $data['username'] = $this->getUsername(); + } + + if ($this->getPassword()) { + $data['password'] = $this->_getEncodedPassword($this->getPassword()); + } + + if ($this->getNewPassword()) { + $data['password'] = $this->_getEncodedPassword($this->getNewPassword()); + } + + if ( !is_null($this->getIsActive()) ) { + $data['is_active'] = intval($this->getIsActive()); + } + + $this->setData($data); + $this->_getResource()->save($this); + return $this; + } + + /** + * Delete user + * + * @return Mage_Admin_Model_User + */ + public function delete() + { + $this->_getResource()->delete($this); + return $this; + } + + /** + * Save user roles + * + * @return Mage_Admin_Model_User + */ + public function saveRelations() + { + $this->_getResource()->_saveRelations($this); + return $this; + } + + public function getRoles() + { + return $this->_getResource()->_getRoles($this); + } + + public function deleteFromRole() + { + $this->_getResource()->deleteFromRole($this); + return $this; + } + + public function roleUserExists() + { + $result = $this->_getResource()->roleUserExists($this); + return ( is_array($result) && count($result) > 0 ) ? true : false; + } + + public function add() + { + $this->_getResource()->add($this); + return $this; + } + + public function userExists() + { + $result = $this->_getResource()->userExists($this); + return ( is_array($result) && count($result) > 0 ) ? true : false; + } + + public function getCollection() { + return Mage::getResourceModel('admin/user_collection'); + } + + /** + * Send email with new user password + * + * @return Mage_Admin_Model_User + */ + public function sendNewPasswordEmail() + { + $translate = Mage::getSingleton('core/translate'); + /* @var $translate Mage_Core_Model_Translate */ + $translate->setTranslateInline(false); + + Mage::getModel('core/email_template') + ->setDesignConfig(array('area' => 'adminhtml', 'store' => $this->getStoreId())) + ->sendTransactional( + Mage::getStoreConfig(self::XML_PATH_FORGOT_EMAIL_TEMPLATE), + Mage::getStoreConfig(self::XML_PATH_FORGOT_EMAIL_IDENTITY), + $this->getEmail(), + $this->getName(), + array('user' => $this, 'password' => $this->getPlainPassword())); + + $translate->setTranslateInline(true); + + return $this; + } + + public function getName($separator=' ') + { + return $this->getFirstname() . $separator . $this->getLastname(); + } + + public function getId() + { + return $this->getUserId(); + } + + /** + * Get user ACL role + * + * @return string + */ + public function getAclRole() + { + return 'U' . $this->getUserId(); + } + + /** + * Authenticate user name and password and save loaded record + * + * @param string $username + * @param string $password + * @return boolean + */ + public function authenticate($username, $password) + { + $this->loadByUsername($username); + if (!$this->getId()) { + return false; + } + $auth = Mage::helper('core')->validateHash($password, $this->getPassword()); + if ($auth) { + return true; + } else { + $this->unsetData(); + return false; + } + } + + /** + * Login user + * + * @param string $login + * @param string $password + * @return Mage_Admin_Model_User + */ + public function login($username, $password) + { + if ($this->authenticate($username, $password)) { + $this->getResource()->recordLogin($this); + } + + return $this; + } + + public function reload() + { + $id = $this->getId(); + $this->setId(null); + $this->load($id); + return $this; + } + + public function loadByUsername($username) + { + $this->setData($this->getResource()->loadByUsername($username)); + return $this; + } + + public function hasAssigned2Role($user) + { + return $this->getResource()->hasAssigned2Role($user); + } + + protected function _getEncodedPassword($pwd) + { + return Mage::helper('core')->getHash($pwd, 2); + } + + /** + * Find first menu item that user is able to access + * + * @param Mage_Core_Model_Config_Element $parent + * @param string $path + * @param integer $level + * @return string + */ + public function findFirstAvailableMenu($parent=null, $path='', $level=0) + { + if ($parent == null) { + $parent = Mage::getConfig()->getNode('adminhtml/menu'); + } + foreach ($parent->children() as $childName=>$child) { + $aclResource = 'admin/' . $path . $childName; + if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) { + if (!$child->children) { + return (string)$child->action; + } else if ($child->children) { + $action = $this->findFirstAvailableMenu($child->children, $path . $childName . '/', $level+1); + return $action ? $action : (string)$child->action; + } + } + } + } + + /** + * Find admin start page url + * + * @deprecated Please use getStartupPageUrl() method instead + * @see getStartupPageUrl() + * @return string + */ + public function getStatrupPageUrl() + { + return $this->getStartupPageUrl(); + } + + /** + * Find admin start page url + * + * @return string + */ + public function getStartupPageUrl() + { + $startupPage = Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE); + $aclResource = 'admin/' . $startupPage; + if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) { + $nodePath = 'adminhtml/menu/' . join('/children/', split('/', $startupPage)) . '/action'; + if ($url = Mage::getConfig()->getNode($nodePath)) { + return $url; + } + } + return $this->findFirstAvailableMenu(); + } + +} diff --git a/app/code/core/Mage/Admin/etc/admin.xml b/app/code/core/Mage/Admin/etc/admin.xml deleted file mode 100644 index a89ac2a023..0000000000 --- a/app/code/core/Mage/Admin/etc/admin.xml +++ /dev/null @@ -1,211 +0,0 @@ - - --