00001 <?php
00002
00007 class GuestbookEntry extends GuestBook
00008 {
00013 protected $_sThisTemplate = 'guestbookentry.tpl';
00014
00019 protected $_sGbFormId = null;
00020
00028 public function saveEntry()
00029 {
00030 $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) );
00031 $sShopId = $this->getConfig()->getShopId();
00032 $sUserId = oxSession::getVar( 'usr' );
00033
00034
00035 if ( !$sUserId ) {
00036 oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRLOGGINTOWRITEENTRY' );
00037
00038 return;
00039 }
00040
00041 if ( !$sShopId ) {
00042 oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRUNDEFINEDSHOP' );
00043 return 'guestbookentry';
00044 }
00045
00046
00047 if ( '' == $sReviewText ) {
00048 oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRREVIEWCONTAINSNOTEXT' );
00049 return 'guestbookentry';
00050 }
00051
00052
00053 $oEntrie = oxNew( 'oxgbentry' );
00054 if ( $oEntrie->floodProtection( $sShopId, $sUserId ) ) {
00055 oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRMAXIMUMNOMBEREXCEEDED' );
00056 return 'guestbookentry';
00057 }
00058
00059
00060 $sFormId = oxConfig::getParameter( "gbFormId" );
00061 $sSessionFormId = oxSession::getVar( "gbSessionFormId" );
00062 if ( $sFormId && $sFormId == $sSessionFormId ) {
00063
00064 $oEntry = oxNew( 'oxgbentry' );
00065 $oEntry->oxgbentries__oxshopid = new oxField($sShopId);
00066 $oEntry->oxgbentries__oxuserid = new oxField($sUserId);
00067 $oEntry->oxgbentries__oxcontent = new oxField($sReviewText);
00068 $oEntry->save();
00069
00070
00071 $this->getFormId();
00072 }
00073
00074 return 'guestbook';
00075 }
00076
00082 public function getFormId()
00083 {
00084 if ( $this->_sGbFormId === null ) {
00085 $this->_sGbFormId = oxUtilsObject::getInstance()->generateUId();
00086 oxSession::setVar( 'gbSessionFormId', $this->_sGbFormId );
00087 }
00088 return $this->_sGbFormId;
00089 }
00090 }