guestbookentry.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class GuestbookEntry extends GuestBook
00008 {
00013     protected $_sThisTemplate = 'guestbookentry.tpl';
00014 
00022     public function saveEntry()
00023     {
00024         $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt' , true ) );
00025         $sShopId     = $this->getConfig()->getShopId();
00026         $sUserId     = oxSession::getVar( 'usr' );
00027 
00028         // guest book`s entry is validated
00029         if ( !$sUserId ) {
00030             oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRLOGGINTOWRITEENTRY' );
00031             //return to same page
00032             return;
00033         }
00034 
00035         if ( !$sShopId ) {
00036             oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRUNDEFINEDSHOP' );
00037             return 'guestbookentry';
00038         }
00039 
00040         // empty entries validation
00041         if ( '' == $sReviewText ) {
00042             oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRREVIEWCONTAINSNOTEXT' );
00043             return 'guestbookentry';
00044         }
00045 
00046         // flood protection
00047 
00048         $oEntrie = oxNew( 'oxgbentry' );
00049         if ( $oEntrie->floodProtection( $sShopId, $sUserId ) ) {
00050             oxUtilsView::getInstance()->addErrorToDisplay( 'GUESTBOOKENTRY_ERRMAXIMUMNOMBEREXCEEDED' );
00051             return 'guestbookentry';
00052         }
00053 
00054         // here the guest book entry is saved
00055         $oEntry = oxNew( 'oxgbentry' );
00056         $oEntry->oxgbentries__oxshopid  = new oxField($sShopId);
00057         $oEntry->oxgbentries__oxuserid  = new oxField($sUserId);
00058         $oEntry->oxgbentries__oxcontent = new oxField($sReviewText);
00059         $oEntry->save();
00060 
00061         return 'guestbook';
00062     }
00063 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5