summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-10 18:52:17 +0200
committerSimon Rettberg2015-09-10 18:52:17 +0200
commite529743b9c18838cc6eedbaa85c17456f9dbb279 (patch)
tree772664806316f4d6d8fded117bdf2ce086c87135
parentAdd dozmod config page (diff)
downloadslx-admin-e529743b9c18838cc6eedbaa85c17456f9dbb279.tar.gz
slx-admin-e529743b9c18838cc6eedbaa85c17456f9dbb279.tar.xz
slx-admin-e529743b9c18838cc6eedbaa85c17456f9dbb279.zip
Add org list to dozmod module
-rw-r--r--lang/de/messages.json1
-rw-r--r--lang/de/templates/dozmod/mailconfig.json20
-rw-r--r--lang/de/templates/dozmod/orglist.json6
-rw-r--r--lang/de/templates/dozmod/userlist.json11
-rw-r--r--lang/de/templates/main-menu.json1
-rw-r--r--lang/en/messages.json1
-rw-r--r--lang/en/templates/dozmod/mailconfig.json20
-rw-r--r--lang/en/templates/dozmod/orglist.json6
-rw-r--r--lang/en/templates/dozmod/userlist.json11
-rw-r--r--lang/en/templates/main-menu.json1
-rw-r--r--lang/pt/templates/dozmod/mailconfig.json3
-rw-r--r--lang/pt/templates/dozmod/orglist.json3
-rw-r--r--lang/pt/templates/dozmod/userlist.json3
-rw-r--r--modules/dozmod.inc.php84
-rw-r--r--templates/dozmod/orglist.html51
-rw-r--r--templates/dozmod/userlist.html91
-rw-r--r--templates/main-menu.html3
17 files changed, 277 insertions, 39 deletions
diff --git a/lang/de/messages.json b/lang/de/messages.json
index 7e449f8d..eddc564a 100644
--- a/lang/de/messages.json
+++ b/lang/de/messages.json
@@ -24,6 +24,7 @@
"invalid-path": "Ung\u00fcltiger Pfad.",
"invalid-template": "Ausgew\u00e4hlte Template ist nicht g\u00fcltig",
"loginfail": "Benutzername oder Kennwort falsch",
+ "mail-config-saved": "Mail-Konfiguration gespeichert",
"missing-file": "Es wurde keine Datei ausgew\u00e4hlt!",
"missing-title": "Kein Titel eingegeben",
"module-added": "Modul erfolgreich hinzugef\u00fcgt",
diff --git a/lang/de/templates/dozmod/mailconfig.json b/lang/de/templates/dozmod/mailconfig.json
new file mode 100644
index 00000000..dde03c55
--- /dev/null
+++ b/lang/de/templates/dozmod/mailconfig.json
@@ -0,0 +1,20 @@
+{
+ "lang_asteriskRequired": "Felder mit (*) sind erforderlich",
+ "lang_host": "Host",
+ "lang_mailConfig": "SMTP-Konfiguration zum Versenden von Mails",
+ "lang_mailConfigHeadline": "EMail-Konfiguration",
+ "lang_password": "Passwort",
+ "lang_port": "Port",
+ "lang_replyTo": "Reply-To Adresse (z.B. Helpdesk)",
+ "lang_save": "Konfiguration speichern",
+ "lang_senderAddress": "Absenderadresse",
+ "lang_senderName": "Absender Anzeigename",
+ "lang_ssl": "SSL-Modus",
+ "lang_sslExplicit": "Explizites SSL (\"STARTTLS\")",
+ "lang_sslImplicit": "Implizites SSL",
+ "lang_sslNone": "Kein SSL",
+ "lang_test": "Test-Mail senden",
+ "lang_testConfiguration": "Um die Konfiguration zu testen, geben Sie hier eine Empf\u00e4ngeradresse ein",
+ "lang_testRecipient": "Empf\u00e4nger",
+ "lang_username": "Benutzername (SMTP-Auth)"
+} \ No newline at end of file
diff --git a/lang/de/templates/dozmod/orglist.json b/lang/de/templates/dozmod/orglist.json
new file mode 100644
index 00000000..938429f0
--- /dev/null
+++ b/lang/de/templates/dozmod/orglist.json
@@ -0,0 +1,6 @@
+{
+ "lang_canLogin": "Nutzer dieser Einrichtung k\u00f6nnen sich am Satelliten anmelden",
+ "lang_organization": "Einrichtung",
+ "lang_organizationList": "Liste der Einrichtungen",
+ "lang_organizationListHeader": "Nutzungsrechte f\u00fcr den Satelliten festlegen"
+} \ No newline at end of file
diff --git a/lang/de/templates/dozmod/userlist.json b/lang/de/templates/dozmod/userlist.json
new file mode 100644
index 00000000..5c9a0f5f
--- /dev/null
+++ b/lang/de/templates/dozmod/userlist.json
@@ -0,0 +1,11 @@
+{
+ "lang_canLogin": "Dieser Benutzer kann sich am Satelilten anmelden",
+ "lang_email": "EMail",
+ "lang_emailNotifications": "EMail-Benachrichtigungen aktiviert",
+ "lang_lastLogin": "Letzte Anmeldung",
+ "lang_organization": "Organisation",
+ "lang_superUser": "Ist SuperUser (darf alle Veranstaltungen und VMs bearbeiten\/l\u00f6schen)",
+ "lang_user": "Benutzername",
+ "lang_userList": "Benutzerliste",
+ "lang_userListHeader": "Dem Satelliten bekannte Benutzer"
+} \ No newline at end of file
diff --git a/lang/de/templates/main-menu.json b/lang/de/templates/main-menu.json
index 98896969..efd918a3 100644
--- a/lang/de/templates/main-menu.json
+++ b/lang/de/templates/main-menu.json
@@ -4,6 +4,7 @@
"lang_clientLog": "Client Log",
"lang_configurationBasic": "PXE\/Boot",
"lang_configurationVariables": "KonfigurationsVariablen",
+ "lang_dozmod": "Dozentenmodul",
"lang_eventLog": "Server Log",
"lang_internetAccess": "Internetzugriff",
"lang_language": "Sprachen",
diff --git a/lang/en/messages.json b/lang/en/messages.json
index 10314625..a18d2287 100644
--- a/lang/en/messages.json
+++ b/lang/en/messages.json
@@ -24,6 +24,7 @@
"invalid-path": "Invalid path.",
"invalid-template": "Selected template is not valid",
"loginfail": "Username or Password incorrect",
+ "mail-config-saved": "Mail config saved",
"missing-file": "There was no file selected!",
"missing-title": "No title given",
"module-added": "Module successfully added",
diff --git a/lang/en/templates/dozmod/mailconfig.json b/lang/en/templates/dozmod/mailconfig.json
new file mode 100644
index 00000000..7628615e
--- /dev/null
+++ b/lang/en/templates/dozmod/mailconfig.json
@@ -0,0 +1,20 @@
+{
+ "lang_asteriskRequired": "Fields marked with (*) are required",
+ "lang_host": "Host",
+ "lang_mailConfig": "SMTP configuration for sending mails",
+ "lang_mailConfigHeadline": "email configuration",
+ "lang_password": "Password",
+ "lang_port": "Port",
+ "lang_replyTo": "Reply-To address",
+ "lang_save": "Save configuration",
+ "lang_senderAddress": "Sender address",
+ "lang_senderName": "Sender's display name",
+ "lang_ssl": "SSL mode",
+ "lang_sslExplicit": "Explicit SSL (\"STARTTLS\")",
+ "lang_sslImplicit": "Implicit SSL",
+ "lang_sslNone": "No SSL",
+ "lang_test": "Send test mail",
+ "lang_testConfiguration": "To test the configuration, enter a recipient address here",
+ "lang_testRecipient": "Recipient",
+ "lang_username": "User name (SMTP auth)"
+} \ No newline at end of file
diff --git a/lang/en/templates/dozmod/orglist.json b/lang/en/templates/dozmod/orglist.json
new file mode 100644
index 00000000..37b89e02
--- /dev/null
+++ b/lang/en/templates/dozmod/orglist.json
@@ -0,0 +1,6 @@
+{
+ "lang_canLogin": "Members of this organization can login",
+ "lang_organization": "Organization",
+ "lang_organizationList": "List of organizations",
+ "lang_organizationListHeader": "Set access permissions for organizations"
+} \ No newline at end of file
diff --git a/lang/en/templates/dozmod/userlist.json b/lang/en/templates/dozmod/userlist.json
new file mode 100644
index 00000000..d6eca1c1
--- /dev/null
+++ b/lang/en/templates/dozmod/userlist.json
@@ -0,0 +1,11 @@
+{
+ "lang_canLogin": "This user can login to this satellite",
+ "lang_email": "E-Mail",
+ "lang_emailNotifications": "E-Mail notifications enabled",
+ "lang_lastLogin": "Last login",
+ "lang_organization": "Organization",
+ "lang_superUser": "Is super user (can edit\/delete all lectures and VMs)",
+ "lang_user": "User name",
+ "lang_userList": "User list",
+ "lang_userListHeader": "Users known to this satellite"
+} \ No newline at end of file
diff --git a/lang/en/templates/main-menu.json b/lang/en/templates/main-menu.json
index 4cb9cb74..839d65b1 100644
--- a/lang/en/templates/main-menu.json
+++ b/lang/en/templates/main-menu.json
@@ -4,6 +4,7 @@
"lang_clientLog": "Client Log",
"lang_configurationBasic": "PXE\/Boot",
"lang_configurationVariables": "Configuration Variables",
+ "lang_dozmod": "Tutor module",
"lang_eventLog": "Server Log",
"lang_internetAccess": "Internet access",
"lang_language": "Language",
diff --git a/lang/pt/templates/dozmod/mailconfig.json b/lang/pt/templates/dozmod/mailconfig.json
new file mode 100644
index 00000000..c44dc44f
--- /dev/null
+++ b/lang/pt/templates/dozmod/mailconfig.json
@@ -0,0 +1,3 @@
+[
+
+] \ No newline at end of file
diff --git a/lang/pt/templates/dozmod/orglist.json b/lang/pt/templates/dozmod/orglist.json
new file mode 100644
index 00000000..c44dc44f
--- /dev/null
+++ b/lang/pt/templates/dozmod/orglist.json
@@ -0,0 +1,3 @@
+[
+
+] \ No newline at end of file
diff --git a/lang/pt/templates/dozmod/userlist.json b/lang/pt/templates/dozmod/userlist.json
new file mode 100644
index 00000000..c44dc44f
--- /dev/null
+++ b/lang/pt/templates/dozmod/userlist.json
@@ -0,0 +1,3 @@
+[
+
+] \ No newline at end of file
diff --git a/modules/dozmod.inc.php b/modules/dozmod.inc.php
index a4fbf57c..cec1c114 100644
--- a/modules/dozmod.inc.php
+++ b/modules/dozmod.inc.php
@@ -16,8 +16,6 @@ class Page_DozMod extends Page
if ($action === 'mail') {
$this->mailHandler();
- } else if ($action === 'setuser') {
- $this->makeAdmin();
}
}
@@ -34,6 +32,7 @@ class Page_DozMod extends Page
Render::addTemplate('dozmod/mailconfig', $conf);
// User list for making people admin
$this->listUsers();
+ $this->listOrganizations();
}
private function cleanMailArray()
@@ -52,6 +51,21 @@ class Page_DozMod extends Page
protected function doAjax()
{
+ if (!User::hasPermission('superadmin'))
+ return;
+
+ $action = Request::post('action');
+ if ($action === 'mail') {
+ $this->handleTestMail();
+ } elseif ($action === 'setmail' || $action === 'setsu' || $action == 'setlogin') {
+ $this->setUserOption($action);
+ } elseif ($action === 'setorglogin') {
+ $this->setOrgOption($action);
+ }
+ }
+
+ private function handleTestMail()
+ {
$do = Request::post('button');
if ($do === 'test') {
// Prepare array
@@ -94,7 +108,7 @@ class Page_DozMod extends Page
. ' ORDER BY lastname ASC, firstname ASC');
$rows = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $row['isbanned'] = $this->checked($row['canlogin'] == 0);
+ $row['canlogin'] = $this->checked($row['canlogin']);
$row['issuperuser'] = $this->checked($row['issuperuser']);
$row['emailnotifications'] = $this->checked($row['emailnotifications']);
$row['lastlogin'] = date('d.m.Y', $row['lastlogin']);
@@ -102,16 +116,72 @@ class Page_DozMod extends Page
}
Render::addTemplate('dozmod/userlist', array('users' => $rows));
}
-
- private function checked($val) {
+
+ private function listOrganizations()
+ {
+ $res = Database::simpleQuery('SELECT organizationid, displayname, canlogin FROM sat.organization'
+ . ' ORDER BY displayname ASC');
+ $rows = array();
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $row['canlogin'] = $this->checked($row['canlogin']);
+ $rows[] = $row;
+ }
+ Render::addTemplate('dozmod/orglist', array('organizations' => $rows));
+ }
+
+ private function checked($val)
+ {
if ($val)
return 'checked="checked"';
return '';
}
- private function makeAdmin()
+ private function setUserOption($option)
{
-
+ $val = (string) Request::post('value', '-');
+ if ($val !== '1' && $val !== '0')
+ die('Nein');
+ if ($option === 'setmail') {
+ $field = 'emailnotifications';
+ } elseif ($option === 'setsu') {
+ $field = 'issuperuser';
+ } elseif ($option === 'setlogin') {
+ $field = 'canlogin';
+ } else {
+ die('Unknown');
+ }
+ $user = (string)Request::post('userid', '?');
+ $ret = Database::exec("UPDATE sat.user SET $field = :onoff WHERE userid = :userid", array(
+ 'userid' => $user,
+ 'onoff' => $val
+ ));
+ error_log("Setting $field to $val for $user - affected: $ret");
+ if ($ret === false)
+ die('Error');
+ if ($ret == 0)
+ die(1 - $val);
+ die($val);
+ }
+
+ private function setOrgOption($option)
+ {
+ $val = (string) Request::post('value', '-');
+ if ($val !== '1' && $val !== '0')
+ die('Nein');
+ if ($option === 'setorglogin') {
+ $field = 'canlogin';
+ } else {
+ die('Unknown');
+ }
+ $ret = Database::exec("UPDATE sat.organization SET $field = :onoff WHERE organizationid = :organizationid", array(
+ 'organizationid' => (string)Request::post('organizationid', ''),
+ 'onoff' => $val
+ ));
+ if ($ret === false)
+ die('Error');
+ if ($ret === 0)
+ die(1 - $val);
+ die($val);
}
}
diff --git a/templates/dozmod/orglist.html b/templates/dozmod/orglist.html
new file mode 100644
index 00000000..d325cc4d
--- /dev/null
+++ b/templates/dozmod/orglist.html
@@ -0,0 +1,51 @@
+<h2>{{lang_organizationList}}</h2>
+
+<div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_organizationListHeader}}
+ </div>
+ <div class="panel-body">
+ <div class="table-responsive">
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>{{lang_organization}}</th>
+ <th><span class="glyphicon glyphicon-ok" title="{{lang_canLogin}}"></span></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#organizations}}
+ <tr>
+ <td class="text-left slx-nowrap">{{displayname}}</td>
+ <td><input onclick="seto('setorglogin', this, '{{organizationid}}')" type="checkbox" {{{canlogin}}}></td>
+ </tr>
+ {{/organizations}}
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div>
+
+<script type="text/javascript"><!--
+
+function seto(action, el, orgid) {
+ var box = $(el);
+ var v = el.checked ? '1' : '0';
+ var old = el.checked == true;
+ box.css('display', 'none');
+ $.post('?do=DozMod', { token: TOKEN, action: action, organizationid: orgid, value: v }).done(function (data) {
+ if (data != 1 && data != 0) {
+ el.checked = !old;
+ box.parent().css('background-color', 'red !important');
+ } else {
+ el.checked = (data == 1);
+ }
+ box.css('display', '');
+ }).fail(function() {
+ el.checked = !old;
+ box.parent().css('background-color', 'red !important');
+ box.css('display', '');
+ });
+}
+
+--> </script> \ No newline at end of file
diff --git a/templates/dozmod/userlist.html b/templates/dozmod/userlist.html
index addb7edf..7fe52acc 100644
--- a/templates/dozmod/userlist.html
+++ b/templates/dozmod/userlist.html
@@ -1,34 +1,61 @@
<h2>{{lang_userList}}</h2>
-<div class="table-responsive">
- <form method="post" action="?do=DozMod">
- <input type="hidden" name="token" value="{{token}}">
- <input type="hidden" name="action" value="setuser">
- <table class="table table-stripped table-condensed">
- <thead>
- <tr>
- <th>{{lang_user}}</th>
- <th>{{lang_organization}}</th>
- <th>{{lang_lastLogin}}</th>
- <th>{{lang_email}}</th>
- <th><span class="glyphicon glyphicon-envelope" title="{{lang_emailNotifications}}"></span></th>
- <th><span class="glyphicon glyphicon-king" title="{{lang_superUser}}"></span></th>
- <th><span class="glyphicon glyphicon-ban-circle" title="{{lang_isBanned}}"></span></th>
- </tr>
- </thead>
- <tbody>
- {{#users}}
- <tr>
- <td class="text-left slx-nowrap">{{lastname}}, {{firstname}}</td>
- <td class="text-left slx-nowrap">{{orgname}}</td>
- <td class="text-left slx-nowrap">{{lastlogin}}</td>
- <td class="text-left slx-nowrap"><a href="mailto:{{email}}">{{email}}</a></td>
- <td><input type="checkbox" {{emailnotifications}}></td>
- <td><input type="checkbox" {{issuperuser}}></td>
- <td><input type="checkbox" {{isbanned}}></td>
- </tr>
- {{/users}}
- </tbody>
- </table>
- </form>
-</div> \ No newline at end of file
+<div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_userListHeader}}
+ </div>
+ <div class="panel-body">
+ <div class="table-responsive">
+ <table class="table table-stripped table-condensed">
+ <thead>
+ <tr>
+ <th>{{lang_user}}</th>
+ <th>{{lang_organization}}</th>
+ <th>{{lang_lastLogin}}</th>
+ <th>{{lang_email}}</th>
+ <th><span class="glyphicon glyphicon-envelope" title="{{lang_emailNotifications}}"></span></th>
+ <th><span class="glyphicon glyphicon-king" title="{{lang_superUser}}"></span></th>
+ <th><span class="glyphicon glyphicon-ok" title="{{lang_canLogin}}"></span></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#users}}
+ <tr>
+ <td class="text-left slx-nowrap">{{lastname}}, {{firstname}}</td>
+ <td class="text-left slx-nowrap">{{orgname}}</td>
+ <td class="text-left slx-nowrap">{{lastlogin}}</td>
+ <td class="text-left slx-nowrap"><a href="mailto:{{email}}">{{email}}</a></td>
+ <td><input onclick="setu('setmail', this, '{{userid}}')" type="checkbox" {{{emailnotifications}}}></td>
+ <td><input onclick="setu('setsu', this, '{{userid}}')" type="checkbox" {{{issuperuser}}}></td>
+ <td><input onclick="setu('setlogin', this, '{{userid}}')" type="checkbox" {{{canlogin}}}></td>
+ </tr>
+ {{/users}}
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div>
+
+<script type="text/javascript"><!--
+
+function setu(action, el, uid) {
+ var box = $(el);
+ var v = el.checked ? '1' : '0';
+ var old = el.checked == true;
+ box.css('display', 'none');
+ $.post('?do=DozMod', { token: TOKEN, action: action, userid: uid, value: v }).done(function (data) {
+ if (data != 1 && data != 0) {
+ el.checked = !old;
+ box.parent().css('background-color', 'red !important');
+ } else {
+ el.checked = (data == 1);
+ }
+ box.css('display', '');
+ }).fail(function() {
+ el.checked = !old;
+ box.parent().css('background-color', 'red !important');
+ box.css('display', '');
+ });
+}
+
+--> </script> \ No newline at end of file
diff --git a/templates/main-menu.html b/templates/main-menu.html
index 77d5d5ee..57576fd7 100644
--- a/templates/main-menu.html
+++ b/templates/main-menu.html
@@ -36,6 +36,9 @@
<li><a href="?do=EventLog">{{lang_eventLog}}</a></li>
</ul>
</li>
+ <li>
+ <a href="?do=DozMod">{{lang_dozmod}}</a>
+ </li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="lang/{{current_lang}}/flag.png" alt="{{current_lang}}"><b class="caret"></b></a>
<ul class="dropdown-menu">