Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Notifications CMS functionality #3103

Open
wants to merge 60 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d8028eb
Added "notifications"-CMS functionality.
jschultze Sep 19, 2023
af189aa
Merge branch 'dev-admin-cms' into dev_vnc
jschultze Sep 19, 2023
5c15d74
Refactoring.
jschultze Sep 19, 2023
e3e3a3d
Merge branch 'dev' into dev_vnc
jschultze Sep 19, 2023
cf63adb
Bugfixes in Notifications-factories.
jschultze Sep 20, 2023
6d9b5d5
Added CSS files with Notifications styles included.
jschultze Sep 20, 2023
2fab4ba
Added permissions example for Notifications.
jschultze Sep 20, 2023
82ab950
Added ability to close each broadcast for the remaining session.
jschultze Nov 7, 2023
b11d7e7
Changed the permission needed to access the notifications administrat…
jschultze Dec 5, 2023
61f7643
Moved the route configuration to the VuFindAdmin module.
jschultze Dec 5, 2023
2a0ecf0
Merge branch 'dev' into dev_vufind_notifications_cms
demiankatz Dec 15, 2023
72a9ee5
Add EOF newlines.
demiankatz Dec 15, 2023
dfbb948
php-cs-fixer
demiankatz Dec 15, 2023
7d5cb9c
phpcbf
demiankatz Dec 15, 2023
8b7b4b5
Fixed indentation and set encoding to utf8.
jschultze Feb 23, 2024
c2dd301
Merge remote-tracking branch 'vufind_notifications_cms/dev_vufind_not…
jschultze Feb 23, 2024
791ea99
Update of PHP version to match current requirements.
jschultze Mar 1, 2024
59b508a
Merge branch 'dev' into dev_vufind_notifications_cms
jschultze Mar 1, 2024
85e14a4
Changed the way the dataTables-library is included from directy copy …
jschultze Mar 4, 2024
34a578c
Removed unused code.
jschultze Mar 4, 2024
72d02c6
Removed jQuery IU and implemented custom tab navigation for notificat…
jschultze Mar 15, 2024
6e727c3
Added generated style and script files.
jschultze Mar 15, 2024
7d42817
Changed check of $templateDir and $templateName to flag in $this->lay…
jschultze Mar 19, 2024
b3415ba
Changed list of dependencies to alphabetic order.
jschultze Mar 19, 2024
8519318
Moved JavaScript and CSS of the datatables plugin from a global inclu…
jschultze Mar 19, 2024
a574e04
Cleaned up translations in templates and added translations to the la…
jschultze Mar 19, 2024
ea64672
Changed translation key to placeholder token.
jschultze Mar 19, 2024
a22c434
Added basic help pages for markdown and emojis.
jschultze Mar 20, 2024
c62480c
Fixed links to markdown help.
jschultze Mar 20, 2024
5e4c6d5
Update lockfile.
demiankatz Mar 20, 2024
9d6c242
Fixed typo in name of database column.
jschultze Mar 21, 2024
bb3ba81
Added missing database columns.
jschultze Mar 21, 2024
7189c11
Added missing configuration files for notifications.
jschultze Mar 21, 2024
0581300
Pages will not be selected based on language. They will be displayed …
jschultze Mar 22, 2024
244c350
Changed page id from being part of url to value of parameter "page_id".
jschultze Mar 22, 2024
cde9c59
Changed "color" to "background_color" to be more clear about the purp…
jschultze Mar 22, 2024
f13e9da
Fixed id for ajax requests in broadcast overview table.
jschultze Mar 22, 2024
84f0ec2
Set color in broadcast links for better visibility.
jschultze Mar 22, 2024
138a8f4
Moved the broadcasts above the search box on search/home.
jschultze Mar 22, 2024
b2573e8
Moved global permission check to methods where permission checks are …
jschultze Jul 3, 2024
a902b3e
Changed height of search header from height to min-height to allow no…
jschultze Jul 3, 2024
f2202ef
Bugfix of JavaScript source: the script crashed as no element #notifi…
jschultze Jul 3, 2024
eb4b0f7
Moved broadcasts in header to be always visible on mobile screens.
jschultze Jul 3, 2024
a658e4c
Removed hard coded date format.
jschultze Sep 26, 2024
0140266
Added line break at the end of the configuration file.
jschultze Sep 26, 2024
9a5aa33
Cleanup of translation keys.
jschultze Sep 26, 2024
485a60d
Cleanup of translation keys.
jschultze Sep 26, 2024
264e8bc
Cleanup of translation keys.
jschultze Sep 26, 2024
6040127
Changed start- and end-date for broadcasts from datetime to date.
jschultze Nov 7, 2024
50ff480
Added fixes from @maccabeelevine.
jschultze Nov 7, 2024
a251e91
Merge branch 'dev' into vufind_notifications_cms_merge_dev
jschultze Nov 20, 2024
10f15ac
Added composer packages for emoji support in notifications.
jschultze Nov 20, 2024
0ff8950
Added compiled css files for bootprint3, bootstrap3 and sandal themes.
jschultze Nov 20, 2024
2c2afa9
Added notification templates to bootstrap5 theme.
jschultze Nov 20, 2024
1d28f84
Added generated style and script files.
jschultze Nov 20, 2024
1dbd344
Added notifications additions to bootstrap5 theme.
jschultze Nov 20, 2024
e75ae07
Added layout variable hide notifications in the header on Search/Home.
jschultze Nov 20, 2024
b1c57b2
Added missing notifications view helper to bootstrap5.
jschultze Nov 20, 2024
ef1fe79
Fixed styles for notifications forms.
jschultze Nov 20, 2024
47225ab
Added initial sql for PostgreSQL.
jschultze Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"colinmollenhour/credis": "1.15.0",
"composer/package-versions-deprecated": "1.11.99.5",
"composer/semver": "3.4.0",
"elgigi/commonmark-emoji": "2.0.0",
"endroid/qr-code": "4.8.2",
"laminas/laminas-cache": "3.10.1",
"laminas/laminas-cache-storage-adapter-blackhole": "^2.0",
Expand Down
257 changes: 155 additions & 102 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions config/vufind/permissionBehavior.ini
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ deniedTemplateBehavior = showTemplate:error/loginForAccess
; block this for some users, you should change the defaultAccountPage in
; config.ini to avoid causing login problems.
;deniedControllerBehavior = "exception::You are not logged in!"

