00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Customer 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Customer dashboard block 00029 * 00030 * @category Mage 00031 * @package Mage_Customer 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Customer_Block_Account_Dashboard extends Mage_Core_Block_Template 00035 { 00036 protected $_subscription = null; 00037 00038 public function getCustomer() 00039 { 00040 return Mage::getSingleton('customer/session')->getCustomer(); 00041 } 00042 00043 public function getAccountUrl() 00044 { 00045 return Mage::getUrl('customer/account/edit', array('_secure'=>true)); 00046 } 00047 00048 public function getAddressesUrl() 00049 { 00050 return Mage::getUrl('customer/address/index', array('_secure'=>true)); 00051 } 00052 00053 public function getAddressEditUrl($address) 00054 { 00055 return Mage::getUrl('customer/address/edit', array('_secure'=>true, 'id'=>$address->getId())); 00056 } 00057 00058 public function getOrdersUrl() 00059 { 00060 return Mage::getUrl('customer/order/index', array('_secure'=>true)); 00061 } 00062 00063 public function getReviewsUrl() 00064 { 00065 return Mage::getUrl('review/customer/index', array('_secure'=>true)); 00066 } 00067 00068 public function getWishlistUrl() 00069 { 00070 return Mage::getUrl('customer/wishlist/index', array('_secure'=>true)); 00071 } 00072 00073 public function getTagsUrl() 00074 { 00075 00076 } 00077 00078 public function getSubscriptionObject() 00079 { 00080 if(is_null($this->_subscription)) { 00081 $this->_subscription = Mage::getModel('newsletter/subscriber')->loadByCustomer($this->getCustomer()); 00082 } 00083 00084 return $this->_subscription; 00085 } 00086 00087 public function getManageNewsletterUrl() 00088 { 00089 return $this->getUrl('*/newsletter/manage'); 00090 } 00091 00092 public function getSubscriptionText() 00093 { 00094 if($this->getSubscriptionObject()->isSubscribed()) { 00095 return Mage::helper('customer')->__('You are currently subscribed to our newsletter'); 00096 } 00097 00098 return Mage::helper('customer')->__('You are currently not subscribed to our newsletter'); 00099 } 00100 00101 public function getPrimaryAddresses() 00102 { 00103 $addresses = $this->getCustomer()->getPrimaryAddresses(); 00104 if (empty($addresses)) { 00105 return false; 00106 } 00107 return $addresses; 00108 } 00109 00110 /** 00111 * Get back url in account dashboard 00112 * 00113 * This method is copypasted in: 00114 * Mage_Wishlist_Block_Customer_Wishlist - because of strange inheritance 00115 * Mage_Customer_Block_Address_Book - because of secure url 00116 * 00117 * @return string 00118 */ 00119 public function getBackUrl() 00120 { 00121 // the RefererUrl must be set in appropriate controller 00122 if ($this->getRefererUrl()) { 00123 return $this->getRefererUrl(); 00124 } 00125 return $this->getUrl('customer/account/'); 00126 } 00127 }