Пример #1
0
 /**
  * Add a group
  *
  * @view views/scripts/group/add.phtml
  * @access public
  */
 public function addAction()
 {
     $form = new Admin_Form_Group_Add();
     $form->setAction('/noc/admin/group/add');
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
         $this->dbGroups->insert($this->getRequest()->getParam('name'), $this->getRequest()->getParam('description'));
         $this->_redirect('admin/group/index');
     } elseif ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams()) === FALSE) {
         $form->setDescription($form->getErrorMessages());
     }
     $this->view->form = $form;
 }
Пример #2
0
 /**
  * Save a new created group in the Database
  *
  * @return array
  */
 public function saveNewGroupAction()
 {
     $params = Zend_Json_Decoder::decode($this->request->getParam('groups'));
     $groupModel = new Admin_Model_DbTable_Groups();
     $groupRow = $groupModel->fetchRowByGroupName(strtolower($params['name']));
     if (!$groupRow) {
         $groupModel->insert($params['name'], $params['description']);
         return $this->responseSuccess();
     }
     return $this->responseFailure('Failed saving informations', 'The group name is already used');
 }