[notifications.Admin]
deniedControllerBehavior = "showMessage:Access to notifications administration not granted"
7 changes: 7 additions & 0 deletions config/vufind/permissions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,10 @@ role = loggedin
;permission[] = "access.alma.webhook.challenge"
;require = ALL
;ipRange[] = "127.0.0.1"

; Example permission for Notifications
[notifications.Admin]
permission[] = notifications.Admin
role = loggedin
; Add usernames to restrict the access to certain users
;username[] = admin
10 changes: 10 additions & 0 deletions module/VuFind/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
'VuFind\Controller\LibraryCardsController' => 'VuFind\Controller\AbstractBaseFactory',
'VuFind\Controller\MissingrecordController' => 'VuFind\Controller\AbstractBaseFactory',
'VuFind\Controller\MyResearchController' => 'VuFind\Controller\AbstractBaseFactory',
'VuFind\Controller\NotificationsController' => 'VuFind\Controller\AbstractBaseFactory',
'VuFind\Controller\OaiController' => 'VuFind\Controller\AbstractBaseFactory',
'VuFind\Controller\OAuth2Controller' => 'VuFind\Controller\OAuth2ControllerFactory',
'VuFind\Controller\OverdriveController' => 'VuFind\Controller\AbstractBaseFactory',
Expand Down Expand Up @@ -289,6 +290,8 @@
'missingrecord' => 'VuFind\Controller\MissingrecordController',
'MyResearch' => 'VuFind\Controller\MyResearchController',
'myresearch' => 'VuFind\Controller\MyResearchController',
'Notifications' => 'VuFind\Controller\NotificationsController',
'notifications' => 'VuFind\Controller\NotificationsController',
'OAI' => 'VuFind\Controller\OaiController',
'oai' => 'VuFind\Controller\OaiController',
'OAuth2' => 'VuFind\Controller\OAuth2Controller',
Expand Down Expand Up @@ -370,6 +373,12 @@
'storageRetrievalRequests' => 'VuFind\Controller\Plugin\StorageRetrievalRequests',
],
],
'form_elements' => [
'factories' => [
'VuFind\Form\BroadcastsForm' => 'VuFind\Form\BroadcastsFormFactory',
'VuFind\Form\PagesForm' => 'VuFind\Form\PagesFormFactory',
],
],
'service_manager' => [
'allow_override' => true,
'factories' => [
Expand Down Expand Up @@ -720,6 +729,7 @@
'Feedback' => ['feedback-form' => 'Form/[:id]'],
'MyResearch' => ['userList' => 'MyList/[:id]', 'editList' => 'EditList/[:id]'],
'LibraryCards' => ['editLibraryCard' => 'editCard/[:id]'],
'Notifications' => ['notifications-page' => 'Page/[:page_id]'],
];

// Define static routes -- Controller/Action strings
Expand Down
32 changes: 32 additions & 0 deletions module/VuFind/sql/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,35 @@ CREATE TABLE `access_token` (
CONSTRAINT `access_token_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

CREATE TABLE `notifications_broadcasts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`broadcast_id` int(11) DEFAULT NULL,
`visibility` tinyint(1) DEFAULT NULL,
`visibility_global` tinyint(1) DEFAULT NULL,
`priority` int(11) DEFAULT NULL,
`author_id` int(11) DEFAULT NULL,
`content` text DEFAULT NULL,
`color` varchar(255) DEFAULT NULL,
`startdate` datetime DEFAULT NULL,
`endate` datetime DEFAULT NULL,
`change_date` datetime DEFAULT NULL,
`create_date` datetime DEFAULT NULL,
`language` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
demiankatz marked this conversation as resolved.
Show resolved Hide resolved

CREATE TABLE `notifications_pages` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`page_id` int(11) DEFAULT NULL,
`visibility` tinyint(1) DEFAULT NULL,
`priority` int(11) DEFAULT NULL,
`author_id` int(11) DEFAULT NULL,
`headline` varchar(255) DEFAULT NULL,
`nav_title` varchar(255) DEFAULT NULL,
`content` text DEFAULT NULL,
`change_date` datetime DEFAULT NULL,
`create_date` datetime DEFAULT NULL,
`language` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
105 changes: 105 additions & 0 deletions module/VuFind/src/VuFind/AjaxHandler/NotificationsClose.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

/**
* AJAX handler to close a broadcast for the current browser session.
*
* PHP version 8
*
* Copyright (C) effective WEBWORK GmbH 2023.
*
* 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 Demian Katz <[email protected]>
* @author Johannes Schultze <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/

namespace VuFind\AjaxHandler;

use Laminas\Mvc\Controller\Plugin\Params;

/**
* AJAX handler to change the visibility of a notification.
*
* @category VuFind
* @package AJAX
* @author Demian Katz <[email protected]>
* @author Johannes Schultze <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class NotificationsClose extends AbstractBase
{
/**
* Session containing Notification status information
*
* @var \Laminas\Session\Container
*/
protected $session;

/**
* SessionManager
*
* @var \Laminas\Session\SessionManager
*/
protected $sessionManager;

/**
* Constructor
*
*/
public function __construct(\Laminas\Session\SessionManager $sessionManager)
{
$this->sessionManager = $sessionManager;
}

/**
* Handle a request.
*
* @param Params $params Parameter helper from controller
*
* @return array [response data, HTTP status code]
*/
public function handleRequest(Params $params)
{
$broadcast_id = $params->fromPost('broadcast-id', $params->fromQuery('broadcast-id', null));

$session = $this->getSession();
if (!isset($session->closedBrodcasts)) {
$session->closedBrodcasts = [];
}
$session->closedBrodcasts[] = $broadcast_id;
return $this->formatResponse(['Closed brodcasts' => $session->closedBrodcasts ? 1 : 0]);
}

/**
* Get the session container (constructing it on demand if not already present)
*
* @return SessionContainer
*/
protected function getSession()
{
// SessionContainer not defined yet? Build it now:
if (null === $this->session) {
$this->session = new \Laminas\Session\Container(
'Notifications',
$this->sessionManager
);
}
return $this->session;
}
}
76 changes: 76 additions & 0 deletions module/VuFind/src/VuFind/AjaxHandler/NotificationsCloseFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

/**
* Factory for NotificationsVisibility AJAX handler.
*
* PHP version 8
*
* Copyright (C) effective WEBWORK GmbH 2023.
*
* 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 Demian Katz <[email protected]>
* @author Johannes Schultze <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/

namespace VuFind\AjaxHandler;

use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\Exception\ServiceNotFoundException;
use Laminas\ServiceManager\Factory\FactoryInterface;

/**
* Factory for NotificationsClose AJAX handler.
*
* @category VuFind
* @package AJAX
* @author Demian Katz <[email protected]>
* @author Johannes Schultze <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class NotificationsCloseFactory implements FactoryInterface
{
/**
* Create an object
*
* @param ContainerInterface $container Service manager
* @param string $requestedName Service being created
* @param null|array $options Extra options (optional)
*
* @return object
*
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException&\Throwable if any other error occurs
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
if (!empty($options)) {
throw new \Exception('Unexpected options sent to factory.');
}
return new $requestedName(
$container->get(\Laminas\Session\SessionManager::class)
);
}
}
101 changes: 101 additions & 0 deletions module/VuFind/src/VuFind/AjaxHandler/NotificationsReorder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php

/**
* AJAX handler to change the order of notifications.
*
* PHP version 8
*
* Copyright (C) effective WEBWORK GmbH 2023.
*
* 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 Demian Katz <[email protected]>
* @author Johannes Schultze <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Page
*/

namespace VuFind\AjaxHandler;

use Laminas\Mvc\Controller\Plugin\Params;
use VuFind\Db\Table\Broadcasts;
use VuFind\Db\Table\Pages;

/**
* AJAX handler to change the order of notifications.
*
* @category VuFind
* @package AJAX
* @author Demian Katz <[email protected]>
* @author Johannes Schultze <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class NotificationsReorder extends AbstractBase
{
/**
* Database table for pages
*
* @var Pages
*/
private $pagesTable;

/**
* Database table for broadcasts
*
* @var Broadcasts
*/
private $broadcastsTable;

/**
* Constructor
*
* @param Pages $pagesTable Database table for pages
* @param Broadcasts $broadcastsTable Database table for broadcasts
*/
public function __construct(Pages $pagesTable, Broadcasts $broadcastsTable)
{
$this->pagesTable = $pagesTable;
$this->broadcastsTable = $broadcastsTable;
}

/**
* Handle a request.
*
* @param Params $params Parameter helper from controller
*
* @return array [response data, HTTP status code]
*/
public function handleRequest(Params $params)
{
$order = $params->fromPost('order', $params->fromQuery('order', []));
$type = $params->fromPost('type', $params->fromQuery('type', []));

if ($type == 'page') {
foreach ($order as $index => $page_id) {
$this->pagesTable->setPriorityForPageId($index, $page_id);
}
}
if ($type == 'broadcast') {
foreach ($order as $index => $broadcast_id) {
$this->broadcastsTable->setPriorityForBroadcastId($index, $broadcast_id);
}
}

$result = ['success' => true];
return $this->formatResponse(compact($result));
}
}
Loading
Loading