Example #1
0
 public function executeList($request)
 {
     $page = $request->getParameter('page', 1);
     $num = $request->getParameter('num', 20);
     $q = LsDoctrineQuery::create()->from('UserView v')->leftJoin('v.User u')->orderBy('v.created_at DESC');
     $this->constraints = array();
     if ($userId = $request->getParameter('user_id')) {
         $user = Doctrine::getTable('sfGuardUser')->find($userId);
         $this->constraints[] = 'Limiting to ' . $user->Profile->getFullName();
         $q->addWhere('v.user_id = ?', $userId);
     }
     if (($model = $request->getParameter('object_model')) && ($id = $request->getParameter('object_id'))) {
         if ($object = Objectable::getObjectByModelAndId($model, $id, $includeDeleted = true)) {
             $this->constraints[] = 'Limiting to ' . $object->getName();
         } else {
             $this->constraints[] = 'Limiting to ' . $model . ' ID ' . $id;
         }
         $q->addWhere('v.object_model = ? AND v.object_id = ?', array($model, $id));
     }
     if ($start = $request->getParameter('start')) {
         $start = date('Y-m-d H:i:s', strtotime($start));
         $q->addWhere('v.created_at > ?', $start);
     }
     if ($end = $request->getParameter('end')) {
         $end = date('Y-m-d H:i:s', strtotime($end));
         $q->addWhere('v.created_at < ?', $end);
     }
     $this->view_pager = new LsDoctrinePager($q, $page, $num);
 }
Example #2
0
 public function executeAdd($request)
 {
     $this->checkObject($request);
     if ($parentId = $request->getParameter('parent_id')) {
         $this->parent_comment = Objectable::getObjectByModelAndId('Comment', $parentId);
     }
     $this->comment_form = new CommentForm();
     if ($request->isMethod('post')) {
         $params = $request->getParameter('comment');
         $this->comment_form->bind($params);
         if ($this->comment_form->isValid()) {
             $comment = new Comment();
             $comment->setObject($this->object);
             $comment->user_id = $this->getUser()->getGuardUser()->id;
             $comment->title = $params['title'];
             $comment->body = $params['body'];
             $comment->parent_id = $parentId;
             $comment->save();
             $this->redirect($request->getParameter('module') . '/comments?id=' . $this->object->id);
         }
     }
 }