Skip to content

Commit

Permalink
phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
driusan committed Jun 8, 2023
1 parent 32e9f4f commit 1f747d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
6 changes: 3 additions & 3 deletions modules/dashboard/jsx/welcome.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import DOMPurify from 'dompurify';

window.addEventListener('load', () => {
fetch(loris.BaseURL + "/dashboard/projectdescription").then ( (resp) => {
fetch(loris.BaseURL + '/dashboard/projectdescription').then( (resp) => {
if (!resp.ok) {
throw new Error('Could not get project description');
}
return resp.json();
}).then ( (json) => {
const el = document.getElementById("project-description");
}).then( (json) => {
const el = document.getElementById('project-description');
el.innerHTML = DOMPurify.sanitize(json.Description);
}).catch( (e) => console.error(e));
});
22 changes: 19 additions & 3 deletions modules/dashboard/php/projectdescription.class.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
namespace LORIS\dashboard;
use \Psr\Http\Server\RequestHandlerInterface;
use \Psr\Http\Message\ServerRequestInterface;
use \Psr\Http\Message\ResponseInterface;

Expand All @@ -12,11 +11,28 @@ use \Psr\Http\Message\ResponseInterface;

class ProjectDescription extends \LORIS\Http\Endpoint
{
public function handle(ServerRequestInterface $request) : ResponseInterface {
/**
* {@inheritDoc}
*
* @param ServerRequestInterface $request The incoming request
*
* @return ResponseInterface
*/
public function handle(ServerRequestInterface $request) : ResponseInterface
{
$desc = $this->loris->getConfiguration()->getSetting('projectDescription');
return new \LORIS\Http\Response\JSON\OK(['Description' => $desc]);
}
public function _hasAccess(\User $user) {

/**
* The hasAccess call called by the Module class before loading the page.
*
* @param \User $user The user accessing the page
*
* @return bool
*/
function _hasAccess(\User $user)
{
return true;
}
}
5 changes: 3 additions & 2 deletions src/Http/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,14 @@ public function hasAccess(\User $user): bool
* This function can be overridden in a module's page to load the necessary
* resources to check the permissions of a user.
*
* @param User $user The user to load the resources for
* @param \User $user The user to load the resources for
* @param ServerRequestInterface $request The PSR15 Request being handled
*
* @return void
*/
public function loadResources(
\User $user, ServerRequestInterface $request
\User $user,
ServerRequestInterface $request
) : void {
}
}

0 comments on commit 1f747d6

Please # to comment.