Loading module/Oscar/config/module.config.php +5 −0 Changes for module/Oscar/config/module.config.php: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -42,6 +42,11 @@ return array( 'roles' => ['user'], ], [ 'controller' => 'Notification', 'action' => ['notifyPerson'], 'roles' => ['user'], ], [ 'controller' => 'Administration', 'action' => ['users', 'roles', 'rolesEdit', "index", "accessAPI", "roleAPI", "userLogs", 'organizationRole', 'organizationRoleApi'], 'roles' => ['user'] Loading module/Oscar/config/routes.yml +2 −2 Changes for module/Oscar/config/routes.yml: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -37,9 +37,9 @@ notification: person: type: segment options: route: /person/:idperson route: /notifyperson/:idperson defaults: action: indexPerson action: notifyPerson # TIMESHEET timesheet: Loading module/Oscar/src/Oscar/Controller/NotificationController.php +54 −0 Changes for module/Oscar/src/Oscar/Controller/NotificationController.php: 54 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ namespace Oscar\Controller; use Oscar\Form\NotificationForm; use Oscar\Service\NotificationService; use Zend\View\Model\JsonModel; Loading Loading @@ -35,10 +36,63 @@ class NotificationController extends AbstractOscarController /** @var NotificationService $notificationService */ $notificationService = $this->getServiceLocator()->get('NotificationService'); if ($this->getHttpXMethod() == "DELETE") { $ids = $this->params()->fromQuery('ids'); if( $ids ){ $ids = explode(',',$ids); try { $notificationService->deleteNotifications($ids); return $this->getResponseOk('Notifications supprimées'); } catch( \Exception $e ){ return $this->getResponseInternalError($e->getMessage()); } } return $this->getResponseInternalError("Impossible de traiter la demande"); } $notifications = $notificationService->getNotificationsPerson($personId); $response = new JsonModel($notifications); return $response; } public function markReadAction() { $ids = $this->params()->fromQuery('ids', ''); } public function deleteAction() { } public function notifyPersonAction() { $method = $this->getHttpXMethod(); $form = new NotificationForm(); $person = $this->getPersonService()->getPerson($this->params()->fromRoute('idperson')); $form->init(); $request = $this->getRequest(); if( $request->isPost() ){ $form->setData($request->getPost()); if( $form->isValid() ) { /** @var NotificationService $serviceNotification */ $serviceNotification = $this->getServiceLocator()->get('NotificationService'); $message = $form->get('message')->getValue(); $serviceNotification->notification($message, [$person->getId()]); die(); } } else { } return [ 'person' => $person, 'form' => $form ]; } } No newline at end of file module/Oscar/src/Oscar/Entity/Notification.php +2 −1 Changes for module/Oscar/src/Oscar/Entity/Notification.php: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -273,7 +273,8 @@ class Notification public function toArray(){ return [ 'dateEffective' => $this->getDateEffective(), 'id' => $this->getId(), 'dateEffective' => $this->getDateEffective()->format('Y-m-d H:i:s'), 'message' => $this->getMessage(), 'context' => $this->getContext(), 'contextId' => $this->getContextId(), Loading module/Oscar/src/Oscar/Form/NotificationForm.php 0 → 100644 +48 −0 Changes for module/Oscar/src/Oscar/Form/NotificationForm.php: 48 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Oscar\Form; use Doctrine\ORM\Query; use Oscar\Entity\DateType; use Oscar\Hydrator\ActivityDateFormHydrator; use Oscar\Hydrator\DateTypeFormHydrator; use UnicaenApp\Service\EntityManagerAwareInterface; use UnicaenApp\Service\EntityManagerAwareTrait; use Zend\Form\Element\Select; use Zend\Form\Form; use Zend\InputFilter\InputFilterProviderInterface; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorAwareTrait; class NotificationForm extends Form { public function init() { // DESCRIPTION $this->add([ 'name' => 'message', 'options' => [ 'label' => "Message" ], 'attributes' => [ 'class' => 'form-control', 'placeholder' => 'Le message', ], 'type'=>'Textarea' ]); $this->add(array( 'name' => 'secure', 'type' => 'Csrf', )); } public function getInputFilterSpecification() { return [ 'message' => [ 'required' => true ] ]; } } No newline at end of file Loading
module/Oscar/config/module.config.php +5 −0 Changes for module/Oscar/config/module.config.php: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -42,6 +42,11 @@ return array( 'roles' => ['user'], ], [ 'controller' => 'Notification', 'action' => ['notifyPerson'], 'roles' => ['user'], ], [ 'controller' => 'Administration', 'action' => ['users', 'roles', 'rolesEdit', "index", "accessAPI", "roleAPI", "userLogs", 'organizationRole', 'organizationRoleApi'], 'roles' => ['user'] Loading
module/Oscar/config/routes.yml +2 −2 Changes for module/Oscar/config/routes.yml: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -37,9 +37,9 @@ notification: person: type: segment options: route: /person/:idperson route: /notifyperson/:idperson defaults: action: indexPerson action: notifyPerson # TIMESHEET timesheet: Loading
module/Oscar/src/Oscar/Controller/NotificationController.php +54 −0 Changes for module/Oscar/src/Oscar/Controller/NotificationController.php: 54 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ namespace Oscar\Controller; use Oscar\Form\NotificationForm; use Oscar\Service\NotificationService; use Zend\View\Model\JsonModel; Loading Loading @@ -35,10 +36,63 @@ class NotificationController extends AbstractOscarController /** @var NotificationService $notificationService */ $notificationService = $this->getServiceLocator()->get('NotificationService'); if ($this->getHttpXMethod() == "DELETE") { $ids = $this->params()->fromQuery('ids'); if( $ids ){ $ids = explode(',',$ids); try { $notificationService->deleteNotifications($ids); return $this->getResponseOk('Notifications supprimées'); } catch( \Exception $e ){ return $this->getResponseInternalError($e->getMessage()); } } return $this->getResponseInternalError("Impossible de traiter la demande"); } $notifications = $notificationService->getNotificationsPerson($personId); $response = new JsonModel($notifications); return $response; } public function markReadAction() { $ids = $this->params()->fromQuery('ids', ''); } public function deleteAction() { } public function notifyPersonAction() { $method = $this->getHttpXMethod(); $form = new NotificationForm(); $person = $this->getPersonService()->getPerson($this->params()->fromRoute('idperson')); $form->init(); $request = $this->getRequest(); if( $request->isPost() ){ $form->setData($request->getPost()); if( $form->isValid() ) { /** @var NotificationService $serviceNotification */ $serviceNotification = $this->getServiceLocator()->get('NotificationService'); $message = $form->get('message')->getValue(); $serviceNotification->notification($message, [$person->getId()]); die(); } } else { } return [ 'person' => $person, 'form' => $form ]; } } No newline at end of file
module/Oscar/src/Oscar/Entity/Notification.php +2 −1 Changes for module/Oscar/src/Oscar/Entity/Notification.php: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -273,7 +273,8 @@ class Notification public function toArray(){ return [ 'dateEffective' => $this->getDateEffective(), 'id' => $this->getId(), 'dateEffective' => $this->getDateEffective()->format('Y-m-d H:i:s'), 'message' => $this->getMessage(), 'context' => $this->getContext(), 'contextId' => $this->getContextId(), Loading
module/Oscar/src/Oscar/Form/NotificationForm.php 0 → 100644 +48 −0 Changes for module/Oscar/src/Oscar/Form/NotificationForm.php: 48 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Oscar\Form; use Doctrine\ORM\Query; use Oscar\Entity\DateType; use Oscar\Hydrator\ActivityDateFormHydrator; use Oscar\Hydrator\DateTypeFormHydrator; use UnicaenApp\Service\EntityManagerAwareInterface; use UnicaenApp\Service\EntityManagerAwareTrait; use Zend\Form\Element\Select; use Zend\Form\Form; use Zend\InputFilter\InputFilterProviderInterface; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorAwareTrait; class NotificationForm extends Form { public function init() { // DESCRIPTION $this->add([ 'name' => 'message', 'options' => [ 'label' => "Message" ], 'attributes' => [ 'class' => 'form-control', 'placeholder' => 'Le message', ], 'type'=>'Textarea' ]); $this->add(array( 'name' => 'secure', 'type' => 'Csrf', )); } public function getInputFilterSpecification() { return [ 'message' => [ 'required' => true ] ]; } } No newline at end of file