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
00050 $this->oxnews__oxdate->setValue( oxUtilsDate::getInstance()->formatDBDate( $this->oxnews__oxdate->value ) );
00051
00052
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
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 $oDb = oxDb::getDb();
00115 $oDb->execute( "delete from oxobject2group where oxobject2group.oxobjectid = ".$oDb->quote( $sOxid ) );
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 if ( !$this->oxnews__oxdate || oxUtilsDate::getInstance()->isEmptyDate( $this->oxnews__oxdate->value ) ) {
00140
00141 $this->oxnews__oxdate = new oxField( date( 'Y-m-d' ) );
00142 } else {
00143 $this->oxnews__oxdate = new oxField( oxUtilsDate::getInstance()->formatDBDate( $this->oxnews__oxdate->value, true ) );
00144 }
00145
00146 return parent::_insert();
00147 }
00148
00158 protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00159 {
00160 switch (strtolower($sFieldName)) {
00161 case 'oxshortdesc':
00162 case 'oxlongdesc':
00163 case 'oxnews__oxlongdesc':
00164 case 'oxnews__oxshortdesc':
00165 $iDataType = oxField::T_RAW;
00166 break;
00167 }
00168 return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00169 }
00170 }