165 abstract protected function _modifyData($aData, $oType);
175 public function __call($sMethod, $aArguments)
177 throw new Exception(
"ERROR: Handler for Object '$sMethod' not implemented!");
199 public function init($sUserName, $sPassword, $iShopID = 1, $iLanguage = 0)
201 ini_set(
'session.use_cookies', 0);
202 $_COOKIE = array(
'admin_sid' =>
false);
204 $myConfig->setConfigParam(
'blForceSessionStart', 1);
205 $myConfig->setConfigParam(
'blSessionUseCookies', 0);
210 @$mySession->start();
216 $oUser =
oxNew(
'oxuser');
218 if (!$oUser->login($sUserName, $sPassword)) {
227 if (!$oUser || (isset($oUser->iError) && $oUser->iError == -1000)) {
229 throw new Exception(self::ERROR_USER_WRONG);
230 } elseif (($oUser->oxuser__oxrights->value ==
"malladmin" || $oUser->oxuser__oxrights->value ==
$myConfig->getShopID())) {
231 $this->_sSID = $mySession->getId();
232 $this->_blInit =
true;
233 $this->_iLanguage = $iLanguage;
234 $this->_sUserID = $oUser->getId();
239 throw new Exception(self::ERROR_USER_NO_RIGHTS);
256 throw new Exception(
"ERROR: Session ID not valid!");
258 $_COOKIE = array(
'admin_sid' => $sSessionID);
266 if ($sSessionID != session_id()) {
268 session_write_close();
270 session_id($sSessionID);
274 $sAuth = $mySession->getVariable(
'auth');
276 if (!isset($sAuth) || !$sAuth) {
277 throw new Exception(
"ERROR: Session ID not valid!");
280 $this->_iLanguage = $mySession->getVariable(
'lang');
281 $this->_sUserID = $sAuth;
284 $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);
307 public function import()
324 $sClassName =
'oxerptype_' . $sType;
325 $sFullPath = dirname(__FILE__) .
'/objects/' . $sClassName .
'.php';
327 if (!file_exists($sFullPath)) {
328 throw new Exception(
"Type $sType not supported in ERP interface!");
331 include_once $sFullPath;
334 return oxNew($sClassName);
348 protected function _export($sType, $sWhere, $iStart = null, $iCount = null, $sSortFieldName = null, $sSortType = null)
350 global $ADODB_FETCH_MODE;
356 $sSQL = $oType->getSQL($sWhere, $this->_iLanguage,
$myConfig->getShopId());
357 $sSQL .= $oType->getSortString($sSortFieldName, $sSortType);
358 $sFnc =
'_Export' . $oType->getFunctionSuffix();
360 $save = $ADODB_FETCH_MODE;
363 if (isset($iCount) || isset($iStart)) {
364 $rs = $oDb->selectLimit($sSQL, $iCount, $iStart);
366 $rs = $oDb->select($sSQL);
369 if ($rs !=
false && $rs->recordCount() > 0) {
374 $rs->fields = $oType->addExportData($rs->fields);
381 $blExport = $this->$sFnc($rs->fields);
383 $sMessage = $e->getMessage();
387 $this->_aStatistics[
$this->_iIdx] = array(
'r' => $blExport,
'm' => $sMessage);
394 $ADODB_FETCH_MODE = $save;
404 $aData = GetTableDescription($sTable);
407 foreach ($aData as $key => $oADODBField) {
408 if (!(is_numeric(substr($oADODBField->name, strlen($oADODBField->name) - 1, 1)) && substr($oADODBField->name, strlen($oADODBField->name) - 2, 1) ==
'_')) {
409 echo(
"'" . $oADODBField->name .
"'\t\t => '" . $oADODBField->name .
"',\n");
425 $sOXID = $oType->getOxidFromKeyFields($aData);
441 if (count($this->_aStatistics) && isset($this->_aStatistics[$this->_iIdx])) {
442 while (isset($this->_aStatistics[$this->_iIdx]) && $this->_aStatistics[$this->_iIdx][
'r']) {
455 if (count($this->_aStatistics) && isset($this->_aStatistics[$this->_iIdx])) {
456 while (isset($this->_aStatistics[$this->_iIdx]) && $this->_aStatistics[$this->_iIdx][
'r']) {
472 static $aAccessCache;
474 if (!$this->_blInit) {
475 throw new Exception(self::ERROR_NO_INIT);
508 $sFnc =
'_' . $sMode . $oType->getFunctionSuffix();
511 $aData = $oType->addImportData($aData);
515 $iId = $this->$sFnc($oType, $aData);
524 $sMessage = $e->getMessage();
527 $this->_aStatistics[
$this->_iIdx] = array(
'r' => $blImport,
'm' => $sMessage);
546 protected function _save(
oxERPType &$oType, $aData, $blAllowCustomShopId =
false)
552 if (isset($aData[
'OXID'])) {
553 $sOxid = $aData[
'OXID'];
557 return $oType->
saveObject($aData, $blAllowCustomShopId);
570 if (method_exists(
$myConfig,
'getSerial')) {
571 if (
$myConfig->getSerial() instanceof oxSerial) {
575 throw new Exception(self::ERROR_SHOP_VERSION_NOT_SUPPORTED_BY_ERP);
599 if (!self::$_sRequestedVersion) {
625 $sDbLayerVersion =
'2.9.0';
626 self::$_sRequestedVersion = $sDbLayerVersion;
639 $sClassName = preg_replace(
'/[^a-z0-9_]/i',
'', $sId);
640 if (preg_match(
'/(.*)Plugin$/i', $sClassName, $m)) {
642 $sClassName = $m[1] .
'Plugin';
644 throw new Exception(
"Plugin handler class has to end with 'Plugin' word (GOT '$sClassName').");
647 $sFileName = dirname(__FILE__) .
'/plugins/' . strtolower($sClassName) .
'.php';
648 if (!is_readable($sFileName)) {
649 $sFileName = basename($sFileName);
650 throw new Exception(
"Can not find the requested plugin file ('$sFileName').");
652 include_once dirname(__FILE__) .
'/plugins/oxerppluginbase.php';
653 include_once $sFileName;
654 if (!class_exists($sClassName)) {
655 throw new Exception(
"Can not find the requested plugin class.");
657 $o =
new $sClassName();
658 if ($o instanceof oxErpPluginBase) {
661 throw new Exception(
"Plugin does not extend oxErpPluginBase class.");