diff --git a/code/admin/helpers/api.php b/code/admin/helpers/api.php index e9a0eee..43012c5 100644 --- a/code/admin/helpers/api.php +++ b/code/admin/helpers/api.php @@ -8,9 +8,9 @@ // No direct access. defined('_JEXEC') or die(); +use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; -use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Factory; diff --git a/code/admin/language/en-GB/en-GB.com_api.sys.ini b/code/admin/language/en-GB/en-GB.com_api.sys.ini index 70b5066..875e132 100644 --- a/code/admin/language/en-GB/en-GB.com_api.sys.ini +++ b/code/admin/language/en-GB/en-GB.com_api.sys.ini @@ -9,6 +9,7 @@ COM_API_XML_DESCRIPTION="Multi" COM_API_TEST_LABEL="Test label" COM_API_TITLE_KEYS="API Keys" +COM_API_TITLE_LOGS="Request Logs" COM_API_SHOW_TABLES_SQL_STATEMENT="SHOW FULL TABLES WHERE tables_in_%s LIKE %s" diff --git a/code/admin/models/fields/createdby.php b/code/admin/models/fields/createdby.php index 6fc3548..03a6aae 100644 --- a/code/admin/models/fields/createdby.php +++ b/code/admin/models/fields/createdby.php @@ -7,7 +7,6 @@ */ defined('JPATH_BASE') or die(); - use Joomla\CMS\Form\FormField; use Joomla\CMS\Factory; @@ -16,7 +15,7 @@ * * @since 1.0 */ -class JFormFieldCreatedby extends JFormField +class FormFieldCreatedby extends FormField { /** * The form field type. diff --git a/code/admin/views/cpanel/view.html.php b/code/admin/views/cpanel/view.html.php index 3bd7bdf..f016609 100644 --- a/code/admin/views/cpanel/view.html.php +++ b/code/admin/views/cpanel/view.html.php @@ -7,9 +7,9 @@ */ defined('_JEXEC') or die(); - -use Joomla\CMS\MVC\View\HtmlView; + use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * Cpanel class @@ -54,7 +54,7 @@ public function display($tpl = null) */ private function generateToolbar() { - JToolBarHelper::title(Text::_('COM_API') . ': ' . Text::_('COM_API_CONTROL_PANEL')); - JToolBarHelper::preferences('com_api', 500, 500); + ToolbarHelper::title(Text::_('COM_API') . ': ' . Text::_('COM_API_CONTROL_PANEL')); + ToolbarHelper::preferences('com_api', 500, 500); } } diff --git a/code/admin/views/key/tmpl/edit.php b/code/admin/views/key/tmpl/edit.php index b9f46b6..e28a88c 100644 --- a/code/admin/views/key/tmpl/edit.php +++ b/code/admin/views/key/tmpl/edit.php @@ -28,36 +28,36 @@ HTMLHelper::_('behavior.keepalive'); // Import CSS -$document = Factory::getDocument(); -$document->addStyleSheet('components/com_api/assets/css/api.css'); -?> +HTMLHelper::_('stylesheet','components/com_api/assets/css/api.css'); - + "); + ?>
diff --git a/code/admin/views/key/view.html.php b/code/admin/views/key/view.html.php index 0cdb813..66e5809 100644 --- a/code/admin/views/key/view.html.php +++ b/code/admin/views/key/view.html.php @@ -14,6 +14,8 @@ use Joomla\CMS\Form\Form; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; + /** * View class key form. @@ -95,11 +97,11 @@ protected function addToolbar() if (JVERSION >= '3.0') { - JToolBarHelper::title($viewTitle, 'pencil-2'); + ToolBarHelper::title($viewTitle, 'pencil-2'); } else { - JToolBarHelper::title($viewTitle, 'key.png'); + ToolBarHelper::title($viewTitle, 'key.png'); } if (isset($this->item->checked_out)) @@ -116,28 +118,28 @@ protected function addToolbar() // If not checked out, can save the item. if (! $checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) { - JToolBarHelper::apply('key.apply', 'JTOOLBAR_APPLY'); - JToolBarHelper::save('key.save', 'JTOOLBAR_SAVE'); + ToolBarHelper::apply('key.apply', 'JTOOLBAR_APPLY'); + ToolBarHelper::save('key.save', 'JTOOLBAR_SAVE'); } if (! $checkedOut && ($canDo->get('core.create'))) { - JToolBarHelper::custom('key.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + ToolBarHelper::custom('key.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } // If an existing item, can save to a copy. if (! $isNew && $canDo->get('core.create')) { - JToolBarHelper::custom('key.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + ToolBarHelper::custom('key.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } if (empty($this->item->id)) { - JToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CANCEL'); + ToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CANCEL'); } else { - JToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CLOSE'); + ToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CLOSE'); } } } diff --git a/code/admin/views/keys/tmpl/default.php b/code/admin/views/keys/tmpl/default.php index 0087608..e43f805 100644 --- a/code/admin/views/keys/tmpl/default.php +++ b/code/admin/views/keys/tmpl/default.php @@ -21,8 +21,7 @@ HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html'); // Import CSS -$document = Factory::getDocument(); -$document->addStyleSheet('components/com_api/assets/css/api.css'); +HTMLHelper::_('stylesheet','components/com_api/assets/css/api.css'); $user = Factory::getUser(); $userId = $user->get('id'); @@ -38,29 +37,26 @@ } $sortFields = $this->getSortFields(); -?> - +'); -extra_sidebar)) { $this->sidebar .= $this->extra_sidebar; diff --git a/code/admin/views/keys/view.html.php b/code/admin/views/keys/view.html.php index a33e3aa..54ca1fc 100644 --- a/code/admin/views/keys/view.html.php +++ b/code/admin/views/keys/view.html.php @@ -7,13 +7,12 @@ */ // No direct access. -defined('_JEXEC') or die(); - +defined('_JEXEC') or die(); use Joomla\CMS\MVC\View\HtmlView; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Pagination\Pagination; use Joomla\CMS\Language\Text; -use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; /** * View class for list of keys @@ -97,11 +96,11 @@ protected function addToolbar() if (JVERSION >= '3.0') { - JToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'key'); + ToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'key'); } else { - JToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'keys.png'); + ToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'keys.png'); } // Check if the form exists before showing the add/edit buttons @@ -111,12 +110,12 @@ protected function addToolbar() { if ($canDo->get('core.create')) { - JToolBarHelper::addNew('key.add', 'JTOOLBAR_NEW'); + ToolBarHelper::addNew('key.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { - JToolBarHelper::editList('key.edit', 'JTOOLBAR_EDIT'); + ToolBarHelper::editList('key.edit', 'JTOOLBAR_EDIT'); } } @@ -124,9 +123,9 @@ protected function addToolbar() { if (isset($this->items[0]->state)) { - JToolBarHelper::divider(); - JToolBarHelper::custom('keys.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('keys.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); + ToolBarHelper::divider(); + ToolBarHelper::custom('keys.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); + ToolBarHelper::custom('keys.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } } @@ -135,14 +134,14 @@ protected function addToolbar() { if ($canDo->get('core.delete')) { - JToolBarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'keys.delete', 'JTOOLBAR_DELETE'); - JToolBarHelper::divider(); + ToolBarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'keys.delete', 'JTOOLBAR_DELETE'); + ToolBarHelper::divider(); } } if ($canDo->get('core.admin')) { - JToolBarHelper::preferences('com_api'); + ToolBarHelper::preferences('com_api'); } // Set sidebar action - New in 3.0 diff --git a/code/admin/views/logs/tmpl/default.php b/code/admin/views/logs/tmpl/default.php index 607498b..16b6d9f 100644 --- a/code/admin/views/logs/tmpl/default.php +++ b/code/admin/views/logs/tmpl/default.php @@ -19,8 +19,7 @@ HTMLHelper::addIncludePath(JPATH_COMPONENT.'/helpers/html'); // Import CSS -$document = Factory::getDocument(); -$document->addStyleSheet('components/com_api/assets/css/api.css'); +HTMLHelper::_('stylesheet','components/com_api/assets/css/api.css'); $user = Factory::getUser(); $userId = $user->get('id'); @@ -36,29 +35,27 @@ } $sortFields = $this->getSortFields(); -?> - +'); -extra_sidebar)) { $this->sidebar .= $this->extra_sidebar; diff --git a/code/admin/views/logs/view.html.php b/code/admin/views/logs/view.html.php index 3b81ad6..a0bcfc3 100644 --- a/code/admin/views/logs/view.html.php +++ b/code/admin/views/logs/view.html.php @@ -7,13 +7,12 @@ */ // No direct access. -defined('_JEXEC') or die(); - +defined('_JEXEC') or die(); use Joomla\CMS\MVC\View\HtmlView; use Joomla\CMS\Object\CMSObject; use Joomla\CMS\Pagination\Pagination; -use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; /** @@ -94,17 +93,17 @@ protected function addToolbar() if (JVERSION >= '3.0') { - JToolBarHelper::title(Text::_('COM_API_TITLE_LOGS'), 'list'); + ToolBarHelper::title(Text::_('COM_API_TITLE_LOGS'), 'list'); } else { - JToolBarHelper::title(Text::_('COM_API_TITLE_LOGS'), 'logs.png'); + ToolBarHelper::title(Text::_('COM_API_TITLE_LOGS'), 'logs.png'); } if ($canDo->get('core.edit.state')) { // If this component does not use state then show a direct delete button as we can not trash - JToolBarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE'); + ToolBarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE'); } // Show trash and delete for components that uses the state field @@ -112,19 +111,19 @@ protected function addToolbar() { if ($state->get('filter.state') == - 2 && $canDo->get('core.delete')) { - JToolBarHelper::deleteList('', 'logs.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); + ToolBarHelper::deleteList('', 'logs.delete', 'JTOOLBAR_EMPTY_TRASH'); + ToolBarHelper::divider(); } elseif ($canDo->get('core.edit.state')) { - JToolBarHelper::trash('logs.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); + ToolBarHelper::trash('logs.trash', 'JTOOLBAR_TRASH'); + ToolBarHelper::divider(); } } if ($canDo->get('core.admin')) { - JToolBarHelper::preferences('com_api'); + ToolBarHelper::preferences('com_api'); } if (JVERSION >= '3.0') diff --git a/code/api.xml b/code/api.xml index 1201912..b35d590 100644 --- a/code/api.xml +++ b/code/api.xml @@ -47,7 +47,9 @@ COM_API COM_API_TITLE_KEYS + COM_API_TITLE_LOGS + access.xml config.xml diff --git a/code/script.api.php b/code/script.api.php index 107470b..45e53c4 100644 --- a/code/script.api.php +++ b/code/script.api.php @@ -254,7 +254,7 @@ private function installSubextensions($parent) } $db->setQuery($sql); - $db->query(); + $db->execute(); // B. Change the ordering of back-end modules to 1 + max ordering if ($folder == 'admin') @@ -272,7 +272,7 @@ private function installSubextensions($parent) ->set($db->qn('ordering') . ' = ' . $db->q($position)) ->where($db->qn('module') . ' = ' . $db->q('mod_' . $module)); $db->setQuery($query); - $db->query(); + $db->execute(); } // C. Link to all pages @@ -364,7 +364,7 @@ private function installSubextensions($parent) ) ->where($db->qn('folder') . ' = ' . $db->q($folder)); $db->setQuery($query); - $db->query(); + $db->execute(); } } } @@ -401,7 +401,7 @@ private function installSubextensions($parent) ->where('( ' . ($db->qn('name') . ' = ' . $db->q($folder)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($folder)) . ' )') ->where($db->qn('folder') . ' = ' . $db->q($folder)); $db->setQuery($query); - $db->query(); + $db->execute(); } } } diff --git a/code/site/api.php b/code/site/api.php index 9cb22b2..6301213 100755 --- a/code/site/api.php +++ b/code/site/api.php @@ -10,8 +10,8 @@ * and the com_api extension by Brian Edgerton (http://www.edgewebworks.com) */ defined('_JEXEC') or die('Restricted access'); - use Joomla\CMS\Table\Table; + use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; diff --git a/code/site/libraries/authentication/user.php b/code/site/libraries/authentication/user.php index 25dd270..a74ec0e 100755 --- a/code/site/libraries/authentication/user.php +++ b/code/site/libraries/authentication/user.php @@ -13,6 +13,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Authentication\Authentication; use Joomla\CMS\User\User; +use Joomla\CMS\Uri\Uri; class ApiAuthenticationUser extends ApiAuthentication { @@ -30,8 +31,9 @@ public function authenticate() //$password = Factory::getApplication()->input->get( 'password' ); $user = $this->loadUserByCredentials( $username, $password ); + // Remove username and password from request for when it gets logged - $uri = Factory::getURI(); + $uri = Uri::getInstance(); $uri->delVar('username'); $uri->delVar('password'); diff --git a/code/site/libraries/plugin.php b/code/site/libraries/plugin.php index b02e514..43143c3 100755 --- a/code/site/libraries/plugin.php +++ b/code/site/libraries/plugin.php @@ -22,7 +22,7 @@ use Joomla\CMS\User\User; use Joomla\Registry\Registry; use Joomla\CMS\Uri\Uri; -use Joomla\Utilities\IpHelper; +use Joomla\Utilities\IpHelper; /** * API_plugin base class @@ -280,8 +280,11 @@ final public function getResourceAccess($resource, $method = 'GET', $returnParam */ final public function fetchResource($resource_name = null) { - $this->log(); $app = Factory::getApplication(); + $app->input->set("key",APIAuthentication::getBearerToken()); + + $this->log(); + if ($resource_name == null) { $resource_name = $this->get('resource'); @@ -439,7 +442,7 @@ final private function log() $excludes = $params->get('exclude_log'); $raw_post = file_get_contents('php://input'); $redactions = explode(",", $excludes); - $req_url = Uri::current() . '?' . Factory::getURI()->getQuery(); + $req_url = Uri::current() . '?' . Uri::getInstance()->getQuery(); switch ($app->input->server->get('CONTENT_TYPE')) {