| @@ 538-575 (lines=38) @@ | ||
| 535 | * add role item |
|
| 536 | * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel |
|
| 537 | */ |
|
| 538 | public function addroleAction() |
|
| 539 | { |
|
| 540 | $tmplVars = $this->getTemplateVars( |
|
| 541 | array( |
|
| 542 | 'acldata' => $this->getAclTable()->fetchAll(), |
|
| 543 | 'roles' => $this->getAclroleTable()->fetchAll(), |
|
| 544 | 'resources' => $this->getAclresourceTable()->fetchAll(), |
|
| 545 | 'showForm' => true, |
|
| 546 | ) |
|
| 547 | ); |
|
| 548 | $form = new AclroleForm(); |
|
| 549 | ||
| 550 | $request = $this->getRequest(); |
|
| 551 | $Aclrole = new Aclrole(); |
|
| 552 | if ($request->isPost()) { |
|
| 553 | $form->setInputFilter($Aclrole->getInputFilter()); |
|
| 554 | $form->setData($request->getPost()); |
|
| 555 | ||
| 556 | if ($form->isValid()) { |
|
| 557 | $Aclrole->exchangeArray($form->getData()); |
|
| 558 | $this->getAclroleTable()->saveAclrole($Aclrole); |
|
| 559 | ||
| 560 | $this->reinitACLCache(); |
|
| 561 | ||
| 562 | // Redirect to list of Acl |
|
| 563 | $this->flashMessenger()->addSuccessMessage($this->translate("role has been saved")); |
|
| 564 | if ( $this->isXHR() ) { |
|
| 565 | $tmplVars["showForm"] = false; |
|
| 566 | } else { |
|
| 567 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'roles')); |
|
| 568 | } |
|
| 569 | } |
|
| 570 | $tmplVars["acl"] = $Aclrole; |
|
| 571 | } |
|
| 572 | $tmplVars["form"] = $form; |
|
| 573 | $tmplVars["roles"] = $this->getAclroleTable()->fetchAll(); |
|
| 574 | return new ViewModel($tmplVars); |
|
| 575 | } |
|
| 576 | ||
| 577 | /** |
|
| 578 | * edit role item |
|
| @@ 690-727 (lines=38) @@ | ||
| 687 | * add resource item |
|
| 688 | * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel |
|
| 689 | */ |
|
| 690 | public function addresourceAction() |
|
| 691 | { |
|
| 692 | $tmplVars = $this->getTemplateVars( |
|
| 693 | array( |
|
| 694 | 'acldata' => $this->getAclTable()->fetchAll(), |
|
| 695 | 'roles' => $this->getAclroleTable()->fetchAll(), |
|
| 696 | 'resources' => $this->getAclresourceTable()->fetchAll(), |
|
| 697 | 'showForm' => true, |
|
| 698 | ) |
|
| 699 | ); |
|
| 700 | $form = new AclresourceForm(); |
|
| 701 | ||
| 702 | $request = $this->getRequest(); |
|
| 703 | $Aclresource = new Aclresource(); |
|
| 704 | if ($request->isPost()) { |
|
| 705 | $form->setInputFilter($Aclresource->getInputFilter()); |
|
| 706 | $form->setData($request->getPost()); |
|
| 707 | ||
| 708 | if ($form->isValid()) { |
|
| 709 | $Aclresource->exchangeArray($form->getData()); |
|
| 710 | $this->getAclresourceTable()->saveAclresource($Aclresource); |
|
| 711 | ||
| 712 | $this->reinitACLCache(); |
|
| 713 | ||
| 714 | // Redirect to list of Acl |
|
| 715 | $this->flashMessenger()->addSuccessMessage($this->translate("resource has been saved")); |
|
| 716 | if ( $this->isXHR() ) { |
|
| 717 | $tmplVars["showForm"] = false; |
|
| 718 | } else { |
|
| 719 | return $this->redirect()->toRoute('admin/acledit', array('action' => 'resources')); |
|
| 720 | } |
|
| 721 | } |
|
| 722 | $tmplVars["aclresource"] = $Aclresource; |
|
| 723 | } |
|
| 724 | $tmplVars["form"] = $form; |
|
| 725 | $tmplVars["resources"] = $this->getAclresourceTable()->fetchAll(); |
|
| 726 | return new ViewModel($tmplVars); |
|
| 727 | } |
|
| 728 | ||
| 729 | /** |
|
| 730 | * edit resource item |
|