1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Customer
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Customer dashboard block
29: *
30: * @category Mage
31: * @package Mage_Customer
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Customer_Block_Account_Dashboard extends Mage_Core_Block_Template
35: {
36: protected $_subscription = null;
37:
38: public function getCustomer()
39: {
40: return Mage::getSingleton('customer/session')->getCustomer();
41: }
42:
43: public function getAccountUrl()
44: {
45: return Mage::getUrl('customer/account/edit', array('_secure'=>true));
46: }
47:
48: public function getAddressesUrl()
49: {
50: return Mage::getUrl('customer/address/index', array('_secure'=>true));
51: }
52:
53: public function getAddressEditUrl($address)
54: {
55: return Mage::getUrl('customer/address/edit', array('_secure'=>true, 'id'=>$address->getId()));
56: }
57:
58: public function getOrdersUrl()
59: {
60: return Mage::getUrl('customer/order/index', array('_secure'=>true));
61: }
62:
63: public function getReviewsUrl()
64: {
65: return Mage::getUrl('review/customer/index', array('_secure'=>true));
66: }
67:
68: public function getWishlistUrl()
69: {
70: return Mage::getUrl('customer/wishlist/index', array('_secure'=>true));
71: }
72:
73: public function getTagsUrl()
74: {
75:
76: }
77:
78: public function getSubscriptionObject()
79: {
80: if(is_null($this->_subscription)) {
81: $this->_subscription = Mage::getModel('newsletter/subscriber')->loadByCustomer($this->getCustomer());
82: }
83:
84: return $this->_subscription;
85: }
86:
87: public function getManageNewsletterUrl()
88: {
89: return $this->getUrl('*/newsletter/manage');
90: }
91:
92: public function getSubscriptionText()
93: {
94: if($this->getSubscriptionObject()->isSubscribed()) {
95: return Mage::helper('customer')->__('You are currently subscribed to our newsletter.');
96: }
97:
98: return Mage::helper('customer')->__('You are currently not subscribed to our newsletter.');
99: }
100:
101: public function getPrimaryAddresses()
102: {
103: $addresses = $this->getCustomer()->getPrimaryAddresses();
104: if (empty($addresses)) {
105: return false;
106: }
107: return $addresses;
108: }
109:
110: /**
111: * Get back url in account dashboard
112: *
113: * This method is copypasted in:
114: * Mage_Wishlist_Block_Customer_Wishlist - because of strange inheritance
115: * Mage_Customer_Block_Address_Book - because of secure url
116: *
117: * @return string
118: */
119: public function getBackUrl()
120: {
121: // the RefererUrl must be set in appropriate controller
122: if ($this->getRefererUrl()) {
123: return $this->getRefererUrl();
124: }
125: return $this->getUrl('customer/account/');
126: }
127: }
128: