Skip to content

Commit

Permalink
Import Magento Release 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeSaferite committed May 30, 2009
1 parent d583154 commit f32ebf0
Show file tree
Hide file tree
Showing 688 changed files with 21,673 additions and 8,931 deletions.
100 changes: 76 additions & 24 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,29 @@
define('PS', PATH_SEPARATOR);
define('BP', dirname(dirname(__FILE__)));

/**
* Error reporting
*/
error_reporting(E_ALL | E_STRICT);

Mage::register('original_include_path', get_include_path());

/**
* Set include path
*/
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';

$app_path = implode(PS, $paths);

set_include_path($app_path . PS . Mage::registry('original_include_path'));
if (defined('COMPILER_INCLUDE_PATH')) {
$app_path = COMPILER_INCLUDE_PATH;
set_include_path($app_path . PS . Mage::registry('original_include_path'));
include_once "Mage_Core_functions.php";
include_once "Varien_Autoload.php";
} else {
/**
* Set include path
*/
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'local';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'community';
$paths[] = BP . DS . 'app' . DS . 'code' . DS . 'core';
$paths[] = BP . DS . 'lib';

$app_path = implode(PS, $paths);
set_include_path($app_path . PS . Mage::registry('original_include_path'));
include_once "Mage/Core/functions.php";
include_once "Varien/Autoload.php";
}

include_once "Mage/Core/functions.php";
include_once "Varien/Profiler.php";
Varien_Autoload::register();

/**
* Main Mage hub class
Expand Down Expand Up @@ -82,7 +84,7 @@ final class Mage {

public static function getVersion()
{
return '1.3.1.1';
return '1.3.2';
}

/**
Expand Down Expand Up @@ -464,9 +466,9 @@ public static function run($code = '', $type = 'store', $options=array())
die();
}
catch (Mage_Core_Model_Store_Exception $e) {
$baseUrl = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
$baseUrl = self::getScriptSystemUrl('404');
if (!headers_sent()) {
header('Location: ' . $baseUrl.'/404/');
header('Location: ' . rtrim($baseUrl, '/').'/404/');
}
else {
print '<script type="text/javascript">';
Expand Down Expand Up @@ -656,9 +658,9 @@ public static function printException(Exception $e, $extra = '')
}
catch (Exception $e) {}

$baseUrl = rtrim(str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])), '/');
$reportUrl = $baseUrl . '/report/?id='
. $reportId . '&s=' . $storeCode;
$baseUrl = self::getScriptSystemUrl('report', true);
$reportUrl = rtrim($baseUrl, '/') . '/report/?id='
. $reportId . '&s=' . $storeCode;

if (!headers_sent()) {
header('Location: ' . $reportUrl);
Expand All @@ -673,6 +675,56 @@ public static function printException(Exception $e, $extra = '')
die();
}

/**
* Define system folder directory url by virtue of running script directory name
* Try to find requested folder by shifting to domain root directory
*
* @param string $folder
* @param boolean $exitIfNot
* @return string
*/
public static function getScriptSystemUrl($folder, $exitIfNot = false)
{
$runDirUrl = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
$runDir = rtrim(dirname($_SERVER['SCRIPT_FILENAME']), DS);

$baseUrl = null;
if (is_dir($runDir.'/'.$folder)) {
$baseUrl = str_replace(DS, '/', $runDirUrl);
} else {
$runDirUrlArray = explode('/', $runDirUrl);
$runDirArray = explode('/', $runDir);
$count = count($runDirArray);

for ($i=0; $i < $count; $i++) {
array_pop($runDirUrlArray);
array_pop($runDirArray);
$_runDir = implode('/', $runDirArray);
if (!empty($_runDir)) {
$_runDir .= '/';
}

if (is_dir($_runDir.$folder)) {
$_runDirUrl = implode('/', $runDirUrlArray);
$baseUrl = str_replace(DS, '/', $_runDirUrl);
break;
}
}
}

if (is_null($baseUrl)) {
$errorMessage = "Unable detect system directory: $folder";
if ($exitIfNot) {
// exit because of infinity loop
exit($errorMessage);
} else {
self::printException(new Exception(), $errorMessage);
}
}

return $baseUrl;
}

