00001 <?php
00002
00003 require_once( 'oxerptype.php');
00004
00005 class oxERPType_ArticleStock extends oxERPType
00006 {
00007
00008 public function __construct()
00009 {
00010 parent::__construct();
00011
00012 $this->_sTableName = 'oxarticles';
00013 $this->_sShopObjectName = 'oxarticle';
00014 $this->_blRestrictedByShopId = true;
00015
00016 $this->_aFieldList = array(
00017 'OXID' => 'OXID',
00018 'OXSTOCK' => 'OXSTOCK',
00019 );
00020 }
00021
00022 public function checkWriteAccess($sOxid)
00023 {
00024
00025
00026 $myConfig = oxConfig::getInstance();
00027
00028 $oDB = oxDb::getDb();
00029
00030 $sSql = "select oxid from ". $this->getTableName($myConfig->getShopId()) ." where oxid = '". $sOxid ."'";
00031 $sRes = $oDB->getOne($sSql);
00032
00033 if(!$sRes){
00034 throw new Exception( oxERPBase::$ERROR_OBJECT_NOT_EXISTING);
00035 }
00036
00037 parent::checkWriteAccess($sOxid);
00038 }
00039
00040
00051 protected function _preAssignObject($oShopObject, $aData, $blAllowCustomShopId)
00052 {
00053 $oCompat = oxNew('OXERPCompatability');
00054 if ( !$oCompat->isArticleNullLongDescComatable() ) {
00055
00056 $aLongDescriptionFields = array('OXLONGDESC_1','OXLONGDESC_2','OXLONGDESC_3');
00057
00058 foreach ($aLongDescriptionFields as $iKey => $sField){
00059 if( in_array($sField,$this->_aFieldList)){
00060 unset($aLongDescriptionFields[$iKey]);
00061 }
00062 }
00063
00064 if(count($aLongDescriptionFields)){
00065 $oArtExt = oxNew('oxbase');
00066 $oArtExt->init('oxartextends');
00067
00068 if( $oArtExt->load($aData['OXID']) ) {
00069 foreach ($aLongDescriptionFields as $sField) {
00070 $sFieldName = $oArtExt->getCoreTableName()."__".strtolower( $sField );
00071 $sLongDesc = null;
00072
00073 if ($oArtExt->$sFieldName instanceof oxField) {
00074 $sLongDesc = $oArtExt->$sFieldName->getRawValue();
00075 } elseif (is_object($oArtExt->$sFieldName)) {
00076 $sLongDesc = $oArtExt->$sFieldName->value;
00077 }
00078
00079 if ( isset($sLongDesc) ) {
00080 $aData[$sField] = $sLongDesc;
00081 }
00082 }
00083 }
00084 }
00085 }
00086
00087 return parent::_preAssignObject($oShopObject, $aData, $blAllowCustomShopId);
00088 }
00089
00090 }