Go to the documentation of this file.00001 <?php
00002
00012 class Account_Wishlist extends Account
00013 {
00019 protected $_sThisTemplate = 'page/account/wishlist.tpl';
00020
00026 protected $_blShowSuggest = null;
00027
00033 protected $_oWishList = null;
00034
00040 protected $_aRecommList = null;
00041
00047 protected $_oEditval = null;
00048
00054 protected $_iSendWishList = null;
00055
00061 protected $_sSearchParam = null;
00062
00068 protected $_oWishListUsers = false;
00069
00075 protected $_blEmailSent = false;
00076
00082 protected $_aEditValues = false;
00083
00089 protected $_aSimilarRecommListIds = null;
00090
00096 protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00097
00106 public function render()
00107 {
00108 parent::render();
00109
00110
00111 $oUser = $this->getUser();
00112 if ( !$oUser ) {
00113 return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00114 }
00115
00116 return $this->_sThisTemplate;
00117 }
00118
00124 public function showSuggest()
00125 {
00126 if ( $this->_blShowSuggest === null ) {
00127 $this->_blShowSuggest = ( bool ) oxConfig::getParameter( 'blshowsuggest' );
00128 }
00129 return $this->_blShowSuggest;
00130 }
00131
00137 public function getWishList()
00138 {
00139 if ( $this->_oWishList === null ) {
00140 $this->_oWishList = false;
00141 if ( $oUser = $this->getUser() ) {
00142 $this->_oWishList = $oUser->getBasket( 'wishlist' );
00143 if ( $this->_oWishList->isEmpty() ) {
00144 $this->_oWishList = false;
00145 }
00146 }
00147 }
00148
00149 return $this->_oWishList;
00150 }
00151
00157 public function getWishProductList()
00158 {
00159 if ( $this->_aWishProductList === null ) {
00160 $this->_aWishProductList = false;
00161 if ( $oWishList = $this->getWishList() ) {
00162 $this->_aWishProductList = $oWishList->getArticles();
00163 }
00164 }
00165 return $this->_aWishProductList;
00166 }
00167
00173 public function getSimilarRecommListIds()
00174 {
00175 if ( $this->_aSimilarRecommListIds === null ) {
00176 $this->_aSimilarRecommListIds = false;
00177
00178 $aWishProdList = $this->getWishProductList();
00179 if ( is_array( $aWishProdList ) && ( $oSimilarProd = current( $aWishProdList ) ) ) {
00180 $this->_aSimilarRecommListIds = array( $oSimilarProd->getId() );
00181 }
00182 }
00183
00184 return $this->_aSimilarRecommListIds;
00185 }
00186
00192 public function sendWishList()
00193 {
00194 $aParams = oxConfig::getParameter( 'editval', true );
00195 if ( is_array( $aParams ) ) {
00196
00197 $oParams = ( object ) $aParams;
00198 $this->setEnteredData( ( object ) oxConfig::getParameter( 'editval' ) );
00199
00200 if ( !isset( $aParams['rec_name'] ) || !isset( $aParams['rec_email'] ) ||
00201 !$aParams['rec_name'] || !$aParams['rec_email'] ) {
00202 return oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY', false, true );
00203 } else {
00204
00205 if ( $oUser = $this->getUser() ) {
00206 $oParams->send_email = $oUser->oxuser__oxusername->value;
00207 $oParams->send_name = $oUser->oxuser__oxfname->getRawValue().' '.$oUser->oxuser__oxlname->getRawValue();
00208 $oParams->send_id = $oUser->getId();
00209
00210 $this->_blEmailSent = oxNew( 'oxemail' )->sendWishlistMail( $oParams );
00211 if ( !$this->_blEmailSent ) {
00212 return oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_CHECK_EMAIL', false, true );
00213 }
00214 }
00215 }
00216 }
00217 }
00218
00224 public function isWishListEmailSent()
00225 {
00226 return $this->_blEmailSent;
00227 }
00228
00236 public function setEnteredData( $oData )
00237 {
00238 $this->_aEditValues = $oData;
00239 }
00240
00246 public function getEnteredData()
00247 {
00248 return $this->_aEditValues;
00249 }
00250
00257 public function togglePublic()
00258 {
00259 if ( $oUser = $this->getUser() ) {
00260
00261 $blPublic = (int) oxConfig::getParameter( 'blpublic' );
00262 $oBasket = $oUser->getBasket( 'wishlist' );
00263 $oBasket->oxuserbaskets__oxpublic = new oxField( ( $blPublic == 1 ) ? $blPublic : 0 );
00264 $oBasket->save();
00265 }
00266 }
00267
00274 public function searchForWishList()
00275 {
00276 if ( $sSearch = oxConfig::getParameter( 'search' ) ) {
00277
00278
00279 $oUserList = oxNew( 'oxuserlist' );
00280 $oUserList->loadWishlistUsers( $sSearch );
00281 if ( $oUserList->count() ) {
00282 $this->_oWishListUsers = $oUserList;
00283 }
00284
00285 $this->_sSearchParam = $sSearch;
00286 }
00287 }
00288
00295 public function getWishListUsers()
00296 {
00297 return $this->_oWishListUsers;
00298 }
00299
00305 public function getWishListSearchParam()
00306 {
00307 return $this->_sSearchParam;
00308 }
00309
00315 public function getBreadCrumb()
00316 {
00317 $aPaths = array();
00318 $aPath = array();
00319
00320 $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_ACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false );
00321 $aPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
00322 $aPaths[] = $aPath;
00323
00324 $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_GIFT_REGISTRY', oxRegistry::getLang()->getBaseLanguage(), false );
00325 $aPath['link'] = $this->getLink();
00326 $aPaths[] = $aPath;
00327
00328 return $aPaths;
00329 }
00330 }