Go to the documentation of this file.00001 <?php
00002
00009 class oxNews extends oxI18n
00010 {
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 if ($this->oxnews__oxdate) {
00051 $this->oxnews__oxdate->setValue(oxRegistry::get("oxUtilsDate")->formatDBDate($this->oxnews__oxdate->value));
00052 }
00053 }
00054
00060 public function getGroups()
00061 {
00062 if ($this->_oGroups == null && $sOxid = $this->getId()) {
00063
00064 $this->_oGroups = oxNew('oxlist', 'oxgroups');
00065 $sViewName = getViewName("oxgroups", $this->getLanguage());
00066 $sSelect = "select {$sViewName}.* from {$sViewName}, oxobject2group ";
00067 $sSelect .= "where oxobject2group.oxobjectid='$sOxid' ";
00068 $sSelect .= "and oxobject2group.oxgroupsid={$sViewName}.oxid ";
00069 $this->_oGroups->selectString($sSelect);
00070 }
00071
00072 return $this->_oGroups;
00073 }
00074
00082 public function inGroup($sGroupID)
00083 {
00084 $blResult = false;
00085 $aGroups = $this->getGroups();
00086 foreach ($aGroups as $oObject) {
00087 if ($oObject->_sOXID == $sGroupID) {
00088 $blResult = true;
00089 break;
00090 }
00091 }
00092
00093 return $blResult;
00094 }
00095
00103 public function delete($sOxid = null)
00104 {
00105 if (!$sOxid) {
00106 $sOxid = $this->getId();
00107 }
00108 if (!$sOxid) {
00109 return false;
00110 }
00111
00112 if ($blDelete = parent::delete($sOxid)) {
00113 $oDb = oxDb::getDb();
00114 $oDb->execute("delete from oxobject2group where oxobject2group.oxobjectid = " . $oDb->quote($sOxid));
00115 }
00116
00117
00118 return $blDelete;
00119 }
00120
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 }