Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Fixes & additions #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions admin/admin2rest.php

This file was deleted.

4 changes: 2 additions & 2 deletions api/library/Admin2/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
12 changes: 11 additions & 1 deletion api/rest/controllers/ProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
17 changes: 17 additions & 0 deletions api/rest/models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion api/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
</script>
Expand Down
38 changes: 38 additions & 0 deletions modules/admin2/admin2rest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
class admin2rest extends admin2rest_parent
{
protected $_sThisTemplate = "admin2rest.tpl";

public function render()
{
parent::render();
$soxId = $this->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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,39 @@
<form name="transfer" id="transfer" action="[{ $oViewConf->getSelfLink() }]" method="post">
[{ $oViewConf->getHiddenSid() }]
<input type="hidden" name="oxid" value="[{ $oxid }]">
<input type="hidden" name="cl" value="adm2rest_api">
<input type="hidden" name="cl" value="admin2rest">
</form>

<script type="text/javascript" src="[{$oViewConf->getResourceUrl()}]admin2/utils.js"></script>
<script type="text/javascript" src="[{$oViewConf->getModuleUrl('admin20')}]admin2/utils.js"></script>
<script type="text/javascript">
<!--
window.onload = function ()
{
[{ if $updatelist == 1}]
top.oxid.admin.updateList('[{ $oxid }]');
[{ /if}]
top.reloadEditFrame();
}
function editThis( sID )
{
var oTransfer = top.basefrm.edit.document.getElementById( "transfer" );
oTransfer.oxid.value = sID;
oTransfer.cl.value = top.basefrm.list.sDefClass;

//forcing edit frame to reload after submit
top.forceReloadingEditFrame();

var oSearch = top.basefrm.list.document.getElementById( "search" );
oSearch.oxid.value = sID;
oSearch.actedit.value = 0;
oSearch.submit();
}
function processUnitInput( oSelect, sInputId )
{
document.getElementById( sInputId ).disabled = oSelect.value ? true : false;
}
//-->
</script>
<h3>[{ oxmultilang ident="ADMIN2_API_HEAD_TITLE" }]</h3>
<h4>[{ oxmultilang ident="ADMIN2_API_DESCRIPTION" }]</h4>

Expand All @@ -25,6 +53,7 @@
<input type="hidden" name="cl" value="[{$oViewConf->getActiveClassName()}]">
<input type="hidden" name="fnc" value="save">
<input type="hidden" name="oxid" value="[{ $oxid }]">
<input type="hidden" name="editval[user__oxid]" value="[{ $oxid }]">
</td>
<td valign="top" class="edittext">
<table cellspacing="0" cellpadding="0" border="0">
Expand All @@ -33,15 +62,15 @@
<label for="apiKey">[{ oxmultilang ident="ADMIN2_API_KEY" }]:</label>
</td>
<td class="edittext">
<input id="apiKey" type="text" name="admin2[apiKey]" value="[{ $edit.apiKey|escape }]" style="width:300px;" [{ $readonly}]>
<input id="apiKey" type="text" name="editval[oxuser__apikey]" value="[{$edit->oxuser__apikey->value}]" style="width:300px;" [{ $readonly}]>
</td>
</tr>
<tr>
<td class="edittext">
<label for="apiSecret">[{ oxmultilang ident="ADMIN2_API_SECRET" }]:</label>
</td>
<td class="edittext">
<input type="password" id="apiSecret" name="admin2[apiSecret]" value="[{ $edit.apiSecret|escape }]" style="width:300px;" [{ $readonly}]>
<input type="password" id="apiSecret" name="editval[oxuser__apisecret]" value="[{$edit->oxuser__apisecret->value}]" style="width:300px;" [{ $readonly}]>
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion modules/admin2/install.sql
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions modules/admin2/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
'url' => 'https://github.com/OXIDprojects/admin_2_0',
'email' => '[email protected]',
'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(
),
Expand Down
File renamed without changes.