oxnews.php

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

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