summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSimon Rettberg2015-06-03 14:26:22 +0200
committerSimon Rettberg2015-06-03 14:26:22 +0200
commit5136f6622e7ca87695c158a31cb8e78299f1967a (patch)
tree554c58c63fdbf58401fcf4e49ac9685e1eff9634 /modules
parentAdd AddUser mask for creating test accounts (diff)
downloadbwlp-webadmin-5136f6622e7ca87695c158a31cb8e78299f1967a.tar.gz
bwlp-webadmin-5136f6622e7ca87695c158a31cb8e78299f1967a.tar.xz
bwlp-webadmin-5136f6622e7ca87695c158a31cb8e78299f1967a.zip
Allow registration, add support for creating test accounts, rename satellite to organization
Diffstat (limited to 'modules')
-rw-r--r--modules/adduser.inc.php4
-rw-r--r--modules/main.inc.php16
-rw-r--r--modules/register.inc.php31
3 files changed, 47 insertions, 4 deletions
diff --git a/modules/adduser.inc.php b/modules/adduser.inc.php
index fc0dfa7..f27717b 100644
--- a/modules/adduser.inc.php
+++ b/modules/adduser.inc.php
@@ -40,7 +40,7 @@ class Page_AddUser extends Page
$suffix = $organizationid;
$login .= "@$suffix";
}
- $ok = Database::queryFirst('SELECT organizationid FROM satellite_suffix WHERE organizationid = :o AND suffix = :s LIMIT 1', array(
+ $ok = Database::queryFirst('SELECT organizationid FROM organization_suffix WHERE organizationid = :o AND suffix = :s LIMIT 1', array(
'o' => $organizationid,
's' => $suffix
));
@@ -66,7 +66,7 @@ class Page_AddUser extends Page
protected function doRender()
{
// Show mask
- $res = Database::simpleQuery('SELECT organizationid, name FROM satellite ORDER BY name ASC');
+ $res = Database::simpleQuery('SELECT organizationid, name FROM organization ORDER BY name ASC');
$orgs = array();
$orgs[] = array(
'organizationid' => '',
diff --git a/modules/main.inc.php b/modules/main.inc.php
index c1382e6..3e3aff8 100644
--- a/modules/main.inc.php
+++ b/modules/main.inc.php
@@ -59,6 +59,22 @@ class Page_Main extends Page
{
$data = User::getData();
$data['organization'] = User::getOrganizationName();
+ // Shoe testacc merge form if organization has test accounts
+ $res = Database::queryFirst('SELECT Count(*) as cnt FROM user WHERE organizationid = :oid', array(
+ 'oid' => User::getOrganizationId()
+ ));
+ if ($res !== false && $res['cnt'] > 0) {
+ $data['testacc'] = true;
+ $mail = trim(User::getMail());
+ if (!empty($mail)) {
+ $existing = Database::queryFirst('SELECT login FROM user WHERE email = :email LIMIT 1', array(
+ 'email' => $mail
+ ));
+ if ($existing !== false) {
+ $data['testlogin'] = $existing['login'];
+ }
+ }
+ }
Render::addTemplate('main/deploy', $data);
}
diff --git a/modules/register.inc.php b/modules/register.inc.php
index 0fec4c7..d24d304 100644
--- a/modules/register.inc.php
+++ b/modules/register.inc.php
@@ -19,10 +19,37 @@ class Page_Register extends Page
Util::redirect('?do=Main');
}
+ if (Request::post('testlogin')) {
+ // Check if one of firstname, lastname or email matches
+ $user = Database::queryFirst('SELECT firstname, lastname, email, organizationid FROM user WHERE login = :login LIMIT 1', array('login' => Request::post('testlogin')));
+ if ($user === false || User::getOrganizationId() !== $user['organizationid']) {
+ // Invalid Login
+ Message::addError('Test-Account {{0}} unbekannt. '
+ . ' Bitte wenden Sie sich an den bwLehrpool-Support, wenn dieser Test-Account Ihnen gehört.', Request::post('testlogin'));
+ Util::redirect('?do=Main');
+ }
+ if (User::getLastName() !== $user['lastname']
+ && User::getFirstName() !== $user['firstname']
+ && User::getMail() !== $user['email']) {
+ // No match by personal information
+ Message::addError('Ihre Metadaten stimmen nicht mit dem Test-Account {{0}} überein. '
+ . ' Bitte wenden Sie sich an den bwLehrpool-Support, wenn dieser Test-Account Ihnen gehört.', Request::post('testlogin'));
+ Util::redirect('?do=Main');
+ }
+ // Check if anonymous is requested, but user shared VMs with his testacc
+ if (Image::getImageCount(Request::post('testlogin')) > 0) {
+ Message::addError('Sie haben mit Ihrem Test-Account Virtuelle Maschinen auf den Zentral-Server hochgeladen und können sich daher nicht ohne Teilnahme am landesweiten VM-Austausch registrieren.');
+ Util::redirect('?do=Main');
+ }
+ }
+
if (Request::post('agb') === 'on') {
// Put stuff in DB
- User::deploy(Request::post('share') !== 'on');
- Message::addSuccess('Ihr Konto wurde freigeschaltet');
+ if (User::deploy(Request::post('share') !== 'on', Request::post('testlogin'))) {
+ Message::addSuccess('Ihr Konto wurde freigeschaltet');
+ } else {
+ Message::addError('Fehler beim Zusammenführen mit Ihrem Test-Account. Bitte wenden Sie sich an den Support.');
+ }
Util::redirect('?do=Main');
}
Message::addError('Sie müssen den Nutzungsbedingungen zustimmen');