| @@ 581-631 (lines=51) @@ | ||
| 578 | * edit role item |
|
| 579 | * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel |
|
| 580 | */ |
|
| 581 | public function editroleAction() |
|
| 582 | { |
|
| 583 | $tmplVars = $this->getTemplateVars( |
|
| 584 | array( |
|
| 585 | 'acldata' => $this->getAclTable()->fetchAll(), |
|
| 586 | 'roles' => $this->getAclroleTable()->fetchAll(), |
|
| 587 | 'resources' => $this->getAclresourceTable()->fetchAll(), |
|
| 588 | 'showForm' => true, |
|
| 589 | ) |
|
| 590 | ); |
|
| 591 | $id = (int) $this->params()->fromRoute('acl_id', 0); |
|
| 592 | if (!$id) { |
|
| 593 | $this->flashMessenger()->addWarningMessage($this->translate("missing parameters")); |
|
| 594 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'roles')); |
|
| 595 | } |
|
| 596 | try { |
|
| 597 | $Aclrole = $this->getAclroleTable()->getAclrole($id); |
|
| 598 | } catch (\Exception $e) { |
|
| 599 | $this->flashMessenger()->addWarningMessage($this->translate("invalid parameters")); |
|
| 600 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'roles')); |
|
| 601 | } |
|
| 602 | ||
| 603 | $form = new AclroleForm(); |
|
| 604 | $form->bind($Aclrole); |
|
| 605 | ||
| 606 | $request = $this->getRequest(); |
|
| 607 | if ($request->isPost()) { |
|
| 608 | $form->setInputFilter($Aclrole->getInputFilter()); |
|
| 609 | $form->setData($request->getPost()); |
|
| 610 | ||
| 611 | if ($form->isValid()) { |
|
| 612 | $this->getAclroleTable()->saveAclrole($Aclrole); |
|
| 613 | ||
| 614 | $this->reinitACLCache(); |
|
| 615 | ||
| 616 | // Redirect to list of Acl |
|
| 617 | $this->flashMessenger()->addSuccessMessage($this->translate("role has been saved")); |
|
| 618 | if ( $this->isXHR() ) { |
|
| 619 | $tmplVars["showForm"] = false; |
|
| 620 | } else { |
|
| 621 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'roles')); |
|
| 622 | } |
|
| 623 | } |
|
| 624 | } else { |
|
| 625 | $form->bind($Aclrole); |
|
| 626 | } |
|
| 627 | $tmplVars["acl_id"] = $id; |
|
| 628 | $tmplVars["form"] = $form; |
|
| 629 | $tmplVars["roles"] = $this->getAclroleTable()->fetchAll(); |
|
| 630 | return new ViewModel($tmplVars); |
|
| 631 | } |
|
| 632 | ||
| 633 | /** |
|
| 634 | * delete role item |
|
| @@ 733-784 (lines=52) @@ | ||
| 730 | * edit resource item |
|
| 731 | * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel |
|
| 732 | */ |
|
| 733 | public function editresourceAction() |
|
| 734 | { |
|
| 735 | $tmplVars = $this->getTemplateVars( |
|
| 736 | array( |
|
| 737 | 'acldata' => $this->getAclTable()->fetchAll(), |
|
| 738 | 'roles' => $this->getAclroleTable()->fetchAll(), |
|
| 739 | 'resources' => $this->getAclresourceTable()->fetchAll(), |
|
| 740 | 'showForm' => true, |
|
| 741 | ) |
|
| 742 | ); |
|
| 743 | $id = (int) $this->params()->fromRoute('acl_id', 0); |
|
| 744 | if (!$id) { |
|
| 745 | $this->flashMessenger()->addWarningMessage($this->translate("missing parameters")); |
|
| 746 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'resources')); |
|
| 747 | } |
|
| 748 | try { |
|
| 749 | $Aclresource = $this->getAclresourceTable()->getAclresource($id); |
|
| 750 | } catch (\Exception $e) { |
|
| 751 | $this->flashMessenger()->addWarningMessage($this->translate("invalid parameters")); |
|
| 752 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'resources')); |
|
| 753 | } |
|
| 754 | ||
| 755 | $form = new AclresourceForm(); |
|
| 756 | $form->bind($Aclresource); |
|
| 757 | ||
| 758 | $request = $this->getRequest(); |
|
| 759 | if ($request->isPost()) { |
|
| 760 | $form->setInputFilter($Aclresource->getInputFilter()); |
|
| 761 | $form->setData($request->getPost()); |
|
| 762 | ||
| 763 | if ($form->isValid()) { |
|
| 764 | $this->getAclresourceTable()->saveAclresource($Aclresource); |
|
| 765 | ||
| 766 | $this->reinitACLCache(); |
|
| 767 | ||
| 768 | // Redirect to list of Acl |
|
| 769 | $this->flashMessenger()->addSuccessMessage($this->translate("resource has been saved")); |
|
| 770 | if ( $this->isXHR() ) { |
|
| 771 | $tmplVars["showForm"] = false; |
|
| 772 | } else { |
|
| 773 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'resources')); |
|
| 774 | } |
|
| 775 | } |
|
| 776 | } else { |
|
| 777 | $form->bind($Aclresource); |
|
| 778 | } |
|
| 779 | $tmplVars["acl_id"] = $id; |
|
| 780 | $tmplVars["aclresource"] = $Aclresource; |
|
| 781 | $tmplVars["form"] = $form; |
|
| 782 | $tmplVars["resources"] = $this->getAclresourceTable()->fetchAll(); |
|
| 783 | return new ViewModel($tmplVars); |
|
| 784 | } |
|
| 785 | ||
| 786 | /** |
|
| 787 | * delete resource item |
|