From 153f8f519b9944eaf6d8e9f85ac275f5344e79a0 Mon Sep 17 00:00:00 2001 From: Panos Date: Thu, 16 Apr 2015 09:49:41 +0200 Subject: [PATCH] Added plugin admin parameters, replaced is_notifiable by listener for user parameters --- Controller/NotificationController.php | 22 +-- ...ificationPluginConfigurationController.php | 74 +++++++++ DependencyInjection/Configuration.php | 28 ---- .../IcapNotificationExtension.php | 7 - Entity/NotificationPluginConfiguration.php | 153 ++++++++++++++++++ .../InvalidNotificationFormException.php | 32 ++++ Form/NotificationPluginConfigurationType.php | 77 +++++++++ IcapNotificationBundle.php | 21 +-- Installation/AdditionalInstaller.php | 30 ++++ Installation/Updater/Updater040200.php | 57 +++++++ Listener/AdministrationToolListener.php | 33 ++++ Manager/NotificationManager.php | 50 +++++- ...NotificationPluginConfigurationManager.php | 105 ++++++++++++ Manager/NotificationUserParametersManager.php | 35 ++-- .../Version20150414153912.php | 36 +++++ Migrations/ibm_db2/Version20150414153912.php | 36 +++++ Migrations/mysqli/Version20150414153912.php | 36 +++++ Migrations/oci8/Version20150414153912.php | 64 ++++++++ Migrations/pdo_ibm/Version20150414153912.php | 36 +++++ .../pdo_mysql/Version20150414153912.php | 36 +++++ Migrations/pdo_oci/Version20150414153912.php | 64 ++++++++ .../pdo_pgsql/Version20150414153912.php | 36 +++++ .../pdo_sqlite/Version20150414153912.php | 36 +++++ .../pdo_sqlsrv/Version20150414153912.php | 36 +++++ Migrations/sqlsrv/Version20150414153912.php | 36 +++++ README.md | 19 ++- Resources/config/config.yml | 10 +- Resources/translations/notification.en.yml | 12 +- Resources/translations/notification.fr.yml | 12 +- Resources/translations/tools.en.yml | 1 + Resources/translations/tools.fr.yml | 1 + .../views/Configuration/config.html.twig | 56 +++++++ Resources/views/Notification/list.html.twig | 2 +- 33 files changed, 1175 insertions(+), 114 deletions(-) create mode 100644 Controller/NotificationPluginConfigurationController.php delete mode 100644 DependencyInjection/Configuration.php create mode 100644 Entity/NotificationPluginConfiguration.php create mode 100644 Exception/InvalidNotificationFormException.php create mode 100644 Form/NotificationPluginConfigurationType.php create mode 100644 Installation/AdditionalInstaller.php create mode 100644 Installation/Updater/Updater040200.php create mode 100644 Listener/AdministrationToolListener.php create mode 100644 Manager/NotificationPluginConfigurationManager.php create mode 100644 Migrations/drizzle_pdo_mysql/Version20150414153912.php create mode 100644 Migrations/ibm_db2/Version20150414153912.php create mode 100644 Migrations/mysqli/Version20150414153912.php create mode 100644 Migrations/oci8/Version20150414153912.php create mode 100644 Migrations/pdo_ibm/Version20150414153912.php create mode 100644 Migrations/pdo_mysql/Version20150414153912.php create mode 100644 Migrations/pdo_oci/Version20150414153912.php create mode 100644 Migrations/pdo_pgsql/Version20150414153912.php create mode 100644 Migrations/pdo_sqlite/Version20150414153912.php create mode 100644 Migrations/pdo_sqlsrv/Version20150414153912.php create mode 100644 Migrations/sqlsrv/Version20150414153912.php create mode 100644 Resources/translations/tools.en.yml create mode 100644 Resources/translations/tools.fr.yml create mode 100644 Resources/views/Configuration/config.html.twig diff --git a/Controller/NotificationController.php b/Controller/NotificationController.php index b307710..4125e44 100644 --- a/Controller/NotificationController.php +++ b/Controller/NotificationController.php @@ -8,9 +8,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; - -use Icap\NotificationBundle\Entity\ColorChooser; - use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -32,19 +29,11 @@ class NotificationController extends Controller */ public function listAction(Request $request, $user, $page) { - if ($request->isXMLHttpRequest()) { - $maxResult = $this->container->getParameter('icap_notification.dropdown_items'); - $page = 1; - } else { - $maxResult = $this->container->getParameter('icap_notification.max_per_page'); - } - $notificationManager = $this->getNotificationManager(); - $result = $notificationManager->getUserNotificationsList($user->getId(), $page, $maxResult); $systemName = $notificationManager->getPlatformName(); - $result['systemName'] = $systemName; - if ($request->isXMLHttpRequest()) { + $result = $notificationManager->getDropdownNotifications($user->getId()); + $result['systemName'] = $systemName; $unviewedNotifications = $notificationManager->countUnviewedNotifications( $user->getId() ); @@ -55,8 +44,8 @@ public function listAction(Request $request, $user, $page) $result ); } else { - $defaultLayout = $this->container->getParameter('icap_notification.default_layout'); - $result['layout'] = $defaultLayout; + $result = $notificationManager->getPaginatedNotifications($user->getId(), $page); + $result['systemName'] = $systemName; return $result; } @@ -75,9 +64,8 @@ public function listAction(Request $request, $user, $page) public function rssAction($rssId) { $notificationManager = $this->getNotificationManager(); - $maxResult = $this->container->getParameter('icap_notification.max_per_page'); try { - $result = $notificationManager->getUserNotificationsListRss($rssId, $maxResult); + $result = $notificationManager->getUserNotificationsListRss($rssId); $result["systemName"] = $notificationManager->getPlatformName(); } catch (NoResultException $nre) { $result = array("error" => "no_rss_defined"); diff --git a/Controller/NotificationPluginConfigurationController.php b/Controller/NotificationPluginConfigurationController.php new file mode 100644 index 0000000..5f87a3f --- /dev/null +++ b/Controller/NotificationPluginConfigurationController.php @@ -0,0 +1,74 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/14/15 + */ + +namespace Icap\NotificationBundle\Controller; + +use Claroline\CoreBundle\Entity\User; +use Icap\NotificationBundle\Exception\InvalidNotificationFormException; +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; +use Symfony\Component\HttpFoundation\Request; + +class NotificationPluginConfigurationController extends Controller +{ + /** + * @Route("/configuration", name="icap_notification_configuration") + * @Template("IcapNotificationBundle:Configuration:config.html.twig") + * @Method({"GET"}) + * @ParamConverter("user", options={"authenticatedUser" = true}) + * @Security("has_role('ROLE_ADMIN')") + */ + public function getAction(User $user) + { + $configManager = $this->getNotificationPluginConfigurationManager(); + $form = $configManager->getForm(); + + return array('form' => $form->createView()); + } + + /** + * @Route("/configuration", name="icap_notification_configuration_save") + * @Template("IcapNotificationBundle:Configuration:config.html.twig") + * @Method({"POST"}) + * @ParamConverter("user", options={"authenticatedUser" = true}) + * @Security("has_role('ROLE_ADMIN')") + */ + public function postAction(Request $request, User $user) + { + $configManager = $this->getNotificationPluginConfigurationManager(); + try{ + $form = $configManager->processForm($request); + $this->addFlash('success', 'successfully_saved_configuration'); + } catch (InvalidNotificationFormException $infe) { + $form = $infe->getForm(); + $this->addFlash('error', $infe->getMessage()); + } + + return array('form' => $form->createView()); + } + + /** + * @return \Icap\NotificationBundle\Manager\NotificationPluginConfigurationManager + */ + private function getNotificationPluginConfigurationManager() + { + return $this->get('icap.notification.manager.plugin_configuration'); + } + + private function addFlash($key, $message) + { + $this->get("session")->getFlashBag()->add($key, $message); + } +} \ No newline at end of file diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php deleted file mode 100644 index 533ace4..0000000 --- a/DependencyInjection/Configuration.php +++ /dev/null @@ -1,28 +0,0 @@ -root('icap_notification'); - - $rootNode - ->children() - ->scalarNode('default_layout')->isRequired()->end() - ->integerNode('max_per_page')->defaultValue(50)->end() - ->integerNode('dropdown_items')->defaultValue(10)->end() - ->end(); - - return $treeBuilder; - } -} \ No newline at end of file diff --git a/DependencyInjection/IcapNotificationExtension.php b/DependencyInjection/IcapNotificationExtension.php index 60e1f3f..6d3dd4e 100644 --- a/DependencyInjection/IcapNotificationExtension.php +++ b/DependencyInjection/IcapNotificationExtension.php @@ -23,13 +23,6 @@ class IcapNotificationExtension extends Extension */ public function load(array $configs, ContainerBuilder $container) { - $configuration = new Configuration(); - $config = $this->processConfiguration($configuration, $configs); - - foreach (array('default_layout', 'max_per_page', 'dropdown_items') as $attribute) { - $container->setParameter("icap_notification." . $attribute, $config[$attribute]); - } - $locator = new FileLocator(__DIR__ . '/../Resources/config/services'); $loader = new YamlFileLoader($container, $locator); $loader->load('services.yml'); diff --git a/Entity/NotificationPluginConfiguration.php b/Entity/NotificationPluginConfiguration.php new file mode 100644 index 0000000..b5b0a11 --- /dev/null +++ b/Entity/NotificationPluginConfiguration.php @@ -0,0 +1,153 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/13/15 + */ + +namespace Icap\NotificationBundle\Entity; + +use Doctrine\ORM\Mapping as ORM; + +/** + * Class NotificationPluginConfiguration + * @package Icap\NotificationBundle\Entity + * + * @ORM\Entity() + * @ORM\Table(name="icap__notification_plugin_configuration") + */ +class NotificationPluginConfiguration +{ + /** + * @ORM\Id + * @ORM\Column(type="integer") + * @ORM\GeneratedValue(strategy="AUTO") + */ + protected $id; + + /** + * @ORM\Column(type="integer", name="dropdown_items") + */ + protected $dropdownItems = 10; + + /** + * @ORM\Column(type="integer", name="max_per_page") + */ + protected $maxPerPage = 50; + + /** + * @ORM\Column(type="boolean", name="purge_enabled") + */ + protected $purgeEnabled = true; + + /** + * @ORM\Column(type="integer", name="purge_after_days") + */ + protected $purgeAfterDays = 60; + + /** + * @ORM\Column(type="datetime", name="last_purge_date", nullable=true) + */ + protected $lastPurgeDate; + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @return mixed + */ + public function getDropdownItems() + { + return $this->dropdownItems; + } + + /** + * @param $dropdownItems + * @return $this + */ + public function setDropdownItems($dropdownItems) + { + $this->dropdownItems = $dropdownItems; + + return $this; + } + + /** + * @return mixed + */ + public function getMaxPerPage() + { + return $this->maxPerPage; + } + + /** + * @param mixed $maxPerPage + * @return $this + */ + public function setMaxPerPage($maxPerPage) + { + $this->maxPerPage = $maxPerPage; + + return $this; + } + + /** + * @return mixed + */ + public function getPurgeEnabled() + { + return $this->purgeEnabled; + } + + /** + * @param mixed $purgeEnabled + * @return $this + */ + public function setPurgeEnabled($purgeEnabled) + { + $this->purgeEnabled = $purgeEnabled; + + return $this; + } + + /** + * @return mixed + */ + public function getPurgeAfterDays() + { + return $this->purgeAfterDays; + } + + /** + * @param mixed $purgeAfterDays + */ + public function setPurgeAfterDays($purgeAfterDays) + { + $this->purgeAfterDays = $purgeAfterDays; + } + + /** + * @return mixed + */ + public function getLastPurgeDate() + { + return $this->lastPurgeDate; + } + + /** + * @param mixed $lastPurgeDate + */ + public function setLastPurgeDate($lastPurgeDate) + { + $this->lastPurgeDate = $lastPurgeDate; + } +} \ No newline at end of file diff --git a/Exception/InvalidNotificationFormException.php b/Exception/InvalidNotificationFormException.php new file mode 100644 index 0000000..1a94f4a --- /dev/null +++ b/Exception/InvalidNotificationFormException.php @@ -0,0 +1,32 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/14/15 + */ + +namespace Icap\NotificationBundle\Exception; + + +class InvalidNotificationFormException extends \RuntimeException +{ + protected $form; + + public function __construct($message, $form = null) + { + parent::__construct($message); + $this->form = $form; + } + + /** + * @return array|null + */ + public function getForm() + { + return $this->form; + } +} \ No newline at end of file diff --git a/Form/NotificationPluginConfigurationType.php b/Form/NotificationPluginConfigurationType.php new file mode 100644 index 0000000..fd8bc18 --- /dev/null +++ b/Form/NotificationPluginConfigurationType.php @@ -0,0 +1,77 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/14/15 + */ + +namespace Icap\NotificationBundle\Form; + +use JMS\DiExtraBundle\Annotation as DI; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + +/** + * Class NotificationPluginConfigurationType + * @package Icap\NotificationBundle\Form + * + * @DI\FormType + */ +class NotificationPluginConfigurationType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('dropdownItems', 'integer', + array( + 'label' => 'dropdown_items', + 'theme_options' => array('control_width' => 'col-md-2') + ) + ) + ->add('maxPerPage', 'integer', + array( + 'label' => 'max_per_page', + 'theme_options' => array('control_width' => 'col-md-2') + ) + ) + ->add('purgeEnabled', 'checkbox', + array( + 'required' => false, + 'label' => 'purge_enabled', + 'theme_options' => array('control_width' => 'col-md-2') + ) + ) + ->add('purgeAfterDays', 'integer', + array( + 'label' => 'purge_after_days', + 'theme_options' => array('control_width' => 'col-md-2') + ) + ); + } + + /** + * Returns the name of this type. + * + * @return string The name of this type + */ + public function getName() + { + return 'icap_notification_type_pluginConfiguration'; + } + + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults( + array( + 'translation_domain' => 'notification', + 'data_class' => 'Icap\NotificationBundle\Entity\NotificationPluginConfiguration', + 'csrf_protection' => true + ) + ); + } +} \ No newline at end of file diff --git a/IcapNotificationBundle.php b/IcapNotificationBundle.php index dfe2add..97f9799 100644 --- a/IcapNotificationBundle.php +++ b/IcapNotificationBundle.php @@ -2,18 +2,12 @@ namespace Icap\NotificationBundle; -use Claroline\KernelBundle\Bundle\AutoConfigurableInterface; +use Claroline\CoreBundle\Library\PluginBundle; use Claroline\KernelBundle\Bundle\ConfigurationBuilder; -use Claroline\InstallationBundle\Bundle\InstallableBundle; +use Icap\NotificationBundle\Installation\AdditionalInstaller; -class IcapNotificationBundle extends InstallableBundle implements AutoConfigurableInterface +class IcapNotificationBundle extends PluginBundle { - - public function supports($environment) - { - return true; - } - public function getConfiguration($environment) { $config = new ConfigurationBuilder(); @@ -22,10 +16,11 @@ public function getConfiguration($environment) $config->addRoutingResource($routingFile, null, 'icap_notification'); } - if (file_exists($containerFile = $this->getPath() . '/Resources/config/config.yml')) { - $config->addContainerResource($containerFile); - } - return $config; } + + public function getAdditionalInstaller() + { + return new AdditionalInstaller(); + } } diff --git a/Installation/AdditionalInstaller.php b/Installation/AdditionalInstaller.php new file mode 100644 index 0000000..6fe935d --- /dev/null +++ b/Installation/AdditionalInstaller.php @@ -0,0 +1,30 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/13/15 + */ + +namespace Icap\NotificationBundle\Installation; + +use Claroline\InstallationBundle\Additional\AdditionalInstaller as BaseInstaller; +use Icap\NotificationBundle\Installation\Updater\Updater040200; + +class AdditionalInstaller extends BaseInstaller +{ + public function postUpdate($currentVersion, $targetVersion) + { + if (version_compare($currentVersion, '4.1.0', '<')) { + $updater040200 = new Updater040200( + $this->container->get('doctrine.orm.entity_manager'), + $this->container->get('doctrine.dbal.default_connection') + ); + $updater040200->setLogger($this->logger); + $updater040200->postUpdate(); + } + } +} \ No newline at end of file diff --git a/Installation/Updater/Updater040200.php b/Installation/Updater/Updater040200.php new file mode 100644 index 0000000..2124ab6 --- /dev/null +++ b/Installation/Updater/Updater040200.php @@ -0,0 +1,57 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/13/15 + */ + +namespace Icap\NotificationBundle\Installation\Updater; + + +use Claroline\InstallationBundle\Updater\Updater; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\EntityManager; +use Icap\NotificationBundle\Entity\NotificationPluginConfiguration; + +class Updater040200 extends Updater +{ + /** + * @var \Doctrine\ORM\EntityManager + */ + private $em; + + private $connection; + + /** + * @param EntityManager $em + * @param \Doctrine\DBAL\Connection $connection + */ + public function __construct(EntityManager $em, Connection $connection) + { + $this->em = $em; + $this->connection = $connection; + } + + public function postUpdate() + { + $this->createDefaultConfiguration(); + } + + private function createDefaultConfiguration() + { + if ($this->connection->getSchemaManager()->tablesExist(array('icap__notification_plugin_configuration'))) { + $this->log('Creating default configuration for notifications...'); + $configuration = $this->em-> + getRepository('IcapNotificationBundle:NotificationPluginConfiguration')->findAll(); + if (count($configuration) == 0) { + $configuration = new NotificationPluginConfiguration(); + $this->em->persist($configuration); + $this->em->flush(); + } + } + } +} \ No newline at end of file diff --git a/Listener/AdministrationToolListener.php b/Listener/AdministrationToolListener.php new file mode 100644 index 0000000..6b6be91 --- /dev/null +++ b/Listener/AdministrationToolListener.php @@ -0,0 +1,33 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/14/15 + */ + +namespace Icap\NotificationBundle\Listener; + +use Claroline\CoreBundle\Event\OpenAdministrationToolEvent; +use JMS\DiExtraBundle\Annotation as DI; +use Claroline\CoreBundle\Listener\AdministrationToolListener as BaseAdministrationToolListener; + +/** + * Class AdminToolListener + * @package Icap\NotificationBundle\Listener + * + * @DI\Service() + */ +class AdministrationToolListener extends BaseAdministrationToolListener +{ + /** + * @DI\Observe("administration_tool_notification_configuration") + */ + public function onNotificationConfiguration(OpenAdministrationToolEvent $event) + { + $this->redirect(['_controller' => 'IcapNotificationBundle:NotificationPluginConfiguration:get'], $event); + } +} \ No newline at end of file diff --git a/Manager/NotificationManager.php b/Manager/NotificationManager.php index db69ef2..89f8e9e 100644 --- a/Manager/NotificationManager.php +++ b/Manager/NotificationManager.php @@ -27,11 +27,35 @@ */ class NotificationManager { + /** + * @var \Doctrine\ORM\EntityManager + */ protected $em; + /** + * @var \Symfony\Component\Security\Core\SecurityContextInterface + */ protected $security; + /** + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface + */ protected $eventDispatcher; + /** + * @var string + */ protected $platformName; + /** + * @var NotificationUserParametersManager + */ protected $notificationParametersManager; + /** + * @var NotificationPluginConfigurationManager + */ + protected $notificationPluginConfigurationManager; + + private function getConfigurationAndPurge() + { + return $this->notificationPluginConfigurationManager->getConfigOrEmpty(); + } /** * @return \Icap\NotificationBundle\Repository\NotificationRepository @@ -97,7 +121,8 @@ protected function getUsersToNotifyForNotifiable(NotifiableInterface $notifiable * "securityContext" = @DI\Inject("security.context"), * "eventDispatcher" = @DI\Inject("event_dispatcher"), * "configHandler" = @DI\Inject("claroline.config.platform_config_handler"), - * "notificationParametersManager" = @DI\Inject("icap.notification.manager.notification_user_parameters") + * "notificationParametersManager" = @DI\Inject("icap.notification.manager.notification_user_parameters"), + * "notificationPluginConfigurationManager" = @DI\Inject("icap.notification.manager.plugin_configuration") * }) */ public function __construct( @@ -105,7 +130,8 @@ public function __construct( SecurityContextInterface $securityContext, EventDispatcherInterface $eventDispatcher, PlatformConfigurationHandler $configHandler, - NotificationUserParametersManager $notificationParametersManager + NotificationUserParametersManager $notificationParametersManager, + NotificationPluginConfigurationManager $notificationPluginConfigurationManager ) { $this->em = $em; $this->security = $securityContext; @@ -115,6 +141,7 @@ public function __construct( $this->platformName = "Claroline"; } $this->notificationParametersManager = $notificationParametersManager; + $this->notificationPluginConfigurationManager = $notificationPluginConfigurationManager; } /** @@ -279,6 +306,18 @@ public function createNotificationAndNotify(NotifiableInterface $notifiable) return $notification; } + public function getDropdownNotifications($userId) + { + $config = $this->getConfigurationAndPurge(); + return $this->getUserNotificationsList($userId, 1, $config->getDropdownItems()); + } + + public function getPaginatedNotifications($userId, $page = 1) + { + $config = $this->getConfigurationAndPurge(); + return $this->getUserNotificationsList($userId, $page, $config->getMaxPerPage()); + } + /** * Retrieves the notifications list * @@ -320,8 +359,9 @@ public function getUserNotificationsList($userId, $page = 1, $maxResult = -1, $i ); } - public function getUserNotificationsListRss($rssId, $maxResult) + public function getUserNotificationsListRss($rssId) { + $config = $this->getConfigurationAndPurge(); $notificationUserParameters = $this ->notificationParametersManager ->getParametersByRssId($rssId); @@ -333,7 +373,7 @@ public function getUserNotificationsListRss($rssId, $maxResult) return $this->getUserNotificationsList( $notificationUserParameters->getUserId(), 1, - $maxResult, + $config->getMaxPerPage(), true ); } @@ -375,7 +415,7 @@ protected function renderNotifications($notificationsViews) * @param int $resourceId * @param string $resourceClass * - * @return + * @return null|object */ public function getFollowerResource($userId, $resourceId, $resourceClass) { diff --git a/Manager/NotificationPluginConfigurationManager.php b/Manager/NotificationPluginConfigurationManager.php new file mode 100644 index 0000000..d91ccfd --- /dev/null +++ b/Manager/NotificationPluginConfigurationManager.php @@ -0,0 +1,105 @@ + + * + * Author: Panagiotis TSAVDARIS + * + * Date: 4/14/15 + */ + +namespace Icap\NotificationBundle\Manager; + + +use Doctrine\ORM\EntityManager; +use Icap\NotificationBundle\Entity\NotificationPluginConfiguration; +use Icap\NotificationBundle\Exception\InvalidNotificationFormException; +use JMS\DiExtraBundle\Annotation as DI; +use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\HttpFoundation\Request; + +/** + * Class NotificationPluginConfigurationManager + * @package Icap\NotificationBundle\Manager + * + * @DI\Service("icap.notification.manager.plugin_configuration") + */ +class NotificationPluginConfigurationManager +{ + /** + * @var \Doctrine\ORM\EntityRepository + */ + private $notificationPluginConfigurationRepository; + + /** + * @var \Doctrine\ORM\EntityManager + */ + private $em; + + /** + * @var \Symfony\Component\Form\FormFactoryInterface + */ + private $formFactory; + + /** + * @DI\InjectParams({ + * "em" = @DI\Inject("doctrine.orm.entity_manager"), + * "formFactory" = @DI\Inject("form.factory") + * }) + */ + public function __construct(EntityManager $em, FormFactoryInterface $formFactory) + { + $this->em = $em; + $this->formFactory = $formFactory; + $this->notificationPluginConfigurationRepository = + $em->getRepository("IcapNotificationBundle:NotificationPluginConfiguration"); + } + + /** + * @return NotificationPluginConfiguration|null + */ + public function getConfigOrEmpty() + { + $result = $this->notificationPluginConfigurationRepository->findAll(); + $config = null; + if (count($result) > 0) { + $config = $result[0]; + } else { + $config = new NotificationPluginConfiguration(); + } + + return $config; + } + + /** + * @param NotificationPluginConfiguration $config + * @return \Symfony\Component\Form\FormInterface + */ + public function getForm(NotificationPluginConfiguration $config = null) + { + if ($config === null) $config = $this->getConfigOrEmpty(); + $form = $this->formFactory->create( + 'icap_notification_type_pluginConfiguration', + $config + ); + + return $form; + } + + public function processForm(Request $request) + { + $form = $this->getForm(); + $form->handleRequest($request); + if ($form->isValid()) { + $config = $form->getData(); + $this->em->persist($config); + $this->em->flush(); + + return $form; + } + + throw new InvalidNotificationFormException('invalid_parameters', $form); + } + +} \ No newline at end of file diff --git a/Manager/NotificationUserParametersManager.php b/Manager/NotificationUserParametersManager.php index ea64751..aa1b309 100644 --- a/Manager/NotificationUserParametersManager.php +++ b/Manager/NotificationUserParametersManager.php @@ -12,11 +12,14 @@ namespace Icap\NotificationBundle\Manager; use Claroline\CoreBundle\Entity\User; +use Claroline\CoreBundle\Event\Notification\NotificationUserParametersEvent; use Claroline\CoreBundle\Manager\ResourceManager; use Doctrine\ORM\EntityManager; use Doctrine\ORM\NoResultException; use Icap\NotificationBundle\Entity\NotificationUserParameters; use JMS\DiExtraBundle\Annotation as DI; +use JMS\Serializer\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class NotificationUserParametersManager @@ -24,17 +27,17 @@ * * @DI\Service("icap.notification.manager.notification_user_parameters") */ -class NotificationUserParametersManager { - +class NotificationUserParametersManager +{ /** * @var \Icap\NotificationBundle\Repository\NotificationUserParametersRepository */ private $notificationUserParametersRepository; /** - * @var \Claroline\CoreBundle\Manager\ResourceManager + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface */ - private $resourceManager; + private $ed; /** * @var \Doctrine\ORM\EntityManager @@ -43,14 +46,14 @@ class NotificationUserParametersManager { /** * @DI\InjectParams({ - * "em" = @DI\Inject("doctrine.orm.entity_manager"), - * "resourceManager" = @DI\Inject("claroline.manager.resource_manager") + * "em" = @DI\Inject("doctrine.orm.entity_manager"), + * "ed" = @DI\Inject("event_dispatcher") * }) */ - public function __construct(EntityManager $em, ResourceManager $resourceManager) + public function __construct(EntityManager $em, EventDispatcherInterface $ed) { $this->em = $em; - $this->resourceManager = $resourceManager; + $this->ed = $ed; $this->notificationUserParametersRepository = $em ->getRepository('IcapNotificationBundle:NotificationUserParameters'); } @@ -89,19 +92,13 @@ public function allTypesList(NotificationUserParameters $parameters) { //$typesParams = array(); - //List with all core notifiables - $coreTypes = array( - array("name" => "role-change_right"), - array("name" => "registration-decline"), - array("name" => "role-subscribe"), - array("name" => "badge-award") - ); + $allTypes = array(); - //Get all notifiable resource types - $resourceTypes = $this->resourceManager - ->getAllNotifiableResourceTypeNames(); + $this->ed->dispatch( + 'icap_notification_user_parameters_event', + new NotificationUserParametersEvent($allTypes) + ); - $allTypes = array_merge($coreTypes, $resourceTypes); $visibleTypes = $parameters->getDisplayEnabledTypes(); $rssVisibleTypes = $parameters->getRssEnabledTypes(); foreach ($allTypes as $key => $type) { diff --git a/Migrations/drizzle_pdo_mysql/Version20150414153912.php b/Migrations/drizzle_pdo_mysql/Version20150414153912.php new file mode 100644 index 0000000..0dc5a96 --- /dev/null +++ b/Migrations/drizzle_pdo_mysql/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INT AUTO_INCREMENT NOT NULL, + dropdown_items INT NOT NULL, + max_per_page INT NOT NULL, + purge_enabled BOOLEAN NOT NULL, + purge_after_days INT NOT NULL, + last_purge_date DATETIME DEFAULT NULL, + PRIMARY KEY(id) + ) + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/ibm_db2/Version20150414153912.php b/Migrations/ibm_db2/Version20150414153912.php new file mode 100644 index 0000000..7b2ebeb --- /dev/null +++ b/Migrations/ibm_db2/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, + dropdown_items INTEGER NOT NULL, + max_per_page INTEGER NOT NULL, + purge_enabled SMALLINT NOT NULL, + purge_after_days INTEGER NOT NULL, + last_purge_date TIMESTAMP(0) DEFAULT NULL, + PRIMARY KEY(id) + ) + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/mysqli/Version20150414153912.php b/Migrations/mysqli/Version20150414153912.php new file mode 100644 index 0000000..b2099b9 --- /dev/null +++ b/Migrations/mysqli/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INT AUTO_INCREMENT NOT NULL, + dropdown_items INT NOT NULL, + max_per_page INT NOT NULL, + purge_enabled TINYINT(1) NOT NULL, + purge_after_days INT NOT NULL, + last_purge_date DATETIME DEFAULT NULL, + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/oci8/Version20150414153912.php b/Migrations/oci8/Version20150414153912.php new file mode 100644 index 0000000..415639a --- /dev/null +++ b/Migrations/oci8/Version20150414153912.php @@ -0,0 +1,64 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id NUMBER(10) NOT NULL, + dropdown_items NUMBER(10) NOT NULL, + max_per_page NUMBER(10) NOT NULL, + purge_enabled NUMBER(1) NOT NULL, + purge_after_days NUMBER(10) NOT NULL, + last_purge_date TIMESTAMP(0) DEFAULT NULL, + PRIMARY KEY(id) + ) + "); + $this->addSql(" + DECLARE constraints_Count NUMBER; BEGIN + SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count + FROM USER_CONSTRAINTS + WHERE TABLE_NAME = 'ICAP__NOTIFICATION_PLUGIN_CONFIGURATION' + AND CONSTRAINT_TYPE = 'P'; IF constraints_Count = 0 + OR constraints_Count = '' THEN EXECUTE IMMEDIATE 'ALTER TABLE ICAP__NOTIFICATION_PLUGIN_CONFIGURATION ADD CONSTRAINT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_AI_PK PRIMARY KEY (ID)'; END IF; END; + "); + $this->addSql(" + CREATE SEQUENCE ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 + "); + $this->addSql(" + CREATE TRIGGER ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_AI_PK BEFORE INSERT ON ICAP__NOTIFICATION_PLUGIN_CONFIGURATION FOR EACH ROW DECLARE last_Sequence NUMBER; last_InsertID NUMBER; BEGIN + SELECT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ.NEXTVAL INTO :NEW.ID + FROM DUAL; IF ( + :NEW.ID IS NULL + OR :NEW.ID = 0 + ) THEN + SELECT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ.NEXTVAL INTO :NEW.ID + FROM DUAL; ELSE + SELECT NVL(Last_Number, 0) INTO last_Sequence + FROM User_Sequences + WHERE Sequence_Name = 'ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ'; + SELECT :NEW.ID INTO last_InsertID + FROM DUAL; WHILE (last_InsertID > last_Sequence) LOOP + SELECT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ.NEXTVAL INTO last_Sequence + FROM DUAL; END LOOP; END IF; END; + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/pdo_ibm/Version20150414153912.php b/Migrations/pdo_ibm/Version20150414153912.php new file mode 100644 index 0000000..f94def0 --- /dev/null +++ b/Migrations/pdo_ibm/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, + dropdown_items INTEGER NOT NULL, + max_per_page INTEGER NOT NULL, + purge_enabled SMALLINT NOT NULL, + purge_after_days INTEGER NOT NULL, + last_purge_date TIMESTAMP(0) DEFAULT NULL, + PRIMARY KEY(id) + ) + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/pdo_mysql/Version20150414153912.php b/Migrations/pdo_mysql/Version20150414153912.php new file mode 100644 index 0000000..a2bb7f6 --- /dev/null +++ b/Migrations/pdo_mysql/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INT AUTO_INCREMENT NOT NULL, + dropdown_items INT NOT NULL, + max_per_page INT NOT NULL, + purge_enabled TINYINT(1) NOT NULL, + purge_after_days INT NOT NULL, + last_purge_date DATETIME DEFAULT NULL, + PRIMARY KEY(id) + ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/pdo_oci/Version20150414153912.php b/Migrations/pdo_oci/Version20150414153912.php new file mode 100644 index 0000000..d4d7212 --- /dev/null +++ b/Migrations/pdo_oci/Version20150414153912.php @@ -0,0 +1,64 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id NUMBER(10) NOT NULL, + dropdown_items NUMBER(10) NOT NULL, + max_per_page NUMBER(10) NOT NULL, + purge_enabled NUMBER(1) NOT NULL, + purge_after_days NUMBER(10) NOT NULL, + last_purge_date TIMESTAMP(0) DEFAULT NULL, + PRIMARY KEY(id) + ) + "); + $this->addSql(" + DECLARE constraints_Count NUMBER; BEGIN + SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count + FROM USER_CONSTRAINTS + WHERE TABLE_NAME = 'ICAP__NOTIFICATION_PLUGIN_CONFIGURATION' + AND CONSTRAINT_TYPE = 'P'; IF constraints_Count = 0 + OR constraints_Count = '' THEN EXECUTE IMMEDIATE 'ALTER TABLE ICAP__NOTIFICATION_PLUGIN_CONFIGURATION ADD CONSTRAINT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_AI_PK PRIMARY KEY (ID)'; END IF; END; + "); + $this->addSql(" + CREATE SEQUENCE ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 + "); + $this->addSql(" + CREATE TRIGGER ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_AI_PK BEFORE INSERT ON ICAP__NOTIFICATION_PLUGIN_CONFIGURATION FOR EACH ROW DECLARE last_Sequence NUMBER; last_InsertID NUMBER; BEGIN + SELECT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ.NEXTVAL INTO :NEW.ID + FROM DUAL; IF ( + :NEW.ID IS NULL + OR :NEW.ID = 0 + ) THEN + SELECT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ.NEXTVAL INTO :NEW.ID + FROM DUAL; ELSE + SELECT NVL(Last_Number, 0) INTO last_Sequence + FROM User_Sequences + WHERE Sequence_Name = 'ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ'; + SELECT :NEW.ID INTO last_InsertID + FROM DUAL; WHILE (last_InsertID > last_Sequence) LOOP + SELECT ICAP__NOTIFICATION_PLUGIN_CONFIGURATION_ID_SEQ.NEXTVAL INTO last_Sequence + FROM DUAL; END LOOP; END IF; END; + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/pdo_pgsql/Version20150414153912.php b/Migrations/pdo_pgsql/Version20150414153912.php new file mode 100644 index 0000000..9a2f38e --- /dev/null +++ b/Migrations/pdo_pgsql/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id SERIAL NOT NULL, + dropdown_items INT NOT NULL, + max_per_page INT NOT NULL, + purge_enabled BOOLEAN NOT NULL, + purge_after_days INT NOT NULL, + last_purge_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, + PRIMARY KEY(id) + ) + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/pdo_sqlite/Version20150414153912.php b/Migrations/pdo_sqlite/Version20150414153912.php new file mode 100644 index 0000000..c989c65 --- /dev/null +++ b/Migrations/pdo_sqlite/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INTEGER NOT NULL, + dropdown_items INTEGER NOT NULL, + max_per_page INTEGER NOT NULL, + purge_enabled BOOLEAN NOT NULL, + purge_after_days INTEGER NOT NULL, + last_purge_date DATETIME DEFAULT NULL, + PRIMARY KEY(id) + ) + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/pdo_sqlsrv/Version20150414153912.php b/Migrations/pdo_sqlsrv/Version20150414153912.php new file mode 100644 index 0000000..9ed3872 --- /dev/null +++ b/Migrations/pdo_sqlsrv/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INT IDENTITY NOT NULL, + dropdown_items INT NOT NULL, + max_per_page INT NOT NULL, + purge_enabled BIT NOT NULL, + purge_after_days INT NOT NULL, + last_purge_date DATETIME2(6), + PRIMARY KEY (id) + ) + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/Migrations/sqlsrv/Version20150414153912.php b/Migrations/sqlsrv/Version20150414153912.php new file mode 100644 index 0000000..651e101 --- /dev/null +++ b/Migrations/sqlsrv/Version20150414153912.php @@ -0,0 +1,36 @@ +addSql(" + CREATE TABLE icap__notification_plugin_configuration ( + id INT IDENTITY NOT NULL, + dropdown_items INT NOT NULL, + max_per_page INT NOT NULL, + purge_enabled BIT NOT NULL, + purge_after_days INT NOT NULL, + last_purge_date DATETIME2(6), + PRIMARY KEY (id) + ) + "); + } + + public function down(Schema $schema) + { + $this->addSql(" + DROP TABLE icap__notification_plugin_configuration + "); + } +} \ No newline at end of file diff --git a/README.md b/README.md index da4294e..82e0a4f 100644 --- a/README.md +++ b/README.md @@ -10,21 +10,20 @@ Notification bundle for Claroline Connect. See https://github.com/claroline/Clar Installation ------------------------- -This bundle is a required bundle from CoreBundle. It is needed so the Core can work properly. +This bundle completes the Core bundle. It is needed so the system can generate notifications. -However if you want to install it manually here is the package in composer: +Via composer: `composer require icap/notification-bundle "dev-master"` -Prerequisites +Configuration ------------------------ -* *User* class must provide methods: getId(), getFirstName(), getLastName() and getPicture() (user's avatar) -* *Resource* class must provide methods: getId(), getClass() -* In config.yml the following fields need to be informed: - - default_layout : the layout from which the notification list page will extend (default ClarolineCoreBundle::layout.html.twig) - - max_per_page : the maximum number of notifications per page in notification list page (default 50) - - dropdown_items : the number of notifications present in the dropdown list (default 10) +* After installation, an Notification configuration admin tool has been added which allow as to set the following: + - the maximum number of notifications per page in notification list page (default 50) + - the number of notifications present in the dropdown list (default 10) + - activate the automatic cleanup of notification items after x days + - the number of days after which a notification is deleted How to use in plugins ----------------------------- @@ -52,7 +51,7 @@ In order to integrate and enable notifications in a Claroline connect plugin you 3. Create a domain for translations under translations folder following the name pattern `notification.lang.yml` 4. Under views folder create a `Notification` folder and store inside all views related to notifications' display/rendering. It is recommended to create a general twig file say `notification_item.html.twig` which will extend the `IcapNotificationBundle:Templates:notification.html.twig` template, will render all common elements and include any other necessary template according to the action type. An example is given [here](https://github.com/iCAPLyon1/WikiBundle/blob/master/Resources/views/Notification/notification_item.html.twig) 5. Create listener, for example [`NotificationListener`](https://github.com/iCAPLyon1/WikiBundle/blob/master/Listener/NotificationListener.php) and service e.g. [`listeners.yml`](https://github.com/iCAPLyon1/WikiBundle/blob/master/Resources/config/services/listeners.yml) is the example for WikiBundle -6. (*new) In `config.yml` file set `is_notifiable` to `true` (under your resource configuration) in order to enable notification configuration for your resource. +6. `*new`Create listener, [`NotificationUserParametersListener`](https://github.com/iCAPLyon1/WikiBundle/blob/master/Listener/NotificationUserParametersListener.php) to enable user activate and deactivate the display of your notifications You can find a complete example of these steps in [iCAPLyon1/WikiBundle](https://github.com/iCAPLyon1/WikiBundle) diff --git a/Resources/config/config.yml b/Resources/config/config.yml index b17a80a..8f2d45b 100644 --- a/Resources/config/config.yml +++ b/Resources/config/config.yml @@ -1,4 +1,6 @@ -icap_notification: - default_layout: ClarolineCoreBundle::layout.html.twig - max_per_page: 50 - dropdown_items: 10 +plugin: + has_options: false + + admin_tools: + - name: notification_configuration + class: bell \ No newline at end of file diff --git a/Resources/translations/notification.en.yml b/Resources/translations/notification.en.yml index 3c46bee..4251b33 100644 --- a/Resources/translations/notification.en.yml +++ b/Resources/translations/notification.en.yml @@ -19,10 +19,12 @@ see_more: "See more" zero_notifications: "There are no notifications" notifications_title: "Notifications list" -notification_user_configuration: Notifications configuration +notification_user_configuration: Notification parameters +notification_configuration: Notification configuration rss_visible: Rss feed rss_url_regenerate: Regenerate RSS URL -role-change_right: Resource access -registration-decline: Registration refusal -role-subscribe: New registration -badge-award: Badges +dropdown_items: Items in dropdown list +max_per_page: Items per page +purge_enabled: Remove notifications automatically +purge_after_days: Remove after (days) +purge_explain_text: "*by activating this option, notification history will automatically be deleted according to the value below" diff --git a/Resources/translations/notification.fr.yml b/Resources/translations/notification.fr.yml index dddf8a0..391ee1c 100644 --- a/Resources/translations/notification.fr.yml +++ b/Resources/translations/notification.fr.yml @@ -19,10 +19,12 @@ see_more: "Voir plus" zero_notifications: "Aucune notification" notifications_title: "Liste des notifications" -notification_user_configuration: Configuration des notifications +notification_user_configuration: Paramètres des notifications +notification_configuration: Configuration des notifications rss_visible: Flux RSS rss_url_regenerate: Régénérer l'URL du flux RSS -role-change_right: Accès ressource -registration-decline: Refus d'inscription -role-subscribe: Nouvelle inscription -badge-award: Badges \ No newline at end of file +dropdown_items: Eléments dans la liste +max_per_page: Eléments par page +purge_enabled: Effacement automatique +purge_after_days: Effacer après (jours) +purge_explain_text: "*en activant cette option, l'historique des notification sera effacé automatiquement en fonction de la valeur ci-dessous" \ No newline at end of file diff --git a/Resources/translations/tools.en.yml b/Resources/translations/tools.en.yml new file mode 100644 index 0000000..ea9a5b2 --- /dev/null +++ b/Resources/translations/tools.en.yml @@ -0,0 +1 @@ +notification_configuration: Notification configuration \ No newline at end of file diff --git a/Resources/translations/tools.fr.yml b/Resources/translations/tools.fr.yml new file mode 100644 index 0000000..daa4212 --- /dev/null +++ b/Resources/translations/tools.fr.yml @@ -0,0 +1 @@ +notification_configuration: Configuration des notifications \ No newline at end of file diff --git a/Resources/views/Configuration/config.html.twig b/Resources/views/Configuration/config.html.twig new file mode 100644 index 0000000..6903519 --- /dev/null +++ b/Resources/views/Configuration/config.html.twig @@ -0,0 +1,56 @@ +{% extends "ClarolineCoreBundle:Administration:layout.html.twig" %} + +{% set title = 'notification_configuration' %} + +{% block title %}{{ parent() ~ ' - ' ~ title | trans({}, 'notification') | striptags | raw }}{% endblock %} + + +{% block breadcrumb %} + {{ + macros.breadcrumbs([ + { + 'icon': 'fa fa-cog', + 'name': 'administration'|trans({}, 'platform'), + 'href': path('claro_admin_index') + }, + { + 'name': 'notification_configuration'|trans({}, 'notification'), + 'href': '' + } + ]) + }} +{% endblock %} + +{% block section_content %} +
+

{{ title|trans({}, 'notification') }}

+
+ {{ macros.flashBox() }} +
+
+ {{ form_errors(form) }} +
+
+ {{ form_row(form.dropdownItems) }} + {{ form_row(form.maxPerPage) }} +
+ {{ form_label(form.purgeEnabled) }} +
+ {{ form_widget(form.purgeEnabled) }} + {{ 'purge_explain_text'|trans({}, 'notification') }} +
+
+ {{ form_rest(form) }} +
+
+
+ + + {{ 'cancel'|trans({}, 'platform') }} + +
+
+
+{% endblock %} \ No newline at end of file diff --git a/Resources/views/Notification/list.html.twig b/Resources/views/Notification/list.html.twig index fd93d2f..63da88e 100644 --- a/Resources/views/Notification/list.html.twig +++ b/Resources/views/Notification/list.html.twig @@ -1,4 +1,4 @@ -{% extends layout %} +{% extends "ClarolineCoreBundle:Desktop:layout.html.twig" %} {% block content %}