Exemple #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);
 }
Exemple #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);
         }
     }
 }
<?php

$rel = Objectable::getObjectByModelAndIdQuery($object['object_model'], $object['object_id'], true)->leftJoin('relationship.Entity1 e1')->leftJoin('relationship.Entity2 e2')->leftJoin('relationship.Category c')->setHydrationMode(Doctrine::HYDRATE_ARRAY)->fetchOne();
?>

<?php 
//only show modification if relationship wasn't already listed as a merge
if (!in_array($object['object_id'], $holder->get('fromMerges'))) {
    ?>

<tr>
  <td><?php 
    echo $object['created_at'];
    ?>
</td>
  <td><?php 
    echo user_link($object['User']);
    ?>
</td>
  <td><?php 
    echo ModificationTable::getType($object);
    ?>
</td>
  <td>
    <strong>
    <?php 
    if ($rel) {
        ?>
      <?php 
        echo link_to(RelationshipTable::getName($rel), RelationshipTable::generateRoute($rel));
        ?>