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 @@
[{ $oViewConf->getHiddenSid() }] - +
- + +

[{ oxmultilang ident="ADMIN2_API_HEAD_TITLE" }]

[{ oxmultilang ident="ADMIN2_API_DESCRIPTION" }]

@@ -25,6 +53,7 @@ + @@ -33,7 +62,7 @@ @@ -41,7 +70,7 @@ diff --git a/modules/admin2/install.sql b/modules/admin2/install.sql index 2e1c0ad..1dbea02 100644 --- a/modules/admin2/install.sql +++ b/modules/admin2/install.sql @@ -1 +1 @@ -ALTER TABLE `oxuser` ADD COLUMN `apiKey` VARCHAR(10) NOT NULL, ADD COLUMN `apiSecret` VARCHAR(50) NOT NULL; +ALTER TABLE `oxuser` ADD COLUMN `apikey` VARCHAR(10) NOT NULL, ADD COLUMN `apisecret` VARCHAR(50) NOT NULL; \ No newline at end of file diff --git a/modules/admin2/metadata.php b/modules/admin2/metadata.php index c0b2d90..1a6c51e 100644 --- a/modules/admin2/metadata.php +++ b/modules/admin2/metadata.php @@ -17,13 +17,14 @@ 'url' => 'https://github.com/OXIDprojects/admin_2_0', 'email' => 'tobias@merkl.eu', 'extend' => array( + 'oxadmindetails' => 'admin2/admin2rest', ), 'files' => array( - 'adm2rest_api' => 'admin20/admin/adm2rest_api.php', - 'adm2oauth' => 'admin20/core/adm2oauth.php', + 'adm2rest_api' => 'admin2/admin/adm2rest_api.php', + 'adm2oauth' => 'admin2/core/adm2oauth.php', ), 'templates' => array( - 'adm2rest_api.tpl' => 'admin20/out/admin/tpl/adm2rest_api.tpl', + 'admin2rest.tpl' => 'admin2/admin2rest.tpl', ), 'blocks' => array( ), diff --git a/out/admin/src/admin2/utils.js b/modules/admin2/utils.js similarity index 100% rename from out/admin/src/admin2/utils.js rename to modules/admin2/utils.js
- +
- +