public function testSave()
 {
     $user = new User();
     $user->setUsername('testname');
     $user->setEmail('email');
     $this->em->persist($user);
     $this->em->flush();
     $event = new CommunityTickerEvent();
     $this->repository->save($event, array('event' => 'test.event', 'user' => 1, 'params' => array('param1' => 'value1')));
     $this->em->flush();
     $this->em->clear();
     $this->assertEquals(1, $event->getId());
     $this->assertEquals('test.event', $event->getEvent());
     $this->assertEquals($user, $event->getUser());
     $this->assertEquals(array('param1' => 'value1'), $event->getParams());
 }
Esempio n. 2
0
 public function editAction()
 {
     $role = $this->_getParam('user', false) ? $this->_helper->entity->find('Newscoop\\Entity\\User', $this->_getParam('user')) : $this->_helper->entity->find('Newscoop\\Entity\\User\\Group', $this->_getParam('group'));
     if ($this->getRequest()->isPost()) {
         $values = $this->getRequest()->getPost();
         if ($this->isBlocker($values)) {
             $this->view->error = getGS("You can't deny yourself to manage \$1", $this->getResourceName($this->resource));
             return;
         }
         try {
             $this->ruleRepository->save($values, $this->_getParam('user', false));
         } catch (\Exception $e) {
             $this->view->error = $e->getMessage();
         }
         return;
     }
     $this->view->role = $role;
     $this->view->groups = $this->groups;
     $this->view->resources = $this->resources;
     $this->view->actions = $this->acl->getResources();
     $this->view->actionNames = $this->actions;
     $this->view->acl = $this->getHelper('acl')->getAcl($role);
 }
Esempio n. 3
0
 public function editAction()
 {
     $translator = \Zend_Registry::get('container')->getService('translator');
     $role = $this->_getParam('user', false) ? $this->_helper->entity->find('Newscoop\\Entity\\User', $this->_getParam('user')) : $this->_helper->entity->find('Newscoop\\Entity\\User\\Group', $this->_getParam('group'));
     if ($this->getRequest()->isPost()) {
         $values = $this->getRequest()->getPost();
         if ($this->isBlocker($values)) {
             $this->view->error = $translator->trans("You cant deny yourself to manage \$1", array('$1' => $this->getResourceName($this->resource)), 'user_types');
             return;
         }
         try {
             $this->ruleRepository->save($values, $this->_getParam('user', false));
         } catch (\Exception $e) {
             $this->view->error = $e->getMessage();
         }
         return;
     }
     $this->view->role = $role;
     $this->view->groups = $this->groups;
     $this->view->resources = $this->resources;
     $this->view->actions = $this->acl->getResources();
     $this->view->actionNames = $this->actions;
     $this->view->acl = $this->getHelper('acl')->getAcl($role);
 }