Ejemplo n.º 1
0
 public function getFromProject($_id, $_num = 20)
 {
     $return = null;
     try {
         $db = new DB();
         $items = $db->query("SELECT id\n                FROM " . $this->table . "\n                WHERE project = '{$_id}'\n                    AND replyTo = '0'\n                ORDER BY date DESC LIMIT {$_num}");
         $result = $items->fetchAll();
         if ($result) {
             $return = array();
             foreach ($result as $item) {
                 $obC = new ProjectComment();
                 $return[] = $obC->getFromId($item['id']);
             }
         }
     } catch (PDOException $e) {
         print "Error!: " . $e->getMessage() . "<br/>";
         die;
     }
     return $return;
 }
Ejemplo n.º 2
0
$this->addTwigVars('title', $_project->name() . " -  PH Clone");
switch (@$this->url_var[2]) {
    default:
        if (!empty($_POST) and $_user->logged && isset($_POST['comment'])) {
            $comment = new ProjectComment();
            if (!empty($_POST['reply-to']) && isset($_POST['reply-to'])) {
                $comment->replyTo = (int) addslashes($_POST['reply-to']);
            } else {
                $comment->replyTo = 0;
            }
            $comment->user = $_user->id;
            $comment->language = $this->language;
            $comment->project = $_project->id;
            $comment->date = date('Y-m-d H:i:s', time());
            $comment->comment = htmlentities(strip_tags($_POST['comment']));
            $comment->save();
            $goTo = strip_tags($this->url_var[0]) . '#comment-' . $comment->id;
            header("Location: {$goTo}");
            exit;
        }
        $obC = new ProjectComment();
        $commentsArray = $obC->getFromProject($_project->id);
        $this->addTwigVars('comments', $commentsArray);
        $this->addTwigVars('userVotes', $_project->getUserVotes());
        $template = $this->twig->loadTemplate('projects/project.twig');
        echo $template->render($this->twigVars);
        break;
}
?>

<?php