159 protected abstract function _modifyData($aData, $oType);
171 public function __call($sMethod, $aArguments)
173 throw new Exception(
"ERROR: Handler for Object '$sMethod' not implemented!");
195 public function init($sUserName, $sPassword, $iShopID = 1, $iLanguage = 0)
197 ini_set(
'session.use_cookies', 0);
198 $_COOKIE = array(
'admin_sid' =>
false);
200 $myConfig->setConfigParam(
'blForceSessionStart', 1 );
201 $myConfig->setConfigParam(
'blSessionUseCookies', 0);
202 $myConfig->setConfigParam(
'blAdmin', 1 );
206 @$mySession->start();
212 $oUser =
oxNew(
'oxuser');
214 if (!$oUser->login($sUserName, $sPassword)) {
223 if ( !$oUser || ( isset($oUser->iError) && $oUser->iError == -1000)) {
225 throw new Exception( self::ERROR_USER_WRONG );
226 } elseif ( ($oUser->oxuser__oxrights->value ==
"malladmin" || $oUser->oxuser__oxrights->value ==
$myConfig->getShopID()) ) {
227 $this->_sSID = $mySession->getId();
228 $this->_blInit =
true;
229 $this->_iLanguage = $iLanguage;
230 $this->_sUserID = $oUser->getId();
235 throw new Exception( self::ERROR_USER_NO_RIGHTS );
254 throw new Exception(
"ERROR: Session ID not valid!");
256 $_COOKIE = array(
'admin_sid' => $sSessionID);
259 $myConfig->setConfigParam(
'blAdmin', 1 );
264 if ($sSessionID != session_id()) {
266 session_write_close();
268 session_id($sSessionID);
272 $sAuth = $mySession->getVar(
'auth');
274 if (!isset($sAuth) || !$sAuth) {
275 throw new Exception(
"ERROR: Session ID not valid!");
278 $this->_iLanguage = $mySession->getVar(
'lang');
279 $this->_sUserID = $sAuth;
282 $this->_blInit =
true;
297 public function exportType($sType, $sWhere = null, $iStart = null, $iCount = null, $sSortFieldName = null, $sSortType = null)
300 $this->
_export($sType, $sWhere, $iStart, $iCount, $sSortFieldName, $sSortType);
309 public function import()
326 $sClassName =
'oxerptype_'.$sType;
327 $sFullPath = dirname(__FILE__).
'/objects/'.$sClassName.
'.php';
329 if ( !file_exists($sFullPath)) {
330 throw new Exception(
"Type $sType not supported in ERP interface!");
333 include_once $sFullPath;
336 return oxNew ($sClassName);
352 protected function _export($sType, $sWhere, $iStart = null, $iCount = null, $sSortFieldName = null, $sSortType = null)
354 global $ADODB_FETCH_MODE;
360 $sSQL = $oType->getSQL($sWhere, $this->_iLanguage,
$myConfig->getShopId());
361 $sSQL .= $oType->getSortString($sSortFieldName, $sSortType);
362 $sFnc =
'_Export'.$oType->getFunctionSuffix();
364 $save = $ADODB_FETCH_MODE;
367 if (isset($iCount) || isset($iStart)) {
368 $rs = $oDb->selectLimit( $sSQL, $iCount, $iStart );
370 $rs = $oDb->select( $sSQL );
373 if ($rs !=
false && $rs->recordCount() > 0) {
378 $rs->fields = $oType->addExportData($rs->fields);
385 $blExport = $this->$sFnc($rs->fields );
387 $sMessage = $e->getMessage();
391 $this->_aStatistics[
$this->_iIdx] = array(
'r'=>$blExport,
'm'=>$sMessage);
398 $ADODB_FETCH_MODE = $save;
410 $aData = GetTableDescription($sTable);
413 foreach ($aData as $key => $oADODBField) {
414 if ( !(is_numeric( substr($oADODBField->name, strlen($oADODBField->name) - 1, 1)) && substr($oADODBField->name, strlen($oADODBField->name) - 2, 1) ==
'_')) {
415 echo(
"'".$oADODBField->name.
"'\t\t => '".$oADODBField->name.
"',\n");
431 $sOXID = $oType->getOxidFromKeyFields($aData);
448 if (count($this->_aStatistics) && isset($this->_aStatistics[$this->_iIdx])) {
449 while ( isset($this->_aStatistics[$this->_iIdx]) && $this->_aStatistics[$this->_iIdx][
'r'] ) {
464 if (count($this->_aStatistics) && isset($this->_aStatistics[$this->_iIdx])) {
465 while ( isset($this->_aStatistics[$this->_iIdx]) && $this->_aStatistics[$this->_iIdx][
'r'] ) {
483 static $aAccessCache;
485 if (!$this->_blInit) {
486 throw new Exception(self::ERROR_NO_INIT);
519 $sFnc =
'_' . $sMode . $oType->getFunctionSuffix();
522 $aData = $oType->addImportData($aData);
526 $iId = $this->$sFnc($oType, $aData);
535 $sMessage = $e->getMessage();
538 $this->_aStatistics[
$this->_iIdx] = array(
'r'=>$blImport,
'm'=>$sMessage);
557 protected function _save(
oxERPType &$oType, $aData, $blAllowCustomShopId =
false)
563 if (isset($aData[
'OXID'])) {
564 $sOxid = $aData[
'OXID'];
568 return $oType->
saveObject($aData, $blAllowCustomShopId);
581 if ( method_exists(
$myConfig,
'getSerial') ) {
582 if (
$myConfig->getSerial() instanceof oxSerial) {
586 throw new Exception(self::ERROR_SHOP_VERSION_NOT_SUPPORTED_BY_ERP);
610 if (!self::$_sRequestedVersion) {
637 $sDbLayerVersion =
'2.9.0';
638 self::$_sRequestedVersion = $sDbLayerVersion;
651 $sClassName = preg_replace(
'/[^a-z0-9_]/i',
'', $sId);
652 if (preg_match(
'/(.*)Plugin$/i', $sClassName, $m)) {
654 $sClassName = $m[1].
'Plugin';
656 throw new Exception(
"Plugin handler class has to end with 'Plugin' word (GOT '$sClassName').");
659 $sFileName = dirname(__FILE__).
'/plugins/'.strtolower($sClassName).
'.php';
660 if (!is_readable($sFileName)) {
661 $sFileName = basename($sFileName);
662 throw new Exception(
"Can not find the requested plugin file ('$sFileName').");
664 include_once dirname(__FILE__).
'/plugins/oxerppluginbase.php';
665 include_once $sFileName;
666 if (!class_exists($sClassName)) {
667 throw new Exception(
"Can not find the requested plugin class.");
669 $o =
new $sClassName();
670 if ($o instanceof oxErpPluginBase) {
673 throw new Exception(
"Plugin does not extend oxErpPluginBase class.");