Go to the documentation of this file.00001 <?php
00002
00012 class Account_Wishlist extends Account
00013 {
00014
00020 protected $_sThisTemplate = 'page/account/wishlist.tpl';
00021
00027 protected $_blShowSuggest = null;
00028
00034 protected $_oWishList = null;
00035
00041 protected $_aRecommList = null;
00042
00048 protected $_oEditval = null;
00049
00055 protected $_iSendWishList = null;
00056
00062 protected $_sSearchParam = null;
00063
00069 protected $_oWishListUsers = false;
00070
00076 protected $_blEmailSent = false;
00077
00083 protected $_aEditValues = false;
00084
00090 protected $_aSimilarRecommListIds = null;
00091
00097 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00098
00107 public function render()
00108 {
00109 parent::render();
00110
00111
00112 $oUser = $this->getUser();
00113 if (!$oUser) {
00114 return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00115 }
00116
00117 return $this->_sThisTemplate;
00118 }
00119
00125 public function showSuggest()
00126 {
00127 if ($this->_blShowSuggest === null) {
00128 $this->_blShowSuggest = ( bool ) oxRegistry::getConfig()->getRequestParameter('blshowsuggest');
00129 }
00130
00131 return $this->_blShowSuggest;
00132 }
00133
00139 public function getWishList()
00140 {
00141 if ($this->_oWishList === null) {
00142 $this->_oWishList = false;
00143 if ($oUser = $this->getUser()) {
00144 $this->_oWishList = $oUser->getBasket('wishlist');
00145 if ($this->_oWishList->isEmpty()) {
00146 $this->_oWishList = false;
00147 }
00148 }
00149 }
00150
00151 return $this->_oWishList;
00152 }
00153
00159 public function getWishProductList()
00160 {
00161 if ($this->_aWishProductList === null) {
00162 $this->_aWishProductList = false;
00163 if ($oWishList = $this->getWishList()) {
00164 $this->_aWishProductList = $oWishList->getArticles();
00165 }
00166 }
00167
00168 return $this->_aWishProductList;
00169 }
00170
00176 public function getSimilarRecommListIds()
00177 {
00178 if ($this->_aSimilarRecommListIds === null) {
00179 $this->_aSimilarRecommListIds = false;
00180
00181 $aWishProdList = $this->getWishProductList();
00182 if (is_array($aWishProdList) && ($oSimilarProd = current($aWishProdList))) {
00183 $this->_aSimilarRecommListIds = array($oSimilarProd->getId());
00184 }
00185 }
00186
00187 return $this->_aSimilarRecommListIds;
00188 }
00189
00195 public function sendWishList()
00196 {
00197 if (!oxRegistry::getSession()->checkSessionChallenge()) {
00198 return false;
00199 }
00200
00201 $aParams = oxRegistry::getConfig()->getRequestParameter('editval', true);
00202 if (is_array($aParams)) {
00203 $oUtilsView = oxRegistry::get("oxUtilsView");
00204 $oParams = ( object ) $aParams;
00205 $this->setEnteredData(( object ) oxRegistry::getConfig()->getRequestParameter('editval'));
00206
00207 if (!isset($aParams['rec_name']) || !isset($aParams['rec_email']) ||
00208 !$aParams['rec_name'] || !$aParams['rec_email']
00209 ) {
00210 return $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY', false, true);
00211 } else {
00212
00213 if ($oUser = $this->getUser()) {
00214 $sFirstName = 'oxuser__oxfname';
00215 $sLastName = 'oxuser__oxlname';
00216 $sSendName = 'send_name';
00217 $sSendEmail = 'send_email';
00218 $sUserNameField = 'oxuser__oxusername';
00219 $sSendName = 'send_name';
00220 $sSendId = 'send_id';
00221
00222 $oParams->$sSendEmail = $oUser->$sUserNameField->value;
00223 $oParams->$sSendName = $oUser->$sFirstName->getRawValue() . ' ' . $oUser->$sLastName->getRawValue();
00224 $oParams->$sSendId = $oUser->getId();
00225
00226 $this->_blEmailSent = oxNew('oxemail')->sendWishlistMail($oParams);
00227 if (!$this->_blEmailSent) {
00228 return $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL', false, true);
00229 }
00230 }
00231 }
00232 }
00233 }
00234
00240 public function isWishListEmailSent()
00241 {
00242 return $this->_blEmailSent;
00243 }
00244
00250 public function setEnteredData($oData)
00251 {
00252 $this->_aEditValues = $oData;
00253 }
00254
00260 public function getEnteredData()
00261 {
00262 return $this->_aEditValues;
00263 }
00264
00271 public function togglePublic()
00272 {
00273 if (!oxRegistry::getSession()->checkSessionChallenge()) {
00274 return false;
00275 }
00276
00277 if ($oUser = $this->getUser()) {
00278
00279 $blPublic = (int) oxRegistry::getConfig()->getRequestParameter('blpublic');
00280 $oBasket = $oUser->getBasket('wishlist');
00281 $oBasket->oxuserbaskets__oxpublic = new oxField(($blPublic == 1) ? $blPublic : 0);
00282 $oBasket->save();
00283 }
00284 }
00285
00290 public function searchForWishList()
00291 {
00292 if ($sSearch = oxRegistry::getConfig()->getRequestParameter('search')) {
00293
00294
00295 $oUserList = oxNew('oxuserlist');
00296 $oUserList->loadWishlistUsers($sSearch);
00297 if ($oUserList->count()) {
00298 $this->_oWishListUsers = $oUserList;
00299 }
00300
00301 $this->_sSearchParam = $sSearch;
00302 }
00303 }
00304
00311 public function getWishListUsers()
00312 {
00313 return $this->_oWishListUsers;
00314 }
00315
00321 public function getWishListSearchParam()
00322 {
00323 return $this->_sSearchParam;
00324 }
00325
00331 public function getBreadCrumb()
00332 {
00333 $aPaths = array();
00334 $aPath = array();
00335
00336 $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
00337 $sSelfLink = $this->getViewConfig()->getSelfLink();
00338
00339 $aPath['title'] = oxRegistry::getLang()->translateString('MY_ACCOUNT', $iBaseLanguage, false);
00340 $aPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sSelfLink . 'cl=account');
00341 $aPaths[] = $aPath;
00342
00343 $aPath['title'] = oxRegistry::getLang()->translateString('MY_GIFT_REGISTRY', $iBaseLanguage, false);
00344 $aPath['link'] = $this->getLink();
00345 $aPaths[] = $aPath;
00346
00347 return $aPaths;
00348 }
00349 }