OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
account_wishlist.php
Go to the documentation of this file.
1 <?php
2 
13 {
19  protected $_sThisTemplate = 'page/account/wishlist.tpl';
20 
26  protected $_blShowSuggest = null;
27 
33  protected $_oWishList = null;
34 
40  protected $_aRecommList = null;
41 
47  protected $_oEditval = null;
48 
54  protected $_iSendWishList = null;
55 
61  protected $_sSearchParam = null;
62 
68  protected $_oWishListUsers = false;
69 
75  protected $_blEmailSent = false;
76 
82  protected $_aEditValues = false;
83 
89  protected $_aSimilarRecommListIds = null;
90 
97 
106  public function render()
107  {
108  parent::render();
109 
110  // is logged in ?
111  $oUser = $this->getUser();
112  if ( !$oUser ) {
113  return $this->_sThisTemplate = $this->_sThisLoginTemplate;
114  }
115 
116  return $this->_sThisTemplate;
117  }
118 
124  public function showSuggest()
125  {
126  if ( $this->_blShowSuggest === null ) {
127  $this->_blShowSuggest = ( bool ) oxConfig::getParameter( 'blshowsuggest' );
128  }
129  return $this->_blShowSuggest;
130  }
131 
137  public function getWishList()
138  {
139  if ( $this->_oWishList === null ) {
140  $this->_oWishList = false;
141  if ( $oUser = $this->getUser() ) {
142  $this->_oWishList = $oUser->getBasket( 'wishlist' );
143  if ( $this->_oWishList->isEmpty() ) {
144  $this->_oWishList = false;
145  }
146  }
147  }
148 
149  return $this->_oWishList;
150  }
151 
157  public function getWishProductList()
158  {
159  if ( $this->_aWishProductList === null ) {
160  $this->_aWishProductList = false;
161  if ( $oWishList = $this->getWishList() ) {
162  $this->_aWishProductList = $oWishList->getArticles();
163  }
164  }
165  return $this->_aWishProductList;
166  }
167 
173  public function getSimilarRecommListIds()
174  {
175  if ( $this->_aSimilarRecommListIds === null ) {
176  $this->_aSimilarRecommListIds = false;
177 
178  $aWishProdList = $this->getWishProductList();
179  if ( is_array( $aWishProdList ) && ( $oSimilarProd = current( $aWishProdList ) ) ) {
180  $this->_aSimilarRecommListIds = array( $oSimilarProd->getId() );
181  }
182  }
183 
185  }
186 
192  public function sendWishList()
193  {
194  if (!oxRegistry::getSession()->checkSessionChallenge()) {
195  return false;
196  }
197 
198  $aParams = oxConfig::getParameter( 'editval', true );
199  if ( is_array( $aParams ) ) {
200 
201  $oParams = ( object ) $aParams;
202  $this->setEnteredData( ( object ) oxConfig::getParameter( 'editval' ) );
203 
204  if ( !isset( $aParams['rec_name'] ) || !isset( $aParams['rec_email'] ) ||
205  !$aParams['rec_name'] || !$aParams['rec_email'] ) {
206  return oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY', false, true );
207  } else {
208 
209  if ( $oUser = $this->getUser() ) {
210  $oParams->send_email = $oUser->oxuser__oxusername->value;
211  $oParams->send_name = $oUser->oxuser__oxfname->getRawValue().' '.$oUser->oxuser__oxlname->getRawValue();
212  $oParams->send_id = $oUser->getId();
213 
214  $this->_blEmailSent = oxNew( 'oxemail' )->sendWishlistMail( $oParams );
215  if ( !$this->_blEmailSent ) {
216  return oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'ERROR_MESSAGE_CHECK_EMAIL', false, true );
217  }
218  }
219  }
220  }
221  }
222 
228  public function isWishListEmailSent()
229  {
230  return $this->_blEmailSent;
231  }
232 
240  public function setEnteredData( $oData )
241  {
242  $this->_aEditValues = $oData;
243  }
244 
250  public function getEnteredData()
251  {
252  return $this->_aEditValues;
253  }
254 
261  public function togglePublic()
262  {
263  if (!oxRegistry::getSession()->checkSessionChallenge()) {
264  return false;
265  }
266 
267  if ( $oUser = $this->getUser() ) {
268 
269  $blPublic = (int) oxConfig::getParameter( 'blpublic' );
270  $oBasket = $oUser->getBasket( 'wishlist' );
271  $oBasket->oxuserbaskets__oxpublic = new oxField( ( $blPublic == 1 ) ? $blPublic : 0 );
272  $oBasket->save();
273  }
274  }
275 
282  public function searchForWishList()
283  {
284  if ( $sSearch = oxConfig::getParameter( 'search' ) ) {
285 
286  // search for baskets
287  $oUserList = oxNew( 'oxuserlist' );
288  $oUserList->loadWishlistUsers( $sSearch );
289  if ( $oUserList->count() ) {
290  $this->_oWishListUsers = $oUserList;
291  }
292 
293  $this->_sSearchParam = $sSearch;
294  }
295  }
296 
303  public function getWishListUsers()
304  {
305  return $this->_oWishListUsers;
306  }
307 
313  public function getWishListSearchParam()
314  {
315  return $this->_sSearchParam;
316  }
317 
323  public function getBreadCrumb()
324  {
325  $aPaths = array();
326  $aPath = array();
327 
328  $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_ACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false );
329  $aPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
330  $aPaths[] = $aPath;
331 
332  $aPath['title'] = oxRegistry::getLang()->translateString( 'MY_GIFT_REGISTRY', oxRegistry::getLang()->getBaseLanguage(), false );
333  $aPath['link'] = $this->getLink();
334  $aPaths[] = $aPath;
335 
336  return $aPaths;
337  }
338 }