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

show "Matrikelnummer" field in admin/user result table, closes #3336

Closes #3336

Merge request studip/studip!2270
parent a6d4707a
No related branches found
No related tags found
No related merge requests found
......@@ -417,7 +417,7 @@ class Admin_UserController extends AuthenticatedController
if (count($editPerms)) {
$editUser['auth_user_md5.perms'] = $editPerms[0];
}
foreach (words('Vorname Nachname auth_plugin visible') as $param) {
foreach (['Vorname', 'Nachname', 'matriculation_number', 'auth_plugin', 'visible'] as $param) {
if (Request::get($param)) $editUser['auth_user_md5.' . $param] = Request::get($param);
}
foreach (words('title_front title_rear geschlecht preferred_language') as $param) {
......
......@@ -22,6 +22,7 @@
</a>
</th>
<th>&nbsp;</th>
<th><?= _('Matrikelnummer') ?></th>
<th <?= $sortby === 'perms' ? 'class="sort' . $order . '"' : '' ?>>
<a href="<?= $controller->link_for('admin/user',['sortby' =>'perms', 'order'=> $order ,'toggle' => $sortby === 'perms']) ?>">
<?= _('Status') ?>
......@@ -99,6 +100,7 @@
?>
<?= tooltipHtmlIcon(htmlReady($tooltxt, true, true)) ?>
</td>
<td><?= htmlReady($user->matriculation_number) ?></td>
<td><?= $user['perms'] ?></td>
<td><?= htmlReady($user->Vorname) ?></td>
<td><?= htmlReady($user->nachname) ?></td>
......
......@@ -204,6 +204,16 @@ use Studip\Button, Studip\LinkButton;
</div>
</section>
<section>
<label>
<?= _('Matrikelnummer') ?>
<input class="user_form" type="text" id="matriculation_number"
value="<?= htmlReady($user->matriculation_number) ?>"
<?= StudipAuthAbstract::CheckField('auth_user_md5.matriculation_number', $user->auth_plugin)
|| LockRules::check($user->user_id, 'matriculation_number') ? 'readonly' : 'name="matriculation_number"' ?>>
</label>
</section>
<? if (!empty($user_roles)) : ?>
<section>
......
......@@ -65,6 +65,8 @@
<? if ($current_user->user_id === $GLOBALS['user']->id) : ?>
<dt><?= _('Status') ?>:</dt>
<dd><?= htmlReady(ucfirst($current_user['perms'])) ?></dd>
<dt><?= _('Matrikelnummer') ?>:</dt>
<dd><?= htmlReady($current_user['matriculation_number']) ?></dd>
<? endif ?>
<? if (!empty($shortDatafields)) : ?>
......
<?php
namespace Studip\Cli\Commands\Migrate;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class MigrateMatrikelnummer extends Command
{
protected static $defaultName = 'migrate:matrikelnummer';
protected function configure() : void
{
$this->setDescription('Migrates the "Matrikelnummer" datafield into the matriculation_number column of the auth_user_md5 table.');
$this->setHelp('This command migrates the "Matrikelnummer" datafield into the matriculation_number column of the auth_user_md5 table. The ID of the datafield must be provided. The datafield is not deleted in the migration process.');
$this->addOption('id', 'i', InputOption::VALUE_REQUIRED, 'The ID of the "Matrikelnummer" datafield.', null);
}
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$datafield_id = $input->getOption('id');
if (!$datafield_id) {
echo 'No ID for the "Matrikelnummer" datafield has been provided.' . "\n";
return Command::FAILURE;
}
$datafield = \DataField::find($datafield_id);
if (!$datafield) {
echo 'The datafield could not be found.' . "\n";
return Command::FAILURE;
}
//Get all entries of the datafield for users and set the
//matriculation_number field:
$verbose = $input->getOption('verbose');
$modifier = function ($entry) use ($verbose) {
if (!$entry->content) {
return;
}
$user = \User::find($entry->range_id);
if (!$user) {
return;
}
$user->matriculation_number = $entry->content;
if ($user->isDirty()) {
$success = $user->store();
if ($verbose) {
if ($success === false) {
printf('Error updating matriculation number for user %s.', $user->username) . "\n";
} elseif ($success > 0) {
printf('Matriculation number updated for user %s.', $user->username) . "\n";
}
}
}
};
\DatafieldEntryModel::findEachByDatafield_id(
$modifier,
$datafield->id
);
return Command::SUCCESS;
}
}
......@@ -38,6 +38,7 @@ $commands = [
Commands\Fix\EndTimeWeeklyRecurredEvents::class,
Commands\Fix\IconDimensions::class,
Commands\HelpContent\Migrate::class,
Commands\Migrate\MigrateMatrikelnummer::class,
Commands\Migrate\MigrateList::class,
Commands\Migrate\MigrateStatus::class,
Commands\Migrate\Migrate::class,
......
<?php
class AddMatriculationNumber extends Migration
{
public function description()
{
return 'Add auth_user_md5.matriculation_number';
}
protected function up()
{
$db = DBManager::get();
$db->exec(
"ALTER TABLE `auth_user_md5`
ADD COLUMN matriculation_number VARCHAR(255) NULL DEFAULT NULL"
);
}
protected function down()
{
$db = DBManager::get();
$db->exec(
"ALTER TABLE `auth_user_md5`
DROP COLUMN matriculation_number"
);
}
}
......@@ -30,6 +30,7 @@
* @property string $vorname database column
* @property string $nachname database column
* @property string $email database column
* @property string $matriculation_number database column
* @property string $validation_key database column
* @property string|null $auth_plugin database column
* @property int $locked database column
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment