Public Member Functions | |
indexAction () | |
viewAction () | |
editAction () | |
removeAction () | |
saveAction () | |
Protected Member Functions | |
_getTagId () |
Definition at line 35 of file CustomerController.php.
_getTagId | ( | ) | [protected] |
Definition at line 37 of file CustomerController.php.
00038 { 00039 $tagId = (int) $this->getRequest()->getParam('tagId'); 00040 if ($tagId) { 00041 $customerId = Mage::getSingleton('customer/session')->getCustomerId(); 00042 $model = Mage::getModel('tag/tag_relation'); 00043 $model->loadByTagCustomer(null, $tagId, $customerId); 00044 Mage::register('tagModel', $model); 00045 return $model->getTagId(); 00046 } 00047 return false; 00048 }
editAction | ( | ) |
Definition at line 97 of file CustomerController.php.
00098 { 00099 if( !Mage::getSingleton('customer/session')->getCustomerId() ) { 00100 Mage::getSingleton('customer/session')->authenticate($this); 00101 return; 00102 } 00103 00104 if ($tagId = $this->_getTagId()) { 00105 $this->loadLayout(); 00106 $this->_initLayoutMessages('tag/session'); 00107 $this->_initLayoutMessages('customer/session'); 00108 if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { 00109 $navigationBlock->setActive('tag/customer'); 00110 } 00111 $this->renderLayout(); 00112 } 00113 else { 00114 $this->_forward('noRoute'); 00115 } 00116 }
indexAction | ( | ) |
Definition at line 50 of file CustomerController.php.
00051 { 00052 if( !Mage::getSingleton('customer/session')->getCustomerId() ) { 00053 Mage::getSingleton('customer/session')->authenticate($this); 00054 return; 00055 } 00056 00057 $this->loadLayout(); 00058 $this->_initLayoutMessages('tag/session'); 00059 $this->_initLayoutMessages('catalog/session'); 00060 00061 if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { 00062 $navigationBlock->setActive('tag/customer'); 00063 } 00064 00065 if ($block = $this->getLayout()->getBlock('customer_tags')) { 00066 $block->setRefererUrl($this->_getRefererUrl()); 00067 } 00068 00069 $this->getLayout()->getBlock('head')->setTitle(Mage::helper('tag')->__('My Tags')); 00070 $this->renderLayout(); 00071 }
removeAction | ( | ) |
Definition at line 118 of file CustomerController.php.
00119 { 00120 if( !Mage::getSingleton('customer/session')->getCustomerId() ) { 00121 Mage::getSingleton('customer/session')->authenticate($this); 00122 return; 00123 } 00124 00125 if ($tagId = $this->_getTagId()) { 00126 try { 00127 $model = Mage::registry('tagModel'); 00128 $model->deactivate(); 00129 $tag = Mage::getModel('tag/tag')->load($tagId)->aggregate(); 00130 Mage::getSingleton('tag/session')->addSuccess(Mage::helper('tag')->__('Your tag was successfully deleted')); 00131 $this->getResponse()->setRedirect(Mage::getUrl('*/*/', array( 00132 self::PARAM_NAME_URL_ENCODED => Mage::helper('core')->urlEncode(Mage::getUrl('customer/account/')) 00133 ))); 00134 //$this-> 00135 return; 00136 } catch (Exception $e) { 00137 Mage::getSingleton('tag/session')->addError(Mage::helper('tag')->__('Unable to remove tag. Please, try again later.')); 00138 } 00139 } 00140 else { 00141 $this->_forward('noRoute'); 00142 } 00143 }
saveAction | ( | ) |
Definition at line 145 of file CustomerController.php.
00146 { 00147 if( !Mage::getSingleton('customer/session')->getCustomerId() ) { 00148 Mage::getSingleton('customer/session')->authenticate($this); 00149 return; 00150 } 00151 00152 $tagId = (int) $this->getRequest()->getParam('tagId'); 00153 $customerId = Mage::getSingleton('customer/session')->getCustomerId(); 00154 $tagName = (string) $this->getRequest()->getPost('productTagName'); 00155 00156 if (strlen($tagName) === 0) { 00157 Mage::getSingleton('tag/session')->addError(Mage::helper('tag')->__('Tag can\'t be empty.')); 00158 $this->_redirect('*/*/edit', array('tagId'=>$tagId)); 00159 return; 00160 } 00161 00162 if($tagId) { 00163 try { 00164 $productId = 0; 00165 $isNew = false; 00166 $message = false; 00167 $storeId = Mage::app()->getStore()->getId(); 00168 00169 $tagModel = Mage::getModel('tag/tag'); 00170 $tagModel->load($tagId); 00171 00172 if( $tagModel->getName() != $tagName ) { 00173 $tagModel->loadByName($tagName); 00174 00175 if($tagModel->getId()) { 00176 $status = $tagModel->getStatus(); 00177 } 00178 else { 00179 $isNew = true; 00180 $message= Mage::helper('tag')->__('Thank you. Your tag has been accepted for moderation.'); 00181 $status = $tagModel->getPendingStatus(); 00182 } 00183 00184 $tagModel->setName($tagName) 00185 ->setStatus($status) 00186 ->setStoreId($storeId) 00187 ->save(); 00188 } 00189 00190 $tagRalationModel = Mage::getModel('tag/tag_relation'); 00191 $tagRalationModel->loadByTagCustomer(null, $tagId, $customerId, $storeId); 00192 00193 if ($tagRalationModel->getCustomerId() == $customerId ) { 00194 $productIds = $tagRalationModel->getProductIds(); 00195 if ($tagRalationModel->getTagId()!=$tagModel->getId()) { 00196 $tagRalationModel->deactivate(); 00197 } else { 00198 $tagRalationModel->delete(); 00199 } 00200 00201 foreach ($productIds as $productId) { 00202 $newTagRalationModel = Mage::getModel('tag/tag_relation') 00203 ->setTagId($tagModel->getId()) 00204 ->setCustomerId($customerId) 00205 ->setStoreId($storeId) 00206 ->setActive(true) 00207 ->setProductId($productId) 00208 ->save(); 00209 } 00210 } 00211 00212 if( $tagModel->getId() ) { 00213 $tagModel->aggregate(); 00214 $this->getResponse()->setRedirect(Mage::getUrl('*/*/')); 00215 } 00216 $message = ($message) ? $message : Mage::helper('tag')->__('Your tag was successfully saved'); 00217 Mage::getSingleton('tag/session')->addSuccess($message); 00218 $this->_redirect('*/*/'); 00219 return; 00220 } catch (Exception $e) { 00221 Mage::getSingleton('tag/session')->addError( 00222 Mage::helper('tag')->__('Unable to save your tag. Please, try again later.') 00223 ); 00224 } 00225 } 00226 $this->_redirectReferer(); 00227 }
viewAction | ( | ) |
Definition at line 73 of file CustomerController.php.
00074 { 00075 if( !Mage::getSingleton('customer/session')->getCustomerId() ) { 00076 Mage::getSingleton('customer/session')->authenticate($this); 00077 return; 00078 } 00079 if ($tagId = $this->_getTagId()) { 00080 Mage::register('tagId', $tagId); 00081 $this->loadLayout(); 00082 $this->_initLayoutMessages('tag/session'); 00083 00084 if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) { 00085 $navigationBlock->setActive('tag/customer'); 00086 } 00087 00088 $this->_initLayoutMessages('checkout/session'); 00089 $this->getLayout()->getBlock('head')->setTitle(Mage::helper('tag')->__('My Tags')); 00090 $this->renderLayout(); 00091 } 00092 else { 00093 $this->_forward('noRoute'); 00094 } 00095 }