Skip to content

Commit

Permalink
Import Magento 1.4.0.0-alpha2
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeSaferite committed Dec 31, 2009
1 parent f7e4e00 commit 7d6c516
Show file tree
Hide file tree
Showing 3,676 changed files with 226,236 additions and 44,779 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
35 changes: 30 additions & 5 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,32 @@ final class Mage
static private $_isInstalled;

/**
* Retrieve current Magento version
* Gets the current Magento version string
* @link http://www.magentocommerce.com/blog/new-community-edition-release-process/
*
* @return string
*/
public static function getVersion()
{
return '1.4.0.0-alpha1';
return '1.4.0.0-alpha2';
}

/**
* Gets the detailed Magento version information
* @link http://www.magentocommerce.com/blog/new-community-edition-release-process/
*
* @return array
*/
public static function getVersionInfo()
{
return array(
'major' => '1',
'minor' => '4',
'revision' => '0',
'patch' => '0',
'stability' => 'alpha',
'number' => '2',
);
}

/**
Expand Down Expand Up @@ -312,7 +331,7 @@ public static function getStoreConfig($path, $store = null)
public static function getStoreConfigFlag($path, $store = null)
{
$flag = strtolower(self::getStoreConfig($path, $store));
if (!empty($flag) && 'false'!==$flag && '0'!==$flag) {
if (!empty($flag) && 'false' !== $flag) {
return true;
} else {
return false;
Expand Down Expand Up @@ -665,8 +684,11 @@ public static function log($message, $level = null, $file = '')
if (!self::getConfig()) {
return;
}
if (!self::getStoreConfig('dev/log/active')) {
return;

if (!self::$_isDeveloperMode) {
if (!self::getStoreConfig('dev/log/active')) {
return;
}
}

static $loggers = array();
Expand Down Expand Up @@ -768,6 +790,9 @@ public static function printException(Exception $e, $extra = '')
!empty($extra) ? $extra . "\n\n" : '' . $e->getMessage(),
$e->getTraceAsString()
);
if (isset($_SERVER) && isset($_SERVER['REQUEST_URI'])) {
$reportData[] = $_SERVER['REQUEST_URI'];
}
$reportData = serialize($reportData);

file_put_contents($reportFile, $reportData);
Expand Down
50 changes: 47 additions & 3 deletions app/code/core/Mage/Admin/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,46 @@
*/
class Mage_Admin_Model_Config extends Varien_Simplexml_Config
{
/**
* adminhtml.xml merged config
*
* @var Varien_Simplexml_Config
*/
protected $_adminhtmlConfig;

/**
* Load config from merged adminhtml.xml files
*/
public function __construct()
{
parent::__construct();
#$this->_elementClass = 'Mage_Core_Model_Config_Element';
#$this->loadFile(Mage::getModuleDir('etc', 'Mage_Admin').DS.'admin.xml');
$this->setCacheId('adminhtml_acl_menu_config');
/* @var $adminhtmlConfig Varien_Simplexml_Config */
$adminhtmlConfig = Mage::app()->loadCache($this->getCacheId());
if ($adminhtmlConfig) {
$this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
} else {
$adminhtmlConfig = new Varien_Simplexml_Config;
$adminhtmlConfig->loadString('<?xml version="1.0"?><config></config>');
Mage::getConfig()->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
$this->_adminhtmlConfig = $adminhtmlConfig;

// support back compatibility with base config
$aclConfig = Mage::getConfig()->getNode('adminhtml/acl');
if ($aclConfig) {
$adminhtmlConfig->getNode()->extendChild($aclConfig, true);
}

$menuConfig = Mage::getConfig()->getNode('adminhtml/menu');
if ($menuConfig) {
$adminhtmlConfig->getNode()->extendChild($menuConfig, true);
}

if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(),
array(Mage_Core_Model_Config::CACHE_TAG));
}
}
}

/**
Expand All @@ -52,7 +87,7 @@ public function __construct()
public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource=null, $parentName=null)
{
if (is_null($resource)) {
$resource = Mage::getConfig()->getNode("adminhtml/acl/resources");
$resource = $this->getAdminhtmlConfig()->getNode("acl/resources");
$resourceName = null;
} else {
$resourceName = (is_null($parentName) ? '' : $parentName.'/').$resource->getName();
Expand Down Expand Up @@ -121,4 +156,13 @@ public function getAclPrivilegeSet($name='')
return false;
}

/**
* Retrieve xml config
*
* @return Varien_Simplexml_Config
*/
public function getAdminhtmlConfig()
{
return $this->_adminhtmlConfig;
}
}
49 changes: 29 additions & 20 deletions app/code/core/Mage/Admin/Model/Mysql4/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,47 @@ protected function _construct() {
$this->_init('admin/rule', 'rule_id');
}

