Add API integration

This commit is contained in:
Oh
2024-08-21 16:46:56 +02:00
parent 96cb33e792
commit ab99fc1336
94 changed files with 621 additions and 91 deletions

1
api/index.html Normal file
View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,51 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage CountriesController.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\Controller;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\ApiController;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Countries Api Controller
*
* @since 4.0.0
*/
class CountriesController extends ApiController
{
/**
* The content type of the item.
*
* @var string
* @since 4.0.0
*/
protected $contentType = 'countries';
/**
* The default view for the display method.
*
* @var string
* @since 3.0
*/
protected $default_view = 'countries';
}

View File

@@ -0,0 +1,138 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage CountryController.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\Controller;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\ApiController;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Country Api Controller
*
* @since 4.0.0
*/
class CountryController extends ApiController
{
/**
* The content type of the item.
*
* @var string
* @since 4.0.0
*/
protected $contentType = 'country';
/**
* The default view for the display method.
*
* @var string
* @since 3.0
*/
protected $default_view = 'country';
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = [])
{
// Get user object.
$user = $this->app->getIdentity();
// Access check.
$access = $user->authorise('country.access', 'com_subformpower');
if (!$access)
{
return false;
}
// In the absence of better information, revert to the component permissions.
return $user->authorise('country.create', $this->option);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = [], $key = 'id')
{
// get user object.
$user = $this->app->getIdentity();
// get record id.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
// Access check.
$access = ($user->authorise('country.access', 'com_subformpower.country.' . (int) $recordId) && $user->authorise('country.access', 'com_subformpower'));
if (!$access)
{
return false;
}
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('country.edit', 'com_subformpower.country.' . (int) $recordId);
if (!$permission)
{
if ($user->authorise('country.edit.own', 'com_subformpower.country.' . $recordId))
{
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
if (empty($ownerId))
{
// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);
if (empty($record))
{
return false;
}
$ownerId = $record->created_by;
}
// If the owner matches 'me' then allow.
if ($ownerId == $user->id)
{
if ($user->authorise('country.edit.own', 'com_subformpower'))
{
return true;
}
}
}
return false;
}
}
// Since there is no permission, revert to the component permissions.
return $user->authorise('country.edit', $this->option);
}
}

View File

@@ -0,0 +1,51 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage CurrenciesController.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\Controller;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\ApiController;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Currencies Api Controller
*
* @since 4.0.0
*/
class CurrenciesController extends ApiController
{
/**
* The content type of the item.
*
* @var string
* @since 4.0.0
*/
protected $contentType = 'currencies';
/**
* The default view for the display method.
*
* @var string
* @since 3.0
*/
protected $default_view = 'currencies';
}

View File

@@ -0,0 +1,138 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage CurrencyController.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\Controller;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\ApiController;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Currency Api Controller
*
* @since 4.0.0
*/
class CurrencyController extends ApiController
{
/**
* The content type of the item.
*
* @var string
* @since 4.0.0
*/
protected $contentType = 'currency';
/**
* The default view for the display method.
*
* @var string
* @since 3.0
*/
protected $default_view = 'currency';
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = [])
{
// Get user object.
$user = $this->app->getIdentity();
// Access check.
$access = $user->authorise('currency.access', 'com_subformpower');
if (!$access)
{
return false;
}
// In the absence of better information, revert to the component permissions.
return $user->authorise('currency.create', $this->option);
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = [], $key = 'id')
{
// get user object.
$user = $this->app->getIdentity();
// get record id.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
// Access check.
$access = ($user->authorise('currency.access', 'com_subformpower.currency.' . (int) $recordId) && $user->authorise('currency.access', 'com_subformpower'));
if (!$access)
{
return false;
}
if ($recordId)
{
// The record has been set. Check the record permissions.
$permission = $user->authorise('currency.edit', 'com_subformpower.currency.' . (int) $recordId);
if (!$permission)
{
if ($user->authorise('currency.edit.own', 'com_subformpower.currency.' . $recordId))
{
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
if (empty($ownerId))
{
// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);
if (empty($record))
{
return false;
}
$ownerId = $record->created_by;
}
// If the owner matches 'me' then allow.
if ($ownerId == $user->id)
{
if ($user->authorise('currency.edit.own', 'com_subformpower'))
{
return true;
}
}
}
return false;
}
}
// Since there is no permission, revert to the component permissions.
return $user->authorise('currency.edit', $this->option);
}
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,36 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage JsonapiView.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\View\Countries;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Subformpower Json View class for the Countries
*
* @since 4.0.0
*/
class JsonapiView extends BaseApiView
{
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,36 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage JsonapiView.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\View\Country;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Country Json View class
*
* @since 4.0.0
*/
class JsonapiView extends BaseApiView
{
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,36 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage JsonapiView.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\View\Currencies;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Subformpower Json View class for the Currencies
*
* @since 4.0.0
*/
class JsonapiView extends BaseApiView
{
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@@ -0,0 +1,36 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Nampharm
/-------------------------------------------------------------------------------------------------------/
@version 1.0.1
@build 21st August, 2024
@created 24th May, 2024
@package Subform Power
@subpackage JsonapiView.php
@author Oh Martin <https://nampharm.com.na>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Api\View\Currency;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;
// No direct access to this file
\defined('_JEXEC') or die;
/**
* Currency Json View class
*
* @since 4.0.0
*/
class JsonapiView extends BaseApiView
{
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

1
api/src/View/index.html Normal file
View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

1
api/src/index.html Normal file
View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>