/** * Update * * @param GenericEvent $event * @return void */ public function update(GenericEvent $event) { $comment = $this->commentService->find($event['id']); $article = new \Article($comment->getLanguage()->getId(), $comment->getThread()->getNumber()); $authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread()->getNumber(), $comment->getLanguage()->getId()); $this->emailService->sendCommentNotification($comment, $article, $authors, $this->userService->getCurrentUser()); }
public function indexAction() { $form = new Application_Form_Profile(); $form->setMethod('POST'); $form->setDefaultsFromEntity($this->user); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $values = $form->getValues(); try { if (!empty($values['image'])) { $imageInfo = array_pop($form->image->getFileInfo()); $values['image'] = $this->_helper->service('image')->save($imageInfo); } $this->service->save($values, $this->user); $this->_helper->redirector('index'); } catch (\InvalidArgumentException $e) { switch ($e->getMessage()) { case 'username_conflict': $form->username->addError($this->view->translate("User with given username exists.")); break; default: $form->image->addError($e->getMessage()); break; } } } $this->view->user_first_name = $this->user->getFirstName(); $this->view->user_last_name = $this->user->getLastName(); $this->view->user_email = $this->user->getEmail(); $this->view->form = $form; $this->view->user = new MetaUser($this->user); $this->view->first_time = $this->_getParam('first', false); }
/** * Update audit * * @param GenericEvent $event * @return void */ public function update(GenericEvent $event) { list($resource, $action) = explode('.', $event->getName()); $user = isset($event['user']) ? $event['user'] : $this->userService->getCurrentUser(); $params = $event->getArguments(); $auditEvent = new AuditEvent(); $values = array('user' => $user, 'action' => $action, 'resource_id' => !empty($params['id']) ? $params['id'] : null, 'resource_type' => $resource, 'resource_diff' => !empty($params['diff']) ? $params['diff'] : null, 'resource_title' => !empty($params['title']) ? $params['title'] : null); $this->em->getRepository('Newscoop\\Entity\\AuditEvent')->save($auditEvent, $values); $this->em->flush(); }
/** * Update * * @param GenericEvent $event * * @return void */ public function update(GenericEvent $event) { $comment = $this->commentService->find($event['id']); $article = $this->em->getRepository('Newscoop\\Entity\\Article')->getArticle($comment->getThread(), $comment->getLanguage()->getId())->getSingleResult(); try { $user = $this->userService->getCurrentUser(); } catch (AuthenticationException $e) { $user = null; } $authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread(), $comment->getLanguage()->getId()); $this->emailService->sendCommentNotification($comment, $article, $authors, $user); }
public function testGetPublicUserCount() { $this->assertEquals(0, $this->service->getPublicUserCount()); $this->user->setActive(); $this->em->persist($this->user); $this->em->flush(); $this->assertEquals(0, $this->service->getPublicUserCount()); $this->user->setPublic(); $this->em->flush(); $this->assertEquals(1, $this->service->getPublicUserCount()); }
/** * Get user for given id * * @return Newscoop\Entity\User */ protected function getUser() { $id = $this->_getParam('user', false); if (!$id) { $this->_helper->flashMessenger(array('error', getGS('User id not specified'))); $this->_helper->redirector('index'); } $user = $this->userService->find($id); if (empty($user)) { $this->_helper->flashMessenger(array('error', getGS("User with id '\$1' not found", $id))); $this->_helper->redirector('index'); } return $user; }
public function indexAction() { $translator = Zend_Registry::get('container')->getService('translator'); $form = $this->_helper->form('profile'); $form->setMethod('POST'); $form->setDefaults((array) $this->user->getView()); $form->username->setRequired(false); $form->removeElement('username'); $username = $this->user->getUsername(); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $values = $form->getValues(); $values['username'] = $username; try { if (!empty($values['image'])) { $imageInfo = array_pop($form->image->getFileInfo()); $values['image'] = $this->_helper->service('image')->save($imageInfo); } //TODO add event to subscribe for newsletter $this->service->save($values, $this->user); $this->_helper->flashMessenger->addMessage($translator->trans('Profile saved.', array(), 'users')); $this->_helper->redirector('index'); } catch (\InvalidArgumentException $e) { switch ($e->getMessage()) { case 'username_conflict': $form->username->addError($translator->trans("User with given username exists.")); break; default: $form->image->addError($e->getMessage()); break; } } } $this->view->user = new MetaUser($this->user); $this->view->form = $form; }
/** * Get user for given id * * @return Newscoop\Entity\User */ protected function getUser() { $translator = \Zend_Registry::get('container')->getService('translator'); $id = (int) $this->_getParam('user', false); if (!$id) { $this->_helper->flashMessenger(array('error', $translator->trans('User id not specified', array(), 'users'))); $this->_helper->redirector('index'); } $user = $this->userService->find($id); if (empty($user)) { $this->_helper->flashMessenger(array('error', $translator->trans("User with id \$1 not found", array('$1' => $id), 'users'))); $this->_helper->redirector('index'); } return $user; }