public function saveRel(Mage_Admin_Model_Rules $rule) {
$this->_getWriteAdapter()->beginTransaction();

/**
* Save ACL resources
*
* @param Mage_Admin_Model_Rules $rule
*/
public function saveRel(Mage_Admin_Model_Rules $rule)
{
try {
$this->_getWriteAdapter()->beginTransaction();
$roleId = $rule->getRoleId();
$this->_getWriteAdapter()->delete($this->getMainTable(), "role_id = {$roleId}");
$masterResources = Mage::getModel('admin/roles')->getResourcesList2D();
$masterAdmin = false;
if ( $postedResources = $rule->getResources() ) {
foreach ($masterResources as $index => $resName) {
if ( !$masterAdmin ) {
$permission = ( in_array($resName, $postedResources) )? 'allow' : 'deny';
$this->_getWriteAdapter()->insert($this->getMainTable(), array(
'role_type' => 'G',
'resource_id' => trim($resName, '/'),
'privileges' => '', # FIXME !!!
'assert_id' => 0,
'role_id' => $roleId,
'permission' => $permission
));
}
if ( $resName == 'all' && $permission == 'allow' ) {
$masterAdmin = true;
$postedResources = $rule->getResources();
if ($postedResources) {
$row = array(
'role_type' => 'G',
'resource_id' => 'all',
'privileges' => '', // not used yet
'assert_id' => 0,
'role_id' => $roleId,
'permission' => 'allow'
);

// If all was selected save it only and nothing else.
if ($postedResources === array('all')) {
$this->_getWriteAdapter()->insert($this->getMainTable(), $row);
} else {
foreach (Mage::getModel('admin/roles')->getResourcesList2D() as $index => $resName) {
$row['permission'] = (in_array($resName, $postedResources) ? 'allow' : 'deny');
$row['resource_id'] = trim($resName, '/');
$this->_getWriteAdapter()->insert($this->getMainTable(), $row);
}
}
}

$this->_getWriteAdapter()->commit();
} catch (Mage_Core_Exception $e) {
$this->_getWriteAdapter()->rollBack();
throw $e;
} catch (Exception $e){
$this->_getWriteAdapter()->rollBack();
Mage::logException($e);
}
}
}
8 changes: 1 addition & 7 deletions app/code/core/Mage/Admin/Model/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null,
{
static $result;
if (is_null($resource)) {
$resource = Mage::getConfig()->getNode('adminhtml/acl/resources');
$resource = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('acl/resources');
$resourceName = null;
$level = -1;
} else {
Expand All @@ -89,12 +89,6 @@ protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null,
$resource->addAttribute("module_c", $module);
}

//if (!(string)$resource->title) {
// return array();
//}

//$resource->title = Mage::helper($module)->__((string)$resource->title);

if ( is_null($represent2Darray) ) {
$result[$resourceName]['name'] = Mage::helper($module)->__((string)$resource->title);
$result[$resourceName]['level'] = $level;
Expand Down
31 changes: 9 additions & 22 deletions app/code/core/Mage/Admin/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ protected function _construct()
}

/**
* Save user
* Processing data before model save
*
* @return Mage_Admin_Model_User
*/
public function save()
protected function _beforeSave()
{
$this->_beforeSave();
$data = array(
'firstname' => $this->getFirstname(),
'lastname' => $this->getLastname(),
Expand All @@ -85,8 +84,7 @@ public function save()

if ($this->getNewPassword()) {
$data['password'] = $this->_getEncodedPassword($this->getNewPassword());
}
elseif ($this->getPassword()) {
} elseif ($this->getPassword()) {
$data['new_password'] = $this->getPassword();
}

Expand All @@ -95,9 +93,8 @@ public function save()
}

$this->addData($data);
$this->_getResource()->save($this);
$this->_afterSave();
return $this;

return parent::_beforeSave();
}

/**
Expand All @@ -115,17 +112,6 @@ public function saveExtra($data)
return $this;
}

/**
* Delete user
*
* @return Mage_Admin_Model_User
*/
public function delete()
{
$this->_getResource()->delete($this);
return $this;
}

/**
* Save user roles
*
Expand Down Expand Up @@ -323,7 +309,7 @@ protected function _getEncodedPassword($pwd)
public function findFirstAvailableMenu($parent=null, $path='', $level=0)
{
if ($parent == null) {
$parent = Mage::getConfig()->getNode('adminhtml/menu');
$parent = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
}
foreach ($parent->children() as $childName=>$child) {
$aclResource = 'admin/' . $path . $childName;
Expand Down Expand Up @@ -372,8 +358,9 @@ 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/', explode('/', $startupPage)) . '/action';
if ($url = Mage::getConfig()->getNode($nodePath)) {
$nodePath = 'menu/' . join('/children/', explode('/', $startupPage)) . '/action';
$url = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode($nodePath);
if ($url) {
return $url;
}
}
Expand Down
9 changes: 0 additions & 9 deletions app/code/core/Mage/Admin/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,7 @@
<setup>
<module>Mage_Admin</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</admin_setup>
<admin_write>
<connection><use>core_write</use></connection>
</admin_write>
<admin_read>
<connection><use>core_read</use></connection>
</admin_read>
</resources>
<blocks>
<admin><class>Mage_Admin_Block</class></admin>
Expand Down
12 changes: 9 additions & 3 deletions app/code/core/Mage/AdminNotification/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ class Mage_AdminNotification_Model_Observer
*/
public function preDispatch(Varien_Event_Observer $observer)
{
$feedModel = Mage::getModel('adminnotification/feed');
/* @var $feedModel Mage_AdminNotification_Model_Feed */

$feedModel->checkUpdate();
if (Mage::getSingleton('admin/session')->isLoggedIn()) {

$feedModel = Mage::getModel('adminnotification/feed');
/* @var $feedModel Mage_AdminNotification_Model_Feed */

$feedModel->checkUpdate();

}

}
}
Loading

0 comments on commit 7d6c516

Please sign in to comment.