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

TandemPlugin: Implemented check for existing pairs before deleting a profile,...

TandemPlugin: Implemented check for existing pairs before deleting a profile, fixed bug in TandemManager class

git-svn-id: https://server2.data-quest.de/svn/studip-plugins/TandemPlugin@2421 6a1f69d7-6018-4d13-bf90-b098e98c258d
parent d7d9b1d9
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ class TandemManager
false,
'1',
false,
'Tandem wurde aufgelöst!',
'Bewerbung zur Tandem-Bildung!',
'1'
);
......@@ -117,13 +117,13 @@ class TandemManager
//send mail (with e-mail)
$m->insert_message(
$message_text,
$pair->request['username'],
$pair->request->user['username'],
'____%system%____',
false,
false,
'1',
false,
'Tandem wurde aufgelöst!',
'Bewerbung für Tandem wurde angenommen!',
'1'
);
......
......@@ -17,6 +17,8 @@ require_once(__DIR__ . '/../models/TandemProfile.class.php');
require_once(__DIR__ . '/../models/TandemLanguage.class.php');
require_once(__DIR__ . '/../classes/TandemMatching.class.php');
require_once(__DIR__ . '/../classes/TandemManager.class.php');
class ProfileController extends PluginController
{
......@@ -262,7 +264,32 @@ class ProfileController extends PluginController
return;
}
$this->profile_pairs = TandemPair::findBySql(
"(request_profile_id = :profile_id
OR
offer_profile_id = :profile_id)",
[
'profile_id' => $profile_id
]
);
$this->user = User::findCurrent();
if(Request::submitted('confirmed')) {
if($this->profile_pairs) {
foreach($this->profile_pairs as $pair) {
if($pair->status == 1) {
//Established pairs must be properly terminated first.
TandemManager::terminatePair($pair, $this->user);
} else {
//status == 0 or -1: undecided and rejected pairs can always be deleted
$pair->delete();
}
}
}
if($this->profile->delete()) {
PageLayout::postSuccess(
dgettext('TandemPlugin', 'Das Tandem-Profil wurde gelöscht!')
......
......@@ -54,6 +54,8 @@ class Initial extends Migration
request_profile_id VARCHAR(32) NOT NULL,
offer_profile_id VARCHAR(32) NOT NULL,
status TINYINT(1) NOT NULL,
request_visible TINYINT(1) NOT NULL DEFAULT '1',
offer_visible TINYINT(1) NOT NULL DEFAULT '1',
mkdate BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',
chdate BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'
);"
......
......@@ -105,12 +105,4 @@
}
/**
* Accepts the application for the tandem offer bound to this TandemPair
* and automatically rejects all tandem applications for the tandem offer.
*/
public function acceptApplication()
{
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment