Go to the documentation of this file.00001 <?php
00002
00009 class oxNews extends oxI18n
00010 {
00016 protected $_oGroups = null;
00017
00023 protected $_sClassName = 'oxnews';
00024
00030 public function __construct()
00031 {
00032 parent::__construct();
00033 $this->init('oxnews');
00034 }
00035
00043 public function assign( $dbRecord )
00044 {
00045
00046 parent::assign( $dbRecord );
00047
00048
00049 if ($this->oxnews__oxdate) {
00050 $this->oxnews__oxdate->setValue( oxRegistry::get("oxUtilsDate")->formatDBDate( $this->oxnews__oxdate->value ) );
00051 }
00052 }
00053
00059 public function getGroups()
00060 {
00061 if ( $this->_oGroups == null && $sOxid = $this->getId() ) {
00062
00063 $this->_oGroups = oxNew( 'oxlist', 'oxgroups' );
00064 $sViewName = getViewName( "oxgroups", $this->getLanguage() );
00065 $sSelect = "select {$sViewName}.* from {$sViewName}, oxobject2group ";
00066 $sSelect .= "where oxobject2group.oxobjectid='$sOxid' ";
00067 $sSelect .= "and oxobject2group.oxgroupsid={$sViewName}.oxid ";
00068 $this->_oGroups->selectString( $sSelect );
00069 }
00070
00071 return $this->_oGroups;
00072 }
00073
00081 public function inGroup( $sGroupID )
00082 {
00083 $blResult = false;
00084 $aGroups = $this->getGroups();
00085 foreach ( $aGroups as $oObject ) {
00086 if ( $oObject->_sOXID == $sGroupID ) {
00087 $blResult = true;
00088 break;
00089 }
00090 }
00091 return $blResult;
00092 }
00093
00101 public function delete( $sOxid = null )
00102 {
00103 if ( !$sOxid ) {
00104 $sOxid = $this->getId();
00105 }
00106 if ( !$sOxid ) {
00107 return false;
00108 }
00109
00110 if ( $blDelete = parent::delete( $sOxid ) ) {
00111 $oDb = oxDb::getDb();
00112 $oDb->execute( "delete from oxobject2group where oxobject2group.oxobjectid = ".$oDb->quote( $sOxid ) );
00113 }
00114
00115
00116 return $blDelete;
00117 }
00118
00124 protected function _update()
00125 {
00126 $this->oxnews__oxdate->setValue( oxRegistry::get("oxUtilsDate")->formatDBDate( $this->oxnews__oxdate->value, true ) );
00127
00128
00129 parent::_update();
00130 }
00131
00137 protected function _insert()
00138 {
00139 if ( !$this->oxnews__oxdate || oxRegistry::get("oxUtilsDate")->isEmptyDate( $this->oxnews__oxdate->value ) ) {
00140
00141 $this->oxnews__oxdate = new oxField( date( 'Y-m-d' ) );
00142 } else {
00143 $this->oxnews__oxdate = new oxField( oxRegistry::get("oxUtilsDate")->formatDBDate( $this->oxnews__oxdate->value, true ) );
00144 }
00145
00146
00147 return parent::_insert();
00148 }
00149
00159 protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00160 {
00161 switch (strtolower($sFieldName)) {
00162 case 'oxlongdesc':
00163 case 'oxnews__oxlongdesc':
00164 $iDataType = oxField::T_RAW;
00165 break;
00166 }
00167 return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00168 }
00169
00175 public function getLongDesc()
00176 {
00177 return oxRegistry::get("oxUtilsView")->parseThroughSmarty( $this->oxnews__oxlongdesc->getRawValue(), $this->getId().$this->getLanguage() );
00178 }
00179
00180 }