Skip to content
Snippets Groups Projects
Commit 18a25df2 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

some account handling

parent 1819ce23
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,16 @@
/**
* Class MatrixPlugin
* Plugin for integrating a Matrix chat into 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 Thomas Hackl <hackl@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Matrix
*/
class MatrixPlugin extends StudIPPlugin implements StandardPlugin
......
<?php
/**
* Class MatrixChatController
* Controller for Matrix chat handling.
*
* 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 Thomas Hackl <hackl@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Matrix
*/
class MatrixChatController extends AuthenticatedController
{
......@@ -37,6 +51,21 @@ class MatrixChatController extends AuthenticatedController
{
// Delete a potential previous entry about not wanting an account.
UserConfig::get(User::findCurrent()->id)->delete('MATRIX_NO_ACCOUNT_WANTED');
// Create an account via libpatrix client
$client = MatrixClient::get();
$created = $client->registerAccount(
new Patrix\Account(Config::get()->MATRIX_NAMESPACE . '-' . User::findCurrent()->username, '')
);
if ($created) {
PageLayout::postSuccess(dgettext('matrix', 'Ihre Kennung wurde erfolgreich angelegt.'));
} else {
PageLayout::postError(
dgettext('matrix', 'Ihre Kennung konnte nicht im Matrixchat angelegt werden.'));
}
$this->relocate('');
}
/**
......
......@@ -27,6 +27,7 @@ class Init extends Migration
DBManager::get()->execute("CREATE TABLE IF NOT EXISTS `matrix_accounts` (
`user_id` CHAR(32) NOT NULL COLLATE latin1_bin,
`matrix_account_id` VARCHAR(255) NOT NULL,
`access_token` VARCHAR(255) NOT NULL COLLATE latin1_bin,
`mkdate` INT NOT NULL,
`chdate` INT NOT NULL,
PRIMARY KEY (`user_id`)
......
<?php
/**
* MatrixAccount.php
* model class for mapping between Matrix and Stud.IP accounts.
*
* 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 Thomas Hackl <hackl@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Matrix
*
* @property string user_id database column
* @property string matrix_account_id database column
* @property string mkdate database column
* @property string chdate database column
*/
class MatrixAccount extends SimpleORMap
{
......
<?php
/**
* Class MatrixClient
* Provides a singleton for connecting to and communicating
* with a Matrix chat server.
*
* 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 Thomas Hackl <hackl@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Matrix
*/
require_once(__DIR__ . '/../../../libpatrix/MatrixClient.php');
class MatrixClient
{
/**
* Singleton instance for connector.
*
* @access private
* @var MatrixClient
*/
private static $client;
public static function get()
{
if (is_null(MatrixClient::$client)) {
MatrixClient::$client = new Patrix\MatrixClient(Config::get()->MATRIX_SERVER_URL);
}
return MatrixClient::$client;
}
}
\ No newline at end of file
<?php
/**
* MatrixRoom.php
* model class for mapping between Matrix rooms and Stud.IP structures (courses).
*
* 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 Thomas Hackl <hackl@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Matrix
*
* @property string range_id database column
* @property string matrix_room_id database column
* @property string mkdate database column
* @property string chdate database column
*/
class MatrixRoom extends SimpleORMap
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment