Skip to content
Snippets Groups Projects
Commit 84e5e8d7 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

TandemPlugin: added support for storing and displaying terminated tandem pairs

git-svn-id: https://server2.data-quest.de/svn/studip-plugins/TandemPlugin@3015 6a1f69d7-6018-4d13-bf90-b098e98c258d
parent a4389c36
No related branches found
No related tags found
No related merge requests found
......@@ -124,6 +124,12 @@ class TandemPlugin extends StudIPPlugin implements SystemPlugin, PortalPlugin
);
$navigation->addSubNavigation('rejected', $sub_navigation);
$sub_navigation = new Navigation(
dgettext('TandemPlugin', 'Aufgelöste Tandems'),
PluginEngine::getURL('tandemplugin/admin/terminated_pairs')
);
$navigation->addSubNavigation('terminated', $sub_navigation);
$sub_navigation = new Navigation(
dgettext('TandemPlugin', 'Konfiguration'),
PluginEngine::getURL('tandemplugin/admin/config')
......
......@@ -566,6 +566,18 @@ class TandemManager
}
//Before we delete anything we create a TerminatedTandemPair object:
$terminated_pair = $pair->createTerminatedTandemPair();
if ($terminated_pair) {
if (!$terminated_pair->store()) {
//Terminated pair could not be stored!
return false;
}
} else {
//Terminated pair could not be created!
return false;
}
//Object deletion:
//Additionally to terminating (deleting) the tandem pair
......@@ -587,6 +599,7 @@ class TandemManager
}
}
if($pair->delete()) {
return true;
}
......
......@@ -171,6 +171,21 @@ class AdminController extends PluginController
}
public function terminated_pairs_action()
{
if(Navigation::hasItem('/tandemplugin/admin/terminated')) {
Navigation::activateItem('/tandemplugin/admin/terminated');
}
$this->terminated_pairs = [];
$this->terminated_pairs = TerminatedTandemPair::findBySql(
'TRUE ORDER BY mkdate DESC',
[]
);
}
public function config_action()
{
if(Navigation::hasItem('/tandemplugin/admin/config')) {
......
No preview for this file type
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: TandemPlugin\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-05 16:02+0200\n"
"PO-Revision-Date: 2017-05-05 16:02+0100\n"
"POT-Creation-Date: 2017-07-11 13:45+0200\n"
"PO-Revision-Date: 2017-07-11 13:47+0100\n"
"Last-Translator: Moritz Strohm <strohm@data-quest.de>\n"
"Language-Team: data-quest <info@data-quest.de>\n"
"Language: en\n"
......@@ -18,6 +18,67 @@ msgstr ""
"X-Generator: Poedit 1.6.10\n"
"X-Poedit-SourceCharset: windows-1252\n"
#: views/admin/terminated_pairs.php:3 TandemPlugin.class.php:128
msgid "Aufgelste Tandems"
msgstr "Terminated tandems"
#: views/admin/terminated_pairs.php:10 views/admin/terminated_pairs.php:14
#: views/admin/terminated_pairs.php:39 views/admin/terminated_pairs.php:77
#: views/admin/pairs.php:16 views/admin/pairs.php:20
msgid "Unbekannte Sprache"
msgstr "Unknown language"
#: views/admin/terminated_pairs.php:22 views/admin/terminated_pairs.php:60
msgid "unbekannt"
msgstr "unknown"
#: views/admin/terminated_pairs.php:32 views/admin/terminated_pairs.php:70
msgid "Nachricht schreiben"
msgstr "Send message to both"
#: views/admin/terminated_pairs.php:36 views/admin/terminated_pairs.php:74
msgid "Gesuchte Sprache und Sprachniveau"
msgstr "Requested language and language niveau"
#: views/admin/terminated_pairs.php:42 views/admin/terminated_pairs.php:80
msgid "Gewnschtes Geschlecht"
msgstr "Requested gender"
#: views/admin/terminated_pairs.php:44 views/admin/terminated_pairs.php:82
#: views/_common/_profile.php:31
msgid "mnnlich"
msgstr "male"
#: views/admin/terminated_pairs.php:46 views/admin/terminated_pairs.php:84
#: views/_common/_profile.php:33
msgid "weiblich"
msgstr "female"
#: views/admin/terminated_pairs.php:47 views/admin/terminated_pairs.php:85
msgid "Keine Prferenz"
msgstr "No preference"
#: views/admin/terminated_pairs.php:48 views/admin/terminated_pairs.php:86
msgid "Kommentar zum Gesuch"
msgstr "Commentary from request"
#: views/admin/terminated_pairs.php:52 views/admin/terminated_pairs.php:90
msgid "kein Kommentar angegeben"
msgstr "No comment provided"
#: views/admin/terminated_pairs.php:97
#, php-format
msgid "Aufgelst am %1$s um %2$s Uhr"
msgstr "Terminated on %1$s at %2$s"
#: views/admin/terminated_pairs.php:104 views/admin/pairs.php:30
msgid "Nachricht an beide schicken"
msgstr "Send message to both"
#: views/admin/terminated_pairs.php:122
msgid "Es wurden keine aufgelsten Tandems gefunden!"
msgstr "No terminated tandems have been found!"
#: views/admin/config.php:1
msgid "Konfiguration des Tandem-Plugins"
msgstr "Tandem Plugin configuration"
......@@ -84,15 +145,7 @@ msgstr "Requested tandems"
msgid "Etablierte Tandems"
msgstr "Established tandems"
#: views/admin/pairs.php:16 views/admin/pairs.php:20
msgid "Unbekannte Sprache"
msgstr "Unknown language"
#: views/admin/pairs.php:29
msgid "Nachricht an beide schicken"
msgstr "Send message to both"
#: views/admin/pairs.php:41
#: views/admin/pairs.php:43
msgid "Es wurden keine Tandems gefunden!"
msgstr "No tandems have been found!"
......@@ -356,75 +409,67 @@ msgstr "Create tandem"
msgid "Kein Tandem bilden"
msgstr "Do not create tandem"
#: views/_common/_profile.php:12
#: views/_common/_profile.php:14
msgid "Unbekannter Nutzer"
msgstr "Unknown user"
#: views/_common/_profile.php:24
#: views/_common/_profile.php:29
msgid "Geschlecht"
msgstr "Gender"
#: views/_common/_profile.php:27
msgid "mnnlich"
msgstr "male"
#: views/_common/_profile.php:29
msgid "weiblich"
msgstr "female"
#: views/_common/_profile.php:30 views/_common/_profile.php:47
#: views/_common/_profile.php:34 views/_common/_profile.php:51
msgid "Keine Angabe"
msgstr "No information"
#: views/_common/_profile.php:44
#: views/_common/_profile.php:48
msgid "Studiengnge"
msgstr "Course of studies"
#: views/_common/_profile.php:60
#: views/_common/_profile.php:64
msgid "Sucht"
msgstr "Seeks"
#: views/_common/_profile.php:64
#: views/_common/_profile.php:68
msgid "Spricht"
msgstr "Speaks"
#: views/_common/_profile.php:116
#: views/_common/_profile.php:120
msgid "Bemerkung"
msgstr "Notes"
#: views/_common/_profile.php:124
#: views/_common/_profile.php:128
msgid "Leistungsbescheinigung"
msgstr "Proof of achievement"
#: views/_common/_profile.php:125 views/_common/_profile.php:131
#: views/_common/_profile.php:129 views/_common/_profile.php:135
msgid "gewnscht"
msgstr "requested"
#: views/_common/_profile.php:130
#: views/_common/_profile.php:134
msgid "Teilnahmebesttigung"
msgstr "Proof of attendance"
#: models/TandemPair.class.php:136
#: models/TandemPair.class.php:139
msgid "Angefragt"
msgstr "Requested"
#: models/TandemPair.class.php:140
#: models/TandemPair.class.php:143
msgid "Noch nicht entschieden"
msgstr "Undecided"
#: models/TandemPair.class.php:142
#: models/TandemPair.class.php:145
msgid "Nutzer nicht beteiligt!"
msgstr "User not involved!"
#: models/TandemPair.class.php:145
#: models/TandemPair.class.php:148
msgid "Angenommen"
msgstr "Accepted"
#: models/TandemPair.class.php:147
#: models/TandemPair.class.php:150
msgid "Abgelehnt"
msgstr "Rejected"
#: models/TandemPair.class.php:149
#: models/TandemPair.class.php:152
msgid "Unbekannter Status"
msgstr "Unknown status"
......@@ -748,7 +793,7 @@ msgstr "CSV export"
msgid "Tandem-Paare"
msgstr "Tandem pairs"
#: controllers/admin.php:192
#: controllers/admin.php:207
msgid ""
"Die Anzahl an Monaten, nach denen alte Gesuche entfernt werden sollen, muss "
"zwischen 1 und 24 liegen!"
......@@ -756,7 +801,7 @@ msgstr ""
"The amount of months after which old requests will be deleted has to lie "
"between 1 and 24!"
#: controllers/admin.php:212
#: controllers/admin.php:227
msgid "Die Konfiguration wurde gespeichert!"
msgstr "The configuration has been saved!"
......@@ -768,11 +813,11 @@ msgstr "My tandems"
msgid "Tandem-Verwaltung"
msgstr "Tandem management"
#: TandemPlugin.class.php:128
#: TandemPlugin.class.php:134
msgid "Konfiguration"
msgstr "Configuration"
#: TandemPlugin.class.php:140 TandemPlugin.class.php:186
#: TandemPlugin.class.php:146 TandemPlugin.class.php:192
msgid "Sprachtandem"
msgstr "Language tandem"
......
<?php
/**
* This file is part of the TandemPlugin for Stud.IP
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Moritz Strohm <strohm@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Plugin
**/
class AddTerminatedTandemPairs extends Migration
{
public function up()
{
$db = DBManager::get();
//Create table:
$db->exec(
"CREATE TABLE IF NOT EXISTS terminated_tandem_pairs (
id VARCHAR(32) PRIMARY KEY NOT NULL,
requester_user_id VARCHAR(32) NOT NULL,
requester_level VARCHAR(2) NOT NULL DEFAULT '',
requester_language_id VARCHAR(32) NOT NULL,
requester_comment TEXT NULL,
requested_gender VARCHAR(1) NULL DEFAULT '',
offerer_user_id VARCHAR(32) NOT NULL,
offerer_level VARCHAR(2) NOT NULL DEFAULT '',
offerer_language_id VARCHAR(32) NOT NULL,
offerer_comment TEXT NULL,
offered_gender VARCHAR(1) NULL DEFAULT '',
mkdate BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
chdate BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'
);"
);
//close DB connection:
$db = null;
}
public function down()
{
$db = DBManager::get();
//Drop table:
$db->exec('DROP TABLE IF EXISTS terminated_tandem_pairs;');
//close DB connection:
$db = null;
}
}
......@@ -14,6 +14,9 @@
**/
require_once(__DIR__ . '/TerminatedTandemPair.class.php');
/**
* A model class to store tandem pairs for the TandemPlugin.
*
......@@ -151,4 +154,24 @@
}
/**
* Factory method that creates a TerminatedTandemPair out of this TandemPair.
*
* @returns TerminatedTandemPair|null A TerminatedTandemPair object or null on failure.
*/
public function createTerminatedTandemPair()
{
$terminated_pair = new TerminatedTandemPair();
$terminated_pair->requester_user_id = $this->request->user_id;
$terminated_pair->requester_level = $this->request->level;
$terminated_pair->requester_language_id = $this->request->target_language_id;
$terminated_pair->requester_comment = $this->request->comment;
$terminated_pair->requested_gender = $this->request->gender;
$terminated_pair->offerer_user_id = $this->offer->user_id;
$terminated_pair->offerer_level = $this->offer->level;
$terminated_pair->offerer_language_id = $this->offer->target_language_id;
$terminated_pair->offerer_comment = $this->offer->comment;
$terminated_pair->offered_gender = $this->offer->gender;
return $terminated_pair;
}
}
<?php
/**
* This file is part of the TandemPlugin for Stud.IP
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Moritz Strohm <strohm@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Plugin
**/
/**
* A model class to store terminated tandem pairs for the TandemPlugin.
*
* @property string id Generated MD5 hash
* @property string requester_user_id A reference to a user.
* @property string requester_language_id The ID of the first tandem language.
* @property string offerer_user_id A reference to a user.
* @property string offerer_language_id The ID of the second tandem language.
* @property string mkdate database column
* @property string chdate database column
* @property User requester belongs to User
* @property TandemLanguage requester_language belongs to TandemLanguage
* @property User offerer belongs to User
* @property TandemLanguage offerer_language belongs to TandemLanguage
*/
class TerminatedTandemPair extends SimpleORMap
{
static protected function configure($config = [])
{
$config['db_table'] = 'terminated_tandem_pairs';
$config['belongs_to']['requester'] = [
'class_name' => 'User',
'foreign_key' => 'requester_user_id',
'assoc_func' => 'find'
];
$config['belongs_to']['requester_language'] = [
'class_name' => 'TandemLanguage',
'foreign_key' => 'requester_language_id',
'assoc_func' => 'find'
];
$config['belongs_to']['offerer'] = [
'class_name' => 'User',
'foreign_key' => 'offerer_user_id',
'assoc_func' => 'find'
];
$config['belongs_to']['offerer_language'] = [
'class_name' => 'TandemLanguage',
'foreign_key' => 'offerer_language_id',
'assoc_func' => 'find'
];
parent::configure($config);
}
}
pluginname=TandemPlugin
pluginclassname=TandemPlugin
origin=data-quest
version=0.5.3
version=0.6
description=Dieses Plugin ermglicht es, Sprachtandems innerhalb der Stud.IP Platform zu bilden.
studipMinVersion=3.5
studipMaxVersion=3.9.99
<? if($terminated_pairs): ?>
<table class="default">
<caption><?= dgettext('TandemPlugin', 'Aufgelste Tandems') ?></caption>
<? foreach($terminated_pairs as $terminated_pair): ?>
<tr>
<th colspan="3">
<strong>
<?= $terminated_pair->requester_language
? htmlReady($terminated_pair->requester_language->getLocalName())
: dgettext('TandemPlugin', 'Unbekannte Sprache') ?>
<?= Icon::create('group', 'info')->asImg('16px', ['class' => 'text-bottom']) ?>
<?= $terminated_pair->offerer_language
? htmlReady($terminated_pair->offerer_language->getLocalName())
: dgettext('TandemPlugin', 'Unbekannte Sprache') ?>
</strong>
</th>
</td>
<tr>
<td>
<?= ($terminated_pair->requester
? htmlReady($terminated_pair->requester->getFullName())
: dgettext('TandemPlugin', 'unbekannt')
) ?>
<a href="<?= URLHelper::getURL(
'dispatch.php/messages/write',
[
'rec_uname' => [
$terminated_pair->requester->username
]
]
) ?>" data-dialog="1"
title="<?= dgettext('TandemPlugin', 'Nachricht schreiben') ?>">
<?= Icon::create('mail', 'clickable')->asImg('20px', ['class' => 'text-bottom']) ?>
</a>
<dl>
<dt><?= dgettext('TamdenPlugin', 'Gesuchte Sprache und Sprachniveau') ?></dt>
<dd><?= $terminated_pair->requester_language
? htmlReady($terminated_pair->requester_language->getLocalName())
: dgettext('TandemPlugin', 'Unbekannte Sprache') ?>
(<?= htmlReady($terminated_pair->requester_level) ?>)
</dd>
<dt><?= dgettext('TamdenPlugin', 'Gewnschtes Geschlecht') ?></dt>
<dd><?= ($terminated_pair->requested_gender == '1')
? dgettext('TandemPlugin', 'mnnlich')
: (($terminated_pair->requested_gender == '2')
? dgettext('TandemPlugin', 'weiblich')
: dgettext('TandemPlugin', 'Keine Prferenz')) ?></dd>
<dt><?= dgettext('TamdenPlugin', 'Kommentar zum Gesuch') ?></dt>
<dd>
<?= ($terminated_pair->requester_comment)
? htmlReady($terminated_pair->requester_comment)
: '(' . dgettext('TandemPlugin', 'kein Kommentar angegeben') . ')'
?>
</dd>
</dl>
</td>
<td>
<?= ($terminated_pair->offerer
? htmlReady($terminated_pair->offerer->getFullName())
: dgettext('TandemPlugin', 'unbekannt')
) ?>
<a href="<?= URLHelper::getURL(
'dispatch.php/messages/write',
[
'rec_uname' => [
$terminated_pair->offerer->username
]
]
) ?>" data-dialog="1"
title="<?= dgettext('TandemPlugin', 'Nachricht schreiben') ?>">
<?= Icon::create('mail', 'clickable')->asImg('20px', ['class' => 'text-bottom']) ?>
</a>
<dl>
<dt><?= dgettext('TamdenPlugin', 'Gesuchte Sprache und Sprachniveau') ?></dt>
<dd><?= $terminated_pair->offerer_language
? htmlReady($terminated_pair->offerer_language->getLocalName())
: dgettext('TandemPlugin', 'Unbekannte Sprache') ?>
(<?= htmlReady($terminated_pair->offerer_level) ?>)
</dd>
<dt><?= dgettext('TamdenPlugin', 'Gewnschtes Geschlecht') ?></dt>
<dd><?= ($terminated_pair->offered_gender == '1')
? dgettext('TandemPlugin', 'mnnlich')
: (($terminated_pair->offered_gender == '2')
? dgettext('TandemPlugin', 'weiblich')
: dgettext('TandemPlugin', 'Keine Prferenz')) ?></dd>
<dt><?= dgettext('TamdenPlugin', 'Kommentar zum Gesuch') ?></dt>
<dd>
<?= ($terminated_pair->offerer_comment)
? htmlReady($terminated_pair->offerer_comment)
: '(' . dgettext('TandemPlugin', 'kein Kommentar angegeben') . ')'
?>
</dd>
</dl>
</td>
<td>
<?= sprintf(
dgettext('TandemPlugin', 'Aufgelst am %1$s um %2$s Uhr'),
date('d.m.Y', $terminated_pair->mkdate),
date('H:i', $terminated_pair->mkdate)
) ?>
<? if ($terminated_pair->requester and $terminated_pair->offerer): ?>
<div>
<?= \Studip\LinkButton::create(
dgettext('TandemPlugin', 'Nachricht an beide schicken'),
URLHelper::getURL(
'dispatch.php/messages/write',
[
'rec_uname' => [
$terminated_pair->requester->username, $terminated_pair->offerer->username
]
]
),
['data-dialog' => '1']
) ?>
</div>
<? endif ?>
</td>
</tr>
<? endforeach ?>
</table>
<? else: ?>
<?= MessageBox::info(dgettext('TandemPlugin', 'Es wurden keine aufgelsten Tandems gefunden!')) ?>
<? endif ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment