-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added plugin admin parameters, replaced is_notifiable by listener for…
… user parameters
- Loading branch information
Showing
33 changed files
with
1,175 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* This file is part of the Claroline Connect package | ||
* | ||
* (c) Claroline Consortium <[email protected]> | ||
* | ||
* 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); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?php | ||
/** | ||
* This file is part of the Claroline Connect package | ||
* | ||
* (c) Claroline Consortium <[email protected]> | ||
* | ||
* 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* This file is part of the Claroline Connect package | ||
* | ||
* (c) Claroline Consortium <[email protected]> | ||
* | ||
* 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; | ||
} | ||
} |
Oops, something went wrong.