oxnews.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class oxNews extends oxI18n
00011 {
00017     protected $_oGroups  = null;
00018 
00024     protected $_sClassName = 'oxnews';
00025 
00031     public function __construct()
00032     {
00033         parent::__construct();
00034         $this->init('oxnews');
00035     }
00036 
00044     public function assign( $dbRecord )
00045     {
00046 
00047         parent::assign( $dbRecord );
00048 
00049         // convert date's to international format
00050         $this->oxnews__oxdate->setValue( oxUtilsDate::getInstance()->formatDBDate( $this->oxnews__oxdate->value ) );
00051 
00052         // #1030C run through smarty
00053         if ( !$this->isAdmin() && $this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00054             $this->oxnews__oxlongdesc->setValue(oxUtilsView::getInstance()->parseThroughSmarty( $this->oxnews__oxlongdesc->value, $this->getId() ), oxField::T_RAW);
00055         }
00056     }
00057 
00063     public function getGroups()
00064     {
00065         if ( $this->_oGroups == null && $sOxid = $this->getId() ) {
00066             // usergroups
00067             $this->_oGroups = oxNew( 'oxlist', 'oxgroups' );
00068             $sSelect  = "select oxgroups.* from oxgroups, oxobject2group ";
00069             $sSelect .= "where oxobject2group.oxobjectid='$sOxid' ";
00070             $sSelect .= "and oxobject2group.oxgroupsid=oxgroups.oxid ";
00071             $this->_oGroups->selectString( $sSelect );
00072         }
00073 
00074         return $this->_oGroups;
00075     }
00076 
00084     public function inGroup( $sGroupID )
00085     {
00086         $blResult = false;
00087         $aGroups  = &$this->getGroups();
00088         foreach ( $aGroups as $oObject ) {
00089             if ( $oObject->_sOXID == $sGroupID ) {
00090                 $blResult = true;
00091                 break;
00092             }
00093         }
00094         return $blResult;
00095     }
00096 
00104     public function delete( $sOxid = null )
00105     {
00106         if ( !$sOxid ) {
00107             $sOxid = $this->getId();
00108         }
00109         if ( !$sOxid ) {
00110             return false;
00111         }
00112 
00113         if ( $blDelete = parent::delete( $sOxid ) ) {
00114             $sQ = "delete from oxobject2group where oxobject2group.oxobjectid = '$sOxid' ";
00115             oxDb::getDb()->execute( $sQ );
00116         }
00117         return $blDelete;
00118     }
00119 
00125     protected function _update()
00126     {
00127         $this->oxnews__oxdate->setValue( oxUtilsDate::getInstance()->formatDBDate( $this->oxnews__oxdate->value, true ) );
00128 
00129         parent::_update();
00130     }
00131 
00137     protected function _insert()
00138     {
00139         // setting insert time
00140         $this->oxnews__oxdate = new oxField( date( 'Y-m-d' ) );
00141         return parent::_insert();
00142     }
00152     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00153     {
00154         switch (strtolower($sFieldName)) {
00155             case 'oxshortdesc':
00156             case 'oxlongdesc':
00157             case 'oxnews__oxlongdesc':
00158             case 'oxnews__oxshortdesc':
00159                 $iDataType = oxField::T_RAW;
00160                 break;
00161         }
00162         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00163     }
00164 }

Generated on Tue Aug 18 09:21:05 2009 for OXID eShop CE by  doxygen 1.5.5