/**
  * Update notification settings
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function updateAction(Request $request)
 {
     try {
         $id = $this->getUser()->getId();
         /** @var User $oUser */
         $oUser = UserQuery::create()->findOneById($id);
         if ($oUser === null) {
             throw $this->createNotFoundException('Unable to find User entity.');
         }
         $aPost = $request->request->get("form");
         $nbUpdatedRows = UserQuery::create()->filterById($id)->update(array('NotificationError' => isset($aPost['notification_error']), 'NotificationChange' => isset($aPost['notification_change'])));
         $aResult = array("success" => true, "message" => $this->get("translator")->trans("notificationcenter.save.successful"));
     } catch (\Exception $e) {
         $aResult = array("success" => false, "message" => $this->get("translator")->trans("notificationcenter.save.failed") . ":<br>" . $e->getMessage());
     }
     $sResult = json_encode($aResult);
     $response = new Response($sResult);
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Deletes a User entity.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param                                           $id
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \Exception
  * @throws \PropelException
  */
 public function deleteAction(Request $request, $id)
 {
     /** @var User $oUser */
     $oUser = UserQuery::create()->findOneById($id);
     if (count($oUser) === 0) {
         throw $this->createNotFoundException('Unable to find User entity.');
     }
     $oUser->delete();
     return $this->redirect($this->generateUrl('backend_system_user'));
 }
Exemplo n.º 3
0
 /**
  * Returns a new UserQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   UserQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return UserQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof UserQuery) {
         return $criteria;
     }
     $query = new UserQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 /**
  * Get the associated User object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return User The associated User object.
  * @throws PropelException
  */
 public function getUser(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aUser === null && $this->user_id !== null && $doQuery) {
         $this->aUser = UserQuery::create()->findPk($this->user_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aUser->addUserCustomerRelations($this);
            */
     }
     return $this->aUser;
 }
Exemplo n.º 5
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = UserQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }