diff options
Diffstat (limited to 'modules/sharemode.inc.php')
-rw-r--r-- | modules/sharemode.inc.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/modules/sharemode.inc.php b/modules/sharemode.inc.php new file mode 100644 index 0000000..ed7c4a4 --- /dev/null +++ b/modules/sharemode.inc.php @@ -0,0 +1,51 @@ +<?php + +class Page_ShareMode extends Page +{ + + public function doPreprocess() + { + if (!User::load()) { + Message::addError('Sie sind nicht angemeldet'); + Util::redirect(CONFIG_PREFIX); + } + // Äktschn + if (Request::post('action') === 'deploy') { + User::deploy(false); + Message::addSuccess('Sie haben sich erfolgreich für die Teilnahme am VM-Austausch freigeschaltet'); + Util::redirect('?do=Main'); + } else if (Request::post('action') === 'remove') { + User::deploy(true); + if (Request::post('delvms', 'off') !== 'off') { + $del = Image::deleteOwnedBy(User::getId()); + if ($del > 1) + Message::addSuccess('Es wurden {{0}} VMs gelöscht', $del); + if ($del == 1) + Message::addSuccess('Es wurde {{0}} VM gelöscht', $del); + } + Message::addSuccess('Ihre persönlichen Daten wurden deprovisioniert'); + Util::redirect('?do=Main'); + } + } + + public function doRender() + { + if (User::isLocalOnly()) { + // Local anyways, no way to de-provision user data + Render::addTemplate('sharemode/testacc'); + } elseif (User::isShibbolethAuth()) { + // Shibboleth user + if (User::isAnonymous()) { + // Did not deploy user data to DB, so show deploy form + $data = User::getData(); + $data['organization'] = User::getOrganizationName(); + Render::addTemplate('sharemode/deploy', $data); + } else { + // User is known in DB, show delete form + Render::addTemplate('sharemode/remove'); + } + } + } + +} + |