diff --git a/admin/admin2rest.php b/admin/admin2rest.php deleted file mode 100644 index 480c677..0000000 --- a/admin/admin2rest.php +++ /dev/null @@ -1,31 +0,0 @@ -query( - 'SELECT `apiKey`, `apiSecret` FROM `oxuser` WHERE `OXID` = ?', - array(oxConfig::getParameter('oxid')) - ); - $user = $result->FetchRow(); - $this->_aViewData['edit'] = $user; - return parent::render(); - } - - public function save() - { - $admin2 = oxConfig::getParameter('admin2'); - $db = oxDb::getDb(true); - $db->query( - 'UPDATE `oxuser` SET `apiKey` = ?, `apiSecret` = ? WHERE `OXID` = ?', - array( - $admin2['apiKey'], - $admin2['apiSecret'], - oxConfig::getParameter('oxid'), - ) - ); - } -} diff --git a/api/library/Admin2/Dispatcher.php b/api/library/Admin2/Dispatcher.php index 80cfc67..dafc8b9 100644 --- a/api/library/Admin2/Dispatcher.php +++ b/api/library/Admin2/Dispatcher.php @@ -94,11 +94,11 @@ public function checkSignature( } $user = oxDb::getDb(true)->GetRow( - 'SELECT `OXID`, `apiSecret` FROM `oxuser` WHERE `apiKey` = ?', + 'SELECT `OXID`, `apisecret` FROM `oxuser` WHERE `apikey` = ?', array($params['key']) ); - $signatureClass->setSalt($user['apiSecret']); + $signatureClass->setSalt($user['apisecret']); $requestSignature = $params['signature']; unset($params['signature']); diff --git a/api/rest/controllers/ProductsController.php b/api/rest/controllers/ProductsController.php index 076f8da..32ffaad 100644 --- a/api/rest/controllers/ProductsController.php +++ b/api/rest/controllers/ProductsController.php @@ -81,6 +81,16 @@ public function put() */ public function delete() { - $this->_response->setData(array('hello' => 'world!')); + $productModel = new Application_Model_Product(); + $entity = $this->_request->getEntity(); + $productData = null; + if ($entity != null) { + $productData = $productModel->deleteProduct($entity); + } + + if ($productData === null) { + return; + } + $this->_response->setData(array('erfolgreich'=>$productData)); } } diff --git a/api/rest/models/Product.php b/api/rest/models/Product.php index 4102ed5..8987e3a 100644 --- a/api/rest/models/Product.php +++ b/api/rest/models/Product.php @@ -63,6 +63,23 @@ public function getProductList($limit = 50, $offset = 0) return $productData; } + /** + * Delete product. + * + * @param string $oxid OXID of the product. + * + * @return array|null + */ + public function deleteProduct($oxid) + { + + $product = oxNew('oxarticle'); + $product->delete($oxid); + return $this->oxidToArray($product); + } + + + /** * Model-specific initialization code. * diff --git a/api/test.php b/api/test.php index d943b19..042f39d 100644 --- a/api/test.php +++ b/api/test.php @@ -201,7 +201,7 @@ function removeRow(anchorNode) $('#dataTable').dataTable().fnClearTable(); return; } - var trNode = $(anchorNode).parent().parent(); + var trNode = $('#dataTable tr').index($(anchorNode).closest('tr')) - 1; $('#dataTable').dataTable().fnDeleteRow(trNode); } diff --git a/out/admin/de/admin2rest_lang.php b/application/views/admin/de/admin2rest_lang.php similarity index 100% rename from out/admin/de/admin2rest_lang.php rename to application/views/admin/de/admin2rest_lang.php diff --git a/out/admin/en/admin2rest_lang.php b/application/views/admin/en/admin2rest_lang.php similarity index 100% rename from out/admin/en/admin2rest_lang.php rename to application/views/admin/en/admin2rest_lang.php diff --git a/modules/admin2/admin2rest.php b/modules/admin2/admin2rest.php new file mode 100644 index 0000000..7e646e0 --- /dev/null +++ b/modules/admin2/admin2rest.php @@ -0,0 +1,38 @@ +getEditObjectId(); + $user = oxNew( "oxuser" ); + $user->load( $soxId ); + $this->_aViewData['edit'] = $user; + + return $this->_sThisTemplate; + } + + public function save() + { + parent::save(); + + $soxId = $this->getEditObjectId(); + + if ( !$this->_allowAdminEdit( $soxId ) ) + return false; + + $aParams = oxConfig::getParameter( "editval" ); + + $oUser = oxNew( "oxuser" ); + + $oUser->load( $soxId ); + + $oUser->assign($aParams); + $oUser->save(); + + // set oxid if inserted + $this->setEditObjectId($oUser->getId()); + } +} diff --git a/out/admin/tpl/admin2/admin2rest.tpl b/modules/admin2/admin2rest.tpl similarity index 71% rename from out/admin/tpl/admin2/admin2rest.tpl rename to modules/admin2/admin2rest.tpl index d80d221..105a6b4 100644 --- a/out/admin/tpl/admin2/admin2rest.tpl +++ b/modules/admin2/admin2rest.tpl @@ -9,11 +9,39 @@
- + +| - + |
| - + |