Initial push
This commit is contained in:
@@ -2,14 +2,17 @@
|
||||
|
||||
/**
|
||||
* Name: SCN01 Scenarios
|
||||
* Description: Public civic diagnostic — browse and submit diagnostic scenarios.
|
||||
* Version: 0.2.0
|
||||
* Description: Public civic diagnostic — browse and submit diagnostic scenarios in plain language.
|
||||
* Version: 0.3.0
|
||||
* MinVersion: 11.0
|
||||
* MaxVersion: 12.0
|
||||
*/
|
||||
|
||||
use Zotlabs\Extend\Widget;
|
||||
|
||||
require_once 'addon/scn01/scn01_renderer.php';
|
||||
require_once 'addon/scn01/scn01_spool.php';
|
||||
|
||||
function scn01_module() {}
|
||||
|
||||
function scn01_load() {
|
||||
@@ -101,7 +104,7 @@ function scn01_access_state($association_slug = '') {
|
||||
intval($prof_gid),
|
||||
dbesc($observer)
|
||||
);
|
||||
if ($r) return 'participant';
|
||||
if ($r) return 'professional';
|
||||
}
|
||||
|
||||
return 'public';
|
||||
@@ -127,7 +130,7 @@ function scn01_access_wall($association_slug = '') {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CONTENT
|
||||
// CONTENT ROUTER
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function scn01_content() {
|
||||
@@ -140,37 +143,40 @@ function scn01_content() {
|
||||
|
||||
$association_slug = argv(1) ?? '';
|
||||
|
||||
// Index — no association selected
|
||||
if (!$association_slug) {
|
||||
return scn01_render_index();
|
||||
}
|
||||
|
||||
$raw = @file_get_contents('addon/vs01/config.json');
|
||||
$cfg = $raw ? json_decode($raw, true) : [];
|
||||
if (json_last_error() !== JSON_ERROR_NONE || !isset($cfg['associations'][$association_slug])) {
|
||||
return scn01_render_not_found();
|
||||
}
|
||||
|
||||
$access = scn01_access_state($association_slug);
|
||||
|
||||
// scn01 is public — access wall only gates submission, not reading
|
||||
// POST — submission handler
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if ($access === 'public') {
|
||||
return scn01_access_wall($association_slug);
|
||||
}
|
||||
// TODO: handle POST submission
|
||||
return scn01_access_wall($association_slug);
|
||||
if (!scn01_verify_csrf()) {
|
||||
return '<div class="alert alert-danger">Invalid form token. Please reload and try again.</div>';
|
||||
}
|
||||
return scn01_handle_post($association_slug, $access);
|
||||
}
|
||||
|
||||
return scn01_render_main($access);
|
||||
// Association landing — carousel + submission form
|
||||
return scn01_render_landing($association_slug, $access);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// RENDER
|
||||
// NOT FOUND
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function scn01_render_main($access) {
|
||||
$out = '<div class="scn01-content">';
|
||||
$out .= '<div class="scn01-header mb-3">';
|
||||
$out .= '<h2>Scenarios</h2>';
|
||||
$out .= '<p class="text-muted">Browse diagnostic scenarios. When you find one close to your situation, submit your account in your own words.</p>';
|
||||
$out .= '</div>';
|
||||
|
||||
// TODO: render scenarios
|
||||
|
||||
$out .= '<div class="scn01-placeholder text-muted fst-italic">Content forthcoming.</div>';
|
||||
$out .= '</div>';
|
||||
|
||||
return $out;
|
||||
function scn01_render_not_found() {
|
||||
return '<div class="scn01-content"><div class="alert alert-warning">Association not found.</div></div>';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user