Ejemplo n.º 1
0
 /**
  * Save Add Leg's discussion
  * CODE:
  */
 public function executeAddDiscussion(sfWebRequest $request)
 {
     if ($request->isMethod('post')) {
         $com_dis = $request->getParameter('comment_dis');
         $leg_id = $request->getParameter('dis_leg_id');
         if ($com_dis != null && strlen($request->getParameter('comment_dis')) <= 300) {
             if ($leg_id) {
                 $discussion = new Discussion();
                 $discussion->setLegId($leg_id);
                 $discussion->setUserId($this->getUser()->getId());
                 $discussion->setComment($request->getParameter('comment_dis'));
                 $discussion->setIsSplit($request->getParameter('is_split'));
                 $discussion->save();
                 $this->redirect('@request_legs?display=' . $leg_id . '#dis_form' . $leg_id);
             } else {
                 $this->getUser()->setFlash('form_' . $leg_id . '_error', 'Please fill comment to discussion!');
                 $this->redirect('@request_legs?display=' . $leg_id . '#dis_form' . $leg_id);
             }
         } else {
             $this->getUser()->setFlash('error', 'Please fill comment to discussion' . (strlen($request->getParameter('comment_dis')) > 300) ? ' with maximum of 300 characters!' : '!');
             $this->redirect('@request_legs?display=' . $leg_id);
         }
     }
 }