Security: Remove obsolete actions

refs #5647
This commit is contained in:
Eric Lippmann 2014-11-19 14:44:28 +01:00
parent bd400855e8
commit f0084542e6
1 changed files with 0 additions and 114 deletions

View File

@ -4,12 +4,9 @@
use Icinga\Application\Config;
use Icinga\Forms\ConfirmRemovalForm;
use Icinga\Forms\Security\PermissionForm;
use Icinga\Forms\Security\RestrictionForm;
use Icinga\Forms\Security\RoleForm;
use Icinga\Web\Controller\ActionController;
use Icinga\Web\Notification;
use Icinga\Web\Request;
class SecurityController extends ActionController
{
@ -131,115 +128,4 @@ class SecurityController extends ActionController
$this->view->name = $name;
$this->view->form = $confirmation;
}
public function newRestrictionAction()
{
$restriction = new RestrictionForm(array(
'onSuccess' => function (Request $request, RestrictionForm $restriction) {
$name = $restriction->getElement('name')->getValue();
$values = $restriction->getValues();
try {
$restriction->add($name, $values);
} catch (InvalidArgumentException $e) {
$restriction->addError($e->getMessage());
return false;
}
if ($restriction->save()) {
Notification::success(t('Restriction set'));
return true;
}
return false;
}
));
$restriction
->setIniConfig(Config::app('restrictions', true))
->setRedirectUrl('security')
->handleRequest();
$this->view->form = $restriction;
}
public function updateRestrictionAction()
{
$name = $this->_request->getParam('restriction');
if (empty($name)) {
throw new Zend_Controller_Action_Exception(
sprintf($this->translate('Required parameter \'%s\' missing'), 'restriction'),
400
);
}
$restriction = new RestrictionForm();
try {
$restriction
->setIniConfig(Config::app('restrictions', true))
->load($name);
} catch (InvalidArgumentException $e) {
throw new Zend_Controller_Action_Exception(
$e->getMessage(),
400
);
}
$restriction
->setOnSuccess(function (Request $request, RestrictionForm $restriction) use ($name) {
$oldName = $name;
$name = $restriction->getElement('name')->getValue();
$values = $restriction->getValues();
try {
$restriction->update($name, $values, $oldName);
} catch (InvalidArgumentException $e) {
$restriction->addError($e->getMessage());
return false;
}
if ($restriction->save()) {
Notification::success(t('Restriction set'));
return true;
}
return false;
})
->setRedirectUrl('security')
->handleRequest();
$this->view->name = $name;
$this->view->form = $restriction;
}
public function removeRestrictionAction()
{
$name = $this->_request->getParam('restriction');
if (empty($name)) {
throw new Zend_Controller_Action_Exception(
sprintf($this->translate('Required parameter \'%s\' missing'), 'restriction'),
400
);
}
$restriction = new RestrictionForm();
try {
$restriction
->setIniConfig(Config::app('restrictions', true))
->load($name);
} catch (InvalidArgumentException $e) {
throw new Zend_Controller_Action_Exception(
$e->getMessage(),
400
);
}
$confirmation = new ConfirmRemovalForm(array(
'onSuccess' => function (Request $request, ConfirmRemovalForm $confirmation) use ($name, $restriction) {
try {
$restriction->remove($name);
} catch (InvalidArgumentException $e) {
Notification::error($e->getMessage());
return false;
}
if ($restriction->save()) {
Notification::success(sprintf(t('Restriction \'%s\' has been successfully removed'), $name));
return true;
}
return false;
}
));
$confirmation
->setRedirectUrl('security')
->handleRequest();
$this->view->name = $name;
$this->view->form = $confirmation;
}
}