OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
account_wishlist.php
Go to the documentation of this file.
1 <?php
2 
13 {
14 
20  protected $_sThisTemplate = 'page/account/wishlist.tpl';
21 
27  protected $_blShowSuggest = null;
28 
34  protected $_oWishList = null;
35 
41  protected $_aRecommList = null;
42 
48  protected $_oEditval = null;
49 
55  protected $_iSendWishList = null;
56 
62  protected $_sSearchParam = null;
63 
69  protected $_oWishListUsers = false;
70 
76  protected $_blEmailSent = false;
77 
83  protected $_aEditValues = false;
84 
90  protected $_aSimilarRecommListIds = null;
91 
98 
107  public function render()
108  {
109  parent::render();
110 
111  // is logged in ?
112  $oUser = $this->getUser();
113  if (!$oUser) {
114  return $this->_sThisTemplate = $this->_sThisLoginTemplate;
115  }
116 
117  return $this->_sThisTemplate;
118  }
119 
125  public function showSuggest()
126  {
127  if ($this->_blShowSuggest === null) {
128  $this->_blShowSuggest = ( bool ) oxRegistry::getConfig()->getRequestParameter('blshowsuggest');
129  }
130 
131  return $this->_blShowSuggest;
132  }
133 
139  public function getWishList()
140  {
141  if ($this->_oWishList === null) {
142  $this->_oWishList = false;
143  if ($oUser = $this->getUser()) {
144  $this->_oWishList = $oUser->getBasket('wishlist');
145  if ($this->_oWishList->isEmpty()) {
146  $this->_oWishList = false;
147  }
148  }
149  }
150 
151  return $this->_oWishList;
152  }
153 
159  public function getWishProductList()
160  {
161  if ($this->_aWishProductList === null) {
162  $this->_aWishProductList = false;
163  if ($oWishList = $this->getWishList()) {
164  $this->_aWishProductList = $oWishList->getArticles();
165  }
166  }
167 
168  return $this->_aWishProductList;
169  }
170 
176  public function getSimilarRecommListIds()
177  {
178  if ($this->_aSimilarRecommListIds === null) {
179  $this->_aSimilarRecommListIds = false;
180 
181  $aWishProdList = $this->getWishProductList();
182  if (is_array($aWishProdList) && ($oSimilarProd = current($aWishProdList))) {
183  $this->_aSimilarRecommListIds = array($oSimilarProd->getId());
184  }
185  }
186 
188  }
189 
195  public function sendWishList()
196  {
197  if (!oxRegistry::getSession()->checkSessionChallenge()) {
198  return false;
199  }
200 
201  $aParams = oxRegistry::getConfig()->getRequestParameter('editval', true);
202  if (is_array($aParams)) {
203  $oUtilsView = oxRegistry::get("oxUtilsView");
204  $oParams = ( object ) $aParams;
205  $this->setEnteredData(( object ) oxRegistry::getConfig()->getRequestParameter('editval'));
206 
207  if (!isset($aParams['rec_name']) || !isset($aParams['rec_email']) ||
208  !$aParams['rec_name'] || !$aParams['rec_email']
209  ) {
210  return $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY', false, true);
211  } else {
212 
213  if ($oUser = $this->getUser()) {
214  $sFirstName = 'oxuser__oxfname';
215  $sLastName = 'oxuser__oxlname';
216  $sSendName = 'send_name';
217  $sSendEmail = 'send_email';
218  $sUserNameField = 'oxuser__oxusername';
219  $sSendName = 'send_name';
220  $sSendId = 'send_id';
221 
222  $oParams->$sSendEmail = $oUser->$sUserNameField->value;
223  $oParams->$sSendName = $oUser->$sFirstName->getRawValue() . ' ' . $oUser->$sLastName->getRawValue();
224  $oParams->$sSendId = $oUser->getId();
225 
226  $this->_blEmailSent = oxNew('oxemail')->sendWishlistMail($oParams);
227  if (!$this->_blEmailSent) {
228  return $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL', false, true);
229  }
230  }
231  }
232  }
233  }
234 
240  public function isWishListEmailSent()
241  {
242  return $this->_blEmailSent;
243  }
244 
250  public function setEnteredData($oData)
251  {
252  $this->_aEditValues = $oData;
253  }
254 
260  public function getEnteredData()
261  {
262  return $this->_aEditValues;
263  }
264 
271  public function togglePublic()
272  {
273  if (!oxRegistry::getSession()->checkSessionChallenge()) {
274  return false;
275  }
276 
277  if ($oUser = $this->getUser()) {
278 
279  $blPublic = (int) oxRegistry::getConfig()->getRequestParameter('blpublic');
280  $oBasket = $oUser->getBasket('wishlist');
281  $oBasket->oxuserbaskets__oxpublic = new oxField(($blPublic == 1) ? $blPublic : 0);
282  $oBasket->save();
283  }
284  }
285 
290  public function searchForWishList()
291  {
292  if ($sSearch = oxRegistry::getConfig()->getRequestParameter('search')) {
293 
294  // search for baskets
295  $oUserList = oxNew('oxuserlist');
296  $oUserList->loadWishlistUsers($sSearch);
297  if ($oUserList->count()) {
298  $this->_oWishListUsers = $oUserList;
299  }
300 
301  $this->_sSearchParam = $sSearch;
302  }
303  }
304 
311  public function getWishListUsers()
312  {
313  return $this->_oWishListUsers;
314  }
315 
321  public function getWishListSearchParam()
322  {
323  return $this->_sSearchParam;
324  }
325 
331  public function getBreadCrumb()
332  {
333  $aPaths = array();
334  $aPath = array();
335 
336  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
337  $sSelfLink = $this->getViewConfig()->getSelfLink();
338 
339  $aPath['title'] = oxRegistry::getLang()->translateString('MY_ACCOUNT', $iBaseLanguage, false);
340  $aPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sSelfLink . 'cl=account');
341  $aPaths[] = $aPath;
342 
343  $aPath['title'] = oxRegistry::getLang()->translateString('MY_GIFT_REGISTRY', $iBaseLanguage, false);
344  $aPath['link'] = $this->getLink();
345  $aPaths[] = $aPath;
346 
347  return $aPaths;
348  }
349 }