public static function setIsDownloader($flag=true)
{
self::$_isDownloader = $flag;
Expand Down
5 changes: 5 additions & 0 deletions app/code/core/Mage/Admin/Model/Mysql4/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
*/
class Mage_Admin_Model_Mysql4_Acl
{
const ACL_ALL_RULES = 'all';

/**
* Read resource connection
*
Expand Down Expand Up @@ -135,6 +137,9 @@ function loadRules(Mage_Admin_Model_Acl $acl, array $rulesArr)
}
try {
if ( $rule['permission'] == 'allow' ) {
if ($resource === self::ACL_ALL_RULES) {
$acl->allow($role, null, $privileges, $assert);
}
$acl->allow($role, $resource, $privileges, $assert);
} else if ( $rule['permission'] == 'deny' ) {
$acl->deny($role, $resource, $privileges, $assert);
Expand Down
16 changes: 7 additions & 9 deletions app/code/core/Mage/Admin/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function login($username, $password, $request = null)
}
}
catch (Mage_Core_Exception $e) {
Mage::dispatchEvent('admin_session_user_login_failed', array('user_name'=>$username));
Mage::dispatchEvent('admin_session_user_login_failed', array('user_name'=>$username, 'exception' => $e));
if ($request && !$request->getParam('messageSent')) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$request->setParam('messageSent', true);
Expand Down Expand Up @@ -143,16 +143,14 @@ public function isAllowed($resource, $privilege=null)
$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;
try {
if (!$acl->has($resource)) {
return $acl->isAllowed($user->getAclRole(), null, $privilege);
}
} catch (Exception $e) { }
}
}
return false;
Expand Down Expand Up @@ -197,4 +195,4 @@ protected function _getRequestUri($request = null)
return null;
}
}
}
}
70 changes: 69 additions & 1 deletion app/code/core/Mage/AdminNotification/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,34 @@
*/
class Mage_AdminNotification_Helper_Data extends Mage_Core_Helper_Abstract
{
const XML_PATH_POPUP_URL = 'system/adminnotification/popup_url';

/**
* Widget Popup Notification Object URL
*
* @var string
*/
protected $_popupUrl;

/**
* Is readable Popup Notification Object flag
*
* @var bool
*/
protected $_popupReadable;

/**
* Last Notice object
*
* @var Mage_AdminNotification_Model_Inbox
*/
protected $_latestNotice;

/**
* count of unread notes by type
*
* @var array
*/
protected $_unreadNoticeCounts;

/**
Expand Down Expand Up @@ -63,4 +90,45 @@ public function getUnreadNoticeCount($severity)
}
return isset($this->_unreadNoticeCounts[$severity]) ? $this->_unreadNoticeCounts[$severity] : 0;
}
}

/**
* Retrieve Widget Popup Notification Object URL
*
* @param bool $withExt
* @return string
*/
public function getPopupObjectUrl($withExt = false)
{
if (is_null($this->_popupUrl)) {
$sheme = Mage::app()->getFrontController()->getRequest()->isSecure()
? 'https://'
: 'http://';

$this->_popupUrl = $sheme . Mage::getStoreConfig(self::XML_PATH_POPUP_URL);
}
return $this->_popupUrl . ($withExt ? '.swf' : '');
}

/**
* Check is readable Popup Notification Object
*
* @return bool
*/
public function isReadablePopupObject()
{
if (is_null($this->_popupReadable)) {
$this->_popupReadable = false;
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array(
'timeout' => 2
));
$curl->write(Zend_Http_Client::GET, $this->getPopupObjectUrl(true));
if ($curl->read()) {
if ($curl->getInfo(CURLINFO_HTTP_CODE) == 200) {
$this->_popupReadable = true;
}
}
}
return $this->_popupReadable;
}
}
8 changes: 6 additions & 2 deletions app/code/core/Mage/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ protected function _construct()
public function getFeedUrl()
{
if (is_null($this->_feedUrl)) {
$this->_feedUrl = Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://'
. Mage::getStoreConfig(self::XML_FEED_URL_PATH);
$this->_feedUrl = (Mage::getStoreConfigFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://')
. Mage::getStoreConfig(self::XML_FEED_URL_PATH);
}
return $this->_feedUrl;
}
Expand All @@ -81,6 +81,7 @@ public function checkUpdate()
$feedData = array();

$feedXml = $this->getFeedData();

if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
foreach ($feedXml->channel->item as $item) {
$feedData[] = array(
Expand Down Expand Up @@ -156,6 +157,9 @@ public function setLastUpdate()
public function getFeedData()
{
$curl = new Varien_Http_Adapter_Curl();
$curl->setConfig(array(
'timeout' => 2
));
$curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
$data = $curl->read();
if ($data === false) {
Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/AdminNotification/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<system>
<adminnotification>
<feed_url>www.magentocommerce.com/notifications_feed</feed_url>
<popup_url>widgets.magentocommerce.com/notificationPopup</popup_url>
<use_https>0</use_https>
<frequency>1</frequency>
<last_update>0</last_update>
Expand Down
71 changes: 48 additions & 23 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,59 @@ protected function _prepareLayout()
$this->getLayout()->createBlock('adminhtml/catalog_category_tabs', 'tabs')
);

$this->setChild('save_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Save Category'),
'onclick' => "categorySubmit('".$this->getSaveUrl()."',true)",
'class' => 'save'
))
);
if (!$this->getCategory()->isReadonly()) {
$this->setChild('save_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Save Category'),
'onclick' => "categorySubmit('".$this->getSaveUrl()."',true)",
'class' => 'save'
))
);
}
if (!in_array($this->getCategory()->getId(), $this->getRootIds()) &&
$this->getCategory()->isDeleteable()) {
$this->setChild('delete_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Delete Category'),
'onclick' => "categoryDelete('".$this->getUrl('*/*/delete', array('_current'=>true))."',true)",
'class' => 'delete'
))
);
}

$this->setChild('delete_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Delete Category'),
'onclick' => "categoryDelete('".$this->getUrl('*/*/delete', array('_current'=>true))."',true)",
'class' => 'delete'
))
);
if (!$this->getCategory()->isReadonly()) {
$this->setChild('reset_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Reset'),
'onclick' => "categoryReset('".$this->getUrl('*/*/edit', array('_current'=>true))."',true)"
))
);
}

$this->setChild('reset_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('catalog')->__('Reset'),
'onclick' => "categoryReset('".$this->getUrl('*/*/edit', array('_current'=>true))."',true)"
))
);
return parent::_prepareLayout();
}

/**
* Return array of root categories ids
*
* @return array
*/
public function getRootIds()
{
$ids = $this->getData('root_ids');
if (is_null($ids)) {
$ids = array();
foreach (Mage::app()->getStores() as $store) {
$ids[] = $store->getRootCategoryId();
}
$this->setData('root_ids', $ids);
}
return $ids;
}

public function getStoreConfigurationUrl()
{
$storeId = (int) $this->getRequest()->getParam('store');
Expand Down
Loading

0 comments on commit f32ebf0

Please sign in to comment.