v1.0.43 - use OCS controller
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<name>Minimal Profile</name>
|
<name>Minimal Profile</name>
|
||||||
<summary>Hides profile fields to create a minimal user profile</summary>
|
<summary>Hides profile fields to create a minimal user profile</summary>
|
||||||
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
||||||
<version>1.0.42</version>
|
<version>1.0.43</version>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Your Name</author>
|
<author>Your Name</author>
|
||||||
<namespace>MinimalProfile</namespace>
|
<namespace>MinimalProfile</namespace>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'routes' => [
|
'ocs' => [
|
||||||
['name' => 'api#getHiddenFields', 'url' => '/api/v1/hidden-fields', 'verb' => 'GET'],
|
['name' => 'api#getHiddenFields', 'url' => '/api/v1/hidden-fields', 'verb' => 'GET'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* MinimalProfile v41 - API-based config
|
* MinimalProfile v42 - OCS API
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('MinimalProfile v41: Starting');
|
console.log('MinimalProfile v42: Starting');
|
||||||
|
|
||||||
var map = {
|
var map = {
|
||||||
'pronouns': '#account-property-pronouns',
|
'pronouns': '#account-property-pronouns',
|
||||||
@@ -36,22 +36,22 @@
|
|||||||
|
|
||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', '/apps/minimalprofile/api/v1/hidden-fields', true);
|
xhr.open('GET', '/ocs/v2.php/apps/minimalprofile/api/v1/hidden-fields', true);
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
try {
|
try {
|
||||||
var data = JSON.parse(xhr.responseText);
|
var data = JSON.parse(xhr.responseText);
|
||||||
console.log('MinimalProfile v41: API returned', data.hiddenFields);
|
console.log('MinimalProfile v42: API returned', data.ocs.data.hiddenFields);
|
||||||
hideFields(data.hiddenFields);
|
hideFields(data.ocs.data.hiddenFields);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error('MinimalProfile v41: JSON parse error', e);
|
console.error('MinimalProfile v42: JSON parse error', e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error('MinimalProfile v41: API failed', xhr.status);
|
console.error('MinimalProfile v42: API failed', xhr.status);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = function() {
|
xhr.onerror = function() {
|
||||||
console.error('MinimalProfile v41: Network error');
|
console.error('MinimalProfile v42: Network error');
|
||||||
};
|
};
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,21 +4,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace OCA\MinimalProfile\Controller;
|
namespace OCA\MinimalProfile\Controller;
|
||||||
|
|
||||||
use OCP\AppFramework\Controller;
|
|
||||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||||
use OCP\AppFramework\Http\Attribute\PublicPage;
|
use OCP\AppFramework\Http\Attribute\PublicPage;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\AppFramework\OCSController;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
|
||||||
class ApiController extends Controller {
|
class ApiController extends OCSController {
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $appName,
|
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
private IConfig $config,
|
private IConfig $config,
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct('minimalprofile', $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
|
|||||||
Reference in New Issue
Block a user