Skip to content
Snippets Groups Projects
Commit c1337fbe authored by Alexander Purr's avatar Alexander Purr Committed by Robert Lange
Browse files

refs #24899 [fid_adr] add export of newsletter mail-addresses

* add extended UserController and new route to module.config.php
* add export logic to UserController
* add translation
* overwrite list.phtml
** add export button
** add styling
parent 17aacd29
Branches
Tags
No related merge requests found
......@@ -99,3 +99,5 @@ newsletter_1 = ja
newsletter_0 = nein
auth_error_account_deleted = Ihr Konto ist zur Löschung vorgemerkt und Ihre Daten werden beim nächsten Wartungslauf endgültig entfernt. Bitte kontaktieren Sie uns unter info@adlr.link, um eine Entsperrung vorzunehmen und eine Löschung zu verhindern.
user_list_export_newsletter = "Mail-Adressen für Newsletter exportieren"
......@@ -93,4 +93,6 @@ newsletter_0 = no
auth_error_account_deleted = Your account is marked for deletion and your data will be permanently removed during the next maintenance run. Please contact us at info@adlr.link to unblock and prevent deletion.
zdf_access = rufus_access
\ No newline at end of file
zdf_access = rufus_access
user_list_export_newsletter = "Export mail addresses for newsletter"
\ No newline at end of file
......@@ -21,12 +21,14 @@
*/
use fid\Controller\MyResearchController;
use fid\Controller\UserControllerFactory;
use fid\FormModel\PasswordChangeModel;
use fid_adlr\Controller\FeedbackController;
use fid_adlr\Controller\FeedbackControllerDelegatorFactory;
use fid_adlr\Controller\RecordController;
use fid_adlr\Controller\RecordControllerDelegatorFactory;
use fid_adlr\Controller\SearchController;
use fid_adlr\Controller\UserController;
use fid_adlr\Helper\Rss;
use VuFind\Controller\AbstractBaseWithConfigFactory;
use Laminas\Router\Http\Regex;
......@@ -44,6 +46,7 @@ $config = [
FeedbackController::class => 'VuFind\Controller\AbstractBaseFactory',
RecordController::class => AbstractBaseWithConfigFactory::class,
SearchController::class => AbstractBaseWithConfigFactory::class,
UserController::class => UserControllerFactory::class,
],
'aliases' => [
'feedback' => FeedbackController::class,
......@@ -92,6 +95,24 @@ $config = [
],
],
],
'fid' => [
'child_routes' => [
'admin' => [
'child_routes' => [
'exportListNewsletter' => [
'type' => 'literal',
'options' => [
'route' => '/exportListNewsletter',
'defaults' => [
'controller' => UserController::class,
'action' => 'exportListNewsletter',
],
],
],
],
],
],
],
],
],
'vufind' => [
......
<?php
/**
* PHP version 7
*
* Copyright (C) 2023 Leipzig University Library
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @category VuFind
* @package Controller
* @author Alexander Purr <purr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
namespace fid_adlr\Controller;
use fid\Controller\UserController as FidUserContoller;
use fid\Service\Client;
use fid\Service\DataTransferObject\User;
use fid\Service\UserNotAuthorizedException;
/**
* User Controller
*
* @category VuFind
* @package Controller
* @author Alexander Purr <purr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
* @link https://vufind.org/wiki/development Wiki
*/
class UserController extends FidUserContoller
{
/**
* Request download of user list newsletter route action
*
* @return HttpResponse
* @throws ClientException
* @throws UserNotAuthorizedException
*/
public function exportListNewsletterAction()
{
$userListNewsletter = [];
foreach ($this->client->requestUserList() as $user) {
/* @var User $user */
$data = $user->getData();
if (isset($data["newsletter"]) && $data["newsletter"] == true) {
$userListNewsletter[] = $user;
}
}
return $this->createExportFile(
$userListNewsletter,
$fields = ['username'],
$mode = 'default',
$separator = "\t",
$printTableHead = false
);
}
}
<!-- fid_adlr: fid - admin - list -->
<?php
/**
* origin: fid
*
* called by view helper/controller: UserController -> listAction()
*
* usage:
* - list all user as admin
* - url: /fid/admin/list
*
* parent template: --
*
* modified for fid_adlr:
* - #24899 add export Newsletter mail addresses
*
* configured in: fid.ini: [Admin]
*/
?>
<?php
/* #16383: added tablesorter - GG*/
$this->headScript()->appendFile('jquery.tablesorter.min.js');
$script = <<<JS
$(document).ready(function() {
// Tablesorter
$('table').tablesorter({
sortList: [[0,1]],
// widgets: ['zebra', 'filter']
});
});
JS;
?>
<?=$this->inlineScript(\Laminas\View\Helper\HeadScript::SCRIPT, $script, 'SET')?>
<h1><?=$this->translate('Users')?></h1>
<?= $this->flashmessages() ?>
<?php if (!empty($this->list)): ?>
<table class="fid fid-admin table user-table table-striped">
<?php /* #16383 */ ?>
<thead>
<tr>
<th><!-- empty cell --></th>
<th>#</th>
<?php foreach ($fields as $fieldname): ?>
<th><?=$this->translate('fid::' . $fieldname)?></th>
<?php endforeach; ?>
</tr>
<?php /* #16383 */ ?>
</thead>
<tbody>
<?php foreach ($list as $id => $user):?>
<?php $tooltip = $this->translate('fid::user_edit', ['%%userid%%' => $id]); ?>
<tr><td><a href="<?=$this->url('fid/admin/edit', ['userid' => $id])?>" title="<?=$tooltip?>"><i class="fa fa-pencil-square-o"></i><span class="sr-only"><?=$tooltip?></span></a></td><th><?=$id?></th><?= $this->render('fid/admin/list-entry', ['user' => $user,'fields'=>$fields, 'config' => $config]) ?></tr>
<?php endforeach; ?>
<?php /* #16383 */ ?>
</tbody>
</table>
<div class="btn-group">
<?php // #24899 remove sorrounding button, add margin-r class ?>
<a href="<?=$this->url('fid/admin/exportList', ['mode' => 'default'])?>" class="btn btn-primary" target="_blank">
<i class="fa fa-download"></i> <?=$this->translate('fid::user_list_export')?>
</a>
<button type="button" class="btn btn-primary dropdown-toggle margin-r" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<?=$this->url('fid/admin/exportList', ['mode' => 'default'])?>"><?=$this->translate('fid::user_list_export')?></a></li>
<li><a href="<?=$this->url('fid/admin/exportList', ['mode' => 'microsoft'])?>"><?=$this->translate('fid::user_list_export_ms')?> MS</a></li>
<li><a href="<?=$this->url('fid/admin/exportList', ['mode' => 'conform'])?>"><?=$this->translate('fid::user_list_export_std')?> Conform</a></li>
<li><a href="<?=$this->url('fid/admin/exportList', ['mode' => 'json'])?>"><?=$this->translate('fid::user_list_export_json')?> JSON</a></li>
</ul>
<?php // #24899 add newsletter-mail-addresses export button here ?>
<a href="<?=$this->url('fid/admin/exportListNewsletter')?>" class="btn btn-primary">
<i class="fa fa-at"></i> <?=$this->translate('fid::user_list_export_newsletter')?>
</a>
</div>
<?php else: ?>
<?= $this->translate('fid::user_list_empty') ?>
<?php endif; ?>
<!-- fid_adlr: fid - admin - list - END -->
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment