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_Adminhtml
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: * Catalog composite product configuration controller
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Customer_Wishlist_Product_Composite_WishlistController
35: extends Mage_Adminhtml_Controller_Action
36: {
37: /**
38: * Wishlist we're working with
39: *
40: * @var Mage_Wishlist_Model_Wishlist
41: */
42: protected $_wishlist = null;
43:
44: /**
45: * Wishlist item we're working with
46: *
47: * @var Mage_Wishlist_Model_Wishlist
48: */
49: protected $_wishlistItem = null;
50:
51: /**
52: * Loads wishlist and wishlist item
53: *
54: * @return Mage_Adminhtml_Customer_Wishlist_Product_Composite_WishlistController
55: */
56: protected function _initData()
57: {
58: $wishlistItemId = (int) $this->getRequest()->getParam('id');
59: if (!$wishlistItemId) {
60: Mage::throwException($this->__('No wishlist item id defined.'));
61: }
62:
63: /* @var $wishlistItem Mage_Wishlist_Model_Item */
64: $wishlistItem = Mage::getModel('wishlist/item')
65: ->loadWithOptions($wishlistItemId);
66:
67: if (!$wishlistItem->getWishlistId()) {
68: Mage::throwException($this->__('Wishlist item is not loaded.'));
69: }
70:
71: $this->_wishlist = Mage::getModel('wishlist/wishlist')
72: ->load($wishlistItem->getWishlistId());
73:
74: $this->_wishlistItem = $wishlistItem;
75:
76: return $this;
77: }
78:
79: /**
80: * Ajax handler to response configuration fieldset of composite product in customer's wishlist
81: *
82: * @return Mage_Adminhtml_Customer_Wishlist_Product_Composite_WishlistController
83: */
84: public function configureAction()
85: {
86: $configureResult = new Varien_Object();
87: try {
88: $this->_initData();
89:
90: $configureResult->setProductId($this->_wishlistItem->getProductId());
91: $configureResult->setBuyRequest($this->_wishlistItem->getBuyRequest());
92: $configureResult->setCurrentStoreId($this->_wishlistItem->getStoreId());
93: $configureResult->setCurrentCustomerId($this->_wishlist->getCustomerId());
94:
95: $configureResult->setOk(true);
96: } catch (Exception $e) {
97: $configureResult->setError(true);
98: $configureResult->setMessage($e->getMessage());
99: }
100:
101: /* @var $helper Mage_Adminhtml_Helper_Catalog_Product_Composite */
102: $helper = Mage::helper('adminhtml/catalog_product_composite');
103: $helper->renderConfigureResult($this, $configureResult);
104:
105: return $this;
106: }
107:
108: /**
109: * IFrame handler for submitted configuration for wishlist item
110: *
111: * @return false
112: */
113: public function updateAction()
114: {
115: // Update wishlist item
116: $updateResult = new Varien_Object();
117: try {
118: $this->_initData();
119:
120: $buyRequest = new Varien_Object($this->getRequest()->getParams());
121:
122: $this->_wishlist
123: ->updateItem($this->_wishlistItem->getId(), $buyRequest)
124: ->save();
125:
126: $updateResult->setOk(true);
127: } catch (Exception $e) {
128: $updateResult->setError(true);
129: $updateResult->setMessage($e->getMessage());
130: }
131: $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname'));
132: Mage::getSingleton('adminhtml/session')->setCompositeProductResult($updateResult);
133: $this->_redirect('*/catalog_product/showUpdateResult');
134:
135: return false;
136: }
137:
138: /**
139: * Check the permission to Manage Customers
140: *
141: * @return bool
142: */
143: protected function _isAllowed()
144: {
145: return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
146: }
147: }
148: