public function reply()
 {
     $validator = Validator::make(Input::all(), WallPost::$rules);
     if (!$validator->fails()) {
         if ($parent_id = Input::get('parent_id')) {
             $root = WallPost::find($parent_id);
             $post = with(new WallPost())->setChildOf($root);
         } else {
             $post = new WallPost();
             $post->setAsRoot();
         }
         $post->user_id = Auth::user()->id;
         $post->message = Input::get('message');
         if ($post->save()) {
             $this->purgeCache();
             return Response::json(array('status' => 'OK', 'created_at' => $post->created_at->format('c'), 'content' => \Michelf\Markdown::defaultTransform($post->message), 'id' => $post->id));
         } else {
             return Response::json(array('status' => 'KO'));
         }
     } else {
         return Response::json(array('status' => 'KO', 'message' => $validator->messages()));
         //            return Redirect::route('dashboard')->with('mError', 'Il y a des erreurs')->withErrors($validator->messages())->withInput();
     }
 }
Example #2
0
 /**
  * @param sfWebRequest $request
  * @return string
  */
 public function executeActivePinToWall(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $decision_id = $request->getParameter('decision_id', false);
     $this->forward404Unless(is_object(DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id)));
     $type = $request->getParameter('type');
     $this->forward404Unless(in_array($type, array('criteria', 'alternatives', 'cost', 'xy', 'bubble', 'partition', 'cumulative', 'radar')));
     $wall = Doctrine::getTable('Wall')->findOneBy('decision_id', $decision_id);
     $wallPost = new WallPost();
     $wallPost->wall_id = $wall->id;
     $wallPost->type = $type;
     $wallPost->params = json_encode($request->getParameter('params', array()));
     $wallPost->save();
     // Create log
     $log = new Log();
     $log->injectDataAndPersist($wall, $this->getUser()->getGuardUser(), array('type' => $type, 'action' => 'edit'));
     return sfView::NONE;
 }