Beispiel #1
0
 /**
  * Edits an existing user group
  *
  * @access public
  * @return void
  */
 public function editAction()
 {
     $this->title = 'Edit user group';
     $form = new GroupForm();
     $groupModel = new Group();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $groupModel->save($form->getValues());
             $this->_helper->FlashMessenger(array('msg-success' => 'The group was successfully edited.'));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/groups/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-success' => 'The provided group_id is invalid.'));
             $this->_redirect('/groups/');
         }
         $row = $groupModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-success' => 'The requested group could not be found.'));
             $this->_redirect('/groups/');
         }
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }