68 $this->_sFunctionSuffix = str_replace(
"oxERPType_",
"", get_class( $this));
80 $this->_sFunctionSuffix = $sNew;
92 $this->_aFieldList = $aFieldList;
105 if ($iShopID === null) {
109 return getViewName($this->_sTableName, -1, $iShopID);
123 foreach ($aData as $key => $oADODBField) {
124 $iLang = substr( $oADODBField->name, strlen( $oADODBField->name) - 1, 1);
125 if ( is_numeric( $iLang) && substr( $oADODBField->name, strlen( $oADODBField->name) - 2, 1) ==
'_') {
127 $sMainFld = str_replace(
'_'.$iLang,
"", $oADODBField->name);
128 $aRet[$iLang][$sMainFld] = $oADODBField->name.
' as '.$sMainFld;
149 if ( isset( $aMultiLang[$iLanguage][$sField])) {
150 $sField = $aMultiLang[$iLanguage][$sField];
157 return "1 as $sField";
159 return "0 as $sField";
174 public function getSQL( $sWhere, $iLanguage = 0, $iShopId = 1)
176 if ( !$this->_aFieldList) {
183 foreach ( $this->_aFieldList as $sField) {
193 $sSQL .=
' from '.$this->getTableName($iShopId, $iLanguage).
' '.$sWhere;
208 $sRes =
" order by ";
210 $sRes .= $sFieldName;
214 if ($sType && ($sType ==
"ASC" || $sType ==
"DESC")) {
215 $sRes .=
" ". $sType;
234 if ($oObj->isDerived()) {
235 throw new Exception( oxERPBase::$ERROR_USER_NO_RIGHTS);
271 $oObj =
oxNew( $sName,
"core");
273 $oObj =
oxNew(
'oxbase',
'core');
277 if (!$oObj->exists($sId)) {
282 if (!$oObj->Load($sId)) {
284 throw new Exception(
"No right to delete object {$sId} !");
288 throw new Exception(
"No right to delete object {$sId} !");
303 $oUsr =
oxNew(
'oxUser');
304 $oUsr->loadAdminUser();
306 if ($oUsr->oxuser__oxrights->value ==
"malladmin") {
308 } elseif ($oUsr->oxuser__oxrights->value == (
int) $iShopId) {
327 $sSql =
"select oxshopid from ".$this->_sTableName.
" where oxid = " . $oDb->quote( $sId );
329 $iShopId = $oDb->getOne($sSql);
335 throw new Exception(
"No right to delete object {$sId} !");
355 $oUsr =
oxNew(
'oxUser');
356 $oUsr->loadAdminUser();
357 if ($oUsr->oxuser__oxrights->value ==
"malladmin") {
363 if ($e->getMessage() ==
'EXCEPTION_SYSTEMCOMPONENT_CLASSNOTFOUND') {
378 public function delete($sID)
382 $sSql =
"delete from ".$this->_sTableName.
" where oxid = " . $oDb->quote( $sID );
384 return $oDb->Execute($sSql);
397 return $oObj->delete($sID);
434 if (!$this->_aFieldList) {
438 foreach ($this->_aFieldList as $sField) {
439 $aRParams[] = strtolower($this->_sTableName.
'__'.$sField);
453 if ( $sObjectName ) {
454 $oShopObject =
oxNew( $sObjectName );
456 $oShopObject =
oxNew(
'oxbase' );
460 if ($oShopObject instanceof
oxI18n) {
461 $oShopObject->setLanguage( 0 );
462 $oShopObject->setEnableMultilang(
false);
465 $sViewName = $oShopObject->getViewName();
466 $sFields = str_ireplace(
'`' . $sViewName .
"`.",
"", strtoupper($oShopObject->getSelectFields()) );
467 $sFields = str_ireplace( array(
" ",
"`"), array(
"",
""), $sFields );
468 $this->_aFieldList = explode(
",", $sFields );
503 if (array_key_exists($sKey, $aData)) {
504 $aWhere[] = $sKey.
'='.$oDb->qstr($aData[$sKey]);
511 $sSelect =
'SELECT OXID FROM '.$this->getTableName().
' WHERE '.implode(
' AND ', $aWhere);
512 return $oDb->getOne( $sSelect );
525 if (isset($this->_aKeyFieldList) && is_array($this->_aKeyFieldList)) {
542 if (isset($aData[
'OXSHOPID'])) {
543 $aData[
'OXSHOPID'] =
'oxbaseshop';
547 if (!isset($aData[
'OXID'])) {
552 foreach ($aData as $key => $val) {
553 if (!strlen((
string) $val)) {
587 $oShopObject =
oxNew( $sObjectName,
'core');
588 if ($oShopObject instanceof
oxI18n) {
589 $oShopObject->setLanguage( 0 );
590 $oShopObject->setEnableMultilang(
false);
593 $oShopObject =
oxNew(
'oxbase',
'core');
597 foreach ($aData as $key => $value) {
599 $sUPKey = strtoupper($key);
600 if (!isset($aData[$sUPKey])) {
602 $aData[$sUPKey] = $value;
608 if ($aData[
'OXID']) {
609 $blLoaded = $oShopObject->load( $aData[
'OXID']);
612 $aData = $this->
_preAssignObject( $oShopObject, $aData, $blAllowCustomShopId );
620 $oShopObject->assign( $aData );
622 if ($blAllowCustomShopId) {
623 $oShopObject->setIsDerived(
false);
628 if ( $oShopObject->save()) {
647 return $oShopObject->getId();