Example #1
0
 public function assigntogroupAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id');
     $id = $this->_helper->IdConvert->hexToStr($id);
     $logic = new Logic_User();
     $form = new Logic_User_Form_UserGroupSelect();
     if ($this->getRequest()->isPost()) {
         if ($form->isCancelled($this->getRequest()->getPost())) {
             $this->_helper->redirector('index', 'user', null);
             return;
         }
         if ($form->isValid($request->getPost())) {
             try {
                 $logic->assignToGroup($form, $id);
                 $cache = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager')->getCache('rolecache');
                 $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
                 $this->_helper->redirector('index');
                 //                    $this->_helper->messenger->success('Przypisanie użytkownika do grupy czeka na akceptację.');
                 $this->_helper->messenger->success('Przypisano użytkownika do grupy');
                 return;
             } catch (Logic_User_Exception $e) {
                 $this->_helper->messenger('error', MSG_ERROR, $e);
             }
         }
     } else {
         $data = array();
         try {
             $model = new User();
             $user = $model->findOne($id);
             $data['group'] = $user->id_group;
         } catch (Logic_User_Exception $e) {
             $this->_helper->messenger->error();
             $this->_helper->redirector('index');
             return;
         }
         $form->setDefaults($data);
     }
     $this->view->form = $form;